⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feedforall_scripts_cachingextension.php

📁 RSS to SQL Caching Tools
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php//// rss2html.php RSS feed to HTML webpage script XML Caching Extension//// Copyright 2005-2007 NotePage, Inc. all rights reserved// http://www.feedforall.com//// NotePage, Inc. grants registerd users of our FeedForAll and/or// FeedForAll Mac product(s) the right to install and use the// FeedForAll_Scripts_CachingExtension.php script free of charge.  // Please refer to the EULA included in the download for full license// terms and conditions.//// $Id: FeedForAll_Scripts_CachingExtension.php,v 3.0 2007/04/16 14:23:03 housley Exp $//// $Log: FeedForAll_Scripts_CachingExtension.php,v $// Revision 3.0  2007/04/16 14:23:03  housley// Release version 3.0 of the scripts//// Revision 1.19  2007/04/10 17:16:44  housley// Allow the input caching to be set during buildURL, only for one PHP include// type//// Revision 1.18  2007/04/10 15:19:27  housley// Allow for the caching for the HTML output of rss2html.php//// Revision 1.17  2007/04/04 20:55:46  housley// Add the ability to set CURLOPT_CONNECTTIMEOUT//// Revision 1.16  2007/03/13 20:33:23  housley// Update copyright year//// Revision 1.15  2007/03/05 01:19:45  housley// Rename FeedForAll_rss2html_readFile() to FeedForAll_scripts_readFile()//// Revision 1.14  2007/02/24 12:42:03  housley// Add checks for safe_mode and open_basedir to prevent warning about// CURLOPT_FOLLOWLOCATION//// Revision 1.13  2007/02/21 13:39:06  housley// * More small fixes for different directories// * Add more debug statements//// Revision 1.12  2007/01/17 17:56:28  housley// Fix the problem of no caching when called from a different directory.// When the script is called from a different directory, the caching system// will look for the cache folder in the current directory instead of the// directory with the script.//// Revision 1.11  2006/09/29 19:07:15  housley// Allow rss2html.php not to show an identity when used with any of the// pay scripts.//// Revision 1.10  2006/09/07 01:24:15  housley// Verify the length of the data read from the cache file is the same// as the cache file.  A server was not returning the right data.//// Revision 1.9  2006/07/17 20:49:54  housley// Add an option, FORCECACHEREFRESH, that will force cache updates//// Revision 1.8  2006/05/27 19:26:32  housley// Ensure in all cases the cached file is readable.  If it is not readable,// return so.//// Revision 1.7  2006/04/08 23:55:33  housley// Rename the directory for cache storage//// Revision 1.6  2006/03/10 14:21:04  housley// Update the licenses//// Revision 1.5  2006/02/19 14:36:45  housley// Change so the read from cache is called twice.  The second time is on an error.//// Revision 1.4  2006/02/19 12:52:28  housley// Allow the capability to return expired cache results when there is// an error reaching the site for new contents//// Revision 1.3  2006/02/12 12:14:03  housley// Allow the length of time each file is cached to be passed in//// Revision 1.2  2006/01/08 23:24:03  housley// Update license statement//// Revision 1.1  2005/12/12 16:27:42  housley// Create the ability to cache files//////if (function_exists("FeedForAll_rss2html_AddIdentity") === FALSE) {  Function FeedForAll_rss2html_AddIdentity($itemString) {    return $itemString;  }}if (function_exists("FeedForAll_scripts_readFile") === FALSE) {    //  // The variable $cacheTTL controls how many seconds a cached copy of an XML  // file can be used before it must be refetched from the server.  // $cacheTTL=60;      //cache files for 1 minute  // $cacheTTL=3600;    //cache files for 1 hour  $cacheTTL=86400;   //cache files for 1 day    //  // The variable $cacheFolder specifies the name of the directory, relative to  // the location of rss2html.php, where the cached files are stored.  It not  // recommened you change this with out a very good reason.  $cacheFolder = "FeedForAllCacheFiles";    //  // The variable $useExpiredOnError when set to 1 causes the program to return  // expired data from the cache when there is an error reaching the website  // to get a new file.  Turn with on with caution because with this on there  // is no indication of an error.  $useExpiredOnError = 0;    //  // Used for trouble shooting with tech support  // $debugLevel = 0;    //  // Output caching of resulting HTML.  CAUTION using both caching for the XML  // and the HTML can cause hard to diagnose problem if not done right.  //$outputCacheTTL = 3600;    if (isset($GLOBALS["XMLCACHTTL"])) {    $cacheTTL = $GLOBALS["XMLCACHETTL"];  }  if (isset($GLOBALS["ALLOWXMLCACHE"])) {    $allowCachingXMLFiles = $GLOBALS["ALLOWXMLCACHE"];  }  if (isset($GLOBALS["OUTCACHTTL"])) {    $outputCacheTTL = $GLOBALS["OUTCACHTTL"];  }    Function FeedForAll_scripts_contentOfCache($filename, $useCaching = 0, $actualCacheTTL = -1, $actualUseExpiredOnError = 0) {    GLOBAL $cacheTTL, $cacheFolder;    GLOBAL $debugLevel;        if (isset($debugLevel) && ($debugLevel >= 1)) {      echo "DIAG: FeedForAll_scripts_contentOfCache($filename, $useCaching, $actualCacheTTL, $actualUseExpiredOnError)<br>\n";    }        //    // Add the path to $cacheFolder, incase it is called from a different directoy    $localCacheFolder = dirname(__FILE__)."/$cacheFolder";        if (!$useCaching) {      if (isset($debugLevel) && ($debugLevel >= 1)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): !useCaching<br>\n";      }      return FALSE;    }        if (isset($_REQUEST["FORCECACHEREFRESH"])) {      if (isset($debugLevel) && ($debugLevel >= 1)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): FORCECACHEREFRESH<br>\n";      }      return FALSE;    }        if ($actualCacheTTL == -1) {      $actualCacheTTL = $cacheTTL;    }        //    // Make the directory if it doesn't exist    if (file_exists($localCacheFolder) === FALSE) {      if (@mkdir($localCacheFolder, 0777) === FALSE) {        if (isset($debugLevel) && ($debugLevel >= 1)) {          echo "DIAG: FeedForAll_scripts_contentOfCache(): no cache folder<br>\n";        }        return FALSE;      }    }    $encodedName = $localCacheFolder."/".md5($filename);        if (file_exists($encodedName) === FALSE) {      // File does not exist      if (isset($debugLevel) && ($debugLevel >= 1)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): file doesn't exist<br>\n";      }      return FALSE;    }        // File exists, so lets check the age    if (((time() - filemtime($encodedName)) > $actualCacheTTL) && ($actualUseExpiredOnError == 0)) {      if (isset($debugLevel) && ($debugLevel >= 3)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): (time() - filemtime($encodedName)) > \$actualCacheTTL)<br>\n";        echo "DIAG: FeedForAll_scripts_contentOfCache(): (".time()." - ".filemtime($encodedName).") > $actualCacheTTL)<br>\n";      }      if (isset($debugLevel) && ($debugLevel >= 1)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): file too old<br>\n";      }      return FALSE;    }        // The file exists and has not expired    if (($fd = @fopen($encodedName, "rb")) !== FALSE) {      if (flock($fd, LOCK_SH)) {        $result = fread($fd, filesize($encodedName));        flock($fd, LOCK_UN);        if (strlen($result) != filesize($encodedName)) {          fclose($fd);          if (isset($debugLevel) && ($debugLevel >= 1)) {            echo "DIAG: FeedForAll_scripts_contentOfCache(): filesize mismatch<br>\n";          }          return FALSE;        }      } else {        if (isset($debugLevel) && ($debugLevel >= 1)) {          echo "DIAG: FeedForAll_scripts_contentOfCache(): flock() faild<br>\n";        }        return FALSE;      }      fclose($fd);      if (isset($debugLevel) && ($debugLevel >= 1)) {        echo "DIAG: FeedForAll_scripts_contentOfCache(): return SUCCESSFUL<br>\n";      }      return $result;    }    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -