php-general Digest 1 Nov 2001 13:28:22 -0000 Issue 969

Topics (messages 73103 through 73150):

Re: Text DB's & bbs lists
        73103 by: Jack Dempsey

paypal instant notification
        73104 by: Sondra Russell
        73110 by: CC Zona

text into web db interface
        73105 by: AAustin
        73120 by: David Robley

Re: sending email to php script
        73106 by: Adrian D'Costa
        73107 by: Jason Murray
        73118 by: David Robley

Dynamic update of content
        73108 by: Martin
        73109 by: Galkov Vladimir

Re: need coments...
        73111 by: Jason G.

Re: show png in the browser
        73112 by: Jason G.

Re: question about variables...
        73113 by: Jason G.

run php in commandline
        73114 by: JIM
        73115 by: JIM
        73119 by: Jason G.

print on printer
        73116 by: Luz Lopez

Re: defending PHP mail function
        73117 by: Jason G.

Secure transfer
        73121 by: Morten Winkler Jørgensen

Week of month
        73122 by: Sheni R. Meledath
        73127 by: Jon Farmer
        73130 by: Andrew Braund
        73136 by: Matt Williams
        73138 by: Jon Farmer

Re: how do I use "<" and "&lt" with eval()?
        73123 by: Stefan Rusterholz

Re: setting member variables out of class
        73124 by: Tim Ward

Comparing strings
        73125 by: phantom
        73131 by: Michael Egan
        73132 by: CC Zona
        73135 by: phantom

regular expression
        73126 by: Galkov Vladimir
        73142 by: liljim
        73144 by: liljim
        73145 by: liljim
        73146 by: Christian Reiniger

Can you AUTO "Post/Submit" on a mixed HTML/PHP form
        73128 by: Arf
        73134 by: CC Zona
        73139 by: Arf

fto_connect() failed??
        73129 by: JIM

destroying sessions
        73133 by: Richard Baskett

Best PHP package for this kind of www site?
        73137 by: web_fm

Yes you can........ but....
        73140 by: Galkov Vladimir
        73141 by: Arf

Problem with date_format() in indirect MySQL query...
        73143 by: Ryan Fischer

Re: Detecting Languages...
        73147 by: Tommy Gildseth
        73148 by: Tommy Gildseth

Problem writing to file, can't find the error
        73149 by: Jeff Lewis

Uncertainties about MySQL commands
        73150 by: TD - Sales International Holland B.V.

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]


----------------------------------------------------------------------


Hi Arsen,

I think that'd be a lot of work, and I'm not sure I understand why you can't
use MySQL?
I suppose you could do it, but i think you'll find once starting it, that
its not worth the time it'll need...

Jack

-----Original Message-----
From: ArsenKirillov [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 31, 2001 7:41 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Text DB's & bbs lists


does anybody hear about
board(bbs or phorum) written oin php wihout using any kind
of SQL DB ? I think of developing one in text db (separated by | fields in
one line)
Did anybody think of this is good idea ? (i have problem in my country -
stupid admins can't run MySQL to be such stable as php4.)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]






Hi guys!

I'm going to use paypal with my site, and they have a cool "instant 
notification" feature which sends, to a page I preassign, information 
about a transaction as it happens.  My script is supposed to:
a) receive this information (as a "post")
b) send it back to them with a sort of "is this really coming from 
you?" message
c) get a confirmation from them, "yes, this came from us"
d) take the post and insert it into my database or whatever else I'd 
like to do with it.

They have provided a perl sample script (see below).

Mostly I'm just trying to figure out how to replicate the whole 
"receiving", "sending", and "receiving again" thing in PHP.  This is 
especially tricky since I apparently can't test my work without 
actually going through a transaction on paypal (and spending money). 
I sorta have to get it right the first time.

Anyone done this before?

Thanks again!
Sondra

sample perl script:

   # read the post from PayPal system and add 'cmd'
   read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
   $query .= '&cmd=_notify-validate';

   # post back to PayPal system to validate
   use LWP::UserAgent;
   $ua = new LWP::UserAgent;
   $req = new HTTP::Request 'POST','https://www.paypal.com/cgi-bin/webscr';
   $req->content_type('application/x-www-form-urlencoded');
   $req->content($query);
   $res = $ua->request($req);

   # split posted variables into pairs
   @pairs = split(/&/, $query);
   $count = 0;
   foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $variable{$name} = $value;
   $count++;
   }

   # assign posted variables to local variables
   $receiver_email = $variable{'receiver_email'};
   $item_name = $variable{'item_name'};
   $item_number = $variable{'item_number'};
   $custom = $variable{'custom'};
   $payment_status = $variable{'payment_status'};
   $payment_date = $variable{'payment_date'};
   $payment_gross = $variable{'payment_gross'};
   $payment_fee = $variable{'payment_fee'};
   $txn_id = $variable{'txn_id'};
   $first_name = $variable{'first_name'};
   $last_name = $variable{'last_name'};
   $address_street = $variable{'address_street'};
   $address_city = $variable{'address_city'};
   $address_state = $variable{'address_state'};
   $address_zip = $variable{'address_zip'};
   $address_country = $variable{'address_country'};
   $payer_email = $variable{'payer_email'};
   if ($res->content eq 'VERIFIED') {
   # check transaction for uniqueness
   # process payment
   }
   elsif ($res->content eq 'INVALID') {
   # possible fraud
   }
   else {
   # error
   }







