} # else } } catch (Exception $x) { echo "Fatal error occured while updating whitelist:" . PHP_EOL; echo " " . $x->getMessage() . PHP_EOL; echo PHP_EOL . PHP_EOL; echo $x->getTraceAsString(); echo PHP_EOL . PHP_EOL; } } # if ## Statistics if ($settings->get('prepare_statistics') && $newSpotCount > 0) { $spotsOverview = new SpotsOverview($db, $settings); $spotImage = new SpotImage($db); $spotsOverview->setActiveRetriever(true); echo "Starting to create statistics " . PHP_EOL; foreach ($spotImage->getValidStatisticsLimits() as $limitValue => $limitName) { # Reset timelimit set_time_limit(60); foreach ($settings->get('system_languages') as $language => $name) { foreach ($spotImage->getValidStatisticsGraphs() as $graphValue => $graphName) { $spotsOverview->getStatisticsImage($graphValue, $limitValue, $settings_nntp_hdr, $language); } # foreach graph } # foreach language echo "Finished creating statistics " . $limitName . PHP_EOL; } # foreach limit
function render() { $settings_nntp_hdr = $this->_settings->get('nntp_hdr'); $settings_nntp_nzb = $this->_settings->get('nntp_nzb'); # Check users' permissions $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotimage, ''); # Haal de image op if (isset($this->_image['type']) && $this->_image['type'] == 'speeddial') { /* * Because the speeddial image shows stuff like last update and amount of new spots, * we want to make sure this is not a totally closed system */ $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, ''); # init $spotImage = new SpotImage($this->_db); $totalSpots = $this->_db->getSpotCount(''); $newSpots = $this->_tplHelper->getNewCountForFilter(''); $lastUpdate = $this->_tplHelper->formatDate($this->_db->getLastUpdate($settings_nntp_hdr['host']), 'lastupdate'); $data = $spotImage->createSpeedDial($totalSpots, $newSpots, $lastUpdate); } elseif (isset($this->_image['type']) && $this->_image['type'] == 'statistics') { $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_statistics, ''); # init $spotsOverview = new SpotsOverview($this->_db, $this->_settings); $graph = isset($this->_image['graph']) ? $this->_image['graph'] : false; $limit = isset($this->_image['limit']) ? $this->_image['limit'] : false; $data = $spotsOverview->getStatisticsImage($graph, $limit, $settings_nntp_hdr, $this->_currentSession['user']['prefs']['user_language']); } elseif (isset($this->_image['type']) && $this->_image['type'] == 'avatar') { # Check users' permissions $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotimage, 'avatar'); # init $spotsOverview = new SpotsOverview($this->_db, $this->_settings); $imgDefaults = array('md5' => false, 'size' => 80, 'default' => 'identicon', 'rating' => 'g'); $imgSettings = array_merge($imgDefaults, $this->_image); if ($imgSettings['size'] < 1 || $imgSettings['size'] > 512) { $imgSettings['size'] = $imgDefaults['size']; } # if if (!in_array($imgSettings['default'], array('identicon', 'mm', 'monsterid', 'retro', 'wavatar'))) { $imgSettings['default'] = $imgDefaults['default']; } # if if (!in_array($imgSettings['rating'], array('g', 'pg', 'r', 'x'))) { $imgSettings['rating'] = $imgDefaults['rating']; } # if $data = $spotsOverview->getAvatarImage($imgSettings['md5'], $imgSettings['size'], $imgSettings['default'], $imgSettings['rating']); } else { # init $spotsOverview = new SpotsOverview($this->_db, $this->_settings); $hdr_spotnntp = new SpotNntp($settings_nntp_hdr); /* Als de HDR en de NZB host hetzelfde zijn, zet geen tweede verbinding op */ if ($settings_nntp_hdr['host'] == $settings_nntp_nzb['host']) { $nzb_spotnntp = $hdr_spotnntp; } else { $nzb_spotnntp = new SpotNntp($this->_settings->get('nntp_nzb')); } # else # Haal de volledige spotinhoud op $fullSpot = $this->_tplHelper->getFullSpot($this->_messageid, false); $data = $spotsOverview->getImage($fullSpot, $nzb_spotnntp); } # else # Images mogen gecached worden op de client, behalve als is opgegeven dat het niet mag if (isset($data['expire'])) { $this->sendExpireHeaders(true); } else { $this->sendExpireHeaders(false); } # else header("Content-Type: " . image_type_to_mime_type($data['metadata']['imagetype'])); header("Content-Length: " . strlen($data['content'])); echo $data['content']; }
function getValidStatisticsLimits() { $spotImage = new SpotImage($this->_db); return $spotImage->getValidStatisticsLimits(); }
function changeAvatar($userId, $imageFile) { $errorList = array(); /* * Don't allow images larger than 4000 bytes */ if (strlen($imageFile) > 4000) { $errorList[] = _('An avatar image has a maximum of 4000 bytes'); } # if /* * Make sure the image can be read, and stuff */ $spotImage = new SpotImage($this->_db); if ($spotImage->getImageInfoFromString($imageFile) === false) { $errorList[] = _('Invalid avatar image was supplied'); } # if if (empty($errorList)) { /* * We store the images base64 encoded */ $imageFile = base64_encode($imageFile); /* * and update the database */ $this->_db->setUserAvatar($userId, $imageFile); } # if return $errorList; }