コード例 #1
0
ファイル: clear_old_cache.php プロジェクト: ASDAFF/open_bx
function CheckCacheFiles_Rec($strDir)
{
	global $iGoodNum, $iOldNum, $iEmptyDirNum, $dLog;

	if ($handle = @opendir($strDir))
	{
		while (($file = readdir($handle)) !== false)
		{
			if ($file == "." || $file == "..") continue;

			if (is_dir($strDir."/".$file))
			{
				CheckCacheFiles_Rec($strDir."/".$file);
			}
			elseif (is_file($strDir."/".$file))
			{
				$ext = "";
				$ext_pos = bxstrrpos($file, ".");
				if ($ext_pos!==false)
					$ext = substr($file, $ext_pos + 1);

				$bCacheExp = False;
				if ($ext=="html")
					$bCacheExp = CPageCache::IsCacheExpired($strDir."/".$file);
				elseif ($ext=="php")
					$bCacheExp = CPHPCache::IsCacheExpired($strDir."/".$file);

				if ($bCacheExp)
				{
					$iOldNum++;
					@unlink($strDir."/".$file);
				}
				else
				{
					$iGoodNum++;
				}
			}
		}
		@closedir($handle);
	}

	clearstatcache();

	$bEmptyFolder = True;
	if ($handle = @opendir($strDir))
	{
		while (($file = readdir($handle)) !== false)
		{
			if ($file == "." || $file == "..") continue;
			$bEmptyFolder = False;
			break;
		}
	}

	if ($bEmptyFolder)
	{
		$iEmptyDirNum++;
		@rmdir($strDir);
	}
}
コード例 #2
0
ファイル: cache.php プロジェクト: mrdeadmouse/u136006
 function IsCacheExpired($path)
 {
     if (is_object($this) && is_object($this->_cache)) {
         return $this->_cache->IsCacheExpired($path);
     } else {
         $obCache = new CPHPCache();
         return $obCache->IsCacheExpired($path);
     }
 }