Skip to content
Snippets Groups Projects
webApi.class.php 1.56 KiB
Newer Older
<?php

class webAPI
{
    public function __construct()
    {
        // if(php_sapi_name() == 'cli') {
        //     global $__site_config;
        //     $__site_config = file_get_contents("/home/Lucifer/photogramconfig.json");

        // } elseif(php_sapi_name() == 'apache2handler') {
        //     global $__site_config;
        //     $__site_config = file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/../photogramconfig.json");
        // }
        global $__site_config;
        $__site_config_path =  __DIR__ . "/../../../project/photogramconfig.json";
        $__site_config = file_get_contents($__site_config_path);
        database::getconnetion();
        /* Here now anything it migh be either cli or apache our path will not change since everthing is configured
        inside our htdocs previously we needed to hard code the loaction to cli and apache2 using _server and complete
        location for CLI but now the issue got resolved*/

    }

    /* intitateSession
       1. starts the session
       2. authorizes the session token stored in sessions
       3. stores the authorized session into a new session variable for later access*/
    public function initiateSession()
    {
        sessions::start();
        if (sessions::isset('session_token')) {
            try {
                /* Authorizing users session and storing it in a static variable */
                sessions::$userSession = userSession::authorize(sessions::get('session_token'));
            } catch (Exception $e) {
                TODO://make changes in the exception
            }
        }