php-general Digest 17 Jan 2007 10:11:32 -0000 Issue 4574
php-general Digest 17 Jan 2007 10:11:32 - Issue 4574 Topics (messages 247187 through 247200): Re: sms through teleflip and php? 247187 by: Jochem Maas Re: More efficient thumbnail script 247188 by: Jochem Maas 247189 by: Curt Zirzow 247190 by: Jochem Maas Re: I lied, another question / problem 247191 by: Jochem Maas 247192 by: Chris 247194 by: Beauford 247199 by: Roman Neuhauser Re: odbc_execute 247193 by: Chris Re: Bug? (_ENV in PHP v5.2.0) 247195 by: Eli Re: $_SESSION variable gets lost on FORM action 247196 by: Stut Where can I get the Printer extension? 247197 by: Chuck Anderson Storing values in arrays 247198 by: Ryan A 247200 by: Robert Cummings 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: php-general@lists.php.net -- ---BeginMessage--- blackwater dev wrote: Thanks for all the insights. It appears that it might have thought my email was spam as I sent it from another server and it worked fine. which makes it even more likely that the 'bad' server doesn't have it's relevant MX DNS records setup properly - I can't really tell you what properly entails - it's a responsiblity I hand off to the relevant sys admin :-) Thanks! On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: also consider that there maybe a reverse lookup being done on the sending MTA that the sms gateway doesn't consider kosher .. and/or that the IP of the sending MTA is grey-listed/black-listed. also a check may be being done to see if the sender's account exists on the sender's [your servers] domain. check the relevant logs on your server to see what (if anything) the sms gateway is asking your server. (no idea what/where those logs are hiding out). sorry if this all sounds vague, I'm mostly parroting what others have said in the past - I'm hardly what you would call knowledgable with regard to mail servers and all that jazz. [EMAIL PROTECTED] wrote: Maybe phpMailer isn't sending the correct headers either. Sometimes all it takes is one missing header that a system is looking for and it may filter it as spam or something. Again, I encourage you to examine the headers from your Thunderbird good email and compare it to your PHP and/or phpMailer headers that are getting sent. Possibly try to emulate the successful email as much as possible by copying the headers from a known successful message. If that doesn't work, then you may contact teleflip or whatever service you're trying to send text messages to and ask them if they can provide any information as to why it may not be going through. Never know, might find someone with half a brain who can help. -TG = = = Original message = = = I tried using phpMailer and all and it nothing seems to work right. I can send it fine through thunderbird but it just seems to complain via php. Not sure why. On 1/16/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm guessing the SMS system is rejecting the email because it's lacking some headers that mail programs tend to use... and spammers sometimes forget. You might send your email from Thunderbird.. CC yourself on it. Verify that it went through as a text message, then open the CC'd copy and look at the headers. You can start by taking all those headers and putting them into your PHP script then slowly commenting some out until you get just what you need and not a lot of extra garbage (to keep it simple and semi-elegant). That's where I'd start at least. -TG = = = Original message = = = Has anyone been able to successfully send a text message using php and the mail function? It works fine if I open up thunderbird and send a message to [EMAIL PROTECTED] but if I use the mail function: mail([EMAIL PROTECTED], test, test); It doesn't work. I've tried several different approaches so was curious if others have used it successfully. Thanks! ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. ---End Message--- ---BeginMessage--- Jason Pruim wrote: On Jan 16, 2007, at 4:10 PM, Jochem Maas wrote: generating/resampling image data is a relatively heavy job for a script to perform. there maybe optimizations available in the script itself but generally caching the results the generation/resampling action is the way to increase performance ... you need a mechanism to check/store/retrieve cached images [and a way to automatically regenerate a cached image when the source image has changes]. another thing to consider on top of caching is to store
[PHP] Where can I get the Printer extension?
It thought it would be bundled with my Windows version pf Php 4.4.1, but it is not. I've searched for it and can't find it at php.net. How do get a copy of php_printer.dll for Php4.4.1 for Windows? -- * Chuck Anderson • Boulder, CO http://www.CycleTourist.com * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Storing values in arrays
Hi, I think its easier to explain what I want to do.. so here goes: I want to store values in arrays for one minute and then write them to file. For example, everytime someone logs in I want their username to be in an array 1 or 100 or X people may login in 60 seconds...but it should only write all the usernames that logged in to disk every 1 minute. Ideas? suggestions? starting points or a link to a specific spot in the manual with a RTFM would be appreciated :) Thanks in advance, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar.
Re: [PHP] I lied, another question / problem
# [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100: Beauford wrote: Further to my previous email, there is something weird going on here. I just tried using this: if (!ereg('^[A-Za-z0-9]', $strvalue)) { return error; } stop using bleeding ereg*() function - move to preg_*() funcs like the rest of the world did 5+ years ago. Or even better: how about using the right tool for the job? :) if (!ctype_isalnum($strvalue)) { return error; } if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) It's dangerous. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
On Wed, 2007-01-17 at 00:35 -0800, Ryan A wrote: Hi, I think its easier to explain what I want to do.. so here goes: I want to store values in arrays for one minute and then write them to file. For example, everytime someone logs in I want their username to be in an array 1 or 100 or X people may login in 60 seconds...but it should only write all the usernames that logged in to disk every 1 minute. Ideas? suggestions? starting points or a link to a specific spot in the manual with a RTFM would be appreciated :) Might be able to do it with shared memory and a cron job. I'm just not sure if shared memory works between web module and cli. If not, I guess you could use wget in the cron job to pull a special page from your website that does the write. 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
Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.
# [EMAIL PROTECTED] / 2007-01-16 20:42:48 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100: Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Doesn't DOMDocument *require* DTD? I thought it's either that or a document fragment (which is probably what you're looking for). And how should i do this? Do you have any example avelable? Sorry, no. You'll have to experiment. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-01-17 at 00:35 -0800, Ryan A wrote: Hi, I think its easier to explain what I want to do.. so here goes: I want to store values in arrays for one minute and then write them to file. For example, everytime someone logs in I want their username to be in an array 1 or 100 or X people may login in 60 seconds...but it should only write all the usernames that logged in to disk every 1 minute. Ideas? suggestions? starting points or a link to a specific spot in the manual with a RTFM would be appreciated :) Might be able to do it with shared memory and a cron job. I'm just not sure if shared memory works between web module and cli. If not, I guess you could use wget in the cron job to pull a special page from your website that does the write. Cheers, Rob. Hey! Thanks for replying. Instead of CRON i was thinking of having a file created and check the creation time everytime someone logged in... if its less than 1 min then don't do anything, if 1 min or more old... write file... No idea about shared memory, will look that up.. Everybody feel free to chip in any bits of info, theories or advise you may have. Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Re: [PHP] I lied, another question / problem
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100: Beauford wrote: Further to my previous email, there is something weird going on here. I just tried using this: if (!ereg('^[A-Za-z0-9]', $strvalue)) { return error; } stop using bleeding ereg*() function - move to preg_*() funcs like the rest of the world did 5+ years ago. Or even better: how about using the right tool for the job? :) true, although the function should be spelled correct to avoid fatal errors ;-) if (!ctype_isalnum($strvalue)) { return error; } if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) It's dangerous. why dangerous? given that this page: http://php.net/manual/en/function.ctype-alnum.php says, and I quote: Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z] and the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text). the 'D' modifier being the only difference in my example regexp and the equilavent given on the ctype_alnum() page ... I grant that the 'D' modifier might the difference between dangerous and not dangerous, if that's the case please explain (because I'm not seeing it :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
On Wed, 2007-01-17 at 02:40 -0800, Ryan A wrote: Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-01-17 at 00:35 -0800, Ryan A wrote: Hi, I think its easier to explain what I want to do.. so here goes: I want to store values in arrays for one minute and then write them to file. For example, everytime someone logs in I want their username to be in an array 1 or 100 or X people may login in 60 seconds...but it should only write all the usernames that logged in to disk every 1 minute. Ideas? suggestions? starting points or a link to a specific spot in the manual with a RTFM would be appreciated :) Might be able to do it with shared memory and a cron job. I'm just not sure if shared memory works between web module and cli. If not, I guess you could use wget in the cron job to pull a special page from your website that does the write. Cheers, Rob. Hey! Thanks for replying. Instead of CRON i was thinking of having a file created and check the creation time everytime someone logged in... if its less than 1 min then don't do anything, if 1 min or more old... write file... But then it wouldn't be written to disk every one minute if someone didn't log in for 3 minutes ;) 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
Re: [PHP] I lied, another question / problem
# [EMAIL PROTECTED] / 2007-01-17 11:41:54 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100: if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) It's dangerous. why dangerous? given that this page: http://php.net/manual/en/function.ctype-alnum.php says, and I quote: Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z] and the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text). re_format(7) on FreeBSD: A bracket expression is a list of characters enclosed in `[]'. (...) If two characters in the list are separated by `-', this is shorthand for the full range of characters between those two (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII matches any decimal digit. (...) Ranges are very collating-sequence-dependent, and portable programs should avoid relying on them. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] better protection?
If I protect folders via cpanel (HTTP auth) is this more secure than using php code? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: better protection?
Ross wrote: If I protect folders via cpanel (HTTP auth) is this more secure than using php code? Logically, it /could/ be more secure as it prevents access to any PHP code and thus any vulns in PHP itself. In practice tho', the login code and the small part of cpanel that the un-authed user has access to is unlikely to have any vulns. Even new injection attacks are unlikely to cause any problems, but you certainly can't rule it out. So, in principle, yes it is more secure; in practice, it probably doesn't matter. (IMO) Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] protection 2
Thanks Colin. Think I will do both. I can timeout the session with PHP. Does adding mysql_real_escape_string make this secure to injection or should I be doing something else? if ($_POST['submitted']){ $username = mysql_real_escape_string( $_POST['username'] ); $pass = mysql_real_escape_string( $_POST['pass'); $username = md5($username); $pass = md5($pass); $query = SELECT username, pass FROM login where username='$username' AND pass ='$pass'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.
Mathijs van Veluw wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100: Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Doesn't DOMDocument *require* DTD? I thought it's either that or a document fragment (which is probably what you're looking for). And how should i do this? Do you have any example avelable? A DTD is not required and is not automatically added to XML documents. Tags are also not automatically added either (using loadHTML methods is excluded from this statement) so not sure exactly what you are trying to do here or running into. Are you just trying to serialize a DOMDocument? root / is a perfectly well-formed document (though inclusion of xml declaration is *highly* recommended). Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.
# [EMAIL PROTECTED] / 2007-01-17 07:08:44 -0500: Mathijs van Veluw wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100: Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Doesn't DOMDocument *require* DTD? I thought it's either that or a document fragment (which is probably what you're looking for). And how should i do this? Do you have any example avelable? A DTD is not required and is not automatically added to XML documents. Tags are also not automatically added either (using loadHTML methods is excluded from this statement) so not sure exactly what you are trying to do here or running into. Are you just trying to serialize a DOMDocument? root / is a perfectly well-formed document (though inclusion of xml declaration is *highly* recommended). Looks like the DTD is really optional, sorry for the noise. prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? XMLDecl ::= '?xml' VersionInfo EncodingDecl? SDDecl? S? '?' VersionInfo ::= S 'version' Eq (' VersionNum ' | '' VersionNum '') Eq ::= S? '=' S? VersionNum ::= '1.0' Misc::= Comment | PI | S http://www.w3.org/TR/2006/REC-xml-20060816/#NT-prolog -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php coding help - Newbie question
Hi Group, A very newbie question. Might be discussed earlier, please forgive. I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the user's login passwd . Each time the user hits the page these vars are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. Many thanx in advance. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to prevent DomDocument from adding a !DOCTYPE.
Mathijs van Veluw wrote: Hello there, Im using DomDocument currently and i realy want to prevent it from adding the !DOCTYPE and mabye even html and body etc.. Is this possible and how? Thx in advance. Mathijs. --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 000703-1, 01/15/2007 Tested on: 1/16/2007 3:37:11 PM avast! - copyright (c) 1988-2007 ALWIL Software. http://www.avast.com Hello again, I will try to explain what i want to do. Mabye there is an other soluttion to fix my problem. I have some HTML content: div id=test1 div id=test2 class=testClass span style=font-color: #900; class=secondTestClass Testingbr /span ØøÅå_^{}\[~]|[EMAIL PROTECTED]#¤%'()*+,ÖÑܧ¿äöñüà-./:;=?¡Ä /div /div Now i need to parse the HTML by getting all the class and id attributes and replace them with something else, and after that return the modified HTML. The DomDocument looked nice for this, because it had getElementsByTagName() etc.. Is there mabye an other way to parse this HTML and replace/modify its atttributes? Thx in advanced. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to prevent DomDocument from adding a !DOCTYPE.
El Wed, 17 Jan 2007 13:53:36 +0100 Mathijs [EMAIL PROTECTED] escribió: sByTagName() etc.. Is there mabye an other way to parse this HTML and replace/modify its atttributes? Thx in advanced. Have you try preg_replace? -- Miguel J. Jiménez Área de Internet/XSL [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla. Teléfono: 955 036 800 - Fax: 955 036 849 http://www.isotrol.com ¿Cuántas lecciones más necesitaremos para aprender cuántas lecciones más necesitaremos para acertar? Juan José Ibaretxe (13/01/2007) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to prevent DomDocument from adding a !DOCTYPE.
Miguel J. Jiménez wrote: El Wed, 17 Jan 2007 13:53:36 +0100 Mathijs [EMAIL PROTECTED] escribió: sByTagName() etc.. Is there mabye an other way to parse this HTML and replace/modify its atttributes? Thx in advanced. Have you try preg_replace? Tryed to, but it went to complex. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] web form data to arrays?
Hello, I have a script which retrieves rows from DB and prints them to a user editable form to a web page. I don't know how to print the form objects so that all editable fields are put to arrays for updating them to DB. I have tried to create arrays sarjanID[] etc. but havent got it to work... Pls. see code below. Thanks -Will $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 'sorter' ASC; $row = mysql_fetch_row($result); $result = mysql_query($sql); $num = mysql_num_rows($result); $cur = 1; while ($num = $cur) { $row = mysql_fetch_array($result); $id = $row[id]; $nimi = $row[nimi]; $kilpailutyyppi = $row[kilpailutyyppi]; $sarjataulukko = $row[sarjataulukko]; $joukkueitakpl = $row[joukkueitakpl]; $sorter = $row[sorter]; $kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, $joukkueitakpl, $sorter); //create arrays here $cur++; } .. foreach ($kilpailut as $value) { //print arrays to a web form if ($value[3] == 1) { $staulu = Kyllä; } elseif ($value[3] == 0) { $staulu = Ei; } print input type=\hidden\ name=\sarjanID[ID]\ value =\$value[0]\\n; print input type=\text\ name=\sarjanID[nimi]\ size=\20\ maxlength=\20\ value =\$value[1]\\n; print select name=\sarjanID[tyyppi]\\n; print option selected$value[2]/option\n; print optionSarja/option\n; print optionCup/option\n; print /select\n; print select name=\sarjanID[sarjataulukko]\\n; print option selected$staulu/option\n; print optionKylla;/option\n; print optionEi/option\n; print /select\n; print select name=\sarjanID[joukkueitayht]\\n; print option selected$value[4]/option\n; for ($i=3; $i=20; $i++ ) { print option$i/option\n; } print /select\n; print input type=\text\ name=\sarjanID[sortteri]\ value =\$value[5]\\n; print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to prevent DomDocument from adding a !DOCTYPE.
Mathijs wrote: I have some HTML content: div id=test1 div id=test2 class=testClass span style=font-color: #900; class=secondTestClass Testingbr /span ØøÅå_^{}\[~]|[EMAIL PROTECTED]#¤%'()*+,ÖÑܧ¿äöñüà-./:;=?¡Ä /div /div Now i need to parse the HTML by getting all the class and id attributes and replace them with something else, and after that return the modified HTML. If this were XHTML or you were working with complete HTML documents, then you would have a shot. Being HTML snippets, you are going to run into problems (different encodings, possibility of entities, etc..) - all of which need to be handled. You could probably hack the snippet a bit to create a full HTML document, but there's still no guarantee it will work correctly between different snippets. On top of that, unlike working with XML, there is no way to output a subtree of HTML. You would need to use the XML serialization routines, which would most likely change the structure of your document (it would be XHTML compliant now). Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
On sze, 2007-01-17 at 15:23 +0200, William Stokes wrote: Hello, I have a script which retrieves rows from DB and prints them to a user editable form to a web page. I don't know how to print the form objects so that all editable fields are put to arrays for updating them to DB. I have tried to create arrays sarjanID[] etc. but havent got it to work... Pls. see code below. Thanks -Will $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 'sorter' ASC; $row = mysql_fetch_row($result); $result = mysql_query($sql); $num = mysql_num_rows($result); $cur = 1; while ($num = $cur) { why don't you use this: while ($row = mysql_fetch_array($result)) { and then you can omit $cur, and also you won't need $num $row = mysql_fetch_array($result); $id = $row[id]; $nimi = $row[nimi]; $kilpailutyyppi = $row[kilpailutyyppi]; $sarjataulukko = $row[sarjataulukko]; $joukkueitakpl = $row[joukkueitakpl]; $sorter = $row[sorter]; $kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, $joukkueitakpl, $sorter); //create arrays here $cur++; } .. foreach ($kilpailut as $value) { //print arrays to a web form if ($value[3] == 1) { $staulu = Kyll; } elseif ($value[3] == 0) { $staulu = Ei; } print input type=\hidden\ name=\sarjanID[ID]\ value =\$value[0]\\n; print input type=\text\ name=\sarjanID[nimi]\ size=\20\ maxlength=\20\ value =\$value[1]\\n; print select name=\sarjanID[tyyppi]\\n; print option selected$value[2]/option\n; print optionSarja/option\n; print optionCup/option\n; print /select\n; print select name=\sarjanID[sarjataulukko]\\n; print option selected$staulu/option\n; print optionKylla;/option\n; print optionEi/option\n; print /select\n; print select name=\sarjanID[joukkueitayht]\\n; print option selected$value[4]/option\n; for ($i=3; $i=20; $i++ ) { print option$i/option\n; } print /select\n; print input type=\text\ name=\sarjanID[sortteri]\ value =\$value[5]\\n; print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n; } all input fields go to $_POST/$_GET depending on the form method you use. so you don't have to create an array in the form itself. just do it like select name=\tyyppi\ and then you will have that value in $_POST['tyyppi'] or $_GET['tyyppi'] greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
On Jan 16, 2007, at 4:15 PM, Paul Novitski wrote: At 1/16/2007 12:54 PM, Jason Pruim wrote: First off, thanks to everyone who helped me get started with a thumbnail gallery that would display info you could just copy/paste into a weblog (Or any webpage) and have the picture display. I am moving along with a few additions and seem to be running into a problem. The script I have works just fine, it's just slow when you put some large files in it, the page takes awhile to load weither I'm calling it through the php file it's self or through a include in an html file. ... The php script I'm using can be seen here: http://www.raoset.com/ tests/picture/images/wheeler.php the html file I want to include it in is: http://www.raoset.com/ tests/ pictures/index.shtml Jason, I'm not able to see your PHP script because when I navigate to the script it is interpreted, not downloaded as text. Please copy the script into a file ending in .txt if you'd like people to be able to read it. Is your thumbnail script slow because you're creating images on the fly every time? If so, an obvious fix would be to cache thumbnails on the server so you only have to create them once. The logic could look something like: if (thumnbail doesn't exist) { // create thumbnail save it to the server } // use existing file Then you might consider putting the thumbnail-cacheing logic into the script that lets people upload their images in the first place, so there won't be so much processing the first time the thumbnail gallery is loaded. Sorry... Not used to working with PHP scripts... I forget you can't just view source them :) here is the wheeler.php script: ? /* ** James Wheeler ** Kender Internet Kompany ** http://kender.org ** ** Name as index.php ** - Display all images in a directory ** - Able to skip files at will ** - remove img src= and use for ** all files in directory ** (skipping desired files) ** ** Code free to use, please give credit ** where credit is due! */ echo 'center Click on a thumbnail to view imagebr / table tr '; $main = .; $dir = opendir($main); // unbutton it $i = 1; // for column count while($filename = readdir($dir)) { { if (filetype($filename) == file $filename !=index.php $filename !=.DS_Store $filename !=uploadac.php $filename !=wheeler.php $file !=wheeler.css $file ! =wheeletest.php $file !=wheeler.shtml $file !=index.shtml $file !=picture.css $file !=picture.txt) // dont show index.php (this file) - skip any file you dont want viewed // format as ( $filename != filename.ext ) inside the () behind index.php { if ($i = '1')// column count (designed for 5 columns wide - change the 5 for however many wanted) { $i = $i + '1'; echo 'td align=left width=115 height=100 a href=images/'.$filename.'img src=images/'.$filename.' height=60 border=0 //abr /'; $imgHTML = 'a href=http://www.raoset.com/tests/picture/ images/'.$filename.'img src=http://www.raoset.com/tests/picture/ images/'.$filename.' height=200px//A'; $imgHTML = htmlentities($imgHTML, ENT_QUOTES); echo $imgHTML; echo ' /td '; // display it } else { $i = '1';// reset column count and change rows echo '/tr tr '; $i = $i + '1';// add 1 to counter to get to next row echo 'td align=left width=115 height=100 a href=images/'.$filename.'img src=images/'.$filename.' height=60 border=0 //abr / '; $imgHTML = 'a href=http:// www.raoset.com/tests/picture/images/'.$filename.'img src=http:// www.raoset.com/tests/picture/images/'.$filename.' height=200px// A'; $imgHTML = htmlentities($imgHTML, ENT_QUOTES); echo $imgHTML; echo ' /td '; // display it } } } } closedir($dir);
Re: [PHP] web form data to arrays?
But if the form is printed with foreach don't I need some type of counter? Otherwise the form that is posted will contain only the data of the last iteration of the loop that wrote the original form. right? -Will Németh Zoltán [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] On sze, 2007-01-17 at 15:23 +0200, William Stokes wrote: Hello, I have a script which retrieves rows from DB and prints them to a user editable form to a web page. I don't know how to print the form objects so that all editable fields are put to arrays for updating them to DB. I have tried to create arrays sarjanID[] etc. but havent got it to work... Pls. see code below. Thanks -Will $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 'sorter' ASC; $row = mysql_fetch_row($result); $result = mysql_query($sql); $num = mysql_num_rows($result); $cur = 1; while ($num = $cur) { why don't you use this: while ($row = mysql_fetch_array($result)) { and then you can omit $cur, and also you won't need $num $row = mysql_fetch_array($result); $id = $row[id]; $nimi = $row[nimi]; $kilpailutyyppi = $row[kilpailutyyppi]; $sarjataulukko = $row[sarjataulukko]; $joukkueitakpl = $row[joukkueitakpl]; $sorter = $row[sorter]; $kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, $joukkueitakpl, $sorter); //create arrays here $cur++; } .. foreach ($kilpailut as $value) { //print arrays to a web form if ($value[3] == 1) { $staulu = Kyll; } elseif ($value[3] == 0) { $staulu = Ei; } print input type=\hidden\ name=\sarjanID[ID]\ value =\$value[0]\\n; print input type=\text\ name=\sarjanID[nimi]\ size=\20\ maxlength=\20\ value =\$value[1]\\n; print select name=\sarjanID[tyyppi]\\n; print option selected$value[2]/option\n; print optionSarja/option\n; print optionCup/option\n; print /select\n; print select name=\sarjanID[sarjataulukko]\\n; print option selected$staulu/option\n; print optionKylla;/option\n; print optionEi/option\n; print /select\n; print select name=\sarjanID[joukkueitayht]\\n; print option selected$value[4]/option\n; for ($i=3; $i=20; $i++ ) { print option$i/option\n; } print /select\n; print input type=\text\ name=\sarjanID[sortteri]\ value =\$value[5]\\n; print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n; } all input fields go to $_POST/$_GET depending on the form method you use. so you don't have to create an array in the form itself. just do it like select name=\tyyppi\ and then you will have that value in $_POST['tyyppi'] or $_GET['tyyppi'] greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
On sze, 2007-01-17 at 16:13 +0200, William Stokes wrote: But if the form is printed with foreach don't I need some type of counter? Otherwise the form that is posted will contain only the data of the last iteration of the loop that wrote the original form. right? -Will so you want to print the same form fields for each iteration on the same page? then I would use a method like echo select name=\record_$count_tyyppi\ which results in select name=\record_1_tyyppi\ for record 1 and so on and you can access the values in $_POST/$_GET like $_POST[record_$count_tyyppi] greets Zoltán Németh Nmeth Zoltn [EMAIL PROTECTED] kirjoitti viestiss:[EMAIL PROTECTED] On sze, 2007-01-17 at 15:23 +0200, William Stokes wrote: Hello, I have a script which retrieves rows from DB and prints them to a user editable form to a web page. I don't know how to print the form objects so that all editable fields are put to arrays for updating them to DB. I have tried to create arrays sarjanID[] etc. but havent got it to work... Pls. see code below. Thanks -Will $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 'sorter' ASC; $row = mysql_fetch_row($result); $result = mysql_query($sql); $num = mysql_num_rows($result); $cur = 1; while ($num = $cur) { why don't you use this: while ($row = mysql_fetch_array($result)) { and then you can omit $cur, and also you won't need $num $row = mysql_fetch_array($result); $id = $row[id]; $nimi = $row[nimi]; $kilpailutyyppi = $row[kilpailutyyppi]; $sarjataulukko = $row[sarjataulukko]; $joukkueitakpl = $row[joukkueitakpl]; $sorter = $row[sorter]; $kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, $joukkueitakpl, $sorter); //create arrays here $cur++; } .. foreach ($kilpailut as $value) { //print arrays to a web form if ($value[3] == 1) { $staulu = Kyll; } elseif ($value[3] == 0) { $staulu = Ei; } print input type=\hidden\ name=\sarjanID[ID]\ value =\$value[0]\\n; print input type=\text\ name=\sarjanID[nimi]\ size=\20\ maxlength=\20\ value =\$value[1]\\n; print select name=\sarjanID[tyyppi]\\n; print option selected$value[2]/option\n; print optionSarja/option\n; print optionCup/option\n; print /select\n; print select name=\sarjanID[sarjataulukko]\\n; print option selected$staulu/option\n; print optionKylla;/option\n; print optionEi/option\n; print /select\n; print select name=\sarjanID[joukkueitayht]\\n; print option selected$value[4]/option\n; for ($i=3; $i=20; $i++ ) { print option$i/option\n; } print /select\n; print input type=\text\ name=\sarjanID[sortteri]\ value =\$value[5]\\n; print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n; } all input fields go to $_POST/$_GET depending on the form method you use. so you don't have to create an array in the form itself. just do it like select name=\tyyppi\ and then you will have that value in $_POST['tyyppi'] or $_GET['tyyppi'] greets Zoltn Nmeth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
BTW: always reply to the list unless asked otherwise. Jason Pruim wrote: you don't know what a class is or how to use one do you? (correct me if I'm wrong) the idea of my particular class is that it is used in the *script* that serves all your resampled images. something *like* (it an overly simplified example): image.php (called as /image.php?id=100width=200height=160 = 8 === ?php $ic = new ImageCache('/path/to/your/cached/images'); $ic-genCacheFileName(array('id', 'width', 'height'), 'jpg', 'foo'); $files = array(); $files[] = '/path/to/your/src/image/that/corresponds/to/id/100.jpg'; if (!$ic-checkCache()) { /* generate a resampled version of * the relevant source file * and save the generated image to the location * that is returned by $ic-getCacheFilePath() */ } // this code won't even run if ImageCache determines that // the browser already has an up2date copy of the // resampled image locally $ic-showImage(); exit; ?php class ImageCache { var $validTypes = array('png','gif','jpeg'); var $cacheFileName; var $cacheFileType; var $cacheDir; var $im; Would I change $cDir to a real directory or $this-cacheDir to a real directory? /* you must give a valid 'cache' dir */ function ImageCache($cDir) { $this-cacheDir = $cDir; } /* generate a cache file name for the image your are generating * if your generated output image is dependent on the values of one or more request * variables then you should add the names to the $args array e.g. * * your script take width/height parameter: /image.php?width=200height=160 * * $args should be the following array: array('width', 'height'); */ function genCacheFileName($args = array(), $type = '', $prefix = '') { /* name/val pair delimiter in the string that results in the hash for the cache id */ $qHashMark = '%~^*'; $qry = array(); $args = (array)$args; natsort($args); foreach ($args as $arg) { if (($val = $this-getR( $arg, false )) !== false) { $qry[] = {$arg}=.str_replace($qHashMark,'',$val); } } $sep = '-:-'; $hash = md5($_SERVER['HTTP_HOST'] .$sep. $_SERVER['SCRIPT_NAME'] .$sep. join($qHashMark,$qry)); if (!in_array($type, $this-validTypes)) { if ($type == 'jpg') { $type = 'jpeg'; } else { $type = 'png'; } } $this-cacheFileType = $type; if (!$prefix) { $prefix = 'cacheimg'; } return ($this-cacheFileName = {$prefix}_{$hash}.{$type}); } /* get the fullpath to the location where the cache file is saved/stored */ function getCacheFilePath() { return $this-cacheDir . '/' . $this-cacheFileName; } /* Return true if the cache file is younger than the source file(s), * false otherwise. * * if this func returns true you can output the relevant cache file, * if false is returned it's your responsibility to generate the output file * and save it to the location given by $this-getCacheFilePath() * * the (array of) files passed to this function should be complete paths, * not just filesnames. */ function checkCache( $files = array() ) { $cacheState = true; $cf = $this-getCacheFilePath(); $mTime= is_readable($cf) ? filemtime($cf): 0; $lastModified = gmdate(D, d M Y H:i:s , $mTime).GMT; $files= (array) $files; if (!count($files) || !$mTime) { $cacheState = false; } else { foreach($files as $file) { if ($mTime filemtime( $file )) { $cacheState = false; break; } } } if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { /* The UA has the exact same image we have. */ header(HTTP/1.1 304 Not Modified); exit; } else { unset($headers); header(Last-Modified: .$lastModified); return true; } } else { // not cached - or cache invalidated // must cache the (new) data. return false; } } function showImage($type = '', $quality = 100) { header( Content-type: image/{$this-cacheFileType} ); readfile( $this-getCacheFilePath() ); exit; } function getR($v = '', $r = null, $t = null) { if (!empty($v)) { if (isset($_REQUEST[$v]))
Re: [PHP] protection 2
Ross wrote: Thanks Colin. Think I will do both. I can timeout the session with PHP. Does adding mysql_real_escape_string make this secure to injection or should I be doing something else? if ($_POST['submitted']){ This should be if ( isset($_POST['submitted']) ) { This way it doesn't give you a PHP NOTICE:... $username = mysql_real_escape_string( $_POST['username'] ); $pass = mysql_real_escape_string( $_POST['pass'); You forgot a closing bracket on that last $_POST['pass' $username = md5($username); ???Why md5 the $username? Makes it difficult to work on and display later on, unless you don't use it that way Jim Lucas $pass = md5($pass); $query = SELECT username, pass FROM login where username='$username' AND pass ='$pass'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
Hey! Thanks for replying. Instead of CRON i was thinking of having a file created and check the creation time everytime someone logged in... if its less than 1 min then don't do anything, if 1 min or more old... write file... But then it wouldn't be written to disk every one minute if someone didn't log in for 3 minutes ;) True, but thats not the most important part... I guess I wrote it wrong, I meant that it should not write to disk before 1 minute... anyway... about the array saving any ideas? Thanks! R -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar.
Re: [PHP] Php coding help - Newbie question
Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { Change the previous lines to this and then move it to the bottom of the file called validate.php Since you include that on each page, it will then be executed and upon failure, stop the script and display a connection error if ( $connect = ldap_connect(ldapserver) === FALSE ) { //display error message and die(); die(Internal problem, please try back later.); } bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the user's login passwd . Each time the user hits the page these vars are checked with the existing values in the LDAP (this is done by validate.php). I would be using the Super Globals for this: $_SESSION, and don't store the password, just the username and something the say that he/she has already authenticated and is valid. Jim Lucas Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. Many thanx in advance. Regards Ram -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php coding help - Newbie question
Ramdas wrote: Hi Group, A very newbie question. Might be discussed earlier, please forgive. Are so much of a noob that STFW is not within your capabilities? (just thought I'd ask, given that you admit to realising the info *might* be out there already) I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: ?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { bind ... do the things }else { echo erro..} ? Also please advice what is a correct method of checking the user's session. Currenlty I use a HTTP_SESSION_VARS variable to store the recommended to use the $_SESSION superglobal instead and stuff values directly into (after having called session_start()) instead of using session_register() et al. user's login passwd . Each time the user hits the page these vars you only need to store *whether* they are logged in - and set that value when you actually handle a login attempt (obviously storing their username could be handy) I don't see any reason to store the passwd and validate against ldap on every request ... in fact I believe that storing the pwd in such a way is essentially less secure. are checked with the existing values in the LDAP (this is done by validate.php). Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. that question is about as vague as 'how long is a chinaman?' (the answer to that question being 'yes he is') here are some very vague ideas/functions: an include file ... === 8 = ?php function sessionCheck() { if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) { /* show login page then .. */ exit; } } function doLogin($username, $passwd) { $_SESSION['loggedin'] = false; if (/* given $username+$passwd check outs in ldap*/) $_SESSION['loggedin'] = true; return $_SESSION['loggedin']; } ? an 'init' include file === 8 = ?php require 'your-include-file.php'; // see above session_start(); if (isset($_POST['uname'], $_POST['pwd'])) { doLogin($_POST['uname'], $_POST['pwd']); } sessionCheck(); ? any other file (other than the login 'page') === 8 = ?php require 'your-init-file.php'; // we are logged in - it's magic // do some shit // the end, congrats go get laid :-) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
El Wed, 17 Jan 2007 15:27:27 - Ross [EMAIL PROTECTED] escribió: Hi, Does md5 really offer much in terms of protection? The algorithm is really well known. I would like to hear your thoughts and poosible alternatives (mcrypt?) R. It works for me. Althought is possible (theorically) to have two strings with the same MD5 is practically impossible to guess one ;-). You can also use sha1 if you prefer. -- Miguel J. Jiménez Área de Internet/XSL [EMAIL PROTECTED] ISOTROL Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. Parque Tecnológico Cartuja '93, 41092 Sevilla. Teléfono: 955 036 800 - Fax: 955 036 849 http://www.isotrol.com ¿Cuántas lecciones más necesitaremos para aprender cuántas lecciones más necesitaremos para acertar? Juan José Ibaretxe (13/01/2007) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
MD5 is a hasing algorithm.. one-way.. really only good for checking known values and keeping them 'private', like storing passwords in a database. That way, if someone breaks into your database, they don't get the passwords, only the non-reversible MD5 hashes of the passwords. To check a user's login credentials, you take the database value for password and you compare it to md5($password) that the user entered and see if they match. So the fact that MD5 is a well known algorithm doesn't really make a difference as far as security goes. Then again, RSA, Blowfish, etc are well known algorithms and are considered at least fairly secure too.. and are reversible. -TG = = = Original message = = = Hi, Does md5 really offer much in terms of protection? The algorithm is really well known. I would like to hear your thoughts and poosible alternatives (mcrypt?) R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
Ross wrote: Hi, Does md5 really offer much in terms of protection? can you STFW? http://search.yahoo.com/search;_ylt=A0oGkkQsQ65FTlkBrTVXNyoA?p=does+md5+offer+any+protectionei=UTF-8fr=moz2x=wrt The algorithm is really well known. do you work for microsoft? strength of a crypto algorithm has nothing to do with whether it's definition known or not. security through obscrurity ... isn't. I would like to hear your thoughts and poosible alternatives (mcrypt?) an alternative might be to first STFM?: http://php.net/sha1 (also read the user notes) R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
[EMAIL PROTECTED] wrote: MD5 is a hasing algorithm.. one-way.. really only good for checking known values and keeping them 'private', like storing passwords in a database. That way, if someone breaks into your database, they don't get the passwords, only the non-reversible MD5 hashes of the passwords. To check a user's login credentials, you take the database value for password and you compare it to md5($password) that the user entered and see if they match. So the fact that MD5 is a well known algorithm doesn't really make a difference as far as security goes. Except for the fact of the growing number of databases that will map the hashes back to the clear text (for example: http://md5.benramsey.com/) Of course it is nice because it is a common implementation, and can be done on the server side, as well as the client side. Then again, RSA, Blowfish, etc are well known algorithms and are considered at least fairly secure too.. and are reversible. -TG = = = Original message = = = Hi, Does md5 really offer much in terms of protection? The algorithm is really well known. I would like to hear your thoughts and poosible alternatives (mcrypt?) R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
input type=text name=name[] *note the []. -- Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
Be warned, crypto isn't a strength of mine, so any/all of this may be total BS. Ross wrote: Does md5 really offer much in terms of protection? Depends on what you're doing with it. AFAIK, md5's weakness comes in the form of collisions - it has been cryptanalysed to the point where it is no longer reasonable for high security purposes. It is possible to create two different strings (i.e. documents, passwords) that result in identical md5 hashes. It is likely possible to find alternate passwords if the md5 is known - if a user can get a hold of your md5'ed passwords, they may be able to come up with another password that will create the same MD5 hash, thus would be capable of logging in to the system. If what you're trying to protect is reasonably sensitive, don't use it to verify that a document hasn't been tampered with, and don't use it to hash passwords though salting may help. The algorithm is really well known. IMO, that's a good thing. I'd much rather have an algorithm that is well known, well analysed and *still* secure over an unknown and untested algorithm. I would like to hear your thoughts and poosible alternatives (mcrypt?) sha1 has also been cryptanalysed but should be more secure than md5. I think sha256 is believed to be secure. PHP 5.2 seems to have a 'hash' function that can generate many atypical hashes like sha256. jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 11:41:54 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100: if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) It's dangerous. why dangerous? given that this page: http://php.net/manual/en/function.ctype-alnum.php says, and I quote: Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z] and the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text). re_format(7) on FreeBSD: A bracket expression is a list of characters enclosed in `[]'. (...) If two characters in the list are separated by `-', this is shorthand for the full range of characters between those two (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII matches any decimal digit. (...) Ranges are very collating-sequence-dependent, and portable programs should avoid relying on them. ah, thanks for that. what would you suggest instead of 'a-z' in this instance, *if* the OP wants *just* the chars [in ASCII] from a to Z then the only thing I could think of would be to use a string of 26 chars ... is there a better way? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 11:41:54 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100: if (!preg_match(#^[A-Z0-9]+\$#i, $s)) { (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) It's dangerous. why dangerous? given that this page: http://php.net/manual/en/function.ctype-alnum.php says, and I quote: Checks if all of the characters in the provided string, text, are alphanumeric. In the standard C locale letters are just [A-Za-z] and the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text). re_format(7) on FreeBSD: A bracket expression is a list of characters enclosed in `[]'. (...) If two characters in the list are separated by `-', this is shorthand for the full range of characters between those two (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII matches any decimal digit. (...) Ranges are very collating-sequence-dependent, and portable programs should avoid relying on them. one other thing ... wouldn't it be fair to assume (safety through paranoia) that ctype_alnum() would suffer the same problem? (given the manual's indication that ctype_alnum() and the offending regexp are equivalent?) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
And how does it work? does it create a sub-array of $_POST? And is it documented somewhere in the manual? Greets Zoltán Németh On sze, 2007-01-17 at 10:54 -0500, Mike Smith wrote: input type=text name=name[] *note the []. -- Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
Still.. that has nothing to do with how well known MD5 is (so I stand by my point).All these databases are is a giant list of pre-MD5'd strings. Brute force stuff, no magic behind it that allows for reversing MD5. You could technically do that with just about any crypto or hashing system. Just happens that MD5 is one that's been focused on and more complicated systems would require exponentially more variables in what you'd have to enter. For instance, you could do this with PGP, but I'm guessing you'd have to have at least two pass phrases and how many things go into generating the public and private keys, plus the message/file that was encrypted. So for one short text string, you could possibly have a database as large as all the MD5 projects put together... but you could potentially do the same thing. At that point it's highly prohibitive though. I got the idea that MD5 really wasn't what he was looking for anyway, so going into detail about the security of it didn't seem fruitful. I talk too much as it is. hah This is a good point though. MD5 isn't great security, particuarly with the databases like the one you mentioned, but most of us aren't storing national security documents. As with security since the dawn of time, it's all a matter of how valuable is what you're protecting versus the cost of implementing a protection scheme. 7-11 doesn't hire secret service to protect against midnight robberies. -TG = = = Original message = = = [EMAIL PROTECTED] wrote: So the fact that MD5 is a well known algorithm doesn't really make a difference as far as security goes. Except for the fact of the growing number of databases that will map the hashes back to the clear text (for example: http://md5.benramsey.com/) Of course it is nice because it is a common implementation, and can be done on the server side, as well as the client side. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
[EMAIL PROTECTED] wrote: Still.. that has nothing to do with how well known MD5 is (so I stand by my point). Was not trying to refute your point. Just pointing something out with regards to the security of MD5 hashes, and what being well known or at least popular does for you. What you say is true...and at the end of the day locks only keep honest people out... (but something like this could be a decent way to check for strength of passwords..) -B All these databases are is a giant list of pre-MD5'd strings. Brute force stuff, no magic behind it that allows for reversing MD5. You could technically do that with just about any crypto or hashing system. Just happens that MD5 is one that's been focused on and more complicated systems would require exponentially more variables in what you'd have to enter. For instance, you could do this with PGP, but I'm guessing you'd have to have at least two pass phrases and how many things go into generating the public and private keys, plus the message/file that was encrypted. So for one short text string, you could possibly have a database as large as all the MD5 projects put together... but you could potentially do the same thing. At that point it's highly prohibitive though. I got the idea that MD5 really wasn't what he was looking for anyway, so going into detail about the security of it didn't seem fruitful. I talk too much as it is. hah This is a good point though. MD5 isn't great security, particuarly with the databases like the one you mentioned, but most of us aren't storing national security documents. As with security since the dawn of time, it's all a matter of how valuable is what you're protecting versus the cost of implementing a protection scheme. 7-11 doesn't hire secret service to protect against midnight robberies. -TG = = = Original message = = = [EMAIL PROTECTED] wrote: So the fact that MD5 is a well known algorithm doesn't really make a difference as far as security goes. Except for the fact of the growing number of databases that will map the hashes back to the clear text (for example: http://md5.benramsey.com/) Of course it is nice because it is a common implementation, and can be done on the server side, as well as the client side. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I lied, another question / problem
# [EMAIL PROTECTED] / 2007-01-17 16:59:26 +0100: Roman Neuhauser wrote: re_format(7) on FreeBSD: A bracket expression is a list of characters enclosed in `[]'. (...) If two characters in the list are separated by `-', this is shorthand for the full range of characters between those two (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII matches any decimal digit. (...) Ranges are very collating-sequence-dependent, and portable programs should avoid relying on them. one other thing ... wouldn't it be fair to assume (safety through paranoia) that ctype_alnum() would suffer the same problem? (given the manual's indication that ctype_alnum() and the offending regexp are equivalent?) isalnum(3) uses isalpha(3) and isdigit(3), so yes, their results are locale-dependent (LC_CTYPE, see setlocale(3)), but don't depend on collating sequence. isdigit(3): The isdigit() function tests for a decimal digit character. Regardless of locale, this includes the following characters only: ``0'' ``1'' ``2'' ``3'' ``4'' ``5'' ``6'' ``7'' ``8'' ``9'' -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
Sorry about that...yes it creates an array so... input type=text name=names[] value=Larry input type=text name=names[] value=Curly input type=text name=names[] value=Moe would create an array accessible from $_POST['names'] foreach($_POST['names'] AS $name){ echo $name; } ...produces: LarryCurlyMoe On 1/17/07, Németh Zoltán [EMAIL PROTECTED] wrote: And how does it work? does it create a sub-array of $_POST? And is it documented somewhere in the manual? Greets Zoltán Németh On sze, 2007-01-17 at 10:54 -0500, Mike Smith wrote: input type=text name=name[] *note the []. -- Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
Németh Zoltán wrote: And how does it work? does it create a sub-array of $_POST? test it and find out: echo 'pre'; var_dump($_POST); echo '/pre'; And is it documented somewhere in the manual? more than likely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] One last try at this!
I hope I can explain this so I can get this figured out, 'cause if not I may just have to find an alternative to PHP. I can't be wasting 3 and 4 days on something as simple as this. Below are 3 validation routines. When I first enter the page 'Optional' is displayed for all of them as it should be, but when I click submit on the form without entering any data, the first one displays optional (which it should), but the 2nd and 3rd ones execute the elseif and the validation routine says there are invalid characters in the string. If nothing is entered in the form where is it getting a value It should never get to the elseif to start with if nothing is entered in the form. So how can I make a reliable check? if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror['orgname'] = $result; } if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
At 10:40 AM -0500 1/17/07, [EMAIL PROTECTED] wrote: MD5 is a hasing algorithm.. one-way.. really only good for checking known values and keeping them 'private', like storing passwords in a database. That way, if someone breaks into your database, they don't get the passwords, only the non-reversible MD5 hashes of the passwords. To check a user's login credentials, you take the database value for password and you compare it to md5($password) that the user entered and see if they match. That's also the way hackers break it, namely take the hash and use a reverse dictionary to look-up the password. While the MD5 hash is non-reversible, it produces a unique string. If people use simple passwords, then the hash is pretty simple to break. As people become more aware of how simple it is to break their passwords, their passwords will become more complex. However, reverse dictionaries will also become larger as processing speeds increase -- and the cycle continues. So, the amount of security that MD5 provides is really dependant upon the user. 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] One last try at this!
On 1/17/07, Beauford [EMAIL PROTECTED] wrote: I hope I can explain this so I can get this figured out, 'cause if not I may just have to find an alternative to PHP. I can't be wasting 3 and 4 days on something as simple as this. This isn't a very nice intro into asking a question on a mailing list. Nobody gets paid here to help you so you shouldn't demand it. I understand the desperation in being lost within a problem, but it isn't anyones fault except your own. I can assure you form validation is a big part of my daily routine at my job and it is possible. :) Below are 3 validation routines. When I first enter the page 'Optional' is displayed for all of them as it should be, but when I click submit on the form without entering any data, the first one displays optional (which it should), but the 2nd and 3rd ones execute the elseif and the validation routine says there are invalid characters in the string. If nothing is entered in the form where is it getting a value It should never get to the elseif to start with if nothing is entered in the form. So how can I make a reliable check? if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror['orgname'] = $result; } if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm not sure where your variables are being set. Are you relying on register globals for $orgname? Is $formerror being set with default values? What does ValidateString do? If you don't want to paste your code to this mailing list you can use http://pastebin.com/. Perhaps somebody smarter than me can figure it out, but I cannot until I see more. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
At 7:15 AM -0800 1/17/07, Ryan A wrote: True, but thats not the most important part... I guess I wrote it wrong, I meant that it should not write to disk before 1 minute... anyway... about the array saving any ideas? Thanks! R Why? 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] One last try at this!
Beauford wrote: I hope I can explain this so I can get this figured out, 'cause if not I may just have to find an alternative to PHP. I can't be wasting 3 and 4 days on something as simple as this. Below are 3 validation routines. When I first enter the page 'Optional' is displayed for all of them as it should be, but when I click submit on the form without entering any data, the first one displays optional (which it should), but the 2nd and 3rd ones execute the elseif and the validation routine says there are invalid characters in the string. If nothing is entered in the form where is it getting a value It should never get to the elseif to start with if nothing is entered in the form. So how can I make a reliable check? if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror['orgname'] = $result; } Take a little closer look at what you think are elseif statements below You are missing the else part :( if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One last try at this!
On 17 Jan 2007, at 17:38, Beauford wrote: if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror ['orgname'] = $result; } if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } Look at your conditional. To my (new to PHP) eyes, you're setting $result to whatever ValidateString($website, 2) returns. It should be: $result == ValidateString($website, 2) Some people countenance conditionals in the form: ValidateString($event, 2) == $result As this usually throws a fairly obvious error if you miss out the extra equals sign. Personally, I don't like this but I can see it helps one write more robust code the first time round. HTH Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: Curt Zirzow wrote: On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: ... if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { I was waiting for this to be mentioned... I would use a more detailed approach: http://pastebin.ca/319054 could you clarify alittle? (beyond not using the apache specific getallheaders() function - I chose to go that route because I never run on anything other than apache) is the value of $headers['If-Modified-Since'] identical to $_SERVER['HTTP_IF_MODIFIED_SINCE'] or *can* they differ (i.e. would it be stupid to assume that apache 'normalized' the modidfied-since string?) they should be identical, the one thing, iirc, is that the getallheaders() returns what exactly the client sent, so if the client sent 'if-modified-since:' then the assoc array would be $headers['if-modified-since']. is my code borked or merely not covering a number of edge cases related to older or more exotic browsers - my code does output 304 headers at the right time AFAIHT. As far as i can see nothing is wrong. After looking at rfc2616 i dont know why there is that $http_size thing going on in the code i posted; must be from a very early draft of HTTP/1.0 (as noted by the date in my comment) Forget i said anything. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] md5
Instead of hashing the password, i prefer to use the following procedure: $user = ... $password = ... $hash = md5($user . $password); Using this method, it will be very dificult guess the password if you get the hash because it depends also on the user name. When you are going to login a user you have to check the hash stored in the database against the result of applying the md5 function on the result of concatenating the user name and the password provided by the user. if ($db_hash == md5($user . $password)) { // logged } else { //error } On 1/17/07, tedd [EMAIL PROTECTED] wrote: That's also the way hackers break it, namely take the hash and use a reverse dictionary to look-up the password. While the MD5 hash is non-reversible, it produces a unique string. If people use simple passwords, then the hash is pretty simple to break. As people become more aware of how simple it is to break their passwords, their passwords will become more complex. However, reverse dictionaries will also become larger as processing speeds increase -- and the cycle continues. So, the amount of security that MD5 provides is really dependant upon the user. -- Saludos Oscar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing values in arrays
On Wed, 2007-01-17 at 07:15 -0800, Ryan A wrote: Hey! Thanks for replying. Instead of CRON i was thinking of having a file created and check the creation time everytime someone logged in... if its less than 1 min then don't do anything, if 1 min or more old... write file... But then it wouldn't be written to disk every one minute if someone didn't log in for 3 minutes ;) True, but thats not the most important part... I guess I wrote it wrong, I meant that it should not write to disk before 1 minute... anyway... about the array saving any ideas? ?php // untested if( ($fptr = fopen( '/tmp/mySavedArray.dat', 'wb' )) !== false ) { fwrite( $fptr, serialize( $myArray ) ); fclose( $fptr ); } ? There's also file_put_contents() but I generally go with backward compatible methods. 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
Re: [PHP] Storing values in arrays
On Wed, 2007-01-17 at 13:14 -0500, tedd wrote: At 7:15 AM -0800 1/17/07, Ryan A wrote: True, but thats not the most important part... I guess I wrote it wrong, I meant that it should not write to disk before 1 minute... anyway... about the array saving any ideas? Why? Why not? 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
Re: [PHP] md5
On Wed, 2007-01-17 at 13:51 -0500, Oscar Gosdinski wrote: Instead of hashing the password, i prefer to use the following procedure: $user = ... $password = ... $hash = md5($user . $password); Using this method, it will be very dificult guess the password if you get the hash because it depends also on the user name. When you are going to login a user you have to check the hash stored in the database against the result of applying the md5 function on the result of concatenating the user name and the password provided by the user. if ($db_hash == md5($user . $password)) { // logged } else { //error } Yep, never a good idea to just rote md5() the password. Best to add a sprinkle of salt, that way you avoid precomputed lookups. For instance if you're server ever got compromised and the attacker got your md5 passwords, if they already had a precomputed database then finding the reverse of the hash would be trivial. 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
RE: [PHP] One last try at this!
Your right. I have been sitting here at this computer for 3 days straight with all the various problems, and I missed this. I need a break, I need a KitKat. Thanks to the list for all the help over the last couple of days. I'm going to watch CSI and get away from this. Take a little closer look at what you think are elseif statements below You are missing the else part :( if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } Again, sorry to be a pain, but I just don't get it. Thanks -- 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] $_SESSION variable gets lost on FORM action
Stut wrote: Redirecting using a Location header is not the only thing you can do with the header() function. It will never end processing of the script no matter what you pass to it. The example on the manual page for the header() function says as much (http://php.net/header), you read that right? ?php header(Location: http://www.example.com/;); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ? -Stut Well, I feel like a du***ss! No, I hadn't read that. I promisse, and this one is to keep, I won't post to this list again without dedicate enough time to the problem, at least to read the manual. Anyway, thank you for confirm what I should have known in advance and also for remembering me that PHP developers have a PHP manual for PHP users... Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
I got it working like this: $counter = 0; foreach ($arr as $value) { //make the form ... print input type=\text\ name=\ArrUpdate[$counter][]\ value =\$value[0]\\n; $counter++; } Now I have array $ArrUpdate which contains sub-arrays with the update data. This can now be processed with another foreach loop -Will Jochem Maas [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] Németh Zoltán wrote: And how does it work? does it create a sub-array of $_POST? test it and find out: echo 'pre'; var_dump($_POST); echo '/pre'; And is it documented somewhere in the manual? more than likely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] One last try at this!
[snip] if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror['orgname'] = $result; } if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } [/snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) [snip] Again, sorry to be a pain, but I just don't get it. [/snip] No problem Grasshopper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One last try at this!
Jay Blanchard wrote: [snip] if(empty($orgname)) { $formerror['orgname'] = Optional; } elseif($result = ValidateString($orgname, 2)) { $formerror['orgname'] = $result; } if(empty($website)) { $formerror['website'] = Optional; } if($result = ValidateString($website, 2)) { $formerror['website'] = $result; } if(empty($event)) { $formerror['event'] = Optional; } if($result = ValidateString($event, 2)) { $formerror['event'] = $result; } [/snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } Jim Lucas [snip] Again, sorry to be a pain, but I just don't get it. [/snip] No problem Grasshopper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] web form data to arrays?
William Stokes wrote: Hello, I have a script which retrieves rows from DB and prints them to a user editable form to a web page. I don't know how to print the form objects so that all editable fields are put to arrays for updating them to DB. I have tried to create arrays sarjanID[] etc. but havent got it to work... Pls. see code below. Thanks -Will $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 'sorter' ASC; $row = mysql_fetch_row($result); $result = mysql_query($sql); $num = mysql_num_rows($result); $cur = 1; while ($num = $cur) { $row = mysql_fetch_array($result); $id = $row[id]; $nimi = $row[nimi]; $kilpailutyyppi = $row[kilpailutyyppi]; $sarjataulukko = $row[sarjataulukko]; $joukkueitakpl = $row[joukkueitakpl]; $sorter = $row[sorter]; $kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, $joukkueitakpl, $sorter); //create arrays here $cur++; } .. foreach ($kilpailut as $value) { //print arrays to a web form if ($value[3] == 1) { $staulu = Kyllä; } elseif ($value[3] == 0) { $staulu = Ei; } print input type=\hidden\ name=\sarjanID[ID]\ value =\$value[0]\\n; print input type=\text\ name=\sarjanID[nimi]\ size=\20\ maxlength=\20\ value =\$value[1]\\n; print select name=\sarjanID[tyyppi]\\n; print option selected$value[2]/option\n; print optionSarja/option\n; print optionCup/option\n; print /select\n; print select name=\sarjanID[sarjataulukko]\\n; print option selected$staulu/option\n; print optionKylla;/option\n; print optionEi/option\n; print /select\n; print select name=\sarjanID[joukkueitayht]\\n; print option selected$value[4]/option\n; for ($i=3; $i=20; $i++ ) { print option$i/option\n; } print /select\n; print input type=\text\ name=\sarjanID[sortteri]\ value =\$value[5]\\n; print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n; } Here is an example that I just setup on my new billing system Section/Row1 div class=col1Location/Contact Name:/div div class=col2input type=hidden name=myValues[sec0][location_name'] value=Billing Address size=32 maxlength=64 autocomplete=off /Billing Address/div div class=col1First Name:/div div class=col2input type=text name=myValues[sec0][first_name] size=32 maxlength=64 autocomplete=off //div div class=col1Last Name:/div div class=col2input type=text name=myValues[sec0][last_name] size=32 maxlength=64 autocomplete=off //div div class=col1Middle Name:/div div class=col2input type=text name=myValues[sec0][middle_name] size=32 maxlength=64 autocomplete=off //div div class=col1address 1:/div div class=col2input type=text name=myValues[sec0][address1] size=48 maxlength=255 autocomplete=off //div Section/Row2 div class=col1Location/Contact Name:/div div class=col2input type=hidden name=myValues[sec1][location_name'] value=Ship To size=32 maxlength=64 autocomplete=off /Service Location/div div class=col1First Name:/div div class=col2input type=text name=myValues[sec1][first_name] size=32 maxlength=64 autocomplete=off //div div class=col1Last Name:/div div class=col2input type=text name=myValues[sec1][last_name] size=32 maxlength=64 autocomplete=off //div div class=col1Middle Name:/div div class=col2input type=text name=myValues[sec1][middle_name] size=32 maxlength=64 autocomplete=off //div div class=col1address 1:/div div class=col2input type=text name=myValues[sec1][address1] size=48 maxlength=255 autocomplete=off //div Then on the server side, I do this. // Sent via POST if ( isset( $_POST['myValues'] ) ) { foreach ( $_POST['myValues'] AS $section = $data ) { // $data is now an array that contains all the entries for the specific section ie: sec0, sec1, etc... // Do something with $data } } else { die(didn't get anything); } Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] One last try at this!
[snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } [/snip] Hmmm.did you test that? $result = ValidateString($event, 2) is always TRUE, $result has had something assigned to it unless the function ValidateString returns a FALSE. The OP never provided the code for the function so we just don't know. Also, the OP forgot to run subsequent conditions in an elseif check, instead he used 3 if statements that will be executed each time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variable gets lost on FORM action
# [EMAIL PROTECTED] / 2007-01-17 19:06:16 +: Stut wrote: Redirecting using a Location header is not the only thing you can do with the header() function. It will never end processing of the script no matter what you pass to it. The example on the manual page for the header() function says as much (http://php.net/header), you read that right? Well, I feel like a du***ss! No, I hadn't read that. I promisse, and this one is to keep, I won't post to this list again without dedicate enough time to the problem, at least to read the manual. Anyway, thank you for confirm what I should have known in advance and also for remembering me that PHP developers have a PHP manual for PHP users... Also, the header() call you provided in the original post was a violation of HTTP. Knowing the programming language is just one of your responsibilities IMNSHO. The manual for HTTP users (you!) is at ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting domain out of a URL
Hi, I receive posts from an open moderated forum that need to be filtered for urls. I've successfully managed to trap any entires that use 'http://' 'www.' with the standard '.com' '.org', '.net' endings. What I need to do is to strip the prefix part ('http:// or http://www. or 'www') and suffix as well (the .com, etc.) I need only the domain name. I can't seem to trim away the suffix part. The code I've tried: $_POST['request'] = . . The third has it all www.borko.worko.com and meanders on. Then it stops.; $check = $_POST['request']; if (preg_match(@^(?:www.)?([^/]+)@i, $check, $match)) { $host = $match[1]; (print brdiv class='center' h4brbrbrURLs are not permitted brbr Click 'Back' on your browser and delete all URL references. /h4brbrbr/div); /* EXTRA 1: Added to see what's happening */ print h4 style='color:green;'$match[1]/h4brbr; /* END EXTRA 1 */ $boom = explode(www., $host); foreach($boom as $key = $host){ $boom[$key] = $host; } $booms = implode(www., $boom); $out = (preg_match('[.com]', $boom[1], $match)); /* EXTRA 2: Added to see what's happening */ echo b style='color:blue;'The BOOM1 SPLIT Domain Name is:/b {$boom[1]}brbrbr; echo b style='color:green;'The OUT SPLIT Domain Name is:/b {$out}brbrbr; /* EXTRA 2 */ What ouputs: Extra 1: . . The third has it all www.borko.worko.com and meanders on. Then it stops. Extra 2 BOOM1 SPLIT: borko.worko.com and meanders on. Then it stops. Extra 2 OUT SPLIT: nothing There's gotta be a better, simpler way of doing this. I want to check for the string in the POST. If it's there, tag it, and be able to save it, and re-enter just the domain back into future checks based on the IP address as well. Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Getting domain out of a URL
[snip] I receive posts from an open moderated forum that need to be filtered for urls. I've successfully managed to trap any entires that use 'http://' 'www.' with the standard '.com' '.org', '.net' endings. What I need to do is to strip the prefix part ('http:// or http://www. or 'www') and suffix as well (the .com, etc.) I need only the domain name. I can't seem to trim away the suffix part. [/snip] Have you looked at http://us3.php.net/manual/en/function.parse-url.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic lists
I'm a noob. My question is whether PHP can produce dynamic drop lists and if so what the tags are so that I can look them up. By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. For instance: say the first list is of the states, then the second list updates to contain cities within that state as options. Thanks, Don
RE: [PHP] dynamic lists
[snip] By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. [/snip] PHP is server side, you need to do this with AJAX or Javascript -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One last try at this!
Jay Blanchard wrote: [snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } [/snip] Hmmm.did you test that? $result = ValidateString($event, 2) is always TRUE, $result has had something assigned to it unless the function ValidateString returns a FALSE. The OP never provided the code for the function so we just don't know. Also, the OP forgot to run subsequent conditions in an elseif check, instead he used 3 if statements that will be executed each time. At one point he mentioned changing ValidateString() to return false on an error. At least that is what I thought he said. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic lists
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 17, 2007 4:05 PM To: Don; php-general@lists.php.net Subject: RE: [PHP] dynamic lists [snip] By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. [/snip] PHP is server side, you need to do this with AJAX or Javascript -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Don, There's a few different ways to do this. #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction(...)). I like #2. If you need a starting point, google for javascript dynamic select list Hope that helps, Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More efficient thumbnail script
Curt Zirzow wrote: On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: Curt Zirzow wrote: On 1/16/07, Jochem Maas [EMAIL PROTECTED] wrote: ... if ($cacheState) { $headers = getallheaders(); if (isset($headers['If-Modified-Since']) ($headers['If-Modified-Since'] == $lastModified)) { I was waiting for this to be mentioned... I would use a more detailed approach: http://pastebin.ca/319054 could you clarify alittle? (beyond not using the apache specific getallheaders() function - I chose to go that route because I never run on anything other than apache) is the value of $headers['If-Modified-Since'] identical to $_SERVER['HTTP_IF_MODIFIED_SINCE'] or *can* they differ (i.e. would it be stupid to assume that apache 'normalized' the modidfied-since string?) they should be identical, the one thing, iirc, is that the getallheaders() returns what exactly the client sent, so if the client sent 'if-modified-since:' then the assoc array would be $headers['if-modified-since']. given that there may be difference in capitalization and the fact that getallheaders() is apache specific it seems to me that using $_SERVER['HTTP_IF_MODIFIED_SINCE'] would be better (not to mention saving a function call). is my code borked or merely not covering a number of edge cases related to older or more exotic browsers - my code does output 304 headers at the right time AFAIHT. As far as i can see nothing is wrong. After looking at rfc2616 i dont know why there is that $http_size thing going on in the code i posted; must be from a very early draft of HTTP/1.0 (as noted by the date in my comment) Forget i said anything. given enough time it's garanteed ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic lists
On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote: -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 17, 2007 4:05 PM To: Don; php-general@lists.php.net Subject: RE: [PHP] dynamic lists [snip] By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. [/snip] PHP is server side, you need to do this with AJAX or Javascript -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Don, There's a few different ways to do this. #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction (...)). I like #2. If you need a starting point, google for javascript dynamic select list Hope that helps, Brad FYI... Neither #1 or #2 are considered good practice for Accessibility/ADA compliance. If you are using a keyboard or screen reader to view your website, it will always pick the first one in the list and you won't have the option of even seeing the rest of the list. Basically, anything that uses onchange or onselect will cause accessibility issues. The only way to accomplish this is using onclick or submitting the form. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326
Re: [PHP] dynamic lists
Kevin Murphy wrote: On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote: -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 17, 2007 4:05 PM To: Don; php-general@lists.php.net Subject: RE: [PHP] dynamic lists [snip] By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. [/snip] PHP is server side, you need to do this with AJAX or Javascript -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Don, There's a few different ways to do this. #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction(...)). I like #2. If you need a starting point, google for javascript dynamic select list Hope that helps, Brad FYI... Neither #1 or #2 are considered good practice for Accessibility/ADA compliance. If you are using a keyboard or screen reader to view your website, it will always pick the first one in the list and you won't have the option of even seeing the rest of the list. Basically, anything that uses onchange or onselect will cause accessibility issues. The only way to accomplish this is using onclick or submitting the form. that stance basically negates everything 'ajax', flash, video and everything considered to be remotely 'web2.0' - is the 'low-common-denominator' case always the correct choice? I understand the importance of accessibility but the practicality of most peoples' job in this sector means satisfying the requirements of a client that demands such dynamic functionality such as the auto-selection example given here. is there not an argument that screen-reader and [braille] keyboard software are somwhat responsible for being capable of 'keeping up' - given that an onclick can be handled why not an 'onchange' (in theory)? --Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic lists
On Jan 17, 2007, at 2:20 PM, Jochem Maas wrote: Kevin Murphy wrote: On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote: -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 17, 2007 4:05 PM To: Don; php-general@lists.php.net Subject: RE: [PHP] dynamic lists [snip] By dynamic drop list I mean the type where the options contained in the subsequent list depend on what was picked in the previous list without clicking submit. [/snip] PHP is server side, you need to do this with AJAX or Javascript -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Don, There's a few different ways to do this. #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction (...)). I like #2. If you need a starting point, google for javascript dynamic select list Hope that helps, Brad FYI... Neither #1 or #2 are considered good practice for Accessibility/ADA compliance. If you are using a keyboard or screen reader to view your website, it will always pick the first one in the list and you won't have the option of even seeing the rest of the list. Basically, anything that uses onchange or onselect will cause accessibility issues. The only way to accomplish this is using onclick or submitting the form. that stance basically negates everything 'ajax', flash, video and everything considered to be remotely 'web2.0' - is the 'low-common- denominator' case always the correct choice? I understand the importance of accessibility but the practicality of most peoples' job in this sector means satisfying the requirements of a client that demands such dynamic functionality such as the auto-selection example given here. is there not an argument that screen-reader and [braille] keyboard software are somwhat responsible for being capable of 'keeping up' - given that an onclick can be handled why not an 'onchange' (in theory)? Not saying I disagree with you. which is why i tossed it out there as an FYI rather than anything else. But its something that you should be aware of when designing a site and weighing your options. For me, working for a governmental institution, I really don't have a choice. I can't throw anything into the website that has a negative ADA impact unless of course I have an alternate way of accomplishing the same thing. And yes, there is an argument that screen-readers should keep up with the technology, and I totally agree with you. but that's not reality. Target.com got sued recently for lack of ADA compliance on their website. The screen reading software company wasn't the one sued. YMMV. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326
Re: [PHP] dynamic lists
# [EMAIL PROTECTED] / 2007-01-17 23:20:23 +0100: Kevin Murphy wrote: On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote: #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction(...)). I like #2. If you need a starting point, google for javascript dynamic select list FYI... Neither #1 or #2 are considered good practice for Accessibility/ADA compliance. If you are using a keyboard or screen reader to view your website, it will always pick the first one in the list and you won't have the option of even seeing the rest of the list. Basically, anything that uses onchange or onselect will cause accessibility issues. The only way to accomplish this is using onclick or submitting the form. that stance basically negates everything 'ajax', flash, video and everything considered to be remotely 'web2.0' - is the 'low-common-denominator' case always the correct choice? And what about the my-ajax-is-longer-than-your-ajax (or whatever's in right now (is in still a cool word?)) lemming-march mentality? I understand the importance of accessibility but the practicality of most peoples' job in this sector means satisfying the requirements of a client that demands such dynamic functionality such as the auto-selection example given here. That's typically a result of poor user requirements capture. :) is there not an argument that screen-reader and [braille] keyboard software are somwhat responsible for being capable of 'keeping up' - given that an onclick can be handled why not an 'onchange' (in theory)? Yeah, wheelchairs can move along a sidewalk, so what's stopping them from walking up and down stairs? If you haven't written an open source browser on par with mozilla for blind people, it's IMO polite to not raise the bar for them unless necessary. KISS and all that. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting domain out of a URL
On Wednesday 17 January 2007 03:35 pm, Jay Blanchard wrote: [snip] I receive posts from an open moderated forum that need to be filtered for urls. I've successfully managed to trap any entires that use 'http://' 'www.' with the standard '.com' '.org', '.net' endings. What I need to do is to strip the prefix part ('http:// or http://www. or 'www') and suffix as well (the .com, etc.) I need only the domain name. I can't seem to trim away the suffix part. [/snip] Have you looked at http://us3.php.net/manual/en/function.parse-url.php Thanks Jay for the function reference, but it doesn't seem like it's what I'm after since the url is packed into the text. What i really need is something that will take the first part of an array cutting the remainder after a delimiter word '.com'. Something along the lines of: ?php $boom[1] = ranchy.stuff.com and other junk; $input = $boom[1]; $out = array_slice($input, 0, 1); ? Part of my problem, I'm beginning to realize, is that the array '$boom[1]' contains only one element. Is there a similar string function I could use that would accomplish what I need? Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script to generate a site thumbnails
Hi People, I'm needing a script that generate a site thumbnail from a given URL. Anybody can help me? Thanks, -- Pablo Lacerda de Miranda Graduando Sistemas de Informação Universidade Estadual de Montes Claros [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting domain out of a URL
# [EMAIL PROTECTED] / 2007-01-17 17:53:09 -0500: On Wednesday 17 January 2007 03:35 pm, Jay Blanchard wrote: [snip] I receive posts from an open moderated forum that need to be filtered for urls. I've successfully managed to trap any entires that use 'http://' 'www.' with the standard '.com' '.org', '.net' endings. What I need to do is to strip the prefix part ('http:// or http://www. or 'www') and suffix as well (the .com, etc.) I need only the domain name. I can't seem to trim away the suffix part. [/snip] Have you looked at http://us3.php.net/manual/en/function.parse-url.php Thanks Jay for the function reference, but it doesn't seem like it's what I'm after since the url is packed into the text. What i really need is something that will take the first part of an array cutting the remainder after a delimiter word '.com'. Something along the lines of: ?php $boom[1] = ranchy.stuff.com and other junk; $input = $boom[1]; $out = array_slice($input, 0, 1); ? Part of my problem, I'm beginning to realize, is that the array '$boom[1]' contains only one element. Is there a similar string function I could use that would accomplish what I need? If there isn't one you can always compose it from the ones already available. That's programming. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] One last try at this!
This is what I am trying to do, and for the most part it works, but it also may be causing some of my other problems. If $event contains invalid characters, I am returning a string that says Invalid Characters So $result now contains the value 'Invalid Characters'. Then $formerror['event'] = $result - is self explanatory. If there are no errors nothing is returned and $result should contain anything. But this doesn't always seem to be the case. This is one of the problems I am having. This is the code in a nutshell. if($result = ValidateString($event)) { $formerror['event'] = $result; function ValidateString($string) { if(!preg_match(/^[-A-Za-z0-9_.' ]+$/, $string)) { return Invalid Characters; } Thanks -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: January 17, 2007 4:36 PM To: Jay Blanchard Cc: Beauford; PHP Subject: Re: [PHP] One last try at this! Jay Blanchard wrote: [snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } [/snip] Hmmm.did you test that? $result = ValidateString($event, 2) is always TRUE, $result has had something assigned to it unless the function ValidateString returns a FALSE. The OP never provided the code for the function so we just don't know. Also, the OP forgot to run subsequent conditions in an elseif check, instead he used 3 if statements that will be executed each time. At one point he mentioned changing ValidateString() to return false on an error. At least that is what I thought he said. -- 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] Getting domain out of a URL
[snip] Something along the lines of: ?php $boom[1] = ranchy.stuff.com and other junk; $input = $boom[1]; $out = array_slice($input, 0, 1); ? Part of my problem, I'm beginning to realize, is that the array '$boom[1]' contains only one element. Is there a similar string function I could use that would accomplish what I need? [/snip] Why not use explode with the period (.) as the delimiter? $url = ranchy.stuff.com and other junk; $boom = explode(., $url); print_r($boom); $boom is now an array containing 'ranchy', 'stuff', 'com and other junk' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where can I get the Printer extension?
Chuck Anderson wrote: It thought it would be bundled with my Windows version pf Php 4.4.1, but it is not. I've searched for it and can't find it at php.net. You didn't search very hard. On this page: http://php.net/printer Read the bit under Installation. This PECL extension is not bundled with PHP. and You may obtain this unbundled PECL extension from the various PECL snaps pages (select the appropriate repository for your version of PHP): PECL for PHP 4.3.x, PECL for PHP 5.0.x or PECL Unstable. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where can I get the Printer extension?
Chris wrote: Chuck Anderson wrote: It thought it would be bundled with my Windows version pf Php 4.4.1, but it is not. I've searched for it and can't find it at php.net. You didn't search very hard. On this page: http://php.net/printer Read the bit under Installation. This PECL extension is not bundled with PHP. and You may obtain this unbundled PECL extension from the various PECL snaps pages (select the appropriate repository for your version of PHP): PECL for PHP 4.3.x, PECL for PHP 5.0.x or PECL Unstable. I did look there. I did read that. You didn't try those links, though, did you? (Not Found) (btw, I asked in another group and just found that it is located here: http://pecl4win.php.net/index.php) I don't see how to get there from the main PECL site, but there it is. -- * Chuck Anderson • Boulder, CO http://www.CycleTourist.com * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic lists
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2007-01-17 23:20:23 +0100: Kevin Murphy wrote: On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote: #1) Submit the form (to itself) when a user chooses an option from the first list (using onChange=form.submit()) then with PHP query the database for the second set of options. #2) Use JavaScript to store all the values and pop them in when the user chooses an option from the first list (using onChange=someFunction(...)). I like #2. If you need a starting point, google for javascript dynamic select list FYI... Neither #1 or #2 are considered good practice for Accessibility/ADA compliance. If you are using a keyboard or screen reader to view your website, it will always pick the first one in the list and you won't have the option of even seeing the rest of the list. Basically, anything that uses onchange or onselect will cause accessibility issues. The only way to accomplish this is using onclick or submitting the form. that stance basically negates everything 'ajax', flash, video and everything considered to be remotely 'web2.0' - is the 'low-common-denominator' case always the correct choice? And what about the my-ajax-is-longer-than-your-ajax (or whatever's in right now (is in still a cool word?)) lemming-march mentality? I think 'correct' was the wrong word. still thinking what the right word should be. bare in mind I was playing devil's advocate rather than defending a particular stance. I understand the importance of accessibility but the practicality of most peoples' job in this sector means satisfying the requirements of a client that demands such dynamic functionality such as the auto-selection example given here. That's typically a result of poor user requirements capture. :) of course the level of requirement/functional specification one can do is dependant on (at least) 2 things: 1. budget - building a small (5000 euros) site leaves not much money for developing detailed specs, it easy enough to blow 5 grand on a preliminary investigation let alone something that resembles a fullblown spec. 2. client - can the client even comprehend the specs and the ramifications they entail, a small local business has no idea (or interest) in the problems, ramifications and technicalities of site building - he/she just want's a website. is there not an argument that screen-reader and [braille] keyboard software are somwhat responsible for being capable of 'keeping up' - given that an onclick can be handled why not an 'onchange' (in theory)? Yeah, wheelchairs can move along a sidewalk, so what's stopping them from walking up and down stairs? no doubt the economics of greed - technically it possible to, I mean Honda built a freakin' robot that runs up stair and I seen multiple axel wheelchairs on TV more than 15 years ago (anyone in England know the 'Tomorrows World' program from the time when it was still about real science? ;-) that were capable of traversing stairs. but applying the extreme accessiblity mantra to the stairs analogy would mean making stairs more or less illegal. should we sue companies out of existence because they have a set of stairs? should stairs be illegal? If you haven't written an open source browser on par with mozilla for blind people, has anyone actually achieved that? actually my comment was aimed purely at commercial software, which, for now, AFAICT is the only real option for disabled people - and it's not a cheap option either, so the bar is set very high in the economic sense, disabled people in a low/no income are often shut out purely on budgetary grounds. should commercial vendors that supply tools to enable disabled people be held to a [very] high standard? additionally it could be said that the only feasible proposition is to make the the enabling tools adapt to the environment they are intended to make accessible? to return to the wheel chair analogy: it's completely impractical to replace all stairs in the world with suitable ramps but it is technically achievable to build a wheelchair that is capable of navigating a world full of chairs. it's IMO polite to not raise the bar for them unless necessary. KISS and all that. there are plenty of multi-billion dollar corporations that pay nothing more than lip service to accessibility - those same companies are the examples alot of my clients point at when telling me what they want. (I'm painting with a broad brush here) if I completely refuse to 'raise the bar' then I'm going to be flipping burgers at sooner than I'd like - my clients will go else where. so I'm stuck between doing 'the right thing' and paying the bills - all this is rather a moot issue in a world where millions of disabled people don't even have access to running water, let alone wheelchairs - so extending KISS approach all the way down the line I would say fuck what's happening online completely and let's all try to make sure everyone on the
Re: [PHP] Where can I get the Printer extension?
Chuck Anderson wrote: Chris wrote: Chuck Anderson wrote: It thought it would be bundled with my Windows version pf Php 4.4.1, but it is not. I've searched for it and can't find it at php.net. You didn't search very hard. On this page: http://php.net/printer Read the bit under Installation. This PECL extension is not bundled with PHP. and You may obtain this unbundled PECL extension from the various PECL snaps pages (select the appropriate repository for your version of PHP): PECL for PHP 4.3.x, PECL for PHP 5.0.x or PECL Unstable. I did look there. I did read that. You didn't try those links, though, did you? (Not Found) (btw, I asked in another group and just found that it is located here: http://pecl4win.php.net/index.php) I don't see how to get there from the main PECL site, but there it is. Consider myself reprimanded :P However you didn't mention that the links didn't work ;) Post a documentation bug at http://bugs.php.net :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting domain out of a URL {SOLVED]
On Wednesday 17 January 2007 06:16 pm, Jay Blanchard wrote: [snip] Why not use explode with the period (.) as the delimiter? $url = ranchy.stuff.com and other junk; $boom = explode(., $url); print_r($boom); $boom is now an array containing 'ranchy', 'stuff', 'com and other junk' Sigh. I have used that code just above the area I have been working on . . . it's been a long day. Thanks - it does the job very well! Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variable gets lost on FORM action
Roman wrote: # [EMAIL PROTECTED] / 2007-01-17 19:06:16 +: Stut wrote: Redirecting using a Location header is not the only thing you can do with the header() function. It will never end processing of the script no matter what you pass to it. The example on the manual page for the header() function says as much (http://php.net/header), you read that right? Well, I feel like a du***ss! No, I hadn't read that. I promisse, and this one is to keep, I won't post to this list again without dedicate enough time to the problem, at least to read the manual. Anyway, thank you for confirm what I should have known in advance and also for remembering me that PHP developers have a PHP manual for PHP users... Also, the header() call you provided in the original post was a violation of HTTP. Knowing the programming language is just one of your responsibilities IMNSHO. The manual for HTTP users (you!) is at ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt Hi Roman, My English is not the best and I'm not sure what you mean. By looking at the document you linked I'm thinking that the problem you're talking about is not the '?var=value' but instead, the fact of being using a relative URL. Am I correct? If so, is there a way to know the full address of the index.php file? I'm asking this because my IP is dynamic and I'm using a free redirection service. My site is at 'http://something.no-ip.org/sitename' can I use 'http://something.no-ip.org/sitename/index.php?vaz=value' on the Locarion header? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variable gets lost on FORM action
# [EMAIL PROTECTED] / 2007-01-18 00:06:27 +: Roman wrote: Also, the header() call you provided in the original post was a violation of HTTP. Knowing the programming language is just one of your responsibilities IMNSHO. The manual for HTTP users (you!) is at ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt My English is not the best and I'm not sure what you mean. By looking at the document you linked I'm thinking that the problem you're talking about is not the '?var=value' but instead, the fact of being using a relative URL. Am I correct? Yes. If so, is there a way to know the full address of the index.php file? You don't need to know your IP. See the grammar for AbsoluteURI: ftp://ftp.rfc-editor.org/in-notes/rfc2396.txt I'm asking this because my IP is dynamic and I'm using a free redirection service. My site is at 'http://something.no-ip.org/sitename' can I use 'http://something.no-ip.org/sitename/index.php?vaz=value' on the Locarion header? Actually you *must* use it instead of just the index... part. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One last try at this!
Beauford wrote: This is what I am trying to do, and for the most part it works, but it also may be causing some of my other problems. If $event contains invalid characters, I am returning a string that says Invalid Characters So $result now contains the value 'Invalid Characters'. Then $formerror['event'] = $result - is self explanatory. If there are no errors nothing is returned and $result should contain anything. But this doesn't always seem to be the case. This is one of the problems I am having. This is the code in a nutshell. if($result = ValidateString($event)) { $formerror['event'] = $result; function ValidateString($string) { if(!preg_match(/^[-A-Za-z0-9_.' ]+$/, $string)) { return Invalid Characters; } Thanks In your regex you have a . this will match anything try this: plaintext?php function ValidateString($string) { if ( preg_match(/[^a-zA-Z0-9\_\.\' -]+/, $string) ) { return Invalid Characters; } return false; } $formerror = array(); $formerror['firstAttempt'] = 'first attempt'; $formerror['secondAttempt'] = 'second attempt'; $event = A-Z and a-z plus 0-9 and an '_' are allowed.; if ( ( $result = ValidateString($event) ) !== false ) { $formerror['firstAttempt'] = $result; } $event = But bad chars like [EMAIL PROTECTED] and %^* are not allowed.; if ( ( $result = ValidateString($event) ) !== false ) { $formerror['secondAttempt'] = $result; } var_dump($formerror); ? Jim Lucas -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: January 17, 2007 4:36 PM To: Jay Blanchard Cc: Beauford; PHP Subject: Re: [PHP] One last try at this! Jay Blanchard wrote: [snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } [/snip] Hmmm.did you test that? $result = ValidateString($event, 2) is always TRUE, $result has had something assigned to it unless the function ValidateString returns a FALSE. The OP never provided the code for the function so we just don't know. Also, the OP forgot to run subsequent conditions in an elseif check, instead he used 3 if statements that will be executed each time. At one point he mentioned changing ValidateString() to return false on an error. At least that is what I thought he said. -- 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] One last try at this!
Jim Lucas wrote: Beauford wrote: This is what I am trying to do, and for the most part it works, but it also may be causing some of my other problems. If $event contains invalid characters, I am returning a string that says Invalid Characters So $result now contains the value 'Invalid Characters'. Then $formerror['event'] = $result - is self explanatory. If there are no errors nothing is returned and $result should contain anything. But this doesn't always seem to be the case. This is one of the problems I am having. This is the code in a nutshell. if($result = ValidateString($event)) { $formerror['event'] = $result; function ValidateString($string) { if(!preg_match(/^[-A-Za-z0-9_.' ]+$/, $string)) { return Invalid Characters; } Thanks In your regex you have a . this will match anything try this: plaintext?php function ValidateString($string) { if ( preg_match(/[^a-zA-Z0-9\_\.\' -]+/, $string) ) { return Invalid Characters; } return false; } $formerror = array(); forgot to say that all you need to do to get rid of the default values is remove the following two lines $formerror['firstAttempt'] = 'first attempt'; $formerror['secondAttempt'] = 'second attempt'; $event = A-Z and a-z plus 0-9 and an '_' are allowed.; if ( ( $result = ValidateString($event) ) !== false ) { $formerror['firstAttempt'] = $result; } $event = But bad chars like [EMAIL PROTECTED] and %^* are not allowed.; if ( ( $result = ValidateString($event) ) !== false ) { $formerror['secondAttempt'] = $result; } var_dump($formerror); ? Jim Lucas -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: January 17, 2007 4:36 PM To: Jay Blanchard Cc: Beauford; PHP Subject: Re: [PHP] One last try at this! Jay Blanchard wrote: [snip] The second condition of each if statement does not contain equality checking, it sets the $result to ValidateString($event, 2). That should be if($result == ValidateString($event, 2)) or if($result === ValidateString($event, 2)) What if the intension was to fail if the result of ValidateString() was false?? Then it should be writen as such. if ( ( $result = ValidateString($event, 2) ) !== FALSE ) { $formerror['event'] = $result; } [/snip] Hmmm.did you test that? $result = ValidateString($event, 2) is always TRUE, $result has had something assigned to it unless the function ValidateString returns a FALSE. The OP never provided the code for the function so we just don't know. Also, the OP forgot to run subsequent conditions in an elseif check, instead he used 3 if statements that will be executed each time. At one point he mentioned changing ValidateString() to return false on an error. At least that is what I thought he said. -- 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] Storing values in arrays
Hello Ryan A, PHP has not application var, and not multi thread the only way is database, share memory. Best regards, === At 2007-01-17, 16:39:31 you wrote: === Hi, I think its easier to explain what I want to do.. so here goes: I want to store values in arrays for one minute and then write them to file. For example, everytime someone logs in I want their username to be in an array 1 or 100 or X people may login in 60 seconds...but it should only write all the usernames that logged in to disk every 1 minute. Ideas? suggestions? starting points or a link to a specific spot in the manual with a RTFM would be appreciated :) Thanks in advance, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar. = = = = = = = = = = = = = = = = = = = = Nicholas Yim [EMAIL PROTECTED] 2007-01-18 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] is there another way ??
can you please check these out and tell me if there another way without installing externsions?? http://groups-beta.google.com/group/cpdevgroup/web/how-easy-is-these-project?_done=%2Fgroup%2Fcpdevgroup%2Fweb%2Fhow-easy-is-these-project%3Fmsg%3Dns
[PHP] May I be added to the list?
Hello, I am hoping to be able to be added to the pear general mailing list. Thanks, --Bernie Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is there another way ??
Oops, i forgot to reply to php-general@ on this use this reply instead of the one i sent to your specific email. On 1/16/07, Ali Nasser [EMAIL PROTECTED] wrote: can you please check these out and tell me if there another way without installing externsions?? http://groups-beta.google.com/group/cpdevgroup/web/how-easy-is-these-project?_done=%2Fgroup%2Fcpdevgroup%2Fweb%2Fhow-easy-is-these-project%3Fmsg%3Dns Perhaps, php.net/proc_open Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] May I be added to the list?
On 1/15/07, Bernie Graham [EMAIL PROTECTED] wrote: Hello, I am hoping to be able to be added to the pear general mailing list. Go to http://pear.php.net/support/ Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] format timestamp
Hi all , I am using php 4.2 , mysql and Linux OS. I need to format timestamp to string using strftime , for e.g: strftime('%e',117000) - the day should be 28 , but is 29 when i execute strftime() function. Anyone have ideas what is the problems ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] format timestamp
On 1/17/07, weetat [EMAIL PROTECTED] wrote: Hi all , I am using php 4.2 , mysql and Linux OS. I need to format timestamp to string using strftime , for e.g: strftime('%e',117000) - the day should be 28 , but is 29 when i execute strftime() function. Anyone have ideas what is the problems ? Upgrade to a more recent version of php? with php5.2 i get 28, with php version 4.4 i get 28. You have to remember the last version of 4.2 was release on 6 September 2002, it is 2007 right now iirc. See php.net/releases/ for more information. Curt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] format timestamp
weetat wrote: Hi all , I am using php 4.2 , mysql and Linux OS. I need to format timestamp to string using strftime , for e.g: strftime('%e',117000) - the day should be 28 , but is 29 when i execute strftime() function. Anyone have ideas what is the problems ? Thanks could be as simple as the TZ of your system. or day lights saving ??? What TZ is your server set for? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] format timestamp
weetat wrote: Hi all , I am using php 4.2 , mysql and Linux OS. I need to format timestamp to string using strftime , for e.g: strftime('%e',117000) - the day should be 28 , but is 29 when i execute strftime() function. Anyone have ideas what is the problems ? Thanks I am running 4.3.11 my current time is Wed Jan 17 19:32:31 PST 2007 and I get 28. Check also the date and time of the server you are running on and make sure that it is set correctly to your local -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting domain out of a URL
[snip] I receive posts from an open moderated forum that need to be filtered for urls. I've successfully managed to trap any entires that use 'http://' 'www.' with the standard '.com' '.org', '.net' endings. What I need to do is to strip the prefix part ('http:// or http://www. or 'www') and suffix as well (the .com, etc.) I need only the domain name. I can't seem to trim away the suffix part. [/snip] What I've done in situations like this is reverse the text and tackle it from the _back_ end. It's a simpler approach to first trim off the TLD, and then to extract only the (reversed) domain name. (Tho', it's not a domain name without the TLD.) Then, obviously, reverse your results. HTH Jonesy -- Marvin L Jones| jonz | W3DHJ | linux 38.24N 104.55W | @ config.com | Jonesy | OS/2 *** Killfiling google posts: http://jonz.net/ng.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Scope of include
Hello php list: If I include a php script inside a php function definition and then call the function in another script. What is the scope of variables in the included script? Are they local to the function that calls include with the file name? Thanks in advance; I'm not sure where to look for this answer; JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Scope of include
On 1/17/07, jekillen [EMAIL PROTECTED] wrote: Hello php list: If I include a php script inside a php function definition and then call the function in another script. What is the scope of variables in the included script? Are they local to the function that calls include with the file name? Thanks in advance; I'm not sure where to look for this answer; JK Does your included PHP script contain any functions? Or is it more like: file1.php contents: function my_function () { if (i_feel_like_it) { include(inc.php); } } and inc.php contains variables at the global level such as: inc.php: $var1 = 2; $var2 = 3; Am I close? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php