Reseller Hosting, Shared Hosting, Dedicated Hosting by Vortech Inc.

Go Back   Reseller Hosting, Shared Hosting, Dedicated Hosting by Vortech Inc. > >> General Public > Chit Chat Public
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Chit Chat Public Talk about any thing you want! This forum is public.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-29-2005, 11:48 AM
BizMonster BizMonster is offline
Registered User
Junior Member
 
PHP fopen issue

Wasnt sure where to post this question.

I know recently Vortech has closed down the fopen function. Are there any other "like" functions that we can use to open and read remote files?
Reply With Quote
  #2  
Old 06-29-2005, 12:08 PM
Dean's Avatar
Dean Dean is offline
Registered User
Admin
 
The CURL library provides similar functionality.

http://us2.php.net/manual/en/ref.curl.php
Reply With Quote
  #3  
Old 06-30-2005, 01:52 AM
BizMonster BizMonster is offline
Registered User
Junior Member
 
Thumbs up

Thanks Dean!

My cURL was a bit rusty but I got working.
Here is my code if any one is interested.

$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"http://www.somesite.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$post = curl_exec($ch);
curl_close($ch);

//Look for a specific range of text
$post = substr($post, 5556, -1);
Reply With Quote
  #4  
Old 07-03-2005, 06:22 PM
HerComServ HerComServ is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
What about system functions like chmod()

Since fopen() is not available - are system functions like chmod() allowed in php script? - unix server
Reply With Quote
  #5  
Old 07-03-2005, 10:34 PM
mresell's Avatar
mresell mresell is offline
ePerson
Vortech Inc. Customer
 
Location: Around the \bin
kinda hope not.
Reply With Quote
  #6  
Old 07-03-2005, 11:08 PM
Brangwyn Brangwyn is offline
T3CHN0 STUD
Vortech Inc. Customer
 
Location: New Zealand (Wellington)
I may be wrong but I think fopen still works for local files, it's only when you try to use fopen with a URL that it's been restricted.
Reply With Quote
  #7  
Old 07-04-2005, 11:23 PM
BizMonster BizMonster is offline
Registered User
Junior Member
 
Hmmm,
It definately works with opening local .html files. I was trying to open a remote html page. I didnt work for any URL, restricted or not.

cURL worked like a charm though.
Reply With Quote
  #8  
Old 07-05-2005, 06:45 AM
Brangwyn Brangwyn is offline
T3CHN0 STUD
Vortech Inc. Customer
 
Location: New Zealand (Wellington)
URL's are whats restricted though as I said, if your opening a local file you should be opening it using the physical path rather than a URL to get around it.
Reply With Quote
  #9  
Old 07-05-2005, 01:41 PM
BizMonster BizMonster is offline
Registered User
Junior Member
 
Sorry Brangwyn, My bad. I mis-understood your post. You're absolutely right.

As for the post from HerComServ. I hope an admin will see this and post an answer for you. I have been using ftp functions to chmod in my scripts.

Incase youre intereseted. This is for a file upload but could be modified to chmod an existing file.

$ftp_host = $acc_ftphost;
$ftp_user = $acc_ftpuser;
$ftp_password = $acc_ftppass;
$ftp_path = $acc_ftppath;

//Connect
$conn = ftp_connect($ftp_host);
$login = ftp_login($conn, $ftp_user, $ftp_password);

$mode = ftp_pasv($conn, TRUE);

$source .= $file_tmp;

$destination .= $file_upload;

$destinationDIR .= $ftp_path;
$destinationDIR .= "/images/pages/";

//change directory and upload
$change = ftp_chdir($conn, $destinationDIR);
$upload = ftp_put($conn, $destination, $source, FTP_BINARY);

//change permisions of file
$chmod_cmd="CHMOD 0755 ". $file_upload;
$chmod=ftp_site($conn, $chmod_cmd);
Reply With Quote
  #10  
Old 07-06-2005, 01:49 AM
Brangwyn Brangwyn is offline
T3CHN0 STUD
Vortech Inc. Customer
 
Location: New Zealand (Wellington)
You can just refer to the phpinfo to check any PHP settings you need ie http://unix11.hsphere.cc/phpinfo.php It shows you that allow_url_fopen is disabled.

CHMOD shouldn't be an issue, thats a system command not a PHP command.
Reply With Quote
  #11  
Old 07-12-2005, 05:27 PM
TicoGrande TicoGrande is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
Location: San Jose, Costa Rica
Assistance needed

I am using the script below for several web sites. It allows for a RSS feed from within a web page, directly accessable.

I am neither a PHP nor a cURL programmer, so I am hoping some kind soul can provise me a workaround for this.

Many thanks in advance!

