[PHP] I need a PHP alternative to Windows Scheduled Tasks

2003-07-23 Thread Phil Powell
I have concluded that Bill Gates is Satan!

Ok, I'm late, but... I have had 26 scheduled tasks that run every hour on the hour 
every day for eternity to go and run a series of Java files I wrote that connect 
remotely to a remote server to do remote cleanup of stray XML files, etc.; things I 
cannot do on the remote machine box itself because it's remote and I don't have 
permissions were I physically on the box anyway.

However, on 7/18 all 26 of my scheduled tasks stopped running; one of which 
continuously ran for 4 days straight w/o stopping (nor could I manually stop it).  I 
deleted the runaway process and recreated it; now not a single one of my 26 scheduled 
Win2000 tasks I created using MS-DOS AT commands work (which were working since 7/2).

I am now looking into programmatic alternatives.  I really could use some ideas that 
are practical given my situation.  I'm thinking PHP since I am very comfortable with 
it, were it possible within my bizarre Win2000 environment, but I need something that 
will clean those XML files remotely on a regular basis, it's important for website 
maintenance.  Any help appreciated.

Thanx
Phil


Re: [PHP] What did I do wrong to cause a parse error?

2003-07-11 Thread Phil Powell
Thanx I got it to work, however, I have no idea why it works now considering
I did nothing different:

$singleProfileHTML .= !--\n;
 foreach ($profileArray[$i][attributes] as $key = $val) {
  $singleProfileHTML .= strtolower($key) . '=' . str_replace(',
'#039;', str_replace('', 'quot;', stripslashes($val))) . \\n;
 }
 $singleProfileHTML .= --\n;

Beats the heck out of me!

Phil
- Original Message -
From: David Otton [EMAIL PROTECTED]
To: Phil Powell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, July 11, 2003 2:48 AM
Subject: Re: [PHP] What did I do wrong to cause a parse error?


 On Fri, 11 Jul 2003 00:53:32 -0400, you wrote:

 foreach ($profileArray[$i][attributes] as $key = $val) {
  $singleProfileHTML .= $key . =\ . str_replace(', '#039;',
str_replace('', 'quot;', $val)) . \\n;
 }
 
 The parsing error occurs in the $singleProfileHTML.. line.  I'm
completely don't get it; I see absolutely nothing wrong with this, what did
I miss?

 Line 1 - attributes should have a $ in front of it, or be a string
literal.

 BTW, that's a really nasty line. Maybe it would be easier to read as :

 foreach ($profileArray[$i][$attributes] as $key = $val) {
 $val = str_replace('', 'quot;', $val);
 $val = str_replace(', '#039;', $val);
 $singleProfileHTML .= $key=\$val\\n;
 }



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Mind exploded on this one!

2003-07-11 Thread Phil Powell
$booleanNonFormVars = array('hasSelectedLetter', 'hasEnteredProfile', 
'hasSelectedProfile',
 'hasEditedProfile', 'hasDeletedProfile', 
'willDeleteProfile',
 'willDeletePic');
 $booleanVars = array('profileID', 'showemail', 'showbirthday', 'season', 
'profilememberid');
 $profileVarArray = array('firstname', 'lastname', 'city', 'state', 'country', 
'favebands',
  'faveconcert', 'favescandinavia', 'faveviking', 'favemeat',
  'freetime', 'thingslove', 'thingshate', 'favebibleverse',
  'changeonething', 'maritalstatus', 'birthday', 'favemovie', 
  'faveplace', 'favetv', 'imgpath', 'imgext');
 $profileNonFormVarArray = array('profileName', 'letter', 'name');

 $arrayListArray = array('booleanNonFormVars', 'booleanVars', 'profileVarArray', 
'profileNonFormVarArray');

Bluntly put, I need to get: 
$hasSelectedLetter
$letter

Etc..

I have absolutely NO idea how to do this, help!

Phil


[PHP] What did I do wrong to cause a parse error?

2003-07-10 Thread Phil Powell
foreach ($profileArray[$i][attributes] as $key = $val) {
 $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 
'quot;', $val)) . \\n;
}

The parsing error occurs in the $singleProfileHTML.. line.  I'm completely don't get 
it; I see absolutely nothing wrong with this, what did I miss?

Phil


[PHP] Need an explanation as to what this line does...

2003-02-01 Thread Phil Powell
 $stuffArray[$i][value] = strtr($stuffArray[$i][value], 
array_flip(get_html_translation_table(HTML_ENTITIES)));

To be bluntly honest, I don't understand hardly any of it, and the PHP Manual isn't 
helping this time.. maybe I'm weekend-stupid or something.. *sigh*

Phil



[PHP] Problem with xml_parse_into_struct

2003-01-29 Thread Phil Powell
I have various XML files that might contain  tags inside the element body, for 
example:

news id=1 shortDescription=Stuff Happened TodayToday on b1/29/03/b, stuff 
happened/news

Because of this I can't use xml_parse_into_struct; when I do this happens:

array (
  ...
  [attributes] = array (
   [ID] = 1
   [SHORTDESCRIPTION] = Stuff Happened Today
   )
 [values]  = Today on
)

and it stops right there on the b tag.

What I need to do is this: Clean out ALL occurrences of tags that are NOT part of 
the original XML structure from the contents read from the XML file:

$fileID = fopen('/phil/xml/news.xml', 'r') or die('Could not open XML');
$stuff = fread($fileID, filesize('/phil/xml/news.xml'));
fclose($fileID);

$stuff contains the contents of news.xml, so I would have to do my cleanup in $stuff, 
BUT.. I can't use preg_replace for tags because then ALL of my tags would be altered 
and xml_parse_into_struct would fail altogether.

How then do I make sure to ONLY remove the trash tags from each XML row body and 
nowhere else???

Thanx
Phil



[PHP] Fw: I need my PHP script to call a TCL proc

2003-01-21 Thread Phil Powell

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 21, 2003 5:36 PM
Subject: I need my PHP script to call a TCL proc


 From: [EMAIL PROTECTED] (Phil Powell)
 Newsgroups: comp.lang.tcl,comp.lang.php
 Subject: I need my PHP script to call a TCL proc
 NNTP-Posting-Host: 65.201.150.91
 Message-ID: [EMAIL PROTECTED]

 It's either that my PHP script call a working TCL proc that converts
 all string text that looks like a URL (http://...;) into a hyperlink,
 or does someone have a PHP equivalent to do it?  My PHP function
 VALIDATE_URL fails to do any conversion in its regexp, however, the
 TCL proc works every time, and the matching pattern is nearly
 identical in both!

 TCL:

 proc VALIDATE_URL {contents} {
  regsub -all \\n $contents br contents
  regsub -all {\.{2,}} $contents {. .} contents
  regsub -all
{(http://([a-zA-Z0-9_\-]+\.)+(/[a-zA-Z0-9_\-\.\~\^,%\+]+)*[^\(\)
 ]+)} $contents a href=\\1 target=_newfont
 style='text-decoration:none'\\1/font/a contents
  regsub -all {\. \.} $contents {..} contents
  return $contents
 }

 PHP:

 function VALIDATE_URL($contents) {
$contents = preg_replace(/\\n/e, 'br', $contents);
$contents = preg_replace('/\.{2,}/e', '. .', $contents);
$contents =
preg_replace('/http[s]?:\/\/\([a-zA-Z0-9_\-]+\.\)+\(\/[a-zA-Z0-9_\-\.\~\^,%\
+]+\)*[^\\(\\)
 ]+\)/ei', a href=1 target=_new1/a, $contents);
return preg_replace('/\. \./e', '..', $contents);
   }

 So who wins, TCL or PHP?

 Thanx
 Phil


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How do I find email patterns in a query string in a text and urlescape them?

2003-01-21 Thread Phil Powell
If I have a text of string like this:

$stuff = Hi my name is Phil, my email is [EMAIL PROTECTED] and you can find me at 
http://www.xx.yy?[EMAIL PROTECTED];;

What I want to do is to validate all patterns resembling an email address EXCEPT 
those found within the query string of a URL.  I would want to to urlencode(\\1) 
somehow onto the email address pattern found within the query string of the URL to 
ensure that it is not validated like any other email address (validate means to 
convert [EMAIL PROTECTED] to a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/a).

Can anyone figure this out for me? I tried using pattern matching and eval() but the 
results were completely wrong:

function VALIDATE_URL($stuff) {
   $stuff = preg_replace('/[\n\r]/', 'br', $stuff);
   $stuff = preg_replace('/\.\./', ' . .', $stuff);
   // URL ESCAPE ALL EMAIL ADDRESSES FOUND WITHIN QUERY STRINGS TO ENSURE PROPER 
VALIDATION
   // IF USING VALIDATE_EMAIL
   $stuff = 
preg_replace('/([\?][a-zA-Z0-9]+=)([a-zA-Z0-9_\-\.]+@([a-zA-Z0-9_\-]+\.)+[a-zA-Z0-9_\-]+)/',
 '\\1' . '? $stuff = urlencode(\\2); echo $stuff; ?', $stuff);
   $stuff = eval('?' . $stuff);
   $stuff = 
preg_replace('/(http[s]?:\/\/([a-zA-Z0-9_\-]+\.)+(\/[a-zA-Z0-9_\-\.\~\^,%\+]+)*[^\(\)
 ]+)/', 'a href=\\1 target=_new\\1/a', $stuff);
   return preg_replace('/ \. \./', '..', $stuff);
  }

Thanx
Phil



[PHP] Cannot show reuploaded image file on page unless manual refresh

2003-01-20 Thread Phil Powell
I am using the following header() functions to force view.php to not cache:

header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);// Date in the past
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT); 
 // always modified
header(Cache-Control: no-store, no-cache, must-revalidate);  // HTTP/1.1
header(Cache-Control: post-check=0, pre-check=0, false);
header(Pragma: no-cache);  // HTTP/1.0


