php-general Digest 27 Jul 2011 07:59:03 -0000 Issue 7417
php-general Digest 27 Jul 2011 07:59:03 - Issue 7417 Topics (messages 314204 through 314213): Re: Tree menu list in php 314204 by: Jasper Mulder 314205 by: Jim Giner 314206 by: Bojan Tesanovic 314207 by: alekto 314208 by: Stuart Dallas 314209 by: Bálint Horváth 314213 by: Pete Ford pathinfo function 314210 by: Tim Streater 314211 by: Micky Hulse 314212 by: Shawn McKenzie Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- From: alekto.antarct...@gmail.com Date: Tue, 26 Jul 2011 19:20:58 +0200 To: php-gene...@lists.php.net Subject: [PHP] Tree menu list in php Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? This is how I imagine the tree menu should look like: v First level Second level Second level v Second level Third level Third level Third level Second level Second level ( = menu is closed, v = menu is open ) Cheers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This appears like a typical JavaScript thing to me. If you insist on not using JS, you could probably use AJAX+PHP to do it. However, JavaScript appears to me as the more convenient method. Regards, Jasper ---End Message--- ---BeginMessage--- Jasper Mulder lord_fa...@hotmail.com wrote in message news:snt106-w6527d1e82d0a3efe6f76f1f7...@phx.gbl... From: alekto.antarct...@gmail.com Date: Tue, 26 Jul 2011 19:20:58 +0200 To: php-gene...@lists.php.net Subject: [PHP] Tree menu list in php Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? If by tree menu you mean to have a menu that interacts with the user and shows the branches, ie, sub-menus as the user clicks on items, then you can't do it with php obviously. OTOH - if you just want a menu with indents and choices similar to an 'outline' , then sure you can do it with php/html/css. But the JS ones are the sharpest ones. There's several out there for free too! ---End Message--- ---BeginMessage--- Look at it this way, PHP is just another scripting language, it processes data. That said PHP is not responsible for user interface , it just prints out what you tell him to , it can be HTML XML JSON etc presentation thing is eg HTML and CSS is for styling HTML, JS is to dynamically change structure of HTML or better to say DOM. Though there is a easy way to make menus with HTML5 and CSS3 but most current browsers don't support those new tech stuff , (most browsers do but user are not up to date with freshest ones) If there is a real reason not to use JS, can you make more specific example so we can help. Bojan Tesanovic Senior PHP Developer http://oophp.org/ On Jul 26, 2011, at 7:20 PM, alekto wrote: Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? This is how I imagine the tree menu should look like: v First level Second level Second level v Second level Third level Third level Third level Second level Second level ( = menu is closed, v = menu is open ) Cheers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Thank you all for good answers and explanations, think I will give JavaScript a try! Den 26. juli 2011 kl. 20.37 skrev Bojan Tesanovic: Look at it this way, PHP is just another scripting language, it processes data. That said PHP is not responsible for user interface , it just prints out what you tell him to , it can be HTML XML JSON etc presentation thing is eg HTML and CSS is for styling HTML, JS is to dynamically change structure of HTML or better to say DOM. Though there is a easy way to make menus with HTML5 and CSS3 but most current browsers don't support those new tech stuff , (most browsers do but user are not up to date with freshest ones) If there is a real reason not to use JS, can you make more specific example so we can help. Bojan Tesanovic Senior PHP Developer http://oophp.org/ On Jul 26, 2011, at 7:20 PM, alekto wrote: Hi, is there a way to create a tree menu list only by using php/html/css? I
[PHP] Re: Tree menu list in php
On 26/07/11 18:20, alekto wrote: Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? This is how I imagine the tree menu should look like: v First level Second level Second level v Second level Third level Third level Third level Second level Second level ( = menu is closed, v = menu is open ) Cheers! Look, I know this is loopy and I haven't tried it (for the protection of my sanity, mainly), but how about the tree being an image generated using PHP, and then used as an image map to submit the page every time a click is made on the image - you could then use the coordinates of the click to determine the new state of the tree and render an appropriate image for it... I'll get my coat... Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] pathinfo function
On 26 Jul 2011 at 23:55, Micky Hulse rgmi...@gmail.com wrote: On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater t...@clothears.org.uk wrote: that I will get an error if I try to reference $info[extension] ?? From what I can tell via reading the docs: The following associative array elements are returned: dirname, basename, extension (if any), and filename. http://php.net/pathinfo Makes me think that if the extension does not exist, then the extension key will not exist. Seems to me that's the case. However the doc is ambiguous, especially as I *asked* for that key to be returned. IMO it should exist and be empty. Not existing is only OK if I didn't ask for it. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Tree menu list in php
That would be so extreemely inefficient both resources and bandwidth-wise, however an interesting thought... On Jul 27, 2011 4:02 AM, Pete Ford p...@justcroft.com wrote: On 26/07/11 18:20, alekto wrote: Hi, is there a way to create a tree menu list only by using php/html/css? I found some, but they are all in JavaScript, do I have to make them by using JavaScript or is there a way in php as well? This is how I imagine the tree menu should look like: v First level Second level Second level v Second level Third level Third level Third level Second level Second level ( = menu is closed, v = menu is open ) Cheers! Look, I know this is loopy and I haven't tried it (for the protection of my sanity, mainly), but how about the tree being an image generated using PHP, and then used as an image map to submit the page every time a click is made on the image - you could then use the coordinates of the click to determine the new state of the tree and render an appropriate image for it... I'll get my coat... Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re: [PHP] pathinfo function
-Original Message- From: Tim Streater [mailto:t...@clothears.org.uk] Sent: 27 July 2011 09:57 On 26 Jul 2011 at 23:55, Micky Hulse rgmi...@gmail.com wrote: On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater t...@clothears.org.uk wrote: that I will get an error if I try to reference $info[extension] ?? From what I can tell via reading the docs: The following associative array elements are returned: dirname, basename, extension (if any), and filename. http://php.net/pathinfo Makes me think that if the extension does not exist, then the extension key will not exist. Seems to me that's the case. However the doc is ambiguous, especially as I *asked* for that key to be returned. IMO it should exist and be empty. Not existing is only OK if I didn't ask for it. This is how you tell the difference between a basename with a null extension (/path/filename.) and no extension (/path/filename). In the former case you get $info[extension]=, in the latter there is no [extension] element in the returned array. This does seem like the most logical way to make this distinction, but the manual could use a bit of work to document this and other edge cases more explicitly. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
Re: RE: Re: [PHP] pathinfo function
On 27 Jul 2011 at 11:09, Mike Ford m.f...@leedsmet.ac.uk wrote: -Original Message- From: Tim Streater [mailto:t...@clothears.org.uk] Seems to me that's the case. However the doc is ambiguous, especially as I *asked* for that key to be returned. IMO it should exist and be empty. Not existing is only OK if I didn't ask for it. This is how you tell the difference between a basename with a null extension (/path/filename.) and no extension (/path/filename). In the former case you get $info[extension]=, in the latter there is no [extension] element in the returned array. OK, this makes sense. This does seem like the most logical way to make this distinction, but the manual could use a bit of work to document this and other edge cases more explicitly. I may have a go at this if I can find a round tuit. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Membership site
Hello, I am just starting out with PHP and I have just created a database named Members with a table named Persons. There are 5 fields (id,firstname, lastname, username, password) . The form I created is a sign up form and the values entered into the form are inserted into the table Persons, now my question is how do I create a secure log in system with this new database? Thanks in advance! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Membership site
On Wed, 2011-07-27 at 14:01 -0700, wil prim wrote: Hello, I am just starting out with PHP and I have just created a database named Members with a table named Persons. There are 5 fields (id,firstname, lastname, username, password) . The form I created is a sign up form and the values entered into the form are inserted into the table Persons, now my question is how do I create a secure log in system with this new database? Thanks in advance! :) Well, first, as a measure of security, make sure that you don't store the plain text password in the DB. Something like an md5($password . $email . $name) offers a rudimentary protection. For something a little meatier, try sha1(). Storing it this way means that even if someone gained access to your DB, they don't actually have the passwords, as people often reuse passwords on different sites. As to the login, you would accept the username and password combo, and then hash or encrypt the password with the salt again, and compare with the entry in the DB. It's typical to have a counter of incorrect logins as well. More than 3 in a row causes the login for that username to lock for a specific period of time. To achieve this, you would need to add a couple of fields to your Persons table, `attempts`(tinyint) `lock_time`(datetime). When you attempt to log someone in with the username and password (encrypted, hashed, whatever) you also check to see if the lock_time is not some time in the future. If it is, then you don't allow them access. If the password was wrong, then increment the attempts field by 1. If this field gets incremented to a specific value (say 3 for example) then you set the lock_time field to some date in the future, the wait period. When a user logs in successfully, set the attempts counter to 0 again so it's ready for the next login attempt to the account. This just ensures that people aren't accidentally locked out indefinitely! This is all just a rough sketch out of how I'd go about it, but it should be enough logic for you to put some code together. It's no more complex than a couple of queries and a few if statements. It may help you to flowchart the whole thing out to get the logic clear in your mind. -- Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] PayPal IPN
Hey everyone, So I know this is related pretty strictly to paypal... But I also know that you all most likely use it :) So with that said... Has anyone successfully setup the IPN with paypal? I'm trying to figure out to get it up and working and can't seem to wrap my head around it... But then again, I've been at it for a few hours so I'm hoping in the morning it gets more clear! Here is the test code that I am working with: ?PHP error_reporting(E_ALL ^ E_NOTICE); $email = $_GET['ipn_email']; $header = ; $emailtext = testing 123; // Read the post from PayPal and add 'cmd' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exits = true; } foreach ($_POST as $key = $value) // Handle escape characters, which depends on setting of magic quotes { if($get_magic_quotes_exists == true get_magic_quotes_gpc() == 1){ $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= $key=$value; } // Post back to PayPal to validate $header .= POST /cgi-bin/webscr HTTP/1.0\r\n; $header .= Content-Type: application/x-www-form-urlencoded\r\n; $header .= Content-Length: . strlen($req) . \r\n\r\n; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);//Test //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);// Live // Process validation from PayPal // TODO: This sample does not test the HTTP response code. All // HTTP response codes must be handles or you should use an HTTP // library, such as cUrl if (!$fp) { // HTTP ERROR } else { // NO HTTP ERROR fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, VERIFIED) == 0) { // TODO: // Check the payment_status is Completed // Check that txn_id has not been previously processed // Check that receiver_email is your Primary PayPal email // Check that payment_amount/payment_currency are correct // Process payment // If 'VERIFIED', send an email of IPN variables and values to the // specified email address foreach ($_POST as $key = $value){ $emailtext .= $key . = .$value .\n\n; } mail(pru...@gmail.com, Live-INVALID IPN, $emailtext . \n\n . $req); //removed for testing //mail($email, Live-VERIFIED IPN, $emailtext . \n\n . $req); } else if (strcmp ($res, INVALID) == 0) { // If 'INVALID', send an email. TODO: Log for manual investigation. foreach ($_POST as $key = $value){ $emailtext .= $key . = .$value .\n\n; } mail(pru...@gmail.com, Live-INVALID IPN, $emailtext . \n\n . $req); //Removed for testing //mail($email, Live-INVALID IPN, $emailtext . \n\n . $req); } } } fclose ($fp); ? Thanks everyone! Hoping to find a easy fix to it! Jason Pruim pru...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PayPal IPN
On Wed, Jul 27, 2011 at 21:58, Jason Pruim pru...@gmail.com wrote: Hey everyone, So I know this is related pretty strictly to paypal... But I also know that you all most likely use it :) Remind me tomorrow. There's a chance I may have some old IPN code lying around, and definitely have Website Payments Pro code that I still use daily. That aside, PayPal has development community forums for PayPal-specific development: http://paypaldev.org/ . Give it a shot. If it doesn't work, I'll see what code I still have, but you'll totally owe me a 50-yardline shot from the Swamp. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php