[PHP] Persistent connections
Hello, I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. -- Regards Nibin.
Re: [PHP] Re: Sending PHP mail with Authentication
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote: [snip] I'm sure I'm going to annoy people with this, but I would advise to never use PEAR. It's the biggest load of extremely badly coded PHP you'll ever find. Creating an SMTP client (with the purpose of just sending mail) is very easy to do yourself (and also a good challenge if you're not yet very skilled with PHP). Alternatively, you can indeed use a package such as PHPMailer; it's not perfect, and quite bloated for what you want probably, but it works rather well. I have to agree on the code bloat. Unless your requirements are extraordinary (which the OP's are), the native PHP mail() function is generally quite adequate. Never thought about creating a PHP email client. Interesting idea... Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static methods vs. plain functions
On Thu, Sep 19, 2013 at 06:28:32PM +0200, Simon Dániel wrote: Hi, I am working on an OOP project, and cannot decide which way to follow when I have to write a simple function. For example, I want to write a function which generates a random string. In an OOP environtment, it is a matter of course to create a static class and a static method for that. But why? Isn't it more elegant, if I implement such a simple thing as a plain function? Not to mention that a function is more efficient than a class method. So, in object-oriented programming, what is the best practice to implement such a simple function? Best practices are for academics and people who read Datamation. You have to look at why OOP exists and then ask yourself if the function you wish to create really needs any of the values that attend OOP. You also have to look at how simple your code is to read and understand. Based on what you've described, there would appear to be absolutely no value in making it into a class with a static method. In that case, all you would have done is to add an extra level of complexity to your code. If I were a programmer coming in after you to work with your code, I'd ask myself why in the world you did that. And if feasible, I would change it back to a flat function for the sake of simplicity. Always prefer non-OOP unless you have some compelling reason to make something object-oriented. For example, the interface to a DBMS is something which may involve many many functions. It is definitely something which benefits from OOP code, not flat functions. I've personally found that dates benefit from this same treatment. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dependency Injector
On Thu, Sep 05, 2013 at 04:19:18PM -0400, Bastien Koert wrote: Jee, that should have been a friday comment...how does your dic standout Don't send emails like that to the list when I've got a mouthful of water! It all came out my nose! ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs JAVA
On Tue, Aug 20, 2013 at 05:09:37PM +0100, Lester Caine wrote: shiplu wrote: During PHPvsPython search I found this info graphic https://www.udemy.com/blog/modern-language-wars/#. Some of the statistics contain Java too. Also you can search PHP and Web Development in big job sites and compare with same search but with Java. 'Python is arguably the most readable programming language' probably says it all? Personally I find it almost impossible to understand when coming in cold to someone elses code ... Java is not much better ... but I still have to persist with both since some key elements of a usable PHP IDE now rely on both :( Python may be most readable, but it's a huge fail for two reasons: 1. There are no statement terminators. Lose your indentation for ANY reason and your program is well and truly screwed, in ways you can't imagine. 2. Python programs fail in the most ungraceful way I've ever seen in an interpreted programming language. (Don't even start in on C. It's a compiled language.) Java is an incredibly heavy language for web work. Much like Ruby but more so. I'll say it again-- one of the reasons for the popularity of PHP is its similarity to C, at least a passing skill in which is common to most programmers. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to see all sessions sets in server
On Sun, Aug 04, 2013 at 05:58:53PM +0100, Ashley Sheridan wrote: [snip] I'm not saying the method is bad, but the way Facebook does it isn't great, I'm constantly seeing people online who sign out when I open up a message box. Now that might be genuine, but I'm not *that* unpopular! I'm sorry. Were you saying something? As soon as I saw Ashley Sheridan in my email client, it closed and my computer rebooted for some strange reason. ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST action
On Thu, Aug 01, 2013 at 02:35:04PM -0500, Larry Garfield wrote: [snip] So you're writing your own form tags for each specific time you need a form, or you wrote your own form builder API that is writing the form tags for you? Unless my wife creates the form in Dreamweaver, I write the HTML for the form fields. Even when she does, I add the proper code to validate each field and the form overall, using my field validation class, etc. Because if the former, I claim it's insecure. The development process is insecure, so you will screw up sooner or later. You're only human. A-ha! That's where you're wrong, Matey! For I am SUPER-CODER! Faster than a speeding 300 baud modem! More powerful than a teletype! Able to leap tall procedural functions at a single bound! With my pocket protector and trusty slide rule, I defend the indefensible and champion the cause of spaghetti code! So there! ;-P Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST action
On Mon, Jul 29, 2013 at 11:50:01AM -0500, Larry Garfield wrote: On 7/28/13 9:23 PM, Paul M Foster wrote: On Sun, Jul 28, 2013 at 08:46:06PM -0500, Larry Garfield wrote: [snip] Except as noted above. This is all home-grown, using native PHP functions designed to do these things, and classes I've written. I carefully examine each field when writing the POST-handling code with the idea in mind that no matter what the HTML says, the return value must conform to what *I* think it should be. No MVC framework written by others (though I do conform to MVC paradigm). Paul Then you're not writing your own form tags from the sound of it; you're writing your own Form API. Still an improvements. :-) No, I'm writing the form tags as well. I write the whole thing, soup to nuts. But as I'm writing the back end validation stuff, I realize that what I wrote in the HTML doesn't matter when it comes to hackers and script kiddies. So I use my bless and validation libraries to tackle form responses. That's the point I'm making. I understand what you're saying about using someone else's framework so you can make sure that tested code is being used to ensure against hacking attempts. But your pronouncement was so thunderous that I had to provide the exception. If you hang around here and read a book or two on security, you can write your own code that handles this stuff. Particularly if you have an example like CodeIgniter to use, to see how it's done. (There are times when I *don't* write the HTML. My wife the designer does. But I still go in and modify it to provide the validation bits which she can't do. She uses Dreamweaver, so a lot of the time, she doesn't even know what the raw HTML looks like.) Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST action
On Sun, Jul 28, 2013 at 08:46:06PM -0500, Larry Garfield wrote: On 07/28/2013 12:38 PM, Ashley Sheridan wrote: On Sun, 2013-07-28 at 13:37 -0400, Jim Giner wrote: Never write your own form? I'm guilty - oh, so guilty. What exactly is a 'security hardened' form? - All forms need a valid CSRF token to avoid CSRF attacks. This needs to be matched between the submitted form and server-maintained state. Do all of your forms have that? Every single one? (A GET lookup form like a search box doesn't need it, but anything with POST does, I'd argue.) Yes. I wrote a bless class just for this purpose, which I use on all form pages. - Do you have a select element? Do you have error handling for when someone submits a value for that wasn't one of the option elements? Yes, since I realize that what comes back to me may bear no resemblence to what I coded in HTML. Thus, I always check for allowed SELECT values. - Your text input field has a max length of 20. Does your code return an error when the user enters a string of 100 characters? Yes. Same answer. Putting a max length of 20 in the HTML works okay, but the user could still submit something much longer if they are attempting to hack the page. Thus I always check for max characters on the return. - Are you checking for weird edge-case-y character encoding issues? (Some versions of some browsers can be hacked by sending UTF-7 instead of UTF-8 for certain parts of the request. I don't fully understand that stuff myself, either.) No I don't check for this. - You have a number field (HTML5). Does your PHP code handle someone submitting a string anyway? I don't use HTML5 tags like this, since they are not universally supported. However, I check that numbers look like numbers on return and strings look like strings on return. PHP has built-in functions for this. All this is part of my validation class. - Are you checking all of those correctly every single time you write a form? Except as noted above. This is all home-grown, using native PHP functions designed to do these things, and classes I've written. I carefully examine each field when writing the POST-handling code with the idea in mind that no matter what the HTML says, the return value must conform to what *I* think it should be. No MVC framework written by others (though I do conform to MVC paradigm). Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reseting the auto-increment number in a MySQL database.
On Thu, Jun 27, 2013 at 11:47:28PM +0200, adriano wrote: holes in sequence of auto increment happen using transaction for insert new record but you don't commit transaction itself it seems that the autoincrement is incremented anyway at least this is my case. I think what Tedd was referring to was something else. The hole was quite large. I've seen this behavior myself, in PostgreSQL. From one transaction to the next, there were over 10,000 skipped numbers, and only me and my wife on the system. Some sort of bug, like a spinlock that wasn't interrupted the way it should have been. I remember the system taking forever to calm down before it gave the next transaction a number way forward of the last one. I waited in front of my browser for quite some time. But I couldn't explain why. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Migration of applications to PHP 5.4
On Tue, Jun 25, 2013 at 07:58:32PM +0200, Forum wrote: Hello, i recently migrated my webserver from Debian Lenny (with PHP 4.x) to Wheezy with PHP 5.4. Some applications like mediawiki could be updated and they are running fine. But there are some old and beloved applications that run any more. A good example is PHPmyedit 5.7.1 http://www.phpmyedit.org/ The first page with data is displayed but all links and buttons are dead! There is no error produced by PHP and i have no idea why it is not working? I'm have only basic knowledge with PHP and would be glad to have some tips how to debug things without error. My hope is that this migration problem is known and can be fixed simply? You should probably turn your error reporting threshold way up, so you can see what's happening. Ultimately, you'll probably need to contact the authors of the individual packages to get them to upgrade, so they can see the problems and fix them. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php, openssl and GOST ciphers - problem with GOST R 34.10-2001
Hi. So, back to the GOST ciphers problem. This is kinda a long story. Basically, there's tow sides of it. On one side there's a lack of OPENSSL_config() calls in ext/openssl/openssl.c. On the other hand, there's also a curl, which is also linked to Openssl. In case you want any encryption, you will probably want to use both modules, for obvious reasons. Curl (in this case - the upstream curl) also lacks OPENSSL_config() calls, so one would think he should add OPENSSL_config() call in every place. This isn't correct, because being called sequentlially, this leads to openssl initialization error, so OPENSSL_config() call should be called once, and it should be called in the module that is loaded first. In case you are using curl AND openssl, this definitely is curl module, because openssl initialization is done in the upstream library. Considering this, no curl/openssl modification is needed in PHP distribution, - you can patch curl upstream distribution by the method described above, and use GOST ciphers. In case you aren't using curl, you need to patch the openssl module in it's code. Curl guys are aware of the problem, but they don't want to make things even worse, so they decided to do nothing at this moment: http://sourceforge.net/p/curl/bugs/1208/ . So, why am I writing all of this ? Because I have next problem. I have a patched curl, php linked with it, fresh openssl with GOST ciphers and one of the ciphers not accessible by php: this is GOST R 34.10-2001 cipher. Here's what I have: /usr/local/openssl/bin/openssl ciphers aGOST01 GOST2001-GOST89-GOST89:GOST2001-NULL-GOST94 (so, openssl has it, according to is manual - aGOST01 - cipher suites using GOST R 34.10-2001 authentication.) Curl also has it: /usr/local/curl/bin/curl --engine gost --ciphers GOST2001-GOST89-GOST89 https://google.com curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure I got a failure, but when the non-existent cipher suite is used, the error is different: /usr/local/curl/bin/curl --engine gost --ciphers GOST2001-GOST89-GOST666 https://google.com curl: (59) failed setting cipher list So, openssl has it, curl has it, but for some reason php doesn't. openssl_get_md_methods() shows a couple of GOST digest but not GOST R 34.11-94: array(30) { [0]= string(3) DSA [1]= string(7) DSA-SHA [2]= string(17) GOST 28147-89 MAC [3]= string(15) GOST R 34.11-94 [4]= string(3) MD4 [5]= string(3) MD5 [6]= string(4) MDC2 [7]= string(9) RIPEMD160 [8]= string(3) SHA [9]= string(4) SHA1 [10]= string(6) SHA224 [11]= string(6) SHA256 [12]= string(6) SHA384 [13]= string(6) SHA512 [14]= string(13) dsaEncryption [15]= string(10) dsaWithSHA [16]= string(15) ecdsa-with-SHA1 [17]= string(8) gost-mac [18]= string(3) md4 [19]= string(3) md5 [20]= string(9) md_gost94 [21]= string(4) mdc2 [22]= string(9) ripemd160 [23]= string(3) sha [24]= string(4) sha1 [25]= string(6) sha224 [26]= string(6) sha256 [27]= string(6) sha384 [28]= string(6) sha512 [29]= string(9) whirlpool } Why ? How to investigate it ? Thanks. Eugene.
Re: [PHP] Detect and Redirect Mobile Users
On Wed, Jun 12, 2013 at 04:19:50PM -0700, dealTek wrote: Hi all, I'm curious of a simple, common, universal way to detect a mobile user so I can redirect them to a mobile directory... What is best for this: Javascript - CSS - PHP? I think for my purposes if I can detect screen size or mobile browser agent - that would be good enough for what I need right now. This is not really a PHP question. I understand your asking it, though. Does anyone know of a better list or whatever for generic web designer questions? To your question, there are two problems: 1) Looking for a browser signature is a needle/haystack proposition, and the haystack is enormous, and it gets bigger every time a new phone/tablet model comes out; 2) Screen size used to be a good indicator, but as I feared when people first started using screen resolution as the main indicator, the screens on mobile devices have become progressively more and more capable. Some of them are better than many desktops I've seen. So I'd be interested in the answer to the question myself. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limit access to php page
On Thu, May 30, 2013 at 12:06:02PM -0400, Tedd Sperling wrote: On May 29, 2013, at 11:05 PM, Paul M Foster pa...@quillandmouse.com wrote: http://sperling.com/php/authorization/log-on.php I realize this is example code. My question is, in a real application where that $_SESSION['auth'] token would be used subsequently to gain entry to other pages, what would you use instead of the simple TRUE/FALSE value? It seems that someone (with far more knowledge of hacking than I have) could rather easily hack the session value to change its value. But then again, I pretty much suck when it comes to working out how you'd hack (crack) things. Paul Paul: While the above link may be example code, it is still sound for production. Keep in mind that everything in security comes down to a true/false condition. Do you let the person in or not! Certainly there are attacks on session ids and one must deal with that. But that's the level of security we have today. I could go through all the things you need to consider in protecting your session id (e.g., not accessing your bank accounts while having coffee at StartBucks) but that would defeat the purpose of attending one of my classes on the subject. :-) Yep, next time I'm up at the North Pole, I'll drop in and see you. Meantime, the beach is heating up. Better go get some more ice for my margueritas. [grin] Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limit access to php page
On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote: On May 29, 2013, at 7:11 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I've created an authentication page (index.php) that logs into an LDAP server, then points you to a second page that some folks are intended to use to request apache redirects from the sysadmin group (redirect.php). Everything works great so far, except if you pop the full URL of redirect.php into your browser you can hit the page regardless of the login process on index.php. How can I limit redirect.php so that it can only be reached once you login via the index page? Thank you! Tim -- GPG me!! Try this: http://sperling.com/php/authorization/log-on.php I realize this is example code. My question is, in a real application where that $_SESSION['auth'] token would be used subsequently to gain entry to other pages, what would you use instead of the simple TRUE/FALSE value? It seems that someone (with far more knowledge of hacking than I have) could rather easily hack the session value to change its value. But then again, I pretty much suck when it comes to working out how you'd hack (crack) things. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] webform spam prevention
On Thu, Apr 04, 2013 at 07:29:12PM +0100, Terry Ally (Gmail) wrote: I am running captcha but the problem that I am having is that fly-by-night SEO marketeers are using the form to send marketing messages anyway. We get so many spam messages that I put up in red letters on the form that we do not want cold-calling SEO marketing messages. Since that message there has been a significant reduction in emails from legitimate SEO companies. legitimate SEO companies ROTFL! (Oh, sorry, did I say that out loud?) Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php, openssl and GOST ciphers
Hi. On 28.03.2013 11:43, czir...@gmail.com wrote: My suggestion is to ensure all the paths to what you use are valid This should help: var_dump('file://'.realpath('./p12.pem')); Does that and the rest of the files Exists? I do hope these files are not in your document root Thanks for your help, but the thing is, this is a serious bug in modules using openssl, for example in ext/openssl itselt and in ext/curl. They both don't honor the openssl config file, thus they only use some hardcoded defaults. This can be easily fixed by calling OPENSSL_config(NULL) in their code (and the default config will be parsed) or calling OPENSSL_config() with a getenv() subcall to invoke a config from the ENV, but the thing is that this isn't that simple - calling this function twice in a row (for example in curl and in openssl) breaks openssl autoconfiguration. Various bug reports exist, but still, this workaround didn't make it into the official code set. Right now I'm using custom patch for curl, which initializes the config, and then openssl module can also use it. Those who don't use curl can use the trick I described above and patch ext/openssl.c. Eugene. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] target question
On Mon, Mar 25, 2013 at 10:01:03AM -0400, Jim Giner wrote: target as in the form attribute In my appl devl I utilize an extra window when my current form is asked to generate a pdf report. Works well since that way the user can generate one report into a new window, read it, close it, and still have the reports menu in front of him/her and generate a 2nd report. I'm experiencing a problem tho and I'm guessing it's associated with ie9 or FPDF. In my reports menu form, when I click on a button that will generate a pdf, I alter the form's target to create a new window. This used to work last fall, but since then I have a new laptop running ie9, not 8. The target changing js logic is working as far as I can see (alerts in my js) but the effect is not there. Instead of a new window, the pdf opens up in the same window where the menu was and so when the user does a back he ends up going up one too many levels and has to re-request the reports menu. Didn't have this much trouble originally setting this up as I'm having now trying to debug this. I'm using the FPDF extension/class to generate my pdfs - made no recent changes there. Also my concept works very well still in a simple html document that has only two buttons on it which I created today to test a theory. That is - maybe it's not just IE9, but FPDF. Anyone have any experience in this area? This behavior of the browser actually conforms to the standard as far as I know. The target attribute is attached only to the a tag, according to w3schools.com. It may work when you use it with a form tag, it doesn't surprise me if IE doesn't honor it (of course, nothing IE does would surprise me). In any case, using it with the form tag appears to be non-standard usage, which may or may not be supported by individual browsers. I handle this situation differently. My generator code (also using FPDF) dumps the PDF in a PDF directory. Then I provide a link elsewhere with an Adobe Acrobat logo which, when clicked, opens the PDF in a separate window, using the aforementioned a href=example.com/pdfs/something.pdf target=_blankMy PDF/a paradigm. In any case, I doubt very much FPDF has anything to do with this. It just dumps its creation to wherever you tell it. The browser determines what helper application it will use to open it when it downloads the content. Whether to open a separate window/tab is determined by the HTML the browser is looking at when it makes the content request. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] target question
On Mon, Mar 25, 2013 at 04:37:50PM +, Stuart Dallas wrote: On 25 Mar 2013, at 16:35, Ford, Mike m.f...@leedsmet.ac.uk wrote: -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: 25 March 2013 16:09 This behavior of the browser actually conforms to the standard as far as I know. The target attribute is attached only to the a tag, according to w3schools.com Actually, the W3C HTML 4.01 Recommendation says: target = frame-target [CI] This attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the target of links defined by other elements. The target attribute may be set for elements that create links (A, LINK), image maps (AREA), and forms (FORM). In the current HTML5 draft, target is explicitly a permitted attribute of the form tag -- although I believe it was originally marked as deprecated. Indeed. In fact w3schools.com is known to be a very unreliable source of information these days. My advice would be to avoid it at all costs! http://w3fools.com/ Interesting. I wasn't aware of this. Thanks for the info. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php, openssl and GOST ciphers
Hi. I'm trying to sign an S/MIME with PHP, using a pair of GOST-encrypted certificate and a private key. When using openssl itself from a console everything is fine: /usr/local/openssl/bin/openssl cms -sign -in file.txt -out signedfile.txt -signer p12.pem (signedfile.txt is created) /usr/local/openssl/bin/openssl cms -verify -in signedfile.txt -out signedddata.txt -no_signer_cert_verify -issuer_checks -ignore_critical Verification successful When using PHP code I'm kinda stuck: $res = openssl_pkcs7_sign(file.txt, phpsignedfile.txt, 'file://'.realpath('./p12.pem'), 'file://'.realpath('./p12.pem'), array(To = f...@bar.com, From: FooBar f...@bar.com, Subject = Foo Bar)); if (!$res) { while ($msg = openssl_error_string()) echo $msg . br /\n; echo Failed to sign.\n; exit; } I get: # /usr/local/php/bin/php sign-clear.php PHP Warning: openssl_pkcs7_sign(): error getting private key in /root/tests/sign-clear.php on line 3 error:0609E09C:digital envelope routines:PKEY_SET_TYPE:unsupported algorithmbr / error:0606F076:digital envelope routines:EVP_PKCS82PKEY:unsupported private key algorithmbr / error:0907B00D:PEM routines:PEM_READ_BIO_PRIVATEKEY:ASN1 libbr / Failed to sign. The 'error getting private key' is all the time here, except for when it really cannot be loaded I get the 'no start line error'. So this output really looks like PHP openssl module cannot find a proper cipher. How do I tell PHP that this is a GOST cipher ? I'm telling this to openssl either using a config file, or using a direct '-engine gost' option. Is there a way to tell PHP the same thing ? I have indeed a PHP compiled and linked to a GOST-enabled openss 1.0.1e (openssl module was built with PHP together): # /usr/local/openssl/bin/openssl ciphers | grep -i GOST ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:SRP-DSS-AES-256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:GOST94-GOST89-GOST89:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES256-SHA384:ECDH-ECDSA-AES256-SHA384:ECDH-RSA-AES256-SHA:ECDH-ECDSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA:PSK-AES256-CBC-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:SRP-DSS-3DES-EDE-CBC-SHA:SRP-RSA-3DES-EDE-CBC-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:ECDH-RSA-DES-CBC3-SHA:ECDH-ECDSA-DES-CBC3-SHA:DES-CBC3-SHA:PSK-3DES-EDE-CBC-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:SRP-DSS-AES-128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-RSA-AES128-SHA256:ECDH-ECDSA-AES128-SHA256:ECDH-RSA-AES128-SHA:ECDH-ECDSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:SEED-SHA:CAMELLIA128-SHA:IDEA-CBC-SHA:PSK-AES128-CBC-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:PSK-RC4-SHA:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5 (notice it's the default config output) # ldd /usr/local/php/bin/php linux-vdso.so.1 = (0x7fff42455000) libcrypt.so.1 = /lib/libcrypt.so.1 (0x7f1077404000) libresolv.so.2 = /lib/libresolv.so.2 (0x7f10771ee000) librt.so.1 = /lib/librt.so.1 (0x7f1076fe5000) libmcrypt.so.4 = /usr/lib/libmcrypt.so.4 (0x7f1076db3000) libltdl.so.7 = /usr/lib/libltdl.so.7 (0x7f1076baa000) libdl.so.2 = /lib/libdl.so.2 (0x7f10769a5000) libfreetype.so.6 = /usr/lib/libfreetype.so.6 (0x7f107671d000) libz.so.1 = /usr/lib/libz.so.1 (0x7f1076506000) libpng12.so.0 = /lib/libpng12.so.0 (0x7f10762df000) libjpeg.so.62 = /usr/lib/libjpeg.so.62 (0x7f10760bc000) libcrypto.so.1.0.0 = /usr/local/openssl/lib/libcrypto.so.1.0.0 (0x7f1075ce2000) libssl.so.1.0.0 = /usr/local/openssl/lib/libssl.so.1.0.0 (0x7f1075a78000) libmysqlclient.so.16 = /usr/lib/libmysqlclient.so.16 (0x7f107565b000) libpthread.so.0 = /lib/libpthread.so.0 (0x7f107543f000) libnsl.so.1 = /lib/libnsl.so.1 (0x7f1075226000) libm.so.6 = /lib/libm.so.6 (0x7f1074fa4000) libxml2.so.2 = /usr/lib/libxml2.so.2 (0x7f1074c53000) libc.so.6 = /lib/libc.so.6
Re: [PHP] Re: Open form in new window
On Mon, Mar 04, 2013 at 05:39:00PM +, Tim Streater wrote: On 04 Mar 2013 at 17:10, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: button type=button onclick=OpenWindow()Submit/button will not submit the form contents. Nothing to stop your OpenWindow() function doing a submit as in: button type=button onclick=OpenWindow(this.form)Submit/button function OpenWindow (formPtr) { // Some actions formPtr.submit (); } Personally I never submit forms. I use ajax to communicate with PHP scripts and do something with the data that is returned by the script. You can see a simple example at http://www.clothears.org.uk -- Cheers -- Tim I'm trying to figure out where the net gain in that is. The PHP file being called via AJAX is doing its processing on the server either way. So it appears the only difference is an asynchronous Javascript/AJAX call or a synchronous PHP call (on a standard PHP form submission). What am I missing? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Open form in new window
On Mon, Mar 04, 2013 at 06:58:41PM +0100, Matijn Woudt wrote: On Mon, Mar 4, 2013 at 6:10 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: You could echo HTML code e.g. Which is still purely HTML and has nothing whatsoever to do with PHP. form action=result.php method=post Number: input id=quantity type=text / button type=button onclick=OpenWindow()Submit**/button /form or include it as one of your form attributes: form action=demo_form.asp method=get target=_blank First name: input type=text name=fnamebr Last name: input type=text name=lnamebr input type=submit value=Submit /form Again, pure HTML, and no PHP involved. Specifically, the (asp??) page called in the form action handler will never even be aware of the fact that the page was opened in a new window, or at least was supposed to. I was using an example and NOT intended to show ASP. target=_blank will open a new window every time. That will defeat the purpose. I have many different submit buttons, for different purposes. Depending on the $_POST value of each submit button, I tell PHP to do different things, I don't wanna interrupt this thread, but are you sure you want multiple submit buttons, especially more than two? There are probably better solutions for what you want, for example, radio button to select which action to take? - Matijn I have to agree with Matijn for this reason: If the user hits the [Enter] button at the end of their form data entry, it will trigger the *first* submit button on the page, which may or may not be what you want. Perhaps better to have the user indicate the action they wish via radio button (as Matijn suggested) and then a single submit button. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Formatting -- defining sections of code
On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote: Hey folks, kind of a strange question here. Basically, I've been trying to move my style from self taught to Oh yeah, there IS a standard for this. One of the things I frequently want to do is define sections of my code: to take a simplistic example, this outputs everything that needs to be in file A, this outputs what needs to be in file B, and so on. Up until now, I've used my own standards (generally SectionName, since it's easy to search for). But it occurs to me to wonder; IS there a standard for this? Most likely, the programming world being what it is, there either isn't one or there are lots of competing standards, but I'd be interested to know... A *standard* for something? ROTFL! Yeah, like there's a standard for herding cats! [guffaw] Seriously, no I know of no such standards. It sounds like you're thinking of the kind of thing that's more common in languages like COBOL than anything modern. Plus, it's near impossible on any significantly sized project to segregate code in such a way. That said, I would recommend PHPDoc or similar. It's a package for generating code documentation from the comments embedded in your code. You adhere to certain conventions in the format of your comments, and PHPDoc can scan your code and produce pretty docs. Plus, the comments themself serve as a sort of discipline in explaining what functions and sections of code do. If you keep your functions to singular, small tasks (as you should), the comments are invaluable when you come back later to try to figure out what you were thinking when you wrote this or that block of code. I don't know how extensive your experience is with coding or PHP. So in case you're a relative newbie, I'd also suggest that you keep classes in their own files (one file per class) in a libraries directory or somesuch. In fact, I'd suggest downloading something like CodeIgniter, and studying the way they structure their code physically. They may not be the optimum example, but for a well-known framework, their code base is relatively slim and well-organized. Also, obviously, study the MVC (model-view-controller) paradigm. It's a very useful way of dividing up your code's functionality. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing searching docs
On Wed, Dec 12, 2012 at 01:00:41PM -0500, Jim Giner wrote: Slightly off-topic perhaps but I'm looking for general input here. New idea for a project - save the minutes of my firehouse meetings into a mysql table and build a ui to search them for words and such. The docs are written in Word currently. My simplistic idea is to perhaps convert them to something other than Word format and then to store them into a field of a mysql record with the meeting date as a key field. Of course having them online I should also allow for viewing as a document in something close to their original (?) format. Any ideas - pro or con - on this idea? First off, I'd convert them to RTF (rich text format). Word format is too ephemeral ( = self-incompatible). RTF is a lowest common denomenator which can be converted to a variety of other formats. And RTF is a standardized format that both Word and things like Open Office both understand. The formatting for meeting minutes don't dictate a very complicated layout (something that RTF isn't that good with). I would suggest HTML format, but Word is notoriously atrocious at faithfully converting its own formats into HTML. The result is horrid. Second, you've hit on one of my pet peeves. Never never store huge blocks of text in SQL files. It slows them down and there's no real reason for it. There's no reason to force a DBMS to schlep around massive clumps of text or binary data. That's what disk file systems are for. Store the target data in a file and store a reference to the location of the data in the SQL database. Or perhaps, use a NoSQL solution. I don't know much about the internals of nosql systems, but I would hope that the metadata about the text objects would be stored separately from the payload (text object). Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP site search broken?
Is it just me, or is the search feature on php.net broken? When I enter a full search term (known good function name) and then hit the arrow, it brings me back to the generic search page. If I enter a partial search term and then click on one of the suggested completions, it usually (not always) does the same thing. Etc. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Beneficial site spamming framework
Folks: I've been getting spam comments on my personal blog (runs on self-written PHP blog software). I'd like to test some methods I've devised to prevent or block it. Does anyone know of a very lightweight framework for simulating an automated form fill-out on a site? Something where you could just add some code to designate the site for the attack and then what fields you wanted to send? This should be a relatively simple task for PHP and curl, but I'm not really familiar with the headers and that part of the HTTP conversation. Yes, I know this is a risky question for a public list. Feel free to contact me privately if you think the answer shouldn't be in the archives of a public list. Likewise, if you can point me to a source of quickly absorbable research on the subject. I frankly don't know how I'd google such a thing. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Day after Friday
On Sun, Sep 23, 2012 at 09:33:33AM -0400, Tedd Sperling wrote: On Sep 22, 2012, at 3:59 PM, Paul M Foster pa...@quillandmouse.com wrote: On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote: Hi gang: I know it's the Day after Friday, but I'm asking a off-topic question anyway -- sorry. Normally, I teach a PHP class at the local college, but it got canceled (don't ask why) -- now I'm teaching Java. So, can anyone recommend a Java list that is similar to this list? Off off topic... Who the hell cancels a PHP class? Do they not realize damn near the whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad nauseum, not to mention Symfony, CakePHP, Code Igniter, etc. Administrators! Ach! Paul [snip] This is just another example of how administration makes decisions. It would be nice if administration decisions were made with respect to what is best for the student as compared to this type of nonsense. You know, I never had much respect for academia (no offense, Tedd; that's not aimed at you), and this just confirms my contempt. Administrators tend to completely lack common sense. And professors tend to be arrogant and suffer from a lack of understanding of the real world and real people. Add to this the skyrocketing cost of higher education. Particularly when many of the things learned in school are either unnecessary or could be learned just as well by the diligent student through books and research on the internet. (Incidentally, when I was a kid, my best friend's father was a university professor. Brilliant economist who hated tenure.) And from what I've seen, even at the primary level, decisions are rarely made on the basis of what is best for the student. We're dealing with this currently with my granddaughter (11 years old). The only saving grace of the whole system appears to be individual teachers who manage to look past all the crap and hold the line for students. What a pity. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Day after Friday
On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote: Hi gang: I know it's the Day after Friday, but I'm asking a off-topic question anyway -- sorry. Normally, I teach a PHP class at the local college, but it got canceled (don't ask why) -- now I'm teaching Java. So, can anyone recommend a Java list that is similar to this list? Off off topic... Who the hell cancels a PHP class? Do they not realize damn near the whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad nauseum, not to mention Symfony, CakePHP, Code Igniter, etc. Administrators! Ach! Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bounce messages
On Fri, Sep 21, 2012 at 08:40:23AM +0100, Lester Caine wrote: I know that the php list are one of the 'reply to sender' email handling camp rather than reply to list. I can cope with that now and handle the multiple reply address problem this end so I ONLY reply to list. BUT is there no way of cleaning up the bounce emails we all get when posting to the list(s)? ( Waits to delete all the bounce messages for this post :) ) Not seeing bounce messages here. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Programmers and developers needed
On Tue, Sep 18, 2012 at 11:02:41AM -0700, Daevid Vincent wrote: -Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] You're missing the most important aspect of social networks.. Advertising. Please tell me that is said sarcastically. Advertising is the cancer of the internet. There was a time when there weren't ad banners, interstitials, pop-ups, pop-unders, spam, and all the other bullshit you have to sift through on a daily basis. I might add to this that one of the reasons I switched to using Google for internet searches many years ago was precisely this. All the other search portals at the time blasted you with ads. Google's search page was just a blank and the name Google, much as it is now. (Though I think Google has now become its own kind of evil.) And now I'm seeing more and more pop-up ads on websites all the time. I'm trying to read content and every little while I have to banish some pop-up or another. Grrr. Here's another massive evil: Web pages that take forever to load. Why? Because they have ads and other content being served up from other sites. It takes forever for the page to fully paint because of congestion at *other* sites which are supposed to be serving up content/ads to the page I'm visiting. Yeah, that's not annoying or anything. In fact, I've gone so far as to force my computer/browser to believe most common providers of ad content are localhost, making most requests for ad content yield 404 errors. I bought TiVo partially so I could skip ads. I've revelled in it every day since. I can watch an hour-long program in 47 minutes. (Though this is a sad commentary on television and cable content providers.) Yes, ads are Evil(tm). Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Blocking gethostbyname and Net_DNS2 behaviour
Hi, I was using gethostbyname up until recently but switched to Net_DNS2 due to lack of support for a timeout. Now I discovered some worrying behaviour and hope someone here get shed some light onto it. I am running PHP inside an Apache 2 installation as module and noticed that once I call gethostbyname it appears to block all other concurrent independent requests to PHP pages until the call returned. I do seem to remember that there were some reentrant issues with the native gethostbyname function but I wouldnt assume there is some kind of global lock on it blocking the entire runtime. What is even more worrying is that Net_DNS2 appears to show the same behaviour, even though from my understanding it is supposed to work completely independent with its own streams/sockets. Of course this behaviour only shows with a domain with non-responding name servers, hence I used vuav.com. You should be able to reproduce it easily with ?php echo gethostbyname('vuav.com'); // OR .. require('Net/DNS2.php'); $dr=new Net_DNS2_Resolver(['nameservers'=['8.8.8.8']]); $ans=$dr-query('vuav.com'); echo $ans-answer[0]-address; ? Could it have to do something with a configuration setting or might I be onto something? Thanks a lot! cheers, Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Blocking gethostbyname and Net_DNS2 behaviour
My apologies, it looks like it was a false alarm and the blocking actually comes from PHP's session manager. Sorry, Alexander On 11 September 2012 14:22, a m ner...@gmail.com wrote: Hi, I was using gethostbyname up until recently but switched to Net_DNS2 due to lack of support for a timeout. Now I discovered some worrying behaviour and hope someone here get shed some light onto it. I am running PHP inside an Apache 2 installation as module and noticed that once I call gethostbyname it appears to block all other concurrent independent requests to PHP pages until the call returned. I do seem to remember that there were some reentrant issues with the native gethostbyname function but I wouldnt assume there is some kind of global lock on it blocking the entire runtime. What is even more worrying is that Net_DNS2 appears to show the same behaviour, even though from my understanding it is supposed to work completely independent with its own streams/sockets. Of course this behaviour only shows with a domain with non-responding name servers, hence I used vuav.com. You should be able to reproduce it easily with ?php echo gethostbyname('vuav.com'); // OR .. require('Net/DNS2.php'); $dr=new Net_DNS2_Resolver(['nameservers'=['8.8.8.8']]); $ans=$dr-query('vuav.com'); echo $ans-answer[0]-address; ? Could it have to do something with a configuration setting or might I be onto something? Thanks a lot! cheers, Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The end of mysql
On Fri, Sep 07, 2012 at 09:58:38PM -0400, Jim Giner wrote: So with the announced end of the mysql functions (and switching to a different extension), one would think that my isp/hoster would be a bit more interested in my dilemma. I tried today to create my first mysqli-based test script and found that I didn't have that extension. A series of emails with my tech support told me that the shared server farm does not get mysqli - only their business servers. Since I dont' have a need for and want to pay more for a 'business server', I'm told I'm s... outta luck. Any idea on the approximate date when mysql truly goes away - ie, when is the proposed (next) update that will completely refuse to recognize it? Might be ammunition for me. Please excuse my ignorance. I feel like I just stepped into the middle of a conversation. What's this about announced end of the mysql functions? Who exactly announced what, and is there a link to whatever announcement somewhere? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FoxPro Table Structure
On Tue, Aug 28, 2012 at 10:46:24AM -0400, Floyd Resler wrote: Is there a way in PHP to get the structure of a FoxPro table (using ODBC) without having to query the table? I know I can get it by getting a row from the table and using odbc_field_type but I'd rather not have to query an entire table since there is no LIMIT command in FoxPro. I've looked and looked and haven't found a solution. Thanks! Floyd FoxPro tables have a header which details the structure of the rows which follow it. I've never written PHP code to do what you're asking, but I did write a C program which will detail the header, dump the records, output the table as SQL and a variety of other things, depending on the command line switches. I generally use it *with* PHP, using a system() call, capture the results, and then display them on screen as needed. The code is on SourceForge. See: http://noferblatz.com/dbfsak.php If you download the code and need help, just let me know. I believe the command line switch you're looking for is -i, as in: dbfsak -i mytable.dbf Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cost of redirect and site domain switch? Good Practice / Bad Practice / Terrible Practice
On Fri, Aug 17, 2012 at 01:35:11PM -0600, Tristan wrote: So, I need to change from somedomain.com to somenewdomain.com I was thinking of doing this 1) create an alias to the site somenewdomain.com to point to current server 2) run permanent 301 redirect from somedomain.com to somenewdomain.com I was thinking this was a clean safe way to do it so we dont have to run a global find replace. Concerns might be but, I don't know for sure? 1) SEO 2) processing / time / cost for the 301 redirect on any old somedomain.comrequests What do you guys think? I can comment on part of this based on what I was recently told by an SEO company. Let's assume you've got a bunch of SEO goodness (recognition, Google search placement, etc.) going for you on site1.com. If you a permanent redirect (301) to site2.com, all that SEO goodness will transfer straight across to the new site. You may take this with whatever grain of salt you like, considering it comes from an SEO company and I consider SEO companies almost uniformly liars and ripoff artists who generally have no earthly idea what they're talking about. In this case, what they're saying makes sense to me, and I suspect it's true. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cost of redirect and site domain switch? Good Practice / Bad Practice / Terrible Practice
On Sat, Aug 18, 2012 at 05:10:39PM -0400, Daniel Brown wrote: On Aug 18, 2012 4:49 PM, Paul M Foster [1]pa...@quillandmouse.com wrote: I can comment on part of this based on what I was recently told by an SEO company. Let's assume you've got a bunch of SEO goodness (recognition, Google search placement, etc.) going for you on [2]site1.com. If you a permanent redirect (301) to [3]site2.com, all that SEO goodness will transfer straight across to the new site. You may take this with whatever grain of salt you like, considering it comes from an SEO company and I consider SEO companies almost uniformly liars and ripoff artists who generally have no earthly idea what they're talking about. In this case, what they're saying makes sense to me, and I suspect it's true. ��� That doesn't sound right to me.� If so, I'd presume a lot of folks would be doing that as a service.� I have several PR6-8 domains myself, and could see how someone (not me) might say, since I'm really not using these domains anyway, I'll 301 to a paying customer for them to include their ranking.� If for no other reason than I haven't heard of folks doing this (read: SPAM), I'd guess it's not true. ��� Still, other folks are far more knowledgeable than Yours Truly when it comes to SEO.� Just for good measure, I've CC'd one (Thiago Pojda) to see if he'd be interested in chiming in on the matter. [grin] Well, what I didn't say in my original email was why this came up with the SEO company in the first place (and part of why I think SEO companies have no idea what they're talking about). We had built a website for a customer, and then they called in this SEO company to advise them. The SEO company insisted on a 301 permanent redirect at the top of every page of the site. From what domain to what domain, you may ask. From www.yourdomain.com to yourdomain.com. I kid you not. The theory being that the SEO goodness from www.yourdomain.com would transfer to yourdomain.com, if someone came in from a www.yourdomain.com link somewhere. Seriously. Never mind that for years, DNS zone files have been routinely set up so that www.example.com is a DNS alias for example.com, and so it was in this case as well. Besides which, does anyone imagine that the spiders and evaluation engines for bright companies like Google and Yahoo might actually think that www.example.com and example.com have completely different content? I can also say that, on some of these pages we built, there were forms which emailed the surfer's responses to someone at our customer's company. And the extraneous 301s at the top of these form pages apparently interfered with the functionality of these pages. When the 301s were removed, we ceased to have complaints from our customer regarding the forms. Like I said, take it with whatever grain of salt you like. And if someone more knowledgeable than the rest of us says otherwise, take their word for it instead. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Two ways to obtain an object property
On Wed, Aug 15, 2012 at 09:28:28AM +0100, phplist wrote: This relates to a minor dilemma I come across from time and time, and I'm looking for advice on pros and cons and best practice. Last night I encountered it again. Within a site I have a User object, and within page code would like to have if ($crntUser-isASubscriber) {...} There seems to be two ways to handle this: I can have a User object method getSubscriberStatus() which sets $this-isASubscriber. But to use this I would have to run the method just before the if statement. Or I could have a method isASubscriber() which returns the result, meaning the if statement should be if ($crntUser-isASubscriber()) {...} While this is last night's specific example, I seem to face the method-setting-variable or the method-returning-result-directly decision quite often. Is either of these approaches preferable, or does it simply not matter? If I read you correctly, the latter would be preferable, primarily because it involves one less step. But if you're going to have to make that decision in an if statement repeatedly, I'd probably say: $isSubscribed = $crntUser-isASubscriber(); just because in subsequent code, you're not suffering the (admittedly small) repeated overhead of the function call. But in answer to your question, isASubscriber() would be a pretty standard getter method to expose internal object properties. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is PHP unsuitable for HTML5 WebSockets?
I've looked all over the net and I have been unable to find a concrete answer to this question. I am about to start development on a web application that will need to provide real-time updates of data to user's browsers. WebSockets are ideal for this task. I have read in some places on the net that PHP is not suitable for WebSockets due to it's nature. That WebSockets are designed for long running threads/processes which each maintain multiple event-driven connections, whereas PHP was designed around the short-lived single process procedural paradigm. Yet on the other hand I see lots of guides and libraries (such as http://socketo.me/) on the net that deal with PHP WebSockets. So I don't know what to think at this stage. Is PHP a suitable platform for developing a web application that requires WebSockets?
Re: [PHP] Re: What do you call the end-user?
On Tue, Jul 24, 2012 at 10:12:34AM -0500, Shawn McKenzie wrote: On 07/19/2012 12:26 PM, Tedd Sperling wrote: Hi gang: I can't wait for tomorrow -- so here's my off-topic post today. First question: What do you call the people who ultimately use your code? Many times I would call them dumb asses. Especially many of the users of free software. Even with clear detailed user guides and the fact that it is free, they are indignant about a missing feature or having to look in the docs for anything. Very true. Also, apparently in some quarters, free == worthless. But in the case of FOSS, nothing could be further from the truth. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-WEBMASTER] Re: [PHP] The Cat Signal
On Fri, Jul 20, 2012 at 09:04:30AM +0100, Lester Caine wrote: Paul M Foster wrote: Here's another one: There are currently discussions in the U.S. Congress in favor of forcing internet vendors to charge sales tax on*all* sales, regardless of whether the vendor has a presence in that state or not. Imagine having to file state sales tax returns in 50 states. This effort has rather significant bipartisan support. Now ask yourself what large corporation with brick and mortar stores *wouldn't* sign on to support this one? That's what you're up against. You've got Amazon.com on your side. Yay. You might want to get busy on that one. In Europe VAT is applied even on on-line sales. It is the likes of Amazon shipping bulk stock from overseas 'clients' into European warehouses and then supplying them without VAT added directly in Europe that is the problem! How can I compete with someone who is also giving next day delivery, but 20% cheaper ... American sellers are one of the problems here. There are two sides to every problem and simply fighting for one side is as bad. What is needed is a reasoned debate rather than things like 'The Cat Signal' which personally I find as objectionable as the laws it's complaining about! The real problem is the VAT tax itself. In my opinion, VAT is worse than direct income tax. The only good thing about VAT is that you (presumably) don't have to file returns with every state/province involved. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What do you call the end-user?
On Thu, Jul 19, 2012 at 01:26:50PM -0400, Tedd Sperling wrote: Hi gang: I can't wait for tomorrow -- so here's my off-topic post today. First question: What do you call the people who ultimately use your code? I call them the end-user, but others have stated other terms, such as customer or user. User, because I'm writing the code for *my* customer. The person actually exposed to my code may or may not be a customer of anyone. They may simply be an internet surfer at my customer's site. Second question: Are you concerned with their (whomever) experience in using your code? This question transcends your code working correctly, accurately, and securely -- no need to comment on those aspects. But rather more specifically do you consider how easily your whomever can use your work efforts? As you may have guessed - I just attended a UX conference and they provide an interesting perspective on UX. I was wondering how php developers typically address the subject. I'm interested in user experience to a limited extent. My interest stops when a user wants the code to wipe their nose for them. Can we make the website automatically update our accounting system and then write a check for the cost of goods to the vendor? Sure. How much money do you have? (Their accounting system is some inscrutable pile of Windows COM objects, like SAP, behind a firewall. And they don't even know which vendor to write the check to. I guess mental telepathy is a part of the PHP libraries not installed on my development system.) Or when someone sends the form on the website for an appointment request, can you make a reminder pop up on all the desktops in the office? No, I can't. Here's an idea: assign someone to check the email for appointment requests throughout the day, and contact the customer to confirm, based on you actually *looking* at your appointment calendar. Sheesh. Apparently, computers (not mine) are capable of performing magic tricks. I think my screens should be fairly self-explanatory, if possible. But I'm averse to making them idiot-proof. If you're an idiot, get someone else to operate your computer for you. You shouldn't be using one. But there may be times when a computer screen or set of screens will absolutely require some training, rather than someone completely unfamiliar with the workings of the office just sitting down and being able to guess how to operate the system. You didn't learn to drive by just sitting in a car and guessing how it is done. Don't expect a web-based application to be operable simply by guessing, necessarily. By the way, I'm quite happy to write documentation for systems. Unfortunately, more than half the people who read anything can't actually *apply* what they read to whatever system they're working with. Supposedly they can read. But somehow they still need someone to explain it to them, no matter how good the docs are. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-WEBMASTER] Re: [PHP] The Cat Signal
On Thu, Jul 19, 2012 at 03:45:46PM -0400, Jeff Burcher wrote: Hi, I have been out of the loop and just did some quick skimming of SOPA/PIPA to see what all the fuss was about. PIPA seems a little vague, but SOPA seems pretty straight forward, stop piracy of copyrighted materials. I don't understand what is wrong with that? Here's another one: There are currently discussions in the U.S. Congress in favor of forcing internet vendors to charge sales tax on *all* sales, regardless of whether the vendor has a presence in that state or not. Imagine having to file state sales tax returns in 50 states. This effort has rather significant bipartisan support. Now ask yourself what large corporation with brick and mortar stores *wouldn't* sign on to support this one? That's what you're up against. You've got Amazon.com on your side. Yay. You might want to get busy on that one. Governments and large corporations are about power and *control*. The internet is the antithesis of this. So expect their efforts to control some or all of the internet to continue until they succeed. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What do you call the end-user?
On Thu, Jul 19, 2012 at 06:57:53PM -0400, admin wrote: [snip] LOL Paul, You are so very spot on, I have a current customer who would like the website to just load when he logs in. I wish I had not agreed to writing him a startup script to load the interface for him because NOW he wants it to auto login for him. They use a random key generator as a portion on their login authentication. So let's see: The system sends you a report every hour on the hour. You no longer have to navigate to the interface. It auto logs into the system for you. I pander to these kind of people like there is no tomorrow when they are the ones who sign the check, because anything outside of scope cost BIG TIME. :) I have gone so far to create training aids that are system mimics to explain to them what they are doing wrong and what the next step is. I use to write SCO compliant learning systems and let me tell you there is NO such thing as idiot proof. My wife and I were discussing something tangential to this the other day. When people are young, they engage in all sorts of silly things that waste time. But when you get older, your time becomes progressively more valuable to you. In this case, I wouldn't want to waste my time on what you describe. I don't care how big the check is. I have too many other more important things to do with my time. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating drop-down menus
On Wed, Jul 18, 2012 at 08:45:34AM +1200, James Newman wrote: Just to put my 2cents in, you might want to try jQuery if you're going to go down the AJAX road. JQuery is a LOT of code to include if you're just going to do an AJAX call or two. There are examples of doing straight AJAX with Javascript on the 'Net. Once you work through them, you find that there's a static part that you can include in all the files you want to make AJAX calls. And then there's the part that deals directly with the data you get back from whatever PHP or other script is feeding you data from outside the website. That's the part that needs custom work. I *hate* Javascript, but I managed to figure it out. Another point: I'm not sure if it's the same for other people. I'm on a crappy little computer running Linux. I've got a little CPU meter in my taskbar. And nothing jacks that meter up like Javascript. I don't know why, but Javascript just devours CPU on my computer. The more javascript, the worse. And like I said, JQuery is a LOT of code. This is one of the reasons I tend to code things in PHP instead of Javascript. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: extend or encapsulate?
On Fri, Jul 13, 2012 at 12:06:22AM -0500, tamouse mailing lists wrote: It's Friday, so... Yes, it's true, I have just started looking at using PDO instead of mysqli -- a bit behind the times... My question at this stage, is do people tend to extend the PDO class for their own use, or encapsulate it in a class (or do most people use it mostly in procedural code?) I encapsulated it in my own database class. One reason for that is that the PDO class is really two classes, which is fine for low level drivers but not production code that I have to use daily. A second reason is that many of the methods are not really necessary in a production environment. I want to limit the methods my code uses to interact with the database. Third, I wanted to handle errors and exceptions with my own methods, more suitable to the code I write. For example, a fatal error should only, but always, be issued if the database code is given something illegal to chew on. Anything else, like a failure to return the expected result, should simply yield some sort of sentinal value or something. If *my code* ever gives the database library something illegal to chew on, then it should only be because of my bad code, not because a user managed to somehow get bad data through. That is, my code should always catch illegal data before it ever gets to the database library. Fourth, encapsulation means that I can have the class itself carry around some of the data that I would normally have to explicitly pass around among functions. This way, I make that useful data (like the number of records returned from the last fetch), part of the payload of the class itself. Extension is tricky and requires a more subtle and refined knowledge of the classes involved. Besides, it exposes methods which I would prefer not be used by my code. Encapsulation limits the methods of the classes to just what I deem necessary and no more. I can always write new methods if I need them. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Entry point of an MVC framework
On Thu, Jul 12, 2012 at 10:21:21PM +0200, Simon Dániel wrote: Hi, I have started to develop a simple MVC framework. I have a base controller class which is abstract and all of the controllers are inherited from that. Every controller contains actions represented by methods. (E. g. there is a controller for managing product items in a webshop, and there are seperate actions for create, modify, remove, etc.) There is also a default action (usually an index page), which is used when nothing is requested. But what is the best way to invoke an action? I can't do it with the baseController constructor, becouse parent class can't see inherited classes. And I can't do it with the constructor of the inherited class, becouse this way I would overwrite the parent constructor. And as far as I know, it is not a good practice to call a method outside of the class, becouse the concept of operation of the class should be hidden from the other parts of the application. While I have a progressively growing dislike of frameworks, I'll give you the following advice from what I've observed in other frameworks: Normally, you build a controller class elsewhere which inherits from the base controller class. Let's say it's a controller for blog entries. Now, you populate the (child) controller with the methods you'll need for each action. Like a method to delete blog entries. A method for adding blog entries. Etc. At that point, you have to decide if you're going to use server redirection or standard URLs to get to your controller. That is: http://mysite.com?controller=blogaction=add or http://mysite.com/blog/add/ The latter method is preferred by those who believe there's such a mythical beast as pretty URLs preferred by search engines (there isn't). It requires the use of .htaccess files and Apache's mod_rewrite, which you may not have in a shared hosting environment. Hopefully that helps. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Entry point of an MVC framework
On Thu, Jul 12, 2012 at 02:44:12PM -0700, Daevid Vincent wrote: -Original Message- From: Simon Dániel [mailto:simondan...@gmail.com] Sent: Thursday, July 12, 2012 1:21 PM Subject: [PHP] Entry point of an MVC framework I have started to develop a simple MVC framework. Yeah! Just what PHP needs, another MVC framework NOT. And here's why Daevid is right. I've been having to work with Symfony, a well-known framework. Nothing against Symfony, per se. It's much like other frameworks. However, here's the kicker-- if you make an unknowing mistake with Symfony (feed it the wrong data at the wrong time), you get the most beautiful 23-file deep stack trace. Trying to track down why this parameter (which I didn't even give Symfony) is making it barf is pure torture. I'm having to wade through deep Symfony code to figure it out. Object after object instantiating other objects, magic methods, virtual classes, design pattern classes, etc. I didn't write any of this code, but I've got to wade through 23 files of it to figure out what the heck went wrong. And, oh by the way, if you don't call ./symfony cc (which clears its internal cache) at the right time, you're screwed and you'll never know why. Don't get me wrong. MVC is a great idea. It's a good way to divvy up your code. But frameworks which enforce the paradigm have a way of getting carried away with themselves. I think a lot of the people who write them try too hard to impress other programmers with the cleverness of their designs. By the time they're done, there are hundreds or thousands of files involved. Every page load has to call in a significant portion of those files, full of deep, obscure classes. Sure *looks* kewl. But it's about 15 levels deeper than it has to be. Remember, this is the web, folks. Your application has a lifetime of one page load, unlike the platform-native accounting program, which you're liable to keep open on your desktop all day. I prefer to develop shallow classes which deal with specific aspects of page handling (dates, databases, encryption, users, etc.). Then use those as part of the toolkit, assembled (again on a shallow basis) in a loosely MVC pattern. If I make a mistake, I should be able to isolate where it is within an hour (ideally much less). And be able to go to the specific class and method involved. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Entry point of an MVC framework
On Fri, Jul 13, 2012 at 12:26:33AM +0200, Timmy Sjöstedt wrote: [snip] The Controllers also doesn't care if the data is stored in MySQL, Postgres, in RAM or on butterflies or anything else, as long as data is returned in an expected format. I can attest that attempting to store data on butterflies is exceptionally difficult. You really want to isolate that in your models. Fortunately, the herding_cats design pattern works equally well with butterflies. (Welcome to Friday, half a day early! ;-) Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] disabled cookies
On Sun, Jun 03, 2012 at 10:21:21PM +0100, Ashley Sheridan wrote: Al n...@ridersite.org wrote: Disabled cookies use to be a problem years ago. What's your experience these days. I need it for my session ID. As I read the docs, the old method of appending it to the URL is a security issue. I can obviously save the ID in a temp file which can be read by all the pages needing it. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There is a new law been passed in the UK that makes non-essential cookies opt-in only, so you must get permission in order to use them. Good lord. I'm glad the U.S. Congress has not gotten together to pass laws about how we build websites here. I'm not sure I could take less-than-bright government bureaucrats telling me how to do the job of programming. No offense, Ash, but you can keep your parliament. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open Call: Official PHP Mirror
On Fri, Jun 01, 2012 at 04:50:03PM -0400, Daniel Brown wrote: [snip] Who should not apply? Third-party sponsors, those who want to try to run the mirror from their Blackberry, people without servers located in the respective country for which they're applying, shared hosting clients, Droids, Borg, Klingons, Romulans, toddlers, and the gum disease known as gingivitis. There I was, ready to volunteer, until I saw Romulans. Geez, a few bad apples spoiling it for the rest of us. Crap. ;-} Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Happy Diamond Jubilee everyone!
On Fri, Jun 01, 2012 at 06:44:17PM +0100, Ashley Sheridan wrote: This is a bit of a shameless plug, but it is a Friday and a pretty special weekend over here. I recently got to work on something a bit fun at work in my spare time and they liked it so much that it got used internally to celebrate the jubilee weekend. This is the result http://jubilee.themlondon.com For those of you interested, the leg-work is done by a bunch of PHP scripts run in the background via cron, split into 3 tasks: 1. A script goes out and searches Twitter for tweets that mention the jubilee, one instance per keyword and records those to a DB to limit the draw on the Twitter API 2. A second script goes over those tweets and pulls in all the non-default profile images for each unique user 3. Lastly, the image is built as 12 separate tiles every half hour, using PHP and GD to match the average colour of each profile pic to a spot on the image, and then these are stitched together for the final image Anyway, hope you guys all have a great weekend, more so if you're unlucky enough to be working over the whole 4 days :-/ *Very* nice work! Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Function size
On Tue, May 29, 2012 at 11:40:25PM +0200, Matijn Woudt wrote: [snip] On Tue, May 29, 2012 at 11:06 PM, Paul M Foster pa...@quillandmouse.com wrote: [snip] I think a lot of coders try to be kewler than the next 18 guys who are gonna have to look at the code, so they use a lot of compression techniques to reduce LOC. Plus, they're lazy. I'd rather see everything with lots of spaces and plenty of comments and blank lines. Especially since I'm sometimes that 18th guy to look at the code. Paul Paul, Are you stating here that compression is a bad thing? That means you consider this nice: if ( action == A ) { doA(); } else if (action == B ) { doB(); } else { doC(); } Or perhaps flooded with comments that merely say the same as the code does? I'd go for if(action == A) doA(); else if(action == B) doB(); else doC(); or , if it's really that clean, i'd probably go for if(action == A) doA(); else if(action == B) doB(); else doC(); No, that's not what I mean. It's not necessarily compression in the sense that the coder is taking up less actual space. It's hard to explain, and I'm not good at it because I try not to do it. It's more along the lines of using very terse and peculiar coding techniques to save time and look kewl. Maybe something like this: The long way: $alfa = 0; if ($bravo) { if ($delta) $alfa = echo(); elseif ($foxtrot) $alfa = golf(); } elseif ($hotel) { $alfa = india(); } The kewl way would be to translate the above into a single expression using solely multiple nested terniary operators ( ? : ) on a single line. Nothing wrong with the functionality of the result, but it becomes hard has hell to read and figure out what the code is trying to do. And nothing against terniary operators. I use them where appropriate. But in a complex conditional like the above, they really only serve to obfuscate the meaning of the code. We might marvel at the skill of a programmer who did such a thing, but he's obviously not looking down the road at the other people who will later maintain his code. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Function size
On Wed, May 30, 2012 at 04:31:12PM +0200, Sebastian Krebs wrote: [snip] If the functions were named properly you don't have to follow every execution path to the deepest deep. Or do you reading PHPs C-source, just because a wild substr() appeared? When you see a method loadFromFile() and the IDE tells you, that it expects a $filename as parameter, why should you jump there just to make sure, that the method loads something from a file by the filename given as first parameter? Here's why, and I've seen this happen a *lot*. The function may be properly named, but have side effects. Or the guy who named the function *thought* it was properly named, but was wrong. For example, he may have named the function loadFromFile(), and the function does in fact do that. What the name doesn't tell you is that it then erases the file from which it pulled. Oops! No, you're correct, the function is *not* properly named in that case. But the guy who wrote it thought it was. And before I look at the internals of the function, I don't know whether it's properly named or not. Worse, the side effects may not show up until later, and then with disasterous results. Imagine assuming everything's okay, patching your code into the system, and finding out that it's been hacking up the customer's filesystem for the last three weeks. All because you didn't check to see what that other function was *actually* doing. Rule: NEVER assume you know what a function is doing by looking at its name. ALWAYS satisfy yourself that you know what a function is doing by *looking* at what it's doing. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Function size
On Tue, May 29, 2012 at 08:52:46AM +0100, Tony Marston wrote: On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote: A rule of thumb is no more than 50 lines per function, most much less. Back in the day when we didn't have nifty gui screens and an 24 line terminals (yay green on black!), if a function exceeded one printed page, it was deemed too long and marked for refactoring. I think the idea of setting an arbitrary limit on the number of lines that a function should contain is quite ludicrous and something which I will completely ignore. If a function requires a hundred or more lines then so be it. The only reason to take a block of code and put it into its own function is when that code is likely to be called more than once so that it conforms to the DRY principle. If it is only ever used in one place then there is no point. The problems I have with creating lots of small used-only-once functions is as follows: - you have to create a meaningful name for each function. - all those functions should be arranged in alphabetical order within their containing file - having them in a random sequence makes it difficult to find the one you want. OMG in alpha order?! At best, I might group them together by function type, with some comment notation in the file. But not alpha order. I prefer not to have forward declares in my files, so I generally arrange functions so that those called by other functions later are defined before they're called. (Probably a holdover from my C days; PHP doesn't care.) No offense. I never even thought about arranging functions in alphabetical order. But I don't think I'd do it. - when browsing through the code you have to keep jumping to another function, and then returning to where you came from. I don't know about you, but I would rather use the scroll wheel on my mouse than keep jumping from one position in the file to another. Another problem I have encountered in the past with such an idea is that it encourages a stupid programmer to decrease the number of lines of code by compressing as many statements as possible into a single line, which then makes the code less easy to read and understand. This is much worse than having more than 20 lines in a function. I think a lot of coders try to be kewler than the next 18 guys who are gonna have to look at the code, so they use a lot of compression techniques to reduce LOC. Plus, they're lazy. I'd rather see everything with lots of spaces and plenty of comments and blank lines. Especially since I'm sometimes that 18th guy to look at the code. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function size
On Tue, May 29, 2012 at 11:56:47AM -0400, Tedd Sperling wrote: On May 29, 2012, at 10:20 AM, Stuart Dallas wrote: -snip- Besides, truth is subjective, but then so is everything, including that assertion. -Stuart You reply was longer than my monitor was high so I can't give an immediate reply -- I have to scroll. :-) However, with that said, you made good points and I don't disagree with any of them. As for me, I was speaking from my experience where the size of my functions over the last few decades has grown (up to a point) with my increasing monitor size. However, my eyesight has not improved and thus should be figured into this somehow. As I said before, mine is just an observation that supports the limits in reception/comprehension articles I have read. I think your 24 line terminal vs the 30 monitor argument is a valid one, up to a point. But I think the problems (if any) would depend upon many factors -- too numerous to elaborate here. But let me pose an idea. When I was in college, my degrees were in Geology. My Summer Field study (6 weeks) was to map out Geologic outcrops on a USGS topographic map. At the end of the study, all maps that matched the Professors' maps, were given the highest grades (mine the highest in all modesty). Not because they were alike, but because they approached the truth of the matter. The truth here was not subjective for there was only ONE defining truth and that could be discovered by detailed mapping. We all (including the Professors) approached the same problem in the same way and reached similar results. The closer to the truth, the more similar the maps. Over the years I've seen programming languages converge producing single solutions for common tasks, such as a FOR loop and IF statements. These seem to be universal constructs in programming logic. So my question is, as in my Geology study Is this convergence in programming logic discovering the truth of the task? Do you see what I mean? If so, then maybe the way we break down problems into smaller subsets might also be approaching an optimum method as well. I used to use (30+ years ago): 1) Input; 2) Calculation; 3) Display; as the main categories in my division logic to tackle problems and that was long before I heard of MVC. So, what I am saying is that we might all be approaching and contributing to an overall optimal logical solution in programming. Kind of an ant-colony think sort of thing. The solution is certainly not simple, but it might be an universally single solution to all the problems we perceive. Said only for Food for thought. About 30 years ago, a guy wrote an essay about architectural stablization or somesuch. He was a computer guy who had written a whole office suite for 8 bit computers (called Valdocs, written for the Epson QX-10 computer, for you voracious learners). His point was that this phenomena was recognizable in many fields involving technology. For example, the architecture of automobiles eventually stabilized in such a way that these days, they pretty much all have steering wheels used for steering, four wheels, two headlights, etc. I think mainstream programming languages have probably done a lot of stabilization over the years. You do occasionally find weird languages like Lisp/Scheme, but in the main, most languages bear strong resemblance to C and Fortran. They're geared for slightly different environments or purposes, but syntactically, they bear strong resemblance to each other, compared to, say, APL or Lisp/Scheme. And to some extent they model how most people (programmers) would naturally approach the solution of programming problems. (Of course, there are always the oddballs like me who still prefer reverse polish notation on our calculators. Go figure.) Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Variables via url
On 5/12/2012 7:21 AM, Jim Giner wrote: Of course, someone here with much more knowledge than I could very soon make me look stupid :) Meh, I don't call that looking stupid. I call it a different way of skinning the cat. :) We're all here to learn from one another, right? Thanks for the suggestion. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variables via url
Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this?
Re: [PHP] PHP: a fractal of bad design
On Wed, Apr 11, 2012 at 05:06:10PM -0700, Daevid Vincent wrote: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ Can't say he doesn't have some good points, but he sure goes about it in a dickish way. Wow. I wish I could find something that complete for Javascript. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script execution after window close
Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( On Sun, Mar 4, 2012 at 9:01 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Sun, 2012-03-04 at 20:49 +0530, Nibin V M wrote: Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, Not reliably. There are events in Javascript that you can use to trigger an Ajax call (such as onbeforeunload and onunload) but these work slightly differently from browser to browser and may not allow you to execute anything on the browser if the user is navigating away from the site or closing the tab/window. Why can't you use the session for this, and allow the session to expire after a certain period of inactivity, which would be better than reinventing what sounds like session behaviour. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( On Sun, Mar 4, 2012 at 9:08 PM, Govinda govinda.webdnat...@gmail.comwrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
ok..thanks guys...I will check further then. thanks for your inputs :) On Sun, Mar 4, 2012 at 9:59 PM, Govinda govinda.webdnat...@gmail.comwrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( My suggestion is to sort out the real issue, rather than try to fix it with the workaround of copying that file to each user's homedir. It sounds like you are just adding unnecessary complexity to your work. Maybe make a new post/thread where you describe THAT issue very carefully.. and what you have tried that is not working the way you thought it should. So far it is not clear enough to me anyway - to help. But that could be because of my shortcomings more than your post's shortcoming; I am not expert on many topics covered on this list, especially in the area of managing your webserver. -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
[PHP] curl equivalent in PHP
Hello, I am trying to display the website content through a php code ( my own websites; doesn't cause copy right issues ). I use curl to display the page via the following simple code. ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? Thank you, -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote: http://simplehtmldom.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 8:10 PM, Nibin V M nibi...@gmail.com wrote: Thanks Marc. But that need to add the DOM parser to the server. What I am looking for something like iframe in html and that doesn't require any additional PHP modules ( I do would like to avoid additions to the current php; that is why I didn't compiled in curl ) On Fri, Mar 2, 2012 at 7:58 PM, Marc Guay marc.g...@gmail.com wrote: http://simplehtmldom.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Thanks guys :) Now another problem...I use a test domain ( say blahblah.com ) for testing this, which isn't registered yet. So with the given code the index page is loading fine. But when I try to click on any links, it will redirect to the original domain which isn't exists! ( I have actually pointed the test domain to my server via hosts file on the server ) So I wanted to browse the website via a PHP script, same as if I use a browser on the server. Hope you get me! :) Is there any way to achieve this via PHP? What I wanted to On Fri, Mar 2, 2012 at 9:37 PM, Jim Lucas li...@cmsws.com wrote: On 03/02/2012 06:26 AM, Nibin V M wrote: Hello, I am trying to display the website content through a php code ( my own websites; doesn't cause copy right issues ). I use curl to display the page via the following simple code. ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? Thank you, As long as you do not need to perform posts to the other website via the PHP request, you could include, file_get_contents, fopen + fread, etc... All you need to make sure is that allow_url_fopen is enabled. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- Regards Nibin. http://TechsWare.in
Re: [PHP] curl equivalent in PHP
Hmm..I am a php newbie ( just started learning it )... what my need is to display website from my server always for a non-registered domain.This is the code I use now to display the website ?php $opts = array( 'http'=array( 'method'=GET, 'header'=Accept-language: en\r\n . Cookie: foo=bar\r\n ) ); $context = stream_context_create($opts); $fp = fopen('http://www.blahblah.com', 'r', false, $context); fpassthru($fp); fclose($fp); ? Of course blahblah.com isn't registered yet. This will load the index page of blahblah.com fine ( since I use hosts file to resolve blahblah.com on the server ). But if we click on any link, it will give server not found error since my local machine is trying to resolve blahblah.com this time. I need to avoid it and want to load my domain always from the server when I click any link on the webpage, etc . How can I modify the above code to make it work! If possible, I request somebody to tell me the exact code that I need to change in the above script - since most of the php part is still greek to me :) Thank you, On Fri, Mar 2, 2012 at 10:09 PM, Micky Hulse rgmi...@gmail.com wrote: Hello, On Fri, Mar 2, 2012 at 8:07 AM, Jim Lucas li...@cmsws.com wrote: But on some of my servers, curl isn't enabled! Is there any equivalent code to achieve the same? I've used a combination of output buffering [1], readfile() [2] and caching (specific to the framework I was using). Simply, you could resort to: ?php readfile('http://www.google.com'); ? Ofc, the links would need to be absolute in order for the assets to load. Good luck! Cheers, Micky [1] php.net/ob-start [2] php.net/readfile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
[PHP] Website preview script
Hello, I am very new to PHP coding. I am trying to achieve a task via PHP, regarding which I have been googling around for a few days and now come up with emtpy hands! Ok, what I need to write is a website preview script. That is I need to display a website hosted on serverA and pointing elsewhere, from ServerA ( via curl possibly ). For example: I have configured techsware.in and google.com on ServerA ( of course google.com pointing to their IP ). I need to display the contents of google.com on my server , if I call http://techsware.in/google.php which has some curl coding in it! Note, what I have is the domain name ( google.com ) and the IP on which it is hosted on serverA to achieve this. Any way to achieve this? I can achieve this if I put my IP google.com in /etc/hosts file ( its Linux ). But I need to run this script for normal users as well, which won't have super user privileges and thus unable to edit /etc/hosts file. So I want to specify somewhere in the PHP script that, google.com points to my IP. I can do this with this little script. # cat curl.php ?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, http://mytest.com;); curl_exec ($curl); curl_close ($curl); ? Hope someone from this forum will come back a solution [image: :)] PS: web server is apache and php version is 5.2 Thank you, -- Regards Nibin. http://TechsWare.in
Re: [PHP] Website preview script
No..what I am trying to write a website preview plugin attached to a control panel.. :) since I am a newbie, I don't know how to achieve this without modifying hosts file ( I am basically a linux sys admin ) :) @Martin - I will check it. Since I am a beginner ( of course, just started to learn PHP today ) I need to start from scratch. If yo could provide some sample code, it will be great :) thanks for your input guys.. On Thu, Mar 1, 2012 at 12:11 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Wed, 2012-02-29 at 19:29 +0100, Matijn Woudt wrote: On Wed, Feb 29, 2012 at 7:07 PM, Nibin V M nibi...@gmail.com wrote: Hello, I am very new to PHP coding. I am trying to achieve a task via PHP, regarding which I have been googling around for a few days and now come up with emtpy hands! Ok, what I need to write is a website preview script. That is I need to display a website hosted on serverA and pointing elsewhere, from ServerA ( via curl possibly ). For example: I have configured techsware.in and google.com on ServerA ( of course google.com pointing to their IP ). I need to display the contents of google.com on my server , if I call http://techsware.in/google.php which has some curl coding in it! Note, what I have is the domain name ( google.com ) and the IP on which it is hosted on serverA to achieve this. Any way to achieve this? I can achieve this if I put my IP google.com in /etc/hosts file ( its Linux ). But I need to run this script for normal users as well, which won't have super user privileges and thus unable to edit /etc/hosts file. So I want to specify somewhere in the PHP script that, google.com points to my IP. I can do this with this little script. How about just doing a str_replace[1]? - Matijn [1]http://www.php.net/str_replace Why can't you use an iframe, or are you trying to offer this other websites content as if it were on your own site? If so, I would first check to see if you're actually allowed to do that, as that will bring up quite a few copyright issues otherwise, which can be very expensive. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in
Re: [PHP] Website preview script
HI all, But what my requirement here is, I need to display the website configured on our server. No matter where the domain actually points to :) Perhaps it can call a proxyhere is the actual intention of creating this script. Suppose X created a new website on serverA, but the domain actually pointing to ServerB. So to test his new website on ServerA, he either has to edit hosts file or use serverA/~user. I don't want him not to use either method. I would like to provide him a PHP feature on my control panel says site preview through which he can view his website on serverA. Its just like a website preview option in plesk control panel :) On Thu, Mar 1, 2012 at 1:25 AM, Simon Schick simonsimc...@googlemail.comwrote: Hi, Ashley The question is what this function does ;) I think it really takes a screenshot of the server - whatever is shown there right now. But how to get a browser running there in full-screen? I came around that post for a couple of weeks ago and thought it could be useful for someone here: http://www.phpgangsta.de/screenshots-von-webseiten-erstellen-mit-php Bye Simon 2012/2/29 Ashley Sheridan a...@ashleysheridan.co.uk ** On Wed, 2012-02-29 at 19:54 +0100, Simon Schick wrote: Hi, Nibin I wonder what you'd call a website preview ... Do you mean a screenshot or the HTML-response from the server, specially prepared (sounds like you want to create a proxy ;))? Bye Simon 2012/2/29 Nibin V M nibi...@gmail.com No..what I am trying to write a website preview plugin attached to a control panel.. :) since I am a newbie, I don't know how to achieve this without modifying hosts file ( I am basically a linux sys admin ) :) @Martin - I will check it. Since I am a beginner ( of course, just started to learn PHP today ) I need to start from scratch. If yo could provide some sample code, it will be great :) thanks for your input guys.. On Thu, Mar 1, 2012 at 12:11 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Wed, 2012-02-29 at 19:29 +0100, Matijn Woudt wrote: On Wed, Feb 29, 2012 at 7:07 PM, Nibin V M nibi...@gmail.com wrote: Hello, I am very new to PHP coding. I am trying to achieve a task via PHP, regarding which I have been googling around for a few days and now come up with emtpy hands! Ok, what I need to write is a website preview script. That is I need to display a website hosted on serverA and pointing elsewhere, from ServerA ( via curl possibly ). For example: I have configured techsware.in and google.com on ServerA ( of course google.com pointing to their IP ). I need to display the contents of google.com on my server , if I call http://techsware.in/google.phpwhich has some curl coding in it! Note, what I have is the domain name ( google.com ) and the IP on which it is hosted on serverA to achieve this. Any way to achieve this? I can achieve this if I put my IP google.com in /etc/hosts file ( its Linux ). But I need to run this script for normal users as well, which won't have super user privileges and thus unable to edit /etc/hosts file. So I want to specify somewhere in the PHP script that, google.compoints to my IP. I can do this with this little script. How about just doing a str_replace[1]? - Matijn [1]http://www.php.net/str_replace Why can't you use an iframe, or are you trying to offer this other websites content as if it were on your own site? If so, I would first check to see if you're actually allowed to do that, as that will bring up quite a few copyright issues otherwise, which can be very expensive. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in It does sound more like a proxy than a preview script. What about using something like this: http://uk3.php.net/manual/en/function.imagegrabscreen.php I've never used it, but on first appearances it looks like it should produce the preview you require. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in
Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.
On Mon, Feb 13, 2012 at 09:01:03AM +0100, Simon Schick wrote: Hi, Paul I personally pretty much like the idea of auto-loaders, but that's a personal point of view. If you have always develop with scripts having autoloaders you'll hate to write a *require_once* command at the beginning of all files. And what would a dependency-injection-container be without an autoloader ;) http://www.slideshare.net/fabpot/dependency-injection-with-php-53 I wrote a quite solid dependency-injector one time, and used it for a while. But it introduced a certain opacity into my code that I didn't like very much, and I ultimately abandoned it, even though it worked quite well. It's kinda like in C. If I want to use the strchr() function, I know I'd better do an #include string.h to get that functionality. I can't just assume all the library functions are all just there, waiting for me to use them. While I've often complained about having to include those header files to get to those functions, I still prefer having those include calls obviously staring at me at the top of my files. I don't have to *assume* it's there somewhere. I can see it right there, and it comforts me. Maybe all this is my C upbringing Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.
On Mon, Feb 13, 2012 at 09:24:38AM +1100, Elbert F wrote: Hi Simon, I think you're right that I may be abusing the constructor a bit. I'm going to follow your suggestion and split it up into smaller functions. I'm also thinking of moving the set_error_handler and spl_autoload_register functions to index.php where Swiftlet is bootstrapped so they can be changed. I didn't look thoroughly at your code (though, if the respondent's perceptions were correct, I'd have to agree with his prescriptions for improvement). But I wanted to make a comment about autoloaders, since you mentioned it. My philosophy, since autoloading was introduced, was that it was a cool way to avoid having a lot of complicated file inclusion calls all over the place. Just tell the autoloader function where different types of files were located, and then just instantiate classes as you like. Easy. But I recently did some work for one of these companies with a million file internally developed framework. And at the top of each file, they'd include a require_once() (or similar) call for each of the files which would be called if you needed to instantiate a class from any of those files. So rather than putting all the magic in an autoloader function, they'd simply include the file where they knew it would be needed. (E.g., you know you're going to be calling your Date class in this file, so you put a require_once() call to the file that contains it at the top of this file.) The more I've thought about it since then, the more I've considered it a Good Thing(tm). It makes troubleshooting existing code a whole lot easier. I don't have to wonder what the autoloader is doing or where the files are, on which the current file depends. It sort of obviates the autoloader stuff, but I'd rather do that than spend hours trying to track down which file in which directory contains the class which paints the screen blue or whatever. (Yes, I'm aware that require_once() introduces some latency.) Just something to consider. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: Re: [PHP] What's Your Favorite Design Pattern?
On Wed, Feb 08, 2012 at 02:25:00PM +, Tim Streater wrote: [snip] Mmmm. Well, at this point I feel underwhelmed - but its entirely possible that I'm missing something profound [1]. Not really. After looking at some of the reviews of the book you mention on Amazon, I might be inclined to get a simpler intro. Um, yeah. It's very meta. (That's what I love about The C Programming Language. It's a little over half an inch thick in paperback, explains the whole language clearly and concisely, and has barely been revised since 1988. I'm not sure you could ask for more in a technical book.) [1] In June 1982 (or was it '83?) I visited PARC with a small group from SLAC. We saw the Star or whatever it was, with bit-mapped display and mouse pointer. Whoosh !! (Well, to be fair, we'd gone along to look into XNS). I remember working for Xerox (copy center employee) around that time, and seeing all kinds of talk in the company materials about *Ethernet*. They explained the basic protocol and compared it to token ring, and I just thought, Hmm, yes, that seems like a pretty clever way to go about networking. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arrays: Comma at end?
On Tue, Feb 07, 2012 at 11:50:45AM -0800, Micky Hulse wrote: Was there ever a time when having a comma at the end of the last array element was not acceptable in PHP? I just did a few quick tests: https://gist.github.com/1761490 ... and it looks like having that comma ain't no big deal. I can't believe that I always thought that having the trailing comma was a no-no in PHP (maybe I picked that up from my C++ classes in college? I just don't remember where I picked up this (bad) habit). I would prefer to have the trailing comma... I just can't believe I have avoided using it for all these years. Thanks! Micky I've always avoided trailing array commas, but only because I was under the impression that leaving one there would append a blank array member to the array, where it might be problematic. Yes? No? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] What's Your Favorite Design Pattern?
On Tue, Feb 07, 2012 at 09:02:00PM +, Tim Streater wrote: On 07 Feb 2012 at 19:34, Daniel Brown danbr...@php.net wrote: On Tue, Feb 7, 2012 at 13:56, Mike Mackintosh mike.mackint...@angrystatic.com wrote: I was curious to see what everyones favorite design patterns were, if you use any, and why/when have you used it? Choices include slots and signals (observer), singleton, mvc, hmvc, factory, commander etc.. Mine is apparently CPSV (Commentless Procedural Spaghetti Vomit), as that's what I encounter no less than 80% of the time in the wild. Since I have no idea what anyone is talking about, I can only conclude that you're playing Mornington Crescent (q.v.), on a non-standard board. -- Cheers -- Tim Design Patterns are Way Nifty Kewl patterns of code which are supposed to facilitate certain types of operations. (Was that sarcasm you detected? Yes it was.) For example, the Singleton pattern. Let's say you had a configuration class that held the configuration values for your application, and you wanted to make sure there was only one object of that class instantiated, no matter how many times it was called in your code. You'd arrange the code and call the class in a certain way to ensure that only one object of that class resulted. To make your configuration class a singleton, you'd probably make the class have a *private* constructor (so no outside routine could call it), and then provide a method called get_instance() which tested for the existence of an object of that class. If such an instance was found, someone calling configuration::get_instance() would simply get the existing object returned to them. Otherwise, configuration::get_instance() would instantiate the class and then return the new object to the caller. As you can see, that's a peculiar way of setting up your code for a specific purpose. Other design patterns do other things and dictate setting up things in other ways. The definitive work on this (and where it first gained the most publicity) is a book called Design Patterns by four authors (Gamma, Helm, Johnson and Vlissides). It essentially contains a chapter about each (known at the time) design pattern and some pseudocode about how it might be constructed. I imagine the authors looked at a lot of code and discovered that programmers were coming up with code that, in each case was remarkably similar for solving certain types of programming problems. So they codified what that found and wrote a book about it. I have the book on my shelf, and it's decent technology, but you could spend your whole career and never use any of it, and get along just fine. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 02:28:42PM -0600, Donovan Brooke wrote: Paul M Foster wrote: This is sort of obliquely related to PHP. I don't have a smart phone, but I need to know a couple of things: 1) Do smart phones use the same browsers as the desktop, or do they have their own stripped down versions of browsers? 2) When a browser broadcasts its header telling the server what kind of browser is involved, do they broadcast anything in the header to indicate that they're being run on a smart phone? 3) Bonus question: Is there a preferred method amongst coders to determine what type of environment is being browsed from, so as to serve up the proper type of page (desktop or smart phone version of a webpage)? Paul Hi Paul, I think this is a great PHP conversation.. and I don't understand why GOTO threads always get way more replies than something like this ;-) See religion (n), defs 1-10. Diverse User Agent compatibility is going to be more and more of a challenge for us.. gone are the days of a few known browsers that are viewing our sites. From bots, to browsers, to mobile devices, to game UA's, to app UA's.., to IE's stubborn outlook on the web... the idea of user experience is growing complicated! ;-) Well, cursory research shows there are at least 12 different major layout engines underneath modern browsers. Multiply that by versions of same, different OSes on which each run, versions of the OSes themselves, etc. etc. etc. I don't envy the job of any piece of code which tries to analyze all this. Plus, I believe that in the future, handhelds (specifically smart phones) will approach desktops in screen resolution. I really liked Mari's posted link to the a list apart blog about responsive web design using media query (CSS).. however, it seems to me that it takes the use of many languages and techniques in many cases to get the job done... user agent serving (using PHP or JS or alike), flexible CSS and web design, and a keen eye on your target audience may all play apart. Not to mention that W3C has all but abandoned its efforts to standardize HTML5. They will likely follow the path of browsers in simple de facto standardization. However, this is a PHP list.. and I think we can better approach this topic by limiting our scope to talk about how PHP could be useful. My first question, being that my first language is not PHP, is; is their any core PHP mobile detection functions/tools that exist? From what I've seen, only the get_browser() function, which depends on the existence of a browsecap file, which may or may not be installed on your system. And if it is, it's 300K in size, and introduces significant latency to page loads as a result. I have a running list of mobile UA's that I picked up somewhere that I often use and edit to distribute content accordingly. I also have a PHP mobile detection script that I picked up somewhere. I'm sure these things can be found via google as well. The problem, as Mari's link suggests, is that UA list's and browser sniffing scripts need maintaining quite regularly, since mobile UA's are being added on a weekly basis perhaps. I suspect that's more as a result of everything sniffer scripts do. They don't just detect the platform, but a variety of other things as well. Many of my projects do some PC UA (browser) sniffing.. especially for IE., as IE has it's own system that it uses for how to render content. Anyway, I'm happy to share what I have.. but like I said, PHP is not my first language, so I am interested to see what the more established PHP'ers may have to say. How about this: those of you with iPhones, Androids and the like, point your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a page which runs the phpinfo() function), and post what you get back from that exercise and what device made the query. I'd like to see if there is anything significant which indicates handheld platforms. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 09:02:34PM +, Ashley Sheridan wrote: [snip] Keeping a PHP angle to this, have you looked at using an up-to-date browscap.ini file with PHP? Basically, you can use that to read in the raw user agent string from the browser, and it then finds a matching entry in the ini file and gives you back some values about what it can assume about that device, such as whether it is known to support Java (although this is something you should be careful of, as it only tells you if it's is supported, not if there is an available JVM), if it is a mobile or search bot, what version of CSS it should support, etc. I use it myself in a personal web stats script, and as long as you keep the copy of the ini file recent, you should be OK. The issue with this (according to the get_browser() docs) is that the browsecap file is 300K long, will get longer, and significantly slows loading of your applications. Moreover, the parsing of the UA string and other data is far more extensive than anything I'd want or could use. The only thing I'd want to know is whether I'm serving pages to a handheld or desktop device. From what I've seen, pages built for handheld devices (see, for example, yahoo.mobi) are considerably stripped down, often with no CSS styling. For now, if I have to make the decision on whether to serve up desktop or handheld versions of a page, all I want to know is a yes or no answer to the question of, Is this a handheld? The native PHP get_browser() function appears to be overkill for that, and may, in fact be insufficient. That was the origin of the original questions-- was there some definitive way of knowing the platform when the page request came in. And from all the research I've done, the answer is, No. The UA string may not work as intended. There are javascript sniffers and CSS triggers, but neither are they definitive. For example, the CSS triggers test for resolution or screen width or the like. This is fine, so long as handhelds remain at crappy resolutions. But I don't expect that to be the case forever. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 04:04:28PM -0500, Adam Richardson wrote: On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson [1]simples...@gmail.com wrote: On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster [2]pa...@quillandmouse.com wrote: This is sort of obliquely related to PHP. I don't have a smart phone, but I need to know a couple of things: 1) Do smart phones use the same browsers as the desktop, or do they have their own stripped down versions of browsers? Both, although more and more smart phones join the ranks of the desktop-quality browser every day (iPhone and Android both have very capable browsers, with the iPhone's omission of flash support being the biggest difference between these two.) � 2) When a browser broadcasts its header telling the server what kind of browser is involved, do they broadcast anything in the header to indicate that they're being run on a smart phone? Yes, but that gets complicated quickly: [3]http://www.zytrax.com/tech/web/mobile_ids.html � This gets directly at the answer, but also proves that there's no practical way of using the information. There are simply too many variations, and more to come. Great reference. I didn't find it in my prior research on Google. 3) Bonus question: Is there a preferred method amongst coders to determine what type of environment is being browsed from, so as to serve up the proper type of page (desktop or smart phone version of a webpage)? To supplement the alistapart link already mentioned, here's another recent writeup: [4]http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/ Apologies, I sent the wrong link last time: [5]http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/ Adam Thanks, Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Headers on smart phone browsers
On Mon, Feb 06, 2012 at 09:01:45PM +, Stuart Dallas wrote: On 6 Feb 2012, at 05:58, Paul M Foster wrote: This is sort of obliquely related to PHP. I don't have a smart phone, but I need to know a couple of things: There are simulators available for most smartphones. 1) Do smart phones use the same browsers as the desktop, or do they have their own stripped down versions of browsers? The trend is certainly moving towards full desktop capability, but personally I still think that if you expect a significant amount of traffic from mobile devices then your site should adapt accordingly. 2) When a browser broadcasts its header telling the server what kind of browser is involved, do they broadcast anything in the header to indicate that they're being run on a smart phone? Yes, but there's no standard at the moment so detection requires something similar to https://gist.github.com/1124666. That code is pretty old, and I can't remember where I got it, but at the time it worked really well. 3) Bonus question: Is there a preferred method amongst coders to determine what type of environment is being browsed from, so as to serve up the proper type of page (desktop or smart phone version of a webpage)? Generally speaking you're better off with a design that automatically adapts to the viewport on which it's being displayed. While there's more than one reason for this, the overriding reason is that the same software (i.e. the same user agent) could be running on any size of device, from watch to huge flat panel screen on a wall. I think the world needs to move on from is it a mobile device or not to accepting the reality which is that the browser / OS is irrelevant, and that the way your site renders should be purely based upon the size of the display. Responsive designs such as that described in the A List Apart article Mari posted are fantastic tools for achieving this goal. I'm inclined to agree. In fact, my daughter, who owns an iPhone, hates the mobile-only webpages and will normally opt to see the full (desktop) website, even on her iPhone. She'd rather gesture around the original website than see a vastly simplified version with everything vertically stacked, as it often is on strictly mobile sites. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Headers on smart phone browsers
This is sort of obliquely related to PHP. I don't have a smart phone, but I need to know a couple of things: 1) Do smart phones use the same browsers as the desktop, or do they have their own stripped down versions of browsers? 2) When a browser broadcasts its header telling the server what kind of browser is involved, do they broadcast anything in the header to indicate that they're being run on a smart phone? 3) Bonus question: Is there a preferred method amongst coders to determine what type of environment is being browsed from, so as to serve up the proper type of page (desktop or smart phone version of a webpage)? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Troubleshooting Code
On Mon, Jan 09, 2012 at 10:42:59AM -0500, Marc Guay wrote: some pretty natives php functions exists to do the job : But how many times in my life will I have write echo pre; ??? Does anyone have a handy solution? (Make this the default behavior? Add a even more human-readable flag to the function? Create a simple macro in Aptana 3?) I have an init file that I include in every site that contains a few routines I use over and over. One such is: function instrument($legend, $var) { print $legend . br/\n;; print prebr/\n; print_r($var); print /prebr/\n; } I use this routine wherever I want to see what's going on. It formats (particularly) array output so that I can read it, instead of having everything look like JSON, which is much harder to read. Feel free to use the above yourself as needed. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF Printing instead?
On Thu, Jan 05, 2012 at 03:14:58PM -0500, Jim Giner wrote: ok - somebody has advised that I should not be trying to print to a printer from my website php script. The suggestion of creating a pdf and sending to the client was made. How do I install the pdf functions? I've never had to install a package before or is that something my hoster does? The fpdf and/or tcpdf libraries are the standard answers to this. The fpdf library is more primitive, but if your needs are simple, it's considerably less bulky than tcpdf. Installation on either one should be very simple, as in, download the package, put it in a subdirectory, read the documentation, and start. I use fpdf constantly for printing invoices, reports, etc. Once you've built a PDF (by following the instructions for the specific package), dump it in a subdirectory and provide a link to it on a webpage. The user can then simply click on the link and their browser will open it and provide the native (usually Adobe Reader) interface for viewing and printing it. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to mac and trying to define a php.ini file.
Hi, Or should I just be looking somewhere else? Yes, if you're setting up a local development environment on a Mac, the painless solution is to install MAMP (m as in Mac). Everything installs into a single folder (easily deletable, too) without modifying any of the original versions that might have come with OSX. There's a free version and a paid pro version here: http://.mamp.info Hope this helps, L -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Alternative session control system
Hello, I need an alternative session control system different from the PHP standard one, that does not need to use the headers, because it's for a series of scripts that will be accessed through AJAX javascript code inserted in different places of a web page which headers I do not control, so I cannot do an start_session before headers sent or setcookies neither. I have an idea on how to solve this, based on client IP, but if there is something done yet, I do not want to reinvent the wheel from scratch. Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Way to output HTML on professional websites
On Tue, Dec 27, 2011 at 12:46:29AM +0100, Florian Müller wrote: Hi guys Just a little question: I've programmed some nice little websites up to 25'000 lines of code. Now if I see some bigger websites just as facebook and so on, how are they printing their website out? Does it work like ?phpecho htmlhead...;? or do they output it like ?phpif (true) {?body /body?php} else { ?head /head?php}? Or is the code even generated or gotten from a database and evaluated? How does the website itself gets printet on really professional websites? Thanks for answer! You're asking for an opinion. In mine, if you have to call fifty files before printing a byte to screen, you've introduced too much complexity. I just finished up five weeks at a company where they were calling probably upwards of 100 files before printing anything on screen. It ought to be like this: body ?php if ($condition): ? h1Some text/h1 Other stuffbr/ Much other stuff.br/ ?php endif; ? /body /html That said, a lot of CMS-based sites use some sort of templating engine. Those go like this: body {{if condition}} ((h1:Some text}} Other stuffbr/ Much other stuff.br/ {{endif}} /body /html ... with PHP or some other language decoding the pseudo-HTML above and displaying it. Kind of a waste, in my opinion, though a lot of people swear by templating systems. Again, my opinion, they're lazy typists. In any case, I think you'll find that most CMS based site presentations are based on templating engines, though I could be wrong. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question regarding passwords/security
Not sure how to ask this question... I've always eschewed consulting a database on page loads to determine if a user is logged in, primarily because of latency issues. For example, you could store a nonce like the session ID in a table for a user when they log in. Then each time they arrive at a page which needs certain permissions to access, you'd check the table for the nonce and compare it to the actual session ID or whatever to determine that they're properly logged in. This seems reasonable but suffers from the lag on the database link's query-and-response lag time. So I've always preferred some solution where something is dragged along in a session cookie instead. Maybe something like the hash of user login, email and user name, which wouldn't be there unless you'd put it there on login. But this latter scheme just seems inherently less secure than consulting the table. Is there any concensus or overwhelming argument one way or the other? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question regarding passwords/security
On Thu, Dec 22, 2011 at 12:55:41PM -0500, Al wrote: On 12/22/2011 10:05 AM, Paul M Foster wrote: Not sure how to ask this question... I've always eschewed consulting a database on page loads to determine if a user is logged in, primarily because of latency issues. For example, you could store a nonce like the session ID in a table for a user when they log in. Then each time they arrive at a page which needs certain permissions to access, you'd check the table for the nonce and compare it to the actual session ID or whatever to determine that they're properly logged in. This seems reasonable but suffers from the lag on the database link's query-and-response lag time. So I've always preferred some solution where something is dragged along in a session cookie instead. Maybe something like the hash of user login, email and user name, which wouldn't be there unless you'd put it there on login. But this latter scheme just seems inherently less secure than consulting the table. Is there any concensus or overwhelming argument one way or the other? Paul Why not just use Sessions, that's what the function is for. http://php.net/manual/en/features.sessions.php There is a good example on this page. I'm also big on using the session buffer to maintain the current states for visitors. e.g., one I'm working on now. Obviously, most are binary switches. Makes condition logic simple. [confirmedRestrictedUser] = [idPassed] = [loggedIn] = [newRegRecordMode] = [pendingRestrictedUser] = [recordToken] = [regModeLoggedIn] = [regUserEditMode] = [restrictedMode] = 1 [secrCodePassed] = [securityPassed] = [sessionStart] = Thu, 22 Dec 2011 12:49:54 -0500 [userType] = restricted I have concerns that the items in a session buffer can be copied and used to spoof legitimate logins. This is harder to do when the info is held in a database. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with CURL using an HTTP Proxy on PHP5
Hello, The following code is failing and I do not find the cause (please, note that checkurl value and CURLOPT_PROXY are NOT the real values I'm using, of course): $ch = curl_init(); $checkurl = 'http://mycheckhost.com/'; curl_setopt ($ch, CURLOPT_TIMEOUT, 6000); curl_setopt ($ch, CURLOPT_URL, $checkurl); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_HEADER, false); curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt ($ch, CURLOPT_PROXY, '1.2.3.4:' ); $data = curl_exec($ch); $curl_info = curl_getinfo ($ch); if ( $data === false ) { $rtn = false; } else { $rtn = true; } return $rtn; Every curl_exec returns false, and a var_dump of $curl_info looks as follows: array(21) { [url]= string(25) http://mycheckhost.com/; [content_type]= NULL [http_code]= int(0) [header_size]= int(0) [request_size]= int(99) [filetime]= int(-1) [ssl_verify_result]= int(0) [redirect_count]= int(0) [total_time]= float(1.843925) [namelookup_time]= float(0.00018) [connect_time]= float(0.333015) [pretransfer_time]= float(0) [size_upload]= float(0) [size_download]= float(0) [speed_download]= float(0) [speed_upload]= float(0) [download_content_length]= float(-1) [upload_content_length]= float(-1) [starttransfer_time]= float(0) [redirect_time]= float(0) [certinfo]= array(0) { } } I know it is NOT a problem with the website, because if I comment out the line curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1) disabling the use of a proxy, it works fine. I know the proxy is working fine, because if I use curl from command line like: curl -x 1.2.3.4: http://mycheckhost.com/ It also WORKS fine. So the problem may be or within the PHP5 curl implementation, or in my own code, but I have not been able to find the problem with my code. Any hints? BTW: $ php --version PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:37:10) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding and reading firefox bookmarks with PHP
On Mon, Nov 28, 2011 at 10:59:03AM -0500, David McGlone wrote: On Sun, 2011-11-27 at 22:20 -0500, Paul M Foster wrote: On Sun, Nov 27, 2011 at 06:47:36PM -0500, David McGlone wrote: Hi all, I am wondering if it's possible to find the bookmarks file in firefox and output the contents on a page with PHP.. I'm wanting to do this so I can use it as my home page. The answer to this is not in PHP; it can be done in Firefox by itself. It's been a long time since I set this up, but if I'm not mistaken, the procedure goes like this: 1. In Firefox, enter about:config in the URL bar. (Ignore warnings.) 2. You are now in the raw configs. Search for a key called browser.bookmarks.autoExportHTML. Set this to 2. This should cause Firefox to dump the contents of it places.sqlite file to a file called bookmarks.html when Firefox is closed. 3. Find another key called browser.startup.homepage. Set this to the absolute path of a file called bookmarks.html in your Firefox file tree. The path will be something like (in Linux): /home/username/.mozilla/firefox/random string.default/bookmarks.html. (Obviously, you'll have to locate this file ahead of time.) If this isn't the exact procedure, it's close. You can dig into the Firefox docs to get the exact values or keys if these aren't right. (For example, I don't know why the first key I mentioned is 2 instead of 1.) Anyway, I have my Firefox set up this way. Hi Paul. The drawback I have found so far with this setup is that the page will not update until firefox is restarted. do you have a workaround for this? Yeah, that's the rub. When I found the instructions for doing this, they were clear that Firefox wouldn't update the file until the browser was closed. Outside of that, you'd just have to read the actual SQLite file, I suppose. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding and reading firefox bookmarks with PHP
On Sun, Nov 27, 2011 at 06:47:36PM -0500, David McGlone wrote: Hi all, I am wondering if it's possible to find the bookmarks file in firefox and output the contents on a page with PHP.. I'm wanting to do this so I can use it as my home page. The answer to this is not in PHP; it can be done in Firefox by itself. It's been a long time since I set this up, but if I'm not mistaken, the procedure goes like this: 1. In Firefox, enter about:config in the URL bar. (Ignore warnings.) 2. You are now in the raw configs. Search for a key called browser.bookmarks.autoExportHTML. Set this to 2. This should cause Firefox to dump the contents of it places.sqlite file to a file called bookmarks.html when Firefox is closed. 3. Find another key called browser.startup.homepage. Set this to the absolute path of a file called bookmarks.html in your Firefox file tree. The path will be something like (in Linux): /home/username/.mozilla/firefox/random string.default/bookmarks.html. (Obviously, you'll have to locate this file ahead of time.) If this isn't the exact procedure, it's close. You can dig into the Firefox docs to get the exact values or keys if these aren't right. (For example, I don't know why the first key I mentioned is 2 instead of 1.) Anyway, I have my Firefox set up this way. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tutorial for the structure of an php-app ?
On Sat, Nov 26, 2011 at 01:38:28AM +0100, Andreas wrote: Hi again, is there a tutorial for the structure of an php-app? There are more than enough books and online docs that teach the basics of PHP and of course the native mysql commands. I'd now rather need a help to figure out how to pull up a wee bit more complex app. I know how to connect to a DB even though it might not be mysql. I can select stuff and dump it into a HTML table. Actually I prefer PDO and PostgreSQL. Is there a tutorial that teaches how to construct a app with a 2-column design. E.g. a menue frame on the left and a bigger content area on the right. So a click on a menue item would dynamically display a form or a list in the content area. What is a good way to glue everthing together between login and logout. I know cookies and sessions and I suspect those were a way to do it. How would I integrate a template system like smarty? It weren't bad if there were clues about AJAX, too. I'm in search of a way to extend the knowledge about bricks, tubes and cables to the wisdom to actually build a house out of those things. Aside from the fact that, yes, much of what you're asking for has to do with the user interface and not PHP, there is no ONE way to build a PHP app. PHP is flexible enough to allow you to do it any of a number of ways. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] news and article posts in one table
On Sat, Nov 26, 2011 at 01:26:49PM -0600, Tamara Temple wrote: muad shibani muad.shib...@gmail.com wrote: i wanna to create one table that contains both news and articles posts, they have similar columns like id, title, content, and date but they are differ in one column = the source of news or article post article has writers that have permanent names and pictures obtained from another table called writers that supposed to be left joined with the news table, while news posts simply have a source as text like AFP or Reuters and so one. How I can solve this ? How you store things in tables can sometimes get a little tricky. One way to approach this is with normalized tables and using joins in your query like you are doing. To make this work, in your main entries table, have a field that indicates what the entry type is. If you are doing one select that gets both articles and news stories, having that extra field can help you distinguish what type it is, and which fields contain data in each record. (cf: Wordpress wp_posts table for an example of how this is done. They store posts, pages, and attachments in a single table this way. I can't say if this is a better arrangement than keeping them in separate tables.) I've had to hack this table. It's a prime example of bad design. Take a long look at the records of this table in an active blog, with a survey of each of the fields and their values. You'll see what I mean. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with proc_open and getmypid
Hello, I'm developing a PHP application that runs on GNU/Linux with php cli. A process must launch another one and store its pid, so I use proc_open and then proc_status to achieve that. The child process must also get its own pid and write it down to a file. After that, the calling process should compare both pids and they should match, but in fact they shoudln't. The problem is that when calling to proc_open like: $res = proc_open (/usr/bin/php proc2.php, array(), $pipes); Two processes are created, one for the sh shell that launchs the php interpreter, and another for the php interpreter itself. Also, it seems like proc_get_status($res) returns the status of the sh, while getmypid in the second process returns the pid of the php interpreter. I wonder if there's anyway of do something of these: a) Get the pid of the php interpreter on proc_open instead of the sh one on the parent process, or... b) Get the pid of the sh process instead of the php interpreter on the child process. Or any manner in which two pids matches. Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help Wth PHP
On Mon, Oct 10, 2011 at 03:58:31PM -0700, Rod Lindgren wrote: Thanks for the info. Very helpful. I am working on it. What is it that makes Wordpress valuable? The website in question is really pretty basic. I am trying to figure out the reason Wordpress was used. It allows the site owner to directly modify the site, without having to call a programmer or web developer. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple SQLite statements
On Mon, Oct 10, 2011 at 04:14:00PM +0100, Tim Streater wrote: I would like to use the SQLite3 (not PDO) interface to SQLite, and I would like to be able to supply a string containing several SQL statements and have them all executed, thus saving the overhead of several calls. It *appears* that this may be how it actually works, but I wondered if anyone could confirm that. -- Cheers -- Tim The docs appear to agree that this is allowed. See: http://us.php.net/manual/en/function.sqlite-exec.php Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Secure data management
On Fri, Oct 07, 2011 at 12:46:52AM -0400, Govinda wrote: http://stut.net/2011/09/15/mysql-real-escape-string-is-not-enough/ Hi everyone I have read many many articles and blog posts in the last few days to bolster my (still mostly newbie) understanding of the factors that play in to preventing various methods of SQL injection prevention.. and by now I am well aware that most everyone (expert) here says prepared statements are the most secure method of (string hacking) SQL-injection prevention.. even to the point of saying that one common (and at least previously-popular) alternative mysql-real-escape-string is ..silly and technically insecure... I am learning and using the CodeIgniter (CI) framework for my current project and, not wanting to leave myself vulnerable, I read posts on the CI forum on this topic, to find out if I could (or needed) to use prepared statements in CI.. and I read one forum thread where one dev shows how to hack the core system of CI so that it can use PDO (for prepared statements) instead of the built-in ActiveRecord (or Query Bindings) which apparently rely on mysql-real-escape-string. In that thread, the debate goes back and forth, as it does in other threads.. and while the sentiment that prepared statements are better because they remove the need to keep being ahead of the char-escaping chase... I never did see any example of *how* mysql-real-escape-string fails. The only thing I ever read that does show mysql-real-escape-string possibly failing is in the example in this article: http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string or rather an article referred to there, here: http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html ..which only comes up in certain circumstances.. ([snip]..The bottom line while the problem is serious, it would only affect people changing character sets from single-byte encodings to multibyte ones. As long as you stay away from multibyte encodings, with the exception of UTF8 you should be safe...[snip]). All well and good. I just wanted to understand, as a relative newbie, why such bold seemingly definitive statements are made here on this list in recent weeks, like .. escaping doesn't work.. ? http://marc.info/?l=php-generalm=131293616328301w=2 http://marc.info/?l=php-generalm=131603743606025w=2 Isn't it that it does work in most cases.. and one just needs to know in which cases it can fail, and how to handle things in each case? I totally get the point that prepared statements just remove so much of the head pressure of sorting all this out.. BUT when someone (mostly new) like me comes along and hears that mysql-real-escape-string is simply not secure, then it just gives an unclear and incomplete picture, and creates more head pressure. Or is there definitive evidence, more recent than the above-mentioned articles, that shows how to hack through mysql-real-escape-string even in an SQL statement e.g. inserting into a UTF8 db, a properly escaped (mysql-real-escape-string) var? In case my post here is lacking understanding, then please forgive.. and better yet, please explain! I post/ask because I am wanting to SEE the whole everything like you few experts here who really know exactly what everyone is talking about (or when they are just groping in the dark). There is more to SQL injection than getting the quoting correct. In my understanding, prepared statements handles the other problems associated with queries and SQL injection beyond just quoting. Here's a good tutorial on how this works: http://www.youtube.com/watch?v=bORZlmyDw0s Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New Service - Short URL Unshortener
Le lundi 26 septembre 2011 02:08, Mike Mackintosh a écrit : Hey All, Wanted to pass a kind word of a new service we launched called Unshortenr (www.unshortenr.com) - which was linkrater.com. Input a short url and you'll get the target address, the page title, and a description of the page. Soon to add an option to preview it with a images on/off type of deal. Feedback would be appreciated. Thanks, Mike and I also have to create a system of free license short url [1] and I hope to have in my team of contributors [1] http://urlshort.eu -- http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x092164A7 gpg --keyserver pgp.mit.edu --recv-key 092164A7 http://urlshort.eu fakessh @ pgpoHofB2G7Ou.pgp Description: PGP signature
Re: [PHP] What determines your use of the type of DB framework/abstract?
On Thu, Sep 22, 2011 at 11:31:54AM -0700, Jamie Krasnoo wrote: Sorry, not sure if the first part of the conversation made it to the list. I will be looking in to Symfony. I'm well versed with ZF and Zend_Db. I'm also somewhat versed with Doctrine and integrating it with ZF. My question isn't whether Doctrine is a part *of* that framework but rather on *what* and *when* it is appropriate to *use* or *substitute* something like Doctrine instead of using straight pdo or mysqli or the abstract that came with that particular framework. Substituting Doctrine or some other abstract could complicate a project rather than help. Doctrine is more than just an abstraction layer. Well, no, but it's also an ORM framework. That alone would kill it for me. I built my own wrapper around PDO, that I use whenever possible. Main reason: it makes my interface the same, whether I'm using MySQL or PostgreSQL. That simplifies things for me. Why not just use PDO? I think PDO, for all its assets, has kind of a clunky interface. When I'm doing work internally, I use PostgreSQL. But for customers, I'm generally forced to use MySQL. So having the same interface for both (for the most part) eases the work. As for ORMs, I'm old skool; my preference is to use straight SQL where possible. I think it makes you think more carefully about your database structure and the type of queries you do. And sooner or later, ORM gets in the way of multi-table foreign-key reliant queries. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any free online tests to test my PHP knowledge?
On Thu, Sep 22, 2011 at 11:53:54AM -0600, Mike Hansen wrote: Does anyone know of a site that has an online test of PHP skills? I'd like to review my PHP knowledge. I've already run across this site: http://vladalexa.com/scripts/php/test/test_php_skill.html Thanks, Mike I've had to take online PHP tests twice for recruiters. My beefs are 1) they're not open book, and I code with a tab open to php.net all the time. (Who remembers which parameter comes first on which function call: needle or haystack?) 2) They never tell you *what* you got wrong. That's not very helpful. Mind you, these aren't free tests like you're probably talking about. They are through a vendor whom the recruiter probably pays to administer the test. Incidentally, despite having written an awful lot of working PHP code, I don't do well on those tests. Helps my confidence a lot, as you can imagine. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] What would you like to see in most in a text editor?
On Wed, Sep 14, 2011 at 01:18:00PM +0100, Tim Streater wrote: On 14 Sep 2011 at 12:40, Richard Quadling rquadl...@gmail.com wrote: On 14 September 2011 01:23, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, Sep 13, 2011 at 3:35 PM, Robert Cummings rob...@interjinn.com wrote: I'm a big fan of editors that work in the terminal. You'll get my emacs when you pry it out of my cold dead hands. Pah! You and your full screen editor. EDLIN is the way to go. Is that more or less terse than TECO? Back in 1989 when I was at SLAC, they were just getting into unix, and debates were raging about which editor to standardise on and teach people (emacs, vi, jove, etc). Because this wasn't settled, I started using notepad (and later, dxnotepad) and got on with coding. Six months later, the debates were still raging. I then had an epiphany: I'd been using notepad for six moths got work done. It took me 5 minutes to find out how to use it. I didn't need teaching about it or to have a manual. So IMO, emacs, vi, and all their ilk belong in the dustbin of history. -- Cheers -- Tim I agree with you for the most part. I used to use Nano for this reason, which tends to be available on any given system. But sometimes Nano isn't available and/or is difficult to find/install. It offers very little flexibility and, as far as I know, no capability to do add-ons. It also doesn't do syntax highlighting, as far as I know. I resisted Emacs because I'd have arthritis in short order from having to deal with the plethora of control and alt keystrokes which don't make mnemonic sense to me. Plus, it can be a massive. Eventually I switched to Vim (counter-intuitively) because 1) there's no *unix variant on which it's not available; 2) at some point, you're probably going to *have* to know how to operate Vi if you move around among foreign machines and networks; 3) there are many other applications which use many of the same keystroke patterns which are fundamental to Vi; 4) most keystroke combinations do not require leaving the home row, etc.; 5) Vi easily does syntax hilighting and a variety of other things, depending on add-ons. The modal model of Vi/Vim is sometimes a pain in the ass. And yes, it can take a long time to know all the features of Vim. But there are a number of things I can do faster in Vim, than anyone else can do in other editors, with less effort. No attempt here to dissuade Emacers or others. Whatever floats your boat and you're happy with, continue using. Why should you or I care what someone else uses for an editor? BTW, my big beef with online editors is latency, and it's a *huge* problem, as far as I'm concerned. Ultimately this is why I wrote blog software for myself which requires you to compose and edit your posts locally, and then *upload* them to the blog. That, and the silly idea that one should store huge masses of text in relation databases; large masses of text should be stored as what they are-- flat files. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php