In article <p05100300b80663ce154a@[212.43.204.76]>,
 [EMAIL PROTECTED] (Sondra Russell) wrote:

> They have provided a perl sample script (see below).
> 
> Mostly I'm just trying to figure out how to replicate the whole 
> "receiving", "sending", and "receiving again" thing in PHP. 

<snip sample script>

Most of that script can be replicated with fread() 
<http://php.net/fread>,fwrite() <http://php.net/fwrite>, a couple of PCRE 
functions <http//php.net/pcre>, and extract() <http://php.net/extract>.  In 
essence, fread() is what does the "receiving" and fwrite() does the 
"sending".

Alternatively, you may want to check script archives like hotscripts.com.  
I'd be surprised if no one's posted a Paypal class yet.

-- 
CC




Hi

Is there a php technique, app, code example..., where users can enter normal
formatted text with paragraphs etc and the '<br>' or '<p> ' tags (and even
'table') are entered so the text looks ok on an php page. This will then
mean the end user does not need to know a smattering of html code just to
enter some text into db.

thanks
andrew






On Thu,  1 Nov 2001 14:51, AAustin wrote:
> Hi
>
> Is there a php technique, app, code example..., where users can enter
> normal formatted text with paragraphs etc and the '<br>' or '<p> ' tags
> (and even 'table') are entered so the text looks ok on an php page.
> This will then mean the end user does not need to know a smattering of
> html code just to enter some text into db.
>
> thanks
> andrew

There is the nl2br() function which will convert end of line characters 
to a <BR>.

For tables, you might have to build something based on say tabs as cell 
separators, EOL as row separators, but you would also need some 
indication of where table starts and ends.

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   Check book: a book with a unhappy ending.




On Mon, 29 Oct 2001, David Robley wrote:

> On Sat, 27 Oct 2001 03:23, JSheble wrote:
> > A while ago an email came through here about how to parse out email
> > message from a php script.  The thing that was mostly of interest to me
> > is the ability to send an email to a php script, I guess through a
> > sendmail alias?  I asked how to accomplish this, and never saw an
> > answer come through.  So I'd like to ask again :o)
> >
> > Does anybody know what would be required or necessary to send an email
> > to an address that would run a php script?
> 
> You say sendmail, so do it thusly:
> 
> Edit /etc/aliases and add a line like
> 
> phpmail: "| /pathto/your/php/script"
> 
> and run newaliases to update your alias database.

Actually, I am still trying to figure this out when I get time.  What I
did was:
 
phpmail: "| lynx -dump > /pathto/your/php/script"

But the problem is nothing appears to be capture in the script.  Or rather
in what format does this mail arrive.  I even tried to write it to a file
but nothing is written.

> 
> You'll also need to compile php as a standalone, and put as the first 
> line of your php script
> 
> #!/path/to/php -q

What if we need both version??


Adrian





> > You'll also need to compile php as a standalone, and put as 
> > the first line of your php script
> > 
> > #!/path/to/php -q
> 
> What if we need both version??

There's nothing stopping you running both.

J




On Wed, 31 Oct 2001 22:04, Adrian D'Costa wrote:
> On Mon, 29 Oct 2001, David Robley wrote:
> > On Sat, 27 Oct 2001 03:23, JSheble wrote:
> > > A while ago an email came through here about how to parse out email
> > > message from a php script.  The thing that was mostly of interest
> > > to me is the ability to send an email to a php script, I guess
> > > through a sendmail alias?  I asked how to accomplish this, and
> > > never saw an answer come through.  So I'd like to ask again :o)
> > >
> > > Does anybody know what would be required or necessary to send an
> > > email to an address that would run a php script?
> >
> > You say sendmail, so do it thusly:
> >
> > Edit /etc/aliases and add a line like
> >
> > phpmail: "| /pathto/your/php/script"
> >
> > and run newaliases to update your alias database.
>
> Actually, I am still trying to figure this out when I get time.  What I
> did was:
>
> phpmail: "| lynx -dump > /pathto/your/php/script"
>
> But the problem is nothing appears to be capture in the script.  Or
> rather in what format does this mail arrive.  I even tried to write it
> to a file but nothing is written.

The pipe feeds the incoming data to the script as standard input - $DEITY 
knows what lynx would do with that, but black holes seem to be the most 
likely destination. Your script needs to be an executable, standalone 
which reads and parses data from stdin and which is the direct recipient 
of info from the pipe.

> > You'll also need to compile php as a standalone, and put as the first
> > line of your php script
> >
> > #!/path/to/php -q
>
> What if we need both version??

As my colleague on the eastern seaboard has noted already, you can have a 
module and a standalone on the same system.

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   Catscan: searching for kitty.




Some time ago I asked for help regarding techniques to provide dynamic 
update of content on a PHP-page.
Someone mentioned a javascript routine which I've forgotten. Anyone here 
might have a clue? What I want to do is that 
User selects and option from a option box, and depending on what that 
selection is the page populates other option boxes.

TIA,

Martin S




Good day!

Well... you can recive access to any tag on HTML page form java-script with
code like this:
<h1 id='Razdel'> here will be text from selected option </h1>
<br>
<select id=selector onchange='some_event()'>
 .............
</select>
........

function some_event()
 {
     objH1  = document.all["razdel"];
     objSelector = document.all["selector"];

     objH1.innerText = objSelector.value;
 }
.........

innerText is a content betvin <h1> </h1>

Well... don't test that code... so cach only idea... but if you need more
coments mail me I'll send working example.
Have a nice day!
-------------------
Galkov Vladimir
[EMAIL PROTECTED]






Second comment is that we are not a review board for specific products.


At 10:40 PM 10/30/2001 +0300, you wrote:
>Good day!
>
>I try to wrote Web-interface for DNS. Only simple test version now. I'd like
>to listen your comets to make real good and useful thing. mail me you
>coments
>please
>
>Galkov Vladimir
>ICQ 84873967
>
>
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





Ever consider reading the online manual?


First, say header("Content-type: image/png");
Second, create image.
third use ImagePNG() function
fourth, destroy image.
fifth, go directly to the php script that generates the image, then you 
will see PHP generated errors.

-Jason Garber
IonZoft.com

At 12:38 AM 10/31/2001 +0000, Luz Lopez wrote:
>Hi All
>
>I configured the php with thelibrary GD, zlib, jpeg and libpng, I hae a 
>program that generate a image, I can to save this png image but in my 
>borwser I can't to see this image, the browser send me to save to my hard 
>disk this image.
>
>I need to show this image in the browser, How can I do it?
>
>Thanks in Advanced,
>
>Regards,
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>





READ THE MANUAL.

variable variables

$i=1;
$sName = "seat$i";
$value = $$sName;


