Ejemplo n.º 1
0
    /**
	 * Expire a sitepage-variation
	 * @param integer ID of the sitepage to expire
	 * @param integer ID of the level that will be expired
	 * @param integer ID of the variation to expire
	 */
	function expireSitepage($spid, $level, $variation) {
		global $db, $c;

		$spidTrans = translateState($spid, $level, $false);
		// update sitepage_names.
		$sql = "UPDATE sitepage_names SET DELETED=1 WHERE SPID = $spidTrans AND VARIATION_ID = $variation";
		$query = new query($db, $sql);
		// get CLID
		$sql = " SELECT cv.CLID FROM cluster_variations cv, sitepage sp WHERE sp.CLNID = cv.CLNID AND sp.SPID = $spidTrans  AND cv.VARIATION_ID = $variation";
		$query = new query($db, $sql);
		$query->getrow();
		$clid = $query->field("CLID");
		$sql = "UPDATE state_translation SET EXPIRED=1 WHERE OUT_ID = $clid";
		$query = new query($db, $sql);
		// count rest of variations of spid.
		$sql = "SELECT COUNT(VARIATION_ID) AS ANZ FROM sitepage_names WHERE SPID = $spidTrans AND DELETED = 0";
		$query = new query($db, $sql);
		$query->getrow();
		$amount = $query->field("ANZ");

		// if last variation was expired, expire also menu and sitepage.
		if ($amount == 0) {
			$sql = "UPDATE state_translation SET EXPIRED=1 WHERE IN_ID = $spid";

			$query = new query($db, $sql);
			$sql = "SELECT MENU_ID FROM sitepage WHERE SPID = $spid";
			$query = new query($db, $sql);
			$query->getrow();
			$menu = $query->field("MENU_ID");
			$sql = "UPDATE state_translation SET EXPIRED = 1 WHERE IN_ID = $menu";
			$query = new query($db, $sql);
			$query->free();
		}

		flushSitePage($spidTrans, $variation);

		// clear direct path
		$sql = "SELECT DIRECT_URL FROM sitepage_names WHERE SPID = $spid AND VARIATION_ID = $variation";
		$query = new query($db, $sql);
		$query->getrow();
		$short = $query->field("DIRECT_URL");
		$query->free();

		if ($short != "")
			clearShortURL ($short);
		
		if (!$c["classicurls"])
		  clearURLPage($spidTrans, $variation);
			
		global $JPCACHE_ON;
		//cc on launch
		
		$menu = getDBCell("sitepage", "MENU_ID", "SPID = $spid");
		$cconlaunch = getDBCell("sitemap", "CC_ON_LAUNCH", "MENU_ID = " . $menu);
		$ccarray = explode(",", $cconlaunch);
		$mparray = createDBCArray("sitepage", "SPID", "MENU_ID = " . $menu);

		for ($i = 0; $i < count($ccarray); $i++) {
			$spidTrans = translateState($ccarray[$i], $level, false);

			if ($spidTrans != ""  && isCached($ccarray[$i], $variation)) {	
				renderSitePage($spidTrans, $variation);
				if ($JPCACHE_ON) {
					@unlink($c["dyncachepath"]."dyncache-".jpcacheFilename($spidTrans, $variation));
				}
			}
		}

		for ($i = 0; $i < count($mparray); $i++) {
			$spidTrans = translateState($mparray[$i], $level, false);

			if ($spidTrans != ""  && isCached($mparray[$i], $variation)) {	
				// old html caching
				// renderSitePage($spidTrans, $variation);
				if ($JPCACHE_ON  && !$c["renderstatichtml"]) {					
					@unlink($c["dyncachepath"]."dyncache-".jpcacheFilename($spidTrans, $variation));					
				} else {
				  @unlink($c["cachepath"]."static/dyncache-".jpcacheFilename($spidTrans, $variation));									  
				}

			}
		}

	}
