我正在用PHP构建一个可与RSS2HTML一起使用的注释框,并允许用户对页面上的文章进行注释。
Homefeed.php引入文章并基于apon feed-template.php显示它们,其中包含供稿文章的注释框和样式。
仅使用模板时,注释框似乎运行良好,但是当我用文章填充它时(也就是我打开Homefeed.php时),它会停止正常运行。
Feed-Template.php包含以下PHP:
<?php
if(isset($_GET['sendcode'])){
sendCode();
}
function sendCode(){
$filename = '~~~ItemTitle~~~.php';
if (file_exists($filename)) {
header('Location:~~~ItemTitle~~~.php');
} else {
$myfile = fopen("~~~ItemTitle~~~.php", "w");
$handle = fopen("~~~ItemTitle~~~.php","a");
fwrite ($handle, '
<?php
if ($_POST){
header("Refresh:0");
$name = $_POST["name"];
$content = $_POST["commentContent"];
$handle = fopen("~~~ItemTitle~~~.php","a");
fwrite ($handle,"<b>" . $name . "</b></br>" . $content . "</br>" . "<hr>");
fclose ($handle);}
?>
<title>~~~ItemTitle~~~</title>
<link href="http://127.0.0.1/projects/INDB%201.0/css/feed.css" rel="stylesheet">
<div align="left">
<form action="" method="POST" target="_parent">
Name: <input type = "text" name = "name"></br>
Comment: <textarea rows ="10" cols ="30" name="commentContent"></textarea></br>
<input type = "submit" value = "post!"></br>
</form>
<h3>~~~ItemTitle~~~</h3>
<h5><font size="-5">COMMENTS:</font></h5>
<hr>
');
header('Location:~~~ItemTitle~~~.php');
}}
?>
以及上面代码之后的Feed模板样式的HTMl。
PHP函数通过以下方式触发:
<A href="?sendcode=true" title="Comments" target="_self"><h2 class="toolhover2"><span class="glyphicon glyphicon-comment"></span></h2></A>
Homefeed.php的第一部分(可编辑)包含以下PHP :(通过RSS2HTML)
(由于字符限制,我将其压缩了)
<?PHP
//
// rss2html.php RSS feed to HTML webpage script
//
// Copyright 2004-2007 NotePage, Inc.
// http://www.feedforall.com
//
// This script may be used and modified freely for business or personal use
// This script may not be resold in any form
// This script may only be redistributed in its original form
//
//
// $Id: rss2html.php,v 3.13 2008/10/18 12:52:36 housley Exp $
//
//
// ==========================================================================
// Configuration options
// ==========================================================================
//
// Set the following variable useFopenURL to one if you want/need to use
// fopen() instead of CURL or FeedForAll_fopen()
$useFopenURL = 1;
//
// If XLMFILE is passed as part of the URL, XMLFILE=, then it will be used
// otherwise the the file below is used.
//$XMLfilename = 'http://examlple.com/sample.xml';
$XMLfilename = 'http://A RSS FEED LINK WOULD GO HERE.xml';
//
// If TEMPLATE is passed as part of the URL. TEMPLATE=, then it will be used
// otherwise the the file below is used.
//$TEMPLATEfilename = 'http://examlple.com/sample-template.html';
$TEMPLATEfilename = 'feed-template.php';
//
// Since some feeds may have titles or descriptins in the feed or items that
// are longer then want fits in your HTML page it is possible to trim them
// with the following 4 variables. A values of 0 (ZERO) displays the full
// length.
// CAUTION: Do not limit a title or description that has HTML in it, the
// will not produce a valid HTML page.
$limitFeedTitleLength = 0; // Not limited, in the URL as FeedTitleLength=
$limitFeedDescriptionLength = 0; // Not limited, in the URL as FeedDescriptionLength=
$limitItemTitleLength = 0; // Not limited, in the URL as ItemTitleLength=
$limitItemDescriptionLength = 0; // Not limited, in the URL as ItemDescriptionLength=
//
// date() function documented http://www.php.net/manual/en/function.date.php
$LongDateFormat = 'F jS, Y'; // ie, 'Jan 21st, 2004'
$ShortDateFormat = 'm/d/Y'; // ie, '1/21/2004'
//$ShortDateFormat = 'd/m/Y'; // ie, '21/1/2004'
$LongTimeFormat = 'H:i:s T O'; // ie, '13:24:30 EDT -0400'
$ShortTimeFormat = 'h:i A'; // ie, '1:24 PM'
//
// Timezone - If your server is not in the same timezone as you are the timezone
// of the times and dates produced in the above from can be controlled with the
// below code. Just uncomment the following line and change to the correct
// zonename. A full list is available here, http://www.php.net/manual/en/timezones.php
// You town.city probably isn't listed, so look for a neighboring major city
// putenv('TZ=America/New_York');
//
// Registered user of FeedForAll and FeedForAll Mac product(s) have access
// to a caching module. This enables it's use if it is installed.
$allowCachingXMLFiles = 0;
//
// File access level: The variable $fileAccessLevel can be used limit what files
// and type of files (local or remote) can be used with rss2html.php
// -1 = Remote files are NOT allowed, only local files allowed for template
// and feed which have filenames ending in extensions in the
// $allowedTemplateExtensions and $allowedFeedExtensions lists below
// 0 = Remote files and any local files allowed for template and feed
// 1 = Remote files and only local files allowed for template and feed
// which have filenames ending in extensions in the
// $allowedTemplateExtensions and $allowedFeedExtensions lists below
// 2 = No local files allowed, remote files only.
$fileAccessLevel = 1;
//
// Allowed file extensions is a list of the allowable extensions for local for
// the template and the feed. New entries can be added by following the example
// below.
$allowedTemplateExtensions = Array('.html', '.htm', '.shtml', '.php');
$allowedFeedExtensions = Array('.xml', '.rss');
//
// Destination Encoding: By default rss2html.php converts all feeds to UTF-8
// and then produces webpages in UTF-8 because UTF-8 is capable of displaying
// all possible characters.
$destinationEncoding = 'UTF-8';
//
// Missing Encoding Default: Some feeds do not specify the character set
// they are encoded in. The XML specification states that if there is no
// encoding specified the XML file, all RSS feeds are XML, must be encoded
// in UTF-8, but experience has show differently. This specifies the
// encoding that will be used for feeds that don't specify the encoding.
//$missingEncodingDefault = 'UTF-8';
$missingEncodingDefault = 'ISO-8859-1';
//
// Escape Ampersand In Links: Proper HTML requires that a link with an
// apersand in while inside of an HTML page have that '&' converted to
// '&'.
$escapeAmpInLinks = 1;
//
// $connectTimeoutLimit allows the limiting the amount of time cURL will
// wait to successfully connect to a remote server. Use with caution,
// a value too small will cause all connections to fail.
//$connectTimeoutLimit = 30;
//
// $hideErrors: This will prevent all error messages from being displayed.
// CAUTION enabling this will cause rss2html.php to fail silently with
// no indication to why there was no output
// $hideErrors = 1;
// ==========================================================================
// 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.
//
(由于字符数限制,已删除了REST)
当我运行homefeed.php时,它会在Feed顶部弹出表格,并显示以下错误: Heres an screenshot example
当我运行homefeed.php时,浏览器中的源代码将显示以下内容: A screenshot of the browser source
这是Feed-Template.php的外观以及其功能: Example of Feed-Template.php
^在运行Homefeed.php时,它应该以与提要模板示例中上面显示的格式相同的格式逐个显示文章。然后,用户单击注释按钮,它将触发PHP函数。目前,它仅适用于feed-template.php,不适用于homefeed.php。我在这里做错了什么? 任何帮助将不胜感激。我仍然是新来的礼节人员,对于在撰写此问题期间可能犯的任何错误深表歉意。