Code:
<?PHP ini_set("allow_url_fopen", "1"); // If XLMfile is passed as part of the REQUEST_URI, then it will be used // otherwise the the file below is used. $XMLfilename = "http://examlple.com/sample.xml"; if (isset($_REQUEST["XMLFILE"])) { if (stristr($_REQUEST["XMLFILE"], "file://")) { // Not allowed ; } elseif (stristr($_REQUEST["XMLFILE"], "://")) { // URL files are allowed $XMLfilename = $_REQUEST["XMLFILE"]; } else { // It is local and must be in the same directory $XMLfilename = basename($_REQUEST["XMLFILE"]); } } // // If TEMPLATE is passed as part of the REQUEST_URI, then it will be used // otherwise the the file below is used. $TEMPLATEfilename = "mytemplate.html"; //the above is a local link if (isset($_REQUEST["TEMPLATE"])) { if (stristr($_REQUEST["TEMPLATE"], "file://")) { // Not allowed ; } elseif (stristr($_REQUEST["TEMPLATE"], "://")) { // URL files are allowed $TEMPLATEfilename = $_REQUEST["TEMPLATE"]; } else { // It is local and must be in the same directory $TEMPLATEfilename = basename($_REQUEST["TEMPLATE"]); } } // // 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" // // Maximum number of items to be displayed // $FeedMaxItems = 10000; if (isset($_REQUEST["MAXITEMS"])) { $FeedMaxItems = $_REQUEST["MAXITEMS"]; } $NoFutureItems = FALSE; if (isset($_REQUEST["NOFUTUREITEMS"])) { $NoFutureItems = TRUE; } Function getRFDdate($datestring) { $year = substr($datestring, 0, 4); $month = substr($datestring, 5, 2); $day = substr($datestring, 8, 2); $hour = substr($datestring, 11, 2); $minute = substr($datestring, 14, 2); $second = substr($datestring, 17, 2); if (substr($datestring, 19, 1) == "Z") { $offset_hour = 0; $offset_minute = 0; } else { if (substr($datestring, 19, 1) == "+") { $offset_hour = substr($datestring, 20, 2); $offset_minute = substr($datestring, 23, 2); } else { $offset_hour = -1*substr($datestring, 20, 2); $offset_minute = -1*substr($datestring, 23, 2); } } return gmmktime($hour+$offset_hour, $minute+$offset_minute, $second, $month, $day, $year); } // // As much as I hate globals, they are needed due to the // recusive nature of the parser $insidechannel = FALSE; $level_channel = 0; $insidechannelimage = FALSE; $level_channelimage = 0; $insideitem = FALSE; $level_item = 0; class RSSParser { var $gotROOT = 0; var $feedTYPE = "RSS"; var $level = 0; var $tag = ""; var $title = ""; var $description = ""; var $contentEncoded = ""; var $link = ""; var $guid = ""; var $enclosureURL = ""; var $pubdate = ""; var $pubdateDC = ""; var $fimageURL = ""; var $fimageTitle = ""; var $fimageLink = ""; var $FeedTitle = ""; var $FeedDescription = ""; var $FeedContentEncoded = ""; var $FeedLink = ""; var $FeedPubDate = ""; var $FeedPubDateDC = ""; var $FeedPubDate_t = ""; var $FeedImageURL = ""; var $FeedImageTitle = ""; var $FeedImageLink = ""; // When adding new Item elements, be sure to update the sort below var $ItemTitle = ""; var $ItemDescription = ""; var $ItemContentEncoded = ""; var $ItemLink = ""; var $ItemGuid = ""; var $ItemPubDate = ""; var $ItemPubDate_t = ""; var $ItemEnclosureURL = ""; function startElement($parser, $tagName, $attrs) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; $this->level++; $this->tag = $tagName; if ($this->gotROOT == 0) { $this->gotROOT = 1; if (strstr($tagName, "RSS")) { $this->feedTYPE = "RSS"; } elseif (strstr($tagName, "RDF")) { $this->feedTYPE = "RDF"; } elseif (strstr($tagName, "FEE")) { $this->feedTYPE = "FEE"; $insidechannel = TRUE; $level_channel = 1; } } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $insideitem = TRUE; $level_item = $this->level; } elseif (($insideitem) && ($tagName == "ENCLOSURE")) { $this->enclosureURL = $attrs["URL"]; } elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) { $this->link = $attrs["HREF"]; } elseif ($tagName == "CHANNEL") { $insidechannel = TRUE; $level_channel = $this->level; } elseif (($tagName == "IMAGE") && ($insidechannel = TRUE)) { $insidechannelimage = TRUE; $level_channelimage = $this->level; } } function endElement($parser, $tagName) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; GLOBAL $NoFutureItems; $this->level--; if ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $UseItem = TRUE; if ($NoFutureItems) { $noon = strtotime("today at 12:00"); if (trim($this->pubdate) != "") { $ItemPubDate = strtotime($this->pubdate); } else if (trim($this->pubdateDC) != "") { $ItemPubDate = getRFDdate($this->pubdateDC); } else { $ItemPubDate = time(); } if (($ItemPubDate - $noon) > 43200) { $UseItem = FALSE; } } if ($UseItem) { $this->ItemTitle[] = trim($this->title); $this->ItemDescription[] = trim($this->description); $this->ItemContentEncoded[] = trim($this->contentEncoded); if ($this->ItemContentEncoded == "") { $this->ItemContentEncoded = $this->ItemDescription; } $this->ItemLink[] = trim($this->link); // // Get the pubDate from pubDate first and then dc:date if (trim($this->pubdate) != "") { $this->ItemPubDate[] = trim($this->pubdate); $this->ItemPubDate_t[] = strtotime($this->pubdate); } else if (trim($this->pubdateDC) != "") { $this->ItemPubDate[] = trim($this->pubdateDC); $this->ItemPubDate_t[] = getRFDdate($this->pubdateDC); } else { $this->ItemPubDate[] = date("D, d M Y H:i:s +0000"); $this->ItemPubDate_t[] = time(); } $this->ItemGuid[] = trim($this->guid); $this->ItemEnclosureURL[] = trim($this->enclosureURL); } $this->title = ""; $this->description = ""; $this->contentEncoded = ""; $this->link = ""; $this->pubdate = ""; $this->pubdateDC = ""; $this->guid = ""; $this->enclosureURL = ""; $insideitem = FALSE; $level_item = 0; } elseif (($tagName == "IMAGE") && ($insidechannelimage)) { $this->FeedImageURL = trim($this->fimageURL); $this->FeedImageTitle = trim($this->fimageTitle); $this->FeedImageLink = trim($this->fimageLink); $this->fimageURL = ""; $this->fimageTitle = ""; $this->fimageLink = ""; $insidechannelimage = FALSE; $level_channelimage = 0; } elseif ($tagName == "CHANNEL") { // // Get the pubDate from pubDate first and then dc:date if (trim($this->pubdate) != "") { $this->FeedPubDate_t = strtotime($this->FeedPubDate); } else if (trim($this->pubdateDC) != "") { $this->FeedPubDate_t = getRFDdate($this->FeedPubDateDC); } else { $this->FeedPubDate = date("D, d M Y H:i:s +0000"); $this->FeedPubDate_t = time(); } $insidechannel = FALSE; $level_channel = 0; } elseif ($this->level == $level_channel) { if ($tagName == "TITLE") { $this->FeedTitle = trim($this->title); $this->title = ""; } elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) { $this->FeedDescription = trim($this->description); $this->description = ""; } elseif ($tagName == "CONTENT:ENCODED") { $this->FeedContentEncoded = trim($this->contentEncoded); $this->contentEncoded = ""; } elseif ($tagName == "LINK") { $this->FeedLink = trim($this->link); $this->link = ""; } } } function characterData($parser, $data) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; if (($data == "") || ($data == NULL)) { } else { if (($insideitem) && ($this->level == $level_item+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT:ENCODED": $this->contentEncoded .= $data; break; case "SUMMARY": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBDATE": $this->pubdate .= $data; break; case "DC:DATE": $this->pubdateDC .= $data; break; case "MODIFIED": $this->pubdateDC .= $data; break; case "GUID": $this->guid .= $data; break; } } elseif ($insidechannelimage) { switch ($this->tag) { case "TITLE": $this->fimageTitle .= $data; break; case "URL": $this->fimageURL .= $data; break; case "LINK": $this->fimageLink .= $data; break; } } elseif (($insidechannel) && ($this->level == $level_channel+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT:ENCODED": $this->contentEncoded .= $data; break; case "TAGLINE": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBDATE": $this->FeedPubDate .= $data; break; case "DC:DATE": $this->FeedPubDateDC .= $data; break; case "MODIFIED": $this->FeedPubDateDC .= $data; break; } } } } } if (($fd = @fopen($TEMPLATEfilename, "rb")) === FALSE) { echo "Unable to open template $TEMPLATEfilename, exiting\n"; exit -1; } $template = NULL; while (($data = fread($fd, 4096)) != "") { $template .= $data; } fclose($fd); if (strstr($template, "~~~NoFutureItems~~~")) { $NoFutureItems = TRUE; } $xml_parser = xml_parser_create(''); $rss_parser = new RSSParser(); xml_set_object($xml_parser,$rss_parser); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,1); if (($fd = @fopen($XMLfilename, "rb")) === FALSE) { echo "Unable to open RSS Feed $XMLfilename, exiting\n"; exit -1; } // Read the whole file 4k at a time so remote files can be read while (($XML = fread($fd, 4096)) != "") { xml_parse($xml_parser,$XML); } fclose($fd); xml_parser_free($xml_parser); // make sure the channel contentEncoded is not blank if ($rss_parser->FeedContentEncoded == "") { $rss_parser->FeedContentEncoded = $rss_parser->FeedDescription; } $template = str_replace("~~~FeedTitle~~~", $rss_parser->FeedTitle, $template); $template = str_replace("~~~FeedDescription~~~", $rss_parser->FeedDescription, $template); $template = str_replace("~~~FeedContentEncoded~~~", $rss_parser->FeedContentEncoded, $template); $template = str_replace("~~~FeedLink~~~", $rss_parser->FeedLink, $template); $template = str_replace("~~~FeedPubDate~~~", $rss_parser->FeedPubDate, $template); $template = str_replace("~~~FeedPubLongDate~~~", date($LongDateFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubShortDate~~~", date($ShortDateFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubLongTime~~~", date($LongTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubShortTime~~~", date($ShortTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedImageUrl~~~", $rss_parser->FeedImageURL, $template); $template = str_replace("~~~FeedImageTitle~~~", $rss_parser->FeedImageTitle, $template); $template = str_replace("~~~FeedImageLink~~~", $rss_parser->FeedImageLink, $template); $match = NULL; $template = str_replace("~~~NoFutureItems~~~", "", $template); // Sort by PubDate if requested if (strstr($template, "~~~SortByPubDate~~~")) { $template = str_replace("~~~SortByPubDate~~~", "", $template); for ($x = 0; $x < count($rss_parser->ItemTitle)-1; $x++) { for ($y = $x+1; $y < count($rss_parser->ItemTitle); $y++) { if ($rss_parser->ItemPubDate_t[$x] < $rss_parser->ItemPubDate_t[$y]) { // Swap them $swapTemp = $rss_parser->ItemTitle[$x]; $rss_parser->ItemTitle[$x] = $rss_parser->ItemTitle[$y]; $rss_parser->ItemTitle[$y] = $swapTemp; $swapTemp = $rss_parser->ItemDescription[$x]; $rss_parser->ItemDescription[$x] = $rss_parser->ItemDescription[$y]; $rss_parser->ItemDescription[$y] = $swapTemp; $swapTemp = $rss_parser->ItemContentEncoded[$x]; $rss_parser->ItemContentEncoded[$x] = $rss_parser->ItemContentEncoded[$y]; $rss_parser->ItemContentEncoded[$y] = $swapTemp; $swapTemp = $rss_parser->ItemLink[$x]; $rss_parser->ItemLink[$x] = $rss_parser->ItemLink[$y]; $rss_parser->ItemLink[$y] = $swapTemp; $swapTemp = $rss_parser->ItemGuid[$x]; $rss_parser->ItemGuid[$x] = $rss_parser->ItemGuid[$y]; $rss_parser->ItemGuid[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate[$x]; $rss_parser->ItemPubDate[$x] = $rss_parser->ItemPubDate[$y]; $rss_parser->ItemPubDate[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate_t[$x]; $rss_parser->ItemPubDate_t[$x] = $rss_parser->ItemPubDate_t[$y]; $rss_parser->ItemPubDate_t[$y] = $swapTemp; $swapTemp = $rss_parser->ItemEnclosureURL[$x]; $rss_parser->ItemEnclosureURL[$x] = $rss_parser->ItemEnclosureURL[$y]; $rss_parser->ItemEnclosureURL[$y] = $swapTemp; } } } } // The the maximum items requested if (strstr($template, "~~~FeedMaxItems=")) { // Limit the maximun number of items displayed if (preg_match("/~~~FeedMaxItems=([0-9-]*)~~~/", $template, $match) !== FALSE) { if (($match[0] != "") && ($match[1] != "")) { $FeedMaxItems = $match[1]; $template = str_replace("~~~FeedMaxItems=$match[1]~~~", "", $template); if (abs($FeedMaxItems) > count($rss_parser->ItemTitle)) { if ($FeedMaxItems > 0) { $FeedMaxItems = count($rss_parser->ItemTitle); } else { $FeedMaxItems = -count($rss_parser->ItemTitle); } } } } } // // Find the string, if it exists, between the ~~~EndItemsRecord~~~ and ~~~BeginItemsRecord~~~ // while ((strstr($template, "~~~BeginItemsRecord~~~")) !== FALSE) { $match = NULL; $allitems = NULL; $loop_limit = min(abs($FeedMaxItems), count($rss_parser->ItemTitle)); if (($parts = split("~~~BeginItemsRecord~~~", $template)) !== FALSE) { if (($parts = split("~~~EndItemsRecord~~~", $parts[1])) !== FALSE) { $WholeBlock = $parts[0]; // // Check for ~~~BeginAlternateItemsRecord~~~ // if (strstr($WholeBlock, "~~~BeginAlternateItemsRecord~~~")) { $parts = split("~~~BeginAlternateItemsRecord~~~", $WholeBlock); $block1 = $parts[0]; $block2 = $parts[1]; } else { $block1 = $WholeBlock; $block2 = $WholeBlock; } if ($FeedMaxItems < 0) { for ($x = count($rss_parser->ItemTitle)-1; $x >= count($rss_parser->ItemTitle) + $FeedMaxItems; $x--) { $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block1); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; $x--; if ($x >= count($rss_parser->ItemTitle) + $FeedMaxItems) { // // This is at least one more item so use the Alternate definition // $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block2); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; } } } else { for ($x = 0; $x < $loop_limit; $x++) { $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block1); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; $x++; if ($x < $loop_limit) { // // This is at least one more item so use the Alternate definition // $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block2); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; } } } $template = str_replace("~~~BeginItemsRecord~~~".$WholeBlock."~~~EndItemsRecord~~~", $allitems, $template); } } } echo $template; ?>

