function renderRequest($url) { if (caching) { $cache = readCache($url); if ($cache) { list($contentType, $content) = $cache; return [true, [$contentType, base64_decode($content)]]; } } list($rBool, $rData, $bCache) = doRequest($url); if (!$rBool) { if (caching) { if ($bCache) { bulkCacheTimestampUpdate(); } $cache = readCache($url, true); if ($cache) { list($contentType, $content) = $cache; return [true, [$contentType, base64_decode($content)]]; } } return [false, $rData]; } if (caching) { if (!writeCache($url, $rData)) { error_log('could not write to cache'); } } list($contentType, $content) = $rData; return [true, [$contentType, base64_decode($content)]]; }
function fGetTweets($user = '', $count = 3) { $file = dirname('.') . $user . '.json'; $options = array('consumer_key' => TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET); OAuthStore::instance("2Leg", $options); $json = new Services_JSON(); $last = getCacheLastModified($file); $now = time(); if (!$last || $now - $last > REFRESH_INTERVAL) { $response = readTimeline($user, $count); saveCache($file, $response); } else { $response = readCache($file); } $response = $json->decode($response); $response = wrapTweets($response); return $response; }
$last_modified = $output_data = null; // If there's a cache file, read it if (hasCache($cache_lang) && !$is_developer) { $last_modified = filemtime(pathCache($cache_lang)); $cache_read = readCache($cache_lang); if ($deflate_support || !$has_compression) { $output_data = $cache_read; } else { $output_data = gzinflate($cache_read); } } else { // First try to read the cache reference if (hasCache($cache_hash) && !$is_developer) { // Read the reference $last_modified = filemtime(pathCache($cache_hash)); $cache_reference = readCache($cache_hash); // Filter the cache reference if ($has_compression) { $output = gzinflate($cache_reference); } else { $output = $cache_reference; } } else { // Last modified date is now $last_modified = time(); // Initialize the loop $looped = ''; // Add the content of the current file foreach ($array as $current) { $looped .= rmBOM(file_get_contents($dir . $current)) . "\n"; }
return false; } } else { return true; } } function online($server, $port) { $socket = fsockopen($server, $port, $errno, $errstr, 1); if (!$socket) { return false; } else { return true; } } if ($_GET['ajaxsync'] == "get-shoutcast-update" && readCache($cacheTime, $cacheOn)) { $masterServerData = explode(":", $masterServer); if ($masterServer && online($masterServerData[0], trim($masterServerData[1]))) { $masterServerData = explode(",", getSCData($masterServerData[0], trim($masterServerData[1]))); $shoutCast["listeners"] = $masterServerData[0]; if (trim($masterServerData[1]) == 1) { $shoutCast["status"] = $onAirStatus; } else { $shoutCast["status"] = $offAirStatus; } $shoutCast["peaklisteners"] = (int) trim($masterServerData[2]); $shoutCast["maxlisteners"] = (int) trim($masterServerData[3]); $shoutCast["uniquelisteners"] = (int) trim($masterServerData[4]); $shoutCast["bitrate"] = (int) trim($masterServerData[5]); for ($i = 6; $i < count($masterServerData); $i++) { $shoutCast["song"] .= $masterServerData[$i] . '';
function ArcadeInfoPanelBlock() { global $context, $txt, $arcSettings, $scripturl; $no = 5; echo ' <table width="100%" border="0" cellpadding="1"> <tr> <td colspan="2"><div align="center"><span><i><b>', $txt['arcade_info'], '</b></i></span></div></td> </tr> <tr> <td><span class="middletext">'; echo ' <script type="text/javascript"> var pausecontent=new Array() '; if ($arcSettings['enable_arcade_cache'] == 1) { ob_start(); if (!($cache3Best = readCache('arcadeinfopanel.cache', 86400))) { echo 'pausecontent[0]="', addslashes(ArcadeInfoBestPlayers($no)), '"; '; echo 'pausecontent[1]="', addslashes(ArcadeInfoNewestGames($no)), '"; '; echo 'pausecontent[2]="', addslashes(Arcade3champsBlock($no)), '"; '; echo 'pausecontent[3]="', addslashes(ArcadeInfoMostPlayed($no)), '"; '; echo 'pausecontent[4]="', addslashes(ArcadeInfoLongestChamps($no)), '"; '; $cache3Best = ob_get_contents(); ob_clean(); writeCache($cache3Best, 'arcadeinfopanel.cache'); ob_end_clean(); } echo $cache3Best; ob_start(); if (!($cacheGotd = readCache('gotd.cache', 86400))) { echo 'pausecontent[5]="', addslashes(ArcadeGOTDBlock()), '"; '; $cacheGotd = ob_get_contents(); ob_clean(); writeCache($cacheGotd, 'gotd.cache'); ob_end_clean(); } echo $cacheGotd; } else { echo 'pausecontent[0]="', addslashes(ArcadeInfoBestPlayers($no)), '"; '; echo 'pausecontent[1]="', addslashes(ArcadeInfoNewestGames($no)), '"; '; echo 'pausecontent[2]="', addslashes(Arcade3champsBlock($no)), '"; '; echo 'pausecontent[3]="', addslashes(ArcadeInfoMostPlayed($no)), '"; '; echo 'pausecontent[4]="', addslashes(ArcadeInfoLongestChamps($no)), '"; '; echo 'pausecontent[5]="', addslashes(ArcadeGOTDBlock()), '"; '; } echo 'pausecontent[6]="', addslashes(ArcadeRandomGameBlock()), '"; '; echo '</script> <style type="text/css"> #pescroller1{ height: 220px; border: 0px solid black; padding: 5px; } .someclass{ //class to apply to your escroller(s) if desired } </style> <script type="text/javascript"> /*********************************************** * Pausing up-down escroller- © Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ function pauseescroller(content, divId, divClass, delay){ this.content=content //message array content this.tickerid=divId //ID of ticker div to display information this.delay=delay //Delay between msg change, in miliseconds. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over escroller (and pause it if it is) this.hiddendivpointer=1 //index of message array for hidden div document.write(\'<div id="\'+divId+\'" class="\'+divClass+\'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="\'+divId+\'1">\'+content[0]+\'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="\'+divId+\'2">\'+content[1]+\'</div></div>\') var escrollerinstance=this if (window.addEventListener) //run onload in DOM2 browsers window.addEventListener("load", function(){escrollerinstance.initialize()}, false) else if (window.attachEvent) //run onload in IE5.5+ window.attachEvent("onload", function(){escrollerinstance.initialize()}) else if (document.getElementById) //if legacy DOM browsers, just start escroller after 0.5 sec setTimeout(function(){escrollerinstance.initialize()}, 500) } // ------------------------------------------------------------------- // initialize()- Initialize escroller method. // -Get div objects, set initial positions, start up down animation // ------------------------------------------------------------------- pauseescroller.prototype.initialize=function(){ this.tickerdiv=document.getElementById(this.tickerid) this.visiblediv=document.getElementById(this.tickerid+"1") this.hiddendiv=document.getElementById(this.tickerid+"2") this.visibledivtop=parseInt(pauseescroller.getCSSpadding(this.tickerdiv)) this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px" this.getinline(this.visiblediv, this.hiddendiv) this.hiddendiv.style.visibility="visible" var escrollerinstance=this document.getElementById(this.tickerid).onmouseover=function(){escrollerinstance.mouseoverBol=1} document.getElementById(this.tickerid).onmouseout=function(){escrollerinstance.mouseoverBol=0} if (window.attachEvent) //Clean up loose references in IE window.attachEvent("onunload", function(){escrollerinstance.tickerdiv.onmouseover=escrollerinstance.tickerdiv.onmouseout=null}) setTimeout(function(){escrollerinstance.animateup()}, this.delay) } // ------------------------------------------------------------------- // animateup()- Move the two inner divs of the escroller up and in sync // ------------------------------------------------------------------- pauseescroller.prototype.animateup=function(){ var escrollerinstance=this if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){ this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px" this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px" setTimeout(function(){escrollerinstance.animateup()}, 50) } else{ this.getinline(this.hiddendiv, this.visiblediv) this.swapdivs() setTimeout(function(){escrollerinstance.setmessage()}, this.delay) } } // ------------------------------------------------------------------- // swapdivs()- Swap between which is the visible and which is the hidden div // ------------------------------------------------------------------- pauseescroller.prototype.swapdivs=function(){ var tempcontainer=this.visiblediv this.visiblediv=this.hiddendiv this.hiddendiv=tempcontainer } pauseescroller.prototype.getinline=function(div1, div2){ div1.style.top=this.visibledivtop+"px" div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px" } // ------------------------------------------------------------------- // setmessage()- Populate the hidden div with the next message before it\'s visible // ------------------------------------------------------------------- pauseescroller.prototype.setmessage=function(){ var escrollerinstance=this if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it) setTimeout(function(){escrollerinstance.setmessage()}, 100) else{ var i=this.hiddendivpointer var ceiling=this.content.length this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1 this.hiddendiv.innerHTML=this.content[this.hiddendivpointer] this.animateup() } } pauseescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any if (tickerobj.currentStyle) return tickerobj.currentStyle["paddingTop"] else if (window.getComputedStyle) //if DOM2 return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top") else return 0 } </script> <script type="text/javascript"> //new pauseescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds) new pauseescroller(pausecontent, "pescroller1", "someclass", 2000) document.write("<br />") </script> </span> </td> </tr> </table> '; }
echo '<script src="base64.js"></script>' . "\n"; echo '<script src="browser.js"></script>' . "\n"; echo '<script>'; echo "var f = '" . $h . "';" . "\n"; echo 'var host = Base64.decode(reverseString("' . $rawRequest . '"));' . "\n"; echo 'window.fetcherUrl = f;window.hostUrl = host;'; echo "fetch(host);" . "\n"; echo "</script>"; } else { if ($reqmode == "p2get_p") { if (strstr($req, "?")) { $query = ""; } else { $query = "?"; } foreach ($_POST as $k => $v) { $kv = $k . "=" . $v . '&'; $query .= $kv; } $redir = $req . $query; $rs = encodeString(urlsafe_b64encode($redir)); echo "<script>window.location = 'fetch.php?mode=loader&url=" . $rs . "';</script>"; } else { if (file_exists($fn) && $reqm == "get") { readCache($fn, $reqmode); checkCache(); } else { fetchPage($req, $fn, $reqm, $reqmode); } } }
// Library Constants defined('FRONTENDER_LIBS') or define('FRONTENDER_LIBS', FRONTENDER_PATH . "/libraries"); defined('FRONTENDER_SRC') or define('FRONTENDER_SRC', FRONTENDER_LIBS . "/assetic/src/Assetic"); defined('CACHE_DIR') or define('CACHE_DIR', Libraries::get(true, 'resources') . "/tmp/cache"); /** * Load in project dependancies which include * LessPHP, Assetic and Symfony Process component */ require __DIR__ . '/libraries.php'; Dispatcher::applyFilter('run', function ($self, $params, $chain) use($options) { $assets = array('css' => array('match' => "/.css\$/", 'type' => 'text/css', 'name' => 'Stylesheet'), 'js' => array('match' => "/.js\$/", 'type' => 'text/javascript', 'name' => 'Script')); foreach (array_keys($assets) as $type) { $config = $assets[$type]; $config['cacheOnly'] = $options['cacheOnly']; if (preg_match($config['match'], $params['request']->url)) { if (readCache($params['request'], $config)) { return; } } } return $chain->next($self, $params, $chain); }); /** * Read cache files for assets * Returns CSS/Js from Cache if exists * @param object $request * @return string contents of cache file */ function readCache($request, array $options) { $http_response_code = null;