php-general Digest 14 Apr 2009 15:31:27 -0000 Issue 6067
php-general Digest 14 Apr 2009 15:31:27 - Issue 6067 Topics (messages 291458 through 291479): Re: try - catch is not so clear to me... 291458 by: Lamp Lists 291473 by: Bastien Koert 291476 by: Lamp Lists Re: https and Credit Cards 291459 by: Paul M Foster 291468 by: Richard Heyes Re: Logging out of a SSL / https:// site using PHP? (or JS?), Client Side Cache 291460 by: Michael A. Peters Re: $_GET verses $_POST 291461 by: Ashley Sheridan 291462 by: Michael A. Peters 291463 by: ×× ××× ×× ×× 291469 by: Nick Cooper 291474 by: Paul M Foster 291478 by: haliphax files creation/access dates 291464 by: Tom Sparks 291466 by: Per Jessen 291477 by: haliphax Re: Generate XHTML (HTML compatible) Code using DOMDocument 291465 by: Peter Ford bug or expected, mbstring.func_overload not changeable by .htaccess 5.2.8/5.2.9 291467 by: Andre Hübner Reflection question 291470 by: Pulni4kiya Re: [PHP-DEV] Re: Is it true that short_open_tag is deprecated in PHP 6? 291471 by: Mikko Koppanen 291475 by: Glen Re: Nagios Monitoring 291472 by: ×××¨× ××× Logical next step in learning? 291479 by: Gary 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: Marc Steinert li...@bithub.net To: Lamp Lists lamp.li...@yahoo.com Cc: php-gene...@lists.php.net Sent: Monday, April 13, 2009 11:27:08 AM Subject: Re: [PHP] try - catch is not so clear to me... Basically try-catch gives you the ability to handle errors outside a class or method scope, by the calling instance. This comes in handy, if you are programming in an object orientated way and thus enables you to seperate error handling from the rest of your functionality. Means, your methods do only the things, they are meant to do, without bothering to handling occuring errors. Hope, that made things clearer. Greetings from Germany Marc Lamp Lists wrote: hi to all! actually, the statement in the Subject line is not 100% correct. I understand the purpose and how it works (at least I think I understand :-)) but to me it's so complicated way? -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert Looks like I still didn't get it correctly: try { if (!send_confirmation_email($email, $subject, $content)) { throw new Exception('Confirmation email is not sent'); } } catch (Exception $e) { send_email_with_error_to_admin($e, $content); } why am I getting both emails? I'm receiving confirmation email and email with error message - that I'm supposed to get if the first one is not sent for some reason?!?!?!? thanks for any help. -LL ---End Message--- ---BeginMessage--- On Mon, Apr 13, 2009 at 11:34 PM, Lamp Lists lamp.li...@yahoo.com wrote: From: Marc Steinert li...@bithub.net To: Lamp Lists lamp.li...@yahoo.com Cc: php-gene...@lists.php.net Sent: Monday, April 13, 2009 11:27:08 AM Subject: Re: [PHP] try - catch is not so clear to me... Basically try-catch gives you the ability to handle errors outside a class or method scope, by the calling instance. This comes in handy, if you are programming in an object orientated way and thus enables you to seperate error handling from the rest of your functionality. Means, your methods do only the things, they are meant to do, without bothering to handling occuring errors. Hope, that made things clearer. Greetings from Germany Marc Lamp Lists wrote: hi to all! actually, the statement in the Subject line is not 100% correct. I understand the purpose and how it works (at least I think I understand :-)) but to me it's so complicated way? -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert Looks like I still didn't get it correctly: try { if (!send_confirmation_email($email, $subject, $content)) { throw new Exception('Confirmation email is not sent'); } } catch (Exception $e) { send_email_with_error_to_admin($e, $content); } why am I getting both emails? I'm receiving confirmation email and email with error message - that I'm supposed to get if the first one is not sent for some reason?!?!?!? thanks for any help. -LL what does this function [send_confirmation_email($email, $subject, $content)] return? -- Bastien Cat, the other other white meat ---End Message---
Re: [PHP] $_GET verses $_POST
On Mon, 2009-04-13 at 15:47 -0700, Michael A. Peters wrote: Daevid Vincent wrote: Just to clarify. Obfuscation is NOT a substitute for security. While I don't disagree with the when's here of GET vs POST, this statement is a bit misleading... Any cracker worth his salt can easily install any number of Firefox extensions or unix command line tools and not only view the POST data, but alter it as well. So if you are sending something like a password, don't think that it's secure just because Joe Average doesn't see it. If you're not using SSL, then it is sent as plain text like everything else. And don't assume that what you presented on a web page in select boxes and other form elements is the ONLY thing that is going to come back to your server to process. It's trivial to mangle the data. This is what SQL injection is all about. http://en.wikipedia.org/wiki/SQL_injection http://phpsec.org/projects/guide/3.html Daevid. http://daevid.com It also should be noted that post is not automatically secure against csrf attacks. While most csrf attacks are get, they can and do happen via post as well. I agree that passwords need to be sent via SSL. Unfortunately most users use the same login and passwords for many sites. So even if your site doesn't otherwise need SSL, using SSL for login helps protect your users. For me the biggest advantage of post is the URLs aren't ugly. For cases where get with a variable in the URL is useful (IE product=BluePhone) - I prefer to handle that via mod_rewrite. The requests get handled by generic.php and generic.php then looks at what the requested URI is to figure out what otherwise would have specified by a get. Just as linkable as ?get=whatever and a lot prettier for the user to look at in the url bar. I think doing it that way also has search engine indexing advantages. I've done a bit of research into that, and can't find any evidence to suggest that the so-called friendly URL's are actually of any benefit to search engines. Just put a question into Google, and more often than not, the top few results are from forums, which tend not to use these friendly URL's. The only reason one might help with SEO is the case where a site is being redeveloped or re-versioned, and you need to preserve old page names to retain any ranking the site once had. Of course, I'm welcome for any evidence to the contrary, so if any of you have stumbled across links to any of that... Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_GET verses $_POST
Ashley Sheridan wrote: On Mon, 2009-04-13 at 15:47 -0700, Michael A. Peters wrote: I think doing it that way also has search engine indexing advantages. I've done a bit of research into that, and can't find any evidence to suggest that the so-called friendly URL's are actually of any benefit to search engines. I haven't done research on it, so I'll take your word for it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_GET verses $_POST
$_REQUEST is less secure because it also contains cookie data. If you manage just to set a cookie, with the name act and value logout, the user will infinitely log out - You get the point. On Sun, Apr 12, 2009 at 10:56 PM, Jason Pruim ja...@jasonpruim.com wrote: On Apr 12, 2009, at 1:48 PM, Ron Piggott wrote: Thanks. I got my script updated. Ron There are a few other thing's that I didn't see mentioned... The best description of when to use what, is this.. Use POST when you are submitting a form for storing info, using GET when you are retrieving from the server... GET can also be bookmarked and shared between computers without a problem... So depending on what your app is for that might be a consideration. POST does not display anything in the browser, so as others have said it's perfect for login's since that info will never be visible to the user. as far as REQUEST goes... I personally don't think it's any less secure then POST or GET... As long as you do sanitization on the info that is appropriate for your app, REQUEST is fine.. Some people prefer to use GET and POST though because then they know where the info is coming from... I think that's everything I wanted to add :) Just stuff to think about. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] files creation/access dates
how do I get the creation dates on a file? how do I get the last access date on a file? tom_a_sparks Please avoid sending me Word or PowerPoint attachments. but instead use OpenDocument File Formats or use OpenOffice http://en.wikipedia.org/wiki/OpenDocument http://en.wikipedia.org/wiki/OpenOffice.org http://www.gnu.org/philosophy/no-word-attachments.html Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate XHTML (HTML compatible) Code using DOMDocument
Michael Shadle wrote: On Mon, Apr 13, 2009 at 2:19 AM, Michael A. Peters mpet...@mac.com wrote: The problem is that validating xhtml does not necessarily render properly in some browsers *cough*IE*cough* I've never had problems and my work is primarily around IE6 / our corporate standards. Hell, even without a script type it still works :) Would this function work for sending html and solve the utf8 problem? function makeHTML($document) { $buffer = $document-saveHTML(); $output = html_entity_decode($buffer,ENT_QUOTES,UTF-8); return $output; } I'll try it and see what it does. this was the only workaround I received for the moment, and I was a bit afraid it would not process the full range of utf-8; it appeared on a quick check to work but I wanted to run it on our entire database and then ask the native geo folks to examine it for correctness. I find that IE7 (at least) is pretty reliable as long as I use strict XHTML and send a DOCTYPE header to that effect at the top - that seems to trigger a standard-compliant mode in IE7. At least then I only have to worry about the JavaScript incompatibilities, and the table model, and the event model, and -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] files creation/access dates
Tom Sparks wrote: how do I get the creation dates on a file? how do I get the last access date on a file? http://php.net/manual/en/function.stat.php /Per -- Per Jessen, Zürich (14.4°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] bug or expected, mbstring.func_overload not changeable by .htaccess 5.2.8/5.2.9
Hello, following in my .htaccess works with php 5.2.6 (mod_php) php_value mbstring.func_overload 2 Seems that since (5.2.7?) 5.2.8/5.2.9 this value is not any more accepted by php in .htaccess. mbstring.func_overload should be changeable by PHP_INI_PERDIR which includes .htaccess Other values are changeable by .htaccess so it should not be a general problem on my side. Please someone could check this? Thanks, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https and Credit Cards
Hi, I've always put any forms that collect credit card information behind a secure connection, https, figuring that sending that information from the client browser to the server should be secure, but I'm having convincing a client that it is necessary. He instead insists that only the call to the credit card processor's server needs to be secure and of course the processor supplies the connection there. But doesn't also the form need to be secure since you're sending CC information from that form back to the web site's server? Yes. Any connection to you where your punter supplies CC details should be secure. If the punters ISP runs a transparent proxy for example, then these details could be easily captured if not sent over a secure connection. -- Richard Heyes HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.net (Updated April 11th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_GET verses $_POST
$_REQUEST is not any less secure then $_POST/$_GET/$_COOKIE, they all contain raw user data. The way $_REQUEST is being used in this example is not less secure then using $_GET. It does open up an exploit but this is not because $_REQUEST is less secure. The same exploit exists with $_GET, I could place an image on the page with src=?act=logout. $_REQUEST has a place but it should not be used as a direct substitute for $_GET/POST etc, unless you want the user to be able to have all the options of posting data to the server. 2009/4/14 דניאל דנון danondan...@gmail.com $_REQUEST is less secure because it also contains cookie data. If you manage just to set a cookie, with the name act and value logout, the user will infinitely log out - You get the point. On Sun, Apr 12, 2009 at 10:56 PM, Jason Pruim ja...@jasonpruim.com wrote: On Apr 12, 2009, at 1:48 PM, Ron Piggott wrote: Thanks. I got my script updated. Ron There are a few other thing's that I didn't see mentioned... The best description of when to use what, is this.. Use POST when you are submitting a form for storing info, using GET when you are retrieving from the server... GET can also be bookmarked and shared between computers without a problem... So depending on what your app is for that might be a consideration. POST does not display anything in the browser, so as others have said it's perfect for login's since that info will never be visible to the user. as far as REQUEST goes... I personally don't think it's any less secure then POST or GET... As long as you do sanitization on the info that is appropriate for your app, REQUEST is fine.. Some people prefer to use GET and POST though because then they know where the info is coming from... I think that's everything I wanted to add :) Just stuff to think about. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reflection question
Hi, everyone! I need to do the following: Let's say I have this class: class A { public function b(array $c, $d = 6) { ... } } I need to get this in runtime: public function b(array $c, $d = 6) What's the best way to do it? (I don't quite like the idea of reading the file in which the class is defined and it might not always work...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] Re: Is it true that short_open_tag is deprecated in PHP 6?
On Tue, Apr 14, 2009 at 1:26 PM, Glen glen...@gmail.com wrote: I didn't say PHP tags were valid XML. I said short_open_tag conflicts with ?xml and other PIs. % is not valid XML either, but it doesn't conflict with processing instructions. Glen. Hello Glen, posting to mailing-lists is not a speed race so think about your answer before sending it. There should be no need to send four emails in a row as you can easily answer multiple persons / arguments in a single post. This discussion belongs to internals list anymore, so please move it to php-general mailing list. CCing the correct list in this mail. -- Mikko Koppanen
Re: [PHP] Nagios Monitoring
Normally, I would write the plugin in perl but the general rule is to return the right exit code to nagios, meaning, the plugin performs a test and exits with a code from 0-3 which indicates to nagios of the result of the test, it is also possible to also return a test message along wit hthe code. for a more information you may look here: http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN78 Liran Cohen CEO +972-54-5617070 בניית אתרים http://www.rct.co.il מוצרי פרסום http://www.icon-a.com ציטוט Waynn Lue: Hey guys, I'm looking to write a nagios plugin that essentially monitors whether or not a database query returns a value 0 at any given point. I was hoping to write this in PHP, but I haven't found too many examples of Nagios plugins in PHP ( http://www.barryodonovan.com/index.php/2007/11/02/asterisk-pri-nagios is the best one I've found so far). Just wondering if anyone has any experience writing them? Waynn
Re: [PHP] try - catch is not so clear to me...
On Mon, Apr 13, 2009 at 11:34 PM, Lamp Lists lamp.li...@yahoo.com wrote: From: Marc Steinert li...@bithub.net To: Lamp Lists lamp.li...@yahoo.com Cc: php-general@lists.php.net Sent: Monday, April 13, 2009 11:27:08 AM Subject: Re: [PHP] try - catch is not so clear to me... Basically try-catch gives you the ability to handle errors outside a class or method scope, by the calling instance. This comes in handy, if you are programming in an object orientated way and thus enables you to seperate error handling from the rest of your functionality. Means, your methods do only the things, they are meant to do, without bothering to handling occuring errors. Hope, that made things clearer. Greetings from Germany Marc Lamp Lists wrote: hi to all! actually, the statement in the Subject line is not 100% correct. I understand the purpose and how it works (at least I think I understand :-)) but to me it's so complicated way? -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert Looks like I still didn't get it correctly: try { if (!send_confirmation_email($email, $subject, $content)) { throw new Exception('Confirmation email is not sent'); } } catch (Exception $e) { send_email_with_error_to_admin($e, $content); } why am I getting both emails? I'm receiving confirmation email and email with error message - that I'm supposed to get if the first one is not sent for some reason?!?!?!? thanks for any help. -LL what does this function [send_confirmation_email($email, $subject, $content)] return? -- Bastien Cat, the other other white meat
Re: [PHP] $_GET verses $_POST
On Tue, Apr 14, 2009 at 07:58:24AM +0100, Ashley Sheridan wrote: snip I've done a bit of research into that, and can't find any evidence to suggest that the so-called friendly URL's are actually of any benefit to search engines. Just put a question into Google, and more often than not, the top few results are from forums, which tend not to use these friendly URL's. The only reason one might help with SEO is the case where a site is being redeveloped or re-versioned, and you need to preserve old page names to retain any ranking the site once had. This is a really good point. I've *always* heard/read that ugly URLs aren't indexed by search engines. But somehow it never occurred to me that what you're saying about search engine results is true. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] Re: Is it true that short_open_tag is deprecated in PHP 6?
Mikko, I'm not in a speed race. All my answers are well-thought out. I sent separate e-mails because mailing list discussions are threaded*, and I was responding to different people regarding different things. Who should I reply to if I want to respond to more than one person? I apologize if I've caused anyone any inconvenience. Glen. * http://aspn.activestate.com/ASPN/Mail/Message/php-dev/3710073 Mikko Koppanen wrote: On Tue, Apr 14, 2009 at 1:26 PM, Glen glen...@gmail.com mailto:glen...@gmail.com wrote: I didn't say PHP tags were valid XML. I said short_open_tag conflicts with ?xml and other PIs. % is not valid XML either, but it doesn't conflict with processing instructions. Glen. Hello Glen, posting to mailing-lists is not a speed race so think about your answer before sending it. There should be no need to send four emails in a row as you can easily answer multiple persons / arguments in a single post. This discussion belongs to internals list anymore, so please move it to php-general mailing list. CCing the correct list in this mail. -- Mikko Koppanen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] files creation/access dates
On Tue, Apr 14, 2009 at 4:12 AM, Per Jessen p...@computer.org wrote: Tom Sparks wrote: how do I get the creation dates on a file? how do I get the last access date on a file? http://php.net/manual/en/function.stat.php Or, perhaps a bit easier: http://php.net/filemtime http://php.net/fileatime http://php.net/filectime -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_GET verses $_POST
On Tue, Apr 14, 2009 at 8:40 AM, Paul M Foster pa...@quillandmouse.com wrote: On Tue, Apr 14, 2009 at 07:58:24AM +0100, Ashley Sheridan wrote: snip I've done a bit of research into that, and can't find any evidence to suggest that the so-called friendly URL's are actually of any benefit to search engines. Just put a question into Google, and more often than not, the top few results are from forums, which tend not to use these friendly URL's. The only reason one might help with SEO is the case where a site is being redeveloped or re-versioned, and you need to preserve old page names to retain any ranking the site once had. This is a really good point. I've *always* heard/read that ugly URLs aren't indexed by search engines. But somehow it never occurred to me that what you're saying about search engine results is true. The URL of a website is just one more field to cram with search-engine-friendly keywords. If your URL isn't http://myserver/blog/regex-with-javascript; it's not going to count against you NEARLY as much as people seem to believe nowadays. In fact, you could probably just put the sentence regex with javascript at the top of your HTML source and it would have the same impact. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] try - catch is not so clear to me...
From: Bastien Koert phps...@gmail.com To: Lamp Lists lamp.li...@yahoo.com Cc: Marc Steinert li...@bithub.net; php-general@lists.php.net Sent: Tuesday, April 14, 2009 8:11:04 AM Subject: Re: [PHP] try - catch is not so clear to me... On Mon, Apr 13, 2009 at 11:34 PM, Lamp Lists lamp.li...@yahoo.com wrote: From: Marc Steinert li...@bithub.net To: Lamp Lists lamp.li...@yahoo.com Cc: php-general@lists.php.net Sent: Monday, April 13, 2009 11:27:08 AM Subject: Re: [PHP] try - catch is not so clear to me... Basically try-catch gives you the ability to handle errors outside a class or method scope, by the calling instance. This comes in handy, if you are programming in an object orientated way and thus enables you to seperate error handling from the rest of your functionality. Means, your methods do only the things, they are meant to do, without bothering to handling occuring errors. Hope, that made things clearer. Greetings from Germany Marc Lamp Lists wrote: hi to all! actually, the statement in the Subject line is not 100% correct. I understand the purpose and how it works (at least I think I understand :-)) but to me it's so complicated way? -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert Looks like I still didn't get it correctly: try { if (!send_confirmation_email($email, $subject, $content)) { throw new Exception('Confirmation email is not sent'); } } catch (Exception $e) { send_email_with_error_to_admin($e, $content); } why am I getting both emails? I'm receiving confirmation email and email with error message - that I'm supposed to get if the first one is not sent for some reason?!?!?!? thanks for any help. -LL what does this function [send_confirmation_email($email, $subject, $content)] return? -- Bastien Cat, the other other white meat function send_confirmation_email($to, $subject, $body) { $headers =MIME-Versin: 1.0\n . Content-type: text/plain; charset=ISO-8859-1; format=flowed\n . Content-Transfer-Encoding: 8bit\n . Reply-To: Contact lamp.li...@yahoo.com\n. From: Contact lamp.li...@yahoo.com\n . X-Mailer: PHP . phpversion(); mail($to, $subject, $body, $headers) or die(mysql_errno()); } $body is regular confirmation text: Thank you for subscribing. To activate your account klick on the following link... etc. function send_email_with_error_to_admin($e, $content) { $error_message = Caught exception: . $e-getMessage() . \n; $error_message .= Code : . $e-getCode().\n; $error_message .= File : . $e-getFile().\n; $error_message .= Line : . $e-getLine().\n; $to_email = lamp.li...@yahoo.com; $subject = [Confirmation Error Report] .$e-getMessage(); $content .= \n--\n\n; $content .= Error Report:\n\n.$error_message; $content .= \n--\n\n; send_confirmation_email($to_email, $subject, $content); }
[PHP] Logical next step in learning?
I am nearing completion of Head First PHP MySQL, which is a beginners book. Does anyone have a next step in a choice of a book to progress my studies? I have been watching the board,starting to understand some of the questions,and have been following some of the responses,in partiuclar to the PHP site, but would like to have a next step book to work on. Any suggestions? Gary BTW, I really enjoyed the Head First method of teaching, making learning such a complicated subject as coding a little easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_GET
2009/4/12 Ron Piggott ron@actsministries.org: At the very start of my index.php I have the following lines of code: foreach($_GET as $key = $val) { $$key = $_GET[$val]; echo $_GET[$val] . br /; } What I don't understand is why the output is br /br / Well, this would happen if you open /page.php?var= that way the var is set and a part of the _GET Array. You might want to check the variables with empty() or isset(). Remeber to escape strings recieved by users (GET-, POST-, COOKIE-Data as well as some server vars like REMOTE_ADDR, PHP_SELF, etc.) byebye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what to use instead of foreach
2009/4/13 PJ af.gour...@videotron.ca: I have already tried with several count and for schemes. None work because foreach ignores any counters once in the loop. Also, this foreach is nested within another foreach; don't know if that affects anything. Have you heard of while()? You can use it in combination with array_pop() and count() like: ? while (($data = array_pop($array)) !== NULL) { /* having $data and count($array) changes with every loop */ } ? Bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What was the unix timestamp of last week, Monday 12:00 am?
2009/4/13 René Fournier m...@renefournier.com: What was the unix timestamp of last week, Monday 12:00 am? Depends on when I read your message. SCNR :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] try - catch is not so clear to me...
[snip] function send_confirmation_email($to, $subject, $body) { $headers =MIME-Versin: 1.0\n . Content-type: text/plain; charset=ISO-8859-1; format=flowed\n . Content-Transfer-Encoding: 8bit\n . Reply-To: Contact lamp.li...@yahoo.com\n. From: Contact lamp.li...@yahoo.com\n . X-Mailer: PHP . phpversion(); mail($to, $subject, $body, $headers) or die(mysql_errno()); } $body is regular confirmation text: Thank you for subscribing. To activate your account klick on the following link... etc. function send_email_with_error_to_admin($e, $content) { $error_message = Caught exception: . $e-getMessage() . \n; $error_message .= Code : . $e-getCode().\n; $error_message .= File : . $e-getFile().\n; $error_message .= Line : . $e-getLine().\n; $to_email = lamp.li...@yahoo.com; $subject = [Confirmation Error Report] .$e-getMessage(); $content .= \n--\n\n; $content .= Error Report:\n\n.$error_message; $content .= \n--\n\n; send_confirmation_email($to_email, $subject, $content); } Since your function doesn't return anything to the code that calls the function, your check of if (!send_confirmation_email($email, $subject, $content)) is always triggering the failure. Try adjusting your function to return the result of the mail call to see if that handles the checks better function send_confirmation_email($to, $subject, $body) { $headers =MIME-Versin: 1.0\n . Content-type: text/plain; charset=ISO-8859-1; format=flowed\n . Content-Transfer-Encoding: 8bit\n . Reply-To: Contact lamp.li...@yahoo.com\n. From: Contact lamp.li...@yahoo.com\n . X-Mailer: PHP . phpversion(); $result = mail($to, $subject, $body, $headers) or die(mysql_errno()); return $result; } -- Bastien Cat, the other other white meat
[PHP] Re: What was the unix timestamp of last week, Monday 12:00 am?
René Fournier wrote: I'm trying to write a [simple] function, such that: function earlier_unix_timestamp () { $now = mktime(); [...] return $then; // e.g., 1238983107 } Anyone have something already made? There seem to be many ways to skin this cat, with date() arithmetic, etc., but the exceptions (Jan 1, first day of the month, etc.) are driving me crazy. ...Rene 1239598800 -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logical next step in learning?
On Tue, Apr 14, 2009 at 11:31 AM, Gary gwp...@ptd.net wrote: I am nearing completion of Head First PHP MySQL, which is a beginners book. Does anyone have a next step in a choice of a book to progress my studies? I have been watching the board,starting to understand some of the questions,and have been following some of the responses,in partiuclar to the PHP site, but would like to have a next step book to work on. Any suggestions? Gary BTW, I really enjoyed the Head First method of teaching, making learning such a complicated subject as coding a little easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Reading is great, but nothing beats doing...my suggestion is find a silly project and code it catalog your books/cds/dvds rental site anything that will put you in a spot where the issues you run into are not in a book. Its the only way to learn real life programming -- Bastien Cat, the other other white meat
Re: [PHP] Logical next step in learning?
I think most books have you writing code, and Head First did as well, so I think that is covered.. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. But thank you for your suggestion! Gary Bastien Koert phps...@gmail.com wrote in message news:d7b6cab70904140854s587cc7e0kacf22d352f375...@mail.gmail.com... On Tue, Apr 14, 2009 at 11:31 AM, Gary gwp...@ptd.net wrote: I am nearing completion of Head First PHP MySQL, which is a beginners book. Does anyone have a next step in a choice of a book to progress my studies? I have been watching the board,starting to understand some of the questions,and have been following some of the responses,in partiuclar to the PHP site, but would like to have a next step book to work on. Any suggestions? Gary BTW, I really enjoyed the Head First method of teaching, making learning such a complicated subject as coding a little easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Reading is great, but nothing beats doing...my suggestion is find a silly project and code it catalog your books/cds/dvds rental site anything that will put you in a spot where the issues you run into are not in a book. Its the only way to learn real life programming -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] what to use instead of foreach
Hi PJ, Maybe you should post your code, or portion thereof. The trained eyes on the list will quickly gather where the problem in the logic lies. Maybe you can also sacrifice some of your data or data structures if not too sensitive. This will help to validate the route you are trying to follow. Best wishes Leon -Original Message- From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] Sent: 14 April 2009 05:45 PM To: PJ Cc: Leon du Plessis; php-general@lists.php.net Subject: Re: [PHP] what to use instead of foreach 2009/4/13 PJ af.gour...@videotron.ca: I have already tried with several count and for schemes. None work because foreach ignores any counters once in the loop. Also, this foreach is nested within another foreach; don't know if that affects anything. Have you heard of while()? You can use it in combination with array_pop() and count() like: ? while (($data = array_pop($array)) !== NULL) { /* having $data and count($array) changes with every loop */ } ? Bye -- 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
[PHP] Re: [PHP-DEV] Re: Is it true that short_open_tag is deprecated in PHP 6?
[moving to general list as per Mikko's request] short_open_tag is not deprecated. What if you want to use ? foreach ($x as $y): ? in your template? There is no point removing ? and not ?= at the same time, since a large portion of code would be broken anyway (and NO, I am *not* suggesting removing either!). Use % if you want a short tag. To those who keep b*tching about this topic being brought up again, please read Philip's post on the internals list -- the horse is far from dead. Glen. Arvids Godjuks wrote: Hello everyone. I've been writing ?php echo get('something')? for some time now at the last project and it really sucks. I understand reason on depricating short_open_tag and I agree. But I have a proposal witch can ease templating. Remove short open tag, but leave ?=get('blah')?. Bacicaly PHP parser should look for ?php or ?=, single ? is not allowed. That way: 1). short_open_tag is gone for good as an option in .ini. 2). Making templates doesn't suck 3). Backwards compability with old templates is preserved (old templates with ?= work fine). 4). ? in code is broken as you want it to be and makes coders fix it with ?php Everyone is happy, XML and others are safe. Yes, it's really irritating to write ?php echo every time! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract varying data from array with different formatting
Jim Lucas wrote: PJ wrote: Jim Lucas wrote: PJ wrote: foreach does a nice job if you want the results identical each time. What can you use to change the formatting of the results dependent on the number of results. Here's an example: foreach ( $authors[$bookID] AS $authorID = $authorData ) { # Display the echo {$authorData['first_name']} {$authorData['last_name']}\n; } will echo - Joe Boe John Blue Andy Candy etc depending on how many rows we have. What I want is: Joe Boe, John Blue, Andy Candy Hans Stick ( separated by commas, except for the last one which is separated with . I thought of passing a variable to the foreach and then using if elseif... but that can't work because the variable is reset to 0 after each pass. Can't get switch to do it (maybe I don't understand it right. Help ? your answer lies with not replacing foreach to make your life/output better. But with how the data is prepared and handed off to the foreach statement. I am guessing that what you want would be something like this. Since this looks like a snippet of code I sent you the other day, I will snag it complete from the other thread. ?php ... # Test to see if the book has any authors if ( isset($authors[$bookID]) ) { # Tell us how many authors we found echo 'Found: ', count($author[$bookID]), ' authors'; # Create an array that will hold the output from the DB. $aList = array(); # Loop through the authors foreach ( $authors[$bookID] AS $authorID = $authorData ) { # Add all the authors to that new array $aList[] = {$authorData['last_name']}, {$authorData['first_name']}; } # Sanitize the output $aList = array_map('htmlspecialchars', $aList); # Get a count of how many authors their is. $tAuthors = count($aList); # If more then one, do... if ( $tAuthors 1 ) { # Take the last one off, so we can handle it differently $last_author = array_pop($aList); echo join(', ', $aList), ' ', $last_author; # If only one, then do... } elseif ( $tAuthors == 1 ) { echo join('', $aList); } echo 'br /'; } else { echo 'No authors found'; } ... ? Hi Jim, Please excuse my writing to you directly. If you don't think it's proper, just let me know I'll swing off. No problem with hitting me directly, but your findings could be of use to others since it is cleaner way of solving your problem. So, on the list we go So, while I have your attention and if you have a moment, I found this interesting possibility: someone threw implode() at me and I looked it up in the php manual and hey, found and interesting little function: function ImplodeProper($arr, $lastConnector = ' ') { if( !is_array($arr) or count($arr) == 0) return ''; $last = array_pop($arr); if(count($arr)) return implode(', ',$arr)., $lastConnector $last; else return $last; } Since my limited understanding of php impedes me to implement it experimentally in my application, I was curious if, indeed, it could be another option. It does look to me like it could work, but it would require a slightly different implementation of the query, probably somehow using something like a CONCAT(first_name, , last_name). Am I learning something here or is this the wrong tree to bark up? This would be a very nice way to clean up the code Although you could do something with CONCAT(), I would suggest leaving the code as is. Data is all that you want to get from MYSQL, not format. Basically, take the above function and place it in a lib you include for everything. Then replace the if/then/else statement that I built for you with a call to said function. ?php ... function ImplodeProper($arr, $lastConnector = ' ') { if( !is_array($arr) or count($arr) == 0) return ''; $last = array_pop($arr); if(count($arr)) return implode(', ',$arr)., $lastConnector $last; else return $last; } ... # Test to see if the book has any authors if ( isset($authors[$bookID]) ) { # Tell us how many authors we found echo 'Found: ', count($author[$bookID]), ' authors'; # Create an array that will hold the output from the DB. $aList = array(); # Loop through the authors foreach ( $authors[$bookID] AS $authorID = $authorData ) { # Add all the authors to that new array $aList[] = {$authorData['last_name']}, {$authorData['first_name']}; } # Sanitize the output $aList = array_map('htmlspecialchars',
Re: [PHP] what to use instead of foreach
Leon du Plessis wrote: Hi PJ, Maybe you should post your code, or portion thereof. The trained eyes on the list will quickly gather where the problem in the logic lies. Maybe you can also sacrifice some of your data or data structures if not too sensitive. This will help to validate the route you are trying to follow. Best wishes Leon -Original Message- From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] Sent: 14 April 2009 05:45 PM To: PJ Cc: Leon du Plessis; php-general@lists.php.net Subject: Re: [PHP] what to use instead of foreach 2009/4/13 PJ af.gour...@videotron.ca: I have already tried with several count and for schemes. None work because foreach ignores any counters once in the loop. Also, this foreach is nested within another foreach; don't know if that affects anything. Have you heard of while()? You can use it in combination with array_pop() and count() like: ? while (($data = array_pop($array)) !== NULL) { /* having $data and count($array) changes with every loop */ } ? Bye Good suggestion Leon, thanks. I can certainly do that, np. Nothing sensitive. I do have quite a few questions about the code I have used. Things are moving along very well and I should be able to put up the code on the actual site in some directory where it will be possible to view the code and see what it is doing. I'll post the link when more or less ready and then ask for comments, observations, suggestions . Posting the code on the list would be too bumbersome. For now, I'll stick to some snippets. :-) -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logging out of a SSL / https:// site using PHP? (or JS?), Client Side Cache
Michael A. Peters mpet...@mac.com wrote in message news:49e41267.5010...@mac.com... scubak1w1 wrote: I have a series of web sites which use https:// authentication (using AD integration to 'check the credentials' as it were) - all seems to be working well.. I have been Googling et al. for a way to log the user off the site fully... I can do a series of things on the server side per Dreamweaver's Server Behaviour / User Authentication | Log Out User, etc - but the client's browser cache (?) still keeps the credentials, and so ifthey return to the site (say, with their back button) they can get right back in... Sounds like you are not properly expiring the session. The only login credentials that ever should be stored with the client is a session id. Expire the session id - and the session ID in their cookie becomes completely meaningless. OK, I will go back and reread... My understanding was that SSL aka https was taking care of the credential checking using, in our case, Active Directory user entries - and that PHP was just grabbing the UID from that source - for instance, what I do is: //grab the logged on user, depending on whether they logged on with the domain prepended if(substr_count($_SERVER['REMOTE_USER'],\\) != 0) { //the logon has a domain prepended before the 'actual' UID list($logged_on_domain, $logged_on_user) = split('', $_SERVER['REMOTE_USER']); //grab the logged on user off the IIS server variable/s, and split off the (presumed) [domain]\ portion and essentially discard --NOTE USE OF FOUR(4)backslashes as needs to be *double escaped* } else { //no domain (assume) prepended before the back slash, so just the 'actual' UID $logged_on_user = $_SERVER['REMOTE_USER']; }; I can set $_SERVER['REMOTE_USER'] = 'baddomain\baduser' of course - but when I return to the secure page the user's browser cache (?) has reset $_SERVER['REMOTE_USER'] to be their previously logged on user name - so they are still logged in... So maybe my logging off question is not really PHP-specific? Hmmm I will go back and reread various pages (paper and online) with your suggestion/s as the context - so thank you... Regards, GREG... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logical next step in learning?
Hi Gary, I would start working on your project. That's how I got to where I am with it. Now though... I want to go through and completely recode the entire project.. Which is something you'll have to get used to :) But I'd start coding and when you run into a problem, ask.. If you search for my name in the archives, you'll see that is exactly what I did. On Apr 14, 2009, at 11:58 AM, Gary wrote: I think most books have you writing code, and Head First did as well, so I think that is covered.. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. But thank you for your suggestion! Gary Bastien Koert phps...@gmail.com wrote in message news:d7b6cab70904140854s587cc7e0kacf22d352f375...@mail.gmail.com... On Tue, Apr 14, 2009 at 11:31 AM, Gary gwp...@ptd.net wrote: I am nearing completion of Head First PHP MySQL, which is a beginners book. Does anyone have a next step in a choice of a book to progress my studies? I have been watching the board,starting to understand some of the questions,and have been following some of the responses,in partiuclar to the PHP site, but would like to have a next step book to work on. Any suggestions? Gary BTW, I really enjoyed the Head First method of teaching, making learning such a complicated subject as coding a little easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Reading is great, but nothing beats doing...my suggestion is find a silly project and code it catalog your books/cds/dvds rental site anything that will put you in a spot where the issues you run into are not in a book. Its the only way to learn real life programming -- Bastien Cat, the other other white meat -- 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] Logging out of a SSL / https:// site using PHP? (or JS?), Client Side Cache
scubak1w1 wrote: Michael A. Peters mpet...@mac.com wrote in message news:49e41267.5010...@mac.com... scubak1w1 wrote: I have a series of web sites which use https:// authentication (using AD integration to 'check the credentials' as it were) - all seems to be working well.. I have been Googling et al. for a way to log the user off the site fully... I can do a series of things on the server side per Dreamweaver's Server Behaviour / User Authentication | Log Out User, etc - but the client's browser cache (?) still keeps the credentials, and so ifthey return to the site (say, with their back button) they can get right back in... Sounds like you are not properly expiring the session. The only login credentials that ever should be stored with the client is a session id. Expire the session id - and the session ID in their cookie becomes completely meaningless. OK, I will go back and reread... My understanding was that SSL aka https was taking care of the credential checking using, in our case, Active Directory user entries - and that PHP was just grabbing the UID from that source - for instance, what I do is: //grab the logged on user, depending on whether they logged on with the domain prepended if(substr_count($_SERVER['REMOTE_USER'],\\) != 0) { //the logon has a domain prepended before the 'actual' UID list($logged_on_domain, $logged_on_user) = split('', $_SERVER['REMOTE_USER']); //grab the logged on user off the IIS server variable/s, and split off the (presumed) [domain]\ portion and essentially discard --NOTE USE OF FOUR(4)backslashes as needs to be *double escaped* } else { //no domain (assume) prepended before the back slash, so just the 'actual' UID $logged_on_user = $_SERVER['REMOTE_USER']; }; I can set $_SERVER['REMOTE_USER'] = 'baddomain\baduser' of course - but when I return to the secure page the user's browser cache (?) has reset $_SERVER['REMOTE_USER'] to be their previously logged on user name - so they are still logged in... So maybe my logging off question is not really PHP-specific? Hmmm I will go back and reread various pages (paper and online) with your suggestion/s as the context - so thank you... I don't know much about active directory but I thought one of the points of AD was to eliminate the need for a user to log in since they are already authenticated by the centralized AD system. If you want to use active directory as the only user authentication method then as long as the browser sends the credentials it will verify and the user is logged in. You could probably use password _in addition to_ active directory to authenticate a php session, allowing you increased security over just a session token (IE browser has to send valid php session AND active directory credentials) but if you want a user to have to login in addition to active directory credentials, use php sessions on your server, and upon succesful login w/ proper AD credentials set a session variable that says they are authenticated. When they log out, unset the session variable that says they are logged in and expire the session. Then regardless of their AD credentials, they will have to log in again to be verified by the session system. SSL doesn't do anything magic as far as user authentication is concerned, it simply provides a public/private key encryption so that (theoretically) only the browser can decrypt what the server sends and only the server can decrypt what the browser sends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https and Credit Cards
On Mon, Apr 13, 2009 at 11:19 PM, Skip Evans s...@bigskypenguin.com wrote: Hey all, I've always put any forms that collect credit card information behind a secure connection, https, figuring that sending that information from the client browser to the server should be secure, but I'm having convincing a client that it is necessary. He instead insists that only the call to the credit card processor's server needs to be secure and of course the processor supplies the connection there. But doesn't also the form need to be secure since you're sending CC information from that form back to the web site's server? That's what I've always assumed. I need some opinions on this, and if I'm right I think the client will defer to a few more votes. -- It is absolutely essential. The form itself should be encrypted using SSL, and it should likewise only accept data that has been encrypted. If not, smart consumers will simply purchase elsewhere because they know their information is not being protected. In addition to lost sales, your client (and possibly you) could also get hit on the other end with penalties, increased processing fees, or loss of privileges from his payment processor if they find out that the site is not securing cardholder information. You (and your client) should read up on PCI compiance. http://www.pcicomplianceguide.org/ Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] count() total records for pagination with limit
I seem to recall that it is possible to count all instances of a query that is limited by $RecordsPerPage without repeating the same query. I believe that COUNT() had to called immediately after the SELECT word but I neglected to bookmark the source. Dummy! I don't like the idea of count(*) over count() or something like that as it seems rather slow fram what I read. right now I do this: $sql = SELECT * FROM book WHERE id IN (SELECT bookID FROM book_author WHERE authID IN (SELECT author.id FROM author WHERE LEFT(last_name, 1 ) = '$Auth')) ; $Count1 = mysql_num_rows(mysql_query($sql, $db)); $books = array(); $SQL = SELECT * FROM book WHERE id IN (SELECT bookID FROM book_author WHERE authID IN (SELECT author.id FROM author WHERE LEFT(last_name, 1 ) = '$Auth')) ORDER BY $sort $dir LIMIT $offset, $records_per_page ; if ( ( $results = mysql_query($SQL, $db) ) !== false ) { while ( $row = mysql_fetch_assoc($results) ) { $books[$row['id']] = $row; } } $Count = mysql_num_rows($results); $Count gives me the actual rows for display - $Count1 gives me the total rows available. Can this be streamlined any? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logical next step in learning?
On Apr 14, 2009, at 10:58 AM, Gary wrote: I think most books have you writing code, and Head First did as well, so I think that is covered.. No, it isn't. There is a big difference between writing it the way a book tells you to do it, hand-holding all the way and doing it. When you actually have to do it, you take what you have read and apply it, using the book as a reference. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. Bastien's suggestion is spot on. Catalog your family members friends, shoes, girlfriends, any information that is important to you. Really the only way. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logical next step in learning?
2009/4/14 phphelp -- kbk phph...@comcast.net On Apr 14, 2009, at 10:58 AM, Gary wrote: I think most books have you writing code, and Head First did as well, so I think that is covered.. No, it isn't. There is a big difference between writing it the way a book tells you to do it, hand-holding all the way and doing it. When you actually have to do it, you take what you have read and apply it, using the book as a reference. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. Bastien's suggestion is spot on. Catalog your family members friends, shoes, girlfriends, any information that is important to you. Really the only way. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That or create a website that has already been created, but on a smaller scale. That way you will run into the common issues that you will have to deal with in most of the projects you do. -- Luke Slater :O)
Re: [PHP] Logical next step in learning?
On Tue, Apr 14, 2009 at 2:20 PM, Luke l...@blog-thing.com wrote: 2009/4/14 phphelp -- kbk phph...@comcast.net On Apr 14, 2009, at 10:58 AM, Gary wrote: I think most books have you writing code, and Head First did as well, so I think that is covered.. No, it isn't. There is a big difference between writing it the way a book tells you to do it, hand-holding all the way and doing it. When you actually have to do it, you take what you have read and apply it, using the book as a reference. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. Bastien's suggestion is spot on. Catalog your family members friends, shoes, girlfriends, any information that is important to you. Really the only way. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That or create a website that has already been created, but on a smaller scale. That way you will run into the common issues that you will have to deal with in most of the projects you do. There's also no reason you couldn't try to break your project down into its component pieces, and starting to think about how you would build them on an individual basis. It's not always the best thing to completely separate the development process like this... but if you start taking a look at each tree, the forest will become a little clearer after a few of them. :) Also, designing processes and such are language-independent, but will help you to develop pseudocode (whether written or just in your head) that will eventually become your PHP code. My first project was a basic membership portal. I split it originally into how I would organize accounts, the login/logout/check session stuff, and the memberlist on the front page. It was a digital art group, and later down the road, I added an art request form and tied it to a member of the user's selection. Doing it one piece at a time meant that I got some pretty ugly spaghetti code towards the end, but knowing how all of the individual pieces worked allowed me to re-vamp it into an efficient, functional system when everything was said and done. YMMV, -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https and Credit Cards
Sounds like your client wants to end up listed in a Terminated Merchant File. On Mon, Apr 13, 2009 at 11:19 PM, Skip Evans s...@bigskypenguin.com wrote: Hey all, I've always put any forms that collect credit card information behind a secure connection, https, figuring that sending that information from the client browser to the server should be secure, but I'm having convincing a client that it is necessary. He instead insists that only the call to the credit card processor's server needs to be secure and of course the processor supplies the connection there. But doesn't also the form need to be secure since you're sending CC information from that form back to the web site's server? That's what I've always assumed. I need some opinions on this, and if I'm right I think the client will defer to a few more votes. -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://bigskypenguin.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Leonard Burton, N9URK http://www.jiffyslides.com serv...@jiffyslides.com leonardbur...@gmail.com The prolonged evacuation would have dramatically affected the survivability of the occupants. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO fetch_obj - question
Hi there, Ive made a fetch_obj and, as stated on some sites, it returns a anonymous object where the properties will have the name of our columns database. However, when I do this, I notice that instead of giving me the column names as they are typed on the DB I get them uppercase. So, when my database field is id_dog to retrieve the property properly I have to search for ID_DOG Why is this? Is this a normal behavior? Thanks a lot, Márcio
Re: [PHP] Logical next step in learning?
Well there seems to be a consensus here... I have been writing code and the last 3 sites have all been php with a DB, and I have started writing some of the code for the new project, however I keep getting glimmers of more and more of what can be done with PHP/MySQL and would like to continue the more structured learning in addition to the experimentation. Thank you all for your input. Gary haliphax halip...@gmail.com wrote in message news:952625160904141238u79f14879x97c51b330437a...@mail.gmail.com... On Tue, Apr 14, 2009 at 2:20 PM, Luke l...@blog-thing.com wrote: 2009/4/14 phphelp -- kbk phph...@comcast.net On Apr 14, 2009, at 10:58 AM, Gary wrote: I think most books have you writing code, and Head First did as well, so I think that is covered.. No, it isn't. There is a big difference between writing it the way a book tells you to do it, hand-holding all the way and doing it. When you actually have to do it, you take what you have read and apply it, using the book as a reference. I actually have a real project to do that is a little beyond my abilities at this point (its my own), so I want to keep the learning process flowing. Bastien's suggestion is spot on. Catalog your family members friends, shoes, girlfriends, any information that is important to you. Really the only way. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That or create a website that has already been created, but on a smaller scale. That way you will run into the common issues that you will have to deal with in most of the projects you do. There's also no reason you couldn't try to break your project down into its component pieces, and starting to think about how you would build them on an individual basis. It's not always the best thing to completely separate the development process like this... but if you start taking a look at each tree, the forest will become a little clearer after a few of them. :) Also, designing processes and such are language-independent, but will help you to develop pseudocode (whether written or just in your head) that will eventually become your PHP code. My first project was a basic membership portal. I split it originally into how I would organize accounts, the login/logout/check session stuff, and the memberlist on the front page. It was a digital art group, and later down the road, I added an art request form and tied it to a member of the user's selection. Doing it one piece at a time meant that I got some pretty ugly spaghetti code towards the end, but knowing how all of the individual pieces worked allowed me to re-vamp it into an efficient, functional system when everything was said and done. YMMV, -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: PDO fetch_obj - question
Hi there, Ive made a fetch_obj and, as stated on some sites, it returns a anonymous object where the properties will have the name of our columns database. However, when I do this, I notice that instead of giving me the column names as they are typed on the DB I get them uppercase. So, when my database field is id_dog to retrieve the property properly I have to search for ID_DOG Why is this? Is this a normal behavior? Thanks a lot, Márcio Ok I found the answer here: http://bugs.php.net/bug.php?id=42632 http://bugs.php.net/bug.php?id=42632edit=1 edit=1 Regards once again, Márcio
Re: [PHP] Reflection question
Have a look at example #5 on http://de3.php.net/manual/en/language.oop5.reflection.php#language.oop5.reflection.reflectionmethod Greetings from Germany Marc Pulni4kiya wrote: Hi, everyone! I need to do the following: Let's say I have this class: class A { public function b(array $c, $d = 6) { ... } } I need to get this in runtime: public function b(array $c, $d = 6) What's the best way to do it? (I don't quite like the idea of reading the file in which the class is defined and it might not always work...) -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reflection question
The problem is to get the parameters and mostly their type-hinting. At the end I decided to just cast the ReflectionParameter classes to strings and get the type-hinting from there, even though it shouldn't normally be done this way, but I don't think there's a better way now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what to use instead of foreach
Hi Phil. On Monday 13 April 2009, PJ wrote: Thanks for the suggestion, Mark. I've already experimented with count; you're close, but there is still a small glitch and that's in count(); foreach doesn't give a damn about count so you can't use that - it is reset once inside the foreach loop. Look again at the code - the count() is not inside the foreach, so it is not reset, simply stored in $lastIndex for comparison. If your array is associative then simply use another variable to find the last value in the array - the code doesn't need to change much. Try actually running the code below - it does work, as does the previous version I posted if the array is not associative. I'd prefer it if in future you didn't tell me that my code didn't work without actually trying it - I tested that snippet before posting it, as I did with the following. HTH Mark ?php // Non-associative array (the code I posted previously). $a = array('1','2','3'); $lastIndex = count($a) - 1; $outputString = ''; foreach ($a as $index = $value) { if ($index != $lastIndex) { $outputString .= $value, ; } else { $outputString = rtrim($outputString,', '); // Strip last comma. $outputString .= $valuebr /; } } echo $outputString; // Associative array (changed only very slightly). $a = array('martha' = '1','jock' = '2','dave' = '3'); $lastIndex = count($a); $counter = 0; $outputString = ''; foreach ($a as $index = $value) { $counter++; if ($counter != $lastIndex) { $outputString .= $value, ; } else { $outputString = rtrim($outputString,', '); // Strip last comma. $outputString .= $valuebr /; } } echo $outputString; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count() total records for pagination with limit
PJ wrote: I seem to recall that it is possible to count all instances of a query that is limited by $RecordsPerPage without repeating the same query. I believe that COUNT() had to called immediately after the SELECT word but I neglected to bookmark the source. Dummy! You're probably thinking of SQL_CALC_FOUND_ROWS (http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html) It's not always faster though (http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/). I don't like the idea of count(*) over count() or something like that as it seems rather slow fram what I read. right now I do this: $sql = SELECT * FROM book WHERE id IN (SELECT bookID FROM book_author WHERE authID IN (SELECT author.id FROM author WHERE LEFT(last_name, 1 ) = '$Auth')) ; $Count1 = mysql_num_rows(mysql_query($sql, $db)); The problem with this is if your '*' includes 50 fields (from all of the tables in the joins etc) then that is still processed in mysql taking up memory especially. Doing a count() just has 1 field - the count. $sql = select count(1) as count from book ; $result = mysql_query($sql, $db); $row = mysql_fetch_assoc($result); $count = $row['count']; $Count gives me the actual rows for display - $Count1 gives me the total rows available. Can this be streamlined any? Not really. -- 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] Generate XHTML (HTML compatible) Code using DOMDocument
Hi, I'm thinking about using the html5 doctype for all html documents since it's supported by all the popular browsers available today. Two Quick questions... Why do we need to send XHTML code to a web browser when standard html code (with html 5 doctype) will do just fine? Is there any advantage of using xhtml in the web browser over html for normal web application development? __ Raymond Irving --- On Tue, 4/14/09, Peter Ford p...@justcroft.com wrote: From: Peter Ford p...@justcroft.com Subject: Re: [PHP] Generate XHTML (HTML compatible) Code using DOMDocument To: php-general@lists.php.net Date: Tuesday, April 14, 2009, 5:05 AM Michael Shadle wrote: On Mon, Apr 13, 2009 at 2:19 AM, Michael A. Peters mpet...@mac.com wrote: The problem is that validating xhtml does not necessarily render properly in some browsers *cough*IE*cough* I've never had problems and my work is primarily around IE6 / our corporate standards. Hell, even without a script type it still works :) Would this function work for sending html and solve the utf8 problem? function makeHTML($document) { $buffer = $document-saveHTML(); $output = html_entity_decode($buffer,ENT_QUOTES,UTF-8); return $output; } I'll try it and see what it does. this was the only workaround I received for the moment, and I was a bit afraid it would not process the full range of utf-8; it appeared on a quick check to work but I wanted to run it on our entire database and then ask the native geo folks to examine it for correctness. I find that IE7 (at least) is pretty reliable as long as I use strict XHTML and send a DOCTYPE header to that effect at the top - that seems to trigger a standard-compliant mode in IE7. At least then I only have to worry about the JavaScript incompatibilities, and the table model, and the event model, and -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- 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] Generate XHTML (HTML compatible) Code using DOMDocument
Raymond Irving wrote: Hi, I'm thinking about using the html5 doctype for all html documents since it's supported by all the popular browsers available today. Two Quick questions... Why do we need to send XHTML code to a web browser when standard html code (with html 5 doctype) will do just fine? In most cases we don't. However if we want to include extensions (such as MathML etc.) then xhtml is the only way to do it. My own reason for sending xhtml is because I believe it to be a superior specification and would like to see html (where not all tags need to be closed) go away. Having valid x(ht)ml output also means that other software that uses your web page as a source for data can just parse it as xml to get the data it needs. Be careful with html 5 - use the fallbacks (IE embed or object for video as a fallback to the video tag), because not everyone uses the latest browsers. Is there any advantage of using xhtml in the web browser over html for normal web application development? In most cases, not a display advantage. HTML 1.1 supports the ruby tags/attribute, html 4 does not, but with html 5 / xhtml 5 - they are supposedly identical in spec with the only difference being the markup semantics of xhtml 5 conform to xml standards. I suspect html 5 elements/attributes are case insensitive (like they are for previous html) but I haven't checked - xhtml tags/attributes need to be lower case. But if your page can be properly displayed with valid html then the only technical advantage I can think of for using xhtml is for apps that use your page as a data source (so they don't have to convert it to xml). I personally will send xhtml most of the time when I can because I want HTML to go away, and as soon as 97% of browsers properly support xhtml, I may stop sending html all together. Since IE 8 still does not (not will correct mime type anyway) it will be years before that happens. Oh - another advantage to xhtml - it's easy to extend for your own use. For example, you can add a custom attribute for your own use (IE as hooks for other web apps on other sites to use when grabbing data from your site, or whatever) and it will validate as long as you properly declare it. With html, I believe adding an attribute is not allowed unless you create a whole new DTD. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate XHTML (HTML compatible) Code using DOMDocument
As michael said my main reason is strictness. It's much easier to parse a document when an XML parser can read it. I like the idea of closing tags etc. On Apr 14, 2009, at 4:38 PM, Raymond Irving xwis...@yahoo.com wrote: Hi, I'm thinking about using the html5 doctype for all html documents since it's supported by all the popular browsers available today. Two Quick questions... Why do we need to send XHTML code to a web browser when standard html code (with html 5 doctype) will do just fine? Is there any advantage of using xhtml in the web browser over html for normal web application development? __ Raymond Irving --- On Tue, 4/14/09, Peter Ford p...@justcroft.com wrote: From: Peter Ford p...@justcroft.com Subject: Re: [PHP] Generate XHTML (HTML compatible) Code using DOMDocument To: php-general@lists.php.net Date: Tuesday, April 14, 2009, 5:05 AM Michael Shadle wrote: On Mon, Apr 13, 2009 at 2:19 AM, Michael A. Peters mpet...@mac.com wrote: The problem is that validating xhtml does not necessarily render properly in some browsers *cough*IE*cough* I've never had problems and my work is primarily around IE6 / our corporate standards. Hell, even without a script type it still works :) Would this function work for sending html and solve the utf8 problem? function makeHTML($document) { $buffer = $document-saveHTML(); $output = html_entity_decode($buffer,ENT_QUOTES,UTF-8); return $output; } I'll try it and see what it does. this was the only workaround I received for the moment, and I was a bit afraid it would not process the full range of utf-8; it appeared on a quick check to work but I wanted to run it on our entire database and then ask the native geo folks to examine it for correctness. I find that IE7 (at least) is pretty reliable as long as I use strict XHTML and send a DOCTYPE header to that effect at the top - that seems to trigger a standard-compliant mode in IE7. At least then I only have to worry about the JavaScript incompatibilities, and the table model, and the event model, and -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https and Credit Cards
On Apr 13, 2009, at 10:19 PM, Skip Evans wrote: But doesn't also the form need to be secure since you're sending CC information from that form back to the web site's server? That's what I've always assumed. I need some opinions on this, and if I'm right I think the client will defer to a few more votes. To add to what others have said: CC processors with which I have worked will audit your site *before* certifying your site to accept CC information. In other words, if you don't do SSL, you won't be *allowed* to process cards. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what to use instead of foreach
Mark Kelly wrote: Hi Phil. On Monday 13 April 2009, PJ wrote: Thanks for the suggestion, Mark. I've already experimented with count; you're close, but there is still a small glitch and that's in count(); foreach doesn't give a damn about count so you can't use that - it is reset once inside the foreach loop. Look again at the code - the count() is not inside the foreach, so it is not reset, simply stored in $lastIndex for comparison. If your array is associative then simply use another variable to find the last value in the array - the code doesn't need to change much. Try actually running the code below - it does work, as does the previous version I posted if the array is not associative. I'd prefer it if in future you didn't tell me that my code didn't work without actually trying it - I tested that snippet before posting it, as I did with the following. My apologies. It certainly was not meant to disparage the suggestion. I had tried all sorts of counts as I mentioned before. I spend an awful lot of time testing and trying but I'm afraid I don't really grasp all the concepts involved. I am rather visually oriented and not seeing things is rather frustrating. I shouldn't assume so much and will certainly examine your suggestion and learn where I went wrong. Thanks again. Phil HTH Mark ?php // Non-associative array (the code I posted previously). $a = array('1','2','3'); $lastIndex = count($a) - 1; $outputString = ''; foreach ($a as $index = $value) { if ($index != $lastIndex) { $outputString .= $value, ; } else { $outputString = rtrim($outputString,', '); // Strip last comma. $outputString .= $valuebr /; } } echo $outputString; // Associative array (changed only very slightly). $a = array('martha' = '1','jock' = '2','dave' = '3'); $lastIndex = count($a); $counter = 0; $outputString = ''; foreach ($a as $index = $value) { $counter++; if ($counter != $lastIndex) { $outputString .= $value, ; } else { $outputString = rtrim($outputString,', '); // Strip last comma. $outputString .= $valuebr /; } } echo $outputString; ? -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count() total records for pagination with limit
Chris wrote: PJ wrote: I seem to recall that it is possible to count all instances of a query that is limited by $RecordsPerPage without repeating the same query. I believe that COUNT() had to called immediately after the SELECT word but I neglected to bookmark the source. Dummy! You're probably thinking of SQL_CALC_FOUND_ROWS (http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html) It's not always faster though (http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/). I don't like the idea of count(*) over count() or something like that as it seems rather slow fram what I read. right now I do this: $sql = SELECT * FROM book WHERE id IN (SELECT bookID FROM book_author WHERE authID IN (SELECT author.id FROM author WHERE LEFT(last_name, 1 ) = '$Auth')) ; $Count1 = mysql_num_rows(mysql_query($sql, $db)); The problem with this is if your '*' includes 50 fields (from all of the tables in the joins etc) then that is still processed in mysql taking up memory especially. Doing a count() just has 1 field - the count. $sql = select count(1) as count from book ; $result = mysql_query($sql, $db); $row = mysql_fetch_assoc($result); $count = $row['count']; $Count gives me the actual rows for display - $Count1 gives me the total rows available. Can this be streamlined any? Not really. OK. Your suggestion does help, though. :-) -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] redirect to a page the fist time a site is accessed
Hi, I have some code in my index.php file that check the user agent and redirects to a warning page if IE 6 or less is encountered. 1. I'm using a framework and so calls to all pages go through index.php 2. The code that checks for IE 6 or less and redirects is in index.php I know how to redirect the users but what I want to do is redirect a user ONLY the first time the web site is accessed regardless of what page they first access. I would like to minimize overhead (no database). Can this be done? Thanks, Don -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] redirect to a page the fist time a site is accessed
Don wrote: Hi, I have some code in my index.php file that check the user agent and redirects to a warning page if IE 6 or less is encountered. 1. I'm using a framework and so calls to all pages go through index.php 2. The code that checks for IE 6 or less and redirects is in index.php I know how to redirect the users but what I want to do is redirect a user ONLY the first time the web site is accessed regardless of what page they first access. I would like to minimize overhead (no database). Can this be done? # first time visitor? if (!isset(cookie)) { set cookie redirect exit; } # they've been here before, continue as normal. -- 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] redirect to a page the fist time a site is accessed
On Apr 14, 2009, at 10:11 PM, Don d...@program-it.ca wrote: Hi, I have some code in my index.php file that check the user agent and redirects to a warning page if IE 6 or less is encountered. 1. I'm using a framework and so calls to all pages go through index.php 2. The code that checks for IE 6 or less and redirects is in index.php I know how to redirect the users but what I want to do is redirect a user ONLY the first time the web site is accessed regardless of what page they first access. I would like to minimize overhead (no database). Can this be done? Thanks, Don -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Probably the best way I could think of would be to set a cookie on their computer that you check for when they come and redirect based on that cookie. It's not completely fail proof because all they have to do is clear cookies and they will see it again but it should work for most people. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multi-dimensional arrays
Andres Gonzalez wrote: Hi, I am learning PHP and have a simple question. I have a input string in this form: xxx xx x xx xxx xx x x xxx xx xx . . . xx xxx xx xx xx each line has 6 words of various lengths, all separated by white space. the input string can have any number of lines I want to put this into a multi-dimensional array, each line an array that is an element of an outer array. I have tried various ways to do this--I have used explode() and array_filter() and can get a single line parsed and into an array but I am having problems getting a well formed 2 dim array. What is the easiest way to do this? With all of the PHP array functions, there should be an very straight forward way to do this. Any help would be appreciated. -Andres I am no guru of regex or preg_* functions. But here is what I came up with. plaintext?php //another way $text = 'xxx xx x xx xxx xx x x xxx xx xx xx xxx xx xx xx'; print_r($text); echo \n; $matches = array(); preg_match_all(/^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$/Um, $text, $matches, PREG_SET_ORDER); print_r($matches); ? The above outputs the following: plaintextxxx xx x xx xxx xx x x xxx xx xx xx xxx xx xx xx Array ( [0] = Array ( [0] = xxx xx x xx xxx [1] = xxx [2] = [3] = xx [4] = x [5] = xx [6] = xxx ) [1] = Array ( [0] = xx x x xxx xx xx [1] = xx [2] = x [3] = x [4] = xxx [5] = xx [6] = xx ) [2] = Array ( [0] = xx xxx xx xx xx [1] = xx [2] = xxx [3] = xx [4] = [5] = xx [6] = xx ) ) Hope this is what you are looking for. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php