At 04:40 PM 10/31/2001 +1100, sc wrote:
>Hey all;
>
>If i have a variable say, $seat and i want to go through variables with a
>number, ie. $seat1 , $seat2 etc. how would i go about it? i have one setup
>where $p increments (so then you have $seat$p) but i cant get it to work
>properly (tried all sorts of combinations with ' and " and . etc.)...and
>cant seem to find any info on it (dont really know what to search for)..
>
>Anyone know how one can go about it?
>
>thx.
>
>-sc
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





hi all,
i want to know how i can feed a parameter into a php script in commandline?
eg.
php getdata.php apple orange

so, i want to get use of "apple" and "orange"...
any help pls!

jim







hi all,
i want to know how i can feed a parameter into a php script in commandline?
eg.
php getdata.php apple orange

so, i want to get use of "apple" and "orange"...
any help pls!

jim








I just did that tonight.

Lookup the predefined variables in the manual.

$argc gives a count of the arguments
$argv is an array of the arguments

Ex:
php -q myscript.php Apple Orange

$argc == 3
$argv[0] == 'php -q myscript.php' or something like that
$argv[1] == 'Apple'
$argv[2] == 'Orange'

-Jason Garber
IonZoft.com

At 03:12 AM 11/1/2001 +0800, JIM wrote:
>hi all,
>i want to know how i can feed a parameter into a php script in commandline?
>eg.
>php getdata.php apple orange
>
>so, i want to get use of "apple" and "orange"...
>any help pls!
>
>jim
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





Hi All

I have a php that access to database and show the values in the browser, But 
I need add hte option of print on printer, but that only print the table 
with values.

Somebody can help me?

Thanks in Advanced,

Regards,



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





I've just been watching the posts regarding this issue.

I can see the following:

You SHOULD test it on *nix JUST to narrow down the problem.
You ask for help from all the *VERY NICE* people on this list, and then 
WILL not do what they say will help???
If you do not like the php smtp implementation, then read RFC821 and 
implement a better one.

Regards,

-Jason Garber
IonZoft.com





At 12:08 PM 10/31/2001 -0500, Matthew Luchak wrote:

>OK.  here's why I think it's in PHP's SMTP support:
>
>There is an address that fails in 4.06 yet functions in 4.04 - exactly
>the same code, same SMTP server, same .ini,  everything the same.
>
>I wouldn't question the class if I hadn't tested my own code and
>settings first.  I've been trying to track this down for the past two
>weeks and have already been advised by someone on this list that PHP's
>SMTP support is not the greatest:
>
> >SMTP code in PHP is not good enough. It needs to be rewritten.
><snip>
> >Yasuo Ohgaki
>
>
>It doesn't do much good to test on a nix box because what I'm looking
>for is a solution to a PHP/SMTP problem.
>
>
>____________________________
>Matthew Luchak
>Webmaster
>Kaydara Inc.
>[EMAIL PROTECTED]
>
>
>-----Original Message-----
>From: Kurt Lieber [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, October 31, 2001 11:57 AM
>To: PHP General List
>Subject: Re: [PHP] defending PHP mail function
>
>
>On Wednesday 31 October 2001 08:40 am, you wrote:
>
> > for now it's PHP that's in question
>
>AFAIK, this is the first I've ever heard of probelms with mail() not
>sending
>to perfectly valid email addresses.  Scalability issues and other
>performance
>problems, sure, but that's a different animal.
>
>Given the number of people that use PHP (and use mail(), especially) I
>would
>certainly think this problem would have been reported before if it were
>a
>real bug.
>
>So, to be blunt, you probably have a problem with your code, your SMTP
>server, the way you've configured PHP, or something other than mail().
>It's
>easy to blame it on mail() and/or PHP, but I think you're barking up the
>
>wrong tree.
>
>Find a forgiving customer who reported the problem, ask for their help
>in
>troubleshooting it and then send some test emails from a completely
>different
>server, preferably on a *nix platform.  (not because *nix is better than
>
>windows, but because *nix PHP doesn't use smtp for mail delivery)
>
>--kurt
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]





Hi php'ers

   I'm about to build a site that allows payment with credit card.
   Of cause the card number, expiration date etc. should be secured
   when transfered. How do I do that?
   I've been looking at the OpenSSL functions in php, but they seem to
   be unsatisfying.

Kind regards,
    Morten Winkler






Hello:

Is there any way to find out the week of the month. Today is in the first 
week of month.

That is, a function like weekofmonth() which displays 1 today & 2 next week.

thanks

Sheni R Meledath
[EMAIL PROTECTED]





> Is there any way to find out the week of the month. Today is in the first
> week of month.
>
> That is, a function like weekofmonth() which displays 1 today & 2 next
week.

No builtin function in PHP. You will need to search to see if some kind and
generous soul has published their code for this purpose or write your own.
Remember the actual first day of a week can be country specific.

Regards

Jon


--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send blank email to [EMAIL PROTECTED]






How about;
echo "It is week ".((int)(date("j")/7)+1)." of the month.<br>";

> -----Original Message-----
> From: Jon Farmer [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 1 November 2001 20:14
> To: PHP Masters; Sheni R. Meledath
> Subject: Re: [PHP] Week of month
> 
> 
> > Is there any way to find out the week of the month. Today is in the first
> > week of month.
> >
> > That is, a function like weekofmonth() which displays 1 today & 2 next
> week.
> 
> No builtin function in PHP. You will need to search to see if some kind and
> generous soul has published their code for this purpose or write your own.
> Remember the actual first day of a week can be country specific.
> 
> Regards
> 
> Jon
> 
> 
> --
> Jon Farmer
> Systems Programmer, Entanet www.enta.net
> Tel 01952 428969 Mob 07763 620378
> PGP Key available, send blank email to [EMAIL PROTECTED]





Please find attached a very good date class.

I can't remeber where I got it from and who wrote it but it's pretty good.

M:

> --
> > Is there any way to find out the week of the month. Today is in
> the first
> > week of month.
> >
> > That is, a function like weekofmonth() which displays 1 today & 2 next
> week.
>
> No builtin function in PHP. You will need to search to see if
> some kind and
> generous soul has published their code for this purpose or write your own.
> Remember the actual first day of a week can be country specific.
>
>

Date_Calc-1.2.4.tar.gz





Well seeing as Monday of this week was the 29th of October is this week the
first of November or the last of October? I think the United Nations set out
a specification for determining the week number of the year but not sure if
they have a spec for the week of the month.

Regards

Jon

--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send blank email to [EMAIL PROTECTED]


----- Original Message -----
From: "Andrew Braund" <[EMAIL PROTECTED]>
To: "PHP Masters" <[EMAIL PROTECTED]>
Sent: Thursday, November 01, 2001 9:57 AM
Subject: RE: [PHP] Week of month


> How about;
> echo "It is week ".((int)(date("j")/7)+1)." of the month.<br>";
>
> > -----Original Message-----
> > From: Jon Farmer [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, 1 November 2001 20:14
> > To: PHP Masters; Sheni R. Meledath
> > Subject: Re: [PHP] Week of month
> >
> >
> > > Is there any way to find out the week of the month. Today is in the
first
> > > week of month.
> > >
> > > That is, a function like weekofmonth() which displays 1 today & 2 next
> > week.
> >
> > No builtin function in PHP. You will need to search to see if some kind
and
> > generous soul has published their code for this purpose or write your
own.
> > Remember the actual first day of a week can be country specific.
> >
> > Regards
> >
> > Jon
> >
> >
> > --
> > Jon Farmer
> > Systems Programmer, Entanet www.enta.net
> > Tel 01952 428969 Mob 07763 620378
> > PGP Key available, send blank email to [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>





----- Original Message -----
From: "John A. Grant" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 31, 2001 11:51 PM
Subject: [PHP] how do I use "<" and "&lt" with eval()?


> I'm not having an easy time understanding the discussion
> in the doc for eval().
>
> I want to read this string from a file:
>     xxx <?php somefunc("yyy",3); ?> zzz
>
> and then "run" it.
>
> I tried this code:
>     <?php
>      function somefunc($text,$n)
>      {
>         for($i=0;$i<$n;$i++){
>             echo $text;
>         }
>     }
>     $string='xxx <?php somefunc("yyy",3); ?> zzz';
>     eval($string);
>     ?>
>
> but I get
> "Parse error:  parse error in eval.php(11) : eval()'d code on line 1
>
> Do I have to use &lt; and &gt; in place of "<" & ">"? I tried
> several combinations, but I still get the same error.
>
> --
> John A. Grant  * I speak only for myself *  (remove 'z' to reply)
> Radiation Geophysics, Geological Survey of Canada, Ottawa
> If you followup, please do NOT e-mail me a copy: I will read it here
>

If you do that this way it looks for php like this:

<?php
     function somefunc($text,$n)
      {
         for($i=0;$i<$n;$i++){
             echo $text;
         }
     }
     #$string='xxx <?php somefunc("yyy",3); ?> zzz';
     #eval($string);
    xxx <?php somfunc("yyy",3); ?> zzz
 ?>

(as someone before correctly stated)

As you see, for PHP is some HTML-Code in the php-code-zone. To avoid this,
do it that way:
<?php
     function somefunc($text,$n)
      {
         for($i=0;$i<$n;$i++){
             echo $text;
         }
     }
     $string='xxx <?php somefunc("yyy",3); ?> zzz';
     eval("?>$string");
 ?>

Pay attention to the trailing "?>" in eval. That causes php to change to
HTML-Mode within the eval'd code.

Hope, I could help you

Stefan Rusterholz, [EMAIL PROTECTED]
----------------------------------
interaktion gmbh
Stefan Rusterholz
Zürichbergstrasse 17
8032 Zürich
----------------------------------
T. +41 1 253 19 55
F. +41 1 253 19 56
W3 www.interaktion.ch
----------------------------------





1.      $telefono is an array (as has already been pointed out) so you need
to reference an element
2.      you're never actually setting the property in the constructor, your
constructor lines should be:
        $this->telefono = array("Teléfono","Phone");
        etc.

        Tim

        ----------
        From:  Silvia Mahiques [SMTP:[EMAIL PROTECTED]]
        Sent:  31 October 2001 14:38
        To:  [EMAIL PROTECTED]
        Cc:  [EMAIL PROTECTED]
        Subject:  setting member variables out of class

        Hello,
        I want to set member variables out of their class. The code class
is:

        <?php

        class translator {
         
         var $nombre; 
         var $departamento;
         var $despacho;
         var $telefono;
         var $correo_electronico;
         var $pagina_personal;

         function translator(){ 
          $nombre = array("Nombre","Name");  
          $departamento = array("Departamento","Department");  
          $despacho = array("Despacho","Office");  
          $telefono = array("Teléfono","Phone");
          $correo_electronico = array("Correo Electrónico","E-mail");
          $pagina_personal = array("Página Personal","Personal HomePage");
         }
        }
        ?>


        I access to this class from another php file and want to set this
member variable:

        $c = new translator();
        echo $c->telefono;       /* this member isn't set but in constructor
method has been set*/


        I have written too:

        echo $c->$telefon;
        echo "{$c->telefon}";

        but is not correct.


        Can anybody help me?

        Thanks


        Silvia Mahiques
        




Bear with me, new to PHP and got a beginner's questions

How do I run an if statement and the if statement compares a String?

IN ASP (yes I Know, ASP is evil) I would have wrote

if (String(Request("Action"))=="Submit")
      do this

In PHP I have tried

if ($Action == "Submit")  but I get a parse error in that statement.
What am I doing wrong?  Thank you.  I did an echo $Action to confirm
that it's value is Submit.





I feel fairly new to this as well but I think that, whilst your logic is
right, the syntax may be a little off.

if ($action == "textstring)
{
 echo "true";
}
else
{
 echo "false";
}

Above should show how the syntax will rok.

Good luck

Michael

phantom wrote:
> 
> Bear with me, new to PHP and got a beginner's questions
> 
> How do I run an if statement and the if statement compares a String?
> 
> IN ASP (yes I Know, ASP is evil) I would have wrote
> 
> if (String(Request("Action"))=="Submit")
>       do this
> 
> In PHP I have tried
> 
> if ($Action == "Submit")  but I get a parse error in that statement.
> What am I doing wrong?  Thank you.  I did an echo $Action to confirm
> that it's value is Submit.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]




In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Phantom) wrote:

> In PHP I have tried
> 
> if ($Action == "Submit")  but I get a parse error in that statement.
> What am I doing wrong?  Thank you.  I did an echo $Action to confirm
> that it's value is Submit.

If the variable is set as you've confirmed, then that should work. If PHP 
is reporting a parse error with that line number, note that the lines where 
PHP stopped parsing isn't necessarily the line where the bad code resides.  
Try checking back a few lines; you may have left off a semi-colon or 
somesuch.  Another idea: check that the variable's length is the expected 5 
chars; maybe there's some trailing whitespace that's causing the comparison 
to fail (trim() is handy for avoiding this gotcha).  If neither of those 
solve the problem, try re-posting with a larger code snippet.

-- 
CC




Must have been a missing semi-colon it works now.  Thanks.

<%
echo $Action;
if ($Action == "Submit")
   { echo " Process form"; }
else
   { echo " Do Nothing"; }
%>

<html>
<form method="Post" action="self.php">
<input type="text" name="Var1" maxlength="20">
<input type="submit" name="Action" value="Submit">
</form>
</html>


Cc Zona wrote:

> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Phantom) wrote:
>
> > In PHP I have tried
> >
> > if ($Action == "Submit")  but I get a parse error in that statement.
> > What am I doing wrong?  Thank you.  I did an echo $Action to confirm
> > that it's value is Submit.
>
> If the variable is set as you've confirmed, then that should work. If PHP
> is reporting a parse error with that line number, note that the lines where
> PHP stopped parsing isn't necessarily the line where the bad code resides.
> Try checking back a few lines; you may have left off a semi-colon or
> somesuch.  Another idea: check that the variable's length is the expected 5
> chars; maybe there's some trailing whitespace that's causing the comparison
> to fail (trim() is handy for avoiding this gotcha).  If neither of those
> solve the problem, try re-posting with a larger code snippet.
>
> --
> CC





 Need to remove all "../"   "/.."  from user inputing string to prevent him
walking and creating files&directories where I don't whant see them/him...

The string:

 $path =
eregi_replace('([..]{2,})|([./]{2})|([../]{3,})|([/.]{2})|([/..]{3})', '',
$path);

works good with any  combinations ( ../../..qwert.txt  =>  qwert.txt) untill
somth like "/../asd/../qwert.txt" will be entered ...  (/../asd/../qwert.txt
=> asdqwert.txt).
 So the qwestion is how upgrade regular expression to remove all this
correctly (with all entered directory names but NOT assigned their names to
file name...

 Must do the operation:
 /../asd/......../qwert.txt  => qwert.txt
but  not  => /asd/qwert.txt or asdqwert.txt.ru
or
/................../asd/../qwert.txt.ru  => qwert.txt.ru
but  not  => /asd/qwert.txt.ru or asdqwert.txt.ru

Thanks.







Hello,

"Galkov Vladimir" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Need to remove all "../"   "/.."  from user inputing string to prevent him
> walking and creating files&directories where I don't whant see them/him...
>
> The string:
>
>  $path =
> eregi_replace('([..]{2,})|([./]{2})|([../]{3,})|([/.]{2})|([/..]{3})', '',
> $path);
>
> works good with any  combinations ( ../../..qwert.txt  =>  qwert.txt)
untill
> somth like "/../asd/../qwert.txt" will be entered ...
(/../asd/../qwert.txt
> => asdqwert.txt).
>  So the qwestion is how upgrade regular expression to remove all this
> correctly (with all entered directory names but NOT assigned their names
to
> file name...
>
>  Must do the operation:
>  /../asd/......../qwert.txt  => qwert.txt
> but  not  => /asd/qwert.txt or asdqwert.txt.ru
> or
> /................../asd/../qwert.txt.ru  => qwert.txt.ru
> but  not  => /asd/qwert.txt.ru or asdqwert.txt.ru
>

Try this:

<?

$string = "/../asd/......../qwert.txt";

$string = preg_replace("/(\.*\/\.?)+.*?(\.*\/)?/s", "", $string);

echo $string;

?>

May need some tweaking, let me know.

~James






Whooops,

Pasted wrong line.  This should do it:

$string = preg_replace("/(\.*\/)+(.*?\.*\/)?/s", "", $string);

James






> Whooops,
>
> Pasted wrong line.  This should do it:
>
> $string = preg_replace("/(\.*\/)+(.*?\.*\/)?/s", "", $string);

Gah... Not.. enough... caffeine: Modification:

$string = preg_replace("/(\.*\/)+(.*?\.*\/)?(\.*)?/s", "", $string);






On Thursday 01 November 2001 10:39, Galkov Vladimir wrote:
>  Need to remove all "../"   "/.."  from user inputing string to prevent
> him walking and creating files&directories where I don't whant see
> them/him...
>
> The string:
>
>  $path =
> eregi_replace('([..]{2,})|([./]{2})|([../]{3,})|([/.]{2})|([/..]{3})',
> '', $path);
>
> works good with any  combinations ( ../../..qwert.txt  =>  qwert.txt)
> untill somth like "/../asd/../qwert.txt" will be entered ... 
> (/../asd/../qwert.txt => asdqwert.txt).
>  So the qwestion is how upgrade regular expression to remove all this
> correctly (with all entered directory names but NOT assigned their
> names to file name...

Here's what I use (take out the parts useful to you):

function FixSrcURI ($SrcURI)
{
        // remove script name
        $SrcURI = preg_replace ('#^/*{{$ Page.Source }}/*#', '', $SrcURI);

        // remove potentially harmful parts
        $SrcURI = preg_replace ('#/?\.\./?#', '/', $SrcURI);
        $SrcURI = preg_replace ('#/\./#', '/', $SrcURI);
        $SrcURI = preg_replace ('#/\.$#', '/', $SrcURI);
        $SrcURI = preg_replace ('#/{2,}#', '/', $SrcURI);
        $SrcURI = preg_replace ('#^/#', '', $SrcURI);

        if (preg_match ('#(\A|/)\.#', $SrcURI) ||
            preg_match ('#CVS#', $SrcURI))
        {
                pbHTTP_404 ();
        }

        if ($SrcURI == '') {
                return array ($SrcURI, -1, 'src');
        }
        else {
                $matches = array ();

                if (preg_match ('#^[^/]+$#', $SrcURI))
                {
                        return array ($SrcURI, '', $SrcURI);
                }
                elseif (preg_match ('#^(.*)/([^/]*)$#', $SrcURI, $matches))
                {
                        return array ($SrcURI, $matches [1], $matches [2]);
                }
                else
                {
                        pbHTTP_404 ();
                        return false;
                }
        }
}

-- 
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)

/* you are not expected to understand this */

- from the UNIX V6 kernel source




I have a little problem that I just can't get to work.

I want to send a URL line from VB6 in an application that I have written to
populate a
three field form on one of my www sites
(http://arthurbard.com/testarea/AutoPost.php) AND post it i.e. populate the
three fields and then simulate clicking on the submit button. I can send a
URL line from VB6 or directly from a browser line and fully populate the
form but do you think I can get it to post without clicking the button....
can I heck!!!!

I can call the form and populate the fields with the following line as the
URL...

http://arthurbard.com/testarea/AutoPost.php/?sender_name=Arthur&sender_email
=me@work&message=Hello.


This is the server side code......


############################################################
<HTML>
<HEAD>
<TITLE>Courier Delivery Feedback Form</TITLE>
</HEAD>
<BODY>

<?

$form_block = "

<FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">

<P><strong>User Name:</strong><br>
<INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\"
SIZE=30></p>

<P><strong>Your E-Mail Address:</strong><br>
<INPUT type=\"text\" NAME=\"sender_email\"  VALUE=\"$sender_email\"
SIZE=30></p>

<P><strong>Message/Problem:</strong><br>
<TEXTAREA NAME=\"message\" COLS=30 ROWS=5
WRAP=virtual>$message</TEXTAREA></p>

<INPUT type=\"hidden\" name=\"op\" value=\"ds\">

<P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></p>

</FORM>

";

if ($op != "ds") {

 // they need to see the form
 echo "$form_block";

} else if ($op == "ds") {

 if ($sender_name == "") {
  $name_err = "<font color=red>Please enter user name!</font><br>";
  $send = "no";
 }

 if ($sender_email == "") {
  $email_err = "<font color=red>Please enter your e-mail
address!</font><br>";
  $send = "no";
 }

 if ($message == "") {
  $message_err = "<font color=red>Please enter a message!</font><br>";
  $send = "no";
 }

 if ($send != "no") {

  // it's ok to send!
  $msg = "AutoPost Report\n";
  $msg .= "Sender's Name:    $sender_name\n";
  $msg .= "Sender's E-Mail:  $sender_email\n";
  $msg .= "Message:          $message\n\n";

  $to = WhoItsTo@TheirISP;
  $subject = "AutoPost Response";
  $mailheaders = "From: CourierDelivery@MyISP\n\n";
  $mailheaders .= "Reply-To: $sender_email\n\n";

  mail($to, $subject, $msg, $mailheaders);
  echo "<P>Mail has been sent!</p>";

 } else if ($send == "no") {

  echo "$name_err";
  echo "$email_err";
  echo "$message_err";
  echo "$form_block";

 }

}

?>

</BODY>
</HTML>
</font></font>
########################################################################

What do I need to change in the following line to make the form submit/post
or do I need to change the code in my form.  I can't use the JavaScript
onLoad() event handler as I will be calling from VB6.

http://arthurbard.com/testarea/AutoPost.php/?sender_name=Arthur&sender_email
=me@work&message=Hello.

I have tried other Newsgroups without success so thought that its about time
to try the experts.






In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Arf) wrote:

> $form_block = "
> 
> <FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">
> 
> <P><strong>User Name:</strong><br>
> <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\"
> SIZE=30></p>
> 
> <P><strong>Your E-Mail Address:</strong><br>
> <INPUT type=\"text\" NAME=\"sender_email\"  VALUE=\"$sender_email\"
> SIZE=30></p>
> 
> <P><strong>Message/Problem:</strong><br>
> <TEXTAREA NAME=\"message\" COLS=30 ROWS=5
> WRAP=virtual>$message</TEXTAREA></p>
> 
> <INPUT type=\"hidden\" name=\"op\" value=\"ds\">
> 
> <P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></p>
> 
> </FORM>
> 
> ";

FWIW, you can save yourself all that PITA backslashing by using heredoc 
syntax<http://www.php.net/manual/language.types.string.php>.

> What do I need to change in the following line to make the form submit/post
> or do I need to change the code in my form.  I can't use the JavaScript
> onLoad() event handler as I will be calling from VB6.

I'm not a VB person, but it's my understanding that VBscript can be invoked 
with an HTML <script> tag the same way JavaScript can.  Just assign 
language="VBscript" instead of language="JavaScript".  Does that help you 
at all?

-- 
CC




Like the "heredoc" thanx for that...

The way that I am using VB will not support the VBscript option
unfortunately but a good suggestion.






hi all,
i was developing in redhat 7.2. with php/4.0.4pl1. iwas able to use
ftp_connect().
but, in a freebsd with php/4.0.6, it returns error that "call to undefined
function"...
anyone can help?
thanks.
im








Ok why does this not work?

session_name(adminid);
session_start();
unset($sess);
session_unset();
session_destroy();
session_write_close();
$sess = 0;

etc etc etc etc etc etc..

After all that is executed I take a look at the session file and what do I
see?  All the session variables still there... and the file still there
also!  How can I get rid of them?  Please how can I do it?  I am sitting in
a corner letting tear after tear drop down into my sodden lap, people are
looking at me crazy... but Im not crazy... am I?

Rick





Hello,

I would like suggestions about the best PHP solution, and possibly
some code examples, to set up a web site which:
     allows to its managers to add articles through the web
     supports threaded discussions on such articles
     includes User forum on any topic
     has internal (always PHP of course) search engine on all its
         content
     Runs with no or minimum modification on both Linux/Apache and
     W2K/IIS, as it would be tested on the first and hosted (not my
     decision) on the second

I know about PHPNuke and Midgard, but would like to know your opinion
about which is the most turn-key solution w.rt. the specific points
above. Of course, other packages are welcome too

Again, code examples, or pointers to them are veryy welcome.

       TIA,

                web_fm
-- 
Nature is very un-American.  Nature never hurries.
                                                -- William George Jordan




Yes you can...
 If....if I rightly understand you only.... well... you whant submit
information without clicking submit button? .. well then you have to imagine
any suported event or use meta tag...... One problrm I don't use VB
script....

Way one... ( this is example of 100% stupid code ... only to show the
gate;-) ... will be usefull only if you find the way to abort/allow submit
in you <script> )

<form id=wwww action=test.php onsubmit='chek()'>   // <<< any supported
event
 <input type=text>
 <input type=submit>
</form>
<script>
 function chek()
  {
  document.forms('wwww').submit();
  }
</script>

-------------------------------
Way two... use meta tag.... (somth like game... or grenade ;-) .... I'm not
worry you are not qwik enoth to fill all fields :-) )
<?
$timer = 10; // seconds
$url_str =
"http://arthurbard.com/testarea/AutoPost.php/?sender_name=Arthur&sender_emai
l=me@work&message=Hello."; // well.. what you wrote
?>
<META HTTP-EQUIV="Refresh" Content="<? print $timer?>; URL=<? print $url_str
?>">






Ummm... Like that where's me PHP editor..... will let you know how it goes
after I have had breakfast.

Thanks






Hello!  :)

First off, please respond to me directly as I am not subscribed to the
list.  Thanks!  :)

Now then, I have a quick question I'm hoping someone can help me with.

I have this class method:

 function query($sql, $type = 'obj')
 {

  if(!$result = @mysql_query($this->masl($sql))){
   echo "Problem with query: <b><tt>$sql</tt></b>.  " . mysql_error();
   exit;
  }

  $objary = array();
  if(@mysql_num_rows($result) > 0){
   if($type == 'obj'){
    while($object = @mysql_fetch_object($result)){ $objary[] =
$object; }
    @mysql_free_result($result);
   }elseif($type == 'assoc'){
    while($object = @mysql_fetch_assoc($result)){ $objary[] = $object; }
    @mysql_free_result($result);
   }else{
    echo "Problem with type of query requested.";
    exit;
   }
   return $objary;
  }else{
   return null;
  }
 }

And this something like this query:

$res = $this->query("select *, date_format(thedate, 'M d, Y') as dt,
date_format(thedate, 'l:i p') as tm from thetable where foo = '$bar'");

Every other query I've executed in this fashion, I've been successful in
retrieving the results.  But, when I try doing something with the
date_format function, when I try to print out the formatted date and
time returned, I get the formats instead.

Does anyone have any idea why, and any idea what I can do to rectify
this?  TIA!  :)

--
 -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/






"Arcadius A." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> HEllo !
> I have a website designed in several languages (En , Fr , Cz) ....
> My question is :
> How to detect the language setting of the the visitor's PC  in order to
> redirect him to a specified content ?
>

These are the HTTP headers my browser send along when  I load a page from a
webserver.
I expect you can guess which one would be interesting for you :-)