Ejemplo n.º 2
0
$_assigns['DEV'] = $CNF_DEV;
$_assigns['SHOW_FORCE_REFRESH'] = $CNF_SHOW_FORCE_REFRESH;
// Check data files are modified
$_data_mtime_file = "{$CNF_PATH_CACHE_MTIME}{$_cache_id}.json";
if (!$force_refresh) {
    if (file_exists($_data_mtime_file)) {
        $_data_mtime = json_decode(file_get_contents($_data_mtime_file), true);
        $auto_refresh = check_data_mtime($_data_mtime);
    } else {
        $auto_refresh = true;
    }
}
// Check whether page is cached
if ($force_refresh || $auto_refresh) {
    clearCache($_template, $_cache_id);
} elseif ($_template && $_cache_id && isCached($_template, $_cache_id)) {
    $_assigns['url_base'] = $url_base;
    display($_template, $_cache_id, 0, $_assigns);
    exit;
}
// Read list
require_once PATH_INCLUDE . 'novel.inc.php';
$list = parse_novel_list($CNF_FILE_LIST);
//$DEBUG = '<pre>' . var_export($list, true) . '</pre>';
// Fetch page
if ($novel_id) {
    $novel = get_novel($list, $novel_id);
    //$DEBUG = '<pre>' . var_export($novel, true) . '</pre>';
    if ($volume_id) {
        $volume = get_volume($novel, $volume_id);
        //$DEBUG = '<pre>' . var_export($volume, true) . '</pre>';//exit($DEBUG);
Ejemplo n.º 3
0
 public function tags($id)
 {
     $collection = [];
     $json = isCached('tags.wp.' . $id, function () use($id) {
         return file_get_contents("https://fr.wikipedia.org/w/api.php?action=query&pageids={$id}&prop=revisions|pageimages|pageterms&rvprop=content&format=json");
     });
     $tab = json_decode($json, true);
     $tab = array_get($tab, 'query.pages.' . $id . '.revisions');
     if (!is_array($tab)) {
         return [];
     }
     $seg = current($tab);
     $seg = $seg['*'];
     $tags = explode('[[', $seg);
     array_shift($tags);
     foreach ($tags as $tag) {
         if (strlen($tag) > 4095) {
             continue;
         }
         if (fnmatch('*|*]]*', $tag)) {
             list($tag, $dummy) = explode('|', $tag, 2);
         }
         list($tag, $dummy) = explode(']]', $tag, 2);
         if (!in_array($tag, $collection) && !fnmatch('*{*', $tag) && !fnmatch('*|*', $tag) && strlen($tag) > 2) {
             $collection[] = $tag;
         }
     }
     return $collection;
 }
Ejemplo n.º 4
0
 protected function _run()
 {
     $viewRedis = container()->getViewRedis();
     $echo = func_get_arg(0);
     $file = $this->_viewFile;
     $isExpired = $this->expired();
     if (false === $this->_compiled) {
         $isExpired = true;
     }
     if (false === $isExpired) {
         $file = $this->compiled();
     } else {
         if (is_numeric($this->_cache)) {
             $cacheInst = new Cache(CACHE_PATH . DS);
             $hash = sha1($this->compiled() . $this->_cache . _serialize((array) $this)) . '.cache';
             $cacheInst->forget($hash);
         }
         $file = $this->compiled($file);
     }
     if (null !== $this->_cache) {
         $isCached = isCached($file, $this->_cache, (array) $this);
         if (false === $isCached) {
             ob_start();
             if (true !== $viewRedis) {
                 include $file;
             }
             $content = ob_get_contents();
             ob_end_clean();
             if (true === $echo) {
                 if (true !== $viewRedis) {
                     echo cache($file, $content, $this->_cache, (array) $this);
                 }
             } else {
                 if (true !== $viewRedis) {
                     return cache($file, $content, $this->_cache, (array) $this);
                 }
             }
         } else {
             if (true !== $viewRedis) {
                 $content = cache($file, null, $this->_cache, (array) $this);
                 if (true === $echo) {
                     echo $content;
                 } else {
                     return $content;
                 }
             }
         }
     } else {
         if (true === $echo) {
             if (true !== $viewRedis) {
                 include $file;
             } else {
                 $this->compile($file);
             }
         } else {
             ob_start();
             if (true !== $viewRedis) {
                 include $file;
             } else {
                 $this->compile($file);
             }
             $content = ob_get_contents();
             ob_end_clean();
             $hash = sha1($this->_viewFile);
             Utils::set($hash, $content);
             return $content;
         }
     }
 }
Ejemplo n.º 5
0
	/**
	 * rebuilds the complete cache of the whole website.
	 *
	 */
	function rebuildCache() {
		global $c, $db;
		if ($c["renderstatichtml"]) {
			$maxtime = ini_get("max_execution_time");
			ini_set("max_execution_time", $c["timeout"]);
			$sp_sql = "SELECT SPID FROM sitepage WHERE DELETED=0 AND VERSION=10";
			$sp_query = new query($db, $sp_sql);
			$clist_id = 0;
			while ($sp_query->getrow()) {
				$my_spid = $sp_query->field("SPID");

				$sv_sql = "SELECT VARIATION_ID FROM variations";
				$sv_query = new query($db, $sv_sql);
				while ($sv_query->getrow()) {
					$my_variation = $sv_query->field("VARIATION_ID");
					if (isCached($my_spid, $my_variation)) {
						if (SPVarExists($my_spid, $my_variation)) {							
							renderSitePage($my_spid, $my_variation);
						}
					}
				}
			}

			ini_set("max_execution_time", $maxtime);
		}
	}
Ejemplo n.º 6
0
<?php

require_once dirname(__DIR__) . '/utils/cache.class.php';
$user_slug = $_GET['user_slug'];
$cache_id = 'mitti-social-counter';
if ($user_slug == NULL) {
    $user_slug = 'mittistockholm';
}
$url = sprintf('http://instagram.com/%s', $user_slug);
$response = array('followed_by' => '');
if (isCached($user_slug)) {
    $response['followed_by'] = getCachedData($user_slug);
    echo json_encode($response);
    die;
}
$opts = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0\r\n"));
$context = stream_context_create($opts);
$data = file_get_contents($url, false, $context);
$pattern = "/followed_by\"\\:(\\s+)?\\{\"count\"\\:(.*?)\\}\\,/";
preg_match($pattern, $data, $matches);
if (!empty($matches[2])) {
    $response['followed_by'] = $matches[2];
    setCacheData($matches[2]);
} else {
    $response['followed_by'] = 'Error occurred during a request.';
}
echo json_encode($response);
function setCacheData($data)
{
    global $user_slug;
    $cache = get_cache();
Ejemplo n.º 7
0
    }
    #if ($LEADERBOARD==0) $LEADERBOARD = '';
    include_once './template/my-leaderboard.php';
    #echo $template;
} elseif (strcasecmp($GO, 'search') == 0) {
    $SEARCHVALUE = isset($_POST["searchvalue"]) ? $_POST["searchvalue"] : "0";
    if ($SEARCHVALUE) {
        $searchresults = getSearchResults($SEARCHVALUE);
    }
    include_once './template/search.php';
    #echo $template;
} else {
    // show the top ten
    $LASTUPDATE = 0;
    $NEXTUPDATE = 0;
    if (isCached('home')) {
        $template = getCache('home');
        $LASTUPDATE = intToTime(getLastUpdate(getcwd() . '/cache/home.cache'));
        $NEXTUPDATE = intToTime(getNextUpdate(getcwd() . '/cache/home.cache', RANKING_REFRESH_TIME));
    } else {
        $topten = getTopTen();
        include_once './template/home.php';
        // write cache file
        writeCache('home', $template);
        $LASTUPDATE = intToTime(0);
        $NEXTUPDATE = intToTime(RANKING_REFRESH_TIME);
    }
    $template = str_replace('{:LASTUPDATE:}', $LASTUPDATE, $template);
    $template = str_replace('{:NEXTUPDATE:}', $NEXTUPDATE, $template);
}
/***************************************************************