php-general Digest 24 Sep 2005 12:14:22 -0000 Issue 3700
php-general Digest 24 Sep 2005 12:14:22 - Issue 3700 Topics (messages 223111 through 223117): Re: how to stream a movie file with fread [success] Now, how to do a fast encrypt ? 223111 by: Graham Anderson Re: Subtracting dates w/o database interaction (MySQL) 223112 by: Stephen Leaf Re: Is PHP the language for me??? 223113 by: Rory Browne Re: basic user/input form questions... more validation! 223114 by: Chris Shiflett Re: selfreferencing script with output 223115 by: Sabine 223116 by: Sabine php 4 script with php 5. 223117 by: Dwayne Hottinger 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--- 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 ---End Message--- ---BeginMessage--- $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 ---End Message--- ---BeginMessage--- 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
php-general Digest 25 Sep 2005 02:17:16 -0000 Issue 3701
php-general Digest 25 Sep 2005 02:17:16 - Issue 3701 Topics (messages 223118 through 223135): Re: php 4 script with php 5. 223118 by: Torgny Bjers 223119 by: Dwayne Hottinger 223120 by: Torgny Bjers 223121 by: Dwayne Hottinger LINKS 223122 by: php . net mines 223123 by: Gustav Wiberg 223131 by: Rory Browne Re: Is PHP the language for me??? 223124 by: Gustav Wiberg 223133 by: Jasper Bryant-Greene Cross Tabulation 223125 by: Shaun Using fopen('php://stdout') with apache 223126 by: andrew morton OT - database and indexes... but anyone please? 223127 by: Gustav Wiberg 223130 by: Rory Browne How to Looking at Raw Binary Data with PHP and curl 223128 by: Graham Anderson 223129 by: Jasper Bryant-Greene Re: basic user/input form questions... more validation! 223132 by: bruce 223134 by: Jasper Bryant-Greene serialize 223135 by: blackwater dev 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--- Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers ---End Message--- ---BeginMessage--- Thanks Torgny, Im a real newby here at php scripting. What should I put in the ()? Copying the snip into the script complains about that. This is in a db.php which defines how another script should utilize the database. I could copy the db.php into an email for someone to look over. thanks, ddh Quoting Torgny Bjers [EMAIL PROTECTED]: Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Dwayne Hottinger Network Administrator Harrisonburg City Public Schools ---End Message--- ---BeginMessage--- Don't top-post (on mailing lists, always respond below the other person's post). Please see below for my reply. Dwayne Hottinger wrote: Thanks Torgny, Im a real newby here at php scripting. What should I put in the ()? Copying the snip into the script complains about that. This is in a db.php which defines how another script should utilize the database. I could copy the db.php into an email for someone to look over. thanks, ddh Quoting Torgny Bjers [EMAIL PROTECTED]: Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them
Re: [PHP] selfreferencing script with output
Thank you very much for your answer, Rory, but I fear I don't understand the most important parts of it. It would be very nice of you if you could give me a further hint, more explanation. Rory Browne schrieb: 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. What do you mean with that meta tag? 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. And what is an ajax type system? I'm not sure if I don't understand what you mean due to my lack of english speaking capabilities or if I don't know the concept. I assume the last. But additionaly I don't find the word ajax in my dictionaries or at leo's. Is it an abbreviation? Kind regards Sabine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] selfreferencing script with output
Thanks for your answer, Gustav, now I see I didn't explain good enough what my problem is. My problem is not how to construct a status bar, but not it is possible to provide any output before the headering (*Warning*: Cannot modify header information - headers already sent by). Neither after it. Best regards Sabine P.S.: I played around with PEARs HTML_Progress. It's really worth trying. The user doc on Laurent Lavilles page provides a lot of explanation and examples. (http://pear.laurent-laville.org/HTML_Progress/). Gustav Wiberg schrieb: - 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
[PHP] php 4 script with php 5.
I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh -- Dwayne Hottinger Network Administrator Harrisonburg City Public Schools -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 4 script with php 5.
Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 4 script with php 5.
Thanks Torgny, Im a real newby here at php scripting. What should I put in the ()? Copying the snip into the script complains about that. This is in a db.php which defines how another script should utilize the database. I could copy the db.php into an email for someone to look over. thanks, ddh Quoting Torgny Bjers [EMAIL PROTECTED]: Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Dwayne Hottinger Network Administrator Harrisonburg City Public Schools -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 4 script with php 5.
Don't top-post (on mailing lists, always respond below the other person's post). Please see below for my reply. Dwayne Hottinger wrote: Thanks Torgny, Im a real newby here at php scripting. What should I put in the ()? Copying the snip into the script complains about that. This is in a db.php which defines how another script should utilize the database. I could copy the db.php into an email for someone to look over. thanks, ddh Quoting Torgny Bjers [EMAIL PROTECTED]: Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers The (...) was just an illustration if you had an if statement that didn't fire, then $return_array wouldn't be defined at all. Just put $return_array = null; in the top of the script somewhere so that it is defined at all times, that way you don't have to worry about the actual notice about it not being defined. You can then also make a simple check to see if it is an array, for instance: if (!emtpy($return_array) is_array($return_array)) { /* Code to do something with $return_array */ } That would be a good idea if you for instance are going to iterate the items in the array somewhere, if you don't check first, you might attempt to iterate a variable that doesn't contain an array but null, then PHP will yell at you for that. You are welcome to mail the script to me privately and I can take a look at it for you. Warm Regards, Torgny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 4 script with php 5.
Quoting Torgny Bjers [EMAIL PROTECTED]: Don't top-post (on mailing lists, always respond below the other person's post). Please see below for my reply. Dwayne Hottinger wrote: Thanks Torgny, Im a real newby here at php scripting. What should I put in the ()? Copying the snip into the script complains about that. This is in a db.php which defines how another script should utilize the database. I could copy the db.php into an email for someone to look over. thanks, ddh Quoting Torgny Bjers [EMAIL PROTECTED]: Dwayne Hottinger wrote: I am trying to transfer some databases and php scripts that populate them to a new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5. Original scripts were writen with php 4.x and worked fine. I get a PHP Notice: Undefined variable: return_array when running them on the new server and the database doesnt get populated. Mysql database and mysql user rights seem to be correct. Do I have to rewrite the script for php 5.x or should it work and I need to dig for another problem? Im quite new to php and dont know quite which way to go for help. I hope I have posted this on the right list. ddh Hello Dwayne, This is easy enough, all you need to do is define return_array. I've included an example here, it's mailer code, but, should illustrate what you need to do. function test() { $return_array = null; if (...) { $return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC); } return $return_array; } That means, you need to assign or indicate that return_array exists before you use it in something like return or other PHP function. Your php.ini file for PHP 4 could have been more forgiving coming to these notices/warnings. Warm Regards, Torgny Bjers The (...) was just an illustration if you had an if statement that didn't fire, then $return_array wouldn't be defined at all. Just put $return_array = null; in the top of the script somewhere so that it is defined at all times, that way you don't have to worry about the actual notice about it not being defined. You can then also make a simple check to see if it is an array, for instance: if (!emtpy($return_array) is_array($return_array)) { /* Code to do something with $return_array */ } That would be a good idea if you for instance are going to iterate the items in the array somewhere, if you don't check first, you might attempt to iterate a variable that doesn't contain an array but null, then PHP will yell at you for that. You are welcome to mail the script to me privately and I can take a look at it for you. Warm Regards, Torgny Torgny, Sorry about the top posting. Force of habit. I'll look over the info you have given me and get back with you. Thanks I really appreciate the help ddh -- Dwayne Hottinger Network Administrator Harrisonburg City Public Schools -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] LINKS
Hi all is there a way to have a program detecting when a link was clicked and automatically opening another window (that can plugged-in in any website - running php of course)? I know... I hate pop-ups too but a client asked for it... Thanks M -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LINKS
- Original Message - From: php @ net mines [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Saturday, September 24, 2005 4:34 PM Subject: [PHP] LINKS Hi all is there a way to have a program detecting when a link was clicked and automatically opening another window (that can plugged-in in any website - running php of course)? I know... I hate pop-ups too but a client asked for it... Thanks M -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I don't if I really understand you're question, but as I see it is done on the clientside (webbrowser) a href=Javascript:popup(url1, url2);Link is clicked/a the popup-function in Javascript opens url1 in one window and url2 opens up in a new window. So a tip is to consult a Javascript-mailinglist. /G http://www.varupiraten.se/ -- 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???
- Original Message - From: Emily McCall [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, September 23, 2005 11:07 PM Subject: [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 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! I have read some posts about this issue, but one point that is essential that I've not read about is the future! I mean, what are your plans in the future? Or what plans is it for the website. Just because it's only simple links now, it might be right to consider if for example object-oriented programming would be an issue in the future. PHP5 has that implementation, but not PHP4 so this might depend on the webserver/webhost... This was just a spontanious thought! And yes, I just love PHP if I compare with ASP which maybe is the most relevant!? comparision.. (The two largest languages for dynamic web out there? Don't know if maybe Perl is larger though). /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cross Tabulation
Hi, The following article describes cross tabulation within MySQL and ends with a Perl application that automates the process, does anyone know of a PHP version? http://dev.mysql.com/tech-resources/articles/wizard/index.html Thanks for your advice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using fopen('php://stdout') with apache
I'm trying to move some code that was written for the CLI to the web. It makes extensive use fprintf() and fputs() and under Apache2 it give no output. The simple test case that demonstrates the problem looks like: ?php $fp = fopen('php://stdout', 'w'); if ($fp === false) { die('open failed.'); } print You can see this with the CLI and Apache.\n; fputs($fp, This only shows up on the CLI...\n); fclose($fp); ? Using php-cli on FreeBSD: [EMAIL PROTECTED]:/home/www/multivac php phptest.php You can see this with the CLI and Apache. This only shows up on the CLI... Viewing the page using Apache2 and mod_php5: You can see this with the CLI and Apache. Anyone know how to get a reference to the standard output to work with the Apache2 SAPI? Thanks, andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OT - database and indexes... but anyone please?
Hi there! This is not strictly PHP... but if there's anyone out there with good knowledge of indexes, please mail me off-list. My question: If I delete an index, what is the WORST thing that can happen? /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to Looking at Raw Binary Data with PHP and curl
How do you display raw binary data of a file sent from a server with curl ? When I curl a movie file with curl -l -i path2file/file.php,I get the below output in my Terminal. file.php: $find = array($find1,$find2,$find3,$find4); $replace = array($replace1,$replace2,$replace3,$replace4); if( $fd = fopen($filepath, 'rb')){ while(!feof($fd)) { echo str_replace($find,$replace, fread($fd, $chunkSize)); //read and encode } fclose ($fd); exit; } I want to encrypt the file with something akin to str_replace and decode it on the other side with a custom data handler Just want to make sure that I am str_replace'ing the actual data and not a representation of it :) I am am bit new to this and deep in experimentation so any help is appreciated :) g output: ETag: 26a774b8e648b52c24f01c7277ce597f Accept-Ranges: bytes Content-Length: 24113190 Cache-Control: no-cache, must-revalidate Content-Type: video/quicktime ftypqt qt [EMAIL PROTECTED]@$edtselst-?S?mdia mdhd?????D?:hdlrmhlrsounapplyApple Sound Media HandlerS|minfsmhd9hdlrdhlralisappl?Apple Alias Data Handler$dinfdref alisSstbl?stsd?mp4a???Dcwave frmamp4a mp4a3esds???[EMAIL PROTECTED]:kNXstsc? 123? 56789:;? ???
Re: [PHP] How to Looking at Raw Binary Data with PHP and curl
Graham Anderson wrote: How do you display raw binary data of a file sent from a server with curl ? You can probably just use file_get_contents() if allow_url_fopen is enabled (it is by default). For binary data, base64_encode and it's friend base64_decode allow you to encode and decode binary data in a normal ASCII string. http://php.net/file_get_contents http://php.net/base64_encode I want to encrypt the file with something akin to str_replace and decode it on the other side with a custom data handler Just want to make sure that I am str_replace'ing the actual data and not a representation of it :) str_replace is not for encryption. You might want to look at mcrypt, as using str_replace is probably just as bad as sending the unencrypted string. It's not going to be secure. http://php.net/mcrypt -- 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] OT - database and indexes... but anyone please?
I'm not an expert on databases, and I haven't a notion of mailing you off-list, with information that could potentially benifit others as well, but from my understanding, deleting an index(a good index that is) would slow the db down in certain cases. Deleting a bad index would speed certain operations up. On 9/24/05, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there! This is not strictly PHP... but if there's anyone out there with good knowledge of indexes, please mail me off-list. My question: If I delete an index, what is the WORST thing that can happen? /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] LINKS
On 9/24/05, php @ net mines [EMAIL PROTECTED] wrote: Hi all is there a way to have a program detecting when a link was clicked and automatically opening another window (that can plugged-in in any website - running php of course)? That would be done using client-side JS. you would define a JS function to do the opening, and then you would iterate through all a tags setting the onClick handler to call your function. Then again on the other hand, maybe you shouldn´t. Maybe you should just tell your client where to stick his pop-up. I personally consider an unrequested pop-up to be a virus, and send it straight to my pop-up blocker. I know... I hate pop-ups too but a client asked for it... Thanks M -- 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!
chris... i would agree, and didn't think it made sense.. but i don't know what you mean by the phrase 'escape all output'!! i don't see the need to escape all output from the mysql db/tbl... so i'm not sure you meant this. for my $0.02, i'd quote/escape all 'strings/date' vars that would be inserted/used within the mysql db. i'd simply go ahead and insert numeric data with no quotes. i'd thoroughly verify/validate using regex or other methods all data before using it in the sql commands. as fars as getting data from the mysql db/tbl, i'd simply use the sql command/query. i'd extract the resulting data, and use the data in vars that i've defined to be the specific data type. this allows me to farily consistenly know what data types i'm using, and how to then present the data to the user if i have to, as well as how to use the vars/data in other parts of the given application. -bruce -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Friday, September 23, 2005 9:22 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: 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 -- 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???
Gustav Wiberg wrote: I have read some posts about this issue, but one point that is essential that I've not read about is the future! I mean, what are your plans in the future? Or what plans is it for the website. Just because it's only simple links now, it might be right to consider if for example object-oriented programming would be an issue in the future. PHP5 has that implementation, but not PHP4 so this might depend on the webserver/webhost... PHP4 has OO as well. It's just an inferior and slower implementation. OO does not suit every case and you need to decide whether the additional time and work spent writing the code in OO is going to pay off in the future. If it isn't likely to, then I would suggest procedural might be a better choice. This was just a spontanious thought! And yes, I just love PHP if I compare with ASP which maybe is the most relevant!? comparision.. (The two largest languages for dynamic web out there? Don't know if maybe Perl is larger though). ASP isn't actually a language, it's just a framework for dynamic (active) server pages, that provides a bunch of common objects and stuf. In classic ASP you can write VBScript or JScript, and in ASP.NET you can write VB.NET, JScript or C#. Both classic and .NET allow you to add additional languages of your choice with a bit of work. I still prefer PHP though; just thought I'd point out the difference... -- 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] basic user/input form questions... more validation!
bruce wrote: i would agree, and didn't think it made sense.. but i don't know what you mean by the phrase 'escape all output'!! i don't see the need to escape all output from the mysql db/tbl... so i'm not sure you meant this. Output can be (among other things): * Your script = MySQL * Your script = User's browser * Your script = Shell Anything that leaves the realms of your PHP script is considered output from that script, and should be escaped. * Output from your script to MySQL should be escaped with mysql_real_escape_string() * Output from your script to the user's browser should be escaped with htmlspecialchars() * Output from your script to the shell should be escaped with escapeshellcmd() and escapeshellarg() [snip] as fars as getting data from the mysql db/tbl, i'd simply use the sql command/query. i'd extract the resulting data, and use the data in vars that i've defined to be the specific data type. And hopefully htmlspecialchars() it if you intend outputting it to the user's browser... -- 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] serialize
I have an app that stores evaluation scores so I have 30+ values all within a certain range, currently in the db, each of these values has it's own column: Table test id user_id motivation caring personal_characteristics creativity, ...etc. If the client decides they want to trap more characteristics, it requires changes to the table structure and the table quickly gets large with 30+ columns. I was thinking of just compacting all of these down to one column and then using serialize/unserialize and storing an array of the test scoresis this the best way?? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to Looking at Raw Binary Data with PHP and curl
Is this good enough encryption for daily use ? FYI, I need to keep the first part of the file unencrypted so the file will progressively load Functions were taken from the mycrypt php page :) $chunkSize = 32768; $key = 6q9nKLg5 if( $fd = fopen($filepath, 'rb')){ while(!feof($fd)) { if($gotFastStartHeaders != true){ echo fread($fd, $chunkSize/30); $gotFastStartHeaders = true; }else{ echo encrypt(fread($fd, $chunkSize)); } } fclose ($fd); exit; } / /--- --- // Encrypt function encrypt($encrypt) { global $key; //$key = 6q9nEUg5; srand((double) microtime() * 100); //for sake of MCRYPT_RAND $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, MCRYPT_MODE_ECB, $iv); $encode = base64_encode($passcrypt); return $encode; } / /--- --- // Decrypt function decrypt($decrypt) { global $key; $decoded = base64_decode($decrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_ECB, $iv); return $decrypted; many thanks g On Sep 24, 2005, at 2:25 PM, Jasper Bryant-Greene wrote: Graham Anderson wrote: How do you display raw binary data of a file sent from a server with curl ? You can probably just use file_get_contents() if allow_url_fopen is enabled (it is by default). For binary data, base64_encode and it's friend base64_decode allow you to encode and decode binary data in a normal ASCII string. http://php.net/file_get_contents http://php.net/base64_encode I want to encrypt the file with something akin to str_replace and decode it on the other side with a custom data handler Just want to make sure that I am str_replace'ing the actual data and not a representation of it :) str_replace is not for encryption. You might want to look at mcrypt, as using str_replace is probably just as bad as sending the unencrypted string. It's not going to be secure. http://php.net/mcrypt -- 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] OT - database and indexes... but anyone please?
- Original Message - From: Rory Browne [EMAIL PROTECTED] To: Gustav Wiberg [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Sent: Sunday, September 25, 2005 1:26 AM Subject: Re: [PHP] OT - database and indexes... but anyone please? I'm not an expert on databases, and I haven't a notion of mailing you off-list, with information that could potentially benifit others as well, but from my understanding, deleting an index(a good index that is) would slow the db down in certain cases. Deleting a bad index would speed certain operations up. On 9/24/05, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there! This is not strictly PHP... but if there's anyone out there with good knowledge of indexes, please mail me off-list. My question: If I delete an index, what is the WORST thing that can happen? /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 -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.6/111 - Release Date: 2005-09-23 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] Is PHP the language for me???
- Original Message - From: Jasper Bryant-Greene [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, September 25, 2005 1:38 AM Subject: Re: [PHP] Is PHP the language for me??? Gustav Wiberg wrote: I have read some posts about this issue, but one point that is essential that I've not read about is the future! I mean, what are your plans in the future? Or what plans is it for the website. Just because it's only simple links now, it might be right to consider if for example object-oriented programming would be an issue in the future. PHP5 has that implementation, but not PHP4 so this might depend on the webserver/webhost... PHP4 has OO as well. It's just an inferior and slower implementation. OO does not suit every case and you need to decide whether the additional time and work spent writing the code in OO is going to pay off in the future. If it isn't likely to, then I would suggest procedural might be a better choice. Ok, I didn't know that PHP4 had OO-support and yes, I agree that it is 95% always better to use OO This was just a spontanious thought! And yes, I just love PHP if I compare with ASP which maybe is the most relevant!? comparision.. (The two largest languages for dynamic web out there? Don't know if maybe Perl is larger though). ASP isn't actually a language, it's just a framework for dynamic (active) server pages, that provides a bunch of common objects and stuf. In classic ASP you can write VBScript or JScript, and in ASP.NET you can write VB.NET, JScript or C#. Both classic and .NET allow you to add additional languages of your choice with a bit of work. Of course! Wrong of me to say that ASP is a language... I meant VBScript... which I have been working with. I still prefer PHP though; just thought I'd point out the difference... Who doesnt? :-) /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] serialize
- Original Message - From: blackwater dev [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, September 25, 2005 4:17 AM Subject: [PHP] serialize I have an app that stores evaluation scores so I have 30+ values all within a certain range, currently in the db, each of these values has it's own column: Table test id user_id motivation caring personal_characteristics creativity, ...etc. If the client decides they want to trap more characteristics, it requires changes to the table structure and the table quickly gets large with 30+ columns. I was thinking of just compacting all of these down to one column and then using serialize/unserialize and storing an array of the test scoresis this the best way?? Thanks! Hi! It doesn't seem like good db-practise to set all the values in one field. You shouldn't be forced to change database-structure just because the user inputs more information. You may reconsider using several tables and do relations between the tables.. /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php