[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: Save page as text
Hello Rafael, You can try using output control functions (see http://ro.php.net/manual/en/function.ob-start.php) and, depending on whether you want to upload the file or save it on your server (I don't understand which from your message), serve the result with a Content-type: text/plain header (see function header()), or use fopen() and fwrite() to save it on your server. Hope this helps, Bogdan [EMAIL PROTECTED] wrote: Hi, I have page with PHP and Javascript code and I need to a link or bottun in it to save its content to a plain text file. (I'm using an apache server in a machine running Windows 2003, and I want to be able to use this feature in IE 6 and Mozilla 1.7) I saw some information about how to do that with PHP, but I wasn't able to do it. Can some one help me with that? Thanks in advance, Rafael Magrin - Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Achieving 64-bit integers on 32-bit platforms
On Wed, June 29, 2005 9:02 pm, Dan Goodes said: This 32-bit limitation is haunting me everywhere I turn. Is it possible with PHP (at compile-time if need be) to make it use large (64-bit) integers? I believe that PHP runs fine on 64-bit hardware, and uses 64-bit ints everywhere on that... So, in theory at least, just buying a 64-bit machine would solve your problem... Not that you necessarily *can* run out and buy a 64-bit machine, mind you. I'm asking because I would like to perform operations on large files, and fillesize($filename) is returning an error, even when I use sprintf(%u, filesize($file)) as per the manual for filesize(). I get: Warning: filesize(): Stat failed for FC4-i386-DVD.iso (errno=75 - Value too large for defined data type) Any thoughts/ideas/suggestions? Thanks! At least for THIS particular function, you could use exec(du $filename, ...) and then you'd have a string representation of the size, which you could then display or even manipulate with BC_MATH or that other new-fangled arbitrary precision mathematics PHP Module whose name I forget. This is a much less general solution, but may suffice for now. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Save page as text
On Wed, June 29, 2005 2:22 pm, [EMAIL PROTECTED] said: I have page with PHP and Javascript code and I need to a link or bottun in it to save its content to a plain text file. (I'm using an apache server in a machine running Windows 2003, and I want to be able to use this feature in IE 6 and Mozilla 1.7) I saw some information about how to do that with PHP, but I wasn't able to do it. Can some one help me with that? ?php header(Content-type: application/octet-stream); ? Any browser that does *NOT* do a download with that, is a badly-broken browser indeed. There are a bunch of Microsoft-only types who recommend some other Content-type which just plain DOES NOT WORK on anything but IE. Surprised? Don't be. That's how Microsoft encourages incompatible software to retain market share. There are other headers you can send that some browser will use to choose the name of the file in the popup dialog where the user chooses to safe the download. These headers DO NOT WORK in *all* browsers, only some. If you want to be CERTAIN the download filename is what you want, then make sure your URL looks like a static URL to the filename you want. Specifically, convert a URL like: http://example.com/download.php?filename=whatever.xyz into: http://example.com/download/whatever.xyz You can do this by using .htaccess: Files download ForceType application/x-httpd-php /Files to force Apache to treat download as a PHP script, even though it has no .php in the filename. Within your download script (nee download.php) you can use: $_SERVER['PATHINFO']; to access /whatever.xyz and use *THAT instead of $_GET['filename'] to determine what file to download. I posted an include file some time ago that makes it easy to translate PATHINFO into an array $_PATH, which you treat pretty much like $_GET. The only caveat is that $_GET is a SuperGlobal and I can't make $_PATH be a SuperGlobal from within a PHP script. :-( Search this group for my name and PATHINFO and that script ought to turn up... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I can't cURL
On Wed, June 29, 2005 9:31 am, Jon said: I was able to modify the ebay login example that was provided on http://curl.haxx.se/libcurl/php/examples/ to login to a billing portal that I am trying to access. by doing that I am able to open the home.asp page. What I am wanting is to be able to keep my logon and open billing.asp as if I had clicked on the link. the link on the page is just a standard link A HREF=billing.aspBilling Reports/A/U when I add a third part to the hacked example // 3- Try to get billing page $GetThisURL = ***/billing.asp; $reffer = ***/home.asp; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$GetThisURL); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $reffer); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); I never got the cURL CookieJar stuff to work, personally. That may be problems with file permissions on my jar, but... Anyway, just to know and understand what is going on, I suggest you PRINT OUT the headers of the document you are retrieving. If there are Cookies, use PHP to parse their headers, collect up the Cookies, and send them back. This is also better in that you can catch stupid Cookies such as: Cookies that are clearly tied into their advertising crapola Cookies that are clearly tied into their webstats crapola Cookies that are used to share your surfing habits with others Odds are really good you can *NOT* send back those Cookies and the site will still work, without you giving them information that's really none of their business in the first place. Don't set FOLLOWLOCATION either, as it might be fooling you by skipping through some Location: headers but bypassing some Cookie headers. So then the Cookies are getting ignored because cURL is following the Location: headers too fast. Which is how some browsers behave anyway, so the site would be broken for those browsers if you tested with them... $result= curl_exec ($ch); curl_close ($ch); all I am able to get is the login page again. I don't have any idea what to even try since I have never used cURL before. One thing that I know is that by clicking on billing.asp link the server does some stuff and you end up at billing_histories.asp. Does that mean that I should be looing for some sort of GET or POST operation that I am not seeing? It's more likely some Location: headers coming out. ASP Developers (and ASP itself) tend to bounce users around a LOT through HTTP Location headers. God only knows why. My best theory is Microsoft *wants* to waste HTTP connections to make hardware seem insufficient to make users buy more hardware which means more licen$e$ sold of MS software. This javascript is also on the homepage. Does this somehow affect what I am trying to do? If so is there a way to work around it? SCRIPT LANGUAGE=javascript !-- function respond(n) { frmSpecialDelivery.action = document.all.SubmitPage.value + ?respond=yeswhich= + n + returnto= + document.all.calledfrom.value frmSpecialDelivery.submit(); } function sendit() { frmEmail.action = document.all.SubmitPage.value + ?sendmail=yeswhich= + document.all.id.value + returnto= + document.all.calledfrom.value frmEmail.submit() } function closeit() { window.location = document.all.calledfrom.value } function initialize() { document.location=filedownload.asp?DFID= + returnto= + document.all.calledfrom.value } -- /SCRIPT Possibly, especially that document.location crap. But you don't show any JavaScript where this gets CALLED, so it could be a red herring. You'd have to examing any JavaScript tied to the link you click on to see what it does, and which functions it calls, and if it's some of the above functions, walk through what they do. Keep in mind that you can save THEIR HTML on YOUR computer, and change their JavaScript to have a bunch of alert() statements like: function respond(n){ alert(Called respond with arg: + n); . . . } So you can always eventually puzzle through what their JavaScript is doing. The code on their server is a bit more of a Black Box. You can only figure out what it does by poking at it and seeing what happens. Ah, the joys of hacking through somebody's really crappy login scripts. Does it feel like you're in the jungle with a machete that has dream-like turned into a wet noodle yet? It will, soon. But then you manage to hack your way through, and it feels real good. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs. ColdFusion
On Wed, June 29, 2005 9:24 am, Andrew Scott said: At the end of the day you, the guy around the corner and even me will use what we need to use to get the job done. Don't get me wrong I like php, it has a good support for free stuff, but it's a pain in the butt to configure it into a full blown application without modifications, which some languages have built in. Oddly enough, I prefer PHP because it *HAS* all the features ColdFusion only has if you pay through the nose to Allaire (or whomever owns it this week) or pay through the nose for custom tags to 20 different guys who each have one of the features you need or... In fact, does CF have *any* feature, at any price, that PHP doesn't? I think not. I also *HATE* the muddled-up mess of CF tags, though that is obviously a more subjective opinion. If you like CF and want to use it, more power to you. But you really are wasting your time telling us it's got more features than PHP, which is patently false. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs. ColdFusion
Actually Richard that is not what I am trying to do. This guy actually is after some feedback and that's what I am trying to give him. Pros for PHP: - It is free, and takes more time to learn that coldfusion (debatable yes). It has a huge support from other developers, and is usually more than free. Cons for PHP: - Coldfusion is also free (Blue Dragon) and has just as much support as PHP, although. PHP can not run in a J2EE environment, limiting it to small scall websites and limiting the prospect of expansion or server migration. I could go on, but as I said at the end of the day it's up to the original poster to put forward the pros and cons to both languages. If I was him I would look at this objectively, because it would bite him in the butt if he made the wrong choice and had to spend more money because the application was not researched for its needs and future expansion path correctly. I would not want to be in a position where I chose one or the other without giving all the information of pros and cons, this allows for the powers to be to make the wrong choice and not the person asking about this in the first place. This is the advice that I am trying to put forward, not whether this language is better than that, but more of an open mind to what each can and can't do. Regards Andrew Scott Analyst Programmer CMS Transport Systems Level 2/33 Bank Street South Melbourne, Victoria, 3205 Phone: 03 9699 7988 - Fax: 03 9699 7976 -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, 30 June 2005 5:54 PM To: Andrew Scott Cc: 'Rick Emery'; php-general@lists.php.net Subject: RE: [PHP] PHP vs. ColdFusion If you like CF and want to use it, more power to you. But you really are wasting your time telling us it's got more features than PHP, which is patently false. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array assignment references: strange behavior
Hi! Under PHP 4.3.10, the following simple code behaves as expected: $b[1] and $c are not modified by the final assignment to $a[1]: Code 1: $a[1] = 1; $b[1] = 2; $c = 3; $a = $b; $a[1] = 7; // resulting mappings: // $a[1] ... 7 // $b[2] ... 2 // $c .. 3 However, the following two codes result in changes to $b[1] and $c, the only difference to the previous code being the connection between $b[1] and $c via a reference: Code 2: $a[1] = 1; $b[1] = 2; $c = $b[1]; $a = $b; $a[1] = 7; // resulting mappings: // $a[1] ... 7 // $b[2] ... 7 // $c .. 7 Code 3: $a[1] = 1; $b[1] = $c; $c = 2; $a = $b; $a[1] = 7; // resulting mappings: // $a[1] ... 7 // $b[2] ... 7 // $c .. 7 Is this effect intended? If it is, is it specified somewhere in the PHP manual? Thanks, Nenad Jovanovic -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP vs. ColdFusion
On Tue, June 28, 2005 8:17 pm, Rick Emery said: Quoting Anton Kovalenko [EMAIL PROTECTED]: As to ColdFusion, It seems to me that this technology is dead already. What makes you say this? I had never heard anything like this, but it would certainly be powerful ammunition to present to my bosses. Perhaps some sort of web market penetration analysis... I just searched through Netcraft and whatsit that the PHP site references from http://php.net/usage.php Neither seemed to mention ColdFusion. There are, however, presumably people out there with some kind of opinion backed with some kind of statistical analysis, inherently flawed to some unknowable degree, that may relate to this. YMMV -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP vs. ColdFusion
Richard Lynch wrote: Quoting Anton Kovalenko [EMAIL PROTECTED]: As to ColdFusion, It seems to me that this technology is dead already. What makes you say this? I had never heard anything like this, but it would certainly be powerful ammunition to present to my bosses. Perhaps some sort of web market penetration analysis... Hi all! Unfortunatelly, I cant say that my thoughts of this kind were inspired by some sort of web market analysis. I do work as a web development team manager, act as an webprojects architect and also I'm realy very interested in modern development technologies. So, I do hear a lot of Python, Java, PHP which is becoming more and more serious development tool for both well-educated and experienced programmers and school-boys who just want to create their own guestbook/webchat. And for a couple of last years I haven't heard of ColdFusion much. I have some sort of example here. ozon.ru -- the largest Russian online bookstore (it's not a bookstore now -- it's a supermarket like amazon.com) was the first Russian e-commerse project, which looked seriously in 1997. It was created using ColdFusion. But several months ago (maybe year and a half -- don't remember) it was recreated with MS ASP. I do have some dozens of freinds who work as web-developers. The use Java, ASP.Net, PHP. I know none, who uses ColdFusion in his work, though ColdFusion is a relatevly old technology. So, that's my ugly point -) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Build Tool / CVS management
Hey everyone, wondering if anyone has any suggestions for a build management tool written in php to lay over a cvs repository. We're really looking for something along the lines of anthill -http://www.urbancode.com/projects/anthill/default.jsp but more php focused. Like an anthill-like tool using phing instead of ant. dare i say ... phinghill? Oh and cheaper than anthill, if at all possible. Anyone know if such a tool exists? Or know of any good cvs/build management tools for php? thanks a bunch, -jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Re: PHP vs. ColdFusion
Hello Anton, Thursday, June 30, 2005, 10:05:45 AM, you wrote: AK I do have some dozens of freinds who work as web-developers. The AK use Java, ASP.Net, PHP. I know none, who uses ColdFusion in his AK work, though ColdFusion is a relatevly old technology. So, that's AK my ugly point -) It's a perfectly good point. I don't know a single CF developer either, not any more. The last few I did know migrated to Python some years ago. I guess that's the downside of locked-in proprietary languages (which could be said for ASP, except Macromedia don't really attract the same level of developers as Microsoft do). Personally for me CF has the *perception* of being a very 1990s technology (regardless if it is or not) Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I do not fear computers. I fear the lack of them. - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] PHP vs. ColdFusion
Hello Andrew, Thursday, June 30, 2005, 9:15:22 AM, you wrote: AS Coldfusion is also free (Blue Dragon) and has just as much support AS as PHP, although. PHP can not run in a J2EE environment, limiting AS it to small scall websites and limiting the prospect of expansion AS or server migration. You like to tout CF as being J2EE/Enterprise ready. For this the free version of Blue Dragon is NOT suitable, by the developers own admission. You need the $6000 Enterprise version of CF (and you can add on a few more thousand $ for extended support). This is before you've bought any of the extra components you need to finish your application. 1) Blue Dragon is also not just a free version of CF it would appear, even on the developers web site they describe the free version as Functionality is robust and useful for most basic CFML applications. - it's the words most basic that concern me here. 2) It doesn't support the newer CF 7 features. 3) The free version does not deploy into J2EE at all. 4) It only runs on Windows, OS X or Linux (sorry, but lots of very big hosting companies prefer the stability of FreeBSD, Solaris, etc). If you want Solaris support it costs $2499 per CPU. If you want FreeBSD support, you're stuffed. 5) It only supports ODBC database connections (via JDBC), so unlike PHP you won't be connecting to Oracle, MS SQL, SQLite, etc. MySQL is supported, but not built-in. If you want to do CF seriously, you need to invest thousands and that's before you've paid your programmers - this is the bottom line. Perhaps that is why even the Blue Dragon developers themselves claim its biggest advantage is: You've invested heavily in CFML.. so have we. Protect your investments. - and how do you protect them? by deploying Blue Dragon so you can then interface directly with .NET applications rather than migrate totally to them. This doesn't strike me as being the approach of a growing, competitive well supported language. It sounds more like shit, people have woken up to the massive cost of using CF, how can we slow the drop-out rate? if that is Blue Dragons primary selling angle, it says a *lot* about the state of serious CF development. When it comes to investing it think long-term. Zend are aggressively attacking the enterprise market and we will see more and more movement in this direction, to the point where I am quite sure their objective is to make PHP itself enterprise capable *regardless* of J2EE. With the rate things change around here, we won't have to wait too long. If you don't actually need to build an enterprise scale site (and let's face it, that covers most of us) then you're good to go with PHP *right now* without actually spending a dime. Take that $6000 CF budget, invest it into training for your entire team and build your own framework, with the knowledge that no matter what happens, your work is safe. Anyway, time to get back to my project for BMW - just one of those small scall websites (sic) things I guess? Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I do not fear computers. I fear the lack of them. - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] PHP vs. ColdFusion
Richard, And your point of before you pay your programmer is what one of my other points was. CF is very rapid development, and you might say the same about PHP. The point is that these are all the things you need to take into consideration, the cost that it would take to develop and maintain in either language, as well as cost involved in the need of the application having to be a true enterprise solution. I am not here to bag php, I am here to make some points about the cost of the application in the overall scenario. Would you develop in a language that you know could not deliver an enterprise solution if in 6 months that's what you really need, and how would you look if you recommended a language because it was free, but in time had to spend more again to make it fully scalable to an enterprise level if it needed it. My point is that both languages have their merits, both have their advantages and disadvantages, but what about the cost is it really worth not researching something properly before jumping into bed with what you think might work? I know what I would do if someone who worked for me, came to me an recommended a language and had not done the research into all possible paths, that person would be very answerable to why we had to spend more down the track. Now that you have bagged CF, lets look at PHP. The amount of work that is needed to implement a reporting solution is hard work and takes a lot of code, the amount of work needed to generate a PDF or even a flash paper is hard work in php, or what about RIA development (Rich Internet Application's) that con leverage of flash to make presentation look good with minimal work. This functionality can and does save more work than you could ever possibly achieve in php, RAD development because it creates less work to achieve something that would take a lot of work and time in php. Don't get me started on the integration of crystal reports and php, I have had to do it and it was not easy compared to the same job in coldfusion. A good developer will know when to use the right tools for the job. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] PHP vs. ColdFusion
Hi Concerning php and J2EE, zend platform is providing a solid bridge between both environment. This as been specially build for developping big system (banking, tracking, etc). regards david Le Thu, 30 Jun 2005 13:06:22 +0200, Richard Davey [EMAIL PROTECTED] a écrit: Hello Andrew, Thursday, June 30, 2005, 9:15:22 AM, you wrote: AS Coldfusion is also free (Blue Dragon) and has just as much support AS as PHP, although. PHP can not run in a J2EE environment, limiting AS it to small scall websites and limiting the prospect of expansion AS or server migration. You like to tout CF as being J2EE/Enterprise ready. For this the free version of Blue Dragon is NOT suitable, by the developers own admission. You need the $6000 Enterprise version of CF (and you can add on a few more thousand $ for extended support). This is before you've bought any of the extra components you need to finish your application. 1) Blue Dragon is also not just a free version of CF it would appear, even on the developers web site they describe the free version as Functionality is robust and useful for most basic CFML applications. - it's the words most basic that concern me here. 2) It doesn't support the newer CF 7 features. 3) The free version does not deploy into J2EE at all. 4) It only runs on Windows, OS X or Linux (sorry, but lots of very big hosting companies prefer the stability of FreeBSD, Solaris, etc). If you want Solaris support it costs $2499 per CPU. If you want FreeBSD support, you're stuffed. 5) It only supports ODBC database connections (via JDBC), so unlike PHP you won't be connecting to Oracle, MS SQL, SQLite, etc. MySQL is supported, but not built-in. If you want to do CF seriously, you need to invest thousands and that's before you've paid your programmers - this is the bottom line. Perhaps that is why even the Blue Dragon developers themselves claim its biggest advantage is: You've invested heavily in CFML.. so have we. Protect your investments. - and how do you protect them? by deploying Blue Dragon so you can then interface directly with .NET applications rather than migrate totally to them. This doesn't strike me as being the approach of a growing, competitive well supported language. It sounds more like shit, people have woken up to the massive cost of using CF, how can we slow the drop-out rate? if that is Blue Dragons primary selling angle, it says a *lot* about the state of serious CF development. When it comes to investing it think long-term. Zend are aggressively attacking the enterprise market and we will see more and more movement in this direction, to the point where I am quite sure their objective is to make PHP itself enterprise capable *regardless* of J2EE. With the rate things change around here, we won't have to wait too long. If you don't actually need to build an enterprise scale site (and let's face it, that covers most of us) then you're good to go with PHP *right now* without actually spending a dime. Take that $6000 CF budget, invest it into training for your entire team and build your own framework, with the knowledge that no matter what happens, your work is safe. Anyway, time to get back to my project for BMW - just one of those small scall websites (sic) things I guess? Best regards, Richard Davey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] PHP vs. ColdFusion
[snip] Would you develop in a language that you know could not deliver an enterprise solution if in 6 months that's what you really need, and how would you look if you recommended a language because it was free, but in time had to spend more again to make it fully scalable to an enterprise level if it needed it. [/snip] I know that I am not the only one, but we have been developing enterprise level (and very scalable) applications in PHP for almost 4 years. If you are asserting that PHP is not enterprise ready here you would be way off base. Here is another side which seems to have been ignored. I can bring C or C++ or JAVA developers in and have them up to speed in PHP very quickly. CF requires an additional learning curve (I used it way back in 1997 when it was in its earlier iterations) because of the tags, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ouput HTML w/PHP
And now for something completely different... I have a question that has been nagging at me. I've searched the archives, FAQs, and web sites, but haven't found an answer. I have two ways that I've output HTML with PHP; one is to write the HTML, using the PHP tags to execute code when necessary. The other is to store the entire HTML output file in a string variable with concatenation and call the print (or echo) function at the bottom to output the page. Are there advantages one way or the other? This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? Thanks in advance, Rick -- Rick Emery When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for there you have been, and there you will always long to return -- Leonardo Da Vinci -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
On 6/30/05, Andrew Scott [EMAIL PROTECTED] wrote: Cons for PHP: - Coldfusion is also free (Blue Dragon) and has just as much support as PHP, although. PHP can not run in a J2EE environment, limiting it to small scall websites and limiting the prospect of expansion or server migration. I'm wondering if you could expand on this some. How does not running in a J2EE environment limit PHPs ability to expand? In my opinion this is not the case, but I'm always open to being convinced otherwise. I'm also curious what you mean by small scale. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
Andrew Scott wrote: snip CF is very rapid development, and you might say the same about PHP. The point is that these are all the things you need to take into consideration, the cost that it would take to develop and maintain in either language, as well as cost involved in the need of the application having to be a true enterprise solution. I am not here to bag php, I am here to make some points about the cost of the application in the overall scenario. Would you develop in a language that you know could not deliver an enterprise solution if in 6 months that's what you really need, and how would you look if you recommended a language because it was free, but in time had to spend more again to make it fully scalable to an enterprise level if it needed it. My point is that both languages have their merits, both have their advantages and disadvantages, but what about the cost is it really worth not researching something properly before jumping into bed with what you think might work? Why do you believe PHP is not capable of being the basis of a true enterprise solution? You've said that several times now without backing it up and I'd like to hear your reasons so I'm better informed next time I have to make this kind of decision. I know what I would do if someone who worked for me, came to me an recommended a language and had not done the research into all possible paths, that person would be very answerable to why we had to spend more down the track. In my experience if you develop a PHP system with a view to scalability (as you would no doubt need to with CF also) the most you would need to spend to allow it to scale up to an enterprise solution is to purchase something like the Zend Platform and more hardware which from what I know is likely to be cheaper than the equivalent requirements for CF. Now that you have bagged CF, lets look at PHP. The amount of work that is needed to implement a reporting solution is hard work and takes a lot of code, the amount of work needed to generate a PDF or even a flash paper is hard work in php, or what about RIA development (Rich Internet Application's) that con leverage of flash to make presentation look good with minimal work. This functionality can and does save more work than you could ever possibly achieve in php, RAD development because it creates less work to achieve something that would take a lot of work and time in php. Don't get me started on the integration of crystal reports and php, I have had to do it and it was not easy compared to the same job in coldfusion. A good developer will know when to use the right tools for the job. Again, for future reference please state specifically what functionality CF provides with regards to integration with Flash and PDF generation that makes it so much better than PHP for these tasks. Is this functionality built in to CF or are they addons? If they are addons what does it cost to add them on? For my 2p-worth I have to say that I am yet to come across a requirement that PHP cannot fulfil either through built-in functionality or freely-available addons. However, if I'm lacking knowledge of the killer feature CF has to offer please enlighten me. Incidentally, if I have a requirement for a CPU-intensive function that does not already exist in CF, what options are there for adding it myself? Can I write code in C/C++ that integrates tightly with the CF engine so I can optimize the crap out of it? Thanks in advance for your responses. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ouput HTML w/PHP
On Thursday 30 June 2005 13:50, Rick Emery typed: the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? When I do this, I browse each page, doing File Save. Then using the form upload of the W3C validator, validate each page. Since I use templates, fixing each template tends to fix lots of other pages. -- My mind not only wanders, it sometimes leaves completely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shell expansion (globbing) from inside php cli script
On Wed, 29 Jun 2005, Bob Winter wrote: Brian, The script works for me, I should have included the screen input/output, which now follows: Hmmm, this simply does not work for me. Maybe something with my version of php or ssh.. I'm at a loss.. $ php -v PHP 4.3.5 (cli) (built: Apr 30 2004 14:27:11) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend Extension Manager v1.0.6, Copyright (c) 2003-2004, by Zend Technologies with Zend Optimizer v2.5.7, Copyright (c) 1998-2004, by Zend Technologies with bDISABLED/b Zend Download Server v1.0.2, Copyright (c) 2003-2004, by Zend Technologies with bDISABLED/b Zend Performance Suite v4.1.0-platform, Copyright (c) 1999-2004, by The Accelerator presently supports only Apache, ISAPI and FastCGI SAPIs with Zend Debugger v3.5.2a, Copyright (c) 1999-2004, by Zend Technologies with sqlite wrapper v1.0, Copyright (c) 2004, by Zend Technologies with java wrapper v1.0, Copyright (c) 2004, by Zend Technologies Executing: program /usr/local/bin/ssh host xxx, user xxx, command scp -v -f /www/files/services/include/niche/paa/include/niche/atc_syc/{q,w,e,r} OpenSSH_3.8p1, SSH protocols 1.5/2.0, OpenSSL 0.9.7d 17 Mar 2004 debug1: Reading configuration data /usr/local/etc/ssh_config debug1: Connecting to stagingcws.traderonline.com [10.222.132.174] port 22. debug1: Connection established. debug1: identity file /home/bonini/.ssh/identity type -1 debug1: identity file /home/bonini/.ssh/id_rsa type -1 debug1: identity file /home/bonini/.ssh/id_dsa type 2 debug1: Remote protocol version 1.99, remote software version OpenSSH_3.5p1 debug1: match: OpenSSH_3.5p1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_3.8p1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server-client aes128-cbc hmac-md5 none debug1: kex: client-server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(102410248192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'xxx' is known and matches the RSA host key. debug1: Found key in /home/bonini/.ssh/known_hosts:10 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Trying private key: /home/bonini/.ssh/identity debug1: Trying private key: /home/bonini/.ssh/id_rsa debug1: Offering public key: /home/bonini/.ssh/id_dsa debug1: Server accepts key: pkalg ssh-dss blen 435 debug1: PEM_read_PrivateKey failed debug1: read PEM private key done: type unknown Enter passphrase for key '/home/bonini/.ssh/id_dsa': debug1: read PEM private key done: type DSA debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending command: scp -v -f /www/files/services/include/niche/paa/include/niche/atc_syc/{q,w,e,r} debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 scp: /www/files/services/include/niche/paa/include/niche/atc_syc/{q,w,e,r}: No such file or directory debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.2 seconds debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0 debug1: Exit status 1 string: scp -v [EMAIL PROTECTED]:/www/files/services/include/niche/paa/include/niche/atc_syc/{q,w,e,r} /www/files/services/include/niche/paa/include/niche/atc_syc/tmp/. status: 1 Array ( ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ouput HTML w/PHP
Hi, It seems to me you are going the wrong way with embedded PHP; try separating logic from view, tons of mvc frameworks out there and templating engines. Try firefox with web developer extension - Validate Local HTML. Catalin Rick Emery wrote: And now for something completely different... I have a question that has been nagging at me. I've searched the archives, FAQs, and web sites, but haven't found an answer. I have two ways that I've output HTML with PHP; one is to write the HTML, using the PHP tags to execute code when necessary. The other is to store the entire HTML output file in a string variable with concatenation and call the print (or echo) function at the bottom to output the page. Are there advantages one way or the other? This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? Thanks in advance, Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] PHP vs. ColdFusion
* Andrew Scott [EMAIL PROTECTED]: CF is very rapid development, and you might say the same about PHP. The point is that these are all the things you need to take into consideration, the cost that it would take to develop and maintain in either language, as well as cost involved in the need of the application having to be a true enterprise solution. I am not here to bag php, I am here to make some points about the cost of the application in the overall scenario. Would you develop in a language that you know could not deliver an enterprise solution if in 6 months that's what you really need, and how would you look if you recommended a language because it was free, but in time had to spend more again to make it fully scalable to an enterprise level if it needed it. You've insinuated several times that PHP is not 'scalable to an enterprise level'. Could you perhaps explain what you mean by this? One informal definition for 'enterprise framework' I've read recently is an enterprise framework allows the end-user to drop in only the business logic to make it work; they do not need to add anymore programming to the framework (http://benramsey.com/2005/05/09/what-is-an-enterprise-framework/) Now, I've seen a number of PHP frameworks where this is the case; you drop in a config file of some sort, point your application to it, and voila! Solution delivered! That doesn't address scalability, however. So, let's look at that. I'm not sure how CF scales, not having been in a CF shop. However, I know what I can do to scale PHP: * Use code optimizers/bytecode caches (zend, apc, eAccelerator) * Build an LVS-HA cluster for a web farm (i.e., increase the number of machines able to serve data and pages) * Focus on code optimization (i.e., make my code as efficient as possible) (As an aside, the beauty of a cluster is that you can add or subtract machines without the public noticing; the site remains up. Additionally, since all the director does is pass requests to the nodes, and possibly relay the responses back to the requestor, you can have machines of just about any configuration running on the backend -- Linux, FreeBSD, Windows, etc. -- so long as they speak the HTTP protocol.) Could you please share why you feel PHP isn't enterprise ready, or why CF is more enterprise ready? Other than the java integration; others have pointed out that the Zend platform addresses that issue. -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP vs. ColdFusion
As for statistics, there are so many large intranet sites in use that never see the light of day using CF, PHP, ASP.NET that numbers would never be very acurate. If it interests any of you, you could check out www.forta.com/blog/ and search for his listings of major corporate entities using currently using CF. I'm not pointing this out to say that there are more major CF sites than PHP, that is not my point... my point is that saying As to ColdFusion, It seems to me that this technology is dead already is probably coming from someone who wouldn't know. A CF (only) developer wouldn't know the PHP usage and community as well as the PHP developer and vice versa. We are more familiar with what we use. Common sense. And of course, In reading so many this VS that posts, I would say people are biased to their own preferrence, quite naturally PHP and CF have their own pros and cons. The only way to truely evaluate them is to use them both. That's my 2 cents. Yves On 6/30/05, Richard Lynch [EMAIL PROTECTED] wrote: On Tue, June 28, 2005 8:17 pm, Rick Emery said: Quoting Anton Kovalenko [EMAIL PROTECTED]: As to ColdFusion, It seems to me that this technology is dead already. What makes you say this? I had never heard anything like this, but it would certainly be powerful ammunition to present to my bosses. Perhaps some sort of web market penetration analysis... I just searched through Netcraft and whatsit that the PHP site references from http://php.net/usage.php Neither seemed to mention ColdFusion. There are, however, presumably people out there with some kind of opinion backed with some kind of statistical analysis, inherently flawed to some unknowable degree, that may relate to this. YMMV -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Yves Arsenault This year, or this month, or, more likely, this very day, we have failed to practise ourselves the kind of behaviour we expect from other people. C.S. Lewis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shell expansion (globbing) from inside php cli script
Brian, Is /www/files/services/ the correct relative path?? You could try using the absolute path to see if it fixes the problem. Also, and maybe more significant, I use tcsh . . . if you use bash this could be the conflict. I see that the echo of the $cmd string from PHP is missing the '\}' that is in my test. -- Bob Brian V Bonini wrote: Hmmm, this simply does not work for me. Maybe something with my version of php or ssh.. I'm at a loss.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs. ColdFusion
OK. What is J2EE, if you know the answer to that then you will know that php doesn't have the ability to run as multiple instances. Lets take security for example, php is known to not have an installer because of security correct me if I am wrong on this assumption. I am only going by what I hear here. So with that in mind let's talk about shared hosting, can you run php and know that your website is secured in a shared hosting environment. That's what J2EE is all about, being able to run multiple instance of an application and CF can do this extremely well and be extremely secured. -Original Message- From: Brad Pauly [mailto:[EMAIL PROTECTED] Sent: Thursday, 30 June 2005 10:54 PM To: php-general@lists.php.net Subject: Re: [PHP] PHP vs. ColdFusion On 6/30/05, Andrew Scott [EMAIL PROTECTED] wrote: Cons for PHP: - Coldfusion is also free (Blue Dragon) and has just as much support as PHP, although. PHP can not run in a J2EE environment, limiting it to small scall websites and limiting the prospect of expansion or server migration. I'm wondering if you could expand on this some. How does not running in a J2EE environment limit PHPs ability to expand? In my opinion this is not the case, but I'm always open to being convinced otherwise. I'm also curious what you mean by small scale. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -Original Message- From: Brad Pauly [mailto:[EMAIL PROTECTED] Sent: Thursday, 30 June 2005 10:54 PM To: php-general@lists.php.net Subject: Re: [PHP] PHP vs. ColdFusion On 6/30/05, Andrew Scott [EMAIL PROTECTED] wrote: Cons for PHP: - Coldfusion is also free (Blue Dragon) and has just as much support as PHP, although. PHP can not run in a J2EE environment, limiting it to small scall websites and limiting the prospect of expansion or server migration. I'm wondering if you could expand on this some. How does not running in a J2EE environment limit PHPs ability to expand? In my opinion this is not the case, but I'm always open to being convinced otherwise. I'm also curious what you mean by small scale. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs. ColdFusion
[snip] Cons for PHP: - Coldfusion is also free (Blue Dragon) and has just as much support as PHP, although. PHP can not run in a J2EE environment, limiting it to small scall websites and limiting the prospect of expansion or server migration. I'm wondering if you could expand on this some. How does not running in a J2EE environment limit PHPs ability to expand? In my opinion this is not the case, but I'm always open to being convinced otherwise. I'm also curious what you mean by small scale. [/snip] It occurs to me that some may think that J2EE is required for enterprise level applications, which is not the necessarily the case. It is a matter of splitting hairs. But if you want to use the two together there are several articles and how-to's on the web. I think that what is going on here is that, depending on who you talk to, enterprise level means different things. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP vs. ColdFusion
[snip] What is J2EE, if you know the answer to that then you will know that php doesn't have the ability to run as multiple instances. Lets take security for example, php is known to not have an installer because of security correct me if I am wrong on this assumption. I am only going by what I hear here. [/snip] What do you mean multiple instances? And how does that apply to EE? I do not think that the reason PHP doesn't have an installer has anything to do with security. [snip] So with that in mind let's talk about shared hosting, can you run php and know that your website is secured in a shared hosting environment. That's what J2EE is all about, being able to run multiple instance of an application and CF can do this extremely well and be extremely secured. [/snip] Any site developed properly in PHP will run in a shared hosting environment securely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
Andrew Scott wrote: OK. What is J2EE, if you know the answer to that then you will know that php doesn't have the ability to run as multiple instances. Lets take security for example, php is known to not have an installer because of security correct me if I am wrong on this assumption. I am only going by what I hear here. First of all PHP does have installation utilities. There's one for Win32, there's the port in FreeBSD and I'm sure there are others (RPMs and the like). Multiple instances in what sense? If you mean multiple servers running the same application this is very possible with PHP. If that's not what you mean please elaborate. So with that in mind let's talk about shared hosting, can you run php and know that your website is secured in a shared hosting environment. That's what J2EE is all about, being able to run multiple instance of an application and CF can do this extremely well and be extremely secured. What does J2EE provide that makes it any more secure in a shared hosting environment than PHP? Again you have made a statement without explaining the reasons behind it. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ouput HTML w/PHP
Some time ago I started working on something realted to this. I was very unsatisfied with managing HTML as just another string, since HTML does have a structure, which we should be able to check before releasing it, if possible, by the same IDE we program with. Perhaps you will want to check it: http://www.satyam.com.ar/StructuredTags.htm Satyam Rick Emery [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] And now for something completely different... I have a question that has been nagging at me. I've searched the archives, FAQs, and web sites, but haven't found an answer. I have two ways that I've output HTML with PHP; one is to write the HTML, using the PHP tags to execute code when necessary. The other is to store the entire HTML output file in a string variable with concatenation and call the print (or echo) function at the bottom to output the page. Are there advantages one way or the other? This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? Thanks in advance, Rick -- Rick Emery When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for there you have been, and there you will always long to return -- Leonardo Da Vinci -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] PHP vs. ColdFusion
On 6/30/05, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: That doesn't address scalability, however. So, let's look at that. I'm not sure how CF scales, not having been in a CF shop. However, I know what I can do to scale PHP: * Use code optimizers/bytecode caches (zend, apc, eAccelerator) * Build an LVS-HA cluster for a web farm (i.e., increase the number of machines able to serve data and pages) * Focus on code optimization (i.e., make my code as efficient as possible) These also apply to CF. However, the built-in caching offered by CF (and by that I mean the ability to store something in memory, like the application scope) can actually be a draw back when going to a multi-server environment. For example, say you have a query that you would like to keep in memory for faster access. You can put this in one of the shared scopes and you are all set. It's very easy, but when you add another server, you now have that query duplicated on both servers. Suppose you have many queries, or other objects that you would like to keep in memory. Using this technique, they are all duplicated on all of the servers. I don't think that is a very efficient use of resources. Of course it doesn't have to be done that way. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
Andrew Scott wrote: OK. What is J2EE, if you know the answer to that then you will know that php doesn't have the ability to run as multiple instances. Lets take security for example, php is known to not have an installer because of security correct me if I am wrong on this assumption. I am only going by what I hear here. So with that in mind let's talk about shared hosting, can you run php and know that your website is secured in a shared hosting environment. That's what J2EE is all about, being able to run multiple instance of an application and CF can do this extremely well and be extremely secured. I've stayed away from this because I really don't know enough about Cold Fusion to compare them. With your above statements, and others you have made in this thread, it is clear you do not know enough about PHP (or Java for that matter) to compare the two. Why don't you do all of us poor little PHP developers a favor, and go beat your chest about CF somewhere else. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
On 6/30/05, Andrew Scott [EMAIL PROTECTED] wrote: OK. What is J2EE, if you know the answer to that then you will know that php doesn't have the ability to run as multiple instances. Lets take security for example, php is known to not have an installer because of security correct me if I am wrong on this assumption. I am only going by what I hear here. So with that in mind let's talk about shared hosting, can you run php and know that your website is secured in a shared hosting environment. That's what J2EE is all about, being able to run multiple instance of an application and CF can do this extremely well and be extremely secured. If by shared hosting you mean multiple websites on one physical machine, well, it really depends on how things are set up. It is possible to run multiple instances of Linux on one computer and have each site running in a different one. So assuming that both CF and PHP can be deployed in a secure environment I would say that it's very easy to write insecure applications in both, shared hosting or otherwise. Neither is necessarily more secure than the other. I think most languages and platforms are going to have thier own set of security concerns. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Weird Image Problem
I'm bin2hex'ing images from an upload script and inserting into a mysql blob field. The php script that re-packs the hex data back to binary, does the createimagefromstring() and streams the image to the browser is generating a corrupted image... i.e. The image looks fine until part-way down... then... no more image; just a gray background where the rest of the image should be. Seems to happen on image any larger than 30 or so kilobytes. Anybody working the the php image libraries seen this before? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cUrl and proxies
Hello This code gives me a 407 Proxy Authentication Required message. Can anyone see what is missing? The username and password are definitely correct, as are the proxy IP and port. Win2k. php 5.0.4 $ch=curl_init(); curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1'); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch,CURLOPT_PROXY,'10.0.0.8:8080'); curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123'); $ret = curl_exec($ch); Thanks in advance Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ouput HTML w/PHP
On Thu, 2005-06-30 at 08:50 -0400, Rick Emery wrote: And now for something completely different... I have a question that has been nagging at me. I've searched the archives, FAQs, and web sites, but haven't found an answer. I have two ways that I've output HTML with PHP; one is to write the HTML, using the PHP tags to execute code when necessary. The other is to store the entire HTML output file in a string variable with concatenation and call the print (or echo) function at the bottom to output the page. Are there advantages one way or the other? This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? Thanks in advance, Rick -- Rick Emery When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for there you have been, and there you will always long to return -- Leonardo Da Vinci What I usually do is to use smarty. There is a lite version that does just fine, and has a very small memory print. Usually, my last lines of code are something like: ... $RenderResult = $Template-fetch('template.tpl'); /* Do something if I need to */ echo $RenderResult; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cUrl and proxies
UPDATE: I think it is a bug in cURL, according to this link (I am using an ISA proxy). https://sourceforge.net/tracker/?func=detailatid=100976aid=1188280group_i d=976 So all I need to do is install the latest version of cURL then. I am really struggling with this - I don't have a good understanding of how PHP and cURL interact. I already have the necessary dlls on my machine : php_curl.dll libeay.dll ssleay.dll But what can I download from http://curl.haxx.se/download.html I don't see any of those files there, and the windows package includes only curl.exe - where does that fit in? The readme files in the package I did download don't really help either: http://curl.haxx.se/dlwiz/?type=*os=Win32flav=-ver=2000%2FXP Please help if you can Mark Mark Rees [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello This code gives me a 407 Proxy Authentication Required message. Can anyone see what is missing? The username and password are definitely correct, as are the proxy IP and port. Win2k. php 5.0.4 $ch=curl_init(); curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1'); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch,CURLOPT_PROXY,'10.0.0.8:8080'); curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123'); $ret = curl_exec($ch); Thanks in advance Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ouput HTML w/PHP
Rick Emery wrote: This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? If you run FireFox you can download the entirely invaluable Web Developer plugin, one feature of which (under the Tools button) is Validate Local HTML. This automates a post of your page to the W3C Validator, thus not requiring a URL visible to the ineternet. The only caveat being, you do still need internet access from your development machine for the post to be possible. This is a great way for developers to validate the output of their code while it still resides on their local machines, prior to actually uploading the code to a public (and therefore visible) site. Regards, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Missing characters when processing scripts
I have a semi -random problem that characters in the php script are dropped. A very noticible instance is in a statement like: $query = SELECT junk FROM table; $result = mysql_query( $query, $handle) or die (mysql_error()); I get an error message from the die function like: Error SELECT jnk FROM table... As you can see the error message has the SELECT statement with one character dropped (this is much more rare than single quotes or semicolons being dropped - but it definitely shows that the error isn't in the code). If I wait a minute and do a browser refresh, the error goes away and either there is another character dropped or it works. This problem was noticed in January a month after we upgraded PHP on our server to 4.3.10. Thanks in advance Charlene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] postgres - mysql last_inserted_id
Hello, I have an application in production, build on mysql database. I decided to migrate to postgres because of numerous reasons. Can you guys please guide me into the right direction? the main problem is the missing autoincrement of pgsql and getting the last record from the tabel, for linking to another tabel. How do you deal with that? also, can you please recommend me some good manual, explanation or book to help me with this problem. Because the application uses around 250 tables in mysql and I would like to make it righ t the first time when migrating to pgsql.. I was thinking about using the pear db wrapper class, but Regards, Uroš KRISTAN
Re: [PHP] postgres - mysql last_inserted_id
On Thu, June 30, 2005 11:55 am, Uro¹ Kristan said: I have an application in production, build on mysql database. I decided to migrate to postgres because of numerous reasons. Can you guys please guide me into the right direction? the main problem is the missing autoincrement of pgsql and getting the I always do this: create sequence TABLENAME_id; create TABLENAME ( TABLENAME_id int4 unsigned default(nextval('TABLENAME_id')) ) create unique index TABLENAME_id_index on TABLENAME(TABLENAME_id); You can use unique not null primary key in the column definition, but then the name of the index is something I can't remember. last record from the tabel, for linking to another tabel. You have to use http://php.net/pg_last_oid to get the PostgreSQL internal Object ID (OID) -- You can then use the ubiquitous oid column. $query = insert ...; pg_exec($connection, $query); $oid = pg_last_oid($connection); $query = select TABLENAME_id from TABLENAME where oid = $oid; $id = pg_exec($connection, $query); $id = pg_result($id, 0, 0); Of course, the above code has no error-checking or anything like that, so it gets about twice as long as that in Real Life. It is possible to configure PostgreSQL to *not* have the oid stored in each record, if you are really really really cramped for disk space, but you have to *KNOW* in advance that you won't need to use the OID as above, which is pretty rare... I daresay that you'd have to be in a REALLY high-performance and high-tolerance for error application to be able to get away with that. If somebody made such an almost-for-sure unwise decision to not have OID fields in the tables, you are SOL. How do you deal with that? also, can you please recommend me some good manual, explanation or book to help me with this problem. Because the application uses around 250 tables in mysql and I would like to make it righ t the first time when migrating to pgsql.. I was thinking about using the pear db wrapper class, but Regards, Uro¹ KRISTAN -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Missing characters when processing scripts
On Thu, June 30, 2005 11:04 am, Charlene said: I have a semi -random problem that characters in the php script are dropped. A very noticible instance is in a statement like: $query = SELECT junk FROM table; $result = mysql_query( $query, $handle) or die (mysql_error()); I get an error message from the die function like: Error SELECT jnk FROM table... As you can see the error message has the SELECT statement with one character dropped (this is much more rare than single quotes or semicolons being dropped - but it definitely shows that the error isn't in the code). If I wait a minute and do a browser refresh, the error goes away and either there is another character dropped or it works. This problem was noticed in January a month after we upgraded PHP on our server to 4.3.10. Another recent poster was having random characters converted to non-ASCII characters. SELECT j*nk FROM table where * is really a u with an umlaut, but I dunno how to get that out of my keyboard... It's possible that you have the same thing, but your software is not displaying non-ASCII characters. Even if it's not, I guess it could be related... Anyway, dig into his thread from a couple weeks back in case that got resolved... I'd also check http://bugs.php.net And maybe try going to 4.3.11 instead of .10, unless you have a very specific reason for not going there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: cUrl and proxies
On Thu, June 30, 2005 9:27 am, Mark Rees said: UPDATE: I think it is a bug in cURL, according to this link (I am using an ISA proxy). https://sourceforge.net/tracker/?func=detailatid=100976aid=1188280group_i d=976 So all I need to do is install the latest version of cURL then. I am really struggling with this - I don't have a good understanding of how PHP and cURL interact. I already have the necessary dlls on my machine : How PHP and cURL (and Apache) interact: PHP is a Module of Apache (or Service of IIS, or [shudder] runs as CGI) php_curl.dll is a Module of PHP So PHP is a tick on the back of the dog to Apache, and php_curl is a flea on the tick. :-v Now, in most cases, like MySQL, you also need MySQL installed on the machine. So, possibly, you will need that new curl.exe ALONG WITH a *new* php_curl.dll DO NOT ATTEMPT TO MIX-N-MATCH THE DIFFERENT VERSIONS OF DLL AND EXE!!! While it might work for awhile, that's only sheer coincidence that the particular functions in curl/php you are using didn't change between those two versions. As soon as you try to use a function that *DID* change, Whammo! the thing will crash and burn. You'll end up very cranky, possibly with a problem caused by a bad decision months and months ago, and you won't have any idea of the cause and effect relationship, cuz it worked fine for so long. I'm not sure you even need the curl.exe -- I suspect that all the functionality of curl.exe gets bundled up into php_curl.dll Now the bad news: You would need to re-compile php_curl, using your current version of PHP source, and the version of curl source you want, on a Windows box, to get the php_curl.dll you need. That requires A) having a copy of MSVC++ (Microsoft Visual C++) compiler/IDE and B) knowing how to work MSVC *very* well, to set up your environment the way it needs to be to compile PHP. A) is easy to solve if you have money. B) is not so easy... There may be a How To for PHP and MSVC out there, but it sure didn't exist back when I tried this, quite some years ago. I failed miserably. You may want to take your plight to the PHP-Windows mailing list. There are probably more people there who are actually capable of running MSVC and getting PHP to compile. They might just do it for you. They may even have the particular version of php_curl.dll you need available somewhere. php_curl.dll libeay.dll ssleay.dll But what can I download from http://curl.haxx.se/download.html I don't see any of those files there, and the windows package includes only curl.exe - where does that fit in? The readme files in the package I did download don't really help either: http://curl.haxx.se/dlwiz/?type=*os=Win32flav=-ver=2000%2FXP Please help if you can Mark Mark Rees [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello This code gives me a 407 Proxy Authentication Required message. Can anyone see what is missing? The username and password are definitely correct, as are the proxy IP and port. Win2k. php 5.0.4 $ch=curl_init(); curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1'); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch,CURLOPT_PROXY,'10.0.0.8:8080'); curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123'); $ret = curl_exec($ch); Thanks in advance Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird Image Problem
On Wed, June 29, 2005 3:30 pm, Shane Little said: I'm bin2hex'ing images from an upload script and inserting into a mysql blob field. The php script that re-packs the hex data back to binary, does the createimagefromstring() and streams the image to the browser is generating a corrupted image... i.e. The image looks fine until part-way down... then... no more image; just a gray background where the rest of the image should be. Seems to happen on image any larger than 30 or so kilobytes. Anybody working the the php image libraries seen this before? Storing images inside MySQL is almost always a Bad Idea in the first place... I'll assume you know that, and have good reason to not use the super-fast, custom-optimized large-data software specifically designed to handle your images. * First, check that MySQL blob fields are not limited to 32K somehow. I suspect that they are. Next, one has to wonder why use bin2hex? Yes, it should generate only 0-9a-f characters, which are all valid for MySQL, but surely that is not the best way to do this... I don't store images in MySQL, so don't KNOW what is the best way, but I'm putting money down right now that bin2hex ain't the best way. * the super-fast, custom-optimized large-data software specifically designed to handle your images is known as... The File System. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird Image Problem
Richard Lynch wrote: On Wed, June 29, 2005 3:30 pm, Shane Little said: I'm bin2hex'ing images from an upload script and inserting into a mysql blob field. The php script that re-packs the hex data back to binary, does the createimagefromstring() and streams the image to the browser is generating a corrupted image... i.e. The image looks fine until part-way down... then... no more image; just a gray background where the rest of the image should be. Seems to happen on image any larger than 30 or so kilobytes. Anybody working the the php image libraries seen this before? Storing images inside MySQL is almost always a Bad Idea in the first place... I'll assume you know that, and have good reason to not use the super-fast, custom-optimized large-data software specifically designed to handle your images. * First, check that MySQL blob fields are not limited to 32K somehow. I suspect that they are. Next, one has to wonder why use bin2hex? Yes, it should generate only 0-9a-f characters, which are all valid for MySQL, but surely that is not the best way to do this... I don't store images in MySQL, so don't KNOW what is the best way, but I'm putting money down right now that bin2hex ain't the best way. * the super-fast, custom-optimized large-data software specifically designed to handle your images is known as... The File System. :-) MySQL blobs are actually limited to 64K. I think a MEDIUMBLOB holds about 16 MB if you're dead-set on storing the image in the database. You might want to check that your max_allowed_packets size is large enough. You can find that by querying SHOW VARIABLES LIKE 'max_allowed_packet'; I just double-checked the manual. It does say that this needs to be set to the largest blob. kgt
Re: [PHP] postgres - mysql last_inserted_id
On Friday 01 July 2005 02:55, Uroš Kristan wrote: I have an application in production, build on mysql database. I decided to migrate to postgres because of numerous reasons. Good idea :) Can you guys please guide me into the right direction? the main problem is the missing autoincrement of pgsql and getting the last record from the tabel, for linking to another tabel. How do you deal with that? The basic idea is that you use sequences which in postgresql are the equivalent of autoincrement in mysql. Something like: INSERT INTO category (category_id, category_name, category_description) VALUES (nextval('category_id_seq'), new_category_name, new_category_description); here 'category_id_seq' is the name of the sequence that produces the unique IDs for your category_id. To use your newly created category_id in another table: INSERT INTO product (product_id, product_name, product_description, category_id) VALUES (nextval('product_id_seq'), new_product_name, new_product_description, currval('category_id_seq')); nextval() and currval() are native postgresql functions which operate on sequences. Sequences are created automatically when you define a field to be of type 'serial'. If you need get the actual value of the newly created category_id for use in php then you would have to do a select query, eg: select currval('category_id_seq') as new_category_id; and do the usual pg_query() and pg_fetch_*() to process the result also, can you please recommend me some good manual, explanation or book to help me with this problem. Lookup serial types and sequences in the (postgresql) manual for the basics. Because the application uses around 250 tables in mysql and I would like to make it righ t the first time when migrating to pgsql.. I would suggest that you start off with a 'smaller' project and explore all the ways where postgresql does things differently to and/or better than mysql, then work your way up to a more complex project. This would be much better than doing a hasty migration to postgresql - which does not make the most of what postgresql has to offer - and then trying to hack the postgresql features in afterwards. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] postgres - mysql last_inserted_id
On Friday 01 July 2005 04:06, Richard Lynch wrote: last record from the tabel, for linking to another tabel. You have to use http://php.net/pg_last_oid to get the PostgreSQL internal Object ID (OID) -- You can then use the ubiquitous oid column. $query = insert ...; pg_exec($connection, $query); $oid = pg_last_oid($connection); I'm pretty sure I read somewhere that the the last OID can get messed up under some circumstances and the OID that you get is not the OID that you want. Can't remember whether this was a php-postgresql thing or simply a postgresql thing. But whatever it is, you don't need OIDs to use sequences. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ouput HTML w/PHP
On Thu, June 30, 2005 5:50 am, Rick Emery said: This leads (sort of) to a second question: how can I validate my HTML? My applications run on an intranet (with database access), so I can't use the W3C Validator to point to the URL. If I try to upload the file, the validator doesn't parse the PHP to get the HTML output (which is why I wonder if I'm not better writing the HTML and sticking PHP where it's needed). Is there a way for me to maybe use the PHP tidy functions on the string containing the HTML ouput to validate it? You could use ob_start() and then get the contents and run them through Tidy before displaying. You could also hack something up with wget (or similar) to get your PHP output to the validator. To expand on this theme a bit... Anybody know of an application which: can be run from command line as a cron job gets HTTP output (possibly from intranet, possibly from internet) maybe even crawls a whole site (stay in my domain name) feed output to user-selected validator (w3c, webmonkey, local application) notifies webmaster of problems In an ideal world: Problem lines would be run through diff and the application would assume (probably correctly) that only the first instance of a problem needs to be reported. I don't need 1893 complaints about the screwup on a template page for a store with 1893 Products. The user could flag certain output from the brain-dead validators as non-issue Example: I really don't *care* that the BODY attributes I use to get rid of borders in the content area only work in some browsers and aren't W3C kosher. THEY WORK! Unlike the nightmare that is CSS in its current implementations. My long-term goal is to crawl my own sites, in a cron job, and nag the hell out of me about any missing closing tags. Maybe a super long-term dream goal is to get to W3C compliance, but only after the browsers fix their CSS implementation, so I got a lot of breathing room there... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird Image Problem
Kristen G. Thorson wrote: MySQL blobs are actually limited to 64K. I think a MEDIUMBLOB holds about 16 MB if you're dead-set on storing the image in the database. You might want to check that your max_allowed_packets size is large enough. You can find that by querying SHOW VARIABLES LIKE 'max_allowed_packet'; I just double-checked the manual. It does say that this needs to be set to the largest blob. kgt doh! That seems to have been the problem. I THOUGHT I had set the field up as a mediumblob or longblob turns out it was only a blob.. and you're right.. ~64k max I had already checked the MAX_ALLOWED_PACKET yesterday and bumped it up to 16M. Figures... I've been staring at the computer screen too long. Thanks for the help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP search
On Sun, June 26, 2005 8:13 pm, Bruce Gilbert said: I am fairly new to PHP, and I am looking to create a search functionality on a website using php. Can anyone point me to a good tutorial that can walk me through this? Your best bets are: Use http://google.com and add site:example.com as one of the search terms. That restricts Google to ONLY return results from the website example.com Use htdig to index your site. A really really really distant third is to roll your own search engine. There are innumerable gothcas to it to start with, and unless you better define what you want your search engine to do, what features you want it to support, there isn't much we can do to advise you. Here's an example: Frequently, websites have an advanced search and a simple search. It's usually clear to the beginning programmer that the advanced search a very complicated bit of interaction between multiple search keys, and requires a fair amount of complex business logic in the program. What's often not as clear is that the simple search is often *WORSE* It's only simple for the *USER*, not necessarily for your programming. If your application has any kind of structure to its data more complex than an amoeba-like table, then depending on what the user inputs, you should probably be choosing entirely different fields/values and algorithms to get your results. simple search means simple for the surfer, not for the coding. YMMV NAIAA -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP search
Richard Lynch mailto:[EMAIL PROTECTED] on Thursday, June 30, 2005 2:33 PM said: There are innumerable gothcas to it to start with, ... Is that a special kind of goth? :P Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP search
On 6/30/05, Richard Lynch [EMAIL PROTECTED] wrote: Use htdig to index your site. Here's a nice tutorial on how to wrap ht://Dig results with PHP for custom layouts and formatting: http://www.devshed.com/c/a/PHP/Search-This/ -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the BACKSLASH
On Sun, June 26, 2005 3:01 pm, Martín Marqués said: El Dom 26 Jun 2005 18:12, Jochem Maas escribió: the backslash has caught us all out when we first started, and beyond. many 'noobs' have had the fortune of being explained, in depth, how and why concerning the backslash by a singular Richard Lynch ... but obviously nobody is immune (spot the mistake): http://www.zend.com/codex.php?id=15single=1 The colors speak for themself. Just look at where everything turns red. :-D This is one thing that makes me love editors that color the coding. made me chuckle, thanks Richard - also for the whereis function and the many tips! :-) You bet! Since the \ is also missing in front of the 'n's down in the sample commented out code at the bottom, I'm guessing the highlighter is at fault for stripping out \... I lost control of the RLYNCH account long long long ago, and while I just emailed webmaster AT zend DOT com, I'm not holding out hope of regaining control any time soon... So I can't really check and be 100% certain. God only knows what email address RLYNCH is tied to, but it don't end up in my Inbox these days. PS Am I the only one that finds zend.com terribly slow to load? It seems like I'm waiting for a lot of bad JavaScript and/or GoogleAds to do things. Ugh. I love Zend, but... [shrug] Guess they gotta pay the bills somehow. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the BACKSLASH
On Sun, June 26, 2005 2:42 pm, Sebastian said: backslash was invented for windows ;) I'm pretty sure backslash as an escape character pre-dates Windows... Maybe not, but pretty sure. btw, what do we have to do to get Radio announcers to read / correctly? It's *NOT* a backslash, you morons! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop spreading PEAR FUD; WAS Re: [PHP] Re: PHP web archeticture
On Sun, June 26, 2005 12:57 pm, M Saleh EG said: In all the cases if someone thinks a framework is bloated. Should just keep it bloated for him/herself. Programmers, and specially PHP programmers who are the majority of web-programming in IT labor market. So being it bloated for someone or perceived to be bloated has no meaning for some other programmers, unless having the same needs and environment. It's simply a matter of prefrence. Period. By this logic, Windows is not bloated. Q.E.D. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs. ColdFusion
In a message dated 6/29/2005 11:26:08 A.M. Central Standard Time, [EMAIL PROTECTED] writes: Yes a framework can be built in PHP, C# or any language but how would you like to design something like this. cfpage cfframe cfinputHidden Name=test Caption=New Record cfinputText Name=FirstName Caption=First Name /cfframe /cfpage How about something like Prado? looks just like it. _http://xisc.com_ (http://xisc.com)
Re: [PHP] $_SESSION and header()
On Sun, June 26, 2005 7:33 am, Alessandro Rosa said: (a) : After saving a couple of data into two $_SESSION variables from a form, (b) : I used the header() function to redirect the browser to (c) : display another page. (c) needs ?php session_start();? at the top, just like (a) and (b) and (z) for any other page you want to use your session data. Also, *WHY* redirect the browser and chew up an HTTP connection and make your application twice as slow? Plus, with the session_start() in there, you're going to duplicate all the effort you've already gone to to build up the session data structure (overhead). At that point in your script, you could just include (c) and be done with it. It's a heck of a lot easier to debug without feeling like you're the pinball in a fast-paced game of HTTP redirects, imho. You also make life easier on cURL and other programmatic access of your site, if you don't force them to play follow the bouncing ball to track down what they asked for. Just give it to them already. :-) I played with header(Location: ) in my early PHP days, and stopped using it rather quickly, unless I actually have a URL I want to maintain for the search engines for awhile, but the document has actually moved. Just because the re-direct works doesn't make it the best answer. Others on this list just LOVE to have a bunch of header(Location: ) statements in their PHP code, so you are not alone. Just something to think about. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] including the result of one query in another query
On Sun, June 26, 2005 4:53 am, Brian V Bonini said: On Sun, 2005-06-26 at 06:38, Pedro Quaresma de Almeida wrote: Hi I have two databases, on for aeromodelistas (aeromodelling) and another for Códigos Postais (Postal Codes). I whant to do the following query SELECT CódigoPostal FROM Aeromodelistas WHERE CódigoPostal IN (SELECT distinct(CP4) FROM codigopostal.LOCART,codigopostal.DISTRITO WHERE codigopostal.LOCART.DD=codigopostal.DISTRITO.DD AND codigopostal.DISTRITO.DESIG='Coimbra'); I believer DISTINCT is not an SQL function, it's a statement. SELECT DISTINCT column_name FROM table_name; In some implementations: distinct(expr[, expr]*) [,expr]* can be used to get only the columns within () to be distinct. Other columns outside the parens can be duplicates. I forget if MySQL does this or PostgreSQL. http://mysql.com http://postgresql.org -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] including the result of one query in another query
On Sun, June 26, 2005 3:38 am, Pedro Quaresma de Almeida said: I have two databases, on for aeromodelistas (aeromodelling) and another for Códigos Postais (Postal Codes). I whant to do the following query First, MySQL *DOES* allow you to select from multiple databases in a single query. Most RDBMS do not have that feature, AFAIK. SELECT CódigoPostal FROM Aeromodelistas WHERE CódigoPostal IN (SELECT distinct(CP4) FROM codigopostal.LOCART,codigopostal.DISTRITO WHERE codigopostal.LOCART.DD=codigopostal.DISTRITO.DD AND codigopostal.DISTRITO.DESIG='Coimbra'); This query is not working, and I do not know why. If I try the two queries individualy they work, togheter they don't!? As noted, maybe your MySQL version doesn't support sub-queries. Are you using mysql_error() to find out what went wrong? Cuz MySQL is practically BEGGING you to ask it What went wrong? http://php.net/mysql_error But the question I want to put to the members of this list is the following. Is it possible to do the following? // first do the subquery $sql_CP4s = select distinct(CP4) from codigopostal.LOCART,codigopostal.DISTRITO where codigopostal.LOCART.DD=codigopostal.DISTRITO.DD and codigopostal.DISTRITO.DESIG='$nomeDistrito'; $resultado_CP4s = mysql_query($sql_CP4s,$ligacao); $linha_CP4s = mysql_fetch_assoc($resultado_CP4s); // then use it in the main query $sql_Aero_Dist_Masc = select count(Nome) from Aeromodelistas where year(AnoQuota)=2005 and Sexo='Masculino' and Distrito IN $linha_CP4s; Yes, but... You'll need to work on the syntax a bit. //Add commas for valid SQL in an IN expression: $linha_CP4s_sql = implode(, , $inha_CP4s //Add parens for valid SQL in an IN expression: ... and Distrito IN ($linha_CP4s_sql) ; Is it possible? Generally, it's SLOWER than using a JOIN or a sub-select. Sometimes, particularly if the fields you are searching/joining on are not indexed, it's actually faster. This might be one of those cases, particularly since your Postal Codes table probably has a LOT of entries. For example, if you assume a rather modest number of aeromodellers (say, 2000) and a number of Postal Codes such as in the US of about 60,000 you then have 2000 X 60,000 == 120,000,000 tuples in an unrestricted join. Your basic $20/month webhost doesn't provide anywhere *NEAR* the amount of temp/swap disk space you would need for 120 MILLION tuples to run AT ALL, much less in some kind of reasonable time frame. This could be rule-breaking time. Normally, you would never, ever, ever want to have the same data duplicated in two tables. BUT, if your choice is between 120 MILLION tuples, and intelligently de-normalizing your database, then intelligently de-normalize your database. Specifically: add column to aeromoddellers DD varchar(10) default null; (Only maybe it's int(11) instead of varchar(10) or whatever) Write a cron job that does something like: select id, something from aeromodellers where DD is null limit 100; while (list($id, $something) = mysql_fetch_row($result)){ select DD from posital_coditas where something about $something update aeromodellers set DD = $DD where id = $id } The purpose of the above psuedo-code is to COPY the DD you need from the Postal Codes to the aeromodeller table. Run the script every few minutes for a day or two, then when the table has no NULL DD colums left, every day or so. Add some triggers (or business logic) so that when $something changes, the DD gets reset to NULL, and your cron job will re-copy the DD from the Source Postal Codes. While this is technically nasty de-normalized data, it is done in such a way that: 1) The DD field is never set directly, only copied from the One True Source 2) The DD field may be NULL, and un-usable, but it's never *WRONG* data. 3) Instead of 120 MILLION tuples crippling your server, you have 2000* * 2000 is really however many rows are in aeromodeller... It's still (1/6)th of the search space, any way you cut it. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array_diff php version
On Sun, June 26, 2005 2:19 am, André Le Tissier said: Help! Array_diff is the perfect function for what I am try to do but I have a php version 4.1.5. Is there any replacement I can use to achieve the same result There are seven different solutions to this (with modifications of what array_diff means) at http://php.net/array_diff The PECL library also provides functions for forwards-compatibility, I do believe, and I'm betting array_diff is one of them. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Achieving 64-bit integers on 32-bit platforms
On Thu, 30 Jun 2005 at 00:16, Richard Lynch wrote: On Wed, June 29, 2005 9:02 pm, Dan Goodes said: This 32-bit limitation is haunting me everywhere I turn. Is it possible with PHP (at compile-time if need be) to make it use large (64-bit) integers? I believe that PHP runs fine on 64-bit hardware, and uses 64-bit ints everywhere on that... So, in theory at least, just buying a 64-bit machine would solve your problem... Not that you necessarily *can* run out and buy a 64-bit machine, mind you. yes. especially since each of our front-end webservers would need to be 64-bit to do what i was hoping to do. what I was hoping for was a way to make php use 64-bit integers (or fake it somehow), such as apache2.0.54 does for files of that size. I'm asking because I would like to perform operations on large files, and fillesize($filename) is returning an error, even when I use sprintf(%u, filesize($file)) as per the manual for filesize(). I get: Warning: filesize(): Stat failed for FC4-i386-DVD.iso (errno=75 - Value too large for defined data type) Any thoughts/ideas/suggestions? Thanks! At least for THIS particular function, you could use exec(du $filename, ...) and then you'd have a string representation of the size, which you could then display or even manipulate with BC_MATH or that other new-fangled arbitrary precision mathematics PHP Module whose name I forget. This is a much less general solution, but may suffice for now. well, it may suffice actually. I'm just not sure of the performance impact of doing this for every file from all our front-end boxes anytime someone does a directory listing. thanks for the answers :-) --dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a basic array question!
On Sat, June 25, 2005 2:01 pm, bruce said: feel kind of foolish posting this.. but i can't seem to figure it out for now.. Here's a way to tackle this kind of thing in the future: Divide and Conquer. print_r($foo) prints out a BUNCH of stuff. Focus only on the outer layer: i have an array, i can do a print_r($foo) and get the following: Array ( [bookmark] = 1 [facets] = Array . . . Then simply do: print_r($foo['facets']); Now you can ignore a bunch of crap you don't care about. Focus on the outer layer and begin again: Array ( [0] = Array ( [lastname] = form id=facet-lastname input type=hidden name=list value= / input type=hidden name=offset value=0 / input type=hidden name=orderBy value=username / input type=hidden name=sort value=asc / strongName:/strong input type=text name=_lastname value= style=width: 125px / input type=submit value=Search / /form } Okay, now we have: print_r($foo['facets'][0]); Array ( [lastname] = form id=facet-lastname input type=hidden name=list value= / input type=hidden name=offset value=0 / input type=hidden name=orderBy value=username / input type=hidden name=sort value=asc / strongName:/strong input type=text name=_lastname value= style=width: 125px / input type=submit value=Search / /form } Finally, print_r($foo['facets'][0]['lastname'] is your answer. It won't always be [] -- If you are using objects you might need - in there somewhere. Figuring out where gets a lot easier if you focus on the Big Picture -- only the outer layer of your data structure, and drill down. If at some point you know you need *ALL* the elements of an array, that's easy enough. That's the point at which you put in a loop to walk through them. BUT During your development, write the loop, see that it dumps out all the elements, or at least a whole lot of stuff, and then stick an exit; at the end, and focus on JUST the first element to tear that apart. You can take the exit; out when you are all done, and it will work for all the elements, assuming your data is well-formed. In the meantime, focus on the outer layer, and focus on just ONE element at a time, to avoid confusing yourself. I do this all the time, especially when I'm dealing with somebody else's structured data, and I don't really know what they've done. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: send email at certain hour
On Sat, June 25, 2005 11:55 am, Arthur Wiebe said: vlad georgescu wrote: i want to make a reminder application which sends emails at certain hour in php. is this posibile ? if not, what else can I use ? I've done it using pure PHP for a calendar script. What I did was write a PHP script with a loop that checks every second whether or not something should be done. For example: ?php $t = true; while ($t) { if (time() == $myTimeStamp) { mail(args); } } ? at the top of the script I have a line like this: #!/usr/bin/env php for *nixs' and I wrote a little batch file for Windows systems. At least it works. This works, but it's kind of resource intensive, I think... You've pretty much got a whole PHP binary running all day, every day. Not a real big deal, but it's not really needed, as you'll see. Your loop is the big issue. You're going to call time() maybe a few thousand times in one second! At least in *MY* single crude bench mark test, it got called 6082 times. ?php $start = time(); $i = 1; while (time() == $start){ echo $i, \n; $i++ } ? I will spare you the 6000+ lines of output, but it ended with 6082. :-) Do you really want PHP sitting there spinning its wheels furiously to call time() 6000 times every second?... You could simple put a sleep(1) inside your loop, so it would sleep for one second. Even then, do you really need to check email every single second of every day? Maybe if you have a *TON* of email to send out... It's more likely that sending email every 5 minutes would work just fine. The better solution, IMHO, would be to use cron (see: man 5 crontab) to run a script every 5 minutes to see who needs to get email notification, and send out the emails, and quit. 5 minutes can be varied as needed for your application. Sometimes it can be 24 hours, or a whole week. Other times you actually *WANT* it every minute. If your web calendar only allows things to occur on even 15 minute blocks, then there's not much point to checking more frequently than every 15 minutes, because nothing can happen to change things until 15 minutes goes by, except users changing their preferences, and that can either run the script as well, or they can just be warned in the interface that it will take at least 30 minutes for their change to take effect. 29 minutes, actually, if they just missed the last cron job, but who's counting? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange is_dir() behavior
On Sat, June 25, 2005 8:54 am, Marcos Mendonça said: Yes, if i try to to echo the variable $entry outside the if is returns the expected directories list. I tried giving it the full path and it still doesn't work. Show us that source code. Cuz I wouldn't expect it to work without the full path for is_dir() But if it's not working with the full path... You've done something wrong. Okay, maybe you've found a bug in PHP that 1,238,874,988 other users have missed... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Writing a PHP Web application
Hello, What are the options to get code to run on the server (every XX minutes), without any user interaction, etc. Example 1: If I have a directory that contains files, can I write a script that will delete all files older that 5 days? Example 2: If I write an email web application, and the user wants to send an email to 50 people, can I write a script that will send emails individually XX seconds apart from each other, but have the progress interfaced with the web page the user is on so they can see the percentage progress of sent emails. Is this possible? How do I do such things? Are there any resources available that can help me with this? Also, back to the email example, is it possible that once an email is composed and sent, that the web application can scan the email for viruses, then show a message to the user if a virus was found in their email, if no virus found, the email is then sent to the users as above. How would I scan an email for viruses (or spam?)? And, scan it only once so that system resources are not used to scan unnecessarily for every recipient? Any help would be greatly appreciated. Thanks Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Verifying images with getimagesize()
On Sat, June 25, 2005 8:41 am, Jack Jackson said: Thanks for telling me about that, Edward. I apprecate it. Actually in this case I was using it only to verify that it was something like an image to validate the file type before allowing it on the server. But you raise a very good point and I appreciate it. Just to be sure we aren't providing a false sense of security through silence... It *IS* possible (remotely, theoretically) somebody could construct an image that passes getimagesize() and is a really nasty binary trojan software hack to destroy your site. It's even possible (very remotely, very theoretically) that it would look like a perfectly fine image in Photoshop or any other application. getimagesize() does not magically make you 100% safe -- It just means that at least they took SOME effort to disguise the malware, and will have to make a great deal of effort to make that malware execute and actually *do* something, much less do something destructive. Feel free to try chmod-ing your JPGs to be executable and then do /full/path/to/images/silly.jpg from the command line... Errr. Maybe you'd better do this on a computer you don't care about JUST IN CASE. You'd have to stumble across the 1 in a zillion chance this would actually do anything, but it's there... I think the first few bytes alone of a valid image are, by definition, not a valid binary executable file, but don't quote me on that. Throw PHP into the picture, though, and imagine they manage to get their JPG file to be passed through the PHP parser, and they have a comment in their JPG that says: ?php exec(rm -rf /);? Granted, your application would have to be pretty screwed up to let them run that JPEG through as if it were HTML/PHP, but it's not impossible to find holes in well-known applications that let Bad Guys run arbitrary files through PHP... I'm not saying anybody has or hasn't developed such an image yet ; Only that it COULD be developed. Take a valid JPEG, keep the first N bytes that getimagesize() looks at, and cram some PHP code on the end. Voila! Note that anybody smart enough to develop that image, would probably be able to break into your site (or at least most sites) a lot easier some other way. :-) :-) :-) Also note that once that image existed, any idiot could upload it and take advantage of it. :-( :-( :-( Tip: Nothing beats the human eye for finding bad stuff. If you are worried about this, give your users a feedback link to notify you of images that look wrong -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop spreading PEAR FUD; WAS Re: [PHP] Re: PHP web archeticture
On Sat, June 25, 2005 7:32 am, Matthew Weier O'Phinney said: * Catalin Trifu [EMAIL PROTECTED] : I also tend to stay away from PEAR, which is kinda bloated for my taste, except the Log package. rant I hear that a lot on this list, and I don't understand the reasoning behind such comments -- perhaps because nobody offers any reasoning, only the opinion? I'm a PEAR user, and I've found the packages anything *but* bloated. Granted, I only use a subset of PEAR, but that subset has made mycoding easier. I use DB, Log, Mail, Mail_MIME, HTML_QuickForm, Cache_Lite, and Pager daily; additionally, we use custom PEAR error handlers to catch errors generated by these packages, log them, and display custom error pages. If I'd had to write the functionality I have readily available in these packages, I wouldn't have a job right now. They've helped me meet numerous deadlines. If somebody could offer some *constructive* criticism of PEAR -- PEAR as it is TODAY, not 3 years ago, when I last tried it -- these comments would have more weight. As it is, I feel they're just FUD based on ignorance. /rant rant When I see some killer feature in PEAR that I think will make up for the *DAYS* of my time that PEAR wasted three years ago, I'll try it again. I remain adamant that PEAR is bloated, has too many internal dependencies, and gives me nothing faster/easier than rolling my own. YMMV /rant :-) I *like* the PEAR guys. I appreciate that they've given some great code that lets people just slap it in and it works. I'm sure some people just LOVE the integrated error handling that silently eats all the errors in PEAR. Maybe they even appreciate that it also eats all the following errors I was sending to the Apache log which I monitored. :-( :-( :-( If that's how you want to build you application, more power to you. *I* don't like to work that way. I will probably continue to boil down my opinion to PEAR is bloated rather than waste time on this list, yet again, provding specific details of my experience. Read the archives if you want detail. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing a PHP Web application
What are the options to get code to run on the server (every XX minutes), without any user interaction, etc. If you are running on a unix like system (linux, freebsd, solaris, etc.) cron can do this for you. See this: http://en.wikipedia.org/wiki/Cron If on windows there are probably scheduling applications, but I don't know anything about them. Example 1: If I have a directory that contains files, can I write a script that will delete all files older that 5 days? Yes. Write the script to do what you want it to do and then have cron execute it on the time period you define. Example 2: If I write an email web application, and the user wants to send an email to 50 people, can I write a script that will send emails individually XX seconds apart from each other, but have the progress interfaced with the web page the user is on so they can see the percentage progress of sent emails. Yes. This is a bit trickier as you would need to coordinate with a backend process that looks for emails that are ready to send them, does the sending and also writes out some status info (either to a temp file or to a database, or to shared memory). Then your web page would need to repeatedly check that status to update the user on the progress. Also, back to the email example, is it possible that once an email is composed and sent, that the web application can scan the email for viruses, then show a message to the user if a virus was found in their email, if no virus found, the email is then sent to the users as above. Yes. You could install a virus scanner such as ClamAV (http://www.clamav.net/) and have it scan the message prior to handing it off to the backend process that does the sending. How would I scan an email for viruses (or spam?)? Same idea, but use something like SpamAssassin (http://spamassassin.apache.org/) And, scan it only once so that system resources are not used to scan unnecessarily for every recipient? Sure. Just do it before handing it off to the script that actually does the mailing... -philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting a filename [with no extension] out of a url
if $_SERVER['SCRIPT_NAME'] give this /folder/folder/Library/php/filename.php what would be the proper way to strip the string until only 'filename' is left I'm a bit new at eregi stuff any help would be appreciated many thanks g -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting a filename [with no extension] out of a url
Hi, Friday, July 1, 2005, 9:54:42 AM, you wrote: GA if $_SERVER['SCRIPT_NAME'] give this GA /folder/folder/Library/php/filename.php GA what would be the proper way to strip the string until only 'filename' GA is left GA I'm a bit new at eregi stuff GA any help would be appreciated GA many thanks GA g I do this: $file = '/folder/folder/Library/php/filename.php'; $ext = @substr($file, (@strrpos($file, .) ? @strrpos($file, .) + 1 : @strlen($file)), @strlen($file)); $fname = basename($file,$ext); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MMcache question
On Sat, June 25, 2005 3:37 am, Catalin Trifu said: No! You don't have to rewrite your application. What mmacache does is to keep a bytecode version of the script available so that PHP won't have to reparse the script every time, which is expensive and also has a nice code optimizer. This is a common misconception about PHP cache systems... The PHP parser is *NOT* the big win Avoiding the hard disk read is the big win The PHP parser, even in PHP 5, just is NOT that complex. We're not talking C++ here. We're not even talking C. It's PHP! The entire language fits on a couple web pages for cripes' sake. [Not all the module/function stuff, just what the PARSER has to figure out] mmcache, Turck, eaccalerator, Zend Cache, whatever. They all have this oft-repeated misconception that they make your script faster because the PHP parser is taken out of the loop. The PHP parser being taken out of the loop is just gravy -- Something the cache does just because it's mind-numbingly easy, once you develop a cache at all. The true performance win is not having to hit the hard drive to *read* the PHP script before you parse it. It's already in RAM. The Zend Cache will make most applications at least 2 X as fast. About 1.9 of this speed increase probably comes from the fact that the script is in RAM. And maybe only 0.1 from the PHP parser getting bypassed. I made the 1.9 and 0.1 numbers up out of thin air for illustrative purposes!!! They are NOT real numbers. They *ARE* representative of the imbalance at work here. The 2 X number ain't made up. That's what Zend customers routinely reported in worst-case situations when I worked there (several years ago). 4 X was often the real world speed-up. You don't get a 2 X speed-up from the PHP parser not ripping through a bunch of text. No way. No how. You could (possibly) achieve similar speed-ups just having a RAM disk for all your PHP code. Though I think even a RAM disk has significant overhead in mimicing the file control function calls that is beggared by the Cache lookup. There are pathalogical cases where the Cache will do you no good at all, or even degrade performance. The most obvious one is if you have *WAY* too many PHP scripts scattered into *WAY* too many files, and your site has a *LOT* of pages with widely-distributed viewing. IE, imagine a site with 10,000 pages, but instead of the home page being the one everybody hits all the time, that site has everybody deep-linking to all the pages equally often. Also imagine that each of the 10,000 pages opens up 10 *different* PHP include files to generate its output. [This is an extreme pathalogical example... But less extreme real-world cases exist.] The Cache will end up thrashing and re-loading script after script because they can't all fit in RAM at once. I saw one client that literally had snippets of PHP code spread out in thousands of files, which they were combining to create PHP scripts on the fly from the database in a combinatorial-explosive algorithm. The Cache they used (not naming names, because it's irrelevent) was actually slowing down their site, a little bit, due to the overhead involved. They would have to have consolidated scripts, thrown *WAY* more RAM at it, or just completely changed their algorithm to fix it. I think they ended up doing a little of all that. Plus throwing more hardware at it. PHP is a shared-nothing architecture for a reason. :-) Most sites have a couple include files that get loaded on every page. Those pretty much get loaded into RAM and never move. And that's where the cache shines. No disk read. Just RAM. Raw Hardware Speed, baby. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MMcache question
you sound exactly like someone i know.. i enjoy reading your long posts.. no sarcasm ;-) i'd defently hire you, but you're probably too expensive ;-) Richard Lynch wrote: On Sat, June 25, 2005 3:37 am, Catalin Trifu said: No! You don't have to rewrite your application. What mmacache does is to keep a bytecode version of the script available so that PHP won't have to reparse the script every time, which is expensive and also has a nice code optimizer. This is a common misconception about PHP cache systems... The PHP parser is *NOT* the big win Avoiding the hard disk read is the big win The PHP parser, even in PHP 5, just is NOT that complex. We're not talking C++ here. We're not even talking C. It's PHP! The entire language fits on a couple web pages for cripes' sake. [Not all the module/function stuff, just what the PARSER has to figure out] mmcache, Turck, eaccalerator, Zend Cache, whatever. They all have this oft-repeated misconception that they make your script faster because the PHP parser is taken out of the loop. The PHP parser being taken out of the loop is just gravy -- Something the cache does just because it's mind-numbingly easy, once you develop a cache at all. The true performance win is not having to hit the hard drive to *read* the PHP script before you parse it. It's already in RAM. The Zend Cache will make most applications at least 2 X as fast. About 1.9 of this speed increase probably comes from the fact that the script is in RAM. And maybe only 0.1 from the PHP parser getting bypassed. I made the 1.9 and 0.1 numbers up out of thin air for illustrative purposes!!! They are NOT real numbers. They *ARE* representative of the imbalance at work here. The 2 X number ain't made up. That's what Zend customers routinely reported in worst-case situations when I worked there (several years ago). 4 X was often the real world speed-up. You don't get a 2 X speed-up from the PHP parser not ripping through a bunch of text. No way. No how. You could (possibly) achieve similar speed-ups just having a RAM disk for all your PHP code. Though I think even a RAM disk has significant overhead in mimicing the file control function calls that is beggared by the Cache lookup. There are pathalogical cases where the Cache will do you no good at all, or even degrade performance. The most obvious one is if you have *WAY* too many PHP scripts scattered into *WAY* too many files, and your site has a *LOT* of pages with widely-distributed viewing. IE, imagine a site with 10,000 pages, but instead of the home page being the one everybody hits all the time, that site has everybody deep-linking to all the pages equally often. Also imagine that each of the 10,000 pages opens up 10 *different* PHP include files to generate its output. [This is an extreme pathalogical example... But less extreme real-world cases exist.] The Cache will end up thrashing and re-loading script after script because they can't all fit in RAM at once. I saw one client that literally had snippets of PHP code spread out in thousands of files, which they were combining to create PHP scripts on the fly from the database in a combinatorial-explosive algorithm. The Cache they used (not naming names, because it's irrelevent) was actually slowing down their site, a little bit, due to the overhead involved. They would have to have consolidated scripts, thrown *WAY* more RAM at it, or just completely changed their algorithm to fix it. I think they ended up doing a little of all that. Plus throwing more hardware at it. PHP is a shared-nothing architecture for a reason. :-) Most sites have a couple include files that get loaded on every page. Those pretty much get loaded into RAM and never move. And that's where the cache shines. No disk read. Just RAM. Raw Hardware Speed, baby. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newline and pregreplace
On Fri, June 24, 2005 3:18 pm, Dotan Cohen said: I've got a line like this: $str=preg_replace( -regex here-, '\nnote\1/note', $str); Which has one of two problems: If I leave the single quotes around the second argument, then it returns as \n and not a newline. If I change the single quotes to double quotes, then the info from the regex is not inserted in place of the \1. What is one to do in these situations? Single quotes have only two (2) special characters: ' and \ You need \' to get a ' buried inside a single quote. Since you use \ as the escape character, but you might want \ in the string, you also want to use \\ to get a single \ in your string. That's pretty much *IT* for single quotes. Double quotes have much for flexibility. Embedded variables, special characters like \n \r \t ..., embedded 1-D arrays and object dereferences (-) and even (in recent times) an {} construct to evaluate an expression and splice it in. In PHP, you need \n inside double quotes to get a newline. [Okay, there are other ways, but it's the most common way.] \n inside of single quotes don't mean squat. So, in PHP \n is newline. I think \1 just turns into 1 because 1 is not special following \... But I can't begin to remember *ALL* the characters that are special following \ especially when you start getting into octal/hex representations. The trick to remember is that if you want \ in PHP, you need \\ to get a single \ Now, both PHP *and* RegEx use \ as a special character. So, not only do you need \\ in PHP to get a single \, you *ALSO* may need one (or more) \ characters to feed into your RegEx. In your case: \n...\1 turns into this in PHP internally: [newline]...1 Because \1 don't mean squat to PHP either, really. It just means 1 [Unless it means ASCII charcter 1, which I doubt...] Anyway, the \ is being used by PHP as an escape character, and you need a \ to get down to the RegEx parser. \n...\\1 will do that. PHP will see the \\ and turn it into \ internally. The \ gets handed to the RegEx parser, and it sees: [newline]...\1 for its input string. That's what you want. Always try to see your PHP / RegEx strings in three stages: 1. What you type in PHP. 2. What PHP stores internally, which is what it hands to RegEx 3. What RegEx is going to parse #2 into. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: send email at certain hour
Richard Lynch wrote: On Sat, June 25, 2005 11:55 am, Arthur Wiebe said: vlad georgescu wrote: i want to make a reminder application which sends emails at certain hour in php. is this posibile ? if not, what else can I use ? I've done it using pure PHP for a calendar script. What I did was write a PHP script with a loop that checks every second whether or not something should be done. For example: ?php $t = true; while ($t) { if (time() == $myTimeStamp) { mail(args); } } ? at the top of the script I have a line like this: #!/usr/bin/env php for *nixs' and I wrote a little batch file for Windows systems. At least it works. This works, but it's kind of resource intensive, I think... You've pretty much got a whole PHP binary running all day, every day. Not a real big deal, but it's not really needed, as you'll see. Your loop is the big issue. You're going to call time() maybe a few thousand times in one second! At least in *MY* single crude bench mark test, it got called 6082 times. ?php $start = time(); $i = 1; while (time() == $start){ echo $i, \n; $i++ } ? I will spare you the 6000+ lines of output, but it ended with 6082. :-) Do you really want PHP sitting there spinning its wheels furiously to call time() 6000 times every second?... You could simple put a sleep(1) inside your loop, so it would sleep for one second. Even then, do you really need to check email every single second of every day? Maybe if you have a *TON* of email to send out... It's more likely that sending email every 5 minutes would work just fine. The better solution, IMHO, would be to use cron (see: man 5 crontab) to run a script every 5 minutes to see who needs to get email notification, and send out the emails, and quit. 5 minutes can be varied as needed for your application. Sometimes it can be 24 hours, or a whole week. Other times you actually *WANT* it every minute. If your web calendar only allows things to occur on even 15 minute blocks, then there's not much point to checking more frequently than every 15 minutes, because nothing can happen to change things until 15 minutes goes by, except users changing their preferences, and that can either run the script as well, or they can just be warned in the interface that it will take at least 30 minutes for their change to take effect. 29 minutes, actually, if they just missed the last cron job, but who's counting? Yes, that is something I forgot to mention. I use the sleep() function with a value of 1 and the script runs using 0% of the CPU. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object Oriented PHP (5)
On Fri, June 24, 2005 12:56 pm, Josh Olson said: PHP has inspired me to become a better programmer. I have been actively reading books as well as online content to try to become better at designing and programming object oriented web applications. My primary focus is PHP. Will you help a pragmatic programmer in training out by suggesting some worthwhile resources? I have read the following already: PHP 5 Power Programming Advanced PHP Programming Pragmatic Programming Gang of Four Design Patterns php.net/oop zend.com php 5 resources most of ibm object design articles http://www.solarphp.com/home/ and many many many shitty online tutorials and source repositories I didn't read any of those books. Only PHP books I've really read all the way through were the ones I Tech-Edited. I don't think I'd really feel right recommending those, solely because I worked on them, but they are pretty good books. PHP Bible series and MySQL/PHP Database Applications. I mostly learned Programming from going to college. Well, okay, really mostly from trying out all kinds of stuff sort of loosely based (or not) on what the boring homework assignments didn't cover. :-) I take it back. I *have* read many many many shitty online tutorials and source repositories. So you got that going for ya :-) Honestly, the best reference *I* know of is: http://php.net/manual The User Contributed notes are priceless. Well, some of them anyway. You have to find the pearls in the muck. And, of course, this list, which has provided invaluable support for YEARS from people way way way smarter than me. One other piece of advice: Write lots and lots of code. Lots of it. I was just reading an interview with Jakob Dylan, whom you may or may not like, but he said something intereesting, which I'll paraphrase. I really wasted a lot of years not writing songs, because I knew I couldn't write them as good as I wanted. I knew I had much better songs in me, maybe even great songs, but I couldn't get myself to write them, because I didn't know how. Eventually I realized. You have to write 10, 100, a thousand bad songs before you've learned enough to write good ones. That's just how it works. If you sit around not writing songs, because they'll be bad, you won't get anywhere. So, stop reading so many books and start typing! :-) Some other suggestions to consider: Take some cheap programming courses at a local community college. Even if you whiz through them, you'll have a piece of paper that helps get a job, and you'll be surprised how much you learn (or re-learn) from a structured course that books and on-line digging won't push you through. Re-write some old code of your own. Amazingly instructive, and often leads you to new heights. Plus your old stuff suddenly has a lower maintenance cost, for some odd reason... :-) Publish some articles or code snippets on your site. The act of trying to explain what you did to somebody else will open up worlds of understanding. You never really understand something until after you've taught it to somebody else. :-) Re-read the whole front part of http://php.net/manual/ -- Just up to the function definitions part. That section of the manual that defines the actual language (quotes, commas, and braces) is SEVERELY under-studied by virtually every PHP programmer, even the ones who have been around forever and a day. Try to work on a project with another developer. You may tear your hair out. You may want to kill them. You may learn a whole hell of a lot. Maybe what you learn is that a whole lot of developers just don't think like you do. That's okay too. At least, it's okay for me. :-) [shrug] Work on a cool new project just for fun, with no time-line, and no intention of every finishing, much less releasing it, nor showing it to anybody. Just write that cool program you've always wanted to write. Hell, I do this with a dozen projects at once, all the time. Don't pay the bills. Don't get the house cleaned up either. But I'm happy. What's that worth? Sure, some of these won't ever get finished. Hell, some of them I've just plain lost interest in over the years. So? I've put in a lot of happy hours instead of drudgery. Wanna put a price on that? One of them turned into the code that's still in production use 10 years later. [shrug] I'm not all that interested in it, but some other guy uses it all the time, and maintains it. Hell, I'd forgotten all about it, pretty much. Certainly had no idea this guy was still using/maintaining it. Ooooh. At the risk of being branded a heretic, try to pick up another language or two. Start with something a whole lot like PHP. Maybe Perl, or even C. You'll have to shove all your PHP knowledge over to one side of your brain, cram all the new stuff into the other half of your brain, and then compare/contrast. Then, for real fun, try to learn something totally whacked-out different like Lisp, Scheme, Forth, Logo, or even
Re: [PHP] Can't even make a simple test RSS feed
On Fri, June 24, 2005 12:23 pm, Brian Dunning said: What am I doing wrong? This doesn't work. The browser does not even load the page, no error or anything: ?php echo '?xml version=1.0?rss version=2.0channel'; echo 'item'; echo 'titlehdfghdf/title'; echo 'descriptiondfghdfh/description'; echo 'linkhttp://somelink/link'; echo '/item'; echo '/channel/rss'; ? Now that you've got the browsers fooled with a .rss extension, go back and rip out all those silly echo statemnts :-) More seriously, unless this was just a test to make sure PHP was working you really don't even need PHP for 90% of what you typed... :-) I'm assuing you'll actually put more complex PHP code in there now, but I couldn't resist. More seriously, you probably should have some embedded newlines in there, even for the silly example that it is. As it stands now, your XML is one giant long line. Maybe XML parsers don't care, but the people who have to read your script output *DO* care. Take care that your PHP output is readable, as well as your PHP source. Your PHP output *IS* source, or it will be to somebody, somewhere, someday, if your site gets any traffic at all. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reading PDF's
On Fri, June 24, 2005 12:10 pm, Jon said: Is it possible to read text from a PDF file with PHP? How? At the crudest level, you can fopen/fread a PDF and dump it out, and pick out the plain-text readable bits with your eyes. :-) After that, there are definitely some commercial command-line tools to convert PDF to text (or HTML or whatever) that you can Google for. There may be a free one, or even an OpenSource one, but I've never heard of it, possibly because they'd have to pay a license to Adobe (Macromedia this week?) to be legal... Note that PDFs can have the text encrypted, or password-protect the PDF, or the text could have been rendered into an image which was embedded in the PDF (ugh!). At that point, you can maybe get the image out and use some kind of OCR softare like OmniPage to read it. Over the years and versions the PDF changed a lot, so be sure to have a representative sample of PDFs to throw at your testing. You don't want to get to launch and find out 90% of the real PDFs simply don't work. :-( -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MMcache question
On Thu, June 30, 2005 5:25 pm, Sebastian said: you sound exactly like someone i know.. i enjoy reading your long posts.. no sarcasm ;-) i'd defently hire you, but you're probably too expensive ;-) Thanks! Some people take my posts far more seriously and/or negatively than I intend, though... [shrug] That's the 'net for ya. Believe it or not, I pre-censor a whole lotta stuff before I hit Send even if it don't seem like it. All caught up with PHP-General. Whoo Hooo! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting a filename [with no extension] out of a url
Hello Graham, Friday, July 1, 2005, 12:54:42 AM, you wrote: GA if $_SERVER['SCRIPT_NAME'] give this GA /folder/folder/Library/php/filename.php $_SERVER['SCRIPT_NAME'] won't give you that, $_SERVER['SCRIPT_FILENAME'] would. SCRIPT_NAME would just give you /filename.php And if you need to remove the slash at the start, pick any of the following: substr, str_replace, preg_replace, strpos, etc. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I do not fear computers. I fear the lack of them. - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Achieving 64-bit integers on 32-bit platforms
On Thu, June 30, 2005 4:02 pm, Dan Goodes said: On Thu, 30 Jun 2005 at 00:16, Richard Lynch wrote: On Wed, June 29, 2005 9:02 pm, Dan Goodes said: This 32-bit limitation is haunting me everywhere I turn. Is it possible with PHP (at compile-time if need be) to make it use large (64-bit) integers? At least for THIS particular function, you could use exec(du $filename, ...) and then you'd have a string representation of the size, which you could then display or even manipulate with BC_MATH or that other new-fangled arbitrary precision mathematics PHP Module whose name I forget. This is a much less general solution, but may suffice for now. well, it may suffice actually. I'm just not sure of the performance impact of doing this for every file from all our front-end boxes anytime someone does a directory listing. thanks for the answers :-) You could *MAYBE* get a performance gain out of caching fullpath, filemtime, and filesize in a database, if every page is already opening a database connection anyway... I'm not sure a file stat is slower than a query or not. Actually, nobody is sure. Depends on your hardware. Obviously you need an index on the file path, and that can limit the path length more than the OS limits it, but this may or may not matter, and you may or may not have all these files rooted in some known directory you can leave off to ameliorate the limit... I guess you could even md5 hash the full path, and take the basename() and store both. Odds on those both matching up and causing a collision are astronmical, I think. Another option would be to catch the error, and only use exec(du) when you absolutely had to, for the files over 2 Gig. Or even (gasp!) just tell the user over 2 Gig any time the error occurred. :-) Cuz, really, once a file is over 2 Gig, does anybody using a web interface to look at it really care?... Maybe for your application they would, because the are using the web interface to do things. But maybe most people would be like Okay, that's monster big, I ain't downloading THAT sucker! for everything over 2 Gig anyway. Depends why you are doing this, but it's a POSSIBLE answer if it's a linked system to let folks download stuff. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP search
On Thu, June 30, 2005 2:36 pm, Chris W. Parker said: Richard Lynch mailto:[EMAIL PROTECTED] on Thursday, June 30, 2005 2:33 PM said: There are innumerable gothcas to it to start with, ... Is that a special kind of goth? Yeah, it's California Goth, also known as Surf Goth. But sometimes people think it means something entirely differnt from that: Canadian Goth, eh? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] postgres - mysql last_inserted_id
On Thu, June 30, 2005 2:17 pm, Jason Wong said: On Friday 01 July 2005 04:06, Richard Lynch wrote: last record from the tabel, for linking to another tabel. You have to use http://php.net/pg_last_oid to get the PostgreSQL internal Object ID (OID) -- You can then use the ubiquitous oid column. $query = insert ...; pg_exec($connection, $query); $oid = pg_last_oid($connection); I'm pretty sure I read somewhere that the the last OID can get messed up under some circumstances and the OID that you get is not the OID that you want. Can't remember whether this was a php-postgresql thing or simply a postgresql thing. But whatever it is, you don't need OIDs to use sequences. There are innumerable on-line forums that (incorrectly) state that an OID could be returned that is not connection-specific, so two HTTP requests in parallel would criss-cross OIDs. This is patently false, and any user of PostgreSQL can demonstrate that in minutes (okay, an hour for a newbie) of coding. OIDs *can* get re-used *IF* you end up having more than 32-bits (2 billion plus) of objects in the lifetime of your application. For normal usage, that ain't a big problem, honestly... Though I should have stated it for the record, cuz maybe the OP has a site where 2 BILLION INSERTs are gonna happen. The solutions there are the same as for not having OID in the first place -- Have some other unique identifier you generate yourself in the INSERT, or use that *with* the OID to be 100% certain you get back the same row from your 2 billion plus data set. If there's a reliable, web-safe, connection-dependent way of getting the sequence ID used in an INSERT, it sure ain't documented, and I've never seen it discussed on the PostgreSQL list (which I dropped off awhile ago, so maybe it's something new). If PostgreSQL guys added some new-fangled thing, sorry! It should be documented under http://postgresql.org if you search for OID and sequence, you'd hope. You *could* write your application to SELECT nextval('TABLENAME_id') and then provide the ID on the INSERT statement, and then you already have the ID, but that's kinda hokey, and goes against the grain of just letting the database do its job... Sort of an elegant and crude solution all at once. Though that also limits you to 2 billion plus records per table -- which is better than OID which is shared across all tables in a single database. If you are dealing in 2 billion object PostgreSQL databases, and you don't know all this already, you're in DEEP trouble... Start reading: http://postgresql.org/ See ya in a couple months. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php5.1 compiling memory usage
On 6/14/05, Xuefer [EMAIL PROTECTED] wrote: i'm compiling php5.1 using php zend_vm_gen.php --with-vm-kind=GOTO (or SWITCH) and make it takes me 300 virtual mem to compile zend_execute.c without ending, hav eto CTRL+c to break CFLAGS: -g3 -O3 -Wall -march=pentium3 -pipe php5.1 is on the road, anyone insterested? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object Oriented PHP (5)
* Richard Lynch [EMAIL PROTECTED] : On Fri, June 24, 2005 12:56 pm, Josh Olson said: PHP has inspired me to become a better programmer. I have been actively reading books as well as online content to try to become better at designing and programming object oriented web applications. My primary focus is PHP. Will you help a pragmatic programmer in training out by suggesting some worthwhile resources? I have read the following already: snip I didn't read any of those books. snip One other piece of advice: Write lots and lots of code. Lots of it. Amen. Only after approaching similar problems several times will you find a more general, elegant solution that could solve all of them. It's the repetition of the problem, and the differing approaches that inform your ability to program towards it. The only way to get there is doing lots of coding. Re-write some old code of your own. Amazingly instructive, and often leads you to new heights. Plus your old stuff suddenly has a lower maintenance cost, for some odd reason... :-) I do this all the time. It's invaluable. Sometimes you find some little gems -- and most of the time you discover how much you've learnt since then, and you refactor it and make it better. Publish some articles or code snippets on your site. The act of trying to explain what you did to somebody else will open up worlds of understanding. You never really understand something until after you've taught it to somebody else. :-) I keep a blog, mostly about my PHP development. I do this in part for myself. If I act as if I'm explaining it for someone else, I often get to the meat of an issue or problem -- a place I might not have visited had I not spent that extra time trying to understand it enough to explain it. My blog has a public face, but it's really for myself. snip Try to work on a project with another developer. You may tear your hair out. You may want to kill them. You may learn a whole hell of a lot. Maybe what you learn is that a whole lot of developers just don't think like you do. That's okay too. At least, it's okay for me. :-) [shrug] I work with another developer, and we're constantly refactoring each other's code. But the brilliant part of it is that we then learn from each other as well. Do some code review for another developer some time. As Richard notes, writing lots of code will improve your coding ability; so will *reading* lots of code. snip Ooooh. At the risk of being branded a heretic, try to pick up another language or two. Start with something a whole lot like PHP. Maybe Perl, or even C. I wouldn't understand PHP half as well as I do if I didn't know perl already. I still use perl regularly; sometimes it's suited for the task. But that's another reason to learn other languages -- to determine when PHP is the right tool for the job, and when another language is. Well, that got long and philosophical, didn't it? Yes, but well worth th read. Thanks, Richard! -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upload and Read pdf file
Hi All, is possible to upload pdf file into MySQL database, then read in web browser using php? And how? Thanks for help rgds
[PHP] Conversion of period and space for $_GET, $_REQUEST, etc. is rather senseless
PHP imports GET and POST data to array elements by senselessly converting periods and spaces to underscore. The intent is to make strings variable-name compatible for conversion directly into global variables via import_request_variables or register_globals. String-to-variable name mangling should only occur when being converted to variable names, but should be left as is when accessed as array elements. The current implementation is particularly bad because it mangles only periods and spaces, but leaves alone other special/unusual characters. Furthermore, the direct conversion into global name space is discouraged for security reasons. A feature-request was made related to this, but it was marked as Won't Fix, primarily due to compatibility concerns. However, I think it's a poor design, and there must be some compatible way to move beyond this misfeature. Do other people really want to keep the period/space name mangling for array keys, and not just for variable names? And, what happens when importing other special characters to variable names? Joe Krhn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php