Example #1
0
 /**
  * Loads session.
  * @since 1.0.0
  *
  * @param string $options Filename as options.
  *
  * @return object Session.
  */
 public static function load($options)
 {
     if (!isset(static::$filename)) {
         static::$filename = $options;
     }
     $sess = new self();
     if (file_exists($options)) {
         $sess->read($options);
     }
     return $sess;
 }
 /**
  * Get settings instance
  * 
  * @return ilObjDiskQuotaSettings
  */
 public static function getInstance()
 {
     global $ilDB;
     $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data " . "WHERE tree.parent = " . $ilDB->quote(SYSTEM_FOLDER_ID, 'integer') . " " . "AND object_data.type = " . $ilDB->quote('facs', 'text') . "AND object_reference.ref_id = tree.child " . "AND object_reference.obj_id = object_data.obj_id";
     $res = $ilDB->query($query);
     $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
     $ref_id = $row["ref_id"];
     if ($ref_id) {
         $obj = new self($ref_id);
         $obj->read();
         return $obj;
     }
 }
Example #3
0
 /**
  * @param shibServerData $shibServerData
  *
  * @return shibUser
  */
 public static function buildInstance(shibServerData $shibServerData)
 {
     $shibUser = new self();
     $shibUser->shibServerData = $shibServerData;
     $ext_id = $shibUser->shibServerData->getLogin();
     $shibUser->setExternalAccount($ext_id);
     $existing_usr_id = self::getUsrIdByExtId($ext_id);
     if ($existing_usr_id) {
         $shibUser->setId($existing_usr_id);
         $shibUser->read();
     }
     $shibUser->setAuthMode('shibboleth');
     return $shibUser;
 }
Example #4
0
 /**
  * Short description for 'getInstance'
  *
  * Long description (if any) ...
  *
  * @param	  unknown $instance Parameter description (if any) ...
  * @return	 mixed Return description (if any) ...
  */
 public static function getInstance($instance)
 {
     $hztv = new self();
     if ($hztv->read($instance) === false) {
         return false;
     }
     return $hztv;
 }
Example #5
0
 static function __init()
 {
     self::$savePath = $CONFIG['session.save_path'];
     self::$cookiePath = $CONFIG['session.cookie_path'];
     self::$cookieDomain = $CONFIG['session.cookie_domain'];
     $CONFIG['session.auth_vars'] && (self::$authVars = array_merge(self::$authVars, $CONFIG['session.auth_vars']));
     $CONFIG['session.group_vars'] && (self::$groupVars = array_merge(self::$groupVars, $CONFIG['session.group_vars']));
     self::$authVars = array_flip(self::$authVars);
     self::$groupVars = array_flip(self::$groupVars);
     if (self::$maxIdleTime < 1 && self::$maxLifeTime < 1) {
         user_error('At least one of the SESSION::$max*Time variables must be strictly positive.');
     }
     if (mt_rand(1, self::$gcProbabilityDenominator) <= self::$gcProbabilityNumerator) {
         $adapter = new self('0lastGC');
         $i = $adapter->read();
         $j = max(self::$maxIdleTime, self::$maxLifeTime);
         if ($j && $_SERVER['REQUEST_TIME'] - $i > $j) {
             $adapter->write($_SERVER['REQUEST_TIME']);
             register_shutdown_function(array(__CLASS__, 'gc'), $j);
         }
         unset($adapter);
     }
     if (isset($_COOKIE['SID'])) {
         self::setSID($_COOKIE['SID']);
         self::$adapter = new self(self::$SID);
         $i = self::$adapter->read();
     } else {
         $i = false;
     }
     if ($i) {
         $i = unserialize($i);
         self::$lastseen = $i[0];
         self::$birthtime = $i[1];
         if (self::$maxIdleTime && $_SERVER['REQUEST_TIME'] - self::$lastseen > self::$maxIdleTime) {
             // Session has idled
             self::onIdle();
             self::$isIdled = true;
         } else {
             if (self::$maxLifeTime && $_SERVER['REQUEST_TIME'] - self::$birthtime > self::$maxLifeTime) {
                 // Session has expired
                 self::onExpire();
             } else {
                 self::$DATA =& $i[2];
             }
         }
         if (isset($_SERVER['HTTPS']) && (!isset($_COOKIE['SSL']) || $i[3] != $_COOKIE['SSL'])) {
             self::regenerateId(true);
         } else {
             self::$sslid = $i[3];
             if ('-' == self::$sslid[0] && isset($_SERVER['HTTPS'])) {
                 self::$sslid = p::strongId();
                 setcookie('SSL', self::$sslid, 0, self::$cookiePath, self::$cookieDomain, true, true);
                 unset($_SERVER['HTTP_IF_NONE_MATCH'], $_SERVER['HTTP_IF_MODIFIED_SINCE']);
             }
         }
     } else {
         self::regenerateId(true);
     }
 }
