[PHP] fread and session vars
Hi all, I'm using the fread function to read one of my php scripts and then produce a static page, within this script I'm using session variables. If I browse to the script normally then all appears to work correctly, however when I use the fread function the session variables are not being translated. I've tried adding SID to the end of the URL but to no avail. Can anyone suggest a course of action. I'm reluctant to produce GET variables as there are many variables and this script will need to be used by multiple domains. Thanks, Zac
RE: [PHP] fread and session vars
Post some code. I don't understand completely what you're trying to do or how you're trying to do it. ---John Holmes... -Original Message- From: Zac Hillier [mailto:[EMAIL PROTECTED]] Sent: Monday, May 27, 2002 9:20 AM To: [EMAIL PROTECTED] Subject: [PHP] fread and session vars Hi all, I'm using the fread function to read one of my php scripts and then produce a static page, within this script I'm using session variables. If I browse to the script normally then all appears to work correctly, however when I use the fread function the session variables are not being translated. I've tried adding SID to the end of the URL but to no avail. Can anyone suggest a course of action. I'm reluctant to produce GET variables as there are many variables and this script will need to be used by multiple domains. Thanks, Zac -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fread and session vars
Code: generate page script: $pge = create-page.php $pd = $HTTP_GET_VARS['pd']; # Set the files $crtPge = /. $pge .?pd=. $pd; # the url of the dynamic page to write the output page $targetfilename = $SITE_ DOCUMENT_ROOT . $outPge; # the output page # delete previous version of temp file if it exists @unlink('temp.html'); # open the dynamic page into dynpage $dynpage = fopen($crtPge, 'r'); # Check for errors if (!$dynpage) { echo(pUnable to load . $crtPge . . Static page update aborted!/p); exit(); } # function read the data $htmldata = fread($dynpage, 1024*1024); # close the dynamic page fclose($dynpage); # connect to temp file ready to write $tempfile = fopen('temp.html', 'w'); # Check for errors if (!$tempfile) { echo(pUnable to open temporary file . ('temp.html') . for writing. Static page update aborted!/p); exit(); } #write to temp file fwrite($tempfile, $htmldata); # close the temp file fclose($tempfile); etc... === create-page.php: ? session_start(); $SITE_ DOCUMENT_ROOT = '/usr/local/htdocs/' . $HTTP_SESSION_VARS['site_Loc'] . '/'; The line above fails when being read by fread in the generate script code above, but works when I browse to it. Hope this makes more sense. Zac - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Zac Hillier' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, May 27, 2002 3:28 PM Subject: RE: [PHP] fread and session vars Post some code. I don't understand completely what you're trying to do or how you're trying to do it. ---John Holmes... -Original Message- From: Zac Hillier [mailto:[EMAIL PROTECTED]] Sent: Monday, May 27, 2002 9:20 AM To: [EMAIL PROTECTED] Subject: [PHP] fread and session vars Hi all, I'm using the fread function to read one of my php scripts and then produce a static page, within this script I'm using session variables. If I browse to the script normally then all appears to work correctly, however when I use the fread function the session variables are not being translated. I've tried adding SID to the end of the URL but to no avail. Can anyone suggest a course of action. I'm reluctant to produce GET variables as there are many variables and this script will need to be used by multiple domains. Thanks, Zac -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fread and session vars
Hi. Code: generate page script: $pge = create-page.php $pd = $HTTP_GET_VARS['pd']; # Set the files $crtPge = /. $pge .?pd=. $pd; # the url of the dynamic page to write the output page $targetfilename = $SITE_ DOCUMENT_ROOT . $outPge; # the output page # delete previous version of temp file if it exists unlink('temp.html'); # open the dynamic page into dynpage $dynpage = fopen($crtPge, 'r'); Here it looks like $crtPge is going to be equal to something like /create-page.php?pd=xx. If you want to open it via a URL, you need to add the HTTP:// and server name to it. $crtPge = http:// . $HTTP_SERVER_VARS['SERVER_NAME'] . / . $pge . ?pd= . $pd; Something like that...then fopen() will work. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fread and session vars
John, Thanks, the code does actually read this but I'm afraid I removed it so the servers ip is not exposed to the mail list. The script runs correctly and opens and creates the page, however it cannot find the include files I have in the page as the variable $SITE_DOCUMENT_ROOT requires a session variable. Zac - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Zac Hillier' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, May 27, 2002 7:12 PM Subject: RE: [PHP] fread and session vars Hi. Code: generate page script: $pge = create-page.php $pd = $HTTP_GET_VARS['pd']; # Set the files $crtPge = /. $pge .?pd=. $pd; # the url of the dynamic page to write the output page $targetfilename = $SITE_ DOCUMENT_ROOT . $outPge; # the output page # delete previous version of temp file if it exists @unlink('temp.html'); # open the dynamic page into dynpage $dynpage = fopen($crtPge, 'r'); Here it looks like $crtPge is going to be equal to something like /create-page.php?pd=xx. If you want to open it via a URL, you need to add the HTTP:// and server name to it. $crtPge = http:// . $HTTP_SERVER_VARS['SERVER_NAME'] . / . $pge . ?pd= . $pd; Something like that...then fopen() will work. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php