/**
  * If the user is logged in, returns signature URL snippet, in form &signature=SOMETHING.
  * Otherwise, empty string is returned
  */
 public static function get_signature_text()
 {
     global $usr;
     if (is_array($usr)) {
         if (isset($_SESSION['signature'])) {
             $signature = $_SESSION['signature'];
         } else {
             $signature = null;
         }
         if ($signature == null) {
             // TODO grhhh, it's not cryptographically strong RNG
             $signature = sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
             $_SESSION['signature'] = $signature;
         }
         Php7Handler::apc_store($signature, $usr, 3600);
         # cache it for 1 hour
         return '&signature=' . $signature;
     } else {
         return '';
     }
 }
 static function getConfig()
 {
     global $debug_page;
     if (self::$config !== null) {
         return self::$config;
     }
     $useCache = !(isset($debug_page) ? $debug_page : false);
     $cache_key = 'HTMLPurifierConfig';
     $result = $useCache ? Php7Handler::apc_fetch($cache_key) : false;
     if ($result === false) {
         $result = self::createConfig();
         // finalize and lock the config
         $result->getHTMLDefinition();
         $result->getCSSDefinition();
         $result->getURIDefinition();
         if ($useCache) {
             Php7Handler::apc_store($cache_key, $result, 60);
             # cache it for 60 seconds
         }
     }
     return self::$config = $result;
 }
Example #3
0
 public function setEncrypt($encrypt)
 {
     $this->encrypt = Php7Handler::Boolval($encrypt);
     return $this;
 }
Example #4
0
 private function setUserFieldsByUsedDbRow(array $dbRow)
 {
     $cordsPresent = false;
     foreach ($dbRow as $key => $value) {
         switch ($key) {
             case 'user_id':
                 $this->userId = (int) $value;
                 break;
             case 'username':
                 $this->userName = $value;
                 break;
             case 'founds_count':
                 $this->foundGeocachesCount = (int) $value;
                 break;
             case 'notfounds_count':
                 $this->notFoundGeocachesCount = (int) $value;
                 break;
             case 'hidden_count':
                 $this->hiddenGeocachesCount = (int) $value;
                 break;
             case 'email':
                 $this->email = $value;
                 break;
             case 'country':
                 $this->country = $value;
                 break;
             case 'latitude':
             case 'longitude':
                 // lat|lon are handling below
                 $cordsPresent = true;
                 break;
             case 'admin':
                 $this->isAdmin = Php7Handler::Boolval($value);
                 break;
             case 'guru':
                 $this->isGuide = Php7Handler::Boolval($value);
                 break;
             case 'log_notes_count':
                 $this->logNotesCount = $value;
                 break;
                 /* db fields not used in this class yet*/
             /* db fields not used in this class yet*/
             case 'password':
             case 'last_login':
             case 'is_active_flag':
             case 'hide_flag':
             case 'date_created':
             case 'description':
                 // just skip it...
                 break;
             default:
                 error_log(__METHOD__ . ": Unknown column: {$key}");
         }
     }
     // if coordinates are present set the homeCords.
     if ($cordsPresent) {
         $this->homeCoordinates = new \lib\Objects\Coordinates\Coordinates(array('dbRow' => $dbRow));
     }
     $this->dataLoaded = true;
     //mark object as containing data
 }