public static function syncLong($force = false) { self::initSync(1800); // Sync analytical and statistical data (long running). Debug::runTimer('Run analytics manager', function () { AnalyticsManager::run(); }); // Update convention archives. Debug::runTimer('Run convention archives manager', function () { ConventionManager::run(); }); /* // Clean up old API calls. Debug::runTimer('Run API call cleanup', function() { ApiCall::cleanUp(); }); */ // Clean up old song history entries. Debug::runTimer('Run song history cleanup', function () { SongHistory::cleanUp(); }); // Sync the BronyTunes library. Debug::runTimer('Run BronyTunes sync', function () { Service\BronyTunes::load(); }); // Sync the Pony.fm library. Debug::runTimer('Run Pony.fm sync', function () { Service\PonyFm::load(); }); // Sync the EqBeats library. Debug::runTimer('Run EqBeats sync', function () { Service\EqBeats::load(); }); Settings::setSetting('sync_slow_last_run', time()); }
public function episodeAction() { $podcast_id = (int) $this->getParam('id'); $episode_id = (int) $this->getParam('episode'); $record = PodcastEpisode::getRepository()->findOneBy(array('id' => $episode_id, 'podcast_id' => $podcast_id)); if (!$record instanceof PodcastEpisode) { throw new \DF\Exception\DisplayOnly('Podcast episode not found!'); } $record->play_count = $record->play_count + 1; $record->save(); // Insert into Influx if (isset($_SERVER['CF-Connecting-IP'])) { $remote_ip = $_SERVER['CF-Connecting-IP']; } else { $remote_ip = $_SERVER['REMOTE_ADDR']; } $origin = $this->getParam('origin', 'organic'); $influx = $this->di->get('influx'); $influx->setDatabase('pvlive_analytics'); $influx->insert('podcast.' . $podcast_id . '.' . $episode_id, ['value' => 1, 'ip' => $remote_ip, 'client' => $origin, 'useragent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER']]); // If request made by AJAX, just return confirmation. if ($this->isAjax()) { return $this->renderJson(array('result' => 'OK')); } else { $redirect_url = \PVL\AnalyticsManager::addTracking($record->web_url, array('source' => $origin)); return $this->redirect($redirect_url); } }
/** * Static Functions */ public static function fetch($only_approved = true) { $cache_name = 'pvlive_affiliates_' . ($only_approved ? 'approved' : 'all'); $records = \DF\Cache::get($cache_name); if (!$records) { $records = self::fetchArray(); if ($only_approved) { $records = array_filter($records, function ($record) { return $record['is_approved']; }); } // Add affiliate tracking info. foreach ($records as &$record) { $record['web_url'] = \PVL\AnalyticsManager::addTracking($record['web_url'], array('source' => 'pvliveaffiliate')); } \DF\Cache::set($records, $cache_name, array(), 60); } shuffle($records); return $records; }
public static function getEpisodePlayerUrl($web_url) { // Special handling for SoundCloud URLs. if (stristr($web_url, 'soundcloud.com')) { $web_url = 'https://w.soundcloud.com/player/?' . http_build_query(array('auto_play' => 'true', 'url' => $web_url)); } return \PVL\AnalyticsManager::addTracking($web_url); }