Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     // Need to call the parent so data is correct
     $skip = array('ipp', 'page', 'PHPSESSID', 'go', 'load_data');
     if ($this->short_url === true) {
         $skip[] = 'route';
         $skip[] = 'm';
     }
     $this->url_vars = "go=1" . $this->get_globals($skip);
     $this->ipp = isset($_REQUEST['ipp']) ? $_REQUEST['ipp'] : '';
     $this->page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
     $this->current_page = 1;
     $this->mid_range = 7;
     if (!empty($_SERVER['REQUEST_URI'])) {
         $pos = strpos($_SERVER['REQUEST_URI'], "?");
         if ($pos === false) {
             // note: three equal signs
             // ? not found...
             $this->server_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "?";
         } else {
             $this->server_url = 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, $pos) . "?";
         }
     } else {
         /**
          * @todo make ipp and page arg checking
          */
         $this->server_url = '';
     }
 }
Ejemplo n.º 2
0
 /**
  * Model constructor
  *
  * Must pass table name and primary key from child class
  * @method __construct
  * @param $options of database
  * @return void
  */
 public function __construct($options)
 {
     $this->db_cache = $this->get_cache();
     $this->table = isset($options['table']) ? $options['table'] : $options;
     $default_key = isset($options['primary_key']) ? $options['primary_key'] : 'id';
     $primary_key = isset($options['key']) ? $options['key'] : $default_key;
     $db_socket = defined('CX_DB_SOCKET') ? CX_DB_SOCKET : '';
     try {
         if (!empty($db_socket)) {
             $this->connect_database(CX_DB_TYPE . ':unix_socket=' . CX_DB_SOCKET . ';dbname=' . CX_DB_NAME, CX_DB_USER, CX_DB_PASS);
         } else {
             $this->connect_database(CX_DB_TYPE . ':host=' . CX_DB_HOST . ';port=' . CX_DB_PORT . ';dbname=' . CX_DB_NAME, CX_DB_USER, CX_DB_PASS);
         }
     } catch (PDOException $e) {
         $error = 'Failed to connect to Database! ' . $e->getMessage();
         cx_email_error('The Database is DOWN!!!' . $error);
         if (defined('CX_LIVE') && CX_LIVE === true) {
             cx_global_error_handler();
             exit;
         } else {
             echo "The Database is down!!! {$error}";
             exit;
         }
     } catch (Exception $e) {
         $error = 'Failed to connect to Database! ' . $e->getMessage();
         cx_email_error('The Database is DOWN!!!' . $error);
         if (defined('CX_LIVE') && CX_LIVE === true) {
             cx_global_error_handler();
             exit;
         } else {
             echo "The Database is down!!! {$error}";
             exit;
         }
     }
     $this->primary_key = $primary_key;
     $this->generate_members();
     parent::__construct();
 }