/** * Returns information about the aggregate of photos on the site * * @access public * @return array */ public function getCounts() { $this->counts['albums'] = Database::selectOne('albums', 'COUNT(*)'); $this->counts['topics'] = Database::selectOne('albums', 'COUNT(DISTINCT topic)'); $this->counts['photos'] = Database::selectOne('photos', 'COUNT(*)'); $this->counts['pixels'] = Database::selectOne('photos', 'SUM(width*height)'); $this->counts['albumhits'] = Database::selectOne('albums', 'SUM(hits)'); $this->counts['photohits'] = Database::selectOne('photos', 'SUM(hits)'); $this->counts['maxphotohits'] = Database::selectOne('photos', 'MAX(hits)'); $this->counts['maxalbumhits'] = Database::selectOne('albums', 'MAX(hits)'); $this->counts['daysonline'] = floor((time() - strtotime(Preferences::valueForModuleWithKey('CameraLife', 'sitedate'))) / 86400); return $this->counts; }
/** * fileStoreWithName function. * * @access public * @param string $name -- 'photo' or 'other' * @return void */ public static function fileStoreWithName($name) { $retval = new FileStore(); $path = null; if ($name == 'photo') { $path = Preferences::valueForModuleWithKey('LocalFileStore', 'photo_dir'); } elseif ($name = 'other') { $path = Preferences::valueForModuleWithKey('LocalFileStore', 'cache_dir'); } else { throw new \Exception('Bad FileStore name'); } if (!realpath($path)) { throw new \Exception('FileStore path does not exist for ' . $path); } $retval->baseDir = realpath($path); return $retval; }
/** * isCacheMissing function. * Return true if thumbnail is missing or if needed _mod is missing * * @access public * @return bool */ public function isCacheMissing() { if ($this->record['modified'] == '1') { return true; //legacy before 2.7 } $cacheBucket = FileStore::fileStoreWithName('other'); if ($this->record['modified']) { $filename = '/' . $this->record['id'] . '_mod.' . $this->extension; $stat = $cacheBucket->listFiles($filename); if (!count($stat)) { return true; } } $sizes = array(); $sizes[] = Preferences::valueForModuleWithKey('CameraLife', 'thumbsize'); $sizes[] = Preferences::valueForModuleWithKey('CameraLife', 'scaledsize'); $options = Preferences::valueForModuleWithKey('CameraLife', 'optionsizes'); preg_match_all('/[0-9]+/', $options, $matches); $sizes = array_merge($sizes, $matches[0]); foreach ($sizes as $cursize) { $filename = '/' . $this->record['id'] . '_' . $cursize . '.' . $this->extension; $stat = $cacheBucket->listFiles($filename); if (!count($stat)) { return true; } } return false; }