Exemplo n.º 1
0
 function __construct($conf)
 {
     Trace::add_trace('construct class', __METHOD__);
     self::$conf = $conf;
     self::$conn = new DB($conf);
     $this->Func = new Func();
 }
Exemplo n.º 2
0
 /** Load Dictionary
  * 
  * @param Array $load - Dictionary array 
  * 
  */
 public static function load($load)
 {
     Trace::add_trace('construct class', __METHOD__);
     self::$dic = isset($load['dic']) ? $load['dic'] : array();
     self::$hooks = isset($load['js']) ? $load['js'] : array();
     self::$lang = isset($load['lang']) ? $load['lang'] : array();
 }
Exemplo n.º 3
0
 /** Generate login session token
  * 
  * @param string $pass
  * @return string
  */
 public function generate_login_session($pass)
 {
     Trace::add_trace('generate login session request', __METHOD__);
     return md5($pass . date("Y-m-d H:i:s"));
 }
Exemplo n.º 4
0
 /** Set page target name 
  * 
  * @return boolean
  */
 public function target()
 {
     Trace::add_trace('get page target', __METHOD__);
     $target = $this->Func->filter_var(filter_input(INPUT_GET, 'page'));
     if (!is_null($target) && $target) {
         $this->target = $target;
         return true;
     }
     $this->target = false;
     return false;
 }
Exemplo n.º 5
0
/************************* Page Target and token ******************************/
Trace::add_step(__FILE__, "Set Target and Page Token");
$Page->target();
if ($User->user_loged) {
    $Page->token = $User->sess_save["sess"];
}
Trace::add_trace("Page parsed target", __FILE__, array("target" => $Page->target));
Trace::add_trace("Page token", __FILE__, array("token" => $Page->token));
/**************************** Secure Request  *********************************/
Trace::add_step(__FILE__, "Secure Request Handler");
$request = $Page->Func->synth($_POST, array("req", "token"));
if ($User->user_loged && $request["req"] !== "" && $request["token"] === $User->sess_save["sess"]) {
    Trace::add_trace("Secure request detected.", __FILE__, $request);
    switch ($request["req"]) {
        case "api":
            Trace::add_trace("Loading Api Request", __FILE__);
            $Page->secure = true;
            $Page->target = "api";
            break;
        default:
            die("E:01");
    }
}
/****************************** Page Loader ***********************************/
switch ($Page->target) {
    case "api":
        Trace::add_step(__FILE__, "Load secure api");
        if ($Page->secure) {
            include_once PATH_CLASSES . "Api.class.php";
            include_once PATH_PAGES . "api.php";
        } else {
Exemplo n.º 6
0
 private function save_db_errors($error, $query)
 {
     Trace::add_trace('Run DB save error', __METHOD__);
     if (getenv("HTTP_X_FORWARDED_FOR") && getenv("HTTP_X_FORWARDED_FOR") !== "") {
         $IP = getenv("HTTP_X_FORWARDED_FOR");
         $proxy = getenv("REMOTE_ADDR");
         $host = gethostbyaddr(getenv("HTTP_X_FORWARDED_FOR"));
     } else {
         $IP = getenv("REMOTE_ADDR");
         $proxy = "No proxy detected";
         $host = gethostbyaddr(getenv("REMOTE_ADDR"));
     }
     if (!$IP || $IP === '' || $IP === null) {
         $IP = 'cant';
     }
     if (!$proxy || $proxy === '' || $proxy === null) {
         $proxy = 'cant';
     }
     if (!$host || $host === '' || $host === null) {
         $host = 'cant';
     }
     $this->insert_safe($this->filter(LOG_DB_TO_TABLE), array('page' => basename($_SERVER['PHP_SELF']), 'user_ip' => $IP, 'proxy' => $proxy, 'host' => $host, 'sql_message' => $error, 'query_used' => $query), false);
 }
Exemplo n.º 7
0
 public function __construct()
 {
     Trace::add_trace('construct class', __METHOD__);
 }
Exemplo n.º 8
0
 /** Constructor
  * 
  *  @param array $conf
  * 
  */
 public function __construct($conf)
 {
     parent::__construct($conf);
     Trace::add_trace('construct class', __METHOD__);
 }
Exemplo n.º 9
0
 /** Random string generator
  * 
  * @param int $length
  * @return string
  * 
  */
 public function rand_string($length = 10)
 {
     Trace::add_trace('rand string', __METHOD__);
     $ch = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $chLength = strlen($ch);
     $rand = '';
     for ($i = 0; $i < $length; $i++) {
         $rand .= $ch[rand(0, $chLength - 1)];
     }
     return $rand;
 }