function getNewsObjects() { //CACHING ENABLED: The server will only fetch news again if the cache has expired. Set expiry values in caching.php /*************** CACHE **************/ $newsCacheName = 'newscache'; $responsejson = null; $cacheExpired = is_null(checkCache($newsCacheName)); $noCache = !is_null($_GET["nocache"]); //////////////////////// if ($cacheExpired || $noCache) { $uri = "http://api.nytimes.com/svc/news/v3/content/all/all.json?api-key={$newsapikey}"; $rawresponsejson = \Httpful\Request::get($uri)->send(); $responsejson = $rawresponsejson . raw_body; setCacheVal($newsCacheName, $responsejson); if ($debug) { echo "Fetched."; } } else { if ($debug) { echo "From cache."; } $responsejson = getCacheVal($newsCacheName); } return parseArticleObjectsFromJson($responsejson); }
function getCache($cacheActionUrl) { if (!($result = checkCache($cacheActionUrl))) { return false; } $cacheFile = CACHE_PATH . $result['alias'] . '.php'; if (is_file($cacheFile)) { if (filemtime($cacheFile) > TIME - $result['timeout']) { ob_start(); include $cacheFile; $cacheContent = ob_get_contents(); ob_end_clean(); return $cacheContent; } else { unlink($cacheFile); } } return false; }
/** * Group details by ID */ function getGroupById($id) { # check if already in cache if ($vtmp = checkCache("group", $id)) { return $vtmp; } else { global $database; /* execute query */ $query = "select * from `userGroups` where `g_id`= '{$id}';"; /* get group */ try { $group = $database->getArray($query); } catch (Exception $e) { $error = $e->getMessage(); die("<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"); } /* return false if none, else list */ if (sizeof($group) == 0) { return false; } else { writeCache("group", $id, $group[0]); return $group[0]; } } }
function _build_result() { $server_cluster = $this->config['server_cluster']; if (post("read_json")) { if (post("url_read")) { $json_path = post("url_read"); foreach ($server_cluster as $serv) { //echo $json_path.'<br>'.$this->config['www_url'].'<br>'; $json_path = str_replace(trim($this->config['www_url']), "", trim($json_path)); //echo $serv . 'read-json/' . $json_path; $json = file_get_contents($serv . 'read-json/' . $json_path); $tmp = json_decode($json, true); return '<pre>' . print_r($tmp, true) . '</pre>'; } } elseif (post("id_read")) { $id_news = post("id_read"); $var = $this->news_model->get_news_by_id($id_news); $cat = $this->get_cat_parent_jsview($id_news, $var[0]['news_category']); foreach ($server_cluster as $serv) { $json = file_get_contents($serv . 'read-json/' . $cat['url'] . '/' . $var[0]['news_url'] . '.html'); $tmp = json_decode($json, true); return '<pre>' . print_r($tmp, true) . '</pre>'; } } } else { if (post("read_cache")) { $CC =& load_object('Cache'); $CC->memcache_active = true; $CC->filecache_active = true; setCache("key-key-key", "data cache key", 1800); if (post("url_read")) { $json_path = post("url_read"); //$cache = checkCache($url,true); } elseif (post("id_read")) { $id_news = post("id_read"); $var = $this->news_model->get_news_by_id($id_news); $cat = $this->get_cat_parent_jsview($id_news, $var[0]['news_category']); $url = $this->config['www_url'] . $cat['url'] . '/' . $var[0]['news_url'] . '.html'; //$cache = checkCache($url,true); } $cache = checkCache("key-key-key", true, 1800); var_dump($cache); $CC->memcache_active = false; $CC->filecache_active = false; return $cache; } else { if (post("update_json")) { if (post("url_gen")) { $json_path = post("url_gen"); foreach ($server_cluster as $serv) { //echo $json_path.'<br>'.$this->config['www_url'].'<br>'; $json_path = str_replace(trim($this->config['www_url']), "", trim($json_path)); $json = file_get_contents($serv . 'update-json/' . $json_path); if ($json) { return 'Json Update'; } } } elseif (post("id_gen")) { $id_news = post("id_gen"); $var = $this->news_model->get_news_by_id($id_news); $cat = $this->get_cat_parent_jsview($id_news, $var[0]['news_category']); foreach ($server_cluster as $serv) { $json = file_get_contents($serv . 'update-json/' . $cat['url'] . '/' . $var[0]['news_url'] . '.html'); if ($json) { return 'Json Update'; } } } else { $ret = ''; $cat = post('categori'); $arrCat = array(); if ($cat != '0') { $arrCat[] = $cat; $tmp_name = $this->arr_Categori['id_to_url'][$cat]; $cat_sub = $this->get_sub_cat($tmp_name); if (is_array($cat_sub) && count($cat_sub) > 0) { $arrCat = array_merge($arrCat, $cat_sub); } } $dateFrom = trim(post('startPeriod')); $dateTo = trim(post('endPeriod')); $type_news = post('type_news'); $type_news = $type_news != '' ? $type_news : 'all'; $row = $this->news_model->get_news_by_category($arrCat, $type_news, $dateFrom, $dateTo); if (is_array($row) && count($row) > 0) { foreach ($row as $rs) { $cat = $this->get_cat_parent_jsview($rs['news_id'], $rs['news_category']); foreach ($server_cluster as $serv) { $json = file_get_contents($serv . 'update-json/' . $cat['url'] . '/' . $rs['news_url'] . '.html'); $ret .= $this->config['www_url'] . $cat['url'] . '/' . $rs['news_url'] . '.html<br>'; } } } return $ret; } } } } }
?> <div class="alert alert-box alert-warning"> <strong>Oh no, the check failed!</strong> <p>Check if you have set up everything correctly and try again.</p> </div> <?php } ?> <div> <p>It seems like you did not yet setup the WebUI. Let's get started with that right now.</p> <h3>Preperation / checklist</h3> <ul id="check-list-box" class="list-group checked-list-box"> <li class="list-group-item list-group-item-<?php echo checkCache() ? 'success' : 'danger'; ?> ">Make sure the <kbd>cache</kbd> directory is writeable and readable.</li> <li class="list-group-item list-group-item-<?php echo checkSettingsFileExistance() ? 'success' : 'danger'; ?> ">Rename the <kbd>settingsRename.php</kbd> file to <kbd>settings.php</kbd>.</li> <li class="list-group-item list-group-item-<?php echo checkSettingsFileWriteable() ? 'success' : 'danger'; ?> ">Make sure the <kbd>settings.php</kbd> file is writeable and readable.</li> <li class="list-group-item list-group-item-<?php echo checkWeakPassword() ? 'success' : 'danger'; ?> ">Open your <kbd>settings.php</kbd> with an editor (such as Notepad++) and adjust the settings. Make sure to set a strong password!</li> </ul>
$p = 'offline'; } else { if ($app->session->maxSessionsReached) { $p = 'maxSessions'; } else { if (!isset($_POST['ids']) && $_GET['c'] == 'skipped' && $p == 'invite') { $p = 'home'; } else { if (!$neverCache and $app->session->isMember === false and $p == 'home') { // OR $p=='read' and 'team' wait for components if ($p == 'read') { $preCacheName = 'pc_' . $p . '_' . $_GET['cid'] . '_anon'; } else { $preCacheName = 'pc_' . $p . '_anon'; } if (checkCache($preCacheName, 30)) { $code = fetchCache($preCacheName); if (isset($_GET['referid'])) { $code = str_ireplace('\\?p\\=signup', '?referid=' . $_GET['referid'] . '&p=signup', $code); } echo $code; // session log already occurred exit; } else { $cachePage = true; } } } } } if (ENABLE_TEMPLATE_EDITS or defined('NO_CACHE') and NO_CACHE) {
function db_store_link($seed, $link) { global $SAME_DOMAIN_FETCH_LEVEL, $MAX_PENETRATION; //echo "db_store_link($seed,$link)\n"; #check if in tblPages #if not, store #get unique id, tblPages.iPageID #get if there is link from seed[iPageID] to $resolved address #if so increment link count #if not, insert new record with link count = 0 #echo "start......db_store_link(...)\n"; #echo "link is: $link\n"; $link = html_entity_decode($link); $cleanUrl = clean_url($link); $cleanUrl = $cleanUrl; $domain = get_domain_part($link, $SAME_DOMAIN_FETCH_LEVEL); $link = $link; $page_id = checkCache($cleanUrl); if ($page_id == null) { $strSQL = "SELECT iPageID FROM tblPages WHERE strCleanURL=?"; $page_id = db_run_select($strSQL, array($cleanUrl), true); addToCache($cleanUrl, $page_id); } if ($page_id == NULL && $MAX_PENETRATION == 0) { //we are set only to crawl only pages in db return NULL; } else { if ($page_id == NULL) { $strSQL = "INSERT INTO tblPages SET fkQueryID=?,strURL=?,strCleanURL=?,iLevel=?,strDomain=?"; db_run_query($strSQL, array($seed["fkQueryID"], $link, $cleanUrl, $seed["iLevel"] + 1, $domain)); //$strSQL="SELECT LAST_INSERT_ID();";//TODO: ONLY MYSQL //"SELECT iPageID FROM tblPages WHERE strCleanURL='" . $cleanUrl . "'"; $page_id = $GLOBALS["db"]->lastInsertId(); //db_run_select($strSQL,true); addToCache($cleanUrl, $page_id); } else { //check current level and give shorter level if possible? } } /*$strSQL="SELECT iLinkID FROM tblLinks " . "WHERE fkParentID=" . $seed["iPageID"] . " AND fkChildID=" . $page_id; $link_id = db_run_select($strSQL,true); if ($link_id==NULL) { $strSQL="INSERT INTO tblLinks(fkParentID,fkChildID,fkQueryID,iNumberTimes) VALUES (" . $seed["iPageID"] . "," . $page_id . "," . $seed["fkQueryID"] . ",1)"; db_run_query($strSQL); } else { //update $strSQL="UPDATE tblLinks SET iNumberTimes=iNumberTimes+1 WHERE iLinkID=" . $link_id; db_run_query($strSQL); }*/ //print "returnVal(" . $seed["iPageID"] . "," . $page_id . "," . $seed["fkQueryID"] . ",1)\n"; return "(" . $seed["iPageID"] . "," . $page_id . "," . $seed["fkQueryID"] . ",1)"; }
/** * Count number of requested IP addresses */ function countRequestedIPaddresses() { # check if already in cache if ($vtmp = checkCache("openrequests", 0)) { return $vtmp; } else { global $database; /* set query, open db connection and fetch results */ $query = 'select count(*) from requests where `processed` = 0;'; /* execute */ try { $details = $database->getArray($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; return false; } # save to cche writeCache("openrequests", 0, $details[0]['count(*)']); # return return $details[0]['count(*)']; } }
/** * Check if subnet contains slaves */ function subnetContainsSlaves($subnetId) { # we need new temp variable for empties $subnetIdtmp = $subnetId; if (strlen($subnetIdtmp) == 0) { $subnetIdtmp = "root"; } # check if already in cache if ($vtmp = checkCache("subnetcontainsslaves", $subnetIdtmp)) { return $vtmp; } else { global $database; /* get all ip addresses in subnet */ $query = 'SELECT count(*) from `subnets` where `masterSubnetId` = "' . $subnetId . '";'; /* execute */ try { $slaveSubnets = $database->getArray($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; return false; } if ($slaveSubnets[0]['count(*)']) { writeCache("subnetcontainsslaves", $subnetIdtmp, true); return true; } else { writeCache("subnetcontainsslaves", $subnetIdtmp, false); return false; } } }
function APIcache($url, $params) { $ds = APIdsName($url, $params); if (checkCache($ds)) { return loadFromCache($ds); } return null; }
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n\r\n\t\tLEFT JOIN #user AS u ON n.news_author = u.user_id\r\n\t\tLEFT JOIN #news_category AS nc ON n.news_category = nc.category_id\r\n\t\tWHERE n.news_class REGEXP '" . e_CLASS_REGEXP . "' AND n.news_start < " . time() . " AND (n.news_end=0 || n.news_end>" . time() . ") AND n.news_render_type<2 AND n.news_datestamp > {$startdate} AND n.news_datestamp < {$enddate} ORDER BY " . $order . " DESC LIMIT " . intval($from) . "," . ITEMVIEW; } else { $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '" . e_CLASS_REGEXP . "' AND news_start < " . time() . " AND (news_end=0 || news_end>" . time() . ") AND news_render_type<2"); if (!isset($pref['newsposts_archive'])) { $pref['newsposts_archive'] = 0; } $interval = $pref['newsposts'] - $pref['newsposts_archive']; // Get number of news item to show if (isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) { $query = "SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, COUNT(*) AS tbcount FROM #news AS n\r\n\t\tLEFT JOIN #user AS u ON n.news_author = u.user_id\r\n\t\tLEFT JOIN #news_category AS nc ON n.news_category = nc.category_id\r\n\t\tLEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id\r\n\t\tWHERE n.news_class REGEXP '" . e_CLASS_REGEXP . "'\r\n\t\tAND n.news_start < " . time() . "\r\n\t\tAND (n.news_end=0 || n.news_end>" . time() . ")\r\n\t\tAND n.news_render_type<2\r\n\t\tGROUP by n.news_id\r\n\t\tORDER BY news_sticky DESC, " . $order . " DESC LIMIT " . intval($from) . "," . $pref['newsposts']; } else { $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n\r\n\t\tLEFT JOIN #user AS u ON n.news_author = u.user_id\r\n\t\tLEFT JOIN #news_category AS nc ON n.news_category = nc.category_id\r\n\t\tWHERE n.news_class REGEXP '" . e_CLASS_REGEXP . "'\r\n\t\tAND n.news_start < " . time() . "\r\n\t\tAND (n.news_end=0 || n.news_end>" . time() . ")\r\n\t\tAND n.news_render_type<2\r\n\t\tORDER BY n.news_sticky DESC, " . $order . " DESC LIMIT " . intval($from) . "," . $pref['newsposts']; } // #### END --------------------------------------------------------------------------------------------------- } if ($tmp_cache = checkCache($cacheString)) { require_once HEADERF; if (!$action) { render_wmessage(); if (isset($pref['fb_active'])) { // --->feature box require_once e_PLUGIN . "featurebox/featurebox.php"; } if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1) { require_once e_PLUGIN . "newforumposts_main/newforumposts_main.php"; } } renderCache($tmp_cache, TRUE); } if (!$sql->db_Select_gen($query)) { require_once HEADERF;
$cacheFn = '/tmp/qiwoo/modules.cache.php'; $checkSum = ''; $output = array(); function checkCache(&$output) { global $base_dir, $cacheFn, $checkSum; @($cache = (include $cacheFn)); exec("tree -a {$base_dir}", $result); $checkSum = md5(implode('\\n', $result)); if ($cache && $cache['checksum'] == $checkSum) { $output = $cache['data']; return true; } return false; } if (checkCache($output)) { die(json_encode($output)); } $output = array(); function isModule($path) { return is_file($path . '/package.json'); } function readPackage($path) { $ret = array(); $data = json_decode(file_get_contents($path . '/package.json'), true); $ret['data'] = $data; $ret['path'] = $path; if (empty($data) || empty($data['keywords'])) { $ret['category'] = 'unknown';
} // is Squid telling us that other authentication has passed? if ($onLan && isset($input[1]) && substr($input[1], 0, 2) == "__") { writeReply("OK"); // cache accordingly if so $input[1] = substr($input[1], 2); $un = null; if ($input[1] == "VIRTUAL") { $input[1] = ""; $un = defined("SQUID_VIRTUAL_USER") ? SQUID_VIRTUAL_USER : "******"; $ttl = SQUID_VIRTUAL_TTL; } cacheResult($srcIP, $mac, $input[1], $un, $ttl); continue; } if (checkCache($srcIP, $mac, isset($input[1]) ? $input[1] : "")) { continue; } // check for a match in device / session database $mconn = mysqli_connect(SQUID_DB_SERVER, SQUID_DB_USERNAME, SQUID_DB_PASSWORD, SQUID_DB_NAME); if (!mysqli_connect_error()) { $un = null; $ldapServer = SQUID_LDAP_SERVER; $ldapUser = SQUID_LDAP_USER_DN; $ldapPassword = SQUID_LDAP_USER_PW; $ldapBase = SQUID_LDAP_BASE_DN; $ldapGroups = $SQUID_LDAP_GROUP_DN; // try devices table first $servers = array_keys($SQUID_PM_DB); if ($onLan && $servers) { $rs = mysqli_query($mconn, "select username, server_name from user_devices where mac_address = '{$mac}' and (server_name in ('" . implode("', '", $servers) . "') or server_name is null) order by line_id desc");
/** * get whole tree path for subnetId - from parent all slaves * * if multi than create multidimensional array */ function getAllSlavesReturn($subnetId) { # check cache if ($vtmp = checkCache("allslavesReturn", $subnetId)) { return $vtmp; } else { $end = false; # breaks while $allSlaves[] = $subnetId; # first # db global $database; while ($end == false) { /* get all immediate slaves */ $query = "select `id` from `subnets` where `masterSubnetId` = '{$subnetId}' order by `id` asc; "; /* execute query */ try { $slaves2 = $database->getArray($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; return false; } # we have more slaves if (sizeof($slaves2) != 0) { # recursive foreach ($slaves2 as $slave) { $allSlaves[] = $slave['id']; getAllSlavesReturn($slave['id']); $end = true; } } else { $end = true; } } # save cache if (sizeof($allSlaves) > 0) { writeCache("allslaves", $subnetId, $allSlaves); } # return return $allSlaves; } }
<body> <script src=js/modernizr.js></script> <script> Modernizr.load({ test: Modernizr.touch, yep : 'appMobile.css', }); </script> <div id="news"> <?php //CACHING ENABLED: The server will only fetch news again if the cache has expired. Set expiry values in caching.php /*************** CACHE **************/ $newsCacheName = 'newscache'; $responsejson = null; $cacheExpired = is_null(checkCache($newsCacheName)); $noCache = !is_null($_GET["nocache"]); //////////////////////// if ($cacheExpired || $noCache) { $uri = "http://api.nytimes.com/svc/news/v3/content/all/all.json?api-key={$newsapikey}"; $rawresponsejson = \Httpful\Request::get($uri)->send(); $responsejson = $rawresponsejson . raw_body; setCacheVal($newsCacheName, $responsejson); if ($debug) { echo "Fetched."; } } else { if ($debug) { echo "From cache."; } $responsejson = getCacheVal($newsCacheName);
function getAllSlaves($subnetId, $multi = false) { # check cache if ($vtmp = checkCache("allslaves", $subnetId . "_{$multi}")) { return $vtmp; } else { global $removeSlaves; $end = false; # breaks while $removeSlaves[] = $subnetId; # first # db global $db; # get variables from config file $database = new database($db['host'], $db['user'], $db['pass'], $db['name']); while ($end == false) { /* get all immediate slaves */ $query = "select * from `subnets` where `masterSubnetId` = '{$subnetId}' order by `id` asc; "; /* execute query */ try { $slaves2 = $database->getArray($query); } catch (Exception $e) { $error = $e->getMessage(); print "<div class='alert alert-danger'>" . _('Error') . ": {$error}</div>"; return false; } # we have more slaves if (sizeof($slaves2) != 0) { # recursive foreach ($slaves2 as $slave) { $removeSlaves[] = $slave['id']; getAllSlaves($slave['id']); $end = true; } } else { $end = true; } } # save cache if (sizeof($removeSlaves) > 0) { writeCache("allslaves", $subnetId . "_{$multi}", $removeSlaves); } } }
header("Location:{$cachedResponse}"); die; } } } else { if (strpos($uri, "/serveFlavor/") !== false && function_exists('apc_fetch') && $_SERVER["REQUEST_METHOD"] == "GET") { require_once dirname(__FILE__) . '/../apps/kaltura/lib/renderers/kRendererDumpFile.php'; require_once dirname(__FILE__) . '/../apps/kaltura/lib/renderers/kRendererString.php'; require_once dirname(__FILE__) . '/../apps/kaltura/lib/monitor/KalturaMonitorClient.php'; require_once dirname(__FILE__) . '/../apps/kaltura/lib/request/kIpAddressUtils.php'; $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; $cacheKey = 'dumpFile-' . kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR']) . '-' . $host . $uri; $renderer = apc_fetch($cacheKey); if ($renderer) { KalturaMonitorClient::initApiMonitor(true, 'extwidget.serveFlavor', $renderer->partnerId); header("X-Kaltura:cached-dispatcher"); $renderer->output(); die; } } } } } } } } checkCache(); define('KALTURA_LOG', 'ps2'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', false); require_once __DIR__ . '/../bootstrap.php';
// Removed, themes should use {FEATUREBOX} shortcode instead // if (isset($pref['fb_active'])) // { // require_once(e_PLUGIN."featurebox/featurebox.php"); // } // Removed, legacy // if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1) // { // require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php"); // } } //news archive if ($action != "item" && $action != 'list' && $pref['newsposts_archive']) { if ($sql->db_Select_gen($query)) { $newsAr = $sql->db_getList(); if ($newsarchive = checkCache('newsarchive')) { $newsCachedPage = $newsCachedPage . $newsarchive; } else { show_newsarchive($newsAr, $interval); } } } renderCache($newsCachedPage, TRUE); } if (!($news_total = $sql->db_Select_gen($query))) { // No news items require_once HEADERF; echo "<br /><br /><div style='text-align:center'><b>" . (strstr(e_QUERY, "month") ? LAN_NEWS_462 : LAN_NEWS_83) . "</b></div><br /><br />"; require_once FOOTERF; exit; }
?> <div class="alert alert-box alert-warning"> <strong>Oh no, the check failed!</strong> <p>Check if you have set up everything correctly and try again.</p> </div> <?php } ?> <div> <p>It seems like you did not yet setup the WebUI. Let's get started with that right now.</p> <h3>Preperation / checklist</h3> <ul id="check-list-box" class="list-group checked-list-box"> <li class="list-group-item" data-state="<?php echo checkCache() ? 'success' : 'failed'; ?> ">Make sure the <kbd>cache</kbd> directory is writeable and readable.</li> <li class="list-group-item" data-state="<?php echo checkSettingsFileExistance() ? 'success' : 'failed'; ?> ">Rename the <kbd>settingsRename.php</kbd> file to <kbd>settings.php</kbd>.</li> <li class="list-group-item" data-state="<?php echo checkSettingsFileWriteable() ? 'success' : 'failed'; ?> ">Make sure the <kbd>settings.php</kbd> file is writeable and readable.</li> <li class="list-group-item" data-state="<?php echo checkWeakPassword() ? 'success' : 'failed'; ?> ">Open your <kbd>settings.php</kbd> with an editor (such as Notepad++) and adjust the settings. Make sure to set a strong password!</li> </ul>