However, when a user reuploads a file in manage.php, it does a form post onto 
manage.php and reuploads the file (which I verified works).  However, when redirected 
via header() to view.php, they still see their OLD image file, NOT the new one!  
Unless I manually refresh the page, they never see it, until they manually refresh the 
page, then the new image file appears!  

I am handling file uploading this way:  If they select another file to upload, the old 
file is deleted and the new file uploaded.

Any suggestions?

Thanx
Phil



[PHP] files no longer upload!

2003-01-20 Thread Phil Powell
I'm having a day, gang!

I have done nothing to my code and now is_uploaded_file is constantly false, even when 
uploading a file every time.  I dunno what to do, would someone want to look at my 
code and tell me what I did wrong; I'm out of ideas.

Phil



Re: [PHP] Cannot show reuploaded image file on page unless manual refresh

2003-01-20 Thread Phil Powell
Dude, your solution failed! :(  The image STILL caches even though on the
server end it's deleted!! Even with a RANDOM string tacked on it STILL
caches!!!

Phil


[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  Aha! Something I can chime in on. I happened across the same scenario a
 few months back. The list helped me then so I'll give back.

  Call the image using a random identifier.

 $rand = rand(1000, );

 echo img src=http://someurl.com/image.jpg?$rand;;

 Since the browser will more than likely not have the image file identified
 by the random number it must request it again from the server. Works
 great where I need it!

 Ed

 On Mon, 20 Jan 2003, Chris Shiflett wrote:

  --- Phil Powell [EMAIL PROTECTED] wrote:
   I am using the following header() functions to force
   view.php to not cache:
  
   header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
   header(Last-Modified:  . gmdate(D, d M Y H:i:s) .
GMT);
   header(Cache-Control: no-store, no-cache,
   must-revalidate);
   header(Cache-Control: post-check=0, pre-check=0,
   false);
   header(Pragma: no-cache);
 
  :-)
 
  I think you killed it.
 
   However, when a user reuploads a file in manage.php, it
   does a form post onto manage.php and reuploads the file
   (which I verified works).  However, when redirected via
   header() to view.php, they still see their OLD image
   file, NOT the new one!  Unless I manually refresh the
   page, they never see it, until they manually refresh the
   page, then the new image file appears!
 
  Right.
 
  I think you are forgetting that the image is not really
  part of the PHP resource. Meaning, this is the series of
  events for a PHP script that refernces a single image
  called bar.jpg using the img tag:
 
  1. HTTP request sent for foo.php (Web client - Web server)
  2. HTTP response sent that includes the output of foo.php
 (Web server - Web client)
  3. Web client (browser) notices img tag referenced in
 the HTML.
  4. HTTP request sent for bar.jpg (Web client - Web server)
  5. HTTP response sent that includes bar.jpg
 
  So, the headers that you are setting only matter for the
  resource returned in step 2. Meaning, the HTML output of
  foo.php is not cached. The image, since it is returned by
  the Web server and not your PHP script, is cached.
 
  Chris
 
  --
  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




[PHP] Re: Cannot show reuploaded image file on page unless manual refresh

2003-01-20 Thread Phil Powell
Tried that too, dude.. now the files are replicating themselves in the
/profile/images folder!  I am supposed to delete the old file and replace it
with the new file, but instead I have old file  new file, and the
association between profile and image is incorrect.

Phil

Philip Hallstrom [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I wonder if appending time() would be better... granular to a second and
 you save the filesystem lookup effort??

 On Mon, 20 Jan 2003, Jim Lucas wrote:

  I would add the modification time of the file in question with
 
  filetime($filename);
 
  that way you will be sure to get a unique argurment.
 
  Jim
 
  - Original Message -
  From: [EMAIL PROTECTED]
  To: Chris Shiflett [EMAIL PROTECTED]
  Cc: Phil Powell [EMAIL PROTECTED]; [EMAIL PROTECTED];
  [EMAIL PROTECTED]
  Sent: Monday, January 20, 2003 10:48 AM
  Subject: Re:  Cannot show reuploaded image file on page unless manual
  refresh
 
 
  
Aha! Something I can chime in on. I happened across the same scenario
a
   few months back. The list helped me then so I'll give back.
  
Call the image using a random identifier.
  
   $rand = rand(1000, );
  
   echo img src=http://someurl.com/image.jpg?$rand;;
  
   Since the browser will more than likely not have the image file
identified
   by the random number it must request it again from the server. Works
   great where I need it!
  
   Ed
  
   On Mon, 20 Jan 2003, Chris Shiflett wrote:
  
--- Phil Powell [EMAIL PROTECTED] wrote:
 I am using the following header() functions to force
 view.php to not cache:

 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 header(Last-Modified:  . gmdate(D, d M Y H:i:s) .
  GMT);
 header(Cache-Control: no-store, no-cache,
 must-revalidate);
 header(Cache-Control: post-check=0, pre-check=0,
 false);
 header(Pragma: no-cache);
   
:-)
   
I think you killed it.
   
 However, when a user reuploads a file in manage.php, it
 does a form post onto manage.php and reuploads the file
 (which I verified works).  However, when redirected via
 header() to view.php, they still see their OLD image
 file, NOT the new one!  Unless I manually refresh the
 page, they never see it, until they manually refresh the
 page, then the new image file appears!
   
Right.
   
I think you are forgetting that the image is not really
part of the PHP resource. Meaning, this is the series of
events for a PHP script that refernces a single image
called bar.jpg using the img tag:
   
1. HTTP request sent for foo.php (Web client - Web server)
2. HTTP response sent that includes the output of foo.php
   (Web server - Web client)
3. Web client (browser) notices img tag referenced in
   the HTML.
4. HTTP request sent for bar.jpg (Web client - Web server)
5. HTTP response sent that includes bar.jpg
   
So, the headers that you are setting only matter for the
resource returned in step 2. Meaning, the HTML output of
foo.php is not cached. The image, since it is returned by
the Web server and not your PHP script, is cached.
   
Chris
   
--
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
  
  
 
 
 
  --
  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




[PHP] Can someone help me with this code please?

2003-01-15 Thread Phil Powell
Following is the code that will do a remote scrape of 
http://www3.brinkster.com/soa/val/profile/display.asp (which sometimes goes down), 
however, it should time out and produce an error after 5 seconds; instead, sometimes, 
the entire page (http://valsignalandet.com) which includes this script below, takes up 
to 90 seconds to load because of the ASP script locking, in spite of my safeguards.  
Can anyone please help; I'm out of ideas.

Thanx

Phil

?
  require_once('/users/ppowell/web/php_global_vars.php');

  // OPEN SOCKET CONNECTION TO BRINKSTER SET TO TIMEOUT IN 2 SECONDS
  $res = '';
  $fp = fsockopen('www3.brinkster.com', 80, $errno, $errstr, 2) or die('Oops');
  if (!$fp) {
   echo ${font}Cannot profiles at this time. a 
href=http://www3.brinkster.com/soa/val/profile/view.aspClick here/a or try again 
later/fontp;
  } else {
   $httpStr = POST /soa/val/profile/display.asp?showLeftNavBanner=1 
HTTP/1.0\r\nAccept: text/*\r\nUser-agent: NC_GET_URL\r\nHost: 
www3.brinkster.com:80\r\n\r\n;
   fputs($fp, $httpStr);
   $start = time();
   
   // DOUBLE TIME SETTING: SET FOR BOTH STREAM TIMEOUT AND FOR DATA LOOPING TIMEOUT TO 
   // ENSURE THAT THE WHOLE PROCESS IS 5 SECONDS OR IT QUITS
   
   // STREAM COMMANDS DON'T WORK ON VAL BECAUSE PHP VERSION IS TOO OLD - CRAP!
   list($phpVersion1, $phpVersion2, $phpVersion3) = explode('.', phpversion());
   if ($phpVersion1 =4  $phpVersion2 = 3) {
if (!stream_set_timeout($fp, 5)) echo 'Could not set stream timeoutp';
if (!stream_set_blocking($fp, 0)) echo 'Could not set stream blockingp';
   }

   $now = $start;
   while (!feof($fp)  $now  $start + 5) {
$res .= fgets($fp, 4096);
$now = time();
   }

   fclose($fp);
  }
  if (strlen($res)  0  $now  $start + 5) {
   echo trim(substr($res, strpos($res, ''), strlen(trim($res;
  } else {
   echo ${font}Could not display profiles at this time. a 
href=http://www3.brinkster.com/soa/val/profile/view.aspClick here/a or try again 
later/fontp;
  }
?
  



[PHP] Problems with require() and variables

2003-01-15 Thread Phil Powell
Consider this:

I have display.php, a script that will do XML parsing into an array and display its 
contents.

I have view.php, a script that will include display.php and have to manipulate the 
variables within display.php for itself.

So in view.php I have:

require('/.../.../display.php');

However, when display.php finishes being required, I lose all of my variables that I 
need for view.php.  How do I retain them?? How can I ensure that these variables in 
display.php will also exist in view.php?

Thanx
Phil



[PHP] fsockopen() to remote URL: what if remote URL times out?

2003-01-10 Thread Phil Powell
I have a question about the usage of fsockopen() to open and scrape the contents of 
a remote URL: if the contents take a very long time to load on the remote URL either 
due to server or coding issues, is there a way for the socket on the PHP end to time 
out, that is, quit trying to scrape contents from the remote site and post a default 
message instead?

Just wondering
Thanx
Phil



[PHP] mysql_num_rows() error

2003-01-09 Thread Phil Powell
 Anyone know why this is happening? I have mySQL on Win2000 Server with IIS
 and PHP:

 mysql_num_rows(): supplied argument is not a valid MySQL result resource

 Here is my code:

 ?
   $conn = mysql_connect('localhost', xxx, yyy) or die('Could not
connect
 to db');
   $result = mysql_query('select * from blah');
   echo Number of rows:  . mysql_num_rows($result);
   if (mysql_num_rows($result)  0) {
while ($row = mysql_fetch_row($result)) {
 for ($i = 0; $i  sizeOf($row); $i++) {
  echo $i:  . $row[$i] . BR;
 }
}
   }
 ?

 It couldn't get any simpler.  I just installed mySQL on my machine and am
 trying to see what I can do with it giving Win2K and IIS.

 AUGH! Thanx
 Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] XML File does not reflect changes upon reopen - HELP

2003-01-08 Thread Phil Powell
if ($isValid) {
$cgi = '/cgi-bin';
if (strpos($HTTP_HOST, 'dyndns') === false) $cgi .= '/cgiwrap/ppowell';
$fileID = 
fopen(http://$SERVER_NAME$cgi/pollinsert.cgi?pollID=$pollIDanswerID=$answerIDvalIdentifier=;
 . urlencode($valIdentifier) . lastPollResultsID= . 
($pollResultsArray[sizeOf($pollResultsArray) - 2][attributes][ID] + 1), 'r') 
 or die('Could not open CGI');
$result = fread($fileID, 10);
fclose($fileID);
if (trim(strtoupper($result)) != 'DONE') die (Problem with TCL CGI writing to 
file: $result);
// RE-PARSE XML CONTENTS SINCE ADDING NEW POLL ANSWER
unset($pollResultsArray); unset($pollResultsXMLStuff);
$fileID = fopen('/users/ppowell/web/xml/pollresults.xml', 'r') or die('Could not 
reopen file');
$pollResultsXMLStuff = fread($fileID, 
filesize('/users/ppowell/web/xml/pollresults.xml'));
fclose($fileID);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $pollResultsXMLStuff, $pollResultsArray, $tags);
xml_parser_free($parser);
   } else {
// REDIRECT BACK TO POLL IF
header(Location: http://$SERVER_NAME/poll/poll.php?pollID=$pollIDerrorMsg=; . 
urlencode($errorMsg));
   }
   // END OF FORM PLACEMENT

  }

I am making changes to an XML file (and the only way I can, unless anyone knows how in 
PHP I can write TO an XML file!!! is to use a TCL CGI script to write to the XML 
file), once changes have been made I need to reopen the file and read its contents, 
however, every time I do I am getting OLD file information and NOT my changes, every 
single time, unless I refresh my page... 

Does anyone know what I can do about this? I can't redirect them, that would be 
horribly inefficient.. what can I do?

Thanx
Phil



[PHP] I can't code today to save my life! :(

2003-01-04 Thread Phil Powell
I have $REQUEST_URI that will take two values:

/event/login.php

and

/event/register.php

What I need to do is so simple it's brainless!!! I need to look into $REQUEST_URI and 
find if it contains register.php.  I tried this and it completely failed, the 
results were wrong every time:

if (strpos($REQUEST_URI, register.php) !== 0) { // you're in login.php }

I don't know why I can't get this other than weekend stupidity, can someone help?

Thanx
Phil



[PHP] Second (Bizarre) Question regarding PHP and ASP

2003-01-04 Thread Phil Powell
I don't know how to post this one so I'm sorry for such bizarre cross-posting, but 
honestly I don't know where to go for help on this one!

I have process.php that has to call a remote file called process.asp on another site.

Site 1 has the cookie domain I want (that's where process.php is housed)
Site 2 has the database I need (because I can't obtain a database for Site 1 - Site 2 
is where process.asp is housed)

process.php has to do an fopen to process.asp to process username and password 
material.  process.asp needs security, obviously, to ensure that the user is coming 
from process.asp (but he's not because he's doing an fopen).

in other words, process.php opens up process.asp and returns the evaluation of 
process.asp onto process.php

I tried using REQUEST_URI but I didn't get the results I wanted.  How will process.asp 
know that process.php called it in order to do what it should do?

Thanx
Phil



[PHP] PHP and empty() if form value is 0

2003-01-04 Thread Phil Powell
foreach ($HTTP_GET_VARS as $key = $val) {
   if (!empty($HTTP_GET_VARS[$key])) ${$key} = $HTTP_GET_VARS[$key];
  }

  foreach ($HTTP_POST_VARS as $key = $val) {
   if (!empty($HTTP_POST_VARS[$key])) ${$key} = $HTTP_POST_VARS[$key];
  }

Whenever the form variable is equal to 0, the value is not passed into the 
corresponding variable.

For example, if isLogin = 1, then $isLogin = 1
But if isRegistered = 0 then $isRegistered = {null}

I do not understand why this happens, someone enlighten me!

Phil



Re: [PHP] PHP and empty() if form value is 0

2003-01-04 Thread Phil Powell
I couldn't think of isset, so I winged it:

if (strlen($var)  0) {...}

Phil

Michael Sims [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
On Sat, 4 Jan 2003 19:26:02 -0500, you wrote:

Whenever the form variable is equal to 0, the value is not passed into the
corresponding variable.

For example, if isLogin = 1, then $isLogin = 1
But if isRegistered = 0 then $isRegistered = {null}

I do not understand why this happens, someone enlighten me!

That's just the way empty() works.  Strings which evaluate to false
(either an empty string or the string '0') will cause empty() to
return true.  Therefore if you have a form where '0' is a valid value,
empty() is not appropriate.

Instead of:

if (!empty($var)) { ... }

use:

if (isset($var)  $var != '') { ... }



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Second (Bizarre) Question regarding PHP and ASP

2003-01-04 Thread Phil Powell
CURL? I only understand CURL as a Vignette command, sorry, you lost me.

Phil

Michael J. Pawlowsky [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 I'm not sure I totally understand...   But why not just call it like a web
page using curl?




 *** REPLY SEPARATOR  ***

 On 04/01/2003 at 6:43 PM Phil Powell wrote:

 I don't know how to post this one so I'm sorry for such bizarre
 cross-posting, but honestly I don't know where to go for help on this
one!
 
 I have process.php that has to call a remote file called process.asp on
 another site.
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Warning: 1 is not a valid File-Handle resource - HELP!

2002-12-29 Thread Phil Powell
Ok, I am a bad coder. :(  I can't figure this out at all:

   $fileID = fopen(nicknames.txt, 'r');
$stuff = fread($fileID, filesize(nicknames.txt)); fclose($fileID);
if (strlen($stuff)  0) $priorNickNewLine = \n; 
$nicks = explode(\n, $stuff);

The last line produces the Warning.. why?  I am trying to read contents from 
nicknames.txt and split according to the newline character so that each nickname is an 
array element.

What did I do wrong? :(

Phil



[PHP] Sorry, really stupid question...

2002-12-28 Thread Phil Powell
Honestly, what does this do:

$fileID = fopen(nicknames.txt, a) or die(Could not open  . $path . 
/nicknames.txt);
   chmod(nicknames.txt, 0755);
   fputs($fileID, $nickname . \n); fflush($fileID); fclose($fileID);

What does it EXACTLY do?  What I'm trying to do is very very simple:  I have the 
nickname of phil and I add it to nicknames.txt as phil + \n.  The next person 
adds his name as bob + \n.  However, this happens:

phil
philbob

Is it due to the way I'm adding to the file?  Can someone show me how to append to a 
file properly without carrying over persistent existing data like what you see above, 
instead having it like this:

phil
bob

Thanx, I'm lost here.

Phil



Re: [PHP] Sorry, really stupid question...

2002-12-28 Thread Phil Powell
I checked, and I am adding just bob.  Turns out to be a wacky logic
problem.

nicknames.txt contains this:

phil\n
bob\n

When bob leaves the chatroom nicknames.txt becomes:

phil\n

BUT.. apparently that's not it either; the carriage return is also somehow
stripped out.  So instead it's this:

phil

so when joe comes on board instead of

phil\n
joe\n

I get

philjoe\n

Understand?  This is a complicated logic problem I can't figure out other
than doing this:

$stuff = fread($fileID, filesize(nicknames.txt, 10));
if (strlen($stuff)  0) $priorNickNewLine = \n;
...
fputs($fileID, $priorNickNewLine . $nickname . \n);

Phil
David Rice [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi Phil:
 It probably does what you are asking it to do. Have you checked the
 value of $nickname to see if you are setting it to bob or appending
 bob to it?
 i.e first time $nickname = phil
 second time $nickname = philbob

 HTH

 David
 On Saturday, December 28, 2002, at 02:24 PM, Phil Powell wrote:

  Honestly, what does this do:
 
  $fileID = fopen(nicknames.txt, a) or die(Could not open  . $path
  . /nicknames.txt);
 chmod(nicknames.txt, 0755);
 fputs($fileID, $nickname . \n); fflush($fileID); fclose($fileID);
 
  What does it EXACTLY do?  What I'm trying to do is very very simple:
  I have the nickname of phil and I add it to nicknames.txt as phil
  + \n.  The next person adds his name as bob + \n.  However, this
  happens:
 
  phil
  philbob
 
  Is it due to the way I'm adding to the file?  Can someone show me how
  to append to a file properly without carrying over persistent existing
  data like what you see above, instead having it like this:
 
  phil
  bob
 
  Thanx, I'm lost here.
 
  Phil




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Fw: PHP script needs to timeout upon FOPEN to URL

2002-12-13 Thread Phil Powell

- Original Message - 
From: [EMAIL PROTECTED] [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 13, 2002 5:13 PM
Subject: PHP script needs to timeout upon FOPEN to URL


I have the following line:

while (!($file = @fopen(http://www.myurl.com;, r))  time() 
$startTime + $time);
if (!$file){
 echo Timed out, try again later;
} else {
 // do stuff
}

Problem is, when it attempts to connect to the remote server, it's supposed
to time out after 2-5 seconds, but it doesn't, it just locks up :(  Any
suggestions?

Phil


mail2web - Check your email from the web at
http://mail2web.com/ .




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] fopen have a setTimeout feature?

2002-12-08 Thread Phil Powell
Can you set something like a setTimeout feature in fopen? That is, if you use fopen 
to open a URL for scraping, if that URL's server is down or doesn't respond in x 
seconds, can you set a feature to show an error message or a friendly error message 
indicating such?

Thanx
Phil



Re: [PHP] fopen have a setTimeout feature?

2002-12-08 Thread Phil Powell
Sorry, your code produced this error and I can't figure out how to debug it
:(

Warning:
fopen(http://www3.brinkster.com/soa/val/profile/display.asp?showLeftNavBann
er=1,r) - Error 0 in /users/ppowell/web/profiledisplay.php on line 4


Phil
- Original Message -
From: Tim Ward [EMAIL PROTECTED]
To: Phil Powell [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Sunday, December 08, 2002 3:10 PM
Subject: Re: [PHP] fopen have a setTimeout feature?


 how about something like...

 $start = time();
 $timeout = 60; // number of seconds to try
 while (!$file = fopen(...)  time()  $start + $timeout);
 if ($file)
 {   // do stuff with file
 }

 Tim Ward
 http://www.chessish.com
 mailto:[EMAIL PROTECTED]
 - Original Message -
 From: Phil Powell [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Sunday, December 08, 2002 7:32 PM
 Subject: [PHP] fopen have a setTimeout feature?


 Can you set something like a setTimeout feature in fopen? That is, if
you
 use fopen to open a URL for scraping, if that URL's server is down or
 doesn't respond in x seconds, can you set a feature to show an error
message
 or a friendly error message indicating such?

 Thanx
 Phil




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to override header info in mail()

2002-11-30 Thread Phil Powell
I am using this line:

if (!mail($to, $subject, $body, From:  . $from . ; . header(Content-type  . 
$contentType))) {..}

to use the mail() function in PHP to send simple text/plain or text/html email.  
However, upon attempting to send I get a warning message indicating that header 
information has already been set prior to emailing.  

Is there a way to overwrite only certain header information prior to emailing to 
ensure the content-type of the email being either text/plain or text/html?

Just wondering
Thanx
Phil



[PHP] File Write Permission Errors - HELP! URGENT!!!

2002-11-25 Thread Phil Powell
Hi I have the following code that breaks:

// PLACE NICK INTO NICKNAMES.TXT AND START OFF MESSAGES.TXT
   $fileID = fopen($path . /nicknames.txt, a) or die(Could not open  . $path . 
/nicknames.txt);
   chmod($path . /nicknames.txt, 0755);
   fputs($fileID, $nickname . \n); fflush($fileID); fclose($fileID);
   $fileID = fopen($path . /messages.txt, a) or die(Could not open  . $path . 
/messages.txt);
   fputs($fileID, *** WELCOME \ . $nickname . \ TO THE ROOM ***); 
fflush($fileID); fclose($fileID);
   

I am getting the following error:
Warning: fopen(/users/ppowell/web/chat/nicknames.txt, a) - Permission denied in 
/users/ppowell/web/chat/chat.php on line 163

I am attempting to write onto the files if they exist, if not, create them on the fly. 
 I need the solution in the next 5 minutes - sorry, kind of an emergency! 

If anyone can help, please tell me what to do, the PHP manuals are not giving me a 
clear solution as to how to write to a file that does not yet exist that has to have 
the permissions of 0755 for both files.

Thanx
Phil



[PHP] Re: File Write Permission Errors - HELP! URGENT!!!

2002-11-25 Thread Phil Powell
I did just that.  Permissions are set the /chat folder as it is in all other
folders.  This is the first time I've ever done fopen with w and I can't
get it to write, always getting unable to access errors. I want to be able
to create the file if it does not exist.  It works for me to do r in all
other folders with the same permissions as /chat.

Phil

Craig [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 you must give the same permissions to the folder also.


 Phil Powell [EMAIL PROTECTED] wrote in message
 0ca201c2947e$44690a80$dcbe6444@scandinawa1bo6">news:0ca201c2947e$44690a80$dcbe6444@scandinawa1bo6...
 Hi I have the following code that breaks:

 // PLACE NICK INTO NICKNAMES.TXT AND START OFF MESSAGES.TXT
$fileID = fopen($path . /nicknames.txt, a) or die(Could not open 
.
 $path . /nicknames.txt);
chmod($path . /nicknames.txt, 0755);
fputs($fileID, $nickname . \n); fflush($fileID); fclose($fileID);
$fileID = fopen($path . /messages.txt, a) or die(Could not open 
.
 $path . /messages.txt);
fputs($fileID, *** WELCOME \ . $nickname . \ TO THE ROOM ***);
 fflush($fileID); fclose($fileID);


 I am getting the following error:
 Warning: fopen(/users/ppowell/web/chat/nicknames.txt, a) - Permission
 denied in /users/ppowell/web/chat/chat.php on line 163

 I am attempting to write onto the files if they exist, if not, create them
 on the fly.  I need the solution in the next 5 minutes - sorry, kind of an
 emergency!

 If anyone can help, please tell me what to do, the PHP manuals are not
 giving me a clear solution as to how to write to a file that does not yet
 exist that has to have the permissions of 0755 for both files.

 Thanx
 Phil






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] chmod - some files can be viewed, others cannot

2002-10-14 Thread Phil Powell

I have a directory $DOCUMENT_ROOT/my/images, permission 0755

I have three images in my folder with the exact same permissions: 0755; same 
ownership, same everything.

The files, viewed on my machine, are fine too.

However, two cannot be seen due to permissions errors; one can be seen.  All three 
were uploaded the exact same way too.

Anyone want to solve this riddle?  I am stumped as usual.

Thanx
Phil



[PHP] How to setcookie with two domains

2002-10-14 Thread Phil Powell

Is it possible, w/o using sessionid session variables, to use setcookie to set a 
cookie that will have two domains or more?

Just curious.  I am having to set a cookie that will go to one domain and then to 
another domain.  Not sure if I can do multiple setcookie commands and be able to 
produce the desired results.

Thanx
Phil



[PHP] How do you strip Header Info from displaying on your browser?

2002-10-02 Thread Phil Powell

If you go to http://valsignalandet.com/feedback.php you can get a clearer indication 
of what I am trying to get rid of.  Following is my function using to produce the 
stuff up there, which I don't want, instead, I either want cookie-driven information 
or nothing (if no cookie is set):

function WebGet($address, $port = 80, $url = '/', $post = false, $cookie = false) {
   // Use fsockopen to catch the URL 
   $fp = fsockopen ( $address, $port);

   // Zero Fill 
   $ret = '';

   if ($fp) {
  // Success.  Now check to see the type of request 
  if ($post) {
 $request = POST $url HTTP/1.1\n;
 $request .= Host: $address\n;
 $request .= Content-Length:  . strlen( $post ). \n;
 $request .= Content-Type: application/x-www-form-urlencoded\n;

 if ($cookie) $request .= Cookie: $cookie\n;

 $request .= Connection: Close\n\n;
 $request .= $post;
  } else {
 $request = GET $url HTTP/1.1\n;
 $request .= Host: $address\n;
 $request .= Content-Type: text/html\n;

 if ($cookie) $request .= Cookie: $cookie\n;

 $request .= Connection: Close\n\n;
  }

  $ret = '';

  // Write the Request 
  fputs ($fp, $request);

  // Get the response 
  while (!feof($fp)) $ret .= fgets ( $fp, 128 );

  // close the connection 
  fclose ($fp);
   }

   return $ret;

 }

I do not want to change WebGet as I wish to keep it a universal function that can be 
used for cookies or not.

So, how can I get rid of the trash on my page?

Thanx
Phil



[PHP] Reading a PHP-as-CGI script into another PHP script

2002-09-30 Thread Phil Powell

I have the following URL:

http://valsignalandet.com/cgi-bin/cgiwrap/ppowell/php4.cgi/~ppowell/my/style.php

This is a PHP script that is evaluated and compiled by a CGI script, php4.cgi, to 
allow for file and directory manipulation w/o having to change file and directory 
permissions to world-write.

This URL works just fine as follows:

!--#INCLUDE 
VIRTUAL=http://valsignalandet.com/cgi-bin/cgiwrap/ppowell/php4.cgi/~ppowell/my/style.php
 -- 

If I place this tag inside .shtml files, the results are exactly what I want.. 
however, I am now required to get the contents of 
http://valsignalandet.com/cgi-bin/cgiwrap/ppowell/php4.cgi/~ppowell/my/style.php and 
place inside another PHP script; to date, nothing occurs.

I am able to read other CGI script inside via fopen(../mycgi.cgi, r); and able to 
read PHP via fopen(../myphp.php, r); with no problem.

Does anyone know of a way then that I might be able to produce the contents of a 
uniquely-formed URL such as 
http://valsignalandet.com/cgi-bin/cgiwrap/ppowell/php4.cgi/~ppowell/my/style.php into 
another PHP script since fopen and require() both do not seem to work in this case?

Thanks
Phil



[PHP] mkdir() failed: Permission denied

2002-09-28 Thread Phil Powell

Ok, I am stuck.  I am trying to create a folder in the same directory as
process.php and then use move_uploaded_file($FILES['myImage]['tmp_name'])
and it constantly fails:

mkdir() failed (Permission denied)

Here is my code:

?
  $willChangeLayout = 1; $isEmptyLayoutValues = 1;

  foreach ($_POST as $key = $val) {
   if (strcmp($key, isDefaultLayout) == 0) $willChangeLayout = 0;
   if (!empty($_POST[$key])) $isEmptyLayoutValues = 0;
   ${$key} = $val;
  }

  // SERVER-SIDE VALIDATION
  if ($willChangeLayout  $isEmptyLayoutValues)
   header(Location:  . $refURL . ?errorMsg= . urlencode(Please fill out
all required fields));

  // FILE UPLOAD HANDLING

  $attempt = mkdir(/users/ppowell/web/my/images, 0655);

  if (is_uploaded_file($_FILES['myImage']['tmp_name']))
   move_uploaded_file($_FILES['myImage']['tmp_name'],
/users/ppowell/web/my/images/ . $_FILES['myImage']['name']);


?

Please someone tell me what I'm doing wrong :(

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mkdir() failed: Permission denied

2002-09-28 Thread Phil Powell

Ok I did just that.. Permission is set for /users/ppowell/web/my at 0755
giving me full write permissions onto that directory, I would think, to
create subdirectory /images.

However, I can't do that because I get the following error:

on line 27:
if (!is_dir($path)) mkdir($path, 01755);

// $path = /users/ppowell/web/my/images/;

Warning: Unable to access /users/ppowell/web/my/images/ in
/users/ppowell/web/my/process.php on line 27




Phil
- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: 'Phil Powell' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Saturday, September 28, 2002 4:22 PM
Subject: RE: [PHP] mkdir() failed: Permission denied


 Whatever user your web server is running as needs to have permission to
 write to that directory that you are trying to make the new one in.

 ---John Holmes...

  -Original Message-
  From: Phil Powell [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, September 28, 2002 3:38 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] mkdir() failed: Permission denied
 
  Ok, I am stuck.  I am trying to create a folder in the same directory
 as
  process.php and then use
 move_uploaded_file($FILES['myImage]['tmp_name'])
  and it constantly fails:
 
  mkdir() failed (Permission denied)
 
  Here is my code:
 
  ?
$willChangeLayout = 1; $isEmptyLayoutValues = 1;
 
foreach ($_POST as $key = $val) {
 if (strcmp($key, isDefaultLayout) == 0) $willChangeLayout = 0;
 if (!empty($_POST[$key])) $isEmptyLayoutValues = 0;
 ${$key} = $val;
}
 
// SERVER-SIDE VALIDATION
if ($willChangeLayout  $isEmptyLayoutValues)
 header(Location:  . $refURL . ?errorMsg= . urlencode(Please
 fill
  out
  all required fields));
 
// FILE UPLOAD HANDLING
 
$attempt = mkdir(/users/ppowell/web/my/images, 0655);
 
if (is_uploaded_file($_FILES['myImage']['tmp_name']))
 move_uploaded_file($_FILES['myImage']['tmp_name'],
  /users/ppowell/web/my/images/ . $_FILES['myImage']['name']);
 
 
  ?
 
  Please someone tell me what I'm doing wrong :(
 
  Thanx
  Phil
 
 
 
  --
  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] mkdir() failed: Permission denied

2002-09-28 Thread Phil Powell

Got it but the solution is derned freaky... talking to the webserver admin I
come to find out that I have to write a stub executable to php4.cgi which
will interpret the PHP script bypassing the Apache mods.. that way I can
keep the directories at the default 0755 and STILL be able to do file mkdir
and uploading!!

Phil

- Original Message - 
From: John W. Holmes [EMAIL PROTECTED]
To: 'Phil Powell' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Saturday, September 28, 2002 7:04 PM
Subject: RE: [PHP] mkdir() failed: Permission denied


 _YOU_ don't need write permissions, the web server does
 
 ---John Holmes...
 
  -Original Message-
  From: Phil Powell [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, September 28, 2002 4:24 PM
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: Re: [PHP] mkdir() failed: Permission denied
  
  Ok I did just that.. Permission is set for /users/ppowell/web/my at
 0755
  giving me full write permissions onto that directory, I would think,
 to
  create subdirectory /images.
  
  However, I can't do that because I get the following error:
  
  on line 27:
  if (!is_dir($path)) mkdir($path, 01755);
  
  // $path = /users/ppowell/web/my/images/;
  
  Warning: Unable to access /users/ppowell/web/my/images/ in
  /users/ppowell/web/my/process.php on line 27
  
  
  
  
  Phil
  - Original Message -
  From: John W. Holmes [EMAIL PROTECTED]
  To: 'Phil Powell' [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Sent: Saturday, September 28, 2002 4:22 PM
  Subject: RE: [PHP] mkdir() failed: Permission denied
  
  
   Whatever user your web server is running as needs to have permission
 to
   write to that directory that you are trying to make the new one in.
  
   ---John Holmes...
  
-Original Message-
From: Phil Powell [mailto:[EMAIL PROTECTED]]
Sent: Saturday, September 28, 2002 3:38 PM
To: [EMAIL PROTECTED]
Subject: [PHP] mkdir() failed: Permission denied
   
Ok, I am stuck.  I am trying to create a folder in the same
 directory
   as
process.php and then use
   move_uploaded_file($FILES['myImage]['tmp_name'])
and it constantly fails:
   
mkdir() failed (Permission denied)
   
Here is my code:
   
?
  $willChangeLayout = 1; $isEmptyLayoutValues = 1;
   
  foreach ($_POST as $key = $val) {
   if (strcmp($key, isDefaultLayout) == 0) $willChangeLayout =
 0;
   if (!empty($_POST[$key])) $isEmptyLayoutValues = 0;
   ${$key} = $val;
  }
   
  // SERVER-SIDE VALIDATION
  if ($willChangeLayout  $isEmptyLayoutValues)
   header(Location:  . $refURL . ?errorMsg= .
 urlencode(Please
   fill
out
all required fields));
   
  // FILE UPLOAD HANDLING
   
  $attempt = mkdir(/users/ppowell/web/my/images, 0655);
   
  if (is_uploaded_file($_FILES['myImage']['tmp_name']))
   move_uploaded_file($_FILES['myImage']['tmp_name'],
/users/ppowell/web/my/images/ . $_FILES['myImage']['name']);
   
   
?
   
Please someone tell me what I'm doing wrong :(
   
Thanx
Phil
   
   
   
--
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




[PHP] Need to get last element of 2-dimensional array

2002-09-28 Thread Phil Powell

The following produced a rather nasty parse error:

echo ($idArray[0][sizeof($idArray[0])]));

I have a 2-dimensional array $idArray that I must obtain the LAST element of that 
2-dimensional array.. how do I do it?

Thanx
Phil



[PHP] Help! Can't set cookie or redirect!!!

2002-09-28 Thread Phil Powell

I am getting the following errors attempting to set a cookie and redirect:

Warning: Cannot add header information - headers already sent by (output started at 
/users/ppowell/web/my/process.php:5) in /users/ppowell/web/my/process.php on line 76

Warning: Cannot add header information - headers already sent by (output started at 
/users/ppowell/web/my/process.php:5) in /users/ppowell/web/my/process.php on line 77


Lines:

   setcookie(valLayout, $id, time()+3600*24*30*12*100, $SERVER_NAME); // WILL EXPIRE 
IN 100 YEARS.. UM YEAH
header(Location:  . $HTTP_POST_VARS[refURL]);

The first time I ran this script it set the cookie just fine; subsequent runnings of 
this script produce this error.  What am I doing wrong, anyone?

Thanx
Phil



Re: [PHP] Help! Can't set cookie or redirect!!!

2002-09-28 Thread Phil Powell

Ok thanx.. yeah I knew that you can set a cookie before anything is set to
the browser, however, if you view my code, nothing is sent as output before
the cookie is set.

?
  // Don't forget you have to use php4.cgi to call this script and this
script's URL will be:
  // /cgi-bin/cgiwrap/ppowell/php4.cgi/~ppowell/my/process.php

  phpinfo();
  $willChangeLayout = 1; $isEmptyLayoutValues = 1;

  $path = $DOCUMENT_ROOT . /my/;

  // SERVER-SIDE VALIDATION
  foreach ($HTTP_POST_VARS as $key = $val) {
   if (strcmp($key, isDefaultLayout) == 0) $willChangeLayout = 0;
   if (!empty($HTTP_POST_VARS[$key])) $isEmptyLayoutValues = 0;
   if (!empty($HTTP_POST_FILES['myImage']['name'])) $isEmptyLayoutValues =
0;
  }

  if ($willChangeLayout  $isEmptyLayoutValues) {
   header(Location:  . $refURL . ?errorMsg= . urlencode(Please fill out
all required fields));
   //--END OF SERVER-SIDE VALIDTION
  } else {

  // FILE UPLOAD HANDLING

   if (!is_dir($path/images/)) mkdir($path/images/, 0755);

   if (is_uploaded_file($HTTP_POST_FILES['myImage']['tmp_name']) 
   !file_exists($DOCUMENT_ROOT/my/images/ .
$HTTP_POST_FILES['myImage']['name']) 
   $willChangeLayout)
move_uploaded_file($HTTP_POST_FILES['myImage']['tmp_name'], $path.
/images/ . urlencode($HTTP_POST_FILES['myImage']['name']));
   //--END OF FILE UPLOAD HANDLING


   // IF LAYOUT COLORS HAVE BEEN SUBMITTED COMBINE THEM INTO WORKABLE STRING
TO PLACE INTO FILE
   if ($willChangeLayout) {

$stuff = ;

// OPEN UP FILE layout.txt TO GET MOST CURRENT ID, ELSE DEFAULT TO 1
if (file_exists($path/layout.txt)) {
 $layoutID = fopen($path/layout.txt, r) or die(Could not open file:
$path/layout.txt);
 $stuff .= fread($layoutID, filesize($path/layout.txt));
 fclose($layoutID) or die(Could not close file: $path/layout.txt);
 // OBTAIN MAX ID BY DOING PREG_MATCH_ALL TO GET ALL PATTERNS OF
id=number
 preg_match_all(/id=[0-9]+/, $stuff, $idArray, PREG_PATTERN_ORDER);
 list($key, $id) = split(=, end($idArray[0]));
 $id++;
} else {
 $id = 1;
}

$layoutString = id= . $id . ;

$varExceptionArray = array(isDefaultLayout, submit, refURL,
previewButton, cancel,
  MAX_FILE_SIZE);
foreach ($HTTP_POST_VARS as $key = $val) {
 if (!in_array($key, $varExceptionArray)) {
  $val = preg_replace(//, #, $val); // IN THEORY YOUR EXTERNAL
IMAGE HAS NO 
  $val = preg_replace(/=/, #, $val); // IN THEORY YOUR EXTERNAL
IMAGE HAS NO =
  if (strcmp($key, myExternalImage) == 0) {
   $layoutString .= background= . urlencode($val) . ;
  } else {
   $layoutString .= $key . = . urlencode($val) . ;
  }
 }
}

if (!empty($HTTP_POST_FILES['myImage']['name'])) {
 $layoutString .= background= .
urlencode($HTTP_POST_FILES['myImage']['name']);
} else {
 $layoutString = substr($layoutString, 0, -1);
}
$layoutID = fopen($path/layout.txt, w) or die(Could not write to
file: $path/layout.txt);
fwrite($layoutID, $stuff . $layoutString . \n);
fflush($layoutID); fclose($layoutID);
// SET THE COOKIE FOR LAYOUT
setcookie(valLayout, $id, time()+3600*24*30*12*100, $SERVER_NAME); //
WILL EXPIRE IN 100 YEARS.. UM YEAH
   } else {  // $willChangeLayout IS FALSE YOU ARE USING isDefaultLayout -
DESTROY COOKIE
$id = $HTTP_COOKIE_VARS[valLayout];
if (empty($id)) $id = 0;
// DELETE ENTRY FROM layout.txt
$layoutID = fopen($path/layout.txt, r) or die(Could not open file:
$path/layout.txt);
$stuff = fread($layoutID, filesize($path/layout.txt));
fclose($layoutID) or die(Could not close file: $path/layout.txt);
preg_match_all(/id=[\n]+\n/, $stuff, $idArray, PREG_PATTERN_ORDER);
preg_replace(end($idArray[0]), , $stuff);
$layoutID = fopen($path/layout.txt, w) or die(Could not open file:
$path/layout.txt);
fwrite($layoutID, $stuff); fflush($layoutID); fclose($layoutID);
// DELETE COOKIE
setcookie(valLayout, , time()-3600, $SERVER_NAME);
   }
   //--END OF LAYOUT COLOR TO WORKABLE STRING HANDLING

   // REDIRECT
   header(Location:  . $HTTP_POST_VARS[refURL]);

  } //--END OF LAYOUT CHANGING
?

Perhaps I'm just not finding it. :(

Phil
John W. Holmes [EMAIL PROTECTED] wrote in message
000e01c26754$cf27c8c0$7c02a8c0@coconut">news:000e01c26754$cf27c8c0$7c02a8c0@coconut...
 You can only set a cookie before any output is send to the browser. A
 newline, space, or html, etc, is output to the browser. Redesign your
 code so the cookie is set before any output or use output buffering.

 ---John Holmes...

  -Original Message-
  From: Phil Powell [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, September 28, 2002 9:03 PM
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: [PHP] Help! Can't set cookie or redirect!!!
 
  I am getting the following errors attempting to set a cookie and
 redirect:
 
  Warning: Cannot add header information - headers already sent by
 (output
  started at /users/ppowell/web/my/proce

Re: [PHP] Help! Can't set cookie or redirect!!!

2002-09-28 Thread Phil Powell

Never mind, I found it.. *sigh* I forgot about phpinfo()..

Everything works now, cookies, redirection, everything.. thanx!

Phil
- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: 'Phil Powell' [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Saturday, September 28, 2002 9:09 PM
Subject: RE: [PHP] Help! Can't set cookie or redirect!!!


 You can only set a cookie before any output is send to the browser. A
 newline, space, or html, etc, is output to the browser. Redesign your
 code so the cookie is set before any output or use output buffering.

 ---John Holmes...

  -Original Message-
  From: Phil Powell [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, September 28, 2002 9:03 PM
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: [PHP] Help! Can't set cookie or redirect!!!
 
  I am getting the following errors attempting to set a cookie and
 redirect:
 
  Warning: Cannot add header information - headers already sent by
 (output
  started at /users/ppowell/web/my/process.php:5) in
  /users/ppowell/web/my/process.php on line 76
 
  Warning: Cannot add header information - headers already sent by
 (output
  started at /users/ppowell/web/my/process.php:5) in
  /users/ppowell/web/my/process.php on line 77
 
 
  Lines:
 
 setcookie(valLayout, $id, time()+3600*24*30*12*100,
 $SERVER_NAME); //
  WILL EXPIRE IN 100 YEARS.. UM YEAH
  header(Location:  . $HTTP_POST_VARS[refURL]);
 
  The first time I ran this script it set the cookie just fine;
 subsequent
  runnings of this script produce this error.  What am I doing wrong,
  anyone?
 
  Thanx
  Phil




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Creatng a PHP chatroom

2002-06-12 Thread Phil Powell

I am intrested in creating a chatroom entirely in PHP involving streaming text.  Where 
can someone help me to find such a means of doing so?

Thanx
Phil
http://valsignalandet.com




Re: [PHP] Using function in PHP script n DOCROOT in PHP script in subfolder

2002-05-11 Thread Phil Powell

Found a MUCH MUCH simpler solution that works across the board.. change
$HTTP_HOST to $DOCUMENT_ROOT and it works!

Phil

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Phil:

 On Fri, May 10, 2002 at 08:01:46PM -0400, Phil Powell wrote:
 
  How do I fix this problem? I do not want to duplicate the PHP script per
  folder as there will be an enormous amount of dynamically-created
subfolders
  and I will have to copy a version per folder.  I want to be able to use
the
  one PHP script in the DOCROOT for every PHP script in every subfolder,
how
  is this done?

 Have a file in each directory called, for the sake of example,
 directory.inc  In that file, set a variable called, $root  The
 value of it should be the relative path used to find the root
 directory, eg ../../.  This will vary depending on the directory
 depth.  Each script on your site then should have
 require('./directory.inc'); at the top.  Now, you'll always know
 where to find the root.  This also makes things easy to move from one
 server to another in the future.

 Another way to do this is to use the auto_prepend_file setting to
 include your file that has the function in it.
 http://www.php.net/manual/en/configuration.php#ini.auto-prepend-file

 Enjoy,

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHP can't access txt files (but TCL can..??)

2002-05-11 Thread Phil Powell

TCL 1, PHP 0

Ok, I am frustrated.. here is my code and this portion has to be done in
PHP.  I have a frame that can only be accessed if 1 of 2 things occur:

1) if $HTTP_REFERER has a specific value
2) if your nickname passed in the query string is found in the existing
nicknames.txt file found in /chat/nicknames.txt

Here is the code:

?
 // Security measure to prevent bookmarking of page unless nickname exists
in nicknames.txt
 $contents = ;
 if (!preg_match(/\bchat_process_nickname\b/i, $HTTP_REFERER)) {
  $canAccessChatroom = 1;
  if (strlen($nickname)  2) $canAccessChatroom = 0;
  if (!file_exists($DOCUMENT_ROOT . /chat/nicknames.txt))
$canAccessChatroom = 0;
  if ($canAccessChatroom == 1) {
   $fileID = fopen($DOCUMENT_ROOT. /chat/nicknames.txt, r) or die (could
not open file);
   if (!$fileID) {
$canAccessChatroom = 0;
   } else {
$contents = fread($fileID);
fclose($fileID);
   }
  }
  if ($canAccessChatroom == 1  strlen($contents) == 0) $canAccessChatroom
= 0;
  if ($canAccessChatroom == 1  !preg_match(/[a-zA-Z0-9_\-]+/,
$contents)) $canAccessChatroom == 0;
  if ($canAccessChatroom == 1) {
   if (!preg_match(/\b$nickname\b/i, $contents)) $canAccessChatroom == 0;
  }
  if ($canAccessChatroom == 0) {
   echo meta http-equiv=Refresh content='1;URL=http://; . $SERVER_NAME .
/chat/chat_login.php'\n;
   echo script\n!--\n  location.href='http://; . $SERVER_NAME .
/chat/chat_login.php';\n\/\/--\n/script\n;
  }
 }
?

No matter what I do, however, the file cannot be accessed if it exists and
causes damage galore.  Can anyone out there help me figure out what I did
wrong; I'm completely stumped and may have to rewrite this portion of the
chatroom in TCL, all of my TCL scripts have had NO problems whatsoever
accessing the txt files.

Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP can't access txt files (but TCL can..??)

2002-05-11 Thread Phil Powell

Swell, I found the error, and it was a STUPID one.. I misconfigured fread()!

Thanx though
Phil

TCL 1, PHP 2

- Original Message -
From: Lars Torben Wilson [EMAIL PROTECTED]
To: Phil Powell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, May 11, 2002 6:13 PM
Subject: Re: [PHP] PHP can't access txt files (but TCL can..??)


 On Sat, 2002-05-11 at 14:53, Phil Powell wrote:
  TCL 1, PHP 0
 
  Ok, I am frustrated.. here is my code and this portion has to be done in
  PHP.  I have a frame that can only be accessed if 1 of 2 things occur:
 
  1) if $HTTP_REFERER has a specific value
  2) if your nickname passed in the query string is found in the existing
  nicknames.txt file found in /chat/nicknames.txt
 
  Here is the code:

 Notes:

  o What version of PHP?
  o Is register_globals on or off? i.e. are you sure $DOCUMENT_ROOT
has a value and that you're not trying to open '/chat/nicknames.txt'?
  o Quote the 'r' in the fopen() call.
  o Try this all with error_reporting(E_ALL) and fix (not with '@')
everything it complains about.
  o Your second regex checks that $contents contains at least one alpha-
numeric or an underscore or a hyphen. Looks like it should be
checking that the string contains *only* those characters.
  o fread() takes 2 parameters, not one.
  o 'damage galore' doesn't tell us anything. What *exactly* is the
current result of running the below?

  ?
   // Security measure to prevent bookmarking of page unless nickname
exists
  in nicknames.txt
   $contents = ;
   if (!preg_match(/\bchat_process_nickname\b/i, $HTTP_REFERER)) {
$canAccessChatroom = 1;
if (strlen($nickname)  2) $canAccessChatroom = 0;
if (!file_exists($DOCUMENT_ROOT . /chat/nicknames.txt))
  $canAccessChatroom = 0;
if ($canAccessChatroom == 1) {
 $fileID = fopen($DOCUMENT_ROOT. /chat/nicknames.txt, r) or die
(could
  not open file);
 if (!$fileID) {
  $canAccessChatroom = 0;
 } else {
  $contents = fread($fileID);
  fclose($fileID);
 }
}
if ($canAccessChatroom == 1  strlen($contents) == 0)
$canAccessChatroom
  = 0;
if ($canAccessChatroom == 1  !preg_match(/[a-zA-Z0-9_\-]+/,
  $contents)) $canAccessChatroom == 0;
if ($canAccessChatroom == 1) {
 if (!preg_match(/\b$nickname\b/i, $contents)) $canAccessChatroom ==
0;
}
if ($canAccessChatroom == 0) {
 echo meta http-equiv=Refresh content='1;URL=http://; . $SERVER_NAME
.
  /chat/chat_login.php'\n;
 echo script\n!--\n  location.href='http://; . $SERVER_NAME .
  /chat/chat_login.php';\n\/\/--\n/script\n;
}
   }
  ?
 
  No matter what I do, however, the file cannot be accessed if it exists
and
  causes damage galore.  Can anyone out there help me figure out what I
did
  wrong; I'm completely stumped and may have to rewrite this portion of
the
  chatroom in TCL, all of my TCL scripts have had NO problems whatsoever
  accessing the txt files.
 
  Phil


 --
  Torben Wilson [EMAIL PROTECTED]
  http://www.thebuttlesschaps.com
  http://www.hybrid17.com
  http://www.inflatableeye.com
  +1.604.709.0506




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Using function in PHP script n DOCROOT in PHP script in subfolder

2002-05-10 Thread Phil Powell

?

 // This function is the PHP version of the TCL proc PRODUCE_MENUBAR which
 // will produce the menubar for all PHP files
 //
 // Syntax: echo PRODUCE_MENUBAR()
 //


 function PRODUCE_MENUBAR() {
  global $HTTP_HOST;
  $tcl = (preg_match(/\bdyndns\b/i, $HTTP_HOST)) ? tclsh83 : tclsh;
  $path = (preg_match(/\bdyndns\b/i, $HTTP_HOST)) ? cgi-bin :
cgi-bin/cgiwrap/ppowell;
  $fileID = fopen(http://$HTTP_HOST/$path/menubar.cgi;, r);
  $menubar = fread($fileID, 100);
  fclose($fileID);
  return $menubar;
 }

?

This function exists in the file menubar_functions.php which is in the
docroot.  I have a PHP script in a subfolder /chat that produces a Fatal
Error (call to undefined function PRODUCE_MENUBAR()) each time it tries to
find it.

How do I fix this problem? I do not want to duplicate the PHP script per
folder as there will be an enormous amount of dynamically-created subfolders
and I will have to copy a version per folder.  I want to be able to use the
one PHP script in the DOCROOT for every PHP script in every subfolder, how
is this done?

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How long does a session last? Need to have it at 20mins

2002-04-19 Thread Phil Powell

I had thought that a session would last only 20 mins if
session.gc_maxlifetime is set at 1440.  Was I wrong in assuming this?  I
have pages that have session_start() at the top to persist the session
throughout the life-cycle of these pages, however, I want the session to
expire after 20 mins or so of use.  How can I assure that the session will
expire after 20 mins?

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How do I handle file uploading for several files at one time?

2002-04-18 Thread Phil Powell

Consider this block of code:

form enctype=multipart/form-data action=... method=post
...
input type=file name=photo1 size=50
input type=file name=photo2 size=50
input type=file name=photo3 size=50
input type=file name=photo4 size=50
input type=file name=photo5 size=50
...
/form

In my PHP script, I have the following:

for ($i = 1; $i = 5; $i++) {
if (is_uploaded_file($HTTP_POST_FILES['userfile'][$i]['tmp_name'])) {
 $hasNoPics = false;
 move_uploaded_file($HTTP_POST_FILES['userfile'][$i]['tmp_name'],
  $DOCUMENT_ROOT/webmissions/pics/$username/ .
$HTTP_POST_FILES['userfile'][$i]['name']
 );
} else {
 echo Possible file upload attack. Filename:  .
$HTTP_POST_FILES['userfile'][$i]['name'];
 $hasNoPics = true;
}
   }

This block of code produces a riddling of PHP errors:

Warning: Undefined index: userfile in c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 76

Warning: Undefined index: userfile in c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 82
Possible file upload attack. Filename:

What I need to know is, what did I do wrong? I need to be able to move 1-5
submitted files at one time but I can't find any documentation on php.net
that handles such an exotic piece of code.

What do I do?

Phil





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to create, name and start PHP sessions

2002-04-18 Thread Phil Powell

Will the following lines set up a session by the name of hasLoggedIn with
HTTP_SESSION_VARS[username]?

$stuff = session_name(hasLoggedIn);
 $HTTP_SESSION_VARS[username] = $username;
 session_start();

I am trying to create a page that sets a session variable upon successful
login, problem is, the session_name() never changes it always remains the
default PHPSESSID  what am I doing wrong now?

I fixed the problem with multiple files, that was bizarre!

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: How to create, name and start PHP sessions

2002-04-18 Thread Phil Powell

Thanx, however, I cannot retain the session_name when I go to the next URL.
How do I retain the session_name especially when I have to use a form
method=POST?

I have a URL that will be the login

Once you login you will have a session (that works now)

That page with the session will have a form with five input=file type form
elements

Once submitted you will be at a thank-you page and files uploaded, but
then the session is gone (session_name is back to PHPSESSID again)

What do I do to keep it? I cannot use cookies and putting it in the URL?

Phil
Michael Virnstein [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 session_name will retur the previos name of the session, so in your case
 $stuff will contain PHPSESSID
 and i think you have to call session_start(); before you do
 $HTTP_SESSION_VARS[username] = $username;

 so perhaps this will work:

 session_name(hasLoggedIn);
 $stuff = session_name();
 session_start();
 $HTTP_SESSION_VARS[username] = $username;

 Regards, Michael

 Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Will the following lines set up a session by the name of hasLoggedIn
 with
  HTTP_SESSION_VARS[username]?
 
  $stuff = session_name(hasLoggedIn);
   $HTTP_SESSION_VARS[username] = $username;
   session_start();
 
  I am trying to create a page that sets a session variable upon
successful
  login, problem is, the session_name() never changes it always remains
the
  default PHPSESSID  what am I doing wrong now?
 
  I fixed the problem with multiple files, that was bizarre!
 
  Thanx
  Phil
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: How to create, name and start PHP sessions

2002-04-18 Thread Phil Powell

I am now getting the following errors on every page:

Warning: Cannot send session cache limiter - headers already sent (output
started at c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php:25) in
c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 81


This is when I use the following block of code to first SET the session for
the very first time:

if (mysql_num_rows($results) == 0) {
 // Could not find info in db redirect to login library with error msg
 $errorHTML .= font color=ccWe could not find your information ;
 $errorHTML .=  in our database.  Please try again./fontp;
 $hasLoggedIn = 0;
} else if (strcmp(session_name(), hasLoggedIn) != 0) {
 // Set up session variable with username and redirect to pic upload lib
 session_name(hasLoggedIn);
 $name = session_name();
 session_start();
 $HTTP_SESSION_VARS[username] = $username;
 $HTTP_SESSION_VARS[ip] = $REMOTE_ADDR; // To prevent session stealing
}

I am completely confused!

Phil


Michael Virnstein [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 you have to put this on top of every of your pages:
 -
 session_name(hasLoggedIn);
 $stuff = session_name();
 session_start();
 -
 session_name first sets the name. then you call session_start which will
 look for the
 sessionid in ${session_name()}. that is why you have to call
session_name()
 BEFORE calling
 session_start();

 Regards Michael


 Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Thanx, however, I cannot retain the session_name when I go to the next
 URL.
  How do I retain the session_name especially when I have to use a form
  method=POST?
 
  I have a URL that will be the login
 
  Once you login you will have a session (that works now)
 
  That page with the session will have a form with five input=file type
 form
  elements
 
  Once submitted you will be at a thank-you page and files uploaded, but
  then the session is gone (session_name is back to PHPSESSID again)
 
  What do I do to keep it? I cannot use cookies and putting it in the URL?
 
  Phil
  Michael Virnstein [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   session_name will retur the previos name of the session, so in your
case
   $stuff will contain PHPSESSID
   and i think you have to call session_start(); before you do
   $HTTP_SESSION_VARS[username] = $username;
  
   so perhaps this will work:
  
   session_name(hasLoggedIn);
   $stuff = session_name();
   session_start();
   $HTTP_SESSION_VARS[username] = $username;
  
   Regards, Michael
  
   Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Will the following lines set up a session by the name of
hasLoggedIn
   with
HTTP_SESSION_VARS[username]?
   
$stuff = session_name(hasLoggedIn);
 $HTTP_SESSION_VARS[username] = $username;
 session_start();
   
I am trying to create a page that sets a session variable upon
  successful
login, problem is, the session_name() never changes it always
remains
  the
default PHPSESSID  what am I doing wrong now?
   
I fixed the problem with multiple files, that was bizarre!
   
Thanx
Phil
   
   
  
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: How to create, name and start PHP sessions

2002-04-18 Thread Phil Powell

I am now getting the following errors on every page:

Warning: Cannot send session cache limiter - headers already sent (output
started at c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php:25) in
c:\program files\apache
group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 81

This is when I use the following block of code to first SET the session for
the very first time:

if (mysql_num_rows($results) == 0) {
 // Could not find info in db redirect to login library with error msg
 $errorHTML .= font color=ccWe could not find your information ;
 $errorHTML .=  in our database.  Please try again./fontp;
 $hasLoggedIn = 0;
} else if (strcmp(session_name(), hasLoggedIn) != 0) {
 // Set up session variable with username and redirect to pic upload lib
 session_name(hasLoggedIn);
 $name = session_name();
 session_start();
 $HTTP_SESSION_VARS[username] = $username;
 $HTTP_SESSION_VARS[ip] = $REMOTE_ADDR; // To prevent session stealing
}

I am completely confused!

Phil

Michael Virnstein [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 you have to put this on top of every of your pages:
 -
 session_name(hasLoggedIn);
 $stuff = session_name();
 session_start();
 -
 session_name first sets the name. then you call session_start which will
 look for the
 sessionid in ${session_name()}. that is why you have to call
session_name()
 BEFORE calling
 session_start();

 Regards Michael


 Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Thanx, however, I cannot retain the session_name when I go to the next
 URL.
  How do I retain the session_name especially when I have to use a form
  method=POST?
 
  I have a URL that will be the login
 
  Once you login you will have a session (that works now)
 
  That page with the session will have a form with five input=file type
 form
  elements
 
  Once submitted you will be at a thank-you page and files uploaded, but
  then the session is gone (session_name is back to PHPSESSID again)
 
  What do I do to keep it? I cannot use cookies and putting it in the URL?
 
  Phil
  Michael Virnstein [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   session_name will retur the previos name of the session, so in your
case
   $stuff will contain PHPSESSID
   and i think you have to call session_start(); before you do
   $HTTP_SESSION_VARS[username] = $username;
  
   so perhaps this will work:
  
   session_name(hasLoggedIn);
   $stuff = session_name();
   session_start();
   $HTTP_SESSION_VARS[username] = $username;
  
   Regards, Michael
  
   Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Will the following lines set up a session by the name of
hasLoggedIn
   with
HTTP_SESSION_VARS[username]?
   
$stuff = session_name(hasLoggedIn);
 $HTTP_SESSION_VARS[username] = $username;
 session_start();
   
I am trying to create a page that sets a session variable upon
  successful
login, problem is, the session_name() never changes it always
remains
  the
default PHPSESSID  what am I doing wrong now?
   
I fixed the problem with multiple files, that was bizarre!
   
Thanx
Phil
   
   
  
  
 
 


Uchendu Nwachukwu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 In your example, simply place this line in your code (on *every* page you
 want the session to be on):

 session_name(HasLoggedIn);
 session_register(username);

 If your PHP was compiled with '--enable-trans-sid' you shouldn't have to
 worry about anything else. PHP will automatically store the session ID in
a
 cookie, or it will pass the session ID in your HTML links. If it wasn't
 compiled with '--enable-trans-sid', you'll need to use the constant SID.

 Example:
 --
 ?php
 session_name(HasLoggedIn);
 session_register(username);  ?

 Welcome ?=$username;?. !-- assumes user has already entered a username
on
 some other page --

 a href=nextpage.php??=SID;?Click here to continue./a
 --

 Hope that helps! Check out http://www.php.net/manual/en/ref.session.php
for
 more info

 --
 Uchendu Nwachukwu
 newsreply AT unndunn DOT com - www.unndunn.com

 Phil Powell [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Thanx, however, I cannot retain the session_name when I go to the next
 URL.
  How do I retain the session_name especially when I have to use a form
  method=POST?
 
  I have a URL that will be the login
 
  Once you login you will have a session (that works now)
 
  That page with the session will have a form wit

[PHP] Re: How to create, name and start PHP sessions

2002-04-18 Thread Phil Powell

OK thanx figured out a workaround in the meantime, I am setting and
retaining part of the session, but not all session variables, am I doing
this wrong???

$ip = $REMOTE_ADDR;

 // Check for session - if session is set user has already logged in
  session_start();
  $login_state = $_SESSION[login_state];
  if ($login_state[hasLoggedIn] === 1) $hasLoggedIn = 1;
  if ($login_state[ip] != $REMOTE_ADDR) $hasLoggedIn = 0; // Prevents
session stealing
  $temp .= Your new session id is:  . $login_state[ip] . br;

$login_state[ip] never exists, though it's supposed to when the session is
created upon successful login:

// Set up session variable with username and redirect to pic upload lib
 session_start();
 $login_state[hasLoggedIn] = 1;
 $login_state[ip] = $ip;
 session_register(login_state);
 header(Location: http://; . $HTTP_HOST . $PHP_SELF);

You can see I am going to be a big problem :(

Phil

Uchendu Nwachukwu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Make sure you aren't sending any HTML to the browser for any reason before
 the session_start(); call.

 Surefire way to prevent this error: place the following line as the first
 line of PHP script you execute on every page:

 ob_start();

 Check out http://www.php.net/ob_start for details on what that does.

 --
 Uchendu Nwachukwu
 newsreply AT unndunn DOT com - www.unndunn.com

 Phil Powell [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I am now getting the following errors on every page:
 
  Warning: Cannot send session cache limiter - headers already sent
(output
  started at c:\program files\apache
  group\apache\htdocs\webmissions\picupload\miss_pic_upload.php:25) in
  c:\program files\apache
  group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 81
 
  This is when I use the following block of code to first SET the session
 for
  the very first time:
 
  if (mysql_num_rows($results) == 0) {
   // Could not find info in db redirect to login library with error
msg
   $errorHTML .= font color=ccWe could not find your
information
 ;
   $errorHTML .=  in our database.  Please try again./fontp;
   $hasLoggedIn = 0;
  } else if (strcmp(session_name(), hasLoggedIn) != 0) {
   // Set up session variable with username and redirect to pic upload
 lib
   session_name(hasLoggedIn);
   $name = session_name();
   session_start();
   $HTTP_SESSION_VARS[username] = $username;
   $HTTP_SESSION_VARS[ip] = $REMOTE_ADDR; // To prevent session
 stealing
  }
 
  I am completely confused!
 
  Phil
 
  Michael Virnstein [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   you have to put this on top of every of your pages:
   -
   session_name(hasLoggedIn);
   $stuff = session_name();
   session_start();
   -
   session_name first sets the name. then you call session_start which
will
   look for the
   sessionid in ${session_name()}. that is why you have to call
  session_name()
   BEFORE calling
   session_start();
  
   Regards Michael
  
  
   Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Thanx, however, I cannot retain the session_name when I go to the
next
   URL.
How do I retain the session_name especially when I have to use a
form
method=POST?
   
I have a URL that will be the login
   
Once you login you will have a session (that works now)
   
That page with the session will have a form with five input=file
 type
   form
elements
   
Once submitted you will be at a thank-you page and files uploaded,
 but
then the session is gone (session_name is back to PHPSESSID again)
   
What do I do to keep it? I cannot use cookies and putting it in the
 URL?
   
Phil
Michael Virnstein [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 session_name will retur the previos name of the session, so in
your
  case
 $stuff will contain PHPSESSID
 and i think you have to call session_start(); before you do
 $HTTP_SESSION_VARS[username] = $username;

 so perhaps this will work:

 session_name(hasLoggedIn);
 $stuff = session_name();
 session_start();
 $HTTP_SESSION_VARS[username] = $username;
    
     Regards, Michael

 Phil Powell [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Will the following lines set up a session by the name of
  hasLoggedIn
 with
  HTTP_SESSION_VARS[username]?
 
  $stuff = session_name(hasLoggedIn);
   $HTTP_SESSION_VARS[username] = $username;
   session_start();
 
  I am trying to create a page that sets a session variable upon
successful
  login, problem is, the 

[PHP] Need to read CGI script in TCL, evaluate and display contents in Safe-Mode

2002-04-16 Thread Phil Powell

The server is UNIX-based server for Linux running PHP in safe mode.

I have a CGI script I wrote in TCL, menubar.cgi, that I have to include into
a PHP file on the docroot, feedback.phtml.  How do I include the CGI script
and display the evaluated contents (again, it's in TCL, not PHP not even in
Perl), which will be a menubar, into the PHP file?

I cannot use backticks, system() or passthru() because the remote system is
running in safe mode and I am not allowed to change that.

What do I do?

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHTML - anyone know anything about this?

2002-04-16 Thread Phil Powell

Anyone out there ever work with .phtml files?? Especially in trying to
include CGI scripts into .phtml files?

Need some help here if possible
Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Screen Scraping using PHP

2002-04-16 Thread Phil Powell

I am having to do a remote URL screen scrape using PHP in safe-mode.  What
do you recommend I do?

Thanx
Phil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Session Variables

2002-04-16 Thread Phil Powell

I understand the concept of session variables, so I want to know the best
methodology of approaching this:

1) HTML redirect to PHP page
2) PHP page looks for session
  a) If found, show some stuff
  b) If not found, prompt user for username and password
3) If no session, prompt user for username and password, once entered  is
ok, set session and redirect

Following is a code snippet I borrowed that I think would work, correct me
if I'm wrong:

// Setting a name for our session.
session_name(hasLoggedIn);
// Starting Session.
session_start();
// Register vars into session
session_register(username);
// Setting values for session vars.
$HTTP_SESSION_VARS[username]=$HTTP_POST_VARS[username];
// Referring a session info to another PHP.
echo A HREF=\somefile.php? . session_name() . = . session_id() .
%s\text/A;

Thanx!!
Phil




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php