Re: [PHP] Array_keys problem
Robin 'Sparky' Kopetzky wrote: Good afternoon. I'm building a class and am having a bunch of trouble with the PHP array_keys function. I keep getting these errors: Warning: First argument to array_keys() should be an array in D:\Htf.php on line 33 Warning: Wrong datatype for second argument in call to in_array in D:\Htf.php on line 35 $this-ma_arguments IS an array, so why is the error popping up? I did check syntax but am buffaloe'd by this one. Just so no one gets confused, I use a form of Hungarian (p=parameter, m=module, a=array, s=string) Since PHP doesn't have strict typing, you can't be sure what it is. I've edited your code a bit. /** * @var assoc array of passed arguments */ //var $ma_arguments; var $ma_arguments = array(); /** * Constructor */ function bmc_html_tag_functions() { //$this-init(); } function init() { $this-ma_arguments = array(); } /** * Checks if the given key or index exists in the array (PHP 4.1.0) * * @param $ps_keyKey to check against * @param $pa_search Array of elements * @return true if key is in array * @access private */ function key_exists($ps_key) { if (!is_array($this-ma_arguments)) { echo '$this-ma_arguments is not an array'; echo 'pre'; var_dump($this-ma_arguments); echo '/pre'; if ( in_array($ps_key, array_keys($this-ma_arguments)) ) { return true; } else { return false; } } Try that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 4 Apr 2004 08:26:36 -0000 Issue 2685
php-general Digest 4 Apr 2004 08:26:36 - Issue 2685 Topics (messages 182255 through 182271): Re: passing variables 182255 by: Larry E. Ullman Message (Your message dated Sat, 3 Apr 2004 19:18:13 +0200...) 182256 by: L-Soft list server at America Online, Inc. (1.8e) email viruses 182257 by: Andy B Re: Flash MX 182258 by: Michal Migurski Keep HTML tags, but strip attributes 182259 by: Matt Palermo 182260 by: Jochem Maas 182263 by: Jochem Maas 182264 by: Matt Palermo 182265 by: Red Wingate 182266 by: Matt Palermo checking for existance of $_SESSION variables 182261 by: Andy B 182262 by: Red Wingate Array_keys problem 182267 by: Robin 'Sparky' Kopetzky 182271 by: Burhan Khalid looping through an array 182268 by: Andy B Re: Suddenly some errors are coming 182269 by: Kim Steinhaug 182270 by: Manisha Sathe 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] -- ---BeginMessage--- When using a link like xxx.proceed.php?language=gbr the 'proceed.php' script does not receive any $language variable. Does someone know how to get it run? This is a register_globals issue. Refer to $_GET['language'] instead of just language. Or, at the top of your script, add $language = $_GET['language']; and you shouldn't have to change anything else. See the manual for $_GET and $_POST for more information. Larry ---End Message--- ---BeginMessage--- Your message dated Sat, 3 Apr 2004 19:18:13 +0200 with subject Re: Mail Authentification has been submitted to the moderator of the WOC list: [EMAIL PROTECTED] ---End Message--- ---BeginMessage--- hi... 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) does anybody know about this sort of thing? and if so how to get rid of it? tnx and sorry for the ot thing ---End Message--- ---BeginMessage--- I have to send data to flash. Should i use the urlencode() or the rawurlencode() function to encode the data? If you are going to be doing this a lot, you should take a look at AMFPHP, Flash Remoting for PHP, at http://sourceforge.net/projects/amfphp/ This seems to be a fast, reliable way to send data back and forth between your server and your Flash client. I have heard rumors that remoting is supposed to be deprecated in the next revision of flash, but I'm not sure how reliable those reports are. Remoting with AMFPHP is speedy and easy, but you may be a little better off using XML - it's definitely chatty, but the API is stable on both sides, and there's no reverse-engineering voodoo associated with it. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html ---End Message--- ---BeginMessage--- I am building a system which allows users to post data. I want to allow them to use ONLY certain tags such as p, /p, b, /b, i, /i, etc... I want to allow them to use only these, and then strip out ALL attributes inside the tags. So if they input something like p junk=junk, it would switch it to just p. Anyone know of a way this can be done? Thanks, Matt Palermo http://sweetphp.com ---End Message--- ---BeginMessage--- Matt Palermo wrote: I am building a system which allows users to post data. I want to allow them to use ONLY certain tags such as p, /p, b, /b, i, /i, etc... I want to allow them to use only these, and then strip out ALL attributes inside the tags. So if they input something like p junk=junk, it would switch it to just p. Anyone know of a way this can be done? regular expressions, heres an example: ?php $input = 'this divis some/div ub class=haxorbad/b/u HTML'; echo {$input}\n; $input = preg_replace('/\/?[^pbiu\/][^]*/', '', $input); echo {$input}\n; $input = preg_replace('/([pbiu])[^]*/', '\1', $input); echo {$input}\n; $input = str_replace('bad', 'good', $input); echo {$input}\n; ? you might also think about stripping script tags etc. try taking a look at some forum code (e.g. phpbb.com) to see how they do it. no doubt that some real regexp wizard could perform the above replacements in a single regexp but hopefully it gives you an idea... if your not yet familiar with regexps then I strongly recommend you read the relevant part of the manual - they are very handy things indeed. Thanks, Matt Palermo http://sweetphp.com ---End Message--- ---BeginMessage--- Jochem Maas wrote: ...
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Intermittent problem with Session Variable and IE6
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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email viruses
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. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looping through an array
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 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to reset PHP_AUTH vars
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Intermittent problem with Session Variable and IE6
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-generalm=107751892631059w=2 which was posted here a while back by Beau Hartshorne -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to reset PHP_AUTH vars
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php as default value in html
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??
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with script halting
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php as default value in html
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php as default value in html
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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with script halting
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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php as default value in html
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] double require_once(string)
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.incbr\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.incbr\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.incbr 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.incbr br / bFatal 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 b3/bbr / 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php as default value in html
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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php as default value in html
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 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with script halting
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 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] double require_once(string)
On Monday 05 April 2004 00:41, Kazuumi TASHIRO wrote: bFatal 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 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php as default value in 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. 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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_exist() ?? Can this be done?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] double require_once(string)
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.phpbr\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.incbr\n; require_once (../../required.inc); ? $ cat subdir/subsubdir/subsubsubdir/require_once.php ?php print I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../../required.incbr\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.incbr I am _test/subdir/required.inc!! $ php -f subdir/subsubdir/subsubsubdir/require_once.php I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../../required.incbr 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.phpbr I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../required.incbr I am _test/required.inc!! I (_test/subdir/subsubdir/subsubsubdir/require_once.php) require ../../../required.incbr br / bFatal 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 b3/bbr / =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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session hell: register_globals off
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_globalsOff Off -- Randall Perry sysTame Xserve Web Hosting/Co-location Website Development/Promotion Mac Consulting/Sales http://www.systame.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expressions
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 = pbrstrongbiu; // 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 hereMy p tag/p into this pMy 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using PDFLib
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session hell: register_globals off
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session hell: register_globals off
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 4 Apr 2004 21:11:59 -0000 Issue 2686
php-general Digest 4 Apr 2004 21:11:59 - 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] -- ---BeginMessage--- 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--- ---BeginMessage--- 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--- ---BeginMessage--- 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--- ---BeginMessage--- 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--- ---BeginMessage--- 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:
[PHP] \n is not working!
\n isn't working properly. Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to the document one|two|three\n but not one|two|three (and break) whole code: if ($a==new){ $post_0 = $_POST[one]; $post_1 = $_POST[two]; $post_2 = $_POST[three]; if ($post_1 !=){ if ($post_2 !=){ $m_fails=fopen('../data/menu.txt','a'); $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; fwrite($m_fails,$new_topic); fclose($m_fails); }} } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $HTTP_SESSION_VARS still holds original values even after unset?
how would you empty all the contents of $HTTP_SESSION_VARS when you dont need them anymore but still keep the current session running? the problem seems to be that when i try to fill them with something else (dont need the original values anymore) but need new ones without destroying the session itself they wont fill with new things. unset($HTTP_SESSION_VARS); does nothing to help at all because they still have the same values that they were originally filled with (and not to mention they are still in the session)... anybody have any ideas how to delete or empty out the array but keep the session active ??
Re: [PHP] \n is not working!
On Sun, 2004-04-04 at 17:58, Labunski wrote: \n isn't working properly. Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to the document one|two|three\n but not one|two|three (and break) Because it's in single quotes versus a double quotes. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: \n is not working!
\n must be included in double-quotes because it's treated like a variable. echo This works\n; // Displays: This works echo This doesn't work\n'; // Displays: This doesn't work\n From: [EMAIL PROTECTED] (Labunski) Newsgroups: php.general Date: Mon, 5 Apr 2004 00:58:35 +0300 To: [EMAIL PROTECTED] Subject: \n is not working! \n isn't working properly. Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to the document one|two|three\n but not one|two|three (and break) whole code: if ($a==new){ $post_0 = $_POST[one]; $post_1 = $_POST[two]; $post_2 = $_POST[three]; if ($post_1 !=){ if ($post_2 !=){ $m_fails=fopen('../data/menu.txt','a'); $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; fwrite($m_fails,$new_topic); fclose($m_fails); }} } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?
Andy B wrote: how would you empty all the contents of $HTTP_SESSION_VARS when you dont need them anymore but still keep the current session running? $HTTP_SESSION_VARS = array(); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session hell: register_globals off
Randall Perry [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Solved my main problem. I was assuming that variables registered with $_SESSION were passed by reference. Apparently they're passed by value. Wouldn't make very much sense to pass by reference, would it? Seems to me like that would kill all values after the script finish... The logic would be the reverse, to make $order a reference to $_SESSION['order']... Oh, and have a look at serialize().. :) 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. That sound VERY wierd to me.. But possible I guess.. 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_globalsOff Off -- Randall Perry sysTame Xserve Web Hosting/Co-location Website Development/Promotion Mac Consulting/Sales http://www.systame.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: \n is not working!
echo This doesn't work\n'; // Displays: This doesn't work\n Seems to me like that would generate parse error.. :s But yea, we get your point.. :) -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Umm.. Use $_SESSION for that, and session_unregister() for the unsetting with the old style code.. -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com Andy B [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] how would you empty all the contents of $HTTP_SESSION_VARS when you dont need them anymore but still keep the current session running? the problem seems to be that when i try to fill them with something else (dont need the original values anymore) but need new ones without destroying the session itself they wont fill with new things. unset($HTTP_SESSION_VARS); does nothing to help at all because they still have the same values that they were originally filled with (and not to mention they are still in the session)... anybody have any ideas how to delete or empty out the array but keep the session active ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $HTTP_SESSION_VARS still holds original values even after unset?
$HTTP_SESSION_VARS = array(); doesnt work... it kills the session and forces me to login as soon as the array is empty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Umm.. Use $_SESSION for that.. wish i could but it wont work for the server that its going to run onthey still use php4.0.4pl1 believe it or not -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] \n is not working!
--- Labunski [EMAIL PROTECTED] wrote: Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to the document one|two|three\n Actually, that's not true. Assuming: $post_0 = 'one'; $post_1 = 'two'; $post_2 = 'three'; The code you posted will store the following in $new_topic: one|two|$post_2\n While others were able to answer your question anyway (anything within single quotes is interpreted literally), this demonstrates how providing misinformation can make it very difficult for people to help you. As a courtesy to those who spend their time answering questions, please test your code. It really only takes a moment of your time. Thanks. :-) Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?
Something else in your code is messing you up if you cannot change the value after setting it in the first place. This happens all the time in my code as my client makes decisions along the way. Try a small test creating a session variable, displaying it, changing it, and redisplaying it. If it does not show the change, post the test code so we might be able to tell why it fails. Provided you can change the variable, you should be able to create a loop that sets all the variables to or some base values etc. Larry -Original Message- From: Andy B [mailto:[EMAIL PROTECTED] Sent: Sunday, April 04, 2004 6:03 PM To: [EMAIL PROTECTED] Subject: [PHP] $HTTP_SESSION_VARS still holds original values even after unset? how would you empty all the contents of $HTTP_SESSION_VARS when you dont need them anymore but still keep the current session running? the problem seems to be that when i try to fill them with something else (dont need the original values anymore) but need new ones without destroying the session itself they wont fill with new things. unset($HTTP_SESSION_VARS); does nothing to help at all because they still have the same values that they were originally filled with (and not to mention they are still in the session)... anybody have any ideas how to delete or empty out the array but keep the session active ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Use the session_* functions then.. -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com Andy B [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Umm.. Use $_SESSION for that.. wish i could but it wont work for the server that its going to run onthey still use php4.0.4pl1 believe it or not -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php as default value in html
When someone pulls up a form and fills it out, they subsequently submit that form. When submitting a form your browser creates a one on one connection with the server where the server inputs the data from your form before or after the next person without mixing the two. (no matter if the two submitted simultaneously it know who is who) -Original Message- From: Andy B [mailto:[EMAIL PROTECTED] Sent: Sunday, April 04, 2004 1:35 PM To: [EMAIL PROTECTED] Subject: [PHP] php as default value in 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. 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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_SESSION_VARS still holds original values even after unset?
On 4 Apr 2004 Andy B wrote: how would you empty all the contents of $HTTP_SESSION_VARS when you dont need them anymore but still keep the current session running? See http://www.php.net/manual/en/function.session-unset.php. That is exactly what it does. That page also explains why unset() is not the right way to go. -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Use the session_* functions then.. still does nothing at all or it does the same as session_destroy. and that forces a user back to the login screen right in the middle of an sql insert/update -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [solved][PHP] php as default value in html
When someone pulls up a form and fills it out, they subsequently submit that form. When submitting a form your browser creates a one on one connection with the server where the server inputs the data from your form before or after the next person without mixing the two. (no matter if the two submitted simultaneously it know who is who) didnt know that tnx for the info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Andy B wrote: Use the session_* functions then.. still does nothing at all or it does the same as session_destroy. and that forces a user back to the login screen right in the middle of an sql insert/update Okay, start showing some code so we can see wtf is going on. Constantly posting back nope, doesn't work is just going to have us grasping at straws again and again. Is register globals on or off? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting array of objects
Hi there, Supposed I have an array of objects, like: $this[$i]-property1 $this[$i]-property2 is there any 'cheap' way to sort the array according to the values of property1? The only way I thought I would be able to accomplish this is to transform this into an assoc array or something like it and then sort it ... I found plenty of functions for dealing with plain arrays, but nothing - easy to use - for this. Am I just blind or do I finally have to write a function doing that on my own? And if so - anyone who had to do this before and come up with a really fast solution (I guess my attempts would work - but not very efficient) Thanks Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
Okay, start showing some code so we can see wtf is going on. Constantly posting back nope, doesn't work is just going to have us grasping at straws again and again. Is register globals on or off? register_globals=off here is the code that gives me problems: files are attached (if allowed) let me know if the attached files didnt make it through and i will post it in the body of the message...the code is quite huge chunck of stuff... file guestbook_add.php: is a form used for admins to insert a guestbook entry. it is linked from a admin page using session_start(); at the top of the admin main page. the button that links to this page code is: input class=button type=button value=add guestbook listing accesskey=3 onclick=window.location='guestbook_add.php'; onkeypress=window.location='guestbook_add.php'; after filling out the form and submitting it to the file called guestbook_review2.php it sets all of the $HTTP_SESSION_VARS[] vars to the inital form submitted values and shows them on the page. after they hit the continue button it checks for default/required vars and then inserts to the db in the file called guestbook_save.php.. after a successful insert it takes them back to the main admin page. the next time i hit the add guestbook listing from the main screen, fill out the form with different values and submit it all the $HTTP_SESSION_VARS have the same values as the last add sequence... its interesting...(i know the code may be sloppy but...im starting out with complex stuff and was forced on a super fast turn around on it)... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
On 4 Apr 2004 Andy B wrote: the next time i hit the add guestbook listing from the main screen, fill out the form with different values and submit it all the $HTTP_SESSION_VARS have the same values as the last add sequence... There are two problems there. First, your session data is not getting cleared. Second, it is not getting reset with the new values. For the former, in guestbook_save.php you can simply do a session_unset (if you really want to clear all of them). However this does not handle an abnormals equence -- for example someone hits Back in the middle of the process. I don't understand why they are not getting set properly the second time around. It could be a condition in your code. I'd have to see the code to have an idea. Try stripping the code WAY down so you have a test_add.php with a 1- field form, and a test_review.php that displays that data and saves it in a session variable, and test_save.php that just displays what it receives in the session variables. If that still fails, post the code. If not, your problem lies in the difference between that and the original code. -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
There are two problems there. First, your session data is not getting cleared. Second, it is not getting reset with the new values. For the former, in guestbook_save.php you can simply do a session_unset (if you really want to clear all of them). However this does not handle an abnormals equence -- for example someone hits Back in the middle of the process. I don't understand why they are not getting set properly the second time around. It could be a condition in your code. I'd have to see the code to have an idea. Try stripping the code WAY down so you have a test_add.php with a 1- field form, and a test_review.php that displays that data and saves it in a session variable, and test_save.php that just displays what it receives in the session variables. If that still fails, post the code. If not, your problem lies in the difference between that and the original code. ok heres the code in the message body: hope it fits note: im in the middle of porting it from new code to old code so some $_SESSION vars might show themselves time to time... [guestbook_add.php: form to fill out:linked from admin.php(not shown)] ? session_start(); if(!empty($_SESSION['username'])){ ? !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/transitional.dtd; html head titleAdd GuestBook Entry/title LINK rel=stylesheet href=style/rnjresort.php type=text/css /head body h1Add guestbook entry/h1 div table tr td NOTE: when filling out this form, make sure you fill the date out in the format mmddhhmmss. example: 2004040100 would be april 1 2004 12 midnight. To insert the current date leave the date blank. /td /tr /table /div div form method=post action=guestbook_review2.php table summary=Below is the entire form for adding your entry to the guestbook tr td label for=id-dateDate: /labelinput type=text name=date accesskey=a label for=id-nameName:/label input type=text name=name accesskey=n id=id-name /td td label for=id-emailYour Email address:/label input type=text name=email accesskey=e id=id-email /td /tr tr td label for=id-website Your URL:/label input type=text name=website accesskey=w id=id-website /td td label for=id-referred How did you hear about us?/label input type=text name=referred accesskey=d id=id-referred /td /tr tr td label for=id-comments Comments:/label textarea name=comments rows=5 cols=40 accesskey=c id=id-comments/textarea center input class=button type=submit value=submit accesskey=s input class=button type=reset value=start over accesskey=o /center /td /tr /table /form /div img src=http://www.w3.org/Icons/valid-html401; alt=Valid HTML 4.01! height=31 width=88 /body /html ?} else { header(location: login.html);}? [end of guestbook_add.php] then the form gets submitted to the next one: [guestbook_review2: give users the choice to back out before its too late and type in again] ?php session_start(); $_SESSION['date']=$date; $HTTP_SESSION_VARS['name']=$name; $HTTP_SESSION_VARS['email']=$email; $HTTP_SESSION_VARS['website']=$website; $HTTP_SESSION_VARS['referred']=$referred; $HTTP_SESSION_VARS['comments']=$comments; if(!empty($_SESSION['username'])){ ? !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/transitional.dtd; html head titleConfirm your post/title LINK rel=stylesheet href=style/rnjresort.php type=text/css /head body h1Confirm your post/h1 div table summary=Instructions for Confirming your post tr td pReview your information below. If you need to return to the form to change anything just click the start over button. If you are satisfied with your listing click the continue button./p /td /tr /table /div div table summary=Your posting information is below tr td Name: ?php echo $HTTP_SESSION_VARS[name];? /td /tr ?php if(!empty($HTTP_SESSION_VARS['email'])){? tr td ?php echo a href=\mailto:$HTTP_SESSION_VARS[email]\;My Email address/a ($HTTP_SESSION_VARS[email]);? /td /tr ?php }else{echo ;} if(!empty($HTTP_SESSION_VARS['website'])) {? tr td ?php echo a href=\http://$HTTP_SESSION_VARS[website]\;My web site/a ($HTTP_SESSION_VARS[website]);? /td /tr ?php } else {echo ;} if(!empty($HTTP_SESSION_VARS['referred'])){? tr td Where did you hear about us?br ?php echo $HTTP_SESSION_VARS[referred];? /td /tr ?php } else { echo ;}? tr td Comments:br ?php echo $HTTP_SESSION_VARS[comments];? /td /tr /table /div div table tr td input class=button type=button value=continue accesskey=c onclick=window.location='guestbook_save.php'; onkeypress=window.location='guestbook_save.php'; /td td input class=button type=button value=start over accesskey=s onclick=window.location='admin.php'; onkeypress=window.location='admin.php'; /td /tr /table /div img src=http://www.w3.org/Icons/valid-html401; alt=Valid HTML 4.01! height=31 width=88 /body /html ?}else{ header(location: login.html);}? [end of guestbook_review2.php] if they hit the continue button it takes them to guestbook_save.php, saves to db and returns to admin.php... [guestbook_save.php: saves and returns
Re: [PHP] session_exist() ?? Can this be done?
* Thus wrote Monty ([EMAIL PROTECTED]): 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. Yes. But you dont *need* to destroy() the session. btw, your Location header should be like this: Location: http://domain.com/login.php 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? A cookie can easiy be sent without ever being assigned one. Doing this will open a large hole in your security model. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: session_exist() ?? Can this be done?
Monty writes: 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? I've been doing exactly that, it works great. I use, $sessid = $_COOKIE[PHPSESSID]; if ( isset($sessid) ) { session_start(); } I use 'if( isset($sessid) )' in the rest of the code if there are things that should only be done if there is a session. Only my login authentication page starts the session if there isn't a cookie. Of course, for security you ought to verify the session after starting it, and unset $sessid (and destroy_session() ) if something screwy is going on. The reason I set things up like this is so that users are not bothered with cookies unless they need to be. I use cookies for the administration side of the site, but casual users don't need a session, so why should they have a cookie? -- I'm a not a proponent of passing around useless data :). Any other suggestions are appreciated! Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aaron VonderHaar ([EMAIL PROTECTED]) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expressions
* Thus wrote Matt Palermo ([EMAIL PROTECTED]): 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 = pbrstrongbiu; // 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 You might wont to try a look behind assertion: / (?=p|br) [^]+ /x Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting array of objects
Hi, Monday, April 5, 2004, 1:03:17 PM, you wrote: RH Hi there, RH Supposed I have an array of objects, like: $this[$i]-property1 $this[$i]-property2 RH is there any 'cheap' way to sort the array according to the values of RH property1? RH The only way I thought I would be able to accomplish this is to RH transform this into an assoc array or something like it and then sort RH it ... RH I found plenty of functions for dealing with plain arrays, but nothing RH - easy to use - for this. Am I just blind or do I finally have to write RH a function doing that on my own? RH And if so - anyone who had to do this before and come up with a really RH fast solution (I guess my attempts would work - but not very efficient) RH Thanks RH Richard This should do what you want, though I think your example is confusing... ?php function cmp_ascending($k1, $k2) { global $a; if ($a[$k1]-property == $a[$k2]-property) { return 0; } return ($a[$k1]-property $a[$k2]-property) ? -1 : 1; } class test{ var $property = 0; function test($val){ $this-property = $val; } } $a[] = new test(7); $a[] = new test(1); $a[] = new test(5); $a[] = new test(3); print_r($a); uksort($a, cmp_ascending); while (list($key, $value) = each($a)) { echo $key: $value-property br; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Weird variable issue encountered... help needed!
This problem only seems to be happening on one of the virtual hosts on this system, and I cannot seem to figure out just what it is. I have a simple form posting to search.php, with a text input field, with a name of 'search'. And since this site is an internal site, register globals are on, as we are not worried about anyone misuing any of the variables in use. In any even, this problem was noticed about a week ago, and it did not exist before. After inputting some text into the search box, in this example, 'var', sans quotes, and i hit submit... on the next page, I am just having it return just $search for testing, and, it comes back sporadically with: 'var', but most of the time, it comes back with: var^!#ndda/form or var4194092d098240928d12ed or var#c0c0c0 or varput type=text etc. etc. it seems soemthing is somehow corrupting the variables, and I cannot seem to figure out what it might be. This has been working fine until about the past week, and I cannot think of any major changes that may have happened within the past week that could have caused this... and as I mentioned above, it only seems to be this one virtual host. And ai also compared with backups of all of y included files at the beginnings and ends of each script from before this problem started happening, and I can see no major changes in any of them. And, this is happening around all php scripts on the site... I am running 4.3.4, with apache 2, FreeBSD 4.8, and the data is all stored on a vinum partition. The server has been rebooted, a fresh install of php... tried setting output buffering on and flushing it at the end of the script(s), however, they seem to get hacked up when doing that, so I stay away from that band-aid fix...I am using sessions as well, as a few scripts within the site store session variables... and also using SMBAuth to do authentication from our domain controller... I've been pulling out my hair for 4 days straight on this issue, and I am all out of ideas, any help would be *GREATLY* appreciated! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_SESSION_VARS still holds original values even after unset?
* Thus wrote Andy B ([EMAIL PROTECTED]): ?php session_start(); $_SESSION['date']=$date; $HTTP_SESSION_VARS['name']=$name; $HTTP_SESSION_VARS['email']=$email; $HTTP_SESSION_VARS['website']=$website; $HTTP_SESSION_VARS['referred']=$referred; $HTTP_SESSION_VARS['comments']=$comments; You should probably read http:/php.net/session more carefully. snip oodles of unread code Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php