By the way, this is a public domain script, so anyone interested can use it.

TG
__________________
San José, Costa Rica
Reply With Quote
  #12  
Old 11-16-2005, 09:35 AM
NotePage NotePage is offline
Registered User
Junior Member
 
home rss2html php script

Quote:
Originally Posted by TicoGrande
I am using the script below for several web sites. It allows for a RSS feed from within a web page, directly accessable.

I am neither a PHP nor a cURL programmer, so I am hoping some kind soul can provise me a workaround for this.

Many thanks in advance!

Code:
<?PHP ini_set("allow_url_fopen", "1"); // If XLMfile is passed as part of the REQUEST_URI, then it will be used // otherwise the the file below is used. $XMLfilename = "http://examlple.com/sample.xml"; if (isset($_REQUEST["XMLFILE"])) { if (stristr($_REQUEST["XMLFILE"], "file://")) { // Not allowed ; } elseif (stristr($_REQUEST["XMLFILE"], "://")) { // URL files are allowed $XMLfilename = $_REQUEST["XMLFILE"]; } else { // It is local and must be in the same directory $XMLfilename = basename($_REQUEST["XMLFILE"]); } } // // If TEMPLATE is passed as part of the REQUEST_URI, then it will be used // otherwise the the file below is used. $TEMPLATEfilename = "mytemplate.html"; //the above is a local link if (isset($_REQUEST["TEMPLATE"])) { if (stristr($_REQUEST["TEMPLATE"], "file://")) { // Not allowed ; } elseif (stristr($_REQUEST["TEMPLATE"], "://")) { // URL files are allowed $TEMPLATEfilename = $_REQUEST["TEMPLATE"]; } else { // It is local and must be in the same directory $TEMPLATEfilename = basename($_REQUEST["TEMPLATE"]); } } // // 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" // // Maximum number of items to be displayed // $FeedMaxItems = 10000; if (isset($_REQUEST["MAXITEMS"])) { $FeedMaxItems = $_REQUEST["MAXITEMS"]; } $NoFutureItems = FALSE; if (isset($_REQUEST["NOFUTUREITEMS"])) { $NoFutureItems = TRUE; } Function getRFDdate($datestring) { $year = substr($datestring, 0, 4); $month = substr($datestring, 5, 2); $day = substr($datestring, 8, 2); $hour = substr($datestring, 11, 2); $minute = substr($datestring, 14, 2); $second = substr($datestring, 17, 2); if (substr($datestring, 19, 1) == "Z") { $offset_hour = 0; $offset_minute = 0; } else { if (substr($datestring, 19, 1) == "+") { $offset_hour = substr($datestring, 20, 2); $offset_minute = substr($datestring, 23, 2); } else { $offset_hour = -1*substr($datestring, 20, 2); $offset_minute = -1*substr($datestring, 23, 2); } } return gmmktime($hour+$offset_hour, $minute+$offset_minute, $second, $month, $day, $year); } // // As much as I hate globals, they are needed due to the // recusive nature of the parser $insidechannel = FALSE; $level_channel = 0; $insidechannelimage = FALSE; $level_channelimage = 0; $insideitem = FALSE; $level_item = 0; class RSSParser { var $gotROOT = 0; var $feedTYPE = "RSS"; var $level = 0; var $tag = ""; var $title = ""; var $description = ""; var $contentEncoded = ""; var $link = ""; var $guid = ""; var $enclosureURL = ""; var $pubdate = ""; var $pubdateDC = ""; var $fimageURL = ""; var $fimageTitle = ""; var $fimageLink = ""; var $FeedTitle = ""; var $FeedDescription = ""; var $FeedContentEncoded = ""; var $FeedLink = ""; var $FeedPubDate = ""; var $FeedPubDateDC = ""; var $FeedPubDate_t = ""; var $FeedImageURL = ""; var $FeedImageTitle = ""; var $FeedImageLink = ""; // When adding new Item elements, be sure to update the sort below var $ItemTitle = ""; var $ItemDescription = ""; var $ItemContentEncoded = ""; var $ItemLink = ""; var $ItemGuid = ""; var $ItemPubDate = ""; var $ItemPubDate_t = ""; var $ItemEnclosureURL = ""; function startElement($parser, $tagName, $attrs) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; $this->level++; $this->tag = $tagName; if ($this->gotROOT == 0) { $this->gotROOT = 1; if (strstr($tagName, "RSS")) { $this->feedTYPE = "RSS"; } elseif (strstr($tagName, "RDF")) { $this->feedTYPE = "RDF"; } elseif (strstr($tagName, "FEE")) { $this->feedTYPE = "FEE"; $insidechannel = TRUE; $level_channel = 1; } } elseif ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $insideitem = TRUE; $level_item = $this->level; } elseif (($insideitem) && ($tagName == "ENCLOSURE")) { $this->enclosureURL = $attrs["URL"]; } elseif (($tagName == "LINK") && ($this->feedTYPE == "FEE")) { $this->link = $attrs["HREF"]; } elseif ($tagName == "CHANNEL") { $insidechannel = TRUE; $level_channel = $this->level; } elseif (($tagName == "IMAGE") && ($insidechannel = TRUE)) { $insidechannelimage = TRUE; $level_channelimage = $this->level; } } function endElement($parser, $tagName) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; GLOBAL $NoFutureItems; $this->level--; if ((($tagName == "ITEM") && ($this->feedTYPE != "FEE")) || (($tagName == "ENTRY") && ($this->feedTYPE == "FEE"))) { $UseItem = TRUE; if ($NoFutureItems) { $noon = strtotime("today at 12:00"); if (trim($this->pubdate) != "") { $ItemPubDate = strtotime($this->pubdate); } else if (trim($this->pubdateDC) != "") { $ItemPubDate = getRFDdate($this->pubdateDC); } else { $ItemPubDate = time(); } if (($ItemPubDate - $noon) > 43200) { $UseItem = FALSE; } } if ($UseItem) { $this->ItemTitle[] = trim($this->title); $this->ItemDescription[] = trim($this->description); $this->ItemContentEncoded[] = trim($this->contentEncoded); if ($this->ItemContentEncoded == "") { $this->ItemContentEncoded = $this->ItemDescription; } $this->ItemLink[] = trim($this->link); // // Get the pubDate from pubDate first and then dc:date if (trim($this->pubdate) != "") { $this->ItemPubDate[] = trim($this->pubdate); $this->ItemPubDate_t[] = strtotime($this->pubdate); } else if (trim($this->pubdateDC) != "") { $this->ItemPubDate[] = trim($this->pubdateDC); $this->ItemPubDate_t[] = getRFDdate($this->pubdateDC); } else { $this->ItemPubDate[] = date("D, d M Y H:i:s +0000"); $this->ItemPubDate_t[] = time(); } $this->ItemGuid[] = trim($this->guid); $this->ItemEnclosureURL[] = trim($this->enclosureURL); } $this->title = ""; $this->description = ""; $this->contentEncoded = ""; $this->link = ""; $this->pubdate = ""; $this->pubdateDC = ""; $this->guid = ""; $this->enclosureURL = ""; $insideitem = FALSE; $level_item = 0; } elseif (($tagName == "IMAGE") && ($insidechannelimage)) { $this->FeedImageURL = trim($this->fimageURL); $this->FeedImageTitle = trim($this->fimageTitle); $this->FeedImageLink = trim($this->fimageLink); $this->fimageURL = ""; $this->fimageTitle = ""; $this->fimageLink = ""; $insidechannelimage = FALSE; $level_channelimage = 0; } elseif ($tagName == "CHANNEL") { // // Get the pubDate from pubDate first and then dc:date if (trim($this->pubdate) != "") { $this->FeedPubDate_t = strtotime($this->FeedPubDate); } else if (trim($this->pubdateDC) != "") { $this->FeedPubDate_t = getRFDdate($this->FeedPubDateDC); } else { $this->FeedPubDate = date("D, d M Y H:i:s +0000"); $this->FeedPubDate_t = time(); } $insidechannel = FALSE; $level_channel = 0; } elseif ($this->level == $level_channel) { if ($tagName == "TITLE") { $this->FeedTitle = trim($this->title); $this->title = ""; } elseif (($tagName == "DESCRIPTION") || ($tagName == "TAGLINE")) { $this->FeedDescription = trim($this->description); $this->description = ""; } elseif ($tagName == "CONTENT:ENCODED") { $this->FeedContentEncoded = trim($this->contentEncoded); $this->contentEncoded = ""; } elseif ($tagName == "LINK") { $this->FeedLink = trim($this->link); $this->link = ""; } } } function characterData($parser, $data) { GLOBAL $insidechannel; GLOBAL $level_channel; GLOBAL $insidechannelimage; GLOBAL $level_channelimage; GLOBAL $insideitem; GLOBAL $level_item; if (($data == "") || ($data == NULL)) { } else { if (($insideitem) && ($this->level == $level_item+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT:ENCODED": $this->contentEncoded .= $data; break; case "SUMMARY": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBDATE": $this->pubdate .= $data; break; case "DC:DATE": $this->pubdateDC .= $data; break; case "MODIFIED": $this->pubdateDC .= $data; break; case "GUID": $this->guid .= $data; break; } } elseif ($insidechannelimage) { switch ($this->tag) { case "TITLE": $this->fimageTitle .= $data; break; case "URL": $this->fimageURL .= $data; break; case "LINK": $this->fimageLink .= $data; break; } } elseif (($insidechannel) && ($this->level == $level_channel+1)) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "CONTENT:ENCODED": $this->contentEncoded .= $data; break; case "TAGLINE": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBDATE": $this->FeedPubDate .= $data; break; case "DC:DATE": $this->FeedPubDateDC .= $data; break; case "MODIFIED": $this->FeedPubDateDC .= $data; break; } } } } } if (($fd = @fopen($TEMPLATEfilename, "rb")) === FALSE) { echo "Unable to open template $TEMPLATEfilename, exiting\n"; exit -1; } $template = NULL; while (($data = fread($fd, 4096)) != "") { $template .= $data; } fclose($fd); if (strstr($template, "~~~NoFutureItems~~~")) { $NoFutureItems = TRUE; } $xml_parser = xml_parser_create(''); $rss_parser = new RSSParser(); xml_set_object($xml_parser,$rss_parser); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,1); if (($fd = @fopen($XMLfilename, "rb")) === FALSE) { echo "Unable to open RSS Feed $XMLfilename, exiting\n"; exit -1; } // Read the whole file 4k at a time so remote files can be read while (($XML = fread($fd, 4096)) != "") { xml_parse($xml_parser,$XML); } fclose($fd); xml_parser_free($xml_parser); // make sure the channel contentEncoded is not blank if ($rss_parser->FeedContentEncoded == "") { $rss_parser->FeedContentEncoded = $rss_parser->FeedDescription; } $template = str_replace("~~~FeedTitle~~~", $rss_parser->FeedTitle, $template); $template = str_replace("~~~FeedDescription~~~", $rss_parser->FeedDescription, $template); $template = str_replace("~~~FeedContentEncoded~~~", $rss_parser->FeedContentEncoded, $template); $template = str_replace("~~~FeedLink~~~", $rss_parser->FeedLink, $template); $template = str_replace("~~~FeedPubDate~~~", $rss_parser->FeedPubDate, $template); $template = str_replace("~~~FeedPubLongDate~~~", date($LongDateFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubShortDate~~~", date($ShortDateFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubLongTime~~~", date($LongTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedPubShortTime~~~", date($ShortTimeFormat, $rss_parser->FeedPubDate_t), $template); $template = str_replace("~~~FeedImageUrl~~~", $rss_parser->FeedImageURL, $template); $template = str_replace("~~~FeedImageTitle~~~", $rss_parser->FeedImageTitle, $template); $template = str_replace("~~~FeedImageLink~~~", $rss_parser->FeedImageLink, $template); $match = NULL; $template = str_replace("~~~NoFutureItems~~~", "", $template); // Sort by PubDate if requested if (strstr($template, "~~~SortByPubDate~~~")) { $template = str_replace("~~~SortByPubDate~~~", "", $template); for ($x = 0; $x < count($rss_parser->ItemTitle)-1; $x++) { for ($y = $x+1; $y < count($rss_parser->ItemTitle); $y++) { if ($rss_parser->ItemPubDate_t[$x] < $rss_parser->ItemPubDate_t[$y]) { // Swap them $swapTemp = $rss_parser->ItemTitle[$x]; $rss_parser->ItemTitle[$x] = $rss_parser->ItemTitle[$y]; $rss_parser->ItemTitle[$y] = $swapTemp; $swapTemp = $rss_parser->ItemDescription[$x]; $rss_parser->ItemDescription[$x] = $rss_parser->ItemDescription[$y]; $rss_parser->ItemDescription[$y] = $swapTemp; $swapTemp = $rss_parser->ItemContentEncoded[$x]; $rss_parser->ItemContentEncoded[$x] = $rss_parser->ItemContentEncoded[$y]; $rss_parser->ItemContentEncoded[$y] = $swapTemp; $swapTemp = $rss_parser->ItemLink[$x]; $rss_parser->ItemLink[$x] = $rss_parser->ItemLink[$y]; $rss_parser->ItemLink[$y] = $swapTemp; $swapTemp = $rss_parser->ItemGuid[$x]; $rss_parser->ItemGuid[$x] = $rss_parser->ItemGuid[$y]; $rss_parser->ItemGuid[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate[$x]; $rss_parser->ItemPubDate[$x] = $rss_parser->ItemPubDate[$y]; $rss_parser->ItemPubDate[$y] = $swapTemp; $swapTemp = $rss_parser->ItemPubDate_t[$x]; $rss_parser->ItemPubDate_t[$x] = $rss_parser->ItemPubDate_t[$y]; $rss_parser->ItemPubDate_t[$y] = $swapTemp; $swapTemp = $rss_parser->ItemEnclosureURL[$x]; $rss_parser->ItemEnclosureURL[$x] = $rss_parser->ItemEnclosureURL[$y]; $rss_parser->ItemEnclosureURL[$y] = $swapTemp; } } } } // The the maximum items requested if (strstr($template, "~~~FeedMaxItems=")) { // Limit the maximun number of items displayed if (preg_match("/~~~FeedMaxItems=([0-9-]*)~~~/", $template, $match) !== FALSE) { if (($match[0] != "") && ($match[1] != "")) { $FeedMaxItems = $match[1]; $template = str_replace("~~~FeedMaxItems=$match[1]~~~", "", $template); if (abs($FeedMaxItems) > count($rss_parser->ItemTitle)) { if ($FeedMaxItems > 0) { $FeedMaxItems = count($rss_parser->ItemTitle); } else { $FeedMaxItems = -count($rss_parser->ItemTitle); } } } } } // // Find the string, if it exists, between the ~~~EndItemsRecord~~~ and ~~~BeginItemsRecord~~~ // while ((strstr($template, "~~~BeginItemsRecord~~~")) !== FALSE) { $match = NULL; $allitems = NULL; $loop_limit = min(abs($FeedMaxItems), count($rss_parser->ItemTitle)); if (($parts = split("~~~BeginItemsRecord~~~", $template)) !== FALSE) { if (($parts = split("~~~EndItemsRecord~~~", $parts[1])) !== FALSE) { $WholeBlock = $parts[0]; // // Check for ~~~BeginAlternateItemsRecord~~~ // if (strstr($WholeBlock, "~~~BeginAlternateItemsRecord~~~")) { $parts = split("~~~BeginAlternateItemsRecord~~~", $WholeBlock); $block1 = $parts[0]; $block2 = $parts[1]; } else { $block1 = $WholeBlock; $block2 = $WholeBlock; } if ($FeedMaxItems < 0) { for ($x = count($rss_parser->ItemTitle)-1; $x >= count($rss_parser->ItemTitle) + $FeedMaxItems; $x--) { $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block1); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; $x--; if ($x >= count($rss_parser->ItemTitle) + $FeedMaxItems) { // // This is at least one more item so use the Alternate definition // $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block2); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; } } } else { for ($x = 0; $x < $loop_limit; $x++) { $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block1); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; $x++; if ($x < $loop_limit) { // // This is at least one more item so use the Alternate definition // $item = str_replace("~~~ItemTitle~~~", $rss_parser->ItemTitle[$x], $block2); $item = str_replace("~~~ItemDescription~~~", $rss_parser->ItemDescription[$x], $item); $item = str_replace("~~~ItemContentEncoded~~~", $rss_parser->ItemContentEncoded[$x], $item); $item = str_replace("~~~ItemLink~~~", $rss_parser->ItemLink[$x], $item); $item = str_replace("~~~ItemPubDate~~~", $rss_parser->ItemPubDate[$x], $item); $item = str_replace("~~~ItemGuid~~~", urlencode($rss_parser->ItemGuid[$x]), $item); $item = str_replace("~~~ItemPubLongDate~~~", date($LongDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortDate~~~", date($ShortDateFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubLongTime~~~", date($LongTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemPubShortTime~~~", date($ShortTimeFormat, $rss_parser->ItemPubDate_t[$x]), $item); $item = str_replace("~~~ItemEnclosureUrl~~~", $rss_parser->ItemEnclosureURL[$x], $item); $allitems .= $item; } } } $template = str_replace("~~~BeginItemsRecord~~~".$WholeBlock."~~~EndItemsRecord~~~", $allitems, $template); } } } echo $template; ?>

