dongxinyue2817 2018-12-04 19:34
浏览 45

PHP函数运行不正常

I am building a comment box in PHP that works with RSS2HTML and allows users to comment on articles on a page.

Homefeed.php pulls in articles and displays them based apon feed-template.php which contains the comment box and styling for the feed articles.

The comment box seems to be working fine when just using the template, but when I populate it with articles (Aka when I open Homefeed.php) it ceases to function properly.

Feed-Template.php contains the following 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');
}}
?> 

As well as the HTMl for the Feed Template Styling which follows the code above.

The PHP Function is triggered with:

 <A href="?sendcode=true" title="Comments" target="_self"><h2 class="toolhover2"><span class="glyphicon glyphicon-comment"></span></h2></A>

The first (Editable) portion of Homefeed.php contains the following PHP: (By RSS2HTML)

(I Condensed it down due to character limit)

<?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
// '&amp;'.
$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.
// 

(THE REST HAS BEEN REDACTED DUE TO CHARACTER LIMIT)

When I run homefeed.php it pops the form in the top of the feed and displays these errors: Heres an screenshot example

And the source in the browser shows this when i run homefeed.php: A screenshot of the browser source

This is what the Feed-Template.php looks like, and how it should function: Example of Feed-Template.php

^ When running Homefeed.php it should display that articles, one after another, in the same format that is displayed above in the feed-template example. Then a user clicks the comment button it should fire the PHP function. At the moment it only works in feed-template.php and not when i put it into practice with homefeed.php. What am i doing wrong here? Any help would be greatly appreciated. I am still new to stack etiquette and apologize for any errors I might of made during the writing of this question.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 有人会搭建GPT-J-6B框架吗?有偿
    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名