php-general Digest 4 Apr 2004 21:11:59 -0000 Issue 2686
Topics (messages 182272 through 182299):
Re: how to reset PHP_AUTH vars
182272 by: Burhan Khalid
182276 by: Nitin Mehta
182278 by: Martin Oettinger
Intermittent problem with Session Variable and IE6
182273 by: beetroot
182277 by: Tom Rogers
Re: email viruses
182274 by: Jason Wong
Re: looping through an array
182275 by: Jason Wong
php as default "value" in html
182279 by: Andy B
182280 by: Mark
182282 by: Andy B
182284 by: John Holmes
182286 by: Andy B
182288 by: John Holmes
182289 by: Jason Wong
182292 by: Andy B
Problem with script halting
182281 by: Nathan Croker
182283 by: John Holmes
182285 by: Nathan Croker
182290 by: Jason Wong
double require_once("string")
182287 by: Kazuumi TASHIRO
182291 by: Jason Wong
182294 by: Kazuumi TASHIRO
session_exist() ?? Can this be done?
182293 by: Monty
Re: Session hell: register_globals off
182295 by: Randall Perry
182298 by: Randall Perry
182299 by: trlists.clayst.com
Regular Expressions
182296 by: Matt Palermo
Using PDFLib
182297 by: Nathan Mealey
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 ---
Nitin Mehta wrote:
Hello,
Thanks for your reply. but what I'm looking for is, yes logoff the user, but
not making him/her click some link. I've this page and I want it to ask for
username & password whenever a user comes/comes back. Any suggestions?
I believe this is the default behavior, unless the user saves the
credentials locally.
--- End Message ---
--- Begin Message ---
but it's not happening.
----- Original Message -----
From: "Burhan Khalid" <[EMAIL PROTECTED]>
To: "Nitin Mehta" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, April 04, 2004 1:58 PM
Subject: Re: [PHP] how to reset PHP_AUTH vars
> Nitin Mehta wrote:
> > Hello,
> >
> > Thanks for your reply. but what I'm looking for is, yes logoff the user,
but
> > not making him/her click some link. I've this page and I want it to ask
for
> > username & password whenever a user comes/comes back. Any suggestions?
>
> I believe this is the default behavior, unless the user saves the
> credentials locally.
>
--- End Message ---
--- Begin Message ---
Another solution to clean the browser auth cache is to close the browser; a
javscript function exists as well....
"Nitin Mehta" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> but it's not happening.
>
> ----- Original Message -----
> From: "Burhan Khalid" <[EMAIL PROTECTED]>
> To: "Nitin Mehta" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Sunday, April 04, 2004 1:58 PM
> Subject: Re: [PHP] how to reset PHP_AUTH vars
>
>
> > Nitin Mehta wrote:
> > > Hello,
> > >
> > > Thanks for your reply. but what I'm looking for is, yes logoff the
user,
> but
> > > not making him/her click some link. I've this page and I want it to
ask
> for
> > > username & password whenever a user comes/comes back. Any suggestions?
> >
> > I believe this is the default behavior, unless the user saves the
> > credentials locally.
> >
--- End Message ---
--- Begin Message ---
I have a php app that is in the final stages of testing and has been tested
by over 30 separate users.
One of the testers is having an intermittent problem which seems to be
caused by a session variable not being read properly in about 1 in 3
requests - the variable is getting set correctly in the session temp file.
This bug only occurs when using IE6 (XP SP2) on this particular machine, it
does not occur when using Netscape7.1 on the same machine.
It occurs when testing against the main server Linux/Apache 1.3.29/PHP4.2.3
and against my dev machine Win2k/Apache 2/PHP4.3.4
None of the other testers seemed to experience the same problem.
Has anybody seen anything similar or know of any possible causes?
--- End Message ---
--- Begin Message ---
Hi,
Sunday, April 4, 2004, 9:11:08 PM, you wrote:
b> I have a php app that is in the final stages of testing and has been tested
b> by over 30 separate users.
b> One of the testers is having an intermittent problem which seems to be
b> caused by a session variable not being read properly in about 1 in 3
b> requests - the variable is getting set correctly in the session temp file.
b> This bug only occurs when using IE6 (XP SP2) on this particular machine, it
b> does not occur when using Netscape7.1 on the same machine.
b> It occurs when testing against the main server Linux/Apache 1.3.29/PHP4.2.3
b> and against my dev machine Win2k/Apache 2/PHP4.3.4
b> None of the other testers seemed to experience the same problem.
b> Has anybody seen anything similar or know of any possible causes?
could be related to this:
http://marc.theaimsgroup.com/?l=php-general&m=107751892631059&w=2
which was posted here a while back by Beau Hartshorne
--
regards,
Tom
--- End Message ---
--- Begin Message ---
On Sunday 04 April 2004 01:45, Andy B wrote:
> i know this is a little ot but in an attempt to keep viruses off the list
> (i think) somebody/something is forging an email in my name to the php
> mailing list as well as mysql mailing list along with a few others. i get a
> message something like this:
>
> "your message titled: submit your authentication here... has been sent to
> (whatever mailing list it sent to)"
I don't know where you've been for the last few years, almost/probably all
recent viruses pick two email addresses at random (from what it harvests from
your computer) then uses those as the TO and FROM address for the crap it
sends out. Read up on the virus information available on any of the major
anti-virus software producers' sites.
> does anybody know about this sort of thing? and if so how to get rid of it?
Don't ever use your email address, ever. Failing that, tell your
friends/associates/whomever has your email address, to stop using crap like
Outlook and/or stop getting themselves infected with viruses.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
1 bulls, 3 cows.
*/
--- End Message ---
--- Begin Message ---
On Sunday 04 April 2004 08:22, Andy B wrote:
[snip]
> i tried using while($_SESSION['guestbook']) but it proves in php's mind to
> be blank or that whole statement gets ignored...
The above doesn't make sense, if you don't have anything inside your
while-loop which alters $_SESSION['guestbook'] then you're going to either
(a) have a zero iteration while-loop, or (b) have an infinite loop.
If $_SESSION['guestbook'] contains an array use a foreach-loop. Or provide
some more details.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"Don't hate me because I'm beautiful. Hate me because I'm beautiful, smart
and rich."
-- Calvin Keegan
*/
--- End Message ---
--- Begin Message ---
hi...
i have the following html line:
<input type="text" name="referred" value=<?echo $old['Referred'];?> accesskey="d"
id="id-referred">
the php variable $old['Referred'] was pulled from a mysql table. the full string that
this variable holds is "I work for you..." but when used as a default value in an
input text field for html the only part that shows up in the form itself is "I". is
there anything going on that im missing somewhere??
--- End Message ---
--- Begin Message ---
--- Andy B <[EMAIL PROTECTED]> wrote:
> hi...
>
> i have the following html line:
> <input type="text" name="referred" value=<?echo $old['Referred'];?>
> accesskey="d" id="id-referred">
> the php variable $old['Referred'] was pulled from a mysql table.
> the full string that this variable holds is "I work for you..." but
> when used as a default value in an input text field for html the
> only part that shows up in the form itself is "I". is there
> anything going on that im missing somewhere??
>
>
Yes. Perform the subsitution manually. You'll get
<input type="text" name="referred" value=I work for you...
accesskey="d" id="id-referred">
You need quotes around the PHP code.
<input type="text" name="referred" value="<?echo $old['Referred'];?>"
accesskey="d" id="id-referred">
=====
Mark Weinstock
[EMAIL PROTECTED]
***************************************
You can't demand something as a "right" unless you are willing to fight to death to
defend everyone else's right to the same thing.
***************************************
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
--- End Message ---
--- Begin Message ---
tnx that works now
----- Original Message -----
From: "Mark" <[EMAIL PROTECTED]>
To: "Andy B" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, April 04, 2004 11:32 AM
Subject: Re: [PHP] php as default "value" in html
>
> --- Andy B <[EMAIL PROTECTED]> wrote:
> > hi...
> >
> > i have the following html line:
> > <input type="text" name="referred" value=<?echo $old['Referred'];?>
> > accesskey="d" id="id-referred">
> > the php variable $old['Referred'] was pulled from a mysql table.
> > the full string that this variable holds is "I work for you..." but
> > when used as a default value in an input text field for html the
> > only part that shows up in the form itself is "I". is there
> > anything going on that im missing somewhere??
> >
> >
>
> Yes. Perform the subsitution manually. You'll get
> <input type="text" name="referred" value=I work for you...
> accesskey="d" id="id-referred">
>
> You need quotes around the PHP code.
> <input type="text" name="referred" value="<?echo $old['Referred'];?>"
> accesskey="d" id="id-referred">
>
>
>
> =====
> Mark Weinstock
> [EMAIL PROTECTED]
> ***************************************
> You can't demand something as a "right" unless you are willing to fight to
death to defend everyone else's right to the same thing.
> ***************************************
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotions.yahoo.com/design_giveaway/
--- End Message ---
--- Begin Message ---
Mark wrote:
--- Andy B <[EMAIL PROTECTED]> wrote:
i have the following html line:
<input type="text" name="referred" value=<?echo $old['Referred'];?>
accesskey="d" id="id-referred">
the php variable $old['Referred'] was pulled from a mysql table.
the full string that this variable holds is "I work for you..." but
when used as a default value in an input text field for html the
only part that shows up in the form itself is "I". is there
anything going on that im missing somewhere??
Yes. Perform the subsitution manually. You'll get
<input type="text" name="referred" value=I work for you...
accesskey="d" id="id-referred">
You need quotes around the PHP code.
<input type="text" name="referred" value="<?echo $old['Referred'];?>"
accesskey="d" id="id-referred">
To prevent a cross site scripting vulnerability, you'll want to use
htmlentities(), also.
<input type="text" name="referred" value="<?echo
htmlentities($old['Referred']);?>" accesskey="d" id="id-referred">
Other wise the value could have a double quote within it and a malicious
user could effectively "end" your input text box and inject their own HTML.
---John Holmes...
--- End Message ---
--- Begin Message ---
"htmlentities(), also.
<input type="text" name="referred" value="<?echo
htmlentities($old['Referred']);?>" accesskey="d" id="id-referred">
Other wise the value could have a double quote within it and a malicious
user could effectively "end" your input text box and inject their own HTML."
is there any way to keep multiple users using the same form from mixing up
variables
--- End Message ---
--- Begin Message ---
Andy B wrote:
<input type="text" name="referred" value="<?echo
htmlentities($old['Referred']);?>" accesskey="d" id="id-referred">
Other wise the value could have a double quote within it and a malicious
user could effectively "end" your input text box and inject their own HTML."
> >
> is there any way to keep multiple users using the same form from mixing up
> variables
I have no idea what you mean here.
---John Holmes...
--- End Message ---
--- Begin Message ---
On Monday 05 April 2004 00:34, Andy B wrote:
[non-standard quoting snipped]
Please use a standard quoting mechanism, eg prefix each line of the quoted
message with a '>'.
Why? Because most mail clients understands the standard quoting styles and are
able to display the quoted parts of previous messages in a different format
making it easy to distinguish the new stuff from the old.
> is there any way to keep multiple users using the same form from
> mixing up variables
Each user requesting your form is serviced by a separate HTTP request. There
are no variables to mix up and nothing to worry about.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
If you must work on your flight, you will experience turbulence as soon as you
touch pen to paper
-- Murphy's Laws for Frequent Flyers n5
*/
--- End Message ---
--- Begin Message ---
> > is there any way to keep multiple users using the same form from mixing
up
> > variables
>>I have no idea what you mean here.
if user #1 logs in and starts using a form and then user #2 logs in and
starts using the same one as user #1, say by chance they submit it at the
same time... is there any way to keep the forms from overwriting each
other...
--- End Message ---
--- Begin Message ---
Can anyone tell me why the following line of code halts my entire script
(anything after it is not processed).
ftp_chmod($conn, 0777, $to);
All other ftp commands in the script work perfectly. I've tried replacing
'0777' with 777, 1777, in and out of "s, but it still halts the script,
there is nothing after the command to halt the execution of the script
either. echoing something directly before it will appear, but echoing
something directly after it does not.
I am using PHP 4.3.6RC1 on Apache 2.0.48.
Thanks in advance for any help.
--- End Message ---
--- Begin Message ---
Nathan Croker wrote:
Can anyone tell me why the following line of code halts my entire script
(anything after it is not processed).
ftp_chmod($conn, 0777, $to);
All other ftp commands in the script work perfectly. I've tried replacing
'0777' with 777, 1777, in and out of "s, but it still halts the script,
there is nothing after the command to halt the execution of the script
either. echoing something directly before it will appear, but echoing
something directly after it does not.
The command is probably failing or hanging on the FTP server. Are you
sure the user you're connecting with has permission to execute chmod?
---John Holmes...
--- End Message ---
--- Begin Message ---
Thank you for your reply.
Yes the user has permission to execute chmod since when I access the server
using an FTP Client it works perfectly.
- Nathan Croker
(amazing as a result of one post, I get 6 different spam emails within
several minutes of posting!)
----- Original Message -----
From: "John Holmes" <[EMAIL PROTECTED]>
To: "Nathan Croker" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, April 04, 2004 5:12 PM
Subject: Re: [PHP] Problem with script halting
> Nathan Croker wrote:
>
> > Can anyone tell me why the following line of code halts my entire script
> > (anything after it is not processed).
> >
> > ftp_chmod($conn, 0777, $to);
> >
> > All other ftp commands in the script work perfectly. I've tried
replacing
> > '0777' with 777, 1777, in and out of "s, but it still halts the script,
> > there is nothing after the command to halt the execution of the script
> > either. echoing something directly before it will appear, but echoing
> > something directly after it does not.
>
> The command is probably failing or hanging on the FTP server. Are you
> sure the user you're connecting with has permission to execute chmod?
>
> ---John Holmes...
--- End Message ---
--- Begin Message ---
On Sunday 04 April 2004 23:38, Nathan Croker wrote:
> Can anyone tell me why the following line of code halts my entire script
> (anything after it is not processed).
>
> ftp_chmod($conn, 0777, $to);
>
> All other ftp commands in the script work perfectly. I've tried replacing
> '0777' with 777, 1777, in and out of "s, but it still halts the script,
> there is nothing after the command to halt the execution of the script
> either. echoing something directly before it will appear, but echoing
> something directly after it does not.
When you say halt, do you mean the script terminates or does it hang? If the
former what does the php error log say?
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
He is the best of men who dislikes power.
-- Mohammed
*/
--- End Message ---
--- Begin Message ---
Hello, nice to meet you.
I couldn't understand following behavior of the function require_once().
(PHP version in my PC is 4.2.3, and `include_path' in the /etc/php.ini might
be well established.)
At first, I made following directory tree.
----------------begin-0:
$ ls
required.inc subdir/
$ cat required.inc
<?php
echo "I am _test/required.inc!!\n";
?>
$ cat subdir/required.inc
<?php
echo "I am _test/subdir/required.inc!!\n";
?>
$ cat subdir/subsubdir/require_once.php
<?php
print "I (_test/subdir/subsubdir/require_once.php) require
subsubsubdir/required.inc<br>\n";
require_once ("subsubsubdir/required.inc");
?>
$ cat subdir/subsubdir/subsubsubdir/require_once.php
<?php
print "I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../../required.inc<br>\n";
require_once ("../../../required.inc");
?>
----------------end-0.
Next, I typed following commands. (This is expected behavior.)
----------------begin-1:
$ php -f subdir/subsubdir/subsubsubdir/require_once.php
I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../../required.inc<br>
I am _test/required.inc!!
----------------end-1.
I typed following commands however it did not work expectedly...
----------------begin-2:
$ php -f subdir/subsubdir/require_once.php
I (_test/subdir/subsubdir/require_once.php) require subsubsubdir/required.inc<br>
<br />
<b>Fatal error</b>: Failed opening required 'subsubsubdir/required.inc'
(include_path='.:/nfs/home2/Users03/tashiro') in
<b>/nfs/home2/Users03/tashiro/public_html/labonly-2004/_test/subdir/subsubdir/require_once.php</b>
on line <b>3</b><br />
----------------end-2.
I couldn't understand the behavior above. Please tell me, how does PHP
calculate (interprete) an argument of the request_once()?
--
Tashiro, Japan
--- End Message ---
--- Begin Message ---
On Monday 05 April 2004 00:41, Kazuumi TASHIRO wrote:
> <b>Fatal error</b>: Failed opening required 'subsubsubdir/required.inc'
> (include_path='.:/nfs/home2/Users03/tashiro') in
Because it doesn't exist? AFAICS you've only got 'subdir/required.inc'.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Blessed is he who expects nothing, for he shall never be disappointed.
-- Alexander Pope
*/
--- End Message ---
--- Begin Message ---
Thanks to your reply.
On Mon, 5 Apr 2004 01:29:13 +0800, Jason Wong <[EMAIL PROTECTED]> wrote:
> Because it doesn't exist? AFAICS you've only got 'subdir/required.inc'.
I'm sorry, I've mistaken. What I'd like to send is below:
=====================Directory Tree BEGIN:
$ cat subdir/subsubdir/require_once.php
<?php
print "I (_test/subdir/subsubdir/require_once.php) require
subsubsubdir/require_once.php<br>\n";
require_once ("subsubsubdir/require_once.1.php");
require_once ("subsubsubdir/require_once.php");
?>
$ cat subdir/subsubdir/subsubsubdir/require_once.1.php
<?php
print "I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../required.inc<br>\n";
require_once ("../../required.inc");
?>
$ cat subdir/subsubdir/subsubsubdir/require_once.php
<?php
print "I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../../required.inc<br>\n";
require_once ("../../../required.inc");
?>
=====================Directory Tree END.
=====================Expected Behavior BEGIN:
$ php -f subdir/subsubdir/subsubsubdir/require_once.1.php
I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../required.inc<br>
I am _test/subdir/required.inc!!
$ php -f subdir/subsubdir/subsubsubdir/require_once.php
I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../../required.inc<br>
I am _test/required.inc!!
=====================Expected Behavior END.
=====================Unexpected Behavior BEGIN:
$ php -f subdir/subsubdir/require_once.php
I (_test/subdir/subsubdir/require_once.php) require subsubsubdir/require_once.php<br>
I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../required.inc<br>
I am _test/required.inc!!
I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require
../../../required.inc<br>
<br />
<b>Fatal error</b>: Failed opening required '../../../required.inc'
(include_path='.:/nfs/home2/Users03/tashiro') in
<b>/nfs/home2/Users03/tashiro/public_html/labonly-2004/_test/subdir/subsubdir/subsubsubdir/require_once.php</b>
on line <b>3</b><br />
=====================Unexpected Behavior END.
What I'd like to say is whether a code calling request_once() receives
`processing result' of php-code (argument of request_once()),
or the code only expansion the text-file (argument of request_once()).
The result above shows that answer might be latter, then however,
are there how to develop a multilayer-required library (Figure.1) ?
========BEGIN of Figure.1: multilayer-required
lib/code0.php
lib/sublib/code1.inc
lib/sublib/subsublib/code2.inc
code1.inc requires code2.inc,
code0.php would like to require code1.inc.
========END of Figure.1.
----
Programmer being unable to sleep...
Tashiro, Japan
--- End Message ---
--- Begin Message ---
Hi, is there any way to know if a site visitor has an existing session
without having to first start the session using session_start()?
I'm trying to avoid starting a valid session unless the visitor has been
authenticated and logged in, so, here's what I do now at the top of every
page:
session_start()
if (!$_SESSION['loggedin']) {
session_destroy();
header("Location:/login.php"); // Send to Log-In page.
}
Is this the most efficient way to do this? I'd prefer to not have to start
then immediately destroy the session if it's possible to first know whether
a session exists without starting it.
I have my site set to store the PHPSESSID in a cookie only (not passed via
URL), so, would checking for the existence of $_COOKIE['PHPSESSID'] be a
reliable way of doing this?
Any other suggestions are appreciated!
Monty
--- End Message ---
--- Begin Message ---
Solved my main problem. I was assuming that variables registered with
$_SESSION were passed by reference. Apparently they're passed by value.
I moved the line '$_SESSION['order'] = $order;' from the top of the page 1
php code (before any properties for the order object are set), to the end of
the php code -- now everything's getting passed to page 2 ok.
This is an important point that should probably be in the docs section on
sessions.
When I coded using session_register() with register_globals on registering
the variable before making changes to it worked.
The '[error] PHP Notice: Undefined variable: _SESSION' happened, I think,
because there were no session variables to pass so PHP killed the session.
> Had a previous thread on this issue. Started working on it again and am
> running into new bugs, so thought I'd start a new thread.
>
> Read thoroughly through session examples in docs and here's how I tried to
> pass an object from one page to another:
>
>
> page 1
> ______
>
> // include class definition file
> include_once "order_classes.php";
> // start session
> session_start();
> // create instance of class Order
> $order = New Order();
> // assign class instance to $SESSION[]
> $_SESSION['order'] = $order;
>
> page 2
> ______
>
> // include class definition file
> include_once "order_classes.php";
> // start session
> session_start();
> // assign $_SESSION['order'] object to variable
> $order = $_SESSION['order'];
>
>
> I'm getting the following error when page 2 loads:
> [error] PHP Notice: Undefined variable: _SESSION
>
> Any ideas?
>
>
>
>
>
> Pertinent PHP vars:
> ___________________
>
> Darwin systame.cniweb.net 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11
> 16:20:23 PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC Power Macintosh
>
> Build Date Apr 2 2004 12:58:17
>
> Configure Command './configure' '--with-apxs=/usr/sbin/apxs' '--with-pgsql'
> '--with-xml' '--with-openssl=/usr/local/ssl' '--with-pear'
> '--with-curl=/usr/lib'
>
> Apache/1.3.29 (Darwin) DAV/1.0.3 mod_perl/1.29 PHP/4.3.5 mod_jk/1.2.4
> mod_ssl/2.8.16 OpenSSL/0.9.7c
>
> register_globals Off Off
>
--
Randall Perry
sysTame
Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales
http://www.systame.com/
--- End Message ---
--- Begin Message ---
Also, this means that each succeeding page that uses and changes the session
variable must read it in at the beginning of the code and reset it to
$_SESSION after changes are made, i.e.:
$order = $_SESSION['order'];
..
..
<code that changes $order>
..
..
$_SESSION['order'] = $order
> Solved my main problem. I was assuming that variables registered with
> $_SESSION were passed by reference. Apparently they're passed by value.
>
> I moved the line '$_SESSION['order'] = $order;' from the top of the page 1
> php code (before any properties for the order object are set), to the end of
> the php code -- now everything's getting passed to page 2 ok.
>
--
Randall Perry
sysTame
Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales
http://www.systame.com/
--- End Message ---
--- Begin Message ---
On 4 Apr 2004 Randall Perry wrote:
> Solved my main problem. I was assuming that variables registered with
> $_SESSION were passed by reference. Apparently they're passed by value.
*Passing* by value or by reference has to do with function parameters,
not array values. However you can assign one variable as a reference
to another, see http://www.php.net/manual/en/language.references.php.
When you enter a line of code like:
$_SESSION['order'] = $order;
you are doing a regular assignment. To use a reference instead, use:
$_SESSION['order'] =& $order;
The data will be passed this way to the next session. For example, try
this (substitute your server name in the header() call):
test1.php:
<?php
session_start();
$test1 = "";
$_SESSION["Test1"] =& $test1;
$test1 = "this is test1";
header("Location: http://localhost/olm/test2.php");
?>
test2.php:
<?php
session_start();
var_dump($_SESSION);
?>
The output on the second page will be something like this (I'm using
xdebug so this is not raw var_dump() output):
array
'Test1' => 'this is test1'
--
Tom
--- End Message ---
--- Begin Message ---
I have a page where I am stripping the html tags down. Basically, it will
allow certain tags, but still strips out ALL attributs of the tag, so it
works something like this:
$allowed_tags = "<p><br><strong><b><i><u>";
// State which tags are allowed
$info = strip_tags($info, $allowed_tags);
// Strip all unwanted tags out
$allowed_tags = "p|br|strong|b|i|u";
// Convert tags for regular expression
$info = preg_replace("/<(?!".$allowed_tags.")[^>]*>/", '<\1>', $info); //
Strip out all attributes from allowed tags
This will strip all attributes out of those tags, so it will turn something
like this <p some stuff here>My p tag</p> into this <p>My p tag</p>. The
above regular expression will handle this just fine. The only problem I am
running into is when someone uses a less than sign in their input (<). So
when someone puts something like: 2 < 8 in their input it gets changed to
this: 2 <>. How can I set it to only replace things when there is a < and
a matching > for it? Anyone have any ideas?
Thanks,
Matt
--- End Message ---
--- Begin Message ---
Hello,
I am trying to generate PDFs using PDFLib for the first time, and have
two questions, one of which is very confusing to me.
1) how can I tell the script generating the pdf to store it in a
particular place on the computer where the pdf generation is happening?
2) this is the really confusing one. The text being put into the body
of the pdf is an article about 6300 characters. The tutorials I have
found all follow the same format, and end up printing all of this text
in one line (or row), so that the pdf ends up being just one line
across. So the question is, how do I get the text to be placed
normally on the page, so as to be a readable document? I should add
that I am using a block of text sent from an HTML form.
Here is the PHP script:
<?php
$author=$_POST['author'];
$text=$_POST['text'];
$pdf = PDF_new();
PDF_open_file($pdf);
PDF_set_info($pdf, "author", "$author");
PDF_begin_page($pdf,612,792);
$font = PDF_findfont($pdf, "Helvetica", "winansi",0);
PDF_setfont($pdf,$font,12);
PDF_show_xy($pdf, "$text", 5,225);
PDF_end_page($pdf);
PDF_close($pdf);
$buffer = PDF_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-Length: ".strlen($buffer));
header("Content-Disposition: inline; filename=sample.pdf");
echo $buffer
?>
Thanks!
--
Nathan Mealey
Director of Operations
Cycle-Smart, Inc.
P.O. Box 1482
Northampton, MA
01061-1482
[EMAIL PROTECTED]
(413) 587-3133
(413) 210-7984 Mobile
(512) 681-7043 Fax
--- End Message ---