0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.133.155.253


Current Path : /var/www/html/collportal/src/
Upload File :
Current File : //var/www/html/collportal/src/cappcontext.php

<?php
  require_once("cconfig.php");
  require_once(APP_DB_G . "/adodb.inc.php");
  require_once(APP_DB_G . "/tohtml.inc.php");
  require_once(APP_DB_G . "/toexport.inc.php");
  require_once(APP_SRC_G . "/crequestbroker.php");
  require_once(APP_SRC_G . "/csessions.php");
  require_once(APP_SRC_G . "/coutput.php");
  require_once(APP_SRC_G . "/cuser.php");
  // require_once(APP_SRC_G . "/jwt.php");
  // require_once(APP_SRC_G . "/constants.php");


  
  class CApplicationContext
  {
    public $mobj_config;  #Config Object
    public $mobj_db;      #Adodb Object
    public $mobj_orb;     #Request Broker - Singleton Class with static functions    
    public $mobj_user;    #User Object
    public $mobj_data;    #Data 
    public $mobj_output;  #Output stream
    public $main_src;   
    #public $mobj_logger; #Logger stream
        
    function __construct()
    {                                   
     }    
    function Initialize()
    {
      # all the contained object creations happen here and not in the constructor
      # this is to avoid exceptions during object creation
      header("Access-Control-Allow-Origin: *");
      header('Content-Type: application/json');
      header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
      header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, x-auth-origin, x-auth-token, x-auth-type");
      # 06. Input - Init
      $this->mobj_data = $_REQUEST;
      # 01. Create the Config Object
      $this->mobj_config = new CConfig( isset($this->mobj_data["dbg"]) );

      if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
        die();
      }
      # 02. Create the DB Object
      $this->mobj_db = ADONewConnection("mysqli"); # by default we connect to mysql
      $this->mobj_db->debug = $this->mobj_config->mbool_debug;
      $lbool_res = $this->mobj_db->Connect($this->mobj_config->mstr_host, $this->mobj_config->mstr_user, $this->mobj_config->mstr_password, $this->mobj_config->mstr_db);
      date_default_timezone_set("Asia/Calcutta");

      // $headers = getallheaders();
      
      // $this->headers = $headers;
      // $origin = $headers["X-Auth-Origin"];
      // $type = $headers["X-Auth-Type"];

      // $_SESSION['user_id'] = "ABCD";

      // if ($origin == 'UNICLARE') {
      //   $token = $headers["Authorization"];
        
      //   try {
      //     $payload = JWT::decode($token, SECRETE_KEY, ['HS256']);
      //     $_SESSION['user_id'] = $payload->userId;
      //   } catch (Exception $e) {
      //     throwError(ACCESS_TOKEN_ERRORS, $e->getMessage());
      //     die();
      //   }
      // }

      # 03. Create the Request Broker
      $this->mobj_orb = CRequestBroker::GetInstance();
      /* Actions to be registered in mregistry.php
       */
      
      # 04. Sessions
      CSessions::Initialize();

      # 07. Output - Init
      $this->mobj_output = new COutput();
      $this->mobj_output->Initialize();
      
      # 05. User
    //   $this->mobj_user = CSessions::GetUser();
	  //  $this->mobj_user = CSessions::GetUser();
	   //$sess_obj=NEW CSessions();
	   // $this->mobj_user = $sess_obj->GetUserManual();
      // if (!isset($this->mobj_user))
      //   $this->mobj_user = new CUser($this); 
		# to get the main source

    // var_dump($main_src);die();
    
		$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
		 $this->main_src=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-7);
		//$this->main_src=$_SERVER["DOCUMENT_ROOT"]."/".$main_src_obj[1];	
       }   

    function __destruct()
    {
      # though php closes the db, it is good practice to do it ourselves explicitely once
      # $this->mobj_db->Close();
      unset($this->mobj_db);
      unset($this->mobj_config);
    } 
  }