php-general Digest 12 Oct 2006 16:23:58 -0000 Issue 4397
php-general Digest 12 Oct 2006 16:23:58 - Issue 4397 Topics (messages 243015 through 243028): Re: PHP Mailer and SMTP = SPAM? 243015 by: Peter Lauri 243028 by: Richard Lynch Re: OOP slow -- am I an idiot? 243016 by: Stut 243017 by: Roman Neuhauser 243018 by: Tony Marston 243023 by: Chris de Vidal PHP causing seg fault 243019 by: Glenn Richmond 243025 by: Kristen G. Thorson 243027 by: Richard Lynch Re: PHP 5 Hosting 243020 by: Sancar Saran Re: If array() 243021 by: Max Belushkin Re: foreach 243022 by: Jochem Maas php mailer problem 243024 by: Ross 243026 by: Richard Lynch Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. So even that I send from thedomain.com SMTP server I should to set the FROM and REPLY TO to the person who is referring? Our main idea was to send the email from the author of the book as it comes from him, but that is maybe not a great idea? So I am in the middle of two suggestions: 1. Make sure that the email is in the domain that you are sending from 2. Make sure that the emails is from the referring persons email so it won't be marked as spam at their point. This is what I got from Rick. What are you thoughts on this? [snip] when you do a dns lookup (from a machine not on the same network) on the ipnumber of the sending mail server does it show a name? if you do a forward lookup on that name, does that resolve to the (same) ipnumber? the answer to the first part must be yes, and ideally the second will be yes. if the first is no, then don't bother sending from that machine until that issue has been dealt with. sending html substantially increases the probability that your messages will be tagged as spam. certain things will increase that probability. your point 2. is mostly irrelevant. an smtp server simply needs to be configured so it is not an open relay. that is generally the default configuration (of any MTA that's worth using), and is achievable without smtp auth. [/snip] Best regards, Peter Lauri www.lauri.se - personal website www.dwsasia.com - company website ---End Message--- ---BeginMessage--- On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote: [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. Not really -- at least not in my limited experience. There are so many OTHER factors that the DNS resolution of the return address and the actual SMTP machine not matching up are probably not a deciding factor... I could be wrong on this -- I don't run SMTP servers, and *most* of my email is coming out from the same server, but I also have a contact them link, and it seems to work fine, and is most certainly not using return addresses whose DNS matches the sending server. So even that I send from thedomain.com SMTP server I should to set the FROM and REPLY TO to the person who is referring? Our main idea was to send the email from the author of the book as it comes from him, but that is maybe not a great idea? Send the email From: the person who actually typed it. Anything else is more likely to trip you up in some other way, I should think. So I am in the middle of two suggestions: 1. Make sure that the email is in the domain that you are sending from 2. Make sure that the emails is from the referring persons email so it won't be marked as spam at their point. In an ideal world, you have a limited number of authors, and you can configure YOUR SMTP server as a relay for them, thus meeting both conditions. rasmus AT dwsasia.com would a valid email, forwarding to a known valid email for Rasmus the PHP Pocket Guide author. So, you get the best of all worlds -- Custom emails on your site with the correct DNS resolution to match the sender, the author's name in the email address, even using the First Last [EMAIL PROTECTED] format. This satisfies all the conditions, at the minimal expense of setting up an email forward for each author/recipient. If
Re: [PHP] OOP slow -- am I an idiot?
# [EMAIL PROTECTED] / 2006-10-12 06:49:22 +0100: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100: Richard Lynch wrote: This is a classic example of the obvious OOP solution being wildly inappropriate. Ok, so I now find myself in the unusual position of disagreeing with the Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is all about. [...] I never said anything about physical entities. The OOP methodology has nothing to do with physical entities, but it has everything to do with entities. The fact that in this example the entity is physical has no bearing on it whatsoever. Nobody said anything about limiting OOP entities to physical entities. Right, sorry for going off on a tangent, it was 3am. :] When you're talking about something as simple as a customer it's true that an OOP approach probably doesn't add much to the equation. However, when you're dealing with complex entities which span several tables and have data stored in a different format to how it's used (think serialize) it makes sense to have a single point where you can get that data so that you don't end up duplicating the code needed to extract and store it. I'll have most of that handled by the database through triggers, updatable views, foreign keys etc. If this is not what you think OOP is all about, do please enlighten us as to the error of our ways. Imagine deleting many rows in a table one by one (pseudocode): snip instead of taking them with a single DELETE: snip Whoa nellie!! This is a question of design, not a question of whether to use OOP. Sure. I think obvious is the key word in Richard's statement: This is a classic example of the obvious OOP solution being wildly inappropriate. AFAICS he says that the obvious solution is wrong, not that OOP is wrong here. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Roman Neuhauser [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] # [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100: Richard Lynch wrote: On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote: I want to create a customer class which fetches its attributes from a MySQL database. No, you don't. :-) This is a classic example of the obvious OOP solution being wildly inappropriate. Ok, so I now find myself in the unusual position of disagreeing with the Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is all about. I have to disagree as well. There is absolutely nothing wrong which the approach of creating one class for each table in the database. It cannot be wrong for the simple reason THAT IT WORKS! It is also the simplest approach as it keeps all the business rules for each database entity in a single class. Also, by keeping the structure of each object in sync with the structure of the database you don't have to introduce another pointless level of complexity with OR mappers. Those OO purists who insist on creating object hierarchies which bear no resemblance to the database structure are making a rod for their own backs. That notion of purity is my idea of putrefaction. -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP causing seg fault
Hi guys, I'm attempting to run a SugarCRM variant that uses SOAP to access information from the database. The code is causing a seg fault when executing a particular line of code. The code executes properly until it calls a generic function in the parent class that causes a seg fault on the return command. The line of code is: return $this; I've found this to be a problem in PHP version 5.1.4 and 5.2.0rc4. Is this statement illegal in PHP5? When I set a memory limit for the script, the error changes to indicating that it has exceeded its memory allocation, so it seems to be allocating memory over and over. Note that this code runs fine on most other combinations of functions calling this same parent method. Any suggestions are appreciated. Thanks, Glenn. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Hosting
take look www.site5.com On Thursday 12 October 2006 00:59, Ed Lazor wrote: Anyone ever use A2Hosting.com? Or better yet, any recommendations on a PHP 5 web hosting company that you're happy with - measured in terms of quality support, they know what they're doing, and they have good prices? Bonus points for good drive space, bandwidth, and SSH access. I ran a Google search and came up with several options. A2Hosting.com seems the best so far. My only reservation is that they offer 24/7 support through a message service who will page a tech who in turn will call you back - seems sketchy and I can imagine trying to talk someone into going to the server room at 2am. I also checked out many of the other options, but some of them seemed even more sketchy... like VisualWebHosting.com... you click on their link for a BBB review and it brings up another company entirely... and you call their number and all the greeting says is Please leave a message... bep... pretty scary if you ask me. Anyway, thanks in advance for any recommendations you have. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] If array()
John Taylor-Johnston wrote: How can I use if to see an array contains something? if (sizeof($array)) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach
João Cândido de Souza Neto wrote: Hello. In the follow code: $numbers=array(1,2,3,4,5); foreach ($numbers as number) { ... } Inside foreach, could i know if i am in the last element of the array $numbers? you've already had a few alternatives; how about this: foreach ($numbers as $key = $number) { // loopy stuff } // do something special with the last item (and it's key?) // which will currently be stored in $number and $key respectively // e.g. : processWhateverTheLastElementWas($numbers[ $key ]); // or : processWhateverTheLastElementsValueWas($number); basically immediately after the foreach loop you have the key and value of the last element - chances are you therefore have what you need to do what you need. no? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
By the way, about myself. I'm primarily a system administrator. Most of the time I USE code, NOT write it. But I also dabble, and right now we need to improve our old custom PHP revenue application which has sat stagnant for a few years. We can't afford a full-time programmer and I know enough to be dangerous ;-) So I'm the guy. All that to say I'm no pro and am humbly asking your collective professional opinions. --- Richard Lynch [EMAIL PROTECTED] wrote: I want to create a customer class which fetches its attributes from a MySQL database. No, you don't. :-) This is a classic example of the obvious OOP solution being wildly inappropriate. I'll consider that possibility. Start thinking more in terms of what you want the whole application to do, and build classes that do THAT, rather then starting with a single customer and their info. It seems you are advocating procedural programming here. I don't see how your use of classes are anything more than glorified functions. I could re-word the sentence above thusly: Start thinking more in terms of what you want the whole application to do, and build [functions] that do THAT... That's the path we went down at first and the net result was data access functions being copied and modified all over the place, making maintenance a real chore. Did it have speed? Yes. Do I hesitate to make changes to it? Yes. In a world where I am forced to choose between speed and maintainability, I'll probably choose speed, particularly when the program will be used daily. However, I truly believe a speedier OOD is attainable, which is why I'm asking. If, however, you are talking about some blending, where I create a procedural-style class and then make any modifications in subclasses which override the parent class, like this: class parentFunction { getRevenueForCustomer ($id) { // SELECT * FROM customer_revenue WHERE customer_id = '$id' } } class childFunction inherits parentFunction { // Overriding the parent function getRevenueForCustomer ($id, $year, $month, $department) { // SELECT * FROM customer_revenue WHERE customer_id = '$id' AND year = '$year' AND month = '$month' AND department = '$department' } } If that's what you mean, I honestly can't see how that saves coding time or helps maintenance, unless I need to also use some extraneous code with every query which would be included into the constructor. But then I could also use a function (instead of a class) which is like a query wrapper: function sql_query ($query) { // Some massaging routines // ... // Some more // ... $result = mysql_query ($query); // Error handling routines // ... // Other routines // ... return $result; } sql_query (SELECT * FROM ...); If that's the case, I don't see the need for classes at all, and that's actually the path we went down at first. We created a query function which massaged the input and handled errors. I've since learned that's not what I really wanted to do; I want to handle errors elsewhere. I think the above is easier to understand than using a class. Anyway, tell me what you have in mind. CD Think you#39;re a good person? Yeah, right! ;-) Prove it and get ten thousand dollars: TenThousandDollarOffer.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php mailer problem
Why does this send multiple times. I want it to loop through and send it once. - ?php session_start(); include check_login.php; global $PHP_SELF, $mail_text, $search_string; if(!isset($_POST['area'])){ $_POST['area']='a'; $area= $_POST['area'];} if(!isset($_POST['filter'])){ $_POST['filter']=sname; $filter = $_POST['filter'];} if (isset($SUBMIT)){ $mail_body = this is the body; include(mailer/class.phpmailer.php); $mail = new PHPMailer(); $mail-Mailer = mail; // telling the class to use SMTP $mail-IsHTML(true); $mail-Host = mail.scottishsocialnetworks.org; // SMTP server $mail-FromName = Scottish Social Networks; $mail-From = [EMAIL PROTECTED]; //set up the mail loop $addresses = array(); $addresses = explode(,, $mail_to); $mail-AddAttachment($userfile, $_FILES['userfile']['name']); $mail-Subject = $mail_subject; $mail-Body = nl2br($mail_body); $mail-WordWrap = 50; for($i = 0; $i count($addresses); $i++) { $mail-AddAddress($addresses[$i]); $mail-Send(); } } ? ?php //include ('authorise.php'); include ('connect.php'); global $one, $two, $three, $recipients, $people; $query= SELECT * from $table_name WHERE $filter LIKE '%$search_string%'; $area= $_POST['area']; if ($area==a) { $query .= AND area LIKE '%%'; } else { $query .= AND area='$area'; } $result = mysql_query($query); $query .= ORDER BY sname; $result = mysql_query($query) or die('Error, query failed'); while ($row=mysql_fetch_array($result)) { $email_addresses[] = $row['email']; $count = count($email_addresses); $recipients = implode(', ', $email_addresses); //this counts the number of entries //echo $count; //echo $recipients; } if (isset($SUBMIT)) { if (empty($mail_to)){ ? script alert ('You have not entered the recipients email address') /script ? } else { ? script alert ('Your email has been sucessfully sent') /script ? } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP causing seg fault
-Original Message- From: Glenn Richmond [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 4:45 AM To: php-general@lists.php.net Subject: [PHP] PHP causing seg fault Hi guys, I'm attempting to run a SugarCRM variant that uses SOAP to access information from the database. The code is causing a seg fault when executing a particular line of code. The code executes properly until it calls a generic function in the parent class that causes a seg fault on the return command. The line of code is: return $this; I've found this to be a problem in PHP version 5.1.4 and 5.2.0rc4. Is this statement illegal in PHP5? When I set a memory limit for the script, the error changes to indicating that it has exceeded its memory allocation, so it seems to be allocating memory over and over. Note that this code runs fine on most other combinations of functions calling this same parent method. Any suggestions are appreciated. This sounds a lot like what I was running into. What is the OS? I was having a very similar-sounding problem running SugarCRM on any Red Hat system (including CentOS and Fedora). kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mailer problem
Move the -Send outside the loop? And fix your indentation to something sane, so you know what's going on in your script. [Apologies if mail transport messed it up...] On Thu, October 12, 2006 8:30 am, Ross wrote: Why does this send multiple times. I want it to loop through and send it once. - ?php session_start(); include check_login.php; global $PHP_SELF, $mail_text, $search_string; if(!isset($_POST['area'])){ $_POST['area']='a'; $area= $_POST['area'];} if(!isset($_POST['filter'])){ $_POST['filter']=sname; $filter = $_POST['filter'];} if (isset($SUBMIT)){ $mail_body = this is the body; include(mailer/class.phpmailer.php); $mail = new PHPMailer(); $mail-Mailer = mail; // telling the class to use SMTP $mail-IsHTML(true); $mail-Host = mail.scottishsocialnetworks.org; // SMTP server $mail-FromName = Scottish Social Networks; $mail-From = [EMAIL PROTECTED]; //set up the mail loop $addresses = array(); $addresses = explode(,, $mail_to); $mail-AddAttachment($userfile, $_FILES['userfile']['name']); $mail-Subject = $mail_subject; $mail-Body = nl2br($mail_body); $mail-WordWrap = 50; for($i = 0; $i count($addresses); $i++) { $mail-AddAddress($addresses[$i]); $mail-Send(); } } ? ?php //include ('authorise.php'); include ('connect.php'); global $one, $two, $three, $recipients, $people; $query= SELECT * from $table_name WHERE $filter LIKE '%$search_string%'; $area= $_POST['area']; if ($area==a) { $query .= AND area LIKE '%%'; } else { $query .= AND area='$area'; } $result = mysql_query($query); $query .= ORDER BY sname; $result = mysql_query($query) or die('Error, query failed'); while ($row=mysql_fetch_array($result)) { $email_addresses[] = $row['email']; $count = count($email_addresses); $recipients = implode(', ', $email_addresses); //this counts the number of entries //echo $count; //echo $recipients; } if (isset($SUBMIT)) { if (empty($mail_to)){ ? script alert ('You have not entered the recipients email address') /script ? } else { ? script alert ('Your email has been sucessfully sent') /script ? } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP causing seg fault
On Thu, October 12, 2006 3:44 am, Glenn Richmond wrote: I'm attempting to run a SugarCRM variant that uses SOAP to access information from the database. The code is causing a seg fault when executing a particular line of code. The code executes properly until it calls a generic function in the parent class that causes a seg fault on the return command. The line of code is: return $this; I've found this to be a problem in PHP version 5.1.4 and 5.2.0rc4. Is this statement illegal in PHP5? When I set a memory limit for the script, the error changes to indicating that it has exceeded its memory allocation, so it seems to be allocating memory over and over. Note that this code runs fine on most other combinations of functions calling this same parent method. Any suggestions are appreciated. Are you sure you are not causing an infinite loop or a circular data reference that PHP is attempting to iterate through? It sure *sounds* like that might be the case, from the symptoms presented. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Mailer and SMTP = SPAM?
On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote: [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. Not really -- at least not in my limited experience. There are so many OTHER factors that the DNS resolution of the return address and the actual SMTP machine not matching up are probably not a deciding factor... I could be wrong on this -- I don't run SMTP servers, and *most* of my email is coming out from the same server, but I also have a contact them link, and it seems to work fine, and is most certainly not using return addresses whose DNS matches the sending server. So even that I send from thedomain.com SMTP server I should to set the FROM and REPLY TO to the person who is referring? Our main idea was to send the email from the author of the book as it comes from him, but that is maybe not a great idea? Send the email From: the person who actually typed it. Anything else is more likely to trip you up in some other way, I should think. So I am in the middle of two suggestions: 1. Make sure that the email is in the domain that you are sending from 2. Make sure that the emails is from the referring persons email so it won't be marked as spam at their point. In an ideal world, you have a limited number of authors, and you can configure YOUR SMTP server as a relay for them, thus meeting both conditions. rasmus AT dwsasia.com would a valid email, forwarding to a known valid email for Rasmus the PHP Pocket Guide author. So, you get the best of all worlds -- Custom emails on your site with the correct DNS resolution to match the sender, the author's name in the email address, even using the First Last [EMAIL PROTECTED] format. This satisfies all the conditions, at the minimal expense of setting up an email forward for each author/recipient. If I had easy access to control email setup, I'd do that on my site, but I don't, so I just send them out with the return address of whomever sent them. Course I also throttle it so it can only send 4 emails per day from one IP, and have a few other measures in place to limit spam abuse. NOTE: If the authors aren't typing the actual email, you do NOT want to be sending it from them without their prior explicit review and consent of the outgoing email. Authors in particular are very picky about what words you put in their mouth. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
On Wed, October 11, 2006 3:42 pm, Bauer, Jay W wrote: From our testing of multiple connections we could easily create 50 of these persistent connections and would have to hit the apache web server pretty hard with a 1000 requests at 50 at a time to get these to terminate after the timeout. That seems excessive... Are you saying you have 1000 Apache children and 50 different OCI logins, for 50,000 persistent connections? Because it seems to me that you're going to swamp your RAM way too soon for that to be a workable setup... Even so, you would only need 1000 hits to kill off any stale connections, one per Apache child process. And there's not much point in hitting more often than the time limit of a single connection, really, as it's just overkill, in any reasonable scenario. Of course, it's only the luck of the draw which child you get -- In an ideal world, you could target each Apache child by PID and ping it to purge stale connections, I suppose... Still, if you're talking 1000 children and 50 OCI logins, you've pulled out the Wrong Weapon. Persistent Connections are not a magic silver bullet -- They are effective for an oft-used username/password/db setup, with one connection per Apache child process. If you're trying to make the work for 1000 children and 50 OCI logins, don't do that :-) Go back to non-persitent connections, because they're the Right Weapon for your usage. But that does work, so that is one data point and limit when setting this idle timeout. What I think should also happen if the timeout is set, and the persistent connection goes idle long enough it should be marked as a candidate for shutting down. But that is how it works, in effect -- The problem is, who shuts it down when? PHP has to be awake and active to do the shutdown. PHP itself if it goes to use this stale connection, should kill it and use another connection, hopefully a non-stale persistent connection. But that's silly. If it needs a connection, and it's already got a connection, even a just-went-stale connection, and the connection parameters match up, why in the world would it tear that connection down only to use another not-quite-stale-yet connection, or, worse, build up a whole new connection. That's just daft, really, if you think about it. And actually, Kiran in our lab proposed that as a very easy fix to implement, and we've tested it and it works fine. In other words we make 50 persistent connections, with the timeout at 10 seconds, wait a minute and then make another round of the same php requests. With the fix we proposed all new php connections are made. So we know this works. I think if this was implemented and the documentation was clear that what the persistent timeout provided was for these connections to be shutdown when every a new connection tried to use them, PHP or not, that would go along way to satisfying most customers. Especially if it clearly and cleanly documented that was how it worked. I'm afraid not -- If I understand your proposal, you would throw away perfectly good, if slightly stale, connections, only to re-build a new one right after that. That dog won't hunt. There seems to me to be several ways to implement this persistent_timeout that would make it act like how most idle timeouts work, and I agree if we can come up with some simple, low overhead ways that are well documented that would do the trick. Feel free to submit a patch -- Even the one you have now. Worst that can happen is the OCI maintainer can tell you exactly why it's not usable. Please understand: I am *NOT* an expert on this stuff, and could be 100% wrong in my armchair analysis. I don't think I've ever even *used* OCI. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] readfile() problem
Hi gang, I have a problem. I am using readfile() to send files to the browser. The code is below. I had is working on another server before, but now my client have moved to a new server and we have started to experience problems with bigger files. I have three different files that I am sending. They are 3MB, 15MB and 59MB large. The 3MB and 15MB are working fine, but the 59MB does not work. I have checked so that the file_exist() and also was able to retrieve filesize() of the file, so the file is there. I have also tried to download it with the url I know it is located at, and that works too. Is there any limitations or settings of how large the files can be when using readfile()? If so, are they settable? header(Pragma: public); header(Expires: 0); // set expiration time header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=$Row[filename]); header(Content-Transfer-Encoding: binary); $filesize = filesize($filelocation); header(Content-Length: $filesize); readfile($filelocation); Best regards, Peter Lauri www.lauri.se - personal website www.dwsasia.com - company website -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Mailer and SMTP = SPAM?
Thanks for your answer. I better think about this one more time, read some more about it, and then execute :) I will let you know if it flops... -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 11:24 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: RE: [PHP] PHP Mailer and SMTP = SPAM? On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote: [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. Not really -- at least not in my limited experience. There are so many OTHER factors that the DNS resolution of the return address and the actual SMTP machine not matching up are probably not a deciding factor... I could be wrong on this -- I don't run SMTP servers, and *most* of my email is coming out from the same server, but I also have a contact them link, and it seems to work fine, and is most certainly not using return addresses whose DNS matches the sending server. So even that I send from thedomain.com SMTP server I should to set the FROM and REPLY TO to the person who is referring? Our main idea was to send the email from the author of the book as it comes from him, but that is maybe not a great idea? Send the email From: the person who actually typed it. Anything else is more likely to trip you up in some other way, I should think. So I am in the middle of two suggestions: 1. Make sure that the email is in the domain that you are sending from 2. Make sure that the emails is from the referring persons email so it won't be marked as spam at their point. In an ideal world, you have a limited number of authors, and you can configure YOUR SMTP server as a relay for them, thus meeting both conditions. rasmus AT dwsasia.com would a valid email, forwarding to a known valid email for Rasmus the PHP Pocket Guide author. So, you get the best of all worlds -- Custom emails on your site with the correct DNS resolution to match the sender, the author's name in the email address, even using the First Last [EMAIL PROTECTED] format. This satisfies all the conditions, at the minimal expense of setting up an email forward for each author/recipient. If I had easy access to control email setup, I'd do that on my site, but I don't, so I just send them out with the return address of whomever sent them. Course I also throttle it so it can only send 4 emails per day from one IP, and have a few other measures in place to limit spam abuse. NOTE: If the authors aren't typing the actual email, you do NOT want to be sending it from them without their prior explicit review and consent of the outgoing email. Authors in particular are very picky about what words you put in their mouth. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Internet Explorer - and File Download dialog box
Hi, Is there any way to set so that the IE File Download dialog box can understand UTF-8? I have some Thai named files that just end up like nonsense :-) /Peter www.lauri.se http://www.lauri.se/ - personal website www.dwsasia.com http://www.dwsasia.com/ - company website
Re: [PHP] OOP slow -- am I an idiot?
On Wed, October 11, 2006 3:28 pm, Stut wrote: Richard Lynch wrote: On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote: I want to create a customer class which fetches its attributes from a MySQL database. No, you don't. :-) This is a classic example of the obvious OOP solution being wildly inappropriate. Ok, so I now find myself in the unusual position of disagreeing with the Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is all about. You can encapsulate everything to do with a customer in an object. This ensures that you don't duplicate any code that works on customer data. You avoid duplication of code. As a result you can ensure data integrity because there is only one route to read and write it. If this is not what you think OOP is all about, do please enlighten us as to the error of our ways. Doing this without some kind of cache or some kind of bulk load of multiple customer data is inevitably going to lead to having a zillion customer instances floating around in one script to calculate something not readily expressed in an SQL aggregate. See other thread regarding 100 orders with all related uploaded files for an example. It's not so much that having a customer object is wrong, as that having ONLY a customer object to deal with an application that deals with MUCH MORE than a single customer at a time is wrong. You're going to end up having a TON of duplicate code for a single customer and multiple customers, or you're going to swamp your machine with way too many instances of a do-nothing object for the sake of being OOP And, in point of fact, unless you spend the majority of your time/energy in your application dealing with one customer at a time, it's quite likely that your one customer at a time can be encapsulated in a much more re-usable generalized notion of a set of customers -- albeit a set with only one element, and with a few specialized functions for certain operations with only work for one-element sets. Objectifying customer is the immediate, obvious, and totally inappropriate solution to needing to deal with not just one customer, but with sets of customers, some of which may, or may not, need special handling for a set with one element. This is merely the most obvious example of what is *probably* the needs of the original poster. One problem with OOP is that you really do need to understand very very very well the full scale and scope of your application before you can architect the appropriate OOP model. Its entirely possible that he does not need sets of customers, but needs some OTHER OOP model -- And there's no way to know without knowing the full scope of the project. You can do a bunch of simple object stuff in an iterative design, scale, scope interaction for rapid prototyping, but you have to be prepared to scrap all that code once you figure out what you REALLY wanted to do for your application, and you build the REAL application with the correct OOP model. Some Free Advice for a beginning OOP scripter. #1. Play around a lot with OOP on some non-mission-critical toy projects to get the feel of it. Build the smallest silliest OOP thing you can think of, and push the limits of class inheritence and how the pieces can be fit together in unusual ways. #2. Don't use a 'class' in a real project until you find yourself typing code that does almost the same thing as code you typed before, only it's just enough different to make an include or function unwieldy. At that juncture in time, figure out how you could relate the code you are typing NOW to the old code, and what common components you can abstract out to a base class and which parts are specializations of the base class. Re-code both chunks of code as OOP. *THAT* is the real power of OOP. Don't get me wrong: There are some other other uses of OOP, such as a substitute for namespaces for code for public release. But the obvious one-to-one mapping of real-world things to OOP classes seldom works out very well, unless your whole application is all about exploring/defining the relationships among those objects, rather than doing something complex with those objects. I *still* don't see OOP as a Right Answer for spitting out HTML web pages in optimized minimalist time frames... Maybe my brain just got warped by all that AI/Lisp work I did for a couple decades, but it feels to me like a bad selection of weapons for the task at hand, most times I see it in PHP. [shrug] -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Thu, October 12, 2006 12:49 am, Stut wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100: Richard Lynch wrote: On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote: I want to create a customer class which fetches its attributes from a MySQL database. No, you don't. :-) This is a classic example of the obvious OOP solution being wildly inappropriate. Ok, so I now find myself in the unusual position of disagreeing with the Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is all about. To clarify my original statement. The *OBVIOUS* OOP setup of customer === class customer was the wildly in appropriate bit, not using OOP in some more sensible manner, like: //a set of customers class customers ( var customer_ids array(); } I believe my original post went on to say that more explicitly, but I can now see that many thought I was just railing against OOP in general, which was not my intent. (In *this* particular sentence, anyway. :-)) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Thu, October 12, 2006 3:11 am, Tony Marston wrote: I have to disagree as well. There is absolutely nothing wrong which the approach of creating one class for each table in the database. It cannot be wrong for the simple reason THAT IT WORKS! Only problem is that then you often end up making ONE INSTANCE for each *row* in a large result set, and then you are in BIG TROUBLE. IT DOES NOT WORK! You've *got* to have some kind of other class that handles more than a couple handsful of the data, for anything other than a trivial application. And if it was trivial to start with OOP is rarely the right answer. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
Hi Roman, As our customers see this, they think if they set a timeout of 10 seconds, that when these connections aren't used for hours they should go away. And I can understand that. As I understand the current workings, I can see an argument for keeping things as they are, but if that is the case the current behavior needs to documented. In a sense the documentation is the bug. And yes whatever is done will be change in behavior, and it may be a design change or it might be a fix, it really isn't all that important. What I like to see is the documentation and behavior match. They don't now. Regarding there being a way to query the age of the connection, what was found is that when the timeout occurred there is a easy check that can be made to see if it has happened. Currently that is never checked once the connection is opened. The fix our lab tried was to check if the timeout happened whenever the an attempt was made to use the open connection again. If the timeout had occurred, then the connection was closed. It is a passive check, and I think reasonable. Again if someone is using this oci8.persistent_timeout they are using it because they want a way of controlling how long these connections stay around. And given this is a timeout for idle connections, it is our customer's expectation that these connections will terminate. What I see as needed is clear documentation regarding how this timeout works and what it does and under what circumstances a persistent connection will terminate when the timeout is set to a time other than -1, or infinite. I don't see this as a major coding issue, simply one of documentation and possibly implementing a small change which would actually implement an action once the timeout occurred. Obviously this 10 sec timeout being used is for testing to see the behavior, I would expect that normally the time, if not -1 and infinite would be more along the line of hours in the real world. Thanks and regards, Jay -Original Message- From: Roman Neuhauser [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 11, 2006 9:25 PM To: Bauer, Jay W Cc: [EMAIL PROTECTED]; php-general@lists.php.net; Mendonce, Kiran (STSD); Nikiel, Carsten; Rai, Moni (GSE WTEC Cupertino); Rieslund, Mikael; Bauer, Jay W Subject: Re: [PHP] Re: Understanding persistent connections with oci8 # [EMAIL PROTECTED] / 2006-10-11 16:42:06 -0400: And actually, Kiran in our lab proposed that as a very easy fix to implement, and we've tested it and it works fine. In other words we make 50 persistent connections, with the timeout at 10 seconds, wait a minute and then make another round of the same php requests. With the fix we proposed all new php connections are made. So we know this works. I think if this was implemented and the documentation was clear that what the persistent timeout provided was for these connections to be shutdown when every a new connection tried to use them, PHP or not, that would go along way to satisfying most customers. Especially if it clearly and cleanly documented that was how it worked. That's not so much a fix as a different behavior. FWIW the current one is perfectly sensible in other circumstances. Is there a way to query the age of the connection? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Thu, October 12, 2006 8:24 am, Chris de Vidal wrote: [use the archives] I can't architect a good OOP solution to a problem that hasn't been fully defined, any more than one can architect a house without knowing all the rooms that are needed... I agree that all the code samples you provided below are wrong, if that helps. :-) If getRevenueForCustomer is all you need, then I'd have optional args for year and other factors, and have just one query and one function, and it does the right thing for that one customer. I'm assuming you need a heck of a lot more than that, though, so the above paragraph is not particularly helpful. The problem with an OOP discussion like this is that you have to have a complete understanding of what needs to be done before you can make sensible statement about what do do. It's POSSIBLE that class customer is the right answer, though I doubt it based on your original post about performance problems from having too many instances floating around. Maybe others' analysis that class customer was right, but not having the database access optimized with cache or with aggregators or something was the true problem. Maybe I even have a point about using class customers and operating on sets, even if it means specializing on the one-element-set. There's no way anybody can say for sure, not knowing the full scope of the application, though. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working with overly aggressive anti-spam measures [SOLVED]
On Wed, October 11, 2006 9:14 pm, Google Kreme wrote: On 10 Oct 2006, at 19:57 , Dave M G wrote: It took me a little while to realize that the Spamassassin always says that an email is possible scam if it has any score above zero, but it takes a score of 5.0 to actually be deleted as spam. No no no, this is not at all true. First off, Spamassassin does not delete mail. It, in point of fact, CANNOT delete mail as it has no mechanism to do so. Sorry -- I was very ambiguous. Everywhere I typed SA in my post should be replaced with: The squirrel-mail interface provided by my webhost, combined with a custom PHP IMAP inbox-scanning/filtering script I hacked up for my own unique needs, along with the Spam Assassin scoring also provided by my webhost My apologies for imprecision. But I get bonus points for brevity in the original post :-) Anyone who is automatically deleting mail on their own with a score of 5.0 or higher _will_ miss some legitimate email. Not might, WILL. Even at a score of 10.0 (where I auto-delete my mail) you will miss as much as 0.004% legitimate mail, iirc. (so, 4 messages in 100,000) Yes, but getting 10,000 messages per day[*] means I don't READ email anymore. I do email triage. :-) I'm losing 4 real emails every 10 days to my triage. I can live with that. I cannot live with skimming through 10,000 emails per day searching for the ~1 email every other day that is valid. YMMV [*] It's been several years since I've seen a report on how many unfiltered emails per day I received. 10,000 was the number back then. It is inconceivable that the number has decreased, by any realistic projection. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
On Thu, October 12, 2006 12:10 pm, Bauer, Jay W wrote: Again if someone is using this oci8.persistent_timeout they are using it because they want a way of controlling how long these connections stay around. Actually, that's an over-simplification of the purpose of persistent and timeout The purpose of persistent is to avoid spending CPU cycles tearing down and building up complex data structures with large buffers, while maintaining the security/integrity of any given user/pass should have 0 chance of accessing persisted (to coin a word) data that is not their data. The purpose of timeout is to tear down unused expensive connections if they are not actively being used, or about to be used in 1 microsecond. Once you understand this, the PHP behaviour makes perfect sense. It is a very very very common mis-perception, and your customers are not the first, and won't be the last, to complain that it's broken. What I see as needed is clear documentation regarding how this timeout works and what it does and under what circumstances a persistent connection will terminate when the timeout is set to a time other than -1, or infinite. Put it in the User Contributed Notes. :-) I don't see this as a major coding issue, simply one of documentation and possibly implementing a small change which would actually implement an action once the timeout occurred. Obviously this 10 sec timeout being used is for testing to see the behavior, I would expect that normally the time, if not -1 and infinite would be more along the line of hours in the real world. I have no idea what real world times are, but would never presume that they'd be hours rather than 10 seconds... Each active persistent connection ties up valuable resources. The cost/benefit ratio has to be examined carefully and tweaked under real-world load in dev box tests to be sure you're doing something sensible. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Hosting
Thanks for the feedback Kyle, much appreciated. DreamHost does look pretty good price-wise. Two others I was referred to are HostBaby.com and OCSSolutions.com. Have a good one :) -Ed On Oct 11, 2006, at 10:12 PM, Kyle wrote: Hello, I would suggest dreamhost at www.dreamhost.com. Their prices look a bit hefty at first but there are referral codes all over the internet and you can end up saving $97. Their plans have tons of bandwidth and space and I haven't had any trouble with it. But I would suggest them highly, their service is quite impressive. And if you don't like the PHP features they let you compile you own! Good Luck with it! Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] readfile() problem
On Thu, October 12, 2006 11:43 am, Peter Lauri wrote: I have a problem. I am using readfile() to send files to the browser. I have three different files that I am sending. They are 3MB, 15MB and 59MB Is there any limitations or settings of how large the files can be when using readfile()? If so, are they settable? readfile() will slurp the whole file into RAM, and then spit it out to the browser. It's super-convenient and easy for small files. It's not a Good Idea for large files. fopen/fread/echo loop is your buddy. I'll bet a dollar that your old setting had a different memory_limit in php.ini -- or none at all, or it wasn't even compiled to allow memory_limit -- something along those lines. Actually, depending on the speed of the server, and its hard drives, and the drive caches, etc, it's entirely possible that the server is just taking TOO LONG to spit out that monster file. wget would probably let you find out pretty quickly if it's RAM or speed that's killing you. But it's kinda moot, really, as the solution either way remains the same. header(Pragma: public); header(Expires: 0); // set expiration time header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=$Row[filename]); header(Content-Transfer-Encoding: binary); You got Content-type: right, but you know that filename thing is only going to work on some browsers, right? http://richardlynch.blogspot.com Actually, I think -Type should be -type and it might be case-sensitive, but I'd have to re-read HTTP specs to be 100% sure, and I think all the browsers ignore case anyway, so it's kind of moot, and I'm not THAT bored... //readfile($filelocation); $file = fopen($filelocation); while (!feof($file)){ //Last I heard, 2048 optimized some PHP internal buffer... //That's probably way out of date! //And does not account for your bandwidth bottle-neck anyway. //Play with the 2048 until you're happy. echo fread($file, 2048); } -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
Hi Richard, That seems excessive... Are you saying you have 1000 Apache children and 50 different OCI logins, for 50,000 persistent connections? That would indeed be excessive. No there are only a max during the running of ab maybe a 100 apache children and some 50 persistent connections. We use the ab bench mark tool to generate a lot of traffic to see how things work in an extreme condition to see what we could break. When the ab finishes we have 50 persistent connections just setting there doing nothing. This is not a normal environment. But I can use lower numbers and see the same behavior, it was just easier to see the limits by doing it this way. And as I've said multiple time, even under these extreme conditions the persistent connections themselves work just fine. And we can do one run where we create 50 persistent connections, do another run where we have another 1 requests coming in at 50 requests at a time and there are no new persistent connections and none lost, they handle the load just fine. In the real world I'd expect this timeout to be set in the terms of hours not seconds. And customer's would want these connections to be terminated after this time if they had been idle say for 4 hours. In the real world I could see an environment that during say a 4 hour period of the day there are lots of users in the oracle data base, and say 20 or 25 persistent connections get set up and used over and over again during that time. And customer sets the oci8.persistent_timeout to 4 hours, so after the 4 hours of peak activity all of these connections will stay available for at least 4 more hours, and maybe 5 of them get some use. After that time I can see them to expect that some of these persistent connections will now start terminating because they aren't being used any more. Under the current situation these won't go away, unless there is a lot of other traffic for the webserver and the httpd servers need to free up these idle connections to handle other requests. Given something along these lines in a more real world setup, what makes sense? Given this scenario, if there is going to be a timeout, it almost needs to be an active one. And something simple along the lines of garbage collector that checks once an hour for connections that have gone and terminates them. But that requires more code in PHP. As I've alluded to before, in some sense why is there even an idle timeout with persistent connections. It currently doesn't do anything, and to get it to really act like an idle timeout would require some changes in the code that aren't really justified. But if timeout is available how it works needs to be clearly documented so it is clear to anyone using it how it should behave. Thanks again for your thoughtful and thought provoking discussion. Regards, Jay -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 12:41 PM To: Bauer, Jay W Cc: php-general@lists.php.net; Mendonce, Kiran (STSD); Nikiel, Carsten; Rai, Moni (GSE WTEC Cupertino); Rieslund, Mikael; Bauer, Jay W Subject: RE: [PHP] Re: Understanding persistent connections with oci8 On Wed, October 11, 2006 3:42 pm, Bauer, Jay W wrote: From our testing of multiple connections we could easily create 50 of these persistent connections and would have to hit the apache web server pretty hard with a 1000 requests at 50 at a time to get these to terminate after the timeout. That seems excessive... Are you saying you have 1000 Apache children and 50 different OCI logins, for 50,000 persistent connections? Because it seems to me that you're going to swamp your RAM way too soon for that to be a workable setup... Even so, you would only need 1000 hits to kill off any stale connections, one per Apache child process. And there's not much point in hitting more often than the time limit of a single connection, really, as it's just overkill, in any reasonable scenario. Of course, it's only the luck of the draw which child you get -- In an ideal world, you could target each Apache child by PID and ping it to purge stale connections, I suppose... Still, if you're talking 1000 children and 50 OCI logins, you've pulled out the Wrong Weapon. Persistent Connections are not a magic silver bullet -- They are effective for an oft-used username/password/db setup, with one connection per Apache child process. If you're trying to make the work for 1000 children and 50 OCI logins, don't do that :-) Go back to non-persitent connections, because they're the Right Weapon for your usage. But that does work, so that is one data point and limit when setting this idle timeout. What I think should also happen if the timeout is set, and the persistent connection goes idle long enough it should be marked as a candidate for shutting down. But that is how it works, in effect -- The problem is, who shuts it down when? PHP has to be awake
[PHP] webapp creation...
hi... I'm looking to create a webapp. I'd rather not spend my wheels spinning on creating functionality from scratch when it already exists in other apps. so, I'm trying to find out if there are good 'starting' templates/shells that I might be able to use as a starting point. I've seen various plain web templates that cover the look/feel. I've also seen the open source CMS kinds of solutions (Mambo/phpBB/etc..) that I could use to rip apart for an initial starting point for the functionality that I'll need.. I've also taken a look at the Pear/Smarty solutions, but they're not quite what I'm searching for... I'm looking for a starting app that would have menus/submenus, user registration/login/management/admin section as a start... I could then incorporate the functionality that I'm looking to create... Basically, I'll add a number of sections to manage software that I'll be creating. The end site won't be a CMS app, but I could rip out of an app what I need. The issue I've seen with some CMS apps is that they appear to write 'everything' into a db!!! (which kind of makes sense if you're creating an app for use by lots of users/operators) I'm more concerned with the functionality of the app than the look/feel. There is also somewhat of a time constraint. So, Thoughts/Comments/Etc... are all helpful. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote: I can't architect a good OOP solution to a problem that hasn't been fully defined, any more than one can architect a house without knowing all the rooms that are needed... Sorry to jump into the middle of the conversation, but I thought this was a pretty interesting comment. It serves as one of those occasional reminders that I need to go back and study OOP structure design a bit more. I know you're right about the importance of a fully defined problem, but it also seems that the reverse is true if you're really good with OOP. In other words, it seems like any high quality solution starts by defining least common denominators. You start with basic building blocks and expand from there; I'm always amazed when I see space stations or other complex structures built out of Legos, for example. My problem is that I usually look at OOP and think it'll take too long, so I go the non-OOP route, solve the problem, and move on. I can't help but think I'm missing out. I do have libraries of code that I reuse, but I've always heard that I'd benefit a lot more from them if I OOPed them. Dunno... that's my two cents worth anyway hehe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] webapp creation...
On Thu, 2006-10-12 at 10:58 -0700, bruce wrote: I'm looking to create a webapp. I'd rather not spend my wheels spinning on creating functionality from scratch when it already exists in other apps. so, I'm trying to find out if there are good 'starting' templates/shells that I might be able to use as a starting point. I've seen various plain web templates that cover the look/feel. I've also seen the open source CMS kinds of solutions (Mambo/phpBB/etc..) that I could use to rip apart for an initial starting point for the functionality that I'll need.. 1. Search the archives around PHP Frameworks, they have been discussed ad naseum 2. Go to http://avoir.uwc.ac.za and download the Chisimba Framework (PHP5) or the KINKY Framework (PHP4) and get cracking. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
Hi again Richard, Excellent points about the purpose of persistent connections and timeout. But let's get to your concluding statement: Each active persistent connection ties up valuable resources. The cost/benefit ratio has to be examined carefully and tweaked under real-world load in dev box tests to be sure you're doing something sensible. I agree and right now all there is in the way of tools for an administrator to use within the PHP configuration is the number of persistent connections per server and the timeout interval. These are a bit crude as tools, but as the persistent_timeout now works it is useless as a tool to tear down unneeded, expensive connections that are no longer being used. I would think in a customer site, that the customer database and network administrators would be the ones making decisions or providing the input on when to let persistent connections go unencumbered and when to start cutting them down during what ever cycles of business they use. Now obviously the oci8.persistent_timeout as it now implemented will be of no help here at all. So the question here may be more of is the oci8.persistent_timeout a possible tool with changes to use for this, or should there be something, may outside of php used. And if the latter, is there any reason to even have the oci8.persistent_timeout. I need to spend some cycle talking to the php maintainers to see if we can come to some understanding. Thanks and regards, Jay -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 1:37 PM To: Bauer, Jay W Cc: Roman Neuhauser; php-general@lists.php.net; Mendonce, Kiran (STSD); Nikiel, Carsten; Rai, Moni (GSE WTEC Cupertino); Rieslund, Mikael; Bauer, Jay W Subject: RE: [PHP] Re: Understanding persistent connections with oci8 On Thu, October 12, 2006 12:10 pm, Bauer, Jay W wrote: Again if someone is using this oci8.persistent_timeout they are using it because they want a way of controlling how long these connections stay around. Actually, that's an over-simplification of the purpose of persistent and timeout The purpose of persistent is to avoid spending CPU cycles tearing down and building up complex data structures with large buffers, while maintaining the security/integrity of any given user/pass should have 0 chance of accessing persisted (to coin a word) data that is not their data. The purpose of timeout is to tear down unused expensive connections if they are not actively being used, or about to be used in 1 microsecond. Once you understand this, the PHP behaviour makes perfect sense. It is a very very very common mis-perception, and your customers are not the first, and won't be the last, to complain that it's broken. What I see as needed is clear documentation regarding how this timeout works and what it does and under what circumstances a persistent connection will terminate when the timeout is set to a time other than -1, or infinite. Put it in the User Contributed Notes. :-) I don't see this as a major coding issue, simply one of documentation and possibly implementing a small change which would actually implement an action once the timeout occurred. Obviously this 10 sec timeout being used is for testing to see the behavior, I would expect that normally the time, if not -1 and infinite would be more along the line of hours in the real world. I have no idea what real world times are, but would never presume that they'd be hours rather than 10 seconds... Each active persistent connection ties up valuable resources. The cost/benefit ratio has to be examined carefully and tweaked under real-world load in dev box tests to be sure you're doing something sensible. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Richard Lynch wrote: I *still* don't see OOP as a Right Answer for spitting out HTML web pages in optimized minimalist time frames... Maybe my brain just got warped by all that AI/Lisp work I did for a couple decades, but it feels to me like a bad selection of weapons for the task at hand, most times I see it in PHP. [shrug] There are different levels of applications that are 'spitting out HTML web pages'. If you're developing a system where each script is independent and simply makes use of shared code then OOP is almost certainly not worth it. When you get to a system of the size I deal with (several thousand files with several hundred classes and a single entry point) it becomes a lot easier to deal with that in an OOP fashion. As for your other posts about have a class that represents a single customer not being a good idea if you are going to be dealing with potentially large sets of customers, I would have to agree whole-heartedly. And I apologise if I read your post as an absolutely anti-OOP opinion when it was not. I came from a C/C++ background and feel that I understand the good and the bad effects of using OOP very well. In a PHP environment you generally need to take more care with how you architect the system to take into account the build and tear-down that occurs with each request, but OOP can still be used to great effect in large PHP sites. I do take issue with your 'free advice' when you say you should base your OOP code on your existing code. One of the things OOP does is allow/force you to think about the way you deal with data in your application from a different angle. That's definitely worth doing. In my experience developers get stuck in their habits far too easily and anything that causes you to re-evaluate the way you to things has to be worthwhile. Anyways, some of that probably didn't make much sense, so I need to write some code now. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Ed Lazor wrote: On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote: I can't architect a good OOP solution to a problem that hasn't been fully defined, any more than one can architect a house without knowing all the rooms that are needed... Sorry to jump into the middle of the conversation, but I thought this was a pretty interesting comment. It serves as one of those occasional reminders that I need to go back and study OOP structure design a bit more. I know you're right about the importance of a fully defined problem, but it also seems that the reverse is true if you're really good with OOP. In other words, it seems like any high quality solution starts by defining least common denominators. You start with basic building blocks and expand from there; I'm always amazed when I see space stations or other complex structures built out of Legos, for example. My problem is that I usually look at OOP and think it'll take too long, so I go the non-OOP route, solve the problem, and move on. I can't help but think I'm missing out. I do have libraries of code that I reuse, but I've always heard that I'd benefit a lot more from them if I OOPed them. Dunno... that's my two cents worth anyway hehe Except that is the attitude that leads to painful OOP in PHP. PHP is not the same environment as C++. The environment (classes, objects, etc) needs to be created and destroyed with each request. As such you cannot start designing a solution unless you know how the data/entities are going to be used. OOP in PHP cannot start with basic building blocks, at least not if you want a system that performs reasonably well. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Memory
I'm running out of memory even though I upped it to memory_limit = 500M in php.ini. Error messages and script are below. Thanks in advance for any tips. $ php -c /usr/local/php5/lib/php.ini createPseudoIDs.php crosswalk.txt php(780) malloc: *** vm_allocate(size=1069056) failed (error code=3) php(780) malloc: *** error: can't allocate region php(780) malloc: *** set a breakpoint in szone_error to debug FATAL: emalloc(): Unable to allocate 37 bytes ?php // Create a complete mapping of SSNs to random Pseudo Keys // Create array with all potential Pseudo Keys $pseudoKeys = array(); for ($i=1;$i=9;$i++) { $pseudoKeys[] = padToNine($i); } // Loop through all possible SSNs $numLeft = 9; for ($i=1;$i=9;$i++) { $ssn = padToNine($i); // Get random index into remaining pseudo keys $maxRand = $numLeft-- - 1; $randIndex = rand(0, $maxRand); $pseudoKey = $pseudoKeys[$randIndex]; array_splice($pseudoKeys,$randIndex,1); // Output it. print $ssn.:.$pseudoKey.\n; } function padToNine($num) { $final = ''; $cnt = strlen(strval($num)); $padding = 9 - $cnt; for ($i=1; $i=$padding; $i++) { $final .= '0'; } $final .= strval($num); return $final; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory
Maybe I'm doing my math wrong here, but for 1 to 9, make a string 9 bytes long, 10 including terminating null. (And PHP probably includes a little extra for overhead)... 9 * 10 bytes = 90 bytes - that's about 9 and a half gigs... jon Doug Fulton wrote: I'm running out of memory even though I upped it to memory_limit = 500M in php.ini. Error messages and script are below. Thanks in advance for any tips. $ php -c /usr/local/php5/lib/php.ini createPseudoIDs.php crosswalk.txt php(780) malloc: *** vm_allocate(size=1069056) failed (error code=3) php(780) malloc: *** error: can't allocate region php(780) malloc: *** set a breakpoint in szone_error to debug FATAL: emalloc(): Unable to allocate 37 bytes ?php // Create a complete mapping of SSNs to random Pseudo Keys // Create array with all potential Pseudo Keys $pseudoKeys = array(); for ($i=1;$i=9;$i++) { $pseudoKeys[] = padToNine($i); } // Loop through all possible SSNs $numLeft = 9; for ($i=1;$i=9;$i++) { $ssn = padToNine($i); // Get random index into remaining pseudo keys $maxRand = $numLeft-- - 1; $randIndex = rand(0, $maxRand); $pseudoKey = $pseudoKeys[$randIndex]; array_splice($pseudoKeys,$randIndex,1); // Output it. print $ssn.:.$pseudoKey.\n; } function padToNine($num) { $final = ''; $cnt = strlen(strval($num)); $padding = 9 - $cnt; for ($i=1; $i=$padding; $i++) { $final .= '0'; } $final .= strval($num); return $final; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] readfile() problem
Hi, It did help, but not perfectly. Sometimes I have to refresh a few times before it will be pushed. Best regards, Peter -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Friday, October 13, 2006 12:52 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] readfile() problem On Thu, October 12, 2006 11:43 am, Peter Lauri wrote: I have a problem. I am using readfile() to send files to the browser. I have three different files that I am sending. They are 3MB, 15MB and 59MB Is there any limitations or settings of how large the files can be when using readfile()? If so, are they settable? readfile() will slurp the whole file into RAM, and then spit it out to the browser. It's super-convenient and easy for small files. It's not a Good Idea for large files. fopen/fread/echo loop is your buddy. I'll bet a dollar that your old setting had a different memory_limit in php.ini -- or none at all, or it wasn't even compiled to allow memory_limit -- something along those lines. Actually, depending on the speed of the server, and its hard drives, and the drive caches, etc, it's entirely possible that the server is just taking TOO LONG to spit out that monster file. wget would probably let you find out pretty quickly if it's RAM or speed that's killing you. But it's kinda moot, really, as the solution either way remains the same. header(Pragma: public); header(Expires: 0); // set expiration time header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=$Row[filename]); header(Content-Transfer-Encoding: binary); You got Content-type: right, but you know that filename thing is only going to work on some browsers, right? http://richardlynch.blogspot.com Actually, I think -Type should be -type and it might be case-sensitive, but I'd have to re-read HTTP specs to be 100% sure, and I think all the browsers ignore case anyway, so it's kind of moot, and I'm not THAT bored... //readfile($filelocation); $file = fopen($filelocation); while (!feof($file)){ //Last I heard, 2048 optimized some PHP internal buffer... //That's probably way out of date! //And does not account for your bandwidth bottle-neck anyway. //Play with the 2048 until you're happy. echo fread($file, 2048); } -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] no SSL environment vaiables
I'm running php 5.1.1 configured with openssl 0.9.7i which was installed in /opt/local/. Everything was working fine. Then suddenly the SSL environment variables disappeared. The https variable displays on, but no SSL_ variables are displayed via phpinfo. I just installed another version of openssl in /usr/local/ssl for a packaged install of perl. I don't know why this would effect the libphp5.so or if it did. The /usr/local file system is nfs mounted so I don't want the php module dependent on anything is /usr/local as it keeps /usr/local continuously mounted. Any ideas? Thanks, Belinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] no SSL environment vaiables
On Thu, October 12, 2006 4:03 pm, gaw wrote: I'm running php 5.1.1 configured with openssl 0.9.7i which was installed in /opt/local/. Everything was working fine. Then suddenly the SSL environment variables disappeared. The https variable displays on, but no SSL_ variables are displayed via phpinfo. I just installed another version of openssl in /usr/local/ssl for a packaged install of perl. I don't know why this would effect the libphp5.so or if it did. The /usr/local file system is nfs mounted so I don't want the php module dependent on anything is /usr/local as it keeps /usr/local continuously mounted. Any ideas? I *think* the SSL_ env vars of which you speak would be entirely dependent on the httpd.conf User setting, their home dir/shell, and whatever ENV settings they have. If your new openssl and/or perl changed those, that's your answer. Just my guess, mind you. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] no SSL environment vaiables
The SSL_ variables are available in the environment. If I run a cgi script and display env they are there. But they do not show in phpinfo(); -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 2:22 PM To: gaw Cc: php-general@lists.php.net Subject: Re: [PHP] no SSL environment vaiables On Thu, October 12, 2006 4:03 pm, gaw wrote: I'm running php 5.1.1 configured with openssl 0.9.7i which was installed in /opt/local/. Everything was working fine. Then suddenly the SSL environment variables disappeared. The https variable displays on, but no SSL_ variables are displayed via phpinfo. I just installed another version of openssl in /usr/local/ssl for a packaged install of perl. I don't know why this would effect the libphp5.so or if it did. The /usr/local file system is nfs mounted so I don't want the php module dependent on anything is /usr/local as it keeps /usr/local continuously mounted. Any ideas? I *think* the SSL_ env vars of which you speak would be entirely dependent on the httpd.conf User setting, their home dir/shell, and whatever ENV settings they have. If your new openssl and/or perl changed those, that's your answer. Just my guess, mind you. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Mailer and SMTP = SPAM?
# [EMAIL PROTECTED] / 2006-10-12 11:23:52 -0500: On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote: [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. Not really -- at least not in my limited experience. There are so many OTHER factors that the DNS resolution of the return address and the actual SMTP machine not matching up are probably not a deciding factor... Sender, client.example.org, IP 1.2.3.4 connects to the receiver (server.example.org). 1. DNS - PTR RR. If 4.3.2.1.in-addr.arpa doesn't exist (the value would be client.example.org), server refuses the connection 2. DNS - A RR. If client.example.org doesn't exist or doesn't resolve to 1.2.3.4, server refuses the connection 3. DNS - RBL. If 1.2.3.4 is in any of a number of possible RBLs, server refuses the connection 4. DNS - RHSBL. If example.org is in any of a number of possible RHSBLs, server refuses the connection If the client passed all checks, the server accepts the connection: S: 220 server.example.org ESMTP C: HELO client.example.org S: 250 Ok 5. SMTP - If client doesn't say HELO with a FQDN argument, or 6. SMTP - If the HELO command argument doesn't resolve to the client IP address, the server responds with a 4xx or 5xx. C: MAIL FROM: [EMAIL PROTECTED] 7. DNS - MX or A RR. If neither of these records exists for elsewhere.org, server replies with 5xx, permanent error. S: 450 Greylisted C: QUIT server replied with a 4xx temporary error code, the client (rightly) disconnected. server in turn tries to send a message back to [EMAIL PROTECTED] to see if it accepts email: E: 220 erwin.elsewhere.org ESMTP S: HELO server.example.org E: 250 Ok S: MAIL FROM: E: 250 Ok S: RCPT TO: [EMAIL PROTECTED] E: 250 Ok S: QUIT The empty FROM address is the special null address used to send bounce messages. Should erwin reply with 5xx to any of the commands from server, [EMAIL PROTECTED] will be stored in a nondeliverables database, and when client returns it'll be rejected: C: MAIL FROM: [EMAIL PROTECTED] S: 550 Sender rejected I'm sure I forgot something or screwed the description here and there, but you get the idea. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Thu, October 12, 2006 1:03 pm, Ed Lazor wrote: On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote: I can't architect a good OOP solution to a problem that hasn't been fully defined, any more than one can architect a house without knowing all the rooms that are needed... Sorry to jump into the middle of the conversation, but I thought this was a pretty interesting comment. It serves as one of those occasional reminders that I need to go back and study OOP structure design a bit more. I know you're right about the importance of a fully defined problem, but it also seems that the reverse is true if you're really good with OOP. In other words, it seems like any high quality solution starts by defining least common denominators. You start with basic building blocks and expand from there; I'm always amazed when I see space stations or other complex structures built out of Legos, for example. My problem is that I usually look at OOP and think it'll take too long, so I go the non-OOP route, solve the problem, and move on. I can't help but think I'm missing out. I do have libraries of code that I reuse, but I've always heard that I'd benefit a lot more from them if I OOPed them. Dunno... that's my two cents worth anyway hehe Rapid prototyping in OOP, if you're willing to chuck the prototyping if it turns out to be the wrong OOP model is do-able. Even building the basic blocks first is fine -- but you've got to have the whole structure in your mind if you expect those blocks to fit in well. This is probably not really specific to OOP, but I think it tends to be more obvious with OOP when you start trying to work around the short-sighted architecture. By which I only mean that in procedural programming, the work-arounds feel less like work-arounds, at least at first, as they are not so obviously work-arounds, and just look like more functions. To get back to the ORIGINAL point -- OOP is not about raw performance. It's about maintainability, code re-use, encapsulation, etc. You can get acceptable performance from OOP if you know what you are doing -- If you don't, it's super easy for a beginner to write a total performance hog following all the best practices in the world. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
On Thu, October 12, 2006 12:52 pm, Bauer, Jay W wrote: Under the current situation these won't go away, unless there is a lot of other traffic for the webserver and the httpd servers need to free up these idle connections to handle other requests. But if there's no traffic, then does it really matter if the idle connections are sitting around?... Given something along these lines in a more real world setup, what makes sense? Given this scenario, if there is going to be a timeout, it almost needs to be an active one. And something simple along the lines of garbage collector that checks once an hour for connections that have gone and terminates them. But that requires more code in PHP. Not just more code LOTS more code, and very complicated. It's got to be inter-process aware, it's got to wake up some kind of assassin daemon, it's got to not consume hardly any resources, ... The only need demonstrated for an active GC is the incorrect perception that PHP should work that way. It just doesn't. Demonstrate a real need for the resources to be freed up when they aren't. Or provide a cheap and easy patch to free them up. Or, write a cron job to get a 0-byte file and uses ab to tickle enough of the Apache children that the connections go away, and tell your customer that you fixed it. :-) Actually, here's an even more attractive option: Set up httpd.conf such that the Apache children are dying off soon enough and fast enough after being idle, that THEY release the connection. Not to mention that they'll free up whatever resources the dormant Apache children are using. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
# [EMAIL PROTECTED] / 2006-10-12 16:29:09 -0500: On Thu, October 12, 2006 1:03 pm, Ed Lazor wrote: On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote: I can't architect a good OOP solution to a problem that hasn't been fully defined, any more than one can architect a house without knowing all the rooms that are needed... Sorry to jump into the middle of the conversation, but I thought this was a pretty interesting comment. It serves as one of those occasional reminders that I need to go back and study OOP structure design a bit more. I know you're right about the importance of a fully defined problem, but it also seems that the reverse is true if you're really good with OOP. In other words, it seems like any high quality solution starts by defining least common denominators. You start with basic building blocks and expand from there; I'm always amazed when I see space stations or other complex structures built out of Legos, for example. My problem is that I usually look at OOP and think it'll take too long, so I go the non-OOP route, solve the problem, and move on. I can't help but think I'm missing out. I do have libraries of code that I reuse, but I've always heard that I'd benefit a lot more from them if I OOPed them. Dunno... that's my two cents worth anyway hehe Rapid prototyping in OOP, if you're willing to chuck the prototyping if it turns out to be the wrong OOP model is do-able. Even building the basic blocks first is fine -- but you've got to have the whole structure in your mind if you expect those blocks to fit in well. Erm, I stopped doing BDUFs when I had to throw out two unimplementable designs and 2 x approx. 2000 LOC. The third attempt grew test-first, with better results. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Understanding persistent connections with oci8
On Thu, October 12, 2006 1:21 pm, Bauer, Jay W wrote: I agree and right now all there is in the way of tools for an administrator to use within the PHP configuration is the number of persistent connections per server and the timeout interval. These are a bit crude as tools, but as the persistent_timeout now works it is useless as a tool to tear down unneeded, expensive connections that are no longer being used. No. It works fine. It just tears them down LATER than you expect, and only under conditions that make sense to tear them down... Run your tests again, but wait for the timeout duration, and then ab a non-OCI file with N requests at once. N OCI connections should disappear. You've done this for one connection, and it went away, as expected. Scale your one-connection test up to N. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] readfile() problem
On Thu, October 12, 2006 3:26 pm, Peter Lauri wrote: It did help, but not perfectly. Sometimes I have to refresh a few times before it will be pushed. Is output_buffering defaulted to on?... Cuz then you're putting a whole SECOND copy of the output into PHP's output buffer. That's bad. :-) ini_set the buffering off in that script, or just turn it off entirely, or... Sorry I missed that bit. I never turn ob on in php.ini, so never think of it. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory
On Thu, October 12, 2006 2:23 pm, Doug Fulton wrote: I'm running out of memory even though I upped it to memory_limit = 500M in php.ini. Error messages and script are below. Thanks in advance for any tips. $ php -c /usr/local/php5/lib/php.ini createPseudoIDs.php crosswalk.txt php(780) malloc: *** vm_allocate(size=1069056) failed (error code=3) php(780) malloc: *** error: can't allocate region php(780) malloc: *** set a breakpoint in szone_error to debug FATAL: emalloc(): Unable to allocate 37 bytes You could re-write this easily enough to just loop from 0 to 99 and echo out the keys, without storing any of them in RAM, other than the one you are working on. That will work quite nicely. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Understanding persistent connections with oci8
On 12 Oct 2006, at 11:10 , Bauer, Jay W wrote: Again if someone is using this oci8.persistent_timeout they are using it because they want a way of controlling how long these connections stay around. Well, are they really? I would think they are using it to free up idle connections for use with new connections. That seems reasonable. And they are saying, Even if a connection appears to be idle right now, I only want it considered idle if there's been no activity in x seconds. I can see how it's not what you expected, but it still seems reasonable. Look at it this way, there's no point checking if an idle connection needs to be closed unless the idle connection is needed elsewhere. -- Bishops move diagonally. That's why they often turn up where the kings don't expect them to be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] no SSL environment vaiables
On Thu, October 12, 2006 4:27 pm, gaw wrote: The SSL_ variables are available in the environment. If I run a cgi script and display env they are there. But they do not show in phpinfo(); Which USER runs the CGI script?... You have to 'su' to the User defined in httpd.conf, or it doesn't have any meaning what you do in CGI for ENV. You MUST be logged in as the user whose ENV PHP is using, which is not your normal login. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] no SSL environment vaiables
It is the same user. I am running the cgi script from my browser through the web server. -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, October 12, 2006 3:08 PM To: gaw Cc: php-general@lists.php.net Subject: RE: [PHP] no SSL environment vaiables On Thu, October 12, 2006 4:27 pm, gaw wrote: The SSL_ variables are available in the environment. If I run a cgi script and display env they are there. But they do not show in phpinfo(); Which USER runs the CGI script?... You have to 'su' to the User defined in httpd.conf, or it doesn't have any meaning what you do in CGI for ENV. You MUST be logged in as the user whose ENV PHP is using, which is not your normal login. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Comments / Questions below. On Oct 12, 2006, at 12:15 PM, Stut wrote: Except that is the attitude that leads to painful OOP in PHP. PHP is not the same environment as C++. The environment (classes, objects, etc) needs to be created and destroyed with each request. I definitely agree that PHP is not the same as C++. I agree with the need for high efficiency and performance with low overhead. Actually, it's funny you mention that, because I've argued those same points with C/C++ coders new to PHP. As such you cannot start designing a solution unless you know how the data/entities are going to be used. Doesn't this mean that your design breaks when the behavior or use of the data/entities changes? OOP in PHP cannot start with basic building blocks, at least not if you want a system that performs reasonably well. Right. That makes sense with PHP being an interpreted language. I've tried to offset this somewhat by compiling libraries and having them cached before pages that rely on these libraries load. I'm trying to get a better idea of how you leverage the advantage of OOP in PHP. Do you use it? If so, how? Do you use any OOP methodologies? If so, which ones? For that matter, how many of your projects start with a detailed description of all data/entities and how they are going to be used? Does your experience differ a lot from mine? My customers rarely have a complete understanding of what they'll be doing. They usually only have a general idea. Part of my challenge is to help them define that idea, especially when it comes to defining the scope of the initial project. Yes, scope creep is to be avoided or managed in projects, but customers are always finding new and creative ways to apply their ideas. Things have to be flexible enough to support current needs and future needs. You're saying that you cannot start designing a solution unless you know how the data/entities are going to be used. I'm saying that you have to start somewhere and that code has to be extensible enough to meet growing demands. I'm sure that you try to come up with flexible designs, but I'm wondering. What is your approach? Also, isn't OOP supposed to be about separating data from programming logic? If that's the case, isn't how you use that data irrelevant? That seems like one of the greatest promises of OOP, but maybe that's just the hype? On Oct 12, 2006, at 2:29 PM, Richard Lynch wrote: Rapid prototyping in OOP, if you're willing to chuck the prototyping if it turns out to be the wrong OOP model is do-able. Do you end up throwing away a lot of code? Even building the basic blocks first is fine -- but you've got to have the whole structure in your mind if you expect those blocks to fit in well. It sounds like you (Both Stut and Richard) have done a lot of this, so I'm sure you know what you're talking about. Like I mentioned in my original post, I think I need to spend time learning better object modeling in order to take better advantage of OOP. I still can't help but wonder. How do you know if you have the full structure? Don't you end up going back and changing things a lot? This is probably not really specific to OOP, but I think it tends to be more obvious with OOP when you start trying to work around the short-sighted architecture. By which I only mean that in procedural programming, the work-arounds feel less like work-arounds, at least at first, as they are not so obviously work-arounds, and just look like more functions. I'm honestly not sure if I understand what you're saying here, but I do know that I've always tended more toward linear / procedural programming with a lot of functions. I have used OOP, but in very limited capacity - mainly to avoid the system overhead. I think I've also avoided it because I usually run into problems with defining data in objects - similar to the original issue of creating a customer object only to run into the problem of how to handle objects that represent a collection of customers. Again, me needing to get a better understanding of data modeling in OOP. It seems like you still end up having to learn data modeling the PHP way; people are probably critical of PHP because of this, but it seems like there's a middle ground and I'm curious where you guys have found that to be. Should I take this off the mailing list and talk with you about it in separate email? To get back to the ORIGINAL point -- OOP is not about raw performance. It's about maintainability, code re-use, encapsulation, etc. You can get acceptable performance from OOP if you know what you are doing -- If you don't, it's super easy for a beginner to write a total performance hog following all the best practices in the world. Definitely agree with you there. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, October 12, 2006 3:11 am, Tony Marston wrote: I have to disagree as well. There is absolutely nothing wrong which the approach of creating one class for each table in the database. It cannot be wrong for the simple reason THAT IT WORKS! Only problem is that then you often end up making ONE INSTANCE for each *row* in a large result set, and then you are in BIG TROUBLE. IT DOES NOT WORK! You've *got* to have some kind of other class that handles more than a couple handsful of the data, for anything other than a trivial application. I don't have, and never will have, one instance for each row. One instance can deal with any number of rows. And if it was trivial to start with OOP is rarely the right answer. Something may start as trivial, but over time it can expand into something more than trivial, by which time you will lose out by not going down the OO route to begin with. -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
Ed Lazor wrote: On Oct 12, 2006, at 12:15 PM, Stut wrote: As such you cannot start designing a solution unless you know how the data/entities are going to be used. Doesn't this mean that your design breaks when the behavior or use of the data/entities changes? You may end up refactoring code if your application changes that much, but a good OO design should also mean that when changes of that magnitude occur the changes required are limited to relatively small sections of code. OOP in PHP cannot start with basic building blocks, at least not if you want a system that performs reasonably well. Right. That makes sense with PHP being an interpreted language. I've tried to offset this somewhat by compiling libraries and having them cached before pages that rely on these libraries load. I'm trying to get a better idea of how you leverage the advantage of OOP in PHP. Do you use it? If so, how? Do you use any OOP methodologies? If so, which ones? For that matter, how many of your projects start with a detailed description of all data/entities and how they are going to be used? My general approach to designing a system is data-centric. I tend to start by defining the database schema since getting that clear in my head tends to lead me to a decent design. For most projects I don't start out with OOP in mind, but my brain is used to building OOP-style systems so nearly everything I do ends up with a few classes. For example, I'm currently working on a site for a couple of friends of mine. The site has an extremely simple user system - hard-coded passwords (evil I know, but it's what they asked for). When I first came to authenticate the user I naturally created a User class with three static methods: Login, Logout and IsLoggedIn. The class stores the logged in status and access level in the session. When I actually get to implementing something that requires a logged in user I will create another static method called Can which will tell me if a user can do a particular thing. Off the top of my head, that Can method will look something like... static public function Can($action) { if (!self::IsLoggedIn()) return false; return (in_array($action, $_SESSION['user']['perms'])); } For this simple example everything is hard-coded and all data required is stored in that class, including the passwords and actions allowed by each access level. Now consider that a couple of months down the line they decide they want to implement a complete DB-based user system, all I do is modify the User class to add the methods that would need incorporating getting users from the database. I can do this because I know that each visitor will only be accessing one user at a time so the performance hit is negligible. If I then go on to create an admin interface for the users, I would create another completely separate class called UserCollection to handle more than one user. I may at that point choose to expose any data-massaging methods in User to UserCollection to avoid code duplication, but that would be the extent of the way UserCollection uses the User class since the User class is optimised to work on a single user at any one time. Does your experience differ a lot from mine? My customers rarely have a complete understanding of what they'll be doing. They usually only have a general idea. Part of my challenge is to help them define that idea, especially when it comes to defining the scope of the initial project. Yes, scope creep is to be avoided or managed in projects, but customers are always finding new and creative ways to apply their ideas. Things have to be flexible enough to support current needs and future needs. You're saying that you cannot start designing a solution unless you know how the data/entities are going to be used. I'm saying that you have to start somewhere and that code has to be extensible enough to meet growing demands. I'm sure that you try to come up with flexible designs, but I'm wondering. What is your approach? To me it's all about numbers. I think the worst way you can apply OOP in PHP is by-the-book. What you need to do is look at defining your entities in relation to their existance within each request. Taking my user example above, I know that for the bulk of the system only one user will ever be needed. This makes it perfect for an object-per-record implementation since there is only one record. When I discuss a system with a customer my head is taking what they are saying and mapping it into several entities, not all of which will become actual classes, but all of which help me organise the site before doing any coding. Examples of these entites would be sections of the site, individual pages, data sets, access limits, etc. and the way those will interact with each other to provide a solution. All requirements change - fact of life. Customers never know what they really want. OOP
[PHP] canon jpegs
Hi! I'm trying to make thumbnails of uploaded jpegs via GD. It works fine on most jpegs but doesn't seem to work on canon jpegs (tried both a consumer canon and one of the finer DSLRs). When I resaved the canon jpeg in my imaging application GD could handle it. Any ideas of how to solve this? I'm in a bit of a panic. Emil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP slow -- am I an idiot?
On Oct 12, 2006, at 4:36 PM, Stut wrote: You may end up refactoring code if your application changes that much, but a good OO design should also mean that when changes of that magnitude occur the changes required are limited to relatively small sections of code. Ok, I think we're using the same approach here. I also noted the earlier comments about BUDF and I'm exploring those. It would be nice if anyone else has more examples of standard methodologies applied to PHP. My general approach to designing a system is data-centric. I tend to start by defining the database schema since getting that clear in my head tends to lead me to a decent design. Same here, most of the time. There are a few situations where I focus more on just giving the customer canned solutions and finding ways to integrate them as easily as possible. This is usually when the customer wants all kinds of features, but they can't really afford them. For example, one guy approached me the other day asking me to code forums, a community calendar, news, a rant section, a products database with inventory management, a shopping cart system, and coming up with a layout and design that integrates it all... then he said... he needs it in two weeks, it has to be priced under $400, and he needs to be able to easily update content on his own. ugh. I told him flat out that his price was way off and that he'd best go with pre-made solutions like PHPBB to get what he's after. If I then go on to create an admin interface for the users, I would create another completely separate class called UserCollection to handle more than one user. I may at that point choose to expose any data-massaging methods in User to UserCollection to avoid code duplication, but that would be the extent of the way UserCollection uses the User class since the User class is optimised to work on a single user at any one time. We use a similar approach for the user class. I haven't ever implemented something like the UserCollection class though. I'm curious about that. Does your UserCollection class extend the basic user class? Or is it something else entirely; I dunno, maybe UserCollection has a property defined as an array of User class? I think that's what people were saying earlier in the thread as being a very bad thing in terms of memory utilization, etc. How to properly define the User class and UserCollection classes also seems to delve into issues of UML and CORBA, which I don't have a lot of experience with. Is anyone applying those technologies to PHP? This makes it perfect for an object-per-record implementation since there is only one record. Yea, but I keep thinking back to how the implementation of data representation is separate from the implementation of how that data is used. Going back to the users example, I created a User class. I never bothered to create a UserCollection class because coding that does anything with a collection of users typically ends up being situational. Say I want a list of customers. I could create a UserCollection class with a method called list... and I could have it query the db and dump general fields. That seems like a fairly generic approach, so it might work, but I usually want to do something with individual fields - like link to a specific webpage to view more information on the customer, edit the customer record, delete, etc.. I know I could code all of these features into the class... but it reaches the point where it seems like overkill. It seems better to just create a webpage that has code to handle that which is what I end up doing. Mind you, I once created a bunch of classes that did all of the cool pretty formatting, table layout, with customizable doohikies, but that's where the classes started getting bloated, the system started bogging down, and there were very small, but very noticeable, delays in loading pages. I guess that leads me back to wondering how you implemented the UserCollection class or, at least, what features you built into it in order for it to be of benefit. I'm also assuming (uhoh hehe) that the same thing applies to other object hierarchies - for example, one class that defines a product and another class that defines a collection of products wondering how the two would be implemented to maintain efficiency... and I'm guessing your answer is that how you implement it depends on the situation... whether the site focuses on using individual products the most or ends up working with collections of products most... but it seems like it wouldn't matter... ie. again, the separation of data from implementation. All requirements change - fact of life. Customers never know what they really want. OOP will not shield you from the effects of having the system specification pulled from under your feet. However, it can be used to
Re: [PHP] canon jpegs
Until someone has more specific information, my first thought was to wonder which version of PHP and GD you're using in case they aren't the latest and greatest. If you're aren't, then I'd upgrade, retest, and go from there. I'd also check to see if you run into the problem with images from your camera saved with different resolution and image quality settings. Finally, you can also go to http:// www.boutell.com/gd/ for more information on GD or to contact them for help. On Oct 12, 2006, at 5:35 PM, Emil Edeholt wrote: Hi! I'm trying to make thumbnails of uploaded jpegs via GD. It works fine on most jpegs but doesn't seem to work on canon jpegs (tried both a consumer canon and one of the finer DSLRs). When I resaved the canon jpeg in my imaging application GD could handle it. Any ideas of how to solve this? I'm in a bit of a panic. Emil -- 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] Problems with LDAP Functions
G'day, I'm converting an app to use AD groups users using the php LDAP functions, now everything is working 99%. I just noticed then that 1 user is coming back via the ldap_get_entries function with a BLANK objectguid, I've confirmed using an LDAP browser they do have a objectGUID field and its also set. This is making things weird as i use it to uniquely identify users. If i pull out say 20 users, they all have objectGUID fields except for that 1 user (but its set inside ad though :S) Any help would be appreciated Phill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Mailer and SMTP = SPAM?
Thanks, that was very clear :) -Original Message- From: Roman Neuhauser [mailto:[EMAIL PROTECTED] Sent: Friday, October 13, 2006 6:32 AM To: Richard Lynch Cc: Peter Lauri; php-general@lists.php.net Subject: Re: [PHP] PHP Mailer and SMTP = SPAM? # [EMAIL PROTECTED] / 2006-10-12 11:23:52 -0500: On Wed, October 11, 2006 11:28 pm, Peter Lauri wrote: [snip] Unless the email is coming from somebody the recipient knows/trusts, then you're going to get marked by them as a spammer -- which will report back to some of the lists marking you as a spammer. [/snip] But is it not a problem sending from the SMTP server thedomain.com using something else then the email [EMAIL PROTECTED] I am planning to send from an existing email from the domain. Not really -- at least not in my limited experience. There are so many OTHER factors that the DNS resolution of the return address and the actual SMTP machine not matching up are probably not a deciding factor... Sender, client.example.org, IP 1.2.3.4 connects to the receiver (server.example.org). 1. DNS - PTR RR. If 4.3.2.1.in-addr.arpa doesn't exist (the value would be client.example.org), server refuses the connection 2. DNS - A RR. If client.example.org doesn't exist or doesn't resolve to 1.2.3.4, server refuses the connection 3. DNS - RBL. If 1.2.3.4 is in any of a number of possible RBLs, server refuses the connection 4. DNS - RHSBL. If example.org is in any of a number of possible RHSBLs, server refuses the connection If the client passed all checks, the server accepts the connection: S: 220 server.example.org ESMTP C: HELO client.example.org S: 250 Ok 5. SMTP - If client doesn't say HELO with a FQDN argument, or 6. SMTP - If the HELO command argument doesn't resolve to the client IP address, the server responds with a 4xx or 5xx. C: MAIL FROM: [EMAIL PROTECTED] 7. DNS - MX or A RR. If neither of these records exists for elsewhere.org, server replies with 5xx, permanent error. S: 450 Greylisted C: QUIT server replied with a 4xx temporary error code, the client (rightly) disconnected. server in turn tries to send a message back to [EMAIL PROTECTED] to see if it accepts email: E: 220 erwin.elsewhere.org ESMTP S: HELO server.example.org E: 250 Ok S: MAIL FROM: E: 250 Ok S: RCPT TO: [EMAIL PROTECTED] E: 250 Ok S: QUIT The empty FROM address is the special null address used to send bounce messages. Should erwin reply with 5xx to any of the commands from server, [EMAIL PROTECTED] will be stored in a nondeliverables database, and when client returns it'll be rejected: C: MAIL FROM: [EMAIL PROTECTED] S: 550 Sender rejected I'm sure I forgot something or screwed the description here and there, but you get the idea. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory
Doug Fulton wrote: function padToNine($num) { Apart from the other suggestions I'd remove the padToNine function and use $padded_num = sprintf('%09d', $number); I think that returns the same ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php