Accept: */*
Accept-Language: en-gb,no;q=0.5
Host: www.gildseth.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)







"Tommy Gildseth" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> "Arcadius A." <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > How to detect the language setting of the the visitor's PC  in order to
> > redirect him to a specified content ?
> >
>
> Accept: */*
> Accept-Language: en-gb,no;q=0.5
> Host: www.gildseth.com
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)

More specifically the variabel $HTTP_ACCEPT_LANGUAGE will tell you what
languages the users browser will accept.








I have this code in my program but I fail to find the error, does anyone see it after 
a quick glance?


<?php
if ($action == "save_filter") {
$fh = fopen ("./filters.data.php", "r+b") or die ("couldnt open");
$file = fread($fh, filesize("./filters.data.php"));
$file = stripslashes($file);
$array = unserialize($file);
$array[] = array($filter, $name);

$out = serialize($array);
fwrite($fh, $out) or die;

fclose($fh);

}
?>




Hey list, i'm new to php so bare with me...

got some questions on mysql commands. I'd like to know how the 
mysql_insert_id() function works exactly. 
First of all how reliable is it? What happens this happens:
Table: (ID int unsigned primary key auto_increment, Stuff text, MoreStuff 
text)
(my script)
insert into table values(NULL, "bla", "bla")
(some other application)
insert into table values(NULL, "bleh", "bleh")
(my script)
$id = mysql_insert_id

