php-general Digest 21 Jun 2003 22:55:26 -0000 Issue 2131

Topics (messages 152376 through 152412):

Re: making image smaller with same aspect ratio
        152376 by: azero

search-and-highlight issue ("byt tes")
        152377 by: 457945.gmx.ch
        152379 by: Milan Reznicek

Re: saving TEXTAREA data into mysql database
        152378 by: Catalin Trifu
        152383 by: Artoo
        152405 by: John W. Holmes
        152406 by: Jeff Harris

Returning TWO variables from function
        152380 by: Roy W
        152396 by: Hugh Bothwell

Re: MAIL( ) - Send mail using another SMTP
        152381 by: Verdon Vaillancourt
        152382 by: Verdon Vaillancourt
        152386 by: Joseph Szobody

Problem receiving notification emails to mails sent with php
        152384 by: czamora
        152385 by: Lowell Allen

Coercing a date calc - problem - or am I just dumb tryin g it this way
        152387 by: George Pitcher

Passing Variables
        152388 by: Jay Fitzgerald
        152389 by: Thomas Seifert
        152390 by: nabil
        152391 by: George Pitcher
        152393 by: Jay Fitzgerald
        152395 by: George Pitcher
        152399 by: Thomas Seifert
        152404 by: John W. Holmes
        152408 by: Jeff Harris

Re: Coercing a date calc - problem - or am I just dumb tryin g it this way SOLVED
        152392 by: George Pitcher

correct session format?
        152394 by: Jay Fitzgerald
        152397 by: Thomas Seifert

PHP Code inside Zend_API
        152398 by: Suhas Pharkute

Text files vs other types
        152400 by: Sparky Kopetzky

AOL
        152401 by: rml
        152403 by: Michael Geier

reference a function in a class from array_walk()
        152402 by: Thomas Hochstetter
        152407 by: David Otton
        152412 by: Leif K-Brooks

Re: Header, Directory, and SESSIONs
        152409 by: Andrew Warner

Is there a way to get rid of \' and \" ?
        152410 by: Dan Anderson
        152411 by: Brad Pauly

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
> Hey all,
>
> How do you reduse an image while keeping the same aspect ratio so not to
> distort the image
>
> Thanks

Original image: x - 800 y - 600
New size: x1 -100 y1 - ?

y1 = 600*100/800 = 75

formula is: y1 = y*x1/x
the same if you want to find x1 when know y1.



--- End Message ---
--- Begin Message ---
hello!

i have a problem with a search-and-highlight script (see code below):

a search for "byt tes" matches entries that contain "bytes" but only
highlights "byt"*.

*) because after the first search term ("byt") is found the line is modified
into <span class="highlight">byt</span>es and therefore the secound search
term ("tes") can't be highlighted anymore.


1. general question

i'm not quite sure if a search like this should match entries that contain a
combination of both terms ("bytes").
of course, the word "bytes" contains both search terms - but on the other
hand, a search for "byt tes" indicates that i'm looking for TWO terms (and
also for TWO "t"s).


2. how to do it anyway?

do you have an idea how to accomplish that this kind of search
- either: does NOT display entries that match "bytes"
- or: displays entries that contain "bytes" and highlights "bytes"

(because both solutions seem to be somehow logical it may depend on the
easiness of creation and/or the speed of processing.)


thanks a lot for your effort!!

best wishes

philipp
www.ipdraw.org


---
code

notes:
- the highlight/preg_replace part is built to skip html tags.
- if you have any other suggestions for improvements, please let me know.


