Example #1
0
 public function __construct()
 {
     parent::__construct();
     $sid = F::i('Cookie')->get('sid');
     $ip = $_SERVER['REMOTE_ADDR'];
     $check = FALSE;
     try {
         $check = $this->checkSid($sid);
     } catch (BadSIDException $e) {
         // Hacking attempt... Say no and log !
         $check = FALSE;
         Record::note($e->__toString());
     } catch (NullSIDException $e) {
         // Nothing important...
         $check = FALSE;
     }
     // If DatabaseException is raised, it's more important, let it throws !
     // If Check return FALSE, sid is incorrect !
     if (!$check) {
         // Create a new session
         // 0.00000000000000000000000000000000000000001
         // chance of having 2 sessions with the same id !
         // I hope never happen
         $sid = $this->generateID();
         $this->mid = _ID_VISITOR;
         // Register it
         F::i(_DBMS_SYS)->exec('INSERT INTO !prefix_sessions (s_id, m_id, v_ip, s_date) VALUES (?, ?, ?, NOW())', array($sid, $this->mid, ip2long($ip)));
     } else {
         // Update it
         F::i(_DBMS_SYS)->exec('UPDATE !prefix_sessions SET s_date=NOW() WHERE s_id = ?', array($sid));
         $result = F::i(_DBMS_SYS)->query('SELECT m.m_id, m.m_auth FROM !prefix_sessions s, !prefix_members m WHERE m.m_id = s.m_id AND s.s_id = ?', array($sid));
         $obj = $result->getObject();
         if ($obj !== NULL) {
             $this->mid = intval($obj->m_id);
             $this->auth = intval($obj->m_auth);
         }
     }
     $this->setSID($sid);
 }
Example #2
0
 public static function handlerError($errno, $errstr, $errfile, $errline)
 {
     $errnum = NULL;
     switch ($errno) {
         case E_NOTICE:
         case E_USER_NOTICE:
         case E_STRICT:
             $message = Tools::generateErrorMessage($errno, $errstr, $errfile, $errline, 'Notice: ');
             break;
         case E_WARNING:
         case E_USER_WARNING:
             $message = Tools::generateErrorMessage($errno, $errstr, $errfile, $errline, 'Warning: ');
             break;
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
             $message = Tools::generateErrorMessage($errno, $errstr, $errfile, $errline, 'Deprecated: ');
             break;
         case E_USER_ERROR:
         case E_RECOVERABLE_ERROR:
             $message = Tools::generateErrorMessage($errno, $errstr, $errfile, $errline, 'Error: ');
             $errnum = Record::note($message);
             break;
         default:
             $message = Tools::generateErrorMessage($errno, $errstr, $errfile, $errline, 'Unknown ' . $errno . ': ');
             $errnum = Record::note($message);
     }
     if (!is_null($errnum)) {
         die('Error n° ' . $errnum);
     }
     // Show the name of the file
     if (_DEBUG) {
         echo $message;
     }
     return TRUE;
     // Ok PHP ! We manage successfully this error, do not manage it again
 }
Example #3
0
        exit;
    }
    F::i('Session')->close();
    $output = Tools::parseOutput($output);
    if (!_DEBUG) {
        ob_end_clean();
    }
} catch (DatabaseException $e) {
    Record::note($e->__toString());
    die('DB Error : ' . $e->getMessage());
} catch (SessionException $e) {
    // Hacking attempt
    Record::note($e->__toString());
    die('Hacking Attempt : ' . $e->getMessage());
} catch (ControllerException $e) {
    // Bad Access
    Record::note($e->__toString());
    die('Bad Access : ' . $e->getMessage());
} catch (ModelException $e) {
    // Error while generating
    Record::note($e->__toString());
    die('Error while generating : ' . $e->getMessage());
} catch (ViewException $e) {
    // Error while displaying
    Record::note($e->__toString());
    die('Error while displaying : ' . $e->getMessage());
} catch (Exception $e) {
    // Unexpected Exception so STOP !
    trigger_error('Unexcepted Exception : ' . $e->__toString(), E_USER_ERROR);
}
echo $output;