php-general Digest 14 May 2008 08:46:23 -0000 Issue 5458
php-general Digest 14 May 2008 08:46:23 - Issue 5458 Topics (messages 274267 through 274289): Re: validating textarea using php 274267 by: Iv Ray 274275 by: Shawn McKenzie 274276 by: Richard Heyes 274277 by: Dotan Cohen 274281 by: Robert Cummings 274286 by: Chris W Re: A Little Something. 274268 by: Thiago Pojda fsockopen on ssl:// 274269 by: bob pilly 274271 by: bob pilly 274285 by: Manuel Lemos Re: $_SESSION NOT WORKING 274270 by: Daniel Brown 274272 by: Thiago Pojda 274273 by: Balpo 274274 by: Jens Himmelrath Re: tracking Mials Which were bounced. 274278 by: Chris 274279 by: mike Re: Good XML Parser 274280 by: Waynn Lue 274284 by: Nathan Nobbe Re: $_SESSION NOT WORKING --SOLVED 274282 by: Balpo Re: Can Safari 3 be forced to cache a large jpeg with PHP headers? 274283 by: Chris 274289 by: Colin Guthrie validating using php 274287 by: Sudhakar form validation using php 274288 by: Sudhakar 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--- Sudhakar wrote: i do not want this to happen, if a user simply hits the spacebar and does not type anything i should be able to display an alert message. From usability point of view such check will, in many cases, generate annoyance, and bring nothing. If I do not want to enter anything, and you error me to enter something, I'll do like this - asdlöfjasdpoöfja spdfj as fsdaölkjf And your check is dead. If you want something, you will get something. It is hard (from usability point of view) to validate textarea to that extent, and especially - to get reasonable answers... I work for a scientific database, where all content providers are very intelligent, well educated and very disciplined, and the content editors still have hard time thinking how to guide the content provider so that they provide reasonable input. Your problem is not so much php related, but a usability and editorial one. Iv ---End Message--- ---BeginMessage--- Dan Joseph wrote: On Tue, May 13, 2008 at 12:02 PM, Usamah al-Amin [EMAIL PROTECTED] wrote: if(chop($comments) == ) { ... } //hope that helps. Well, chop() is an alias of rtrim(), so it won't work here for, say, trimming control characters at the end of the string like line feeds. trim() is actually the best bit here. Regards, Usamah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There is always using substr to mimic the Perl chomp() function. Look thru the comments on http://us.php.net/chop and you'll find a few different ways of doing it. Or just use trim() :-) -Shawn ---End Message--- ---BeginMessage--- Jim Lucas wrote: Richard Heyes wrote: Also you can use short tags (popular...) to make the HTML more readable. Eg: textarea name=comments cols=26 rows=3 id=comments ?=htmlspecialchars($comments)? /textarea It also makes the code less portable. If that's even a concern. A lot of the time, it's not. -- Richard Heyes ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ ---End Message--- ---BeginMessage--- 2008/5/14 Richard Heyes [EMAIL PROTECTED]: It also makes the code less portable. If that's even a concern. A lot of the time, it's not. A lot of people think that, until their host upgrades php. Have you seen how many things are being removed for php6? Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? ---End Message--- ---BeginMessage--- On Wed, 2008-05-14 at 00:32 +0300, Dotan Cohen wrote: 2008/5/14 Richard Heyes [EMAIL PROTECTED]: It also makes the code less portable. If that's even a concern. A lot of the time, it's not. A lot of people think that, until their host upgrades php. Have you seen how many things are being removed for php6? PHP6??? Pshaw... PHP5 just came out the other week ;D Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- Dotan Cohen wrote: 2008/5/14 Richard Heyes [EMAIL PROTECTED]: It also makes the code less portable. If that's even a concern. A lot of the time, it's not. A lot of people think that, until their host upgrades php. Have you seen how many things are being removed for php6? From the article I read, that isn't one of them. -- Chris W KE5GIX Protect your digital freedom and
[PHP] form validation using php
hi i need to validate a field in a form where a user enters their lodgement number as part of a registration form. this lodgement number can have letters, numbers, spaces and special characters. i do not know exactly what those special characters are, so do i have to define the type of special characters and validate accordingly. presently my php code for validating the lodgement number is $lodgementtf = $_POST[lodgementtf]; if($lodgementtf == || !preg_match(/^[a-zA-Z0-9_ ]+$/, $lodgementtf) ) { echo display error message: } i also have another way of validating if($lodgementnumber == || !preg_match(/^[a-zA-Z0-9_ [EMAIL PROTECTED]*()]+$/, $lodgementnumber) ) does this mean that the special characters can only be = a space AND [EMAIL PROTECTED]*() and no other special characters. please advice. thanks.
[PHP] Re: Can Safari 3 be forced to cache a large jpeg with PHP headers?
Chris wrote: Rob Gould wrote: I am creating a touch-screen kiosk application, using a full-screen version of Safari 3.1, and was wondering if there's a way I can force Safari to cache a large background image JPEG. What I'm finding is that Safari 3 will sometimes cache my large 1.1 MB background image (1680x1050), and display perfectly fine, but on occassion Safari 3 will think about the cache and Flash the screen white for a millisecond and then draw the screen. Firefox doesn't seem to have this problem, so unfortunately this is a Safari 3 only issue. I really only want to cache this ONE image - - - nothing else. Is that possible? How are you sending it? through a php script or through a normal html tag? If it's through a php script, try setting a far-future expiry header. Yeah PHP can send out appropriate headers to tell the browser to cache the content delivered. You just use header() with appropriate Cache-Control and Pragma etc. headers. There are lots of good resources out there on how to do this so just google around now you know the concept :) Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
A lot of people think that Can't fault them. until their host upgrades php. Any host that upgrades the PHP version (a major upgrade considering it would be 5 - 6) without notifying Customers isn't a very good hosting company, and you really should change to a better one (Rackspace are good). Even 1and1 don't do that and they're pants (IMO). Plus you need to consider how long they would take to use PHP6 exclusively - my guess it would be at least a year; probably longer. Have you seen how many things are being removed for php6? Nope. Why? It's not even out yet in beta and therefore not worth my time considering. ISTR having read something about a 5.3 release, which I read would have namespaces. That needs consideration before any PHP6 release. -- Richard Heyes ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Scripts slowing down?
Per Jessen a écrit : René Leboeuf wrote: I'm running a large website. I have some mailing scripts that take days to run. I noticed these scripts slow down with time, sometimes going to an almost complete stop (no mail sent for several minutes). The source code is trivial and can't contain a loop. I monitored the memory usage and couldn't find a memory leak. Using APD, most of the time is reported to be spent in the fgets() function (script waiting for a sendmail reply). But sendmail still replies swiftly when this problem occurs. It sounds like you are using SMTP to talk directly to your sendmail daemon? Yes, SMTP code is provided by phpmailer. Restarting sendmail has no effect on these scripts. Restarting the scripts makes them run like hell for some hours, until the problem rises again. So, if there is no loop in your script, what _does_ it contain? Oops... The code can't contain a INFINITE loop... Of course, there is a loop through all the members! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Scripts slowing down?
Peter Ford a écrit : René Leboeuf wrote: Hi. I'm running a large website. I have some mailing scripts that take days to run. I noticed these scripts slow down with time, sometimes going to an almost complete stop (no mail sent for several minutes). The source code is trivial and can't contain a loop. I monitored the memory usage and couldn't find a memory leak. Using APD, most of the time is reported to be spent in the fgets() function (script waiting for a sendmail reply). But sendmail still replies swiftly when this problem occurs. By this, I guesss you mean that other connections to sendmail reply swiftly: so the server is not just jamming up completely and refusing requests ? Right, I can still create new connections that perform well, with no noticeable delay when talking to sendmail. The mail queue doesn't grow. It might depend on the exact implementation of 'sendmail': for example, the Courier mail system which I use replaces the program 'sendmail' with it's own binary to do the job. Courier also has a 'tar-pitting' feature which is triggered by behaviour that looks like a spammer is trying to relay stuff: it atificially slows the response to the send requests if there is an unreasonably high rate of requests coming from a given source. At least that's how I understand the feature to work. Other mail system may implement a similar feature - it might just be that your mailing script looks like a spam engine to the mail server. I disabled all the limiting features of sendmail without result (QUEUE_LA, REFUSE_LA, confBAD_RCPT_THROTTLE...) The user sending emails is trusted by sendmail, and the sending program is located on the sendmail machine. Restarting sendmail has no effect on these scripts. Restarting the scripts makes them run like hell for some hours, until the problem rises again. I'm using PHP 5.2.5 I don't know where to look next for the source of this problem... I think you need to provide some more detail - you could start by explaining what method you use to send the messages. The next thing to do is to look at the mail logs and see if there are any messages written around the time that yourt script runs. Don't always assume that it is your code that is wrong (that's what managers are for) Mail is sent via PHPMailer. PHPMailer offers to send mail via PHP's mail() function, or by calling the sendmail program or using SMTP. SMTP may use persistent connections or not. All these modes were tested and they all slow down after a while. I didn't notice anything special in the maillog or other logs on the machine. Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
2008/5/14 Chris W [EMAIL PROTECTED]: A lot of people think that, until their host upgrades php. Have you seen how many things are being removed for php6? From the article I read, that isn't one of them. That issue specifically, no. However, portable code is desirable even if your code is confined to a single machine. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
[PHP] how do I stop Firefox doing a conditional get?
All, not really PHP related, but I figured someone here would already have solved this problem. I've got a page with a single img. I change the src attribute dynamically using javascript. Although the images being served all have long expiry times, Firefox still does a conditional get to which apache says 304 as it should. The issue is - I'd like this page to appear to be as real time as possible, and the occasional delay caused by the conditional get is a nuisance. My images are clearly cached, so how do I prevent Firefox from doing the conditional get ? There must be some HTTP header I can use. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I stop Firefox doing a conditional get?
2008/5/14 Per Jessen [EMAIL PROTECTED]: All, not really PHP related, but I figured someone here would already have solved this problem. I've got a page with a single img. I change the src attribute dynamically using javascript. Although the images being served all have long expiry times, Firefox still does a conditional get to which apache says 304 as it should. The issue is - I'd like this page to appear to be as real time as possible, and the occasional delay caused by the conditional get is a nuisance. My images are clearly cached, so how do I prevent Firefox from doing the conditional get ? There must be some HTTP header I can use. You can use either or both of 'Expires' or 'Cache-Control' -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
Thank you all. I have made it working excellent for me now. The solution is here: http://phparch.cn On Tue, May 13, 2008 at 1:34 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2008-05-13 at 01:27 -0400, Robert Cummings wrote: On Tue, 2008-05-13 at 12:28 +0800, Shelley wrote: Maybe I didn't use that tidy correctly. I don't want html, head, body things. Just parsed string. So strip them... ?php // ... tidy_parse_string( $html ); tidy_clean_repair(); $html = tidy_get_output(); $html = preg_replace( '#^.*body#Uis', '', $html ) $html = preg_replace( '#/body#Uis', '', $html ) //... ? Whoops... noticed some bugs there :B ?php $html = preg_replace( '#^.*body#Uis', '', $html ); $html = preg_replace( '#/body.*$#Uis', '', $html ); ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- Regards, Shelley
Re: [PHP] how do I stop Firefox doing a conditional get?
Robin Vickery wrote: 2008/5/14 Per Jessen [EMAIL PROTECTED]: The issue is - I'd like this page to appear to be as real time as possible, and the occasional delay caused by the conditional get is a nuisance. My images are clearly cached, so how do I prevent Firefox from doing the conditional get ? There must be some HTTP header I can use. You can use either or both of 'Expires' or 'Cache-Control' I've just now added 'Cache-Control' - I was already using 'Expires', but that wasn't sufficient. Thanks. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good XML Parser
Thank you all. Maybe you didn't get what I meant. I have made it working excellent for me. I have summarized the solution: http://phparch.cn On Wed, May 14, 2008 at 11:10 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Tue, May 13, 2008 at 7:29 PM, Waynn Lue [EMAIL PROTECTED] wrote: Ok, thanks so much for the help. I went with DOM-parsing to begin with, I'll explore XPath + SimpleXML later. just fyi, youre likely to get more bang for your buck starting off w/ SimpleXML. DOM is a successor to DOMXML from php4. its a bulky, yet powerful interface into the DOM. SimpleXML is also a DOM parser, however the interface is simpler in exchange for less power. the good news is in php5 you can switch back and for between DOM and SimpleXML easily at virtually no cost. my modo in php5 is to use SimpleXML unless there is a real need for DOM, and in that case most likey, you can get away w/ converting to DOM at runtime (again very little cost there) and doing a few operations, then carrying on w/ SimpleXML. -nathan -- Regards, Shelley
Re: [PHP] Re: Scripts slowing down?
René Leboeuf wrote: The user sending emails is trusted by sendmail, and the sending program is located on the sendmail machine. No need to use SMTP then. You should just be calling sendmail to drop the emails into the queue. And that should not be slowing down. Mail is sent via PHPMailer. PHPMailer offers to send mail via PHP's mail() function, or by calling the sendmail program or using SMTP. SMTP may use persistent connections or not. All these modes were tested and they all slow down after a while. They _all_ slow down after a while? How many emails are you sending in this way? It's easily tested. Just generate a script with 1 calls to the mail() function (send to [EMAIL PROTECTED] with N = random number). If that goes through without slowing down, mail() and your sendmail daemon are not to blame. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to get user IP address
Hi, How to get user IP address in a PHP server? Thank you. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get user IP address
On Wed, May 14, 2008 at 8:06 AM, hce [EMAIL PROTECTED] wrote: Hi, How to get user IP address in a PHP server? Thank you. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $_SERVER[REMOTE_ADDR] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to get user IP address
-Original Message- From: hce [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 14, 2008 2:07 PM To: php-general@lists.php.net Subject: [PHP] How to get user IP address Hi, How to get user IP address in a PHP server? Thank you. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi $ip = $_SERVER['REMOTE_ADDR']; Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
2008/5/14 Richard Heyes [EMAIL PROTECTED]: Any host that upgrades the PHP version (a major upgrade considering it would be 5 - 6) without notifying Customers isn't a very good hosting company, and you really should change to a better one (Rackspace are good). Even 1and1 don't do that and they're pants (IMO). It does not matter if the customer was notified. Even if he is notified, he needs to update his code. Plus you need to consider how long they would take to use PHP6 exclusively - my guess it would be at least a year; probably longer. A year is nothing! I have projects from 7 years ago that I know I need to update when I get around to it. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Re: [PHP] validating textarea using php
Dotan Cohen wrote: 2008/5/14 Richard Heyes [EMAIL PROTECTED]: Any host that upgrades the PHP version (a major upgrade considering it would be 5 - 6) without notifying Customers isn't a very good hosting company, and you really should change to a better one (Rackspace are good). Even 1and1 don't do that and they're pants (IMO). It does not matter if the customer was notified. Even if he is notified, he needs to update his code. That really should be expected. You can't expect something to last forever without tweaking it on occassion. And in the case of going from PHP 5 - 6, the tweaking required may well be major, becxcause it's a major version change. Plus you need to consider how long they would take to use PHP6 exclusively - my guess it would be at least a year; probably longer. A year is nothing! I have projects from 7 years ago that I know I need to update when I get around to it. Well when you get around to it makes it sound as though it's not exactly important. -- Richard Heyes ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating using php
Sudhakar wrote: if( strlen(trim($name) == 0 ) || !preg_match('/^[a-zA-Z ]+$/x', $name) ) { $error.=Name is blank or has special characters ; } You have messed up the brackets. This - strlen(trim($name) == 0 ) should be - strlen(trim($name)) == 0 Then the script does what you want. Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RES: $_SESSION NOT WORKING --SOLVED
I never heard of such extension. You should report this bug :) And you're welcome ;) Atenciosamente, www.softpartech.com.br Thiago Henrique Pojda Desenvolvimento Web +55 41 3033-7676 [EMAIL PROTECTED] Excelência em Softwares Financeiros -Mensagem original- De: Balpo [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 13 de maio de 2008 23:09 Para: Thiago Pojda Cc: 'Daniel Brown'; 'PHP General' Assunto: Re: $_SESSION NOT WORKING --SOLVED Prioridade: Alta After an all-evening debugging I found out what the problem is. Why? Please don't ask. I have no idea. The problem was php's extension php-colorer How I got to the problem. Eliminating every extension until I got the *bad* one. Thank you: Daniel, Thiago, Jens, Verny Dmitri for your concern. Balpo Thiago Pojda wrote: Actually his question was about why session.auto_start is not working on Linux, I almost answered what you both did :) Atenciosamente, www.softpartech.com.br Thiago Henrique Pojda Desenvolvimento Web +55 41 3033-7676 [EMAIL PROTECTED] Excelência em Softwares Financeiros -Mensagem original- De: Daniel Brown [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 13 de maio de 2008 16:43 Para: Balpo Cc: PHP General Assunto: Re: [PHP] $_SESSION NOT WORKING On Tue, May 13, 2008 at 2:38 PM, Balpo [EMAIL PROTECTED] wrote: Hi everyone, I'm having a problem moving my code to a linux computer. I won't post the whole code here, but an accurate example that reproduces exactly the error. [snip!] Modify 2.php as follows: ?php session_start(); print_r($_SESSION); ? You only missed instantiating the session. The rest looks good. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacing accented characters by non-accented characters
On Tue, May 13, 2008 at 8:39 AM, Per Jessen [EMAIL PROTECTED] wrote: Yannick Warnier wrote: That would probably work out if it wasn't too dependent on the locales to work. I'm developing an open-source product which could end up on a server without the locales for French but be used by some French people, which would make (as far as I can get out of one comment from Richie in the PHP manual) the transliteration somewhat wrong. With the kind of rough conversion/transformation you're doing, is the locale really very important anyway? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Why should the server folder name matter? Make it a hash and store the user provided name in a db. Then when presenting the data to the user just show the user provided name as the folder name. This would also handle multiple users trying to use the same folder name for their stuff. -- Bastien Cat, the other other white meat
Re: [PHP] using variable in php form before the form is POSTed
On Tue, May 13, 2008 at 9:02 AM, tedd [EMAIL PROTECTED] wrote: At 2:44 PM -0700 5/12/08, milt wrote: I have a form that will be filled in by the user, I want to have access to the content of one of the fields in that form, in order to fill in an another variable that is not part of the form. this variable is used by a routine when the form is posted. Question - is the $_post[field name] availble before the submit button is pushed, or is there another way to get the contents of the field? thanks, Milt Use hidden, such as: input type=hidden name=step value=1 After the form is posted, $_POST['step'] will = 1. I use this technique all the time so that I can use the same script to present different forms based upon which step in the form processing the user is on (i.e., step=1, step=2, step=3 and so on). Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could get funky and send that data bit via AJAX to the server to be preprocessed. But likely handling the data bit as the first step on submission, is gonna be simpler and faster to do -- Bastien Cat, the other other white meat
[PHP] Re: $_SESSION NOT WORKING --SOLVED
On Wed, May 14, 2008 at 9:47 AM, Thiago Pojda [EMAIL PROTECTED] wrote: I never heard of such extension. You should report this bug :) And you're welcome ;) I agree, Balpo. You should submit the details of your findings at http://bugs.php.net/ and let us check it out. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
On Wed, 2008-05-14 at 18:50 +0800, Shelley wrote: Thank you all. I have made it working excellent for me now. The solution is here: http://phparch.cn Ah, there you go... show_body_only. I was too lazy when I used tidy a while back to look through every option, so a quick preg stripping sufficed :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Safe mode story
On May 11, 2008, at 12:06 AM, admin wrote: [snip!] Safe mode has _got_ to be there for some good reason. Read on about PHP6 http://www.ibm.com/developerworks/opensource/library/os-php-future/?ca=dgr-lnxw01PHP-Future Scroll down to where the title is Things removed - notice that 'safe_mode' is listed. It may have been put in originally for a good reason, but since then deprecated. HTH, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to get user IP address
hce [EMAIL PROTECTED] wrote: Hi, How to get user IP address in a PHP server? Thank you. Jim RTFM, Google, PHP.net are GREAT resources What part of the code are you having an issue with? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert query result to array
On May 13, 2008, at 6:35 AM, Sanjeev N wrote: fetchAll() works if php version is greater than 5. As Wang suggested, we should write our own function. its easy... i have done so many times for larger database. Store earch rows of the resultset in the array (multidimensional ie. 2). and then work on the array using the loops conditions $query = select * from tablename; $result = mysql_query($query); while($arr = somefunction($result)){ $resultarray[] = $arr; } Hope it works! Here's a way to get a 2-dimensional array of results that you can loop through when needed. Don't know if it's what you need, but it's useful when you have more than 1 row as a result. ?php function fetchObjectsAsArray ($sql) { $result = mysql_query ($sql); if (!$obj['count'] = mysql_num_rows ($result)) { return null; } while ($rows[] = mysql_fetch_array ($result)) { } foreach ($rows as $array) { foreach ($array as $field = $value) { $obj[$field][] = $value; } } return $obj; } ? Have fun! ~Phil On 5/13/08, Forcey [EMAIL PROTECTED] wrote: I guess PDOStatement::fetchAll() should work? see http://www.php.net/manual/en/pdostatement.fetchall.php for details. - Forcey On Tue, May 13, 2008 at 9:55 AM, Yi Wang [EMAIL PROTECTED] wrote: I think flance's meaning is whether there is a build-in function that can convert the result set to an array. The short answer is: do it yourself. On 5/12/08, Stut [EMAIL PROTECTED] wrote: On 12 May 2008, at 15:56, It flance wrote: is there any function that can convert the result of query to an associative array? what i want is the following: $query = select * from tablename; $result = mysql_query($query); $arr = somefunction($result); where $arr should be an assoiative array whose indices have the same name as the fields names of table tablename. http://php.net/mysql_fetch_assoc Please please please read the manual: http://php.net/mysql -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote: On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. That depends... if I'm the webmaster and I want to input arbitrary HTML, then htmlpurifier is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are *standards compliant.* Set it up how you want it. -- /James On Wed, May 14, 2008 at 4:38 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote: On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. That depends... if I'm the webmaster and I want to input arbitrary HTML, then htmlpurifier is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP
[PHP] Question about setting up FTP Upload and using the FTP suite...
Hello all, I am just trying to see if I can connect up with my internal FTP server from our website. The server is accessible from the outside world, as we can log in using a client, etc. I am not really sure how to troubleshoot this, but below is the script that I have. I found it on the net (and can't remember where), and changed it a bit for my needs. It would appear that the call to 'ftp_connect' is where it fails. I tried this with both a URL as well as the actual IP address, both error at the same place with the same error. Is there a way to get an actual error message that is a bit more explanatory as to what is happening? ?php $ftp_server = FTP.URL; $ftp_user = USER; $ftp_pass = PASSWORD; echo Trying to connect with $ftp_server using $ftp_user, $ftp_pass; // set up a connection or die $conn_id = ftp_connect($ftp_server) or die(Couldn't connect to $ftp_server); if ($conn_id) { echo Logging in as $ftp_user, $ftp_pass.; $login = ftp_login($conn_id, $ftp_user, $ftp_pass); // try to login if ($login) { echo Connected as [EMAIL PROTECTED]; } else { echo Couldn't connect as $ftp_user\n; } // close the connection ftp_close($conn_id); } else { echo Could not establish connection; } ? Thanks for your help, Mike -- Peace may sound simple—one beautiful word— but it requires everything we have, every quality, every strength, every dream, every high ideal. —Yehudi Menuhin (1916–1999), musician
Re: [PHP] php 5.2.6 make failure
Steven Perez wrote: ext/openssl/openssl.o: In function `zif_openssl_sign': /home/sperez/php-5.2.6/ext/openssl/openssl.c:3525: undefined reference to `EVP_MD_CTX_cleanup' ext/openssl/openssl.o: In function `zif_openssl_verify': /home/sperez/php-5.2.6/ext/openssl/openssl.c:3565: undefined reference to `EVP_MD_CTX_cleanup' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 Does your openssl include files match your openssl library? The version of openssl I am using is the following: # ./openssl version OpenSSL 0.9.6l 04 Nov 2003 That's quite old. I would almost certainly update that. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
On Wed, May 14, 2008 at 11:38 AM, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote: On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. That depends... if I'm the webmaster and I want to input arbitrary HTML, then htmlpurifier is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP OP said users. Strip tags doesn't bother with tag attributes so that is a security hole. Any regex type solution will encounter the same set of issues. Htmlpurifier actually strips down and re-builds your html from the ground against a nice whitelist filtering system that you can customize to your needs. No nasty tags/attributes will get through unless you want them to. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Scottish Devs
Afternoon, Just had word of a freelance project on for the next 4 weeks, start immediately, basically 1 static site (design already done) - an easy job, and 1 static site + a bit of PHP, breadcrumb, site search - it's £200 GBP a day (so about £4k for the next 4 weeks), ideally for somebody who can pop into edinburgh to meet the client/agency and maybe work on site? I was offered but I'm committed at the minute, it's through a reputable recruitment agency for a top edinburgh design house - so worth going for if you have the time free. Give me a shout on [EMAIL PROTECTED] or [EMAIL PROTECTED] and I'll fire you over the details of the man you need to speak to. God it's been ages since I posted here! Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validating textarea using php
2008/5/14 Richard Heyes [EMAIL PROTECTED]: That really should be expected. You can't expect something to last forever without tweaking it on occassion. And in the case of going from PHP 5 - 6, the tweaking required may well be major, becxcause it's a major version change. Exactly. That's why it should be written in a relatively portable fashion from the beginning. To avoid pitfalls later on. A year is nothing! I have projects from 7 years ago that I know I need to update when I get around to it. Well when you get around to it makes it sound as though it's not exactly important. It was written in a relatively portable fashion. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
[PHP] JavaScript and PHP
Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php So, einstein.php will be called with a parameter (satellite): http://portulan-online.net/einstein.php?satellite=123 After that, in einstein.php, I do: $satellite = $_REQUEST['satellite']; Next thing, I need the action in the JavaScript to be, for example: http://portulan-online.net/template.php?id=3satellite=123 What I don't know is how to mix the PHP variable satellite with the image ID here: document.getElementById('image1').src = http://portulan-online.net/einstein-; + ID + .png; I've tried putting einstein.php all inside an echo, but the radio buttons and the submit button stopped working. Does anyone knows how to do this ? Any help would be appreciated. Warm Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JavaScript and PHP
On Wed, May 14, 2008 at 2:31 PM, Mário Gamito [EMAIL PROTECTED] wrote: Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php So, einstein.php will be called with a parameter (satellite): http://portulan-online.net/einstein.php?satellite=123 After that, in einstein.php, I do: $satellite = $_REQUEST['satellite']; Next thing, I need the action in the JavaScript to be, for example: http://portulan-online.net/template.php?id=3satellite=123 What I don't know is how to mix the PHP variable satellite with the image ID here: document.getElementById('image1').src = http://portulan-online.net/einstein-; + ID + .png; I've tried putting einstein.php all inside an echo, but the radio buttons and the submit button stopped working. Does anyone knows how to do this ? Any help would be appreciated. Warm Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php document.getElementById('image1').src = http://portulan-online.net/einstein-; + ?php echo $_GET['satellite']; ? + .png; You could do that. Also, I'd suggest using $_GET instead of $_REQUEST. Request works,b ut it is very broad. $_GET is more specific/secure. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Reseller plans and Dedicated servers available. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Replacing accented characters by non-accented characters
2008/5/14 Bastien Koert [EMAIL PROTECTED]: Why should the server folder name matter? Make it a hash and store the user provided name in a db. Then when presenting the data to the user just show the user provided name as the folder name. This would also handle multiple users trying to use the same folder name for their stuff. It may be that the whole folder hierarchy is publicly accesable. Some faculties at my university do that. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
[PHP] Two word array Value
I am trying to use array's to populate a group of check boxes for a form. I am getting the checkboxes to print OK, but when the form is posted I am only getting part of the array. Form Page: $vars = array(Main Classroom = Main Classroom, Break Out Classroom = Break Out Classroom, Gym = Gym, Firearms Range = Firearms Range, EVOC Track = EVOC Track); $cols = 4; echo form method=post action=twocoltests.phptabletrtd colspan=.$cols. align=centerEquipment Needed/tdtr; foreach($vars as $key = $value){ if (($cols % 4) == 0 ){ echo /trtr; } echo tdinput name=.$key. type=checkbox value=.$value./tdtd.$value./td; $cols++; } echo /tr/table; echo br /; When I submit the form I am only getting the following having checked the boxes for Mail Classroom and Break Out Classroom. If I eliminate the spaces between the words, I get everything, but when I put the spaces between the words in the array, it cuts off the second word. Not sure what is happening? Array ( [Main] = Main [Break] = Break [Submit] = Submit )
Re: [PHP] Two word array Value
Try: echo tdinput name=.urlencode($key). type=checkbox value=.urlencode($value)./tdtd. $value./td; On Wed, May 14, 2008 at 4:02 PM, Mark Bomgardner [EMAIL PROTECTED] wrote: I am trying to use array's to populate a group of check boxes for a form. I am getting the checkboxes to print OK, but when the form is posted I am only getting part of the array. Form Page: $vars = array(Main Classroom = Main Classroom, Break Out Classroom = Break Out Classroom, Gym = Gym, Firearms Range = Firearms Range, EVOC Track = EVOC Track); $cols = 4; echo form method=post action=twocoltests.phptabletrtd colspan=.$cols. align=centerEquipment Needed/tdtr; foreach($vars as $key = $value){ if (($cols % 4) == 0 ){ echo /trtr; } echo tdinput name=.$key. type=checkbox value=.$value./tdtd.$value./td; $cols++; } echo /tr/table; echo br /; When I submit the form I am only getting the following having checked the boxes for Mail Classroom and Break Out Classroom. If I eliminate the spaces between the words, I get everything, but when I put the spaces between the words in the array, it cuts off the second word. Not sure what is happening? Array ( [Main] = Main [Break] = Break [Submit] = Submit )
[PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
I have a class that is throwing the error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM ... It is appearing in the constructor of a parent class abstract class parent { protected $titles = array('title1','title2','title3'); protected $a; function __construct($set = NULL, $special = NULL) { self::$this-titles = array_merge(self::$this-titles, $special); //error foreach($set as $key=value) { if (array_key_exists($key,$this-titles) { $this-a[$key] = $value; } } } } class child extends parent { protected $titles = array('titleA', 'titleB', 'titleC'); function __construct($set, $special = NULL) { self::$this-titles = array_merge(self::$this-titles, $special); parent::__construct($set, self::$this-titles); unset($this-titles); } } Basically parent is an extensible tool for holding data with titles that dictate behavior later in the script. Eventually I will have a dozen or so different child classes each using an identical API. But first I need this constructor to work. The parent constructor just tacks the array of titles from the $special attributes onto the end of the $titles array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Two word array Value
On Wed, May 14, 2008 at 4:02 PM, Mark Bomgardner [EMAIL PROTECTED] wrote: I am trying to use array's to populate a group of check boxes for a form. I am getting the checkboxes to print OK, but when the form is posted I am only getting part of the array. [snip!] Looks like someone's working with the police academy, or something similar. Reminds me I think I have to recert my CEVO and EVOC Anyway, using spaces in HTML form name and ID compartments is illegal, and you're not encapsulating the data in quotes. So HTML thinks that the first word of the bunch is the name of the form element, then skips the rest. For valid HTML: ?php // foreach echo tdinput name=\.str_replace(' ','_',$key).\ type=\checkbox\ value=\.$value.\/tdtd.$value./td; ? Otherwise, if you still want to use spaced form field names, you can enclose them in quotes (as shown above) and the browser will probably automatically urlencode() the data on submit. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JavaScript and PHP
At 7:31 PM +0100 5/14/08, Mário Gamito wrote: Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php Mário: The key here to remember is that javascript uses ID and php uses NAME for inputs. So, if you put your variables in that form and they will work between javascript and php. Such as: input type=radio name=rad id=rad value=2 onclick=javascript:GetImage(this);Einstein 2 Note the change of this in your js call -- you can do that and not have to provide the number. Also put in an action=whatever into your form and collect the selection via $_POST['rad']; That will do what you want. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Two word array Value
Mark Bomgardner wrote: When I submit the form I am only getting the following having checked the boxes for Mail Classroom and Break Out Classroom. If I eliminate the spaces between the words, I get everything, but when I put the spaces between the words in the array, it cuts off the second word. Not sure what is happening? Array ( [Main] = Main [Break] = Break [Submit] = Submit ) Look at the source of the page that this script generates. Your input tags look like this tdinput name=Main Classroom type=checkbox value=Main Classroom/tdtdMain Classroom/td See the problem? The html attribute values have spaces in them. As far as your browser knows Classroom is supposed to be an attribute like type and value. Since it doesn't understand it it drops it. Here is some code, notice the \ surrounding the .$key. ?php $vars = array(Main Classroom = Main Classroom, Break Out Classroom = Break Out Classroom, Gym = Gym, Firearms Range = Firearms Range, EVOC Track = EVOC Track); echo form method=post action=twocoltests.php; echo fieldsetlegendEquipment Needed/legend; foreach($vars as $key = $value){ echo divinput name=\.$key.\ type=checkbox value=\.$value.\label for=\.$key.\.$value./label/div; } echo /fieldset; echo /form; ? I also redid your layout. You should be able to control the layout much better with some simple CSS. Shoot me an e-mail if you wnat help with the CSS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
[snip] I have a class that is throwing the error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM ... [/snip] Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM (Hebrew) It means there's an unexpected double colon where there shouldn't have been. self::$this-titles = array_merge(self::$this-titles, $special); //error Appears to be the trouble maker. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
On Wed, May 14, 2008 at 4:05 PM, Tyson Vanover [EMAIL PROTECTED] wrote: I have a class that is throwing the error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM ... You're using a Hebrew version of PHP? That means something along the lines of two times the two marks in Hebrew. However, in your case, you're checking the error on the wrong line. Look at your foreach() statement. It should instead read as follows: ?php foreach($set as $key = $value) { // You just missed the $ before value. ? Also, check this line: ?php if (array_key_exists($key,$this-titles) ? You're missing a ')' to close the if() statement. It's not causing this problem, but it will cause a problem afterward. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mic check 1, 2, 3...
Just wondering if the mailing list is working. I have not received anything from this list today. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
I've got that before and I am not using a Hebrew version of PHP :) On 5/14/08, Daniel Brown [EMAIL PROTECTED] wrote: You're using a Hebrew version of PHP? That means something along the lines of two times the two marks in Hebrew. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mic check 1, 2, 3...
At 1:50 PM -0700 5/14/08, Jim Lucas wrote: Just wondering if the mailing list is working. I have not received anything from this list today. -- Jim Lucas If you don't receive this, please let me know. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mic check 1, 2, 3...
On Wed, May 14, 2008 at 4:56 PM, tedd [EMAIL PROTECTED] wrote: At 1:50 PM -0700 5/14/08, Jim Lucas wrote: Just wondering if the mailing list is working. I have not received anything from this list today. -- Jim Lucas If you don't receive this, please let me know. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php check check -- Bastien Cat, the other other white meat
RE: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
In your code, it appears you forgot to close a pair of parentheses: --- foreach($set as $key=value) { if (array_key_exists($key,$this-titles) { $this-a[$key] = $value; } } --- It looks like that 3rd line should be: --- if (array_key_exists($key,$this-titles)) --- I hope that helps. Having another set of eyes take a look at it usually does. ;) Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
On Wed, May 14, 2008 at 4:51 PM, mike [EMAIL PROTECTED] wrote: I've got that before and I am not using a Hebrew version of PHP :) Yeah, just a joke. I forgot to put the Trademark ;-P in its place. The etymology of that message could be attributed to the fact that Zeev and Andi are Israeli. Just taking a guess at it though. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mic check 1, 2, 3...
On Wed, May 14, 2008 at 4:50 PM, Jim Lucas [EMAIL PROTECTED] wrote: Just wondering if the mailing list is working. I have not received anything from this list today. I saw a response from you come through to the elusive thread. So it looks like it's working both ways for you now. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
Daniel Brown wrote: ?php foreach($set as $key = $value) { // You just missed the $ before value. ? This seems to be the culprit. Also, check this line: ?php if (array_key_exists($key,$this-titles) ? You're missing a ')' to close the if() statement. It's not causing this problem, but it will cause a problem afterward. Thanks for catching that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable Scope from child to parent
I am trying to get a child class to pass an array of valid keys to it's parent when the constructor is run, and the parent appends the data to one of it's array of valid keys. Then it walks through an array pulling out values that have valid keys, and putting them in an array for processing later. I have tried explicitly stating the variable scope. abstract class parentclass { protected $vkeys= array('title1','title2','title3'); protected $a; function __construct($set = NULL, $special = NULL) { self::$this-vkeys= array_merge(self::$this-vkeys, $special); foreach($set as $key=$value) { if (in_array($key,self::$this-vkeys)) { $this-a[$key] = $value; } } print_r(self::$this-vkeys); //output below print_r(self::$this-a); //output below } } class childclass extends parentclass { protected $vkeys= array('titleA', 'titleB', 'TitleC'); function __construct($set, $special = NULL) { parent::__construct($set, self::$this-vkeys); unset(self::$this-vkeys); } } Unfortunately it seems to duplicate the child's array instead of appending. Explicitly stating scope does not seem to help. print_r(self::$this-vkeys); Array ( [0] = titleA [1] = titleB [2] = titleB [3] = titleA [4] = titleB [5] = titleB ) print_r(self::$this-a); Array() Any thoughts? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mic check 1, 2, 3...
tedd wrote: At 1:50 PM -0700 5/14/08, Jim Lucas wrote: Just wondering if the mailing list is working. I have not received anything from this list today. -- Jim Lucas If you don't receive this, please let me know. Cheers, tedd Wait... the recursive not testing of that statement just crashed my brain servers. But I hope it is working for you Jim. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
Yeah, you are right, friend. Because users' input should be in body tag only. On Wed, May 14, 2008 at 11:06 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2008-05-14 at 18:50 +0800, Shelley wrote: Thank you all. I have made it working excellent for me now. The solution is here: http://phparch.cn Ah, there you go... show_body_only. I was too lazy when I used tidy a while back to look through every option, so a quick preg stripping sufficed :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- Regards, Shelley
[PHP] Validating Form input
I was wondering what others think of my approach to form validation. I know many use Java script to do various validation. However, since there is no way to be sure the data sent to the server is actually valid, you have to check it in your php code on the server anyway. Granted you don't have to, but if you don't, you are just asking for someone to hack your system, or at the very least screw up your data. So my question is since you have to do a validity check on the server, why bother with the Java script? The only advantage I can see to doing it with Java script is it will cut down on the errors in data that get to the server and then in turn reduce the number for resubmits and keep traffic down a little. However since none of the projects I have worked on are very high traffic sites, that hasn't been much of a concern. Any thoughts? -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
Can anyone provide some code that can't be stripped by strip_tags? On 5/15/08, Eric Butera [EMAIL PROTECTED] wrote: On Wed, May 14, 2008 at 11:38 AM, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote: On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. That depends... if I'm the webmaster and I want to input arbitrary HTML, then htmlpurifier is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP OP said users. Strip tags doesn't bother with tag attributes so that is a security hole. Any regex type solution will encounter the same set of issues. Htmlpurifier actually strips down and re-builds your html from the ground against a nice whitelist filtering system that you can customize to your needs. No nasty tags/attributes will get through unless you want them to. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Wang Yi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating Form input
client validation is a way to provide quick response to the user for whether their input is correct or not. It doesn't guarantee correctness of the posted data. Because everything from client can't be trusted. On 5/15/08, Chris W [EMAIL PROTECTED] wrote: I was wondering what others think of my approach to form validation. I know many use Java script to do various validation. However, since there is no way to be sure the data sent to the server is actually valid, you have to check it in your php code on the server anyway. Granted you don't have to, but if you don't, you are just asking for someone to hack your system, or at the very least screw up your data. So my question is since you have to do a validity check on the server, why bother with the Java script? The only advantage I can see to doing it with Java script is it will cut down on the errors in data that get to the server and then in turn reduce the number for resubmits and keep traffic down a little. However since none of the projects I have worked on are very high traffic sites, that hasn't been much of a concern. Any thoughts? -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Wang Yi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating Form input
On Wed, May 14, 2008 at 10:48 PM, Chris W [EMAIL PROTECTED] wrote: I was wondering what others think of my approach to form validation. I know many use Java script to do various validation. However, since there is no way to be sure the data sent to the server is actually valid, you have to check it in your php code on the server anyway. Granted you don't have to, but if you don't, you are just asking for someone to hack your system, or at the very least screw up your data. So my question is since you have to do a validity check on the server, why bother with the Java script? The only advantage I can see to doing it with Java script is it will cut down on the errors in data that get to the server and then in turn reduce the number for resubmits and keep traffic down a little. However since none of the projects I have worked on are very high traffic sites, that hasn't been much of a concern. Any thoughts? -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think you'll find most people on this list in agreement. PHP level validation is a must, as JavaScript is unreliable at best. Now, the only real advantage I've seen with JS validation is just to have that first line of validation to save the end user some time in between submits. If you don't want to bother with it, don't. I tend to just for that first layer. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Reseller plans and Dedicated servers available. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Tracking down the elusive expecting T_PAAMAYIM_NEKUDOTAYIM
On Wed, May 14, 2008 at 5:43 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Wed, May 14, 2008 at 4:05 PM, Tyson Vanover [EMAIL PROTECTED] wrote: I have a class that is throwing the error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM ... You're using a Hebrew version of PHP? not necessary should be the hebrew PHP version. by definition even in the english version T_PAAMAYIM_NEKUDOTAYIM is used to name :: That means something along the lines of two times the two marks in Hebrew. However, in your case, you're checking the error on the wrong line. Look at your foreach() statement. It should instead read as follows: ?php foreach($set as $key = $value) { // You just missed the $ before value. ? Also, check this line: ?php if (array_key_exists($key,$this-titles) ? You're missing a ')' to close the if() statement. It's not causing this problem, but it will cause a problem afterward. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Los sabios buscan la sabiduría; los necios creen haberla encontrado. Gabriel Sosa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using SVN w/ Zend Studio for Eclipse
Hey all, Apologies ahead of time if this isn't the appropriate forum for my inquiry. I'm evaluating Zend Studio for Eclipse and it's certainly making some features that I'd hope would be trivial, extremely onerous. I'm simply trying to take an existing project which I started in TextMate and import it into ZS for Eclipse with Subversion controls attached to the project. I do not want to copy the project into a new directory as the existing directory is where Apache's DocumentRoot is set. And although that's simple to change, I really don't think any IDE should mandate where I set my project's directory on the filesystem. Also, if I try to create a new project from an SVN Repository, it doesn't allow me to select what directory I want the code checked out in. Otherwise I'd just cringe and let it overwrite what's in my existing document root, since that's all versioned code anyhow. If I just create a new project, and import the directory of the code base (which is under version control already), it doesn't pick up the subversion controls in the IDE itself. If any of you have run into similar frustrations, I'd love to hear it. So far I've spent the better part of the evening fiddling with extremely rudimentary features which no IDE in any programming environment I've ever worked with has imposed on me. Perhaps this thing isn't ready for mainstream yet, or perhaps I'm missing something obvious. Thanks for any insight. /rant /sf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating Form input
On Wed, 2008-05-14 at 21:48 -0500, Chris W wrote: I was wondering what others think of my approach to form validation. I know many use Java script to do various validation. However, since there is no way to be sure the data sent to the server is actually valid, you have to check it in your php code on the server anyway. Granted you don't have to, but if you don't, you are just asking for someone to hack your system, or at the very least screw up your data. So my question is since you have to do a validity check on the server, why bother with the Java script? The only advantage I can see to doing it with Java script is it will cut down on the errors in data that get to the server and then in turn reduce the number for resubmits and keep traffic down a little. However since none of the projects I have worked on are very high traffic sites, that hasn't been much of a concern. Any thoughts? I ignore JavaScript validation unless I think the round trip is an issue. Since I'm not working on any million hit per day systems, it's not an issue. When it becomes an issue... it's simple enough to add the JavaScript. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Scope from child to parent
tyson i never saw self::$this-vkeys doing this you actually are callig the var inside $this-vkeys do self::$vkeys as static or $this-vkeys as object don't mix regards On Wed, May 14, 2008 at 7:33 PM, Tyson Vanover [EMAIL PROTECTED] wrote: I am trying to get a child class to pass an array of valid keys to it's parent when the constructor is run, and the parent appends the data to one of it's array of valid keys. Then it walks through an array pulling out values that have valid keys, and putting them in an array for processing later. I have tried explicitly stating the variable scope. abstract class parentclass { protected $vkeys= array('title1','title2','title3'); protected $a; function __construct($set = NULL, $special = NULL) { self::$this-vkeys= array_merge(self::$this-vkeys, $special); foreach($set as $key=$value) { if (in_array($key,self::$this-vkeys)) { $this-a[$key] = $value; } } print_r(self::$this-vkeys); //output below print_r(self::$this-a); //output below } } class childclass extends parentclass { protected $vkeys= array('titleA', 'titleB', 'TitleC'); function __construct($set, $special = NULL) { parent::__construct($set, self::$this-vkeys); unset(self::$this-vkeys); } } Unfortunately it seems to duplicate the child's array instead of appending. Explicitly stating scope does not seem to help. print_r(self::$this-vkeys); Array ( [0] = titleA [1] = titleB [2] = titleB [3] = titleA [4] = titleB [5] = titleB ) print_r(self::$this-a); Array() Any thoughts? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Los sabios buscan la sabiduría; los necios creen haberla encontrado. Gabriel Sosa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good HTML parser needed
Gabriel Sosa wrote: this one strip_tags('%3C%68%31%3E%68%65%6C%6C%6F%20%77%6F%72%6C%64%3C%2F%68%31%3E'); aka h1hello world/h1 using urlencode from http://ha.ckers.org/xss.html take care the possible xss saludos gabriel On Wed, May 14, 2008 at 11:56 PM, Yi Wang [EMAIL PROTECTED] wrote: Can anyone provide some code that can't be stripped by strip_tags? On 5/15/08, Eric Butera [EMAIL PROTECTED] wrote: On Wed, May 14, 2008 at 11:38 AM, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2008-05-14 at 11:18 -0400, Eric Butera wrote: On Tue, May 13, 2008 at 4:07 AM, James Dempster [EMAIL PROTECTED] wrote: http://htmlpurifier.org/ -- /James This is the only real solution. That depends... if I'm the webmaster and I want to input arbitrary HTML, then htmlpurifier is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP OP said users. Strip tags doesn't bother with tag attributes so that is a security hole. Any regex type solution will encounter the same set of issues. Htmlpurifier actually strips down and re-builds your html from the ground against a nice whitelist filtering system that you can customize to your needs. No nasty tags/attributes will get through unless you want them to. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards, Wang Yi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yes, this raw string can't be stripped by strip_tags. But actually, how the string take xss? The string has been urldecoded before we use it. for example: assuming url is test.php?test_string=%3C%68%31%3E%68%65%6C%6C%6F%20%77%6F%72%6C%64%3C%2F%68%31%3E ?php var_dump( strip_tags( $_GET[ 'test_string' ] ) ); ? should be produce string(11) hello world. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can I install a newer version of php over an older version
Can I install a newer version of php over an older version ? I am new to php and am in the process of installing it and reading various tutorials. I installed version php-5.2.5-win32-installer.msi I have just downloaded php-5.2.6-win32-installer.msi can I install over the first one or must I uninstall the php-5.2.5-win32-installer.msi version first. TIA Tony M