Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 05:19 pm EST
Geeklog Forums
errors on static pages
Theophile
Anonymous
I am receiving 4 lines of errors above the header whenever I display static pages. I believe the errors are caused by the php block I am using to show random images from my Cafepress store. Here is the code for the php block in question. This is located in lib-common.php:
{
global $_CONF;
// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'monopedilos,ipcclinton,';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = 'cpitemfile.inc';
$mode = $_SERVER['QUERY_STRING'];
//$mode = "update";
if ($mode == "update") {
echo "Beginning CP item file update...<br>\n";
// connect to CP
$reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
$socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr);
if ($socket)
{
fputs($socket, $reqheader);
while (!feof($socket))
{
$cpfile .= fgets($socket, 4096);
}
}
fclose($socket);
$items = eregi("$start(.*)$end", $cpfile, $cparray);
$newcparray = split ("\n", $cparray[1]);
foreach ($newcparray as $line) {
if (strlen($line) > 100)
{
$newestcparray[] = $line;
}
}
$handle = fopen($itemfile, "w");
foreach ($newestcparray as $line) {
$line = ereg_replace("<td align=\"center\" valign=\"top\"><p>","",$line);
$line = ereg_replace("</td>","",$line);
$line = ereg_replace("150","100",$line);
$line = ereg_replace("<b>(.*)</b>","",$line);
// $line = ereg_replace("\\$(.*)\r", "\r", $line); // Uncomment to hide prices
$line = ereg_replace("prod.aspx\?","prod&",$line); //this line is just used to integrate with custom store. delete to use regular cp store.
if (eregi("<td colspan=3>",$line)) {unset ($line);}
if (eregi("<tr>",$line)) {unset ($line);}
$line = ereg_replace("<a href=\"","<a href=\"http://www.monopedilos.com/store.php?target=http://www.cafepress.com",$line);
$line = ereg_replace("src=\"/cp/img","src=\"http://www.cafepress.com/cp/img",$line);
if (!empty($line)) {
$lastcparray[] = $line;
fwrite($handle, $line);
}
}
fclose($handle);
echo "CP item file update completed.\n";
}
else {
$itemhandle = fopen($itemfile, "r");
$itemarray = fread($itemhandle,filesize("$itemfile"));
fclose($itemhandle);
$lastcparray = split ("\r", $itemarray);
$item = $lastcparray[rand(0,count($lastcparray)-2)];
$item = ereg_replace("[\x27]",'',$item);
$item = trim($item);
//for javascript use:
//echo "document.write('<div align=\"center\">" . $item . "</div>');";
//for php use:
$theitem = '<div align="center">' . $item . '<br>';
$theitem .= '<a href="' . $_CONF['site_url'] . '/store.php"><strong>More Products</strong></a></div>';
return $theitem;
}
}
The errors I receive look like this:
Warning: filesize(): Stat failed for cpitemfile.inc (errno=2 - No such file or directory) in /var/www/localhost/htdocs/lib-common.php on line 4499
Warning: fread(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/lib-common.php on line 4499
Warning: fclose(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/lib-common.php on line 4500
You can see the errors for yourself by going to:
http://monopedilos.com/staticpages/index.php/drawing
Again, this only occurs on static pages.
Any help appreciated! Thanks!
Text Formatted Code
function phpblock_randomitem(){
global $_CONF;
// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'monopedilos,ipcclinton,';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = 'cpitemfile.inc';
$mode = $_SERVER['QUERY_STRING'];
//$mode = "update";
if ($mode == "update") {
echo "Beginning CP item file update...<br>\n";
// connect to CP
$reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
$socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr);
if ($socket)
{
fputs($socket, $reqheader);
while (!feof($socket))
{
$cpfile .= fgets($socket, 4096);
}
}
fclose($socket);
$items = eregi("$start(.*)$end", $cpfile, $cparray);
$newcparray = split ("\n", $cparray[1]);
foreach ($newcparray as $line) {
if (strlen($line) > 100)
{
$newestcparray[] = $line;
}
}
$handle = fopen($itemfile, "w");
foreach ($newestcparray as $line) {
$line = ereg_replace("<td align=\"center\" valign=\"top\"><p>","",$line);
$line = ereg_replace("</td>","",$line);
$line = ereg_replace("150","100",$line);
$line = ereg_replace("<b>(.*)</b>","",$line);
// $line = ereg_replace("\\$(.*)\r", "\r", $line); // Uncomment to hide prices
$line = ereg_replace("prod.aspx\?","prod&",$line); //this line is just used to integrate with custom store. delete to use regular cp store.
if (eregi("<td colspan=3>",$line)) {unset ($line);}
if (eregi("<tr>",$line)) {unset ($line);}
$line = ereg_replace("<a href=\"","<a href=\"http://www.monopedilos.com/store.php?target=http://www.cafepress.com",$line);
$line = ereg_replace("src=\"/cp/img","src=\"http://www.cafepress.com/cp/img",$line);
if (!empty($line)) {
$lastcparray[] = $line;
fwrite($handle, $line);
}
}
fclose($handle);
echo "CP item file update completed.\n";
}
else {
$itemhandle = fopen($itemfile, "r");
$itemarray = fread($itemhandle,filesize("$itemfile"));
fclose($itemhandle);
$lastcparray = split ("\r", $itemarray);
$item = $lastcparray[rand(0,count($lastcparray)-2)];
$item = ereg_replace("[\x27]",'',$item);
$item = trim($item);
//for javascript use:
//echo "document.write('<div align=\"center\">" . $item . "</div>');";
//for php use:
$theitem = '<div align="center">' . $item . '<br>';
$theitem .= '<a href="' . $_CONF['site_url'] . '/store.php"><strong>More Products</strong></a></div>';
return $theitem;
}
}
The errors I receive look like this:
Text Formatted Code
Warning: fopen(cpitemfile.inc): failed to open stream: No such file or directory in /var/www/localhost/htdocs/lib-common.php on line 4498Warning: filesize(): Stat failed for cpitemfile.inc (errno=2 - No such file or directory) in /var/www/localhost/htdocs/lib-common.php on line 4499
Warning: fread(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/lib-common.php on line 4499
Warning: fclose(): supplied argument is not a valid stream resource in /var/www/localhost/htdocs/lib-common.php on line 4500
You can see the errors for yourself by going to:
http://monopedilos.com/staticpages/index.php/drawing
Again, this only occurs on static pages.
Any help appreciated! Thanks!
7
6
Quote
Status: Banned
gtgillis
Forum User
Full Member
Registered: 11/05/03
Posts: 121
From the errors it looks like the file cpitemfile.inc is not found.
5
5
Quote
Status: offline
suprsidr
Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
try using an absolute path to cpitemfile.inc in your cp config
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
5
5
Quote
Theophile
Anonymous
It is there, and it never gives an error on anything other than static pages. I can't think of any reason why the block displaying on a static page would cause the block code to look for cpitemfile.inc in a different location.
5
6
Quote
Theophile
Anonymous
Meh, thanks guys! Don't know why that post took so long to show up, but the absolute referencing was the trick! Thanks!
9
6
Quote
All times are EST. The time is now 05:19 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content