Ejemplo n.º 1
0
 public function __construct($data = NULL)
 {
     if ($data === NULL) {
         $data = $this->cookie();
     }
     if (preg_match("#^[0-9]+\$#", $data)) {
         $this->session_id = $data;
     } elseif (is_scalar($data)) {
         $this->token = $data;
     } else {
         parent::__construct($data);
     }
     try {
         $this->loadBySessionId();
         $this->loadByToken();
     } catch (PDOException $e) {
         $msg = $e->getMessage();
         if (strpos($e, 'no such table') === FALSE) {
             throw $e;
         }
         $this->initialize();
         $this->loadBySessionId();
         $this->loadByToken();
     }
     $this->checksum = $this->checksum();
 }
Ejemplo n.º 2
0
 public function __construct( $data  = NULL, $options = NULL ){
     $options = new GLU( $options );
     if( $data instanceof iterator ) {
         $str = '';
         foreach($data as $v ) $str .= ' ' . $v;
         $data = $str;
     }
     if( is_array( $data ) ) $data = implode(' ', $data );
     $data = preg_split("/[\s,\.\:\/\\\]+/", trim(preg_replace('/[^a-z0-9\s,\.\:\/\\\]/i', '', strtolower($data))));
     $words = array();
     foreach( $data as $word ){
         if( strpos(self::$stopwords, $word . '|') !== FALSE ) continue;
         if( ! $options->disable_stemmer ) $word = PorterStemmer::stem( $word );
         $len = strlen( $word );
         if( $len < 3 || $len > 30 ) continue;
         if( strpos(self::$stopwords, $word . '|') !== FALSE ) continue;
         if( ! isset( $words[ $word ] ) ) $words[ $word ] = 0;
         $words[$word]++;
         if( $len < 6 || $options->disable_soundex ) continue;
         $word = soundex( $word );
         if( ! isset( $words[ $word ] ) ) $words[ $word ] = 0;
         $words[$word]++;
     }
     parent::__construct( $words );
 }
Ejemplo n.º 3
0
 public function __construct($data = NULL)
 {
     if ($data === NULL) {
         return;
     }
     if (is_scalar($data)) {
         if ($this->isUserId($data)) {
             $this->user_id = $data;
         } elseif ($this->isEmail($data)) {
             $this->email = $data;
         } elseif ($this->isNickname($data)) {
             $this->nickname = $data;
         }
     } else {
         parent::__construct($data);
     }
     try {
         $this->load();
     } catch (PDOException $e) {
         $msg = $e->getMessage();
         if (strpos($e, 'no such table') === FALSE) {
             throw $e;
         }
         $this->initialize();
         $this->load();
     }
 }
Ejemplo n.º 4
0
 public function __construct($data = NULL)
 {
     if ($data === NULL) {
         return;
     }
     if (is_scalar($data)) {
         if (preg_match("#^[0-9]+\$#", $data)) {
             $this->entry_id = $data;
         } elseif (preg_match('#^/[0-9]+$#', $data)) {
             $this->entry_id = substr($data, 1);
         } else {
             $this->path = $data;
         }
     } else {
         parent::__construct($data);
     }
     try {
         $this->load();
     } catch (PDOException $e) {
         $msg = $e->getMessage();
         if (strpos($e, 'no such table') === FALSE) {
             throw $e;
         }
         $this->initialize();
         $this->load();
     }
 }
Ejemplo n.º 5
0
 public function __construct($data = NULL)
 {
     if ($data !== NULL) {
         if (is_scalar($data)) {
             $data = array('htpasswd' => $data);
         }
         parent::__construct($data);
     }
     if (!isset($this->realm)) {
         $this->realm = 'Restricted area';
     }
     if (!isset($this->domain)) {
         $this->domain = '/';
     }
 }
Ejemplo n.º 6
0
 public function __construct($data = NULL)
 {
     parent::__construct($data);
     $this->NEW = new Instantiator();
     if (get_magic_quotes_gpc()) {
         foreach ($_REQUEST as $k => $v) {
             if (is_scalar($v)) {
                 $_REQUEST[$k] = stripslashes($v);
             }
         }
         foreach ($_FILES as $k => $v) {
             if (is_scalar($v)) {
                 $_FILES[$k] = stripslashes($v);
             }
         }
         foreach ($_SERVER as $k => $v) {
             if (is_scalar($v)) {
                 $_FILES[$k] = stripslashes($v);
             }
         }
     }
     $this->request = new GLU($_REQUEST);
     foreach ($_FILES as $k => $v) {
         $this->request->{$k} = $v;
     }
     $this->server = new GLU($_SERVER);
     $this->selfurl = rtrim(substr($this->server->SCRIPT_FILENAME, strlen($this->server->DOCUMENT_ROOT)), ' /');
     $this->baseurl = rtrim(substr(dirname($this->server->SCRIPT_FILENAME) . '/', strlen($this->server->DOCUMENT_ROOT)), ' /');
     $path = str_replace($this->selfurl, '', $this->server->REQUEST_URI);
     if (($pos = strpos($path, '?')) !== FALSE) {
         $path = substr($path, 0, $pos);
     }
     $this->path = $path;
     $this->dir = new Dir();
     $this->route = $this->request->route ? $this->request->route : 'display';
     if (substr($this->path, -5) != '.text') {
         return;
     }
     $this->path = substr($this->path, 0, -5);
     if ($this->path == '/index') {
         $this->path = '/';
     }
     $this->route = 'text';
 }
Ejemplo n.º 7
0
 public function __construct( $role = NULL, $data = NULL){
     if( $role instanceof User ){
         $user = $role;
         $role = $user->role;
         if( ! $role ){
             $role = ( $user->user_id ) ? 'user' : 'guest';
         }
         if( $user->user_id == 1 ){
             $data = array('/'=>array('read','write','comment', 'manage'));
         }
     }
 
     
     $this->role = $this->normalizeRole( $role );
     if( is_array( $data ) ) {
         parent::__construct( $data );
         $this->ksort();
         return;
     }
     if( strlen( $this->role ) < 1 ) return;
     $db = $this->db();
     $st = $db->prepare("SELECT path, action FROM access WHERE role = ?");
     try {
         $st->execute(array($role));
     } catch( PDOException $e ){
         $msg =  $e->getMessage();
         if( strpos($e, 'no such table') === FALSE ) throw $e;
         $this->initialize();
         $st->execute(array($role));
     }
     
     $paths = array();
     while( $row = $st->fetch(PDO::FETCH_ASSOC)){
         if( ! isset( $paths[ $row['path'] ] ) )  $paths[ $row['path'] ]= array();
          $paths[ $row['path'] ][] = $row['action'];
     }
     $st->closeCursor();
     foreach( $paths as $path=>$actions ) $this->$path = $actions;
     $this->ksort();
 }