if (isset($src)) {

  if (preg_match("/[A-z]/", $src) | preg_match("/[0-9]/", $src)) {

  $src = stripslashes($src);
  $src = preg_replace("/\,/i", " ", $src);
  $src = html_entity_decode($src);
  $src = preg_replace("/&nbsp;/i", " ", $src);
  $src = preg_replace("/[[:space:]]+/i", " ", $src);
  $src = trim($src);

  $handle = fopen($entries, "r");
  $i = 1;
  $results = 0;

  while ($i <= $dbs_total) {
      $buffer = fgets($handle, 4096);
      $buffer_raw = strip_tags($buffer);
      $buffer_raw = preg_replace("/&nbsp;/i", " ", $buffer_raw);

      $words = explode(' ', $src);
      $t = 0;
      $test='return(';
      foreach($words as $word)
      {
          if($t>0)$test.=' && ';
          $test.='strstr($buffer_raw,\''.$word.'\')';
          $t++;
      }
      $test.=');';
      // 01:A
      if (eval($test)) {
      foreach($words as $word)
      {
      $wordreg = preg_replace('/([\.\*\+\(\)\[\]])/','\\\\\1',$word);
      $buffer = 
preg_replace('/(<)([^>]*)('.("$wordreg").')([^<]*)(>)/sei',"'\\1'.preg_repla
ce('/'.(\"$wordreg\").'/i','###','\\2\\3\\4').'\\5'",stripslashes($buffer));
      $buffer = preg_replace('/('.$wordreg.')/si','<span
class="highlight">\\1</span>',stripslashes($buffer));
      $buffer = preg_replace('/###/si',$word,$buffer);
      }
      echo $buffer;
      $results++;
      }
      $i++;
    }
    fclose ($handle);
  } else {
  $illegal_src = 1;
  }
}


--- End Message ---
--- Begin Message ---
And what about highlighting the whole word which contains the searched term.


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 21, 2003 12:31 PM
Subject: [PHP] search-and-highlight issue ("byt tes")


> hello!
>
> i have a problem with a search-and-highlight script (see code below):
>
> a search for "byt tes" matches entries that contain "bytes" but only
> highlights "byt"*.
>
> *) because after the first search term ("byt") is found the line is
modified
> into <span class="highlight">byt</span>es and therefore the secound search
> term ("tes") can't be highlighted anymore.
>
>
> 1. general question
>
> i'm not quite sure if a search like this should match entries that contain
a
> combination of both terms ("bytes").
> of course, the word "bytes" contains both search terms - but on the other
> hand, a search for "byt tes" indicates that i'm looking for TWO terms (and
> also for TWO "t"s).
>
>
> 2. how to do it anyway?
>
> do you have an idea how to accomplish that this kind of search
> - either: does NOT display entries that match "bytes"
> - or: displays entries that contain "bytes" and highlights "bytes"
>
> (because both solutions seem to be somehow logical it may depend on the
> easiness of creation and/or the speed of processing.)
>
>
> thanks a lot for your effort!!
>
> best wishes
>
> philipp
> www.ipdraw.org
>
>
> ---
> code
>
> notes:
> - the highlight/preg_replace part is built to skip html tags.
> - if you have any other suggestions for improvements, please let me know.
>
>
> if (isset($src)) {
>
>   if (preg_match("/[A-z]/", $src) | preg_match("/[0-9]/", $src)) {
>
>   $src = stripslashes($src);
>   $src = preg_replace("/\,/i", " ", $src);
>   $src = html_entity_decode($src);
>   $src = preg_replace("/&nbsp;/i", " ", $src);
>   $src = preg_replace("/[[:space:]]+/i", " ", $src);
>   $src = trim($src);
>
>   $handle = fopen($entries, "r");
>   $i = 1;
>   $results = 0;
>
>   while ($i <= $dbs_total) {
>       $buffer = fgets($handle, 4096);
>       $buffer_raw = strip_tags($buffer);
>       $buffer_raw = preg_replace("/&nbsp;/i", " ", $buffer_raw);
>
>       $words = explode(' ', $src);
>       $t = 0;
>       $test='return(';
>       foreach($words as $word)
>       {
>           if($t>0)$test.=' && ';
>           $test.='strstr($buffer_raw,\''.$word.'\')';
>           $t++;
>       }
>       $test.=');';
>       // 01:A
>       if (eval($test)) {
>       foreach($words as $word)
>       {
>       $wordreg = preg_replace('/([\.\*\+\(\)\[\]])/','\\\\\1',$word);
>       $buffer =
>
preg_replace('/(<)([^>]*)('.("$wordreg").')([^<]*)(>)/sei',"'\\1'.preg_repla
>
ce('/'.(\"$wordreg\").'/i','###','\\2\\3\\4').'\\5'",stripslashes($buffer));
>       $buffer = preg_replace('/('.$wordreg.')/si','<span
> class="highlight">\\1</span>',stripslashes($buffer));
>       $buffer = preg_replace('/###/si',$word,$buffer);
>       }
>       echo $buffer;
>       $results++;
>       }
>       $i++;
>     }
>     fclose ($handle);
>   } else {
>   $illegal_src = 1;
>   }
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
        Hi,

    See the manual nl2br() function.
http://www.php.net/manual/en/function.nl2br.php

Cheers,
Catalin


"Artoo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey,
>
> How do you save the data from a TEXTAREA of a form into a mysql database
so
> that when you retrieve the data later you get the same format that the
user
> entered
>
> EXAMPLE
> user enters the following and cliks save
>
> Line 1 testing
> Line 2 TEST
>
> Line 4 test
>
> line 5 test
>
> test
>
> testing
>
> result when displaying data
>
> Line 1 testingLine 2 TESTLine 4 testline 5 testtesttesting
>
>
> How do I get it so the format is the same?
>
> Thanks
>
>



--- End Message ---
--- Begin Message ---
Thanks,

Is it better to use that function before the INSERT query and save it to the
database like that or use that nl2br() function while displaying the results
of the SELECT query,

Thanks agian.
Artoo

"Catalin Trifu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>         Hi,
>
>     See the manual nl2br() function.
> http://www.php.net/manual/en/function.nl2br.php
>
> Cheers,
> Catalin
>
>
> "Artoo" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hey,
> >
> > How do you save the data from a TEXTAREA of a form into a mysql database
> so
> > that when you retrieve the data later you get the same format that the
> user
> > entered
> >
> > EXAMPLE
> > user enters the following and cliks save
> >
> > Line 1 testing
> > Line 2 TEST
> >
> > Line 4 test
> >
> > line 5 test
> >
> > test
> >
> > testing
> >
> > result when displaying data
> >
> > Line 1 testingLine 2 TESTLine 4 testline 5 testtesttesting
> >
> >
> > How do I get it so the format is the same?
> >
> > Thanks
> >
> >
>
>



--- End Message ---
--- Begin Message --- Artoo wrote:
Is it better to use that function before the INSERT query and save it to the
database like that or use that nl2br() function while displaying the results
of the SELECT query,

Use it while displaying. You generally want to save the data in the database exactly as it was entered. This will allow you to display it back to the user for editing without them wondering what all the <br /> are in their sentences and also use it in other places, like mail or files...


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
On Jun 21, 2003, "John W. Holmes" claimed that:

|Artoo wrote:
|> Is it better to use that function before the INSERT query and save it to the
|> database like that or use that nl2br() function while displaying the results
|> of the SELECT query,
|
|Use it while displaying. You generally want to save the data in the
|database exactly as it was entered. This will allow you to display it
|back to the user for editing without them wondering what all the <br />
|are in their sentences and also use it in other places, like mail or
|files...
|

I believe, that alternatively, you can wrap the output within <pre></pre>
tags for the html out.

Jeff

-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



--- End Message ---
--- Begin Message ---
Can someone let me know how to return TWO variables from a function
 
I tried:
 
return $var1, $var2;
 
But I get parse errors and other errors.
 
Thanks!

--- End Message ---
--- Begin Message ---
"Roy W" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Can someone let me know how to return TWO variables from a function
>
> I tried:
>
> return $var1, $var2;
>
> But I get parse errors and other errors.


function ReturnMultiValues($a, $b, $c, $d) {
    return array($a, $b, $c, $d);
}


list($first, $second, $third, $fourth) = ReturnMultiValues(1, 2, 3, 4);


--
Hugh Bothwell     [EMAIL PROTECTED]     Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b++++ DI+++ D-(++) G+ e(++) h-- r- y+




--- End Message ---
--- Begin Message ---
I think you can do this with an .htaccess file instead of the php.ini file
:)


On 6/21/03 6:29 AM, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> From: Chinmoy Barua <[EMAIL PROTECTED]>
> Date: Fri, 20 Jun 2003 23:46:06 -0700 (PDT)
> To: [EMAIL PROTECTED]
> Subject: MAIL( ) - Send mail using another SMTP
> 
> Hello Everybody,
> 
> I don't have sendmail/qmail on my web server where i
> installed PHP. But I want to send mails from web
> server using PHP.
> 
> Can anybody tell me, how can i use another SMTP server
> to send mails? I don't like to change php.ini on my
> web server.
> 
> Thank You,
> - Chinmoy


--- End Message ---
--- Begin Message ---
Something like this...

Add the following into a .htaccess file for your domain(s)

php_value SMTP  smtp.yourhost.com



On 6/21/03 7:51 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> how do you do this   please explain



--- End Message ---
--- Begin Message ---
Here is a class that you could use.

http://phpmailer.sourceforge.net/

Joseph

"Chinmoy Barua" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hello Everybody,
> 
> I don't have sendmail/qmail on my web server where i
> installed PHP. But I want to send mails from web
> server using PHP. 
> 
> Can anybody tell me, how can i use another SMTP server
> to send mails? I don't like to change php.ini on my
> web server.
> 
> Thank You,
> - Chinmoy
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com


--- End Message ---
--- Begin Message ---
Hi there,

I'm sending emails to the subscribers of my site using mail() with a fourth
parameter to specify the From: and Reply-To: headers. They seem to be sent
correctly and the users may reply to them and I get the replies in the
mailbox identified by these headers.
The problem is some email addresses I'm sending email to are incorrect, and
I should be receiving the email notification saying that the email could not
be delivered. But I'm not receiving these messages in my mailbox.
Any ideas why this could be so?

Thanks a lot for any hints.

I'm sending mails with:

mail($to, $subject, $body, $from);

where $from = "<[EMAIL PROTECTED]>\nReply-To:
[EMAIL PROTECTED]: PHP/" . phpversion();

I've also tried using \r\n instead of \n



--- End Message ---
--- Begin Message ---
> From: "czamora" <[EMAIL PROTECTED]>
> 
> I'm sending emails to the subscribers of my site using mail() with a fourth
> parameter to specify the From: and Reply-To: headers. They seem to be sent
> correctly and the users may reply to them and I get the replies in the
> mailbox identified by these headers.
> The problem is some email addresses I'm sending email to are incorrect, and
> I should be receiving the email notification saying that the email could not
> be delivered. But I'm not receiving these messages in my mailbox.
> Any ideas why this could be so?
> 
> Thanks a lot for any hints.
> 
> I'm sending mails with:
> 
> mail($to, $subject, $body, $from);
> 
> where $from = "<[EMAIL PROTECTED]>\nReply-To:
> [EMAIL PROTECTED]: PHP/" . phpversion();
> 
> I've also tried using \r\n instead of \n

Send yourself an email using PHP and examine the Return-Path listed in the
source code. (The Return-Path is not the same as the From you're setting.)
If you're using a commercial host (shared hosting), then the Return-Path is
probably something like [EMAIL PROTECTED] My host provides
Horde for web-based email, and bounces go to the master user account.

HTH

--
Lowell Allen


--- End Message ---
--- Begin Message ---
Hi all,

I've just written this function:

$term='Michaelmas';
function f_week($w,$t)
{
        $P=7*($w-1);
        if( $t == 'Michaelmas'){
                $D = 06;
                $M = 10;
                $Y = 2003;
        } else {
                $D = 12;
                $M = 01;
                $Y = 2004;
        }
        $week=date("d/m/Y", mktime(0,0,0,$D+$P,$M,$Y));
        return $week;
}
?>
Michaelmas week 4 is <? echo f_week(4,$term) ?>

But the date it shows is '10/03/2005 ' rather than '03/10/2003'.

Suggestions please.

George in Oxford



--- End Message ---
--- Begin Message --- I have been searching for an answer to this for a couple of hours now and cant find anything. I believe that there is a secure way of doing this but I think my brain is having a momentary lapse...

I have these variables:

$eventid = "1";
$age = "15";

Is there a way to pass these variables to the next page so I can continue using them without doing something like this:

<A HREF="test.php?eventid=1&age=15">

I would rather not have the variables be seen or known to the end user for security reasons because they could change them in the URL. I know it has something to do with $_GET and $_POST because I do have register_globals set to OFF in my php file and I do not want to turn them on....

TIA


--- End Message ---
--- Begin Message ---
If you don't want them seen anywhere, then you've got to use 
sessions.


Thomas

On Sat, 21 Jun 2003 08:53:12 -0500 [EMAIL PROTECTED] (Jay Fitzgerald) wrote:

> I have been searching for an answer to this for a couple of hours now and 
> cant find anything. I believe that there is a secure way of doing this but 
> I think my brain is having a momentary lapse...
> 
> I have these variables:
> 
> $eventid = "1";
> $age = "15";
> 
> Is there a way to pass these variables to the next page so I can continue 
> using them without doing something like this:
> 
> <A HREF="test.php?eventid=1&age=15">
> 
> I would rather not have the variables be seen or known to the end user for 
> security reasons because they could change them in the URL. I know it has 
> something to do with $_GET and $_POST because I do have register_globals 
> set to OFF in my php file and I do not want to turn them on....
> 
> TIA
> 



--- End Message ---
--- Begin Message ---
use hidden field (pure html) and then u have it as $yourhiddenfield on the
next page even u have the register global off..

Nabil


"Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have been searching for an answer to this for a couple of hours now and
> cant find anything. I believe that there is a secure way of doing this but
> I think my brain is having a momentary lapse...
>
> I have these variables:
>
> $eventid = "1";
> $age = "15";
>
> Is there a way to pass these variables to the next page so I can continue
> using them without doing something like this:
>
> <A HREF="test.php?eventid=1&age=15">
>
> I would rather not have the variables be seen or known to the end user for
> security reasons because they could change them in the URL. I know it has
> something to do with $_GET and $_POST because I do have register_globals
> set to OFF in my php file and I do not want to turn them on....
>
> TIA
>



--- End Message ---
--- Begin Message ---
Nabil,

That is one way but it means that Jay would have to use a form and not a
link.

You could set a cookie. That would work, but it relies on the user allowing
cookies.

George

> -----Original Message-----
> From: nabil [mailto:[EMAIL PROTECTED]
> Sent: 21 June 2003 2:58 pm
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Passing Variables
>
>
> use hidden field (pure html) and then u have it as $yourhiddenfield on the
> next page even u have the register global off..
>
> Nabil
>
>
> "Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have been searching for an answer to this for a couple of
> hours now and
> > cant find anything. I believe that there is a secure way of
> doing this but
> > I think my brain is having a momentary lapse...
> >
> > I have these variables:
> >
> > $eventid = "1";
> > $age = "15";
> >
> > Is there a way to pass these variables to the next page so I
> can continue
> > using them without doing something like this:
> >
> > <A HREF="test.php?eventid=1&age=15">
> >
> > I would rather not have the variables be seen or known to the
> end user for
> > security reasons because they could change them in the URL. I
> know it has
> > something to do with $_GET and $_POST because I do have register_globals
> > set to OFF in my php file and I do not want to turn them on....
> >
> > TIA
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message --- That was my thought too, George. But if the user does not have cookies enabled, then I believe, as Thomas pointed out, that a SESSION is the only way to handle the variables. I have never done a "correct" session so I am trying to learn how to do them without having a userid and password for each user. I have played with sessions but I don't know if I am doing them correctly or how to do sessions without authentication.

Jay



At 03:14 PM 6/21/2003 +0100, George Pitcher wrote:
Nabil,

That is one way but it means that Jay would have to use a form and not a
link.

You could set a cookie. That would work, but it relies on the user allowing
cookies.

George

> -----Original Message-----
> From: nabil [mailto:[EMAIL PROTECTED]
> Sent: 21 June 2003 2:58 pm
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Passing Variables
>
>
> use hidden field (pure html) and then u have it as $yourhiddenfield on the
> next page even u have the register global off..
>
> Nabil
>
>
> "Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have been searching for an answer to this for a couple of
> hours now and
> > cant find anything. I believe that there is a secure way of
> doing this but
> > I think my brain is having a momentary lapse...
> >
> > I have these variables:
> >
> > $eventid = "1";
> > $age = "15";
> >
> > Is there a way to pass these variables to the next page so I
> can continue
> > using them without doing something like this:
> >
> > <A HREF="test.php?eventid=1&age=15">
> >
> > I would rather not have the variables be seen or known to the
> end user for
> > security reasons because they could change them in the URL. I
> know it has
> > something to do with $_GET and $_POST because I do have register_globals
> > set to OFF in my php file and I do not want to turn them on....
> >
> > TIA
> >
>
>
>
> --
> 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


--- End Message ---
--- Begin Message ---
Jay,

I've never ventured into 'sessions' (not ones without drinks) but I've a
feeling that if the user has turned cookies off then sessions are out as
well as they require a cookie being stored on the user's machine.

Someone will surely correct me if I am wrong.

I went to the PHP conference in Frankfurt about 18 months ago and Rasmus was
talking about 'clean' URLs (ithout the 'query' string. I never did find out
how though?

Cheers

George

> -----Original Message-----
> From: Jay Fitzgerald [mailto:[EMAIL PROTECTED]
> Sent: 21 June 2003 3:19 pm
> To: George Pitcher; nabil; [EMAIL PROTECTED]
> Subject: RE: [PHP] Re: Passing Variables
>
>
> That was my thought too, George. But if the user does not have cookies
> enabled, then I believe, as Thomas pointed out, that a SESSION is
> the only
> way to handle the variables. I have never done a "correct"
> session so I am
> trying to learn how to do them without having a userid and password for
> each user. I have played with sessions but I don't know if I am
> doing them
> correctly or how to do sessions without authentication.
>
> Jay
>
>
>
> At 03:14 PM 6/21/2003 +0100, George Pitcher wrote:
> >Nabil,
> >
> >That is one way but it means that Jay would have to use a form and not a
> >link.
> >
> >You could set a cookie. That would work, but it relies on the
> user allowing
> >cookies.
> >
> >George
> >
> > > -----Original Message-----
> > > From: nabil [mailto:[EMAIL PROTECTED]
> > > Sent: 21 June 2003 2:58 pm
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] Re: Passing Variables
> > >
> > >
> > > use hidden field (pure html) and then u have it as
> $yourhiddenfield on the
> > > next page even u have the register global off..
> > >
> > > Nabil
> > >
> > >
> > > "Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > > > I have been searching for an answer to this for a couple of
> > > hours now and
> > > > cant find anything. I believe that there is a secure way of
> > > doing this but
> > > > I think my brain is having a momentary lapse...
> > > >
> > > > I have these variables:
> > > >
> > > > $eventid = "1";
> > > > $age = "15";
> > > >
> > > > Is there a way to pass these variables to the next page so I
> > > can continue
> > > > using them without doing something like this:
> > > >
> > > > <A HREF="test.php?eventid=1&age=15">
> > > >
> > > > I would rather not have the variables be seen or known to the
> > > end user for
> > > > security reasons because they could change them in the URL. I
> > > know it has
> > > > something to do with $_GET and $_POST because I do have
> register_globals
> > > > set to OFF in my php file and I do not want to turn them on....
> > > >
> > > > TIA
> > > >
> > >
> > >
> > >
> > > --
> > > 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
>
>


--- End Message ---
--- Begin Message ---
you can transfer the session-id (which is unique) through the url too.
but then its only the session-id and not the actual data and the session-id
can't be guessed that simple to reach another user's data.


Thomas

On Sat, 21 Jun 2003 15:31:56 +0100 [EMAIL PROTECTED] (George Pitcher) wrote:

> Jay,
> 
> I've never ventured into 'sessions' (not ones without drinks) but I've a
> feeling that if the user has turned cookies off then sessions are out as
> well as they require a cookie being stored on the user's machine.
> 
> Someone will surely correct me if I am wrong.
> 
> I went to the PHP conference in Frankfurt about 18 months ago and Rasmus was
> talking about 'clean' URLs (ithout the 'query' string. I never did find out
> how though?
> 
> Cheers
> 
> George
> 
> > -----Original Message-----
> > From: Jay Fitzgerald [mailto:[EMAIL PROTECTED]
> > Sent: 21 June 2003 3:19 pm
> > To: George Pitcher; nabil; [EMAIL PROTECTED]
> > Subject: RE: [PHP] Re: Passing Variables
> >
> >
> > That was my thought too, George. But if the user does not have cookies
> > enabled, then I believe, as Thomas pointed out, that a SESSION is
> > the only
> > way to handle the variables. I have never done a "correct"
> > session so I am
> > trying to learn how to do them without having a userid and password for
> > each user. I have played with sessions but I don't know if I am
> > doing them
> > correctly or how to do sessions without authentication.
> >
> > Jay
> >
> >
> >
> > At 03:14 PM 6/21/2003 +0100, George Pitcher wrote:
> > >Nabil,
> > >
> > >That is one way but it means that Jay would have to use a form and not a
> > >link.
> > >
> > >You could set a cookie. That would work, but it relies on the
> > user allowing
> > >cookies.
> > >
> > >George
> > >
> > > > -----Original Message-----
> > > > From: nabil [mailto:[EMAIL PROTECTED]
> > > > Sent: 21 June 2003 2:58 pm
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP] Re: Passing Variables
> > > >
> > > >
> > > > use hidden field (pure html) and then u have it as
> > $yourhiddenfield on the
> > > > next page even u have the register global off..
> > > >
> > > > Nabil
> > > >
> > > >
> > > > "Jay Fitzgerald" <[EMAIL PROTECTED]> wrote in message
> > > > news:[EMAIL PROTECTED]
> > > > > I have been searching for an answer to this for a couple of
> > > > hours now and
> > > > > cant find anything. I believe that there is a secure way of
> > > > doing this but
> > > > > I think my brain is having a momentary lapse...
> > > > >
> > > > > I have these variables:
> > > > >
> > > > > $eventid = "1";
> > > > > $age = "15";
> > > > >
> > > > > Is there a way to pass these variables to the next page so I
> > > > can continue
> > > > > using them without doing something like this:
> > > > >
> > > > > <A HREF="test.php?eventid=1&age=15">
> > > > >
> > > > > I would rather not have the variables be seen or known to the
> > > > end user for
> > > > > security reasons because they could change them in the URL. I
> > > > know it has
> > > > > something to do with $_GET and $_POST because I do have
> > register_globals
> > > > > set to OFF in my php file and I do not want to turn them on....
> > > > >
> > > > > TIA
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > 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
> >
> >
> 



--- End Message ---
--- Begin Message --- Jay Fitzgerald wrote:
I have been searching for an answer to this for a couple of hours now and cant find anything. I believe that there is a secure way of doing this but I think my brain is having a momentary lapse...

I have these variables:

$eventid = "1";
$age = "15";

Is there a way to pass these variables to the next page so I can continue using them without doing something like this:

<A HREF="test.php?eventid=1&age=15">

I would rather not have the variables be seen or known to the end user for security reasons because they could change them in the URL. I know it has something to do with $_GET and $_POST because I do have register_globals set to OFF in my php file and I do not want to turn them on....

If you want to truly keep them away from the "client" then you need to use sessions. Only the session ID is passed in a cookie or URL and your data remains on the server. Using GET, POST, or COOKIE will allow the user to edit this data.


If the user does not allow cookies, then you must pass the SESSION ID in every URL that you want the session to persist.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
On Jun 21, 2003, "George Pitcher" claimed that:

|Jay,
|
|I've never ventured into 'sessions' (not ones without drinks) but I've a
|feeling that if the user has turned cookies off then sessions are out as
|well as they require a cookie being stored on the user's machine.
|
|Someone will surely correct me if I am wrong.
|
|I went to the PHP conference in Frankfurt about 18 months ago and Rasmus was
|talking about 'clean' URLs (ithout the 'query' string. I never did find out
|how though?
|
|Cheers
|
|George
|

http://marc.theaimsgroup.com/?l=php-general&m=105597453308214&w=2

<form name="myform" method="POST" action="validate.php">
<input type="hidden" name="secret1" value="15">
<input type="hidden" name="secret2" value="secret login code">
<a href="javascript:void(document.myform.submit())">next page</a></form>

If you really want to keep the values a secret, you will have to
substitute them with a reverable hash or some other method to keep prying
eyes away.

Jeff

-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



--- End Message ---
--- Begin Message ---
Yeah - just dumb!. I'd put my date vars into mktime in the european order.
Once I switched them it worked fine.

Chers

George

> -----Original Message-----
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: 21 June 2003 2:50 pm
> To: [EMAIL PROTECTED]
> Subject: [PHP] Coercing a date calc - problem - or am I just dumb tryin
> g it this way
>
>
> Hi all,
>
> I've just written this function:
>
> $term='Michaelmas';
> function f_week($w,$t)
> {
>       $P=7*($w-1);
>       if( $t == 'Michaelmas'){
>               $D = 06;
>               $M = 10;
>               $Y = 2003;
>       } else {
>               $D = 12;
>               $M = 01;
>               $Y = 2004;
>       }
>       $week=date("d/m/Y", mktime(0,0,0,$D+$P,$M,$Y));
>       return $week;
> }
> ?>
> Michaelmas week 4 is <? echo f_week(4,$term) ?>
>
> But the date it shows is '10/03/2005 ' rather than '03/10/2003'.
>
> Suggestions please.
>
> George in Oxford
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message --- is this the correct way to register variables via a session?

[code]
session_start ();
$_SESSION['eventid'] = 'arma2';

print_r ($_SESSION);
echo "<P> $_SESSION";
[/code]


[result] Array ( [eventid] => arma2 )

Array
[/result]

I apologize for the numerous questions, but I am trying to learn...If anyone would like to help off-list, my ICQ is 38823829

Jay


--- End Message ---
--- Begin Message ---
yeah its the right way.
though I don't know what you'r trying to do with 
echo "<P> $_SESSION";


Thomas
On Sat, 21 Jun 2003 09:22:39 -0500 [EMAIL PROTECTED] (Jay Fitzgerald) wrote:

> is this the correct way to register variables via a session?
> 
> [code]
> session_start ();
> $_SESSION['eventid'] = 'arma2';
> 
> print_r ($_SESSION);
> echo "<P> $_SESSION";
> [/code]
> 
> 
> [result]
> Array ( [eventid] => arma2 )
> 
> Array
> [/result]
> 
> I apologize for the numerous questions, but I am trying to learn...If 
> anyone would like to help off-list, my ICQ is 38823829
> 
> Jay
> 



--- End Message ---
--- Begin Message ---
I have a custom extension for windows (dll which can be used in PHP).

I want to run some php code inside this dll module. I searched for Zend_API
Docs, but I could not find any way to run php code inside this API.

Any Ideas how to do this,

Please help!

Thanks
Suhas


--- End Message ---
--- Begin Message ---
If there an ability like Perl to determine if a file is a text file (-T) or any other 
type??

Robin E. Kopetzky
Black Mesa Computers/Internet Services
www.blackmesa-isp.net


--- End Message ---
--- Begin Message ---
I have recently created a site that has some PHP in it.  It works fine in
all browsers except AOL.  I can see some of the PHP page in AOL except the
one that fetches information from MySQL database.  I also host my own server
for this site.  Maybe this is a server setting or securtity issue.  Anyone
see this before?

Thanks.



--- End Message ---
--- Begin Message ---
How many times do people have to respond to your same email before you get a 
clue?

http://marc.theaimsgroup.com/?l=php-general&m=105621501902618&w=2
http://marc.theaimsgroup.com/?l=php-general&m=105593686426998&w=2
http://marc.theaimsgroup.com/?l=php-general&m=105556674131637&w=2

PHP is server side.  MySQL is server side.  A client side browser (in this case 
AOL), has no bearing on the output produced by PHP/MySQL.

You have been told to check your HTML output at least twice for 
missing/unsupported tags.
http://webmaster.info.aol.com/compatibility.html

Quoting rml <[EMAIL PROTECTED]>:

> I have recently created a site that has some PHP in it.  It works fine in
> all browsers except AOL.  I can see some of the PHP page in AOL except the
> one that fetches information from MySQL database.  I also host my own server
> for this site.  Maybe this is a server setting or securtity issue.  Anyone
> see this before?
> 
> Thanks.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


=======================================
Michael Geier
CDM Sports, Inc. Systems Administration
   email: [EMAIL PROTECTED]
   phone: 314.692.3540

-----------------------------------------------
 This email sent using CDM Sports Webmail v3.1
              [ http://webmail.cdmsports.com ]

--- End Message ---
--- Begin Message ---
Hi guys.
I want to call this generic echo function within a class, but have
trouble referencing the output function with $this-> .
Any suggestions? Maybe there is a better solution to this?
 
This is within a class:
 
[snip]
# generic WALK functions
            function walkit($array)
            {
                        array_walk($array,"$this->output"); //not
working
            }
            
            function output($item,$key)
            {
                        echo "$key. $item<br />\n";        
            }
 
thomas

--- End Message ---
--- Begin Message ---
On Sat, 21 Jun 2003 19:24:26 +0200, you wrote:

>I want to call this generic echo function within a class, but have
>trouble referencing the output function with $this-> .
>Any suggestions? Maybe there is a better solution to this?
> 
>This is within a class:
> 
>[snip]
># generic WALK functions
>            function walkit($array)
>            {
>                        array_walk($array,"$this->output"); //not
>working
>            }
>            
>            function output($item,$key)
>            {
>                        echo "$key. $item<br />\n";        
>            }

You want to apply a function that's wrapped in a class to a given array?

My first reaction is that your best approach is to invoke a function within
a class, without creating an instance of that class. See the :: operator.

The following code covers several ways of calling functions wrapped in
classes. You probably want the last two calls:

<?

        /* Class A has method B */
        class A {
                function B ($s = "None") {
                        echo ("<p>input : $s</p>");
                }
        }

        /* $C is an instance of A */
        $C = new A ();

        /* $D is an array of strings */
        $D = array('item 1', 'item 2', 'item 3', 'item 4');

        /* invoke A::B */
        A::B ('call 1');

        /* invoke $C->B */
        $C->B ('call 2');

        /* invoke A::B via call_user_func() */
        call_user_func (array('A', 'B'), 'call 3');

        /* invoke $C->B via call_user_func() */
        call_user_func (array($C, 'B'), 'call 4');

        /* invoke A::B via call_user_func_array() */
        call_user_func_array (array('A', 'B'), array('call 5'));

        /* invoke $C->B via call_user_func_array() */
        call_user_func_array (array($C, 'B'), array('call 6'));

        /* apply A::B to $D via array_walk() */
        array_walk ($D, array('A', 'B'));

        /* apply $C->B to $D via array_walk() */
        array_walk ($D, array($C, 'B'));

?>


--- End Message ---
--- Begin Message --- Thomas Hochstetter wrote:

Hi guys.
I want to call this generic echo function within a class, but have
trouble referencing the output function with $this-> .
Any suggestions? Maybe there is a better solution to this?

This is within a class:

[snip]
# generic WALK functions
function walkit($array)
{
array_walk($array,"$this->output"); //not
working
}
function output($item,$key)
{
echo "$key. $item<br />\n"; }


thomas



http://us3.php.net/manual/en/language.pseudo-types.php
"A method of an instantiated object is passed as an array containing an object as the element with index 0 and a method name as the element with index 1."


function walkit($array){
   array_walk($array,array($this,'output'));
}
function output($item,$key){
   echo "$key. $item<br />\n";
}

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.



--- End Message ---
--- Begin Message --- At 9:43 AM +0300 6/21/03, nabil wrote:
4- I want if any user jumped to the other directory and logged in with the
correct requested password TO HAVE THE FIRST SESSION UNREGISTERED
automatically, so he can't be logged in in both at same time.. and keep only
the new.. and ofcourse have to re logging if he jumped back to the first
one...


If the user has the credentials to access both directories, why not let him be logged into both directories, provided he logs into both separately?
You can confine cookie containing session id to the site _and_ directory user logged into so that you have have separate sessions for both:


in your login routine in each directory:

session_set_cookie_params (0, dirname($_SERVER['SCRIPT_NAME']).'/');
session_start();

Now when user logs into different directory, php won't even know about session cookie from other directory. This is my understanding, anyway.

andrew



--- End Message ---
--- Begin Message ---
I have a form which feeds into an e-mail.  When I use the mail function
all 's turn into \'s and all "s turn into \"s.  I tried
set_magic_quotes_runtime(0) and it didn't do anything, neither did
urldecode().  Is there a function to strip escape charechters?

Thanks,

Dan


--- End Message ---
--- Begin Message ---
On Sat, 2003-06-21 at 16:00, Dan Anderson wrote:
> I have a form which feeds into an e-mail.  When I use the mail function
> all 's turn into \'s and all "s turn into \"s.  I tried
> set_magic_quotes_runtime(0) and it didn't do anything, neither did
> urldecode().  Is there a function to strip escape charechters?

I think you want stripslashes().

http://us4.php.net/manual/en/function.stripslashes.php

Brad

--- End Message ---

Reply via email to