示例#1
0
 /**
 		Custom session handler
 			@param $table string
 			@public
 	**/
 function session($table = 'sessions')
 {
     session_set_save_handler(function ($path, $name) {
         register_shutdown_function('session_commit');
         return TRUE;
     }, function () {
         return TRUE;
     }, function ($id) use($table) {
         $jig = new Jig($table);
         $jig->load(array('id' => $id));
         return $jig->dry() ? FALSE : $jig->data;
     }, function ($id, $data) use($table) {
         $jig = new Jig($table);
         $jig->load(array('id' => $id));
         $jig->id = $id;
         $jig->data = $data;
         $jig->stamp = time();
         $jig->save();
         return TRUE;
     }, function ($id) use($table) {
         $jig = new Jig($table);
         $jig->erase(array('id' => $id));
         return TRUE;
     }, function ($max) use($table) {
         $jig = new Jig($table);
         $jig->erase(array('_PHP_' => array('stamp' => function ($stamp) use($max) {
             return $stamp + $max < time();
         })));
         return TRUE;
     });
 }
示例#2
0
 /**
 		Authenticate against Jig-based flat-file database;
 			AUTH global array elements:
 				db:<Jig-database> (default:'DB'),
 				table:<table-name>,
 				id:<userID-field>,
 				pw:<password-field>
 			@return mixed
 			@param $id string
 			@param $pw string
 			@public
 	**/
 static function jig($id, $pw)
 {
     $auth = self::$vars['AUTH'];
     foreach (array('table', 'id', 'pw') as $param) {
         if (!isset($auth[$param])) {
             trigger_error(self::TEXT_AuthSetup);
             return FALSE;
         }
     }
     if (!isset($auth['db'])) {
         $auth['db'] = self::ref('DB');
     }
     $jig = new Jig($auth['table'], $auth['db']);
     $jig->load(array(self::ref('AUTH.id') => $id, self::ref('AUTH.pw') => $pw));
     return $jig->dry() ? FALSE : $jig;
 }