By the way, this is a public domain script, so anyone interested can use it.

TG

The script is free to use for personal or business use, and a more current version can be found here. Technical support for the rss2html.php script can also be found there.

However, the script you posted is NOT public domain. It belongs to NotePage, Inc. The copyright notice at the beginning of the script has been stripped off by someone.
Reply With Quote
  #13  
Old 11-16-2005, 12:09 PM
BizMonster BizMonster is offline
Registered User
Junior Member
 
NotePage, just for your peace of mind I ended up going another route with my issue after all and I havent posted that code anywhere else or anything like that.

Thanks for that link to feed for all though. Very helpful.
Reply With Quote
  #14  
Old 11-17-2005, 05:53 AM
Catalyst-X Catalyst-X is offline
Vortech Inc. Customer
Vortech Inc. Customer
 
Location: Australia
OK I understand Biz monsters CURL code the file is left in a string... Not being a php programmer... how do I write that out to a file?
Will that still work it is a 6 meg file ... what would I need to change?
__________________
Geoff Currie
http://www.Catalyst-X.com.au

Have a fantastic day :-)
Reply With Quote
  #15  
Old 11-17-2005, 11:39 AM
BizMonster BizMonster is offline
Registered User
Junior Member
 
I think this is what youre asking for. the w+ creates a file if it doesnt exist. You may need to look at