it's not likely that this will happen, but if the site is very/extremely 
crowded it could be that there's an insert right after mine but before me 
callind mysql_insert_id. As you might guess I'd like to know which ID will be 
returned, the one my script created or the one from the other application?

Also what happens if my table is like this:
Table: (Stuff text, ID int unsigned primary key auto_increment, OtherStuff 
text)
Thus having the ID on column 2 instead of 1
or like this
Table: (Bla int unsigned primary key auto_increment, Stuff text, Otherstuff 
text)
Thus the ID not having the name ID
Or like this
Table: (bla int unsigned primary key auto_increment, id int unsigned primary 
key auto_increment, stuff text, otherstuff text)
Thus having 2 auto_increment columns where the 2nd one is called ID (lower 
case).

I'm really uncertain about that and couldn't find it back in the manual.... 
does it only read the first column? does this column have to be named ID, 
what if ID is another column? what if there is more than 1 auto_increment 
column in the table? what happens if some(one)/(thing) else inserts before 
calling mysql_insert_id.

One more question (pure curiosity this one) the return value from 
mysql_query... is that ever gonna be higher than 1? I assume it can be if the 
insert affects more than 1 line right? Also my book says that the return 
value is TRUE or FALSE for every command except for an INSERT in which case 
it would be 0 on failure and higher on succes. I think that's crap? I'm 
guessing it will also return a number for UPDATE's and REPLACE's is that 
correct? Are there others?

OK just one more thing, this is for the people from troutworks if they're 
monitoring this list. I think the translation of the PHP Bible is 
crap!!!!!!!!! Please complain about it at the translator. The guy/girl 
managed to translate (quotes) " to (comma's) , and there are a lot of other 
wrongly translated things in there, luckily the examples in there got me on 
the right path again over and over showing that the translation was incorrect 
but it's just confusing like hell. The number of mistakes is unbelievable 
(and i'm NOT talking about spelling errors, I'm talking about messy stuff 
like calling quotes comma's) and I'm 100% certain it was NOT translated by a 
programmer

regards


Reply via email to