php-general Digest 23 Sep 2005 11:58:02 -0000 Issue 3698
php-general Digest 23 Sep 2005 11:58:02 - Issue 3698 Topics (messages 223035 through 223064): Re: basic user/input form questions... more validation! 223035 by: Jasper Bryant-Greene 223038 by: bruce 223039 by: Jasper Bryant-Greene 223041 by: Murray . PlanetThoughtful 223046 by: Chris Shiflett 223047 by: bruce 223050 by: Chris Shiflett Re: Suggestions for class design 223036 by: Manuel Lemos Re: Opensource webshop 223037 by: Chris Martin 223052 by: Gustav Wiberg 223053 by: Gustav Wiberg 223054 by: Gustav Wiberg 223055 by: Jasper Bryant-Greene 223056 by: Gustav Wiberg 223057 by: Vince LaMonica 223062 by: Mark Evans 223063 by: Gustav Wiberg Posting variables from one php script to another 223040 by: Graham Anderson 223043 by: Jasper Bryant-Greene 223044 by: Graham Anderson 223045 by: Jasper Bryant-Greene 223051 by: Graham Anderson ftp_site problem 223042 by: Al 223049 by: cron.odi.com.br 223064 by: Al Re: File complete check (FTP) 223048 by: cron.odi.com.br 223060 by: Johannes Tyra 223061 by: Jasper Bryant-Greene session clustering 223058 by: Jad Madi problem with php and mail() 223059 by: Marco Strullato Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- bruce wrote: not sure i agree with this one.. if i put foo \' cat in a db tbl... i expect that i'll get the same out... which is what some of the articles i've seen have stated.. are you telling me, and are you sure, that i'd get foo ' cat out instead!! the articles i've seen imply that if you addslashes, you also need to stripslashes on the backend... With all due respect, you are demonstrating a fundamental lack of understanding of the principle of escaping anything... The point of escaping the quote mark is so that it looks *exactly like a quote mark* to MySQL, rather than like the delimiter for a string value. MySQL treats the character sequence \' as ' when inside a string value. When you SELECT the data at the other end, MySQL will not give you the slashes, because the slashes are not stored in the database table. If you do run stripslashes() on the output, you will lose data in some situations. So don't. Hope that made sense and helped... -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ ---End Message--- ---BeginMessage--- one more question/issue... the mysql_real_escape function escapes with a'\' which works for mysql, but isn't standard ansi... is there another function that does the same thing, but uses the ansi standard '. also, if there is another function, does it also work with mysql?? thanks -bruce -Original Message- From: Jasper Bryant-Greene [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 4:39 PM To: php-general@lists.php.net Subject: Re: [PHP] basic user/input form questions... more validation! bruce wrote: not sure i agree with this one.. if i put foo \' cat in a db tbl... i expect that i'll get the same out... which is what some of the articles i've seen have stated.. are you telling me, and are you sure, that i'd get foo ' cat out instead!! the articles i've seen imply that if you addslashes, you also need to stripslashes on the backend... With all due respect, you are demonstrating a fundamental lack of understanding of the principle of escaping anything... The point of escaping the quote mark is so that it looks *exactly like a quote mark* to MySQL, rather than like the delimiter for a string value. MySQL treats the character sequence \' as ' when inside a string value. When you SELECT the data at the other end, MySQL will not give you the slashes, because the slashes are not stored in the database table. If you do run stripslashes() on the output, you will lose data in some situations. So don't. Hope that made sense and helped... -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- bruce wrote: the mysql_real_escape function escapes with a'\' which works for mysql, but isn't standard ansi... is there another function that does the same thing, but uses the ansi standard '. also, if there is another function, does it also work with mysql?? Well, you could just use str_replace. But what's the point? A whole lot of MySQL deviates from the standards, often for good reason, and often in ways that makes it easier to use or simply better. There's no functional
[PHP] problem with php and mail()
hi all, I have a problem sending mails with mail(): when this code runs: mail([EMAIL PROTECTED],ciao,ciao[EMAIL PROTECTED],%22ciao%22,%22ciao, From: marco marco@ [EMAIL PROTECTED] anotherexample.comhttp://anotherexample.com/ ); any email arrives: qmail tells @40004332b7d900edffbc delivery 548: deferral: 193.70.193.96_does_not_like_recipient./Remote_host_said:_450_[EMAIL PROTECTED]:_Sender_address_rejected:_Domain_not_found/Giving_up_on_193.70.193.96./[EMAIL PROTECTED]:_Sender_address_rejected:_Domain_not_found/Giving_up_on_193.70.193.96./ It is a misconfiguration of php.ini or qmail and I don't know what to look for: in php.ini I wrote [mail function] SMTP = localhost sendmail_from = [EMAIL PROTECTED] sendmail_path = /usr/sbin/sendmail (I've tryed to set a cmd line option for sendmail as sendmail -f [EMAIL PROTECTED] but it does not work...) and qmail is configured to accept only mails from localdomains. I think I have to set default address somewhere. tnks!! marco ps I've sent this message also in php-install ml but it is not arrived, so I crosspost it here
RE: [PHP] File complete check (FTP)
I don't know the local filezize. I have only the remote ftp file, uploaded on the server... PHP runs on the server, so the uploaded file remote ftp file (from the ftp user) is the file to check... -Original Message- From: Jake Gardner [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 1:05 AM To: Johannes Tyra Subject: Re: [PHP] File complete check (FTP) The simplest (albeit a dirtier) method is to just compare the filesize of the remote file to the local file. http://us2.php.net/filesize On 9/22/05, Johannes Tyra [EMAIL PROTECTED] wrote: Hello, i want to check if a file (jpg image) is completely uploaded on a server. If checked für the to last bytes (ffd9), but these method is not save. Anybody know how it works?? -- Mit freundlichem Gruß, | Johannes Tyra | --- | BrainData - InterNet Services | --- | Tel: +49.209.8181788 | Fax: +49.209.8181789 | --- | www.BrainData.de | mailto:[EMAIL PROTECTED] -- 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] File complete check (FTP)
Johannes Tyra wrote: I don't know the local filezize. I have only the remote ftp file, uploaded on the server... PHP runs on the server, so the uploaded file remote ftp file (from the ftp user) is the file to check... But you can run filesize() on the file before you upload it to the FTP server, and then filesize() on it afterwards... both from the server... if the two are equal then the file is complete. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opensource webshop
Are there many in just PHP to? I can name at least 7 or 8 that I know of :-) Most are multi-lingual so can work with any language and come with a full administration tool. Regards Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opensource webshop
- Original Message - From: Vince LaMonica [EMAIL PROTECTED] To: Jasper Bryant-Greene [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Friday, September 23, 2005 7:17 AM Subject: Re: [PHP] Opensource webshop On Fri, 23 Sep 2005, Jasper Bryant-Greene wrote: } There are probably dozens of free open source PHP carts already out } there. Not to mention the ones written in Perl. } } Are there many in just PHP to? } } As he said, there are probably dozens. Four of the PHP-based ones are listed } under e-Commerce on this website: } } http://www.opensourcecms.com/ A few more PHP ones [including the 4 at the above URL]: http://www.shop-script.com/php-shopping-cart-software-1.html http://www.zen-cart.com/ http://www.oscommerce.com/ http://www.x-cart.com/articles/x-cart_open_source.html http://creloaded.com/index.php http://www.osc2nuke.com/ http://cpcommerce.org/ http://www.cubecart.com/site/home/ [not OSS, but free if (c) is not modified] http://siliconsys.com/content/applications/phpcatalog/ http://www.terraserver.de/terraserver.php3 http://www.ecommerceshoppingcartsoftware.org/ http://open.appideas.com/MyCart/ http://cosmicphp.com/freescripts_cosmicshoppingcart.php http://www.affcommerce.com/ http://developer.berlios.de/projects/oos/ http://www.soft4e.com/loadshop.html https://sourceforge.net/project/showfiles.php?group_id=83355release_id=166221 http://scripts.justwilliams.com/amazon/index.htm And more can be found via google and php.resourceindex.com /vjl/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 Hi there! Thanx for the response about opensource- e-commerce solutions. Now I think I have a better picture of the situation about opensource e-commerce... :-) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_site problem
[EMAIL PROTECTED] wrote: try: if(ftp_site($conn_id, SITE chmod 0777 /public_html/EditPage/cd_ef_W.txt)) echo 'successful'; else 'failed'; it works for me Crom - Original Message - From: Al [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, September 22, 2005 9:34 PM Subject: [PHP] ftp_site problem I can't get ftp_site() to chmod a file. WS_FTP utility changes them OK. I can connect and log-in via ftp OK Then I send if(ftp_site($conn_id, chmod 0777 /public_html/EditPage/cd_ef_W.txt)) echo 'successful'; else 'failed'; And get successful OK But, the file's permissions don't change. Have tried 777 as well as 0777. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the conformation Crom. It looks a virtual server problem. I've got my host's tech support working on it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Posting variables from one php script to another
Graham Anderson wrote: I am using GET to send variables from one php script to another php script How would I POST the same variables ? This is the php script I am sending GET variables to... $movieBuilder = ./movieBuilder.php?mask=mask.gifdrag=drag.gifmovie=fonovisa.mov; I am placing $movieBuilder in the src = attribute Is it possible to POST these same variables to movieBuilder.php ? The below generates a Quicktime movie: $xml = EOB ?xml version=1.0? ?quicktime type=application/x-quicktime-media-link? embed autoplay=$autoplay cache=$cache kioskmode=$kioskmode quitwhendone=$quitwhendone movieid=$movieid moviename=$moviename src=$movieBuilder/ EOB; many thanks I'd use this. It's simple and doesn't involve CURL. Here is a brief outline. $file_str= base64encode(serialize($_GET)); //$_GET can be any array Create a temporary file and write your string fwrite($temp, $file_str); fetch your data with $saved_get= unserialize(base64decode(file_get_contents(filename)); Unlink your file when done with it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
Al wrote: I'd use this. It's simple and doesn't involve CURL. Here is a brief outline. $file_str= base64encode(serialize($_GET)); //$_GET can be any array Any reason why you base64_encode here? fwrite is binary-safe so base64 encoding your data is slow and a waste of space. Create a temporary file and write your string fwrite($temp, $file_str); fetch your data with $saved_get= unserialize(base64decode(file_get_contents(filename)); Unlink your file when done with it. Rather than resort to the slow process of creating, writing, reading and deleting a file for every request (not to mention generating a unique ID to prevent collisions with simultaneous requests), I'd be more tempted to find out exactly why the OP couldn't get it working with GET variables. Perhaps he could post some more code, as I regularly pass GET variables to PHP scripts through img tags and the like with no problems whatsoever. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Re: newbie questionsession and cookie by javascript
Thanks. -- Forwarded message -- From: Ben [EMAIL PROTECTED] Date: Sep 22, 2005 5:29 PM Subject: [PHP] Re: newbie questionsession and cookie by javascript To: php-general@lists.php.net Alex Andrew Mosqueda said the following on 09/22/05 06:28: Hi! I there a way I can get the cookie data stored by javascript(client side) in php(server side) and vice versa? Thanks. It never hurts to check php.net http://php.net, plenty of useful information there... $_cookie['cookie name'] http://ca3.php.net/manual/en/features.cookies.php - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gettext() troubles
Hello List, I am facing some troubles with gettext. phpinfo() says that both of gettext and iconv extensions are installed properly, I can call gettext() function but it never translates my strings returning the original key every time. Here is the code: ?php putenv(LANG=ru_RU); setlocale (LC_ALL,ru); $domain = 'messages'; echo bindtextdomain ($domain, 'D:\intranet\wwwroot\lng'); echo textdomain ($domain); echo bind_textdomain_codeset($domain, 'UTF-8'); echo gettext(string); ? Below is the output: D:\intranet\wwwroot\lng messages UTF-8 string All of the language files are in the following location: D:\intranet\wwwroot\lng\ru\LC_MESSAGES\ D:\intranet\wwwroot\lng\ru\LC_MESSAGES\messages.po D:\intranet\wwwroot\lng\ru\LC_MESSAGES\messages.mo The files were created with poEdit utility and look fine. Any help would be greatly appreciated. Have a great day, Denis S Gerasimov Web Developer Team Force LLC Web:http://www.team-force.org/ www.team-force.org RU Int'l: +7 8362-468693 email:[EMAIL PROTECTED]
[PHP] PHP in a commandline shell?
Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gettext() troubles
Denis Gerasimov wrote: ?php putenv(LANG=ru_RU); setlocale (LC_ALL,ru); $domain = 'messages'; echo bindtextdomain ($domain, 'D:\intranet\wwwroot\lng'); echo textdomain ($domain); echo bind_textdomain_codeset($domain, 'UTF-8'); echo gettext(string); ? Here's what I use to set my language (to French in this case). It works 100% of the time for me: // Set locale to preferred language setlocale(LC_ALL, 'fr_FR'); bindtextdomain('messages', $_SERVER['DOCUMENT_ROOT'].'/locale'); textdomain('messages'); I don't do the putenv line that you have, so I'm not sure if it's necessary... -- Aaron Gould Programmer/Systems Administrator PARTS CANADA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: gettext() troubles
Hi Denis Gerasimov, you wrote: I am facing some troubles with gettext. ... putenv(LANG=ru_RU); Speaking from my experience, you need to use only ru there on Windows... setlocale (LC_ALL,ru); ...but you definitly have to use the Windows abbreviation for the corresponding locale in the setlocale call. Have a look at PEARs I18Nv2 module which attempts to solve this discrepancy. Regards, -- Michael - mike(@)php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gettext() troubles
Aaron Gould wrote: Denis Gerasimov wrote: ?php putenv(LANG=ru_RU); setlocale (LC_ALL,ru); $domain = 'messages'; echo bindtextdomain ($domain, 'D:\intranet\wwwroot\lng'); echo textdomain ($domain); echo bind_textdomain_codeset($domain, 'UTF-8'); echo gettext(string); ? anyone who has worked with locales on different machines/platforms will probably run into the problem that locales are different and/or differently named on alot of systems... for this reason (I believe) set_locale() allows you to pass an array of locale names as the second arg - the first one found will be used... e.g. (I use dutch locales alot): setlocale( LC_ALL, array('[EMAIL PROTECTED]', 'nl_NL', 'nld_nld', 'Dutch', 'Dutch_Netherlands.1252', 'nl_NL.ISO8859-1', 'nl') ); maybe that helps a bit. Here's what I use to set my language (to French in this case). It works 100% of the time for me: // Set locale to preferred language setlocale(LC_ALL, 'fr_FR'); bindtextdomain('messages', $_SERVER['DOCUMENT_ROOT'].'/locale'); textdomain('messages'); I don't do the putenv line that you have, so I'm not sure if it's necessary... it sometimes is I believe - depends on your setup (e.g. if your using CGI version) - don't hold me to that I could be completely wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opensource webshop
Jasper Bryant-Greene wrote: There are probably dozens of free open source PHP carts already out there. Not to mention the ones written in Perl. Are there many in just PHP to? As he said, there are probably dozens. Four of the PHP-based ones are listed under e-Commerce on this website: http://www.opensourcecms.com/ And the 100+ listed here http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
Gustav Wiberg wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Depends on your version of php, and how it was installed. PHP versions 4.2.x you had to turn it _on_ when configuring. 4.3.x, you had to turn it _off_. PHP versions older than 4.2.0 there was the CGI API which you could use on the command line. Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
That depends on several things, chief among which are: What version did you install? What options did you supply ./configure? **Did you delete your old install?** The reason for that is because the difference between the CLI and CGI versions of PHP is the binary which is installed. However, while only one is installed, both are compiled (assuming you didnt supply certain configure options pseudooption --without-cli /pseudooption. When I replaced the CGI version with CLI, I just overwrote the existing and INSTALLED php binary (the CGI one) with the CLI binary in your install folder. (Assuming you kept the old one) On 9/23/05, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- 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 in a commandline shell?
- Original Message - From: Jake Gardner [EMAIL PROTECTED] To: Gustav Wiberg [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Sent: Friday, September 23, 2005 4:36 PM Subject: Re: [PHP] PHP in a commandline shell? That depends on several things, chief among which are: What version did you install? What options did you supply ./configure? **Did you delete your old install?** The reason for that is because the difference between the CLI and CGI versions of PHP is the binary which is installed. However, while only one is installed, both are compiled (assuming you didnt supply certain configure options pseudooption --without-cli /pseudooption. When I replaced the CGI version with CLI, I just overwrote the existing and INSTALLED php binary (the CGI one) with the CLI binary in your install folder. (Assuming you kept the old one) On 9/23/05, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 Thanx! /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
- Original Message - From: John Nichel [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Friday, September 23, 2005 4:34 PM Subject: Re: [PHP] PHP in a commandline shell? Gustav Wiberg wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Depends on your version of php, and how it was installed. PHP versions 4.2.x you had to turn it _on_ when configuring. 4.3.x, you had to turn it _off_. PHP versions older than 4.2.0 there was the CGI API which you could use on the command line. Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 Thanx! /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] basic user/input form questions... more validation!
chris... i understood the concept of data being output from an application/function. my question was directed towards trying to understand if you were meaning that an app should escape all output from the mysql db?? or, were you referring to data that would go back to the user via a form? in other words, which 'output' function are/were you referring to. -bruce ps. tried to get to the link... it wouldn't come up for me for some reason... -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 8:38 PM To: [EMAIL PROTECTED] Cc: 'Chris W. Parker'; php-general@lists.php.net Subject: Re: [PHP] basic user/input form questions... more validation! bruce wrote: but what do you mean by ...escape output!! Output is data that you send somewhere else. In other words, if it leaves your application, it is output. This is explained a bit further (with some code) near the start of this talk: http://brainbulb.com/talks/php-security-audit-howto.pdf Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
Gustav Wiberg wrote: - Original Message - From: John Nichel [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Friday, September 23, 2005 4:34 PM Subject: Re: [PHP] PHP in a commandline shell? Gustav Wiberg wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Depends on your version of php, and how it was installed. PHP versions 4.2.x you had to turn it _on_ when configuring. 4.3.x, you had to turn it _off_. PHP versions older than 4.2.0 there was the CGI API which you could use on the command line. Thanx! At the command line, do a 'which php' -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Subtracting dates w/o database interaction (MySQL)
Hey all. I'm needing to find the number of days between two dates without using an database functions (DATE_SUB, etc)... only PHP. Is there an easy way to accomplish this? I have searched the PHP site, but have not been successful in finding anything that will assist me. Any help would be appreciated. Thanks, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] selfreferencing script with output
Hello to all, I have 2 scripts ( preparing about 1000 mails for pear's mail-queue and sending them) which shall be started by the user. There are - limitations of the provider for the duration of the scripts - no cronjobs So I had the idea to write a selfreferencing script like that: $begin= intval($_GET[begin]); $allMails = 1000; //... prepare / send a portion of for example 50 mails if (($begin+ 50) $allMails) { header(Location: script.php?begin=.($begin+ 50)); } else { echo Done!; } But I want to show the user some output like a statusbar (eventually with pear's Html_Progress) or something like that so he knows the script is still working. Has anybody of you an idea, a tip for me how to do it? I don't see how I can do it within the construct above. Is there an alternative to it? Thanks in advance for your answers Sabine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Subtracting dates w/o database interaction (MySQL)
Philip Thompson mailto:[EMAIL PROTECTED] on Friday, September 23, 2005 9:12 AM said: I'm needing to find the number of days between two dates without using an database functions (DATE_SUB, etc)... only PHP. Is there an easy way to accomplish this? I have searched the PHP site, but have not been successful in finding anything that will assist me. Any help would be appreciated. There might be an easier way but... convert to timestamp, subtract smaller number from bigger number, figure out how much time has passed. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] basic user/input form questions... more validation!
You should be careful about column types in mysql especially if you are doing joins. For example: mysql create temporary table justsomeresearch(foo varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justsomeresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into justsomeresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql select * from justsomeresearch; +--+ | foo | +--+ | 3| | 3| +--+ 2 rows in set (0.00 sec) mysql create temporary table justmoreresearch(bar varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; +--+--+ | bar | foo | +--+--+ | 3| 3| | 3| 3| +--+--+ 2 rows in set (0.00 sec) See this works because both the number version and the 'char' version are the same.. but let's do something else mysql update justsomeresearch set foo = '03' where foo=3; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql select * from justsomeresearch; +--+ | foo | +--+ | 03 | | 03 | +--+ 2 rows in set (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; Empty set (0.00 sec) You see.. because the '03' is not the same as 3 it doesn't join, you would either have to have both columns as ints or make sure both columns were in the same format as a char. Now let's look at int column type mysql create temporary table evenmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(bar int(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into evenmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into evenmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('03'); Query OK, 1 row affected (0.00 sec) mysql select * from evenmoreresearch, andmoreresearch where bar = foo; +--+--+ | foo | bar | +--+--+ |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | +--+--+ 6 rows in set (0.00 sec) mysql select * from evenmoreresearch; +--+ | foo | +--+ |3 | |3 | +--+ 2 rows in set (0.00 sec) mysql select * from andmoreresearch; +--+ | bar | +--+ |3 | |3 | |3 | +--+ 3 rows in set (0.00 sec) You get some rather curious results. I've even switched the names around and it comes out with 6 results, exactly the same (or least as exactly as data to a php script would be). So if you're joining in mysql it's good to insert your data as ints into integer columns and 'char' or 'strings' when inserting into varchar, char or text columns (although why you would join text columns I have no idea). And this was only straight joins.. imagine what left right or other joins would look like. Carl Furst Vote.com P.O. Box 7 Georgetown, Ct 06829 203-544-8252 [EMAIL PROTECTED] -Original Message- From: Chris W. Parker [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 6:42 PM To: php-general@lists.php.net Subject: RE: [PHP] basic user/input form questions... more validation! bruce mailto:[EMAIL PROTECTED] on Thursday, September 22, 2005 3:33 PM said: further investigation seems to imply that 'strings' that are to be inserted into the mysql db should be 'backslashed' for the chars \x00, \n, \r, \,', and \x1a. That's what escaping is. the mysql_real_escape_string function requires a db connection and the app might not have opened up a connection to the db at this point in the code.. (or i could rewrite the code!!) Unless you have warnings print to the screen you should be fine. Or you could just suppress the errors on that one function. numeric data: -doesn't need quoting, but it shouldn't hurt to quote anyway.. (quote all numeric values inserted in the db...) -but wouldn't this require the app to detect numeric vals in the db, and to convert the 'type'!!) No. Why would it? If you quote everything then there's no need to check for type. -how does this affect date/float vars... I'm not sure. Check the MySQL manual on column types. extracting data from the db: numeric data -get the data/val from the db -check the type/convert the db to int/float/date/etc... No type conversion is necessary. PHP is a loose typed language. string data -get the vals from the db, -strip any slashes that were added to the data/vars -process/use accordingly... As I said in my previous email,
RE: [PHP] basic user/input form questions... more validation!
which is why it's critical/important to really lay out (architect) your app and to think about how the app should be handling various data types. this also goes to thiking about how you name variables in your app. all of this is really software design 101 -bruce -Original Message- From: Carl Furst [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 9:48 AM To: 'Chris W. Parker'; php-general@lists.php.net Subject: RE: [PHP] basic user/input form questions... more validation! You should be careful about column types in mysql especially if you are doing joins. For example: mysql create temporary table justsomeresearch(foo varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justsomeresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into justsomeresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql select * from justsomeresearch; +--+ | foo | +--+ | 3| | 3| +--+ 2 rows in set (0.00 sec) mysql create temporary table justmoreresearch(bar varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; +--+--+ | bar | foo | +--+--+ | 3| 3| | 3| 3| +--+--+ 2 rows in set (0.00 sec) See this works because both the number version and the 'char' version are the same.. but let's do something else mysql update justsomeresearch set foo = '03' where foo=3; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql select * from justsomeresearch; +--+ | foo | +--+ | 03 | | 03 | +--+ 2 rows in set (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; Empty set (0.00 sec) You see.. because the '03' is not the same as 3 it doesn't join, you would either have to have both columns as ints or make sure both columns were in the same format as a char. Now let's look at int column type mysql create temporary table evenmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(bar int(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into evenmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into evenmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('03'); Query OK, 1 row affected (0.00 sec) mysql select * from evenmoreresearch, andmoreresearch where bar = foo; +--+--+ | foo | bar | +--+--+ |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | +--+--+ 6 rows in set (0.00 sec) mysql select * from evenmoreresearch; +--+ | foo | +--+ |3 | |3 | +--+ 2 rows in set (0.00 sec) mysql select * from andmoreresearch; +--+ | bar | +--+ |3 | |3 | |3 | +--+ 3 rows in set (0.00 sec) You get some rather curious results. I've even switched the names around and it comes out with 6 results, exactly the same (or least as exactly as data to a php script would be). So if you're joining in mysql it's good to insert your data as ints into integer columns and 'char' or 'strings' when inserting into varchar, char or text columns (although why you would join text columns I have no idea). And this was only straight joins.. imagine what left right or other joins would look like. Carl Furst Vote.com P.O. Box 7 Georgetown, Ct 06829 203-544-8252 [EMAIL PROTECTED] -Original Message- From: Chris W. Parker [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 6:42 PM To: php-general@lists.php.net Subject: RE: [PHP] basic user/input form questions... more validation! bruce mailto:[EMAIL PROTECTED] on Thursday, September 22, 2005 3:33 PM said: further investigation seems to imply that 'strings' that are to be inserted into the mysql db should be 'backslashed' for the chars \x00, \n, \r, \,', and \x1a. That's what escaping is. the mysql_real_escape_string function requires a db connection and the app might not have opened up a connection to the db at this point in the code.. (or i could rewrite the code!!) Unless you have warnings print to the screen you should be fine. Or you could just suppress the errors on that one function. numeric data: -doesn't need quoting, but it shouldn't hurt to quote anyway.. (quote all numeric values inserted in the db...) -but wouldn't this require the app to detect numeric vals in the db, and to convert the 'type'!!) No. Why would it? If you quote everything then there's no need to check for
Re: [PHP] selfreferencing script with output
On 9/23/05, Sabine [EMAIL PROTECTED] wrote: Hello to all, I have 2 scripts ( preparing about 1000 mails for pear's mail-queue and sending them) which shall be started by the user. There are - limitations of the provider for the duration of the scripts - no cronjobs So I had the idea to write a selfreferencing script like that: $begin= intval($_GET[begin]); $allMails = 1000; //... prepare / send a portion of for example 50 mails if (($begin+ 50) $allMails) { header(Location: script.php?begin=.($begin+ 50)); } else { echo Done!; } But I want to show the user some output like a statusbar (eventually with pear's Html_Progress) or something like that so he knows the script is still working. instead of simply headering the location out, you could simply output a html page, that has a meta tag to replace it. maybe something like html/head/meta tag here body ?php $full_width = 200; $amt_sent = $_GET['begin'] + 50; $amt_to_send = 1000; $img_width = ceil($amt_sent * $full_width / $amt_to_send); ? img src=pixel.php height=20 width=?php echo $img_width; ? ?php flush(); send_the_mails(); ? Has anybody of you an idea, a tip for me how to do it? I don't see how I can do it within the construct above. Is there an alternative to it? This doesn't necessarly need to be done using a self-referencing script. You could have an ajax type system where each script is accessed sequentially. Thanks in advance for your answers Sabine -- 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] basic user/input form questions... more validation!
bruce mailto:[EMAIL PROTECTED] on Friday, September 23, 2005 10:46 AM said: which is why it's critical/important to really lay out (architect) your app and to think about how the app should be handling various data types. this also goes to thiking about how you name variables in your app. all of this is really software design 101 Oh whatever, I don't quote everything in my own apps anyway. You just seem to be so confused about this whole thing* that it'd be easier for you to just quote everything and escape everything and run everything through htmlspecialchars(). Chris. * Not that I'm not completely confused about other subjects myself. And doesn't anyone know how to trim anymore? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] basic user/input form questions... more validation!
That may be true, but the point about php being loosely typed is valid.. Although there are cast functions in php, you can store integers in strings and vice versa.. and move them around as much as you want... When you declare a variable it has no type and is not associated with any class per se, AND you can do most of the things you were talking about like putting quotes around all your input into the database. I was just saying that if you want to do joins you need to be more careful and match your data with the column type so you should quote data going into a varchar field and not quote numbers going into an int field and vice versa otherwise your joins are going to get screwed up and that's not something they teach you in software 101... Peace, Carl Furst Vote.com P.O. Box 7 Georgetown, Ct 06829 203-544-8252 [EMAIL PROTECTED] -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 1:46 PM To: 'Carl Furst'; 'Chris W. Parker'; php-general@lists.php.net Subject: RE: [PHP] basic user/input form questions... more validation! which is why it's critical/important to really lay out (architect) your app and to think about how the app should be handling various data types. this also goes to thiking about how you name variables in your app. all of this is really software design 101 -bruce -Original Message- From: Carl Furst [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 9:48 AM To: 'Chris W. Parker'; php-general@lists.php.net Subject: RE: [PHP] basic user/input form questions... more validation! You should be careful about column types in mysql especially if you are doing joins. For example: mysql create temporary table justsomeresearch(foo varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justsomeresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into justsomeresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql select * from justsomeresearch; +--+ | foo | +--+ | 3| | 3| +--+ 2 rows in set (0.00 sec) mysql create temporary table justmoreresearch(bar varchar(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into justmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; +--+--+ | bar | foo | +--+--+ | 3| 3| | 3| 3| +--+--+ 2 rows in set (0.00 sec) See this works because both the number version and the 'char' version are the same.. but let's do something else mysql update justsomeresearch set foo = '03' where foo=3; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql select * from justsomeresearch; +--+ | foo | +--+ | 03 | | 03 | +--+ 2 rows in set (0.00 sec) mysql select * from justmoreresearch, justsomeresearch where bar = foo; Empty set (0.00 sec) You see.. because the '03' is not the same as 3 it doesn't join, you would either have to have both columns as ints or make sure both columns were in the same format as a char. Now let's look at int column type mysql create temporary table evenmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(foo int(10)); Query OK, 0 rows affected (0.00 sec) mysql create temporary table andmoreresearch(bar int(10)); Query OK, 0 rows affected (0.00 sec) mysql insert into evenmoreresearch values(3); Query OK, 1 row affected (0.00 sec) mysql insert into evenmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values(03); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('3'); Query OK, 1 row affected (0.00 sec) mysql insert into andmoreresearch values('03'); Query OK, 1 row affected (0.00 sec) mysql select * from evenmoreresearch, andmoreresearch where bar = foo; +--+--+ | foo | bar | +--+--+ |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | |3 |3 | +--+--+ 6 rows in set (0.00 sec) mysql select * from evenmoreresearch; +--+ | foo | +--+ |3 | |3 | +--+ 2 rows in set (0.00 sec) mysql select * from andmoreresearch; +--+ | bar | +--+ |3 | |3 | |3 | +--+ 3 rows in set (0.00 sec) You get some rather curious results. I've even switched the names around and it comes out with 6 results, exactly the same (or least as exactly as data to a php script would be). So if you're joining in mysql it's good to insert your data as ints into integer columns and 'char' or 'strings' when inserting into varchar, char or text columns (although why you would join text columns I have no idea). And this was only straight joins.. imagine what left right or other joins would look like.
Re: [PHP] Subtracting dates w/o database interaction (MySQL)
- Original Message - From: Philip Thompson [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, September 23, 2005 6:11 PM Subject: [PHP] Subtracting dates w/o database interaction (MySQL) Hey all. I'm needing to find the number of days between two dates without using an database functions (DATE_SUB, etc)... only PHP. Is there an easy way to accomplish this? I have searched the PHP site, but have not been successful in finding anything that will assist me. Any help would be appreciated. Thanks, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 Hi there! Take a look at http://www.varupiraten.se/opensource/doc.php?subject=datefunctions.php#datefunctions.php I hope this will help you... :-) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
- Original Message - From: John Nichel [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Friday, September 23, 2005 4:34 PM Subject: Re: [PHP] PHP in a commandline shell? Gustav Wiberg wrote: Hi there! As I understand you MUST? recompile PHP for use with only commandlineshell instead of for example Apache (or any other webserver) Depends on your version of php, and how it was installed. PHP versions 4.2.x you had to turn it _on_ when configuring. 4.3.x, you had to turn it _off_. PHP versions older than 4.2.0 there was the CGI API which you could use on the command line. Is that true? Or is there any alternative if you only want to use PHP in shell-mode for testing... /G http://www.varupiraten.se/ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 With PHPinfo() I get this result on my local testserver which has Windows XP running Apache Can I then use Shell? What command do I use for waiting for user input? Totally novice in this area of PHP... PHP Version 4.3.10 System Windows NT BLACKSHADOW 5.1 build 2600 Build Date Dec 14 2004 17:46:48 Server API CGI/FastCGI Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS\php.ini PHP API 20020918 PHP Extension 20020429 Zend Extension 20021010 Debug Build no Thread Safety enabled Registered PHP Streams php, http, ftp, compress.zlib /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
Gustav Wiberg wrote: snip With PHPinfo() I get this result on my local testserver which has Windows XP running Apache Can I then use Shell? What command do I use for waiting for user input? Totally novice in this area of PHP... PHP Version 4.3.10 System Windows NT BLACKSHADOW 5.1 build 2600 Build Date Dec 14 2004 17:46:48 Server API CGI/FastCGI Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS\php.ini PHP API 20020918 PHP Extension 20020429 Zend Extension 20021010 Debug Build no Thread Safety enabled Registered PHP Streams php, http, ftp, compress.zlib http://us3.php.net/features.commandline -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] selfreferencing script with output
- Original Message - From: Sabine [EMAIL PROTECTED] To: PHP general php-general@lists.php.net Sent: Friday, September 23, 2005 6:14 PM Subject: [PHP] selfreferencing script with output Hello to all, I have 2 scripts ( preparing about 1000 mails for pear's mail-queue and sending them) which shall be started by the user. There are - limitations of the provider for the duration of the scripts - no cronjobs So I had the idea to write a selfreferencing script like that: $begin= intval($_GET[begin]); $allMails = 1000; //... prepare / send a portion of for example 50 mails if (($begin+ 50) $allMails) { header(Location: script.php?begin=.($begin+ 50)); } else { echo Done!; } But I want to show the user some output like a statusbar (eventually with pear's Html_Progress) or something like that so he knows the script is still working. Has anybody of you an idea, a tip for me how to do it? I don't see how I can do it within the construct above. Is there an alternative to it? Thanks in advance for your answers Sabine Hi I don't know if this works, but I think it ought to work: Set a picture (a line) with width 1, next iteration set the line to width 2, next to width 3... OR set a picture with width % off count of mails Change picture with dhtml (or if you prefer Javascript and css ;-)) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] basic user/input form questions... more validation!
bruce mailto:[EMAIL PROTECTED] on Thursday, September 22, 2005 4:19 PM said: the articles i've seen imply that if you addslashes, you also need to stripslashes on the backend... That's probably because gpc_magic_quotes (I think that's what it's called) is turned on and doing addslashes will double escape everything leaving you with a \ in the db. No escaping: Hello, I'm... Result after db insertion: Error, cannot insert gpc_magic_quotes: Hello, I\'m... Result after db insertion: Hello, I'm... gpc_magic_quotes + addslahes: Hello, I\\\'m... Result after db insertion: Hello, I\'m... So when you retrieve the data you would indeed have to do stripslashes() because escapging is being done wrong. With distributed apps it's a good practice to determine whether or not gpc_magic_quotes is turned on and then act accordingly. I don't know if mysql_real_escape_string() is subject to over escaping or not. You'd have to test it. Hth, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
The below method is the way I send variables to the movieBuilder.php file [located in the 'src' attribute] with GET Variables It does work :) How would I use CURL to POST the same variables to the movieBuilder.php file WITHIN the 'src' attribute ? FYI, I am able to POST to the movieBuilder.php file as the POSTed variables are properly echo'd when I look at the buffer I would assume it would not be much different than Posting variables to a GD script to create a dynamic image // With GET--Does Work // Build the XML file $xml = EOB ?xml version=1.0? ?quicktime type=application/x-quicktime-media-link? embed src=./movieBuilder.php? mask=mask.gifdrag=drag.gifmovie=fonovisa.mov/ EOB; } // output the QT movie header('Content-Type: application/x-quicktimeplayer'); header (Content-Length:.strlen($xml)); echo $xml; // With POST // Build the XML file $xml = EOB ?xml version=1.0? ?quicktime type=application/x-quicktime-media-link? embed src=SOMEHOW CALL THE 'CURLME' FUNCTION/ EOB; } // output the QT movie header('Content-Type: application/x-quicktimeplayer'); header (Content-Length:.strlen($xml)); echo $xml; Function curlme(){ $ch = curl_init (path2myScript/movieBuilder.php); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST,1); curl_setopt ($ch, CURLOPT_POSTFIELDS, mask=mask.gifdrag=drag.gifmovie=fonovisa.mov); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($ch); // execute the post //echo $buffer; curl_close ($ch); } anyone know how to do this ? Is it too complicated to be worth it ? I just want to avoid GET when possible many thanks g On Sep 23, 2005, at 5:57 AM, Jasper Bryant-Greene wrote: Al wrote: I'd use this. It's simple and doesn't involve CURL. Here is a brief outline. $file_str= base64encode(serialize($_GET)); //$_GET can be any array Any reason why you base64_encode here? fwrite is binary-safe so base64 encoding your data is slow and a waste of space. Create a temporary file and write your string fwrite($temp, $file_str); fetch your data with $saved_get= unserialize(base64decode(file_get_contents(filename)); Unlink your file when done with it. Rather than resort to the slow process of creating, writing, reading and deleting a file for every request (not to mention generating a unique ID to prevent collisions with simultaneous requests), I'd be more tempted to find out exactly why the OP couldn't get it working with GET variables. Perhaps he could post some more code, as I regularly pass GET variables to PHP scripts through img tags and the like with no problems whatsoever. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to encrypt a readfile($file) on the fly ?
is it possible to encypt a file dynamically as it is being readfile'd ? I want to create a key stored in a db that decrypts the file once it reaches the user's computer. This file is being progressively loaded...loads and plays at the same time something like: header(ETag: .md5(time())); header(Accept-Ranges: bytes); header (Content-Length: .fileSize($file2Encrypt)); header(Content-Type: .$mime); readfile_whileEncrypting($file2Encrypt,MCRYPT_3DES)); is there a PHP function out there that can do this ? g -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Subtracting dates w/o database interaction (MySQL)
On Sep 23, 2005, at 11:16 AM, Chris W. Parker wrote: Philip Thompson mailto:[EMAIL PROTECTED] on Friday, September 23, 2005 9:12 AM said: I'm needing to find the number of days between two dates without using an database functions (DATE_SUB, etc)... only PHP. Is there an easy way to accomplish this? I have searched the PHP site, but have not been successful in finding anything that will assist me. Any help would be appreciated. There might be an easier way but... convert to timestamp, subtract smaller number from bigger number, figure out how much time has passed. Chris. I actually discovered how to do this right after I made the post. I looked at some archives and worked this out. code // today - 9/23/05 $start = mktime(0, 0, 0, date(m), date(d), date(Y)); // the objective day - 3/15/06 $end = mktime(0, 0, 0, 3, 15, 2006); // subtract today from the objective and divide by 24*60*60 to get days $difference = ceil(($end - $start) / (86400)); /code Thanks for your assistance. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
Graham Anderson wrote: The below method is the way I send variables to the movieBuilder.php file [located in the 'src' attribute] with GET Variables It does work :) How would I use CURL to POST the same variables to the movieBuilder.php file WITHIN the 'src' attribute ? You can't. Browsers make a GET request for the URL listed in the /src/ attribute, and there's nothing you can do about that. PHP doesn't have anything to do with that /src/ attribute, it just prints it out and the browser parses it. On recent Mozilla browsers you can use XMLHTTPRequest to fetch a base64-encoded stream of your data and write it to the src attribute within a data: URI scheme, but that won't work on IE or many other browsers. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP in a commandline shell?
- Original Message - From: John Nichel [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Friday, September 23, 2005 8:35 PM Subject: Re: [PHP] PHP in a commandline shell? Gustav Wiberg wrote: snip With PHPinfo() I get this result on my local testserver which has Windows XP running Apache Can I then use Shell? What command do I use for waiting for user input? Totally novice in this area of PHP... PHP Version 4.3.10 System Windows NT BLACKSHADOW 5.1 build 2600 Build Date Dec 14 2004 17:46:48 Server API CGI/FastCGI Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS\php.ini PHP API 20020918 PHP Extension 20020429 Zend Extension 20021010 Debug Build no Thread Safety enabled Registered PHP Streams php, http, ftp, compress.zlib http://us3.php.net/features.commandline -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 2005-09-22 Hi! Thanx for link. That was helpful! /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is PHP the language for me???
I am trying to figure out whether php will help me to set up a website which is essentially just links to donwloadable material. I have directories in place and am using flash to auto fill the directory names on to an index page, however i cant use this to access the files themselves. So I am after a language i can use to read all the file names in the directory and display them with a bit of 'niceness' onto a webpage so as they can be used as links to the files. Thanks
Re: [PHP] Is PHP the language for me???
Emily McCall [EMAIL PROTECTED] wrote on 09/23/2005 03:07:39 PM: I am trying to figure out whether php will help me to set up a website which is essentially just links to donwloadable material. Emily, you certainly came to the right place to get an endorsement of PHP ;) Yes. PHP will handle your task nicely, and IMHO, it is the easiest language to learn and use for dynamic web programming. Dig in and enjoy! Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
thanks Well, I had to try As an alternative, if I: 1) posted variables to a script with curl $ch = curl_init (path2myScript/movieBuilder.php); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST,1); curl_setopt ($ch, CURLOPT_POSTFIELDS, mask=mask.gifdrag=drag.gifmovie=fonovisa.mov); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($ch); // execute the post //echo $buffer; curl_close ($ch); } 2) write the 'src' attribute as './movieBuilder.php' with no variables passed $xml = EOB ?xml version=1.0? ?quicktime type=application/x-quicktime-media-link? embed src=./movieBuilder.php/ EOB; Would the movieBuilder.php file retain the POST'ed variables ? Or, would they be lost in the void. maybe this approach is silly? g On Sep 23, 2005, at 1:25 PM, Jasper Bryant-Greene wrote: Graham Anderson wrote: The below method is the way I send variables to the movieBuilder.php file [located in the 'src' attribute] with GET Variables It does work :) How would I use CURL to POST the same variables to the movieBuilder.php file WITHIN the 'src' attribute ? You can't. Browsers make a GET request for the URL listed in the /src/ attribute, and there's nothing you can do about that. PHP doesn't have anything to do with that /src/ attribute, it just prints it out and the browser parses it. On recent Mozilla browsers you can use XMLHTTPRequest to fetch a base64-encoded stream of your data and write it to the src attribute within a data: URI scheme, but that won't work on IE or many other browsers. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- 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] Is PHP the language for me???
I have directories in place and am using flash to auto fill the directory names on to an index page, however i cant use this to access the files themselves. So I am after a language i can use to read all the file names in the directory and display them with a bit of 'niceness' onto a webpage so as they can be used as links to the files. PHP is capable of doing that. I'd start with the dir() function, and maybe a bit of printf. http://www.php.net/dir http://www.php.net/printf -- Scott Noyes [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
Graham Anderson wrote: As an alternative, if I: 1) posted variables to a script with curl $ch = curl_init (path2myScript/movieBuilder.php); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST,1); curl_setopt ($ch, CURLOPT_POSTFIELDS, mask=mask.gifdrag=drag.gifmovie=fonovisa.mov); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($ch); // execute the post //echo $buffer; curl_close ($ch); } 2) write the 'src' attribute as './movieBuilder.php' with no variables passed $xml = EOB ?xml version=1.0? ?quicktime type=application/x-quicktime-media-link? embed src=./movieBuilder.php/ EOB; Would the movieBuilder.php file retain the POST'ed variables ? Or, would they be lost in the void. maybe this approach is silly? You could save the variables to a file. But it's silly and slow when you could just use GET. Can you explain why you don't want to just send them as GET variables in the query string? -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is PHP the language for me???
On 9/23/05, Emily McCall [EMAIL PROTECTED] wrote: I am trying to figure out whether php will help me to set up a website which is essentially just links to donwloadable material. I have directories in place and am using flash to auto fill the directory names on to an index page, however i cant use this to access the files themselves. So I am after a language i can use to read all the file names in the directory and display them with a bit of 'niceness' onto a webpage so as they can be used as links to the files. Yeah, PHP can do that. Toss this in a web directory and pull it up in a browser. ?php $files = array(); $d = dir( './' ); while( false !== ( $entry = $d-read() ) ) { if( $entry != '.' $entry != '..' !is_dir( $entry ) ) { $files[] = $entry; } } sort( $files ); foreach( $files as $file ) { echo EOF a href=$file$file/abr / EOF; } ? -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
Re: [PHP] Is PHP the language for me???
On 9/24/2005 12:14:55 AM, Greg Donald ([EMAIL PROTECTED]) wrote: On 9/23/05, Emily McCall [EMAIL PROTECTED] wrote: I am trying to figure out whether php will help me to set up a website which is essentially just links to donwloadable material. I have directories in place and am using flash to auto fill the directory names on to an index page, however i cant use this to access the files themselves. So I am after a language i can use to read all the file names in the directory and display them with a bit of 'niceness' onto a webpage so as they can be used as links to the files. Yep, PHP can certainly do that, and once you start you wont find a friendlier place if you need help...without this list I wouldnt be a programming in PHP todayokay, maybe I would but it would be a LOT harder :-) Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is PHP the language for me???
Yep, PHP can certainly do that, and once you start you wont find a friendlier place if you need help...without this list I wouldnt be a programming in PHP todayokay, maybe I would but it would be a LOT harder :-) Sooo... how much did they pay you to make you say this? :P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to stream a movie file with fread
I am trying to stream a movie file with 'fread' this my first step in trying to dynamically encrypt the file as it is being streamed from the server do I need to fread the data in chunks? If so, how? $filename =$path2file; $file = fopen($filename,'r'); $fileSize = filesize($filename); $ContentType = video/quicktime; header (Content-type: $ContentType); header (Content-length: $fileSize); while( $filedata_temp = fread($file, $fileSize) ) echo $filedata_temp; bFatal error/b: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in b/fopenTest.php/b on line b27/bbr / BTW, I can get readfile to work just fine :) AFAIK, readfile does not parameters to alter the file contents many thanks :) g -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is PHP the language for me???
On 9/24/2005 12:46:39 AM, Thorsten Suckow-Homberg ([EMAIL PROTECTED]) wrote: Yep, PHP can certainly do that, and once you start you wont find a friendlier place if you need help...without this list I wouldnt be a programming in PHP todayokay, maybe I would but it would be a LOT harder :-) Sooo... how much did they pay you to make you say this? :P Nothing actuallythey pay in kind :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how to stream a movie file with fread
if i may... what exactly are you trying to do. are you simply trying to get a single movie to stream... are you trying to get a better feel for how/what streaming is? -bruce -Original Message- From: Graham Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 4:07 PM To: php Subject: [PHP] how to stream a movie file with fread I am trying to stream a movie file with 'fread' this my first step in trying to dynamically encrypt the file as it is being streamed from the server do I need to fread the data in chunks? If so, how? $filename =$path2file; $file = fopen($filename,'r'); $fileSize = filesize($filename); $ContentType = video/quicktime; header (Content-type: $ContentType); header (Content-length: $fileSize); while( $filedata_temp = fread($file, $fileSize) ) echo $filedata_temp; bFatal error/b: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in b/fopenTest.php/b on line b27/bbr / BTW, I can get readfile to work just fine :) AFAIK, readfile does not parameters to alter the file contents many thanks :) g -- 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] how to stream a movie file with fread
I am trying to stream a movie file with 'fread' this my first step in trying to dynamically encrypt the file as it is being streamed from the server do I need to fread the data in chunks? If so, how? $filename =$path2file; $file = fopen($filename,'r'); $fileSize = filesize($filename); $ContentType = video/quicktime; header (Content-type: $ContentType); header (Content-length: $fileSize); while( $filedata_temp = fread($file, $fileSize) ) echo $filedata_temp; bFatal error/b: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in b/fopenTest.php/b on line b27/bbr / Not knowing exactly what you're trying to accomplish... I'm guessing that your $filename file is 24113191 in size and that PHP is compiled with a memory limit of 16777216. And since your assigning the results of fread() to a variable, PHP is going to try an allocate that for you and is failing. Couple of points.. Why loop if you are reading the entire file at once? Which is what fread($file, $fileSize) is going to do? Instead perhaps you want this: while ( !feof($file) ) { echo fread($file, 32768); } (or some other value for 32768...) That keeps the memory usage down, but does the same thing... good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting variables from one php script to another
Jasper Bryant-Greene wrote: Al wrote: I'd use this. It's simple and doesn't involve CURL. Here is a brief outline. $file_str= base64encode(serialize($_GET)); //$_GET can be any array Any reason why you base64_encode here? fwrite is binary-safe so base64 encoding your data is slow and a waste of space. Create a temporary file and write your string fwrite($temp, $file_str); fetch your data with $saved_get= unserialize(base64decode(file_get_contents(filename)); Unlink your file when done with it. Rather than resort to the slow process of creating, writing, reading and deleting a file for every request (not to mention generating a unique ID to prevent collisions with simultaneous requests), I'd be more tempted to find out exactly why the OP couldn't get it working with GET variables. Perhaps he could post some more code, as I regularly pass GET variables to PHP scripts through img tags and the like with no problems whatsoever. Serializing has problems with quotes, backslashs, etc. base64 makes it foolproof. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to stream a movie file with fread [success] Now, how to do a fast encrypt ?
Ok, I got it :) Is there a better way to do a very fast encryption of a file for a key that changes daily ? The movie is loading and playing at the same time [progressive/rtsp], so the encrypt/decrypt needs to be pretty fast I tried mcrypt but it seemed way to slow Maybe there is a better encryption method ? Or, are there better characters to search/replace ? Does not have to be ultra secure...just needs to be encryption that could last a day or so...as it will change daily. When I run this, the movie plays, but shows a blank screen and plays no audio...which is exactly what I want :) I want to write a data handler on the user side that connects to a db and gets the $find and $replace keys to unlock the movie many thanks in advance...and yes, I am experimenting ?php $fileSize = filesize($filepath); header(ETag: .md5(time())); header(Accept-Ranges: bytes); header (Content-Length: .$fileSize); header('Content-Type: video/quicktime'); $find = array({,ፀ,k,?); $replace = array(q,m,g,); if( $fd = fopen($filepath, 'rb')){ while(!feof($fd)) { echo str_replace($find,$replace, fread($fd, 8192)); } fclose ($fd); exit; } ? On Sep 23, 2005, at 4:07 PM, Graham Anderson wrote: I am trying to stream a movie file with 'fread' this my first step in trying to dynamically encrypt the file as it is being streamed from the server do I need to fread the data in chunks? If so, how? $filename =$path2file; $file = fopen($filename,'r'); $fileSize = filesize($filename); $ContentType = video/quicktime; header (Content-type: $ContentType); header (Content-length: $fileSize); while( $filedata_temp = fread($file, $fileSize) ) echo $filedata_temp; bFatal error/b: Allowed memory size of 16777216 bytes exhausted (tried to allocate 24113191 bytes) in b/fopenTest.php/b on line b27/bbr / BTW, I can get readfile to work just fine :) AFAIK, readfile does not parameters to alter the file contents many thanks :) g -- 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] Subtracting dates w/o database interaction (MySQL)
$date = mysql date field 2005-09-23 for example $difference =ceil((strtotime($date) - time()) / 86400); strtotime is far nicer than mktime when you already have a date field ready. On Friday 23 September 2005 03:10 pm, Philip Thompson wrote: On Sep 23, 2005, at 11:16 AM, Chris W. Parker wrote: Philip Thompson mailto:[EMAIL PROTECTED] on Friday, September 23, 2005 9:12 AM said: I'm needing to find the number of days between two dates without using an database functions (DATE_SUB, etc)... only PHP. Is there an easy way to accomplish this? I have searched the PHP site, but have not been successful in finding anything that will assist me. Any help would be appreciated. There might be an easier way but... convert to timestamp, subtract smaller number from bigger number, figure out how much time has passed. Chris. I actually discovered how to do this right after I made the post. I looked at some archives and worked this out. code // today - 9/23/05 $start = mktime(0, 0, 0, date(m), date(d), date(Y)); // the objective day - 3/15/06 $end = mktime(0, 0, 0, 3, 15, 2006); // subtract today from the objective and divide by 24*60*60 to get days $difference = ceil(($end - $start) / (86400)); /code Thanks for your assistance. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is PHP the language for me???
On 9/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Emily McCall [EMAIL PROTECTED] wrote on 09/23/2005 03:07:39 PM: I am trying to figure out whether php will help me to set up a website which is essentially just links to donwloadable material. Emily, you certainly came to the right place to get an endorsement of PHP ;) Kirk: While I agree with you to a certain extent, I think you should have a little more faith in the professionalism(and honesty) of many of the subscribers to this list. I've personally(I think), as have many others, pointed out situations on this list, where another language would be a better tool for the job than PHP. This however is not one of those situations. This type of job is what PHP was made for, and what PHP is extremely suitable for. This is the type of job, for which I have no problem whatsoever endorsing PHP. Emily: I hope this goes some way towards answering your question. I cannot answer it conclusively because this may be a one off project, and the rest of your coding may be better suited to a different language. Look into Perl and Python. I think you should still choose PHP, but would hope that you do so on its merits, and not because it was the first one you considered. Yes. PHP will handle your task nicely, and IMHO, it is the easiest language to learn and use for dynamic web programming. Dig in and enjoy! Kirk -- 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] basic user/input form questions... more validation!
bruce wrote: my question was directed towards trying to understand if you were meaning that an app should escape all output from the mysql db? If you think about that for a moment, I think you'll see that it doesn't make a lot of sense. Data that you get from a remote source is input, not output. Data that you send to a remote source is output. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php