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

📄 sql2rss.php

📁 for news RSS to HTML as ASP
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php//// sql2rss.php RSS feed generation from SQL//// Copyright 2006-2007 NotePage, Inc.// 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// sql2rss.php script free of charge.// Please refer to the EULA included in the download for full license// terms and conditions.//// $Id: sql2rss.php,v 3.0 2007/04/16 14:23:05 housley Exp $////// The variable $outputCacheFolder specifies the name of the directory, relative to// the location of sql2rss.php, where the cached files are stored.  It not// recommened you change this with out a very good reason.$outputCacheFolder = "sql2rssCacheFiles";//// Destination Encoding:  By default sql2rss.php creates feedx in  UTF-8.// UTF-8 is used because UTF-8 is capable of displaying all possible characters.$destinationEncoding = "UTF-8";// ==========================================================================// Below this point of the file there are no user editable options.  Your// are welcome to make any modifications that you wish to any of the code// below, but that is not necessary for normal use.// ==========================================================================// $Log: sql2rss.php,v $// Revision 3.0  2007/04/16 14:23:05  housley// Release version 3.0 of the scripts//// Revision 1.29  2007/04/02 19:22:14  housley// Make the generated config file support direct calling//// Revision 1.28  2007/03/25 11:26:40  housley// Detect the decoding from the channel template//// Revision 1.27  2007/03/24 16:33:12  housley// Set the character set for mysql communications//// Revision 1.26  2007/03/16 22:56:37  housley// Changes to allow more power in the outer calling script//// Revision 1.25  2007/03/16 19:22:07  housley// Minor fixes//// Revision 1.24  2007/03/16 18:43:47  housley// Fix the striping of spaces//// Revision 1.23  2007/03/14 17:32:54  housley// Make it simple, just hash the $SQLquery//// Revision 1.22  2007/03/14 01:16:34  housley// * Remove extra spaces in dates, while techincally NOT wrong.// * Allow to specify a cache file name, needed when the outer script//   has logic to create the query//// Revision 1.21  2007/03/13 21:08:36  housley// Allow sql2rss.php to be included from within the configuration file//// Revision 1.20  2007/03/12 19:14:47  housley// Add required parameter to FeedForAll_database_error()//// Revision 1.19  2007/03/04 22:59:24  housley// Update Copyright year//// Revision 1.18  2007/02/26 18:26:20  housley// Logging was already in there//// Revision 1.16  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.15  2007/01/01 17:27:51  housley// Start of some debug information//// Revision 1.14  2006/11/01 23:22:14  housley// Require the configuration files where appropiate, this will cause errors// instead of quite failure//// Revision 1.13  2006/10/31 20:39:09  housley// Use the common FeedForAll_database.inc.php//// Revision 1.12  2006/10/23 20:22:33  housley// * Fix header description// * Add a log of changes// * No functional change//// Set some defaults before reading the configurationif (!isset($useOutputCaching)) {  $useOutputCaching = 1;}if (!isset($outputCacheTTL)) {  $outputCacheTTL = 3600;}if (!isset($ChannelTemplate)) {  $ChannelTemplate  = "sql2rss_Template.xml";}if (!isset($ItemTemplate)) {  $ItemTemplate  = "sql2rss_ItemTemplate.xml";}if (!isset($DBconfigFile)) {  $DBconfigFile = "sql2rss_DBconfig.inc.php";}if (!isset($DBtype)) {  $DBtype = "mysql";}if (!isset($ConfigFilename)) {  $ConfigFilename = "sql2rss_SampleConfig.php";}if (isset($_REQUEST["CONFIGFILE"])) {  if (stristr($_REQUEST["CONFIGFILE"], "file"."://")) {    // Not allowed    ;  }  elseif (stristr($_REQUEST["CONFIGFILE"], "://")) {    // Not allowed    ;  } else {    // It is local and must be in the same directory    $ConfigFilename = basename($_REQUEST["CONFIGFILE"]);  }}Function sql2rss_encodeForXML($string) {  $string = str_replace("&amp;", "&", $string);  $string = str_replace("&", "&amp;", $string);  $string = str_replace("<", "&lt;", $string);  $string = str_replace(">", "&gt;", $string);  return $string;}Function sql2rss_subsutition($data, $text) {  $match = NULL;  //  // Put now() RFC 822 date  $text = str_replace("~~~RSSDATE-NOW~~~", str_replace("  ", " ", date("r", time())), $text);  //  // Convert almost any time to a RFC 822 date  while (preg_match("/~~~RSSDATE\([0-9a-zA-Z_]*\)~~~/", $text, $match) !== FALSE) {    if (count($match) == 0) break;    if ($match[0] == "") break;    $field = str_replace("  ", " ", str_replace("~~~RSSDATE(", "", str_replace(")~~~", "", $match[0])));    if (isset($data[$field])) {      $text = str_replace($match[0], str_replace("  ", " ", date("r", strtotime($data[$field]))), $text);    } else {      $text = str_replace($match[0], "", $text);    }  }    //  // All other fields  while (preg_match("/~~~[0-9a-zA-Z_]*~~~/", $text, $match) !== FALSE) {    if (count($match) == 0) break;    if ($match[0] == "") break;    $field = str_replace("~~~", "", str_replace("~~~", "", $match[0]));    if (isset($data[$field])) {      $text = str_replace($match[0], sql2rss_encodeForXML($data[$field]), $text);    } else {      $text = str_replace($match[0], "", $text);    }  }  return $text;}ob_start();@require_once("FeedForAll_database.inc.php");ob_end_clean();if (!isset($_REQUEST["buildConfig"])) {  if ($ConfigFilename != "DO_NOT_INCLUDE_CONFIG") {    //    // Read in the configuration file    ob_start();    @require_once($ConfigFilename);    ob_end_clean();  }  //  // Read in the DataBase configuration file  if (!isset($config)) {    $confg = Array();    $config["DBtype"] = "mysql";    ob_start();    @require_once($DBconfigFile);    ob_end_clean();  }  if (!isset($config["DBuser"]) || !isset($config["DBpassword"]) || !isset($config["DBmachine"]) || !isset($config["DBdatabase"])) {    echo "Invalid database configuration\n";    exit(2);  }  //  // Verify that the requested DBtype is actually available  if (($config["DBtype"] == "mysql") && (!function_exists("mysql_connect"))) {    echo "Requested DB type is not available\n";    exit(1);  }  else if (($config["DBtype"] == "mssql") && (!function_exists("mssql_connect"))) {    echo "Requested DB type is not available\n";    exit(1);  }    //  // Add the path to $cacheFolder, incase it is called from a different directoy  $localCacheFolder = dirname(__FILE__)."/$outputCacheFolder";  //  // Make the directory if it doesn't exist  if (file_exists($localCacheFolder) === FALSE) {    if (@mkdir($localCacheFolder, 0777) === FALSE) {      $useOutputCaching = 0;    }  }  $gotDataFromCache = 0;  if ($ConfigFilename != "DO_NOT_INCLUDE_CONFIG") {    $outputCacheName = "$localCacheFolder/$ConfigFilename.cache.xml";

⌨️ 快捷键说明

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