Example #6
0
 /**
  * Fine a specific record, or create it
  * if not found
  *
  * @param   string  $type
  * @param   string  $authenticator
  * @param   string  $domain
  * @return  mixed
  */
 public static function find_or_create($type, $authenticator, $domain = null)
 {
     $hzad = new self();
     $hzad->type = $type;
     $hzad->authenticator = $authenticator;
     $hzad->domain = $domain;
     $hzad->read();
     if (empty($hzad->id) && !$hzad->create()) {
         return false;
     }
     return $hzad;
 }
Example #7
0
 /**
  * Find a record, creating it if not found.
  *
  * @param   string  $type
  * @param   string  $authenticator
  * @param   string  $domain
  * @param   string  $username
  * @return  mixed   Object on success, False on failure
  */
 public static function find_or_create($type, $authenticator, $domain, $username)
 {
     $hzad = Domain::find_or_create($type, $authenticator, $domain);
     if (!is_object($hzad)) {
         return false;
     }
     if (empty($username)) {
         return false;
     }
     $hzal = new self();
     $hzal->username = $username;
     $hzal->auth_domain_id = $hzad->id;
     $hzal->read();
     if (empty($hzal->id) && !$hzal->create()) {
         return false;
     }
     return $hzal;
 }
 /**
  * @param string      $cachePath
  * @param FileScanner $scanner
  * @return CachingFileScanner
  */
 public static function create($cachePath, FileScanner $scanner)
 {
     $self = new self($cachePath, $scanner);
     $self->read();
     return $self;
 }
Example #9
0
 static function saveValue($k, $v)
 {
     $config = new self();
     $config->read();
     $config->set($k, $v);
     $config->save();
 }
Example #10
0
 /**
  * Loads a WKT string into a Geometry Object
  *
  * @param string $WKT
  *
  * @return Geometry\Geometry
  */
 public static function load($WKT)
 {
     $instance = new self();
     return $instance->read($WKT);
 }
Example #11
0
 /**
  * Short description for 'getInstance' Long description (if any) . ..
  *
  * @param   unknown $instance Parameter description (if any) ...
  * @param   unknown $storage Parameter description (if any) ...
  * @return  mixed Return description (if any) ...
  */
 public static function getInstance($instance, $storage = null)
 {
     $hzup = new self();
     if ($hzup->read($instance) === false) {
         return false;
     }
     return $hzup;
 }
Example #12
0
 /**
  * Returns a reference to a group object
  *
  * @param   mixed  $group  A string (cn) or integer (ID)
  * @return  mixed  Object if instance found, false if not
  */
 public static function getInstance($group)
 {
     static $instances;
     // Set instances array
     if (!isset($instances)) {
         $instances = array();
     }
     // Do we have a matching instance?
     if (!isset($instances[$group])) {
         // If an ID is passed, check for a match in existing instances
         if (is_numeric($group)) {
             foreach ($instances as $instance) {
                 if ($instance && $instance->get('gidNumber') == $group) {
                     // Match found
                     return $instance;
                     break;
                 }
             }
         }
         // No matches
         // Create group object
         $hzg = new self();
         if ($hzg->read($group) === false) {
             $instances[$group] = false;
         } else {
             $instances[$group] = $hzg;
         }
     }
     // Return instance
     return $instances[$group];
 }
Example #13
0
 /**
  * Cleanup expired cache entries.
  */
 private static function file_gc()
 {
     $dir = new DirectoryIterator(\Sledgehammer\TMP_DIR . 'Cache');
     $files = [];
     foreach ($dir as $entry) {
         if ($entry->isFile()) {
             $files[] = $entry->getFilename();
         }
     }
     shuffle($files);
     $files = array_slice($files, 0, ceil(count($files) / 10));
     // Take 10% of the files
     $cache = new self('GC', 'file');
     foreach ($files as $id) {
         $cache->_guid = $id;
         $cache->_file = fopen(\Sledgehammer\TMP_DIR . 'Cache/' . $id, 'r');
         $hit = $cache->read($output);
         fclose($cache->_file);
         $cache->_file = null;
         if ($hit === false) {
             // Expired?
             $cache->clear();
         }
     }
 }
Example #14
0
 /**
  * Find a project. Create it if one doesn't exist.
  *
  * @param   string  $name  Project name
  * @return  mixed
  */
 public static function find_or_create($name)
 {
     $hztp = new self();
     if (is_numeric($name)) {
         $hztp->id = $name;
     } else {
         $hztp->name = $name;
     }
     if ($hztp->read() == false) {
         if ($hztp->create() == false) {
             return false;
         }
     }
     return $hztp;
 }