[PHP] QUARANTINED: Mail System Error - Returned Mail
The message Mail System Error - Returned Mail from , sent on 8/29/2006 06:01 was quarantined because it contained either an executable file, a batch file or a screen saver file. All of these types of attachments are considered security risks. Please consult your mail administrator who can release the message. This message was checked by MailScan for WorkgroupMail. www.workgroupmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing strings... need advice. :)
On Mon, 28 Aug 2006 19:39:49 -0400, Robert Cummings wrote: On Mon, 2006-08-28 at 16:50 +0200, Ivo F.A.C. Fokkema wrote: On Mon, 28 Aug 2006 09:47:02 +0100, Stut wrote: Micky Hulse wrote: I am looking for the most secure/efficient way to compare these two strings: /folder1/folder2/folder3/folder4/ /folder1/folder2/folder3/folder4/file.php Basically I am trying to setup as many security features as possible for a simplistic (home-grown/hand-coded) CMS... This appears to work: $haystack = '/folder1/folder2/folder3/folder4/someFileName.php'; $needle = '/folder1/folder2/folder3/folder4/'; if(substr_count($haystack, $needle) === 1) echo yea; Before making changes to someFileName.php I want to make sure it is within the allowed path ($needle). First of all make sure you are sending both strings through realpath (http://php.net/realpath) to remove any symbolic links and relative references. Then you can compare the two strings. The way you're doing it will work but it's probably not very efficient. This is what I use... $valid = (strcmp($needle, substr($haystack, 0, strlen($needle))) == 0); Personally, this seems simpler to me: $valid = (dirname($haystack) == $needle); But the way the above folders are presented, it should become $valid = (dirname($haystack) == rtrim($needle, '/')); less simple already... Possibly, this is not the best solution for some reason I don't know. If so, I would like to know :) The above technique doesn't allow for sub-directories. It only allows for files within the needle directory. Ah, thanks. Misunderstood the question, then. Thought just checking if it's a file in that directory was what's needed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help - outputting a jpeg
I just get all the binary data output ? include(includes/config.php); $link = mysql_connect($host, $user, $password) or die ('somethng went wrong:' .mysql_error() ); mysql_select_db($dbname, $link) or die ('somethng went wrong, DB error:' .mysql_error() ); $query = SELECT DISTINCT gallery FROM thumbnails; $result = @mysql_query( $query,$link ); while ($row = @mysql_fetch_assoc($result) ) { $gallery_id=$row['gallery']; $query2 = SELECT * FROM thumbnails WHERE gallery ='$gallery_id' LIMIT 1; $result2 = @mysql_query($query2); while ($row2 = @mysql_fetch_array($result2, MYSQL_ASSOC)){ Header( Content-type: image/pjpeg); echo img src=\.$row2[bin_data].\; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help - outputting a jpeg
On Tue, 29 Aug 2006 09:52:20 +0100, Ross wrote: I just get all the binary data output ? include(includes/config.php); $link = mysql_connect($host, $user, $password) or die ('somethng went wrong:' .mysql_error() ); mysql_select_db($dbname, $link) or die ('somethng went wrong, DB error:' .mysql_error() ); $query = SELECT DISTINCT gallery FROM thumbnails; $result = @mysql_query( $query,$link ); while ($row = @mysql_fetch_assoc($result) ) { $gallery_id=$row['gallery']; $query2 = SELECT * FROM thumbnails WHERE gallery ='$gallery_id' LIMIT 1; $result2 = @mysql_query($query2); while ($row2 = @mysql_fetch_array($result2, MYSQL_ASSOC)){ Header( Content-type: image/pjpeg); echo img src=\.$row2[bin_data].\; } You're mixing binary data with HTML. What do you want to do? If you want to put multiple pictures on one page, first build the HTML, that loads the pictures and use a php file to retrieve the given ID from the database and output the header and binary result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing strings... need advice. :)
Ivo F.A.C. Fokkema wrote: Ah, thanks. Misunderstood the question, then. Thought just checking if it's a file in that directory was what's needed. You were right. :) I did not plan on looking-in anything other than one or two hard-coded folder locations. But, it is good to know the details. ;) Thanks again for the help... Time for me to hit the hay. I have een geeking-out for way too long today. Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] character set when sending emails with PHP
Hi all, I have various PHP CRONTAB scripts that run and send automated emails to people, the subject often contains the TM character: ™, in most of the email clients the character shows correctly but in some webmail applications the character is replaced with a square, it obviously doesnt recognise the character. Now if I forward one the mails from the email client to the webmail account it then recognises and shows the character correctly? Very weird as it is the same mail just forwarded, is the problem that the mail forwarded from the email client uses a different content type when sent? The one specified in the PHP script is as follows: $mail-setHeader(Content-type, text/plain; charset=iso-8859-1); Or is there something wrong with the charset that I'm specifying above? Any help or advice would be appreciated. TIA Angelo -- Angelo Zanetti Systems developer *Telephone:* +27 (021) 469 1052 *Mobile:* +27 (0) 72 441 3355 *Fax:* +27 (0) 86 681 5885 * Web:* http://www.zlogic.co.za *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file type and recode
Simple question: Is there a built-in function in PHP to get the charset of a file, so that I can pass the right parameters to recode_file()? -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replace single and double quotes
This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the single quote so it is shown as a single quote on a webpage when I get it from the database I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace single and double quotes
since I had something similar as a problem, let m etry to anser ang see did I get it correct :) first, and most important: never store in DB row submitted string $act_extra = mysql_real_escape_string($_POST[editextra]); $act_extra_fr = mysql_real_escape_string($_POST[editextrafr]) $act_id = mysql_real_escape_string($_POST[editid]); then: $sqledit = update activities set act_extra='.$act_extra.', act_extra_fr = '.$act_extra_fr.' where act_id = '.$act_id.'; to check: echo $sqledit; it should work now. hope this helped. -afan This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the single quote so it is shown as a single quote on a webpage when I get it from the database I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- 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] replace single and double quotes
[EMAIL PROTECTED] wrote: since I had something similar as a problem, let m etry to anser ang see did I get it correct :) seems ok ... first, and most important: never store in DB row submitted string $act_extra = mysql_real_escape_string($_POST[editextra]); $act_extra_fr = mysql_real_escape_string($_POST[editextrafr]) the following should always be an integer (probably) ... $act_id = mysql_real_escape_string($_POST[editid]); so why not do: $act_id = intval($_POST[editid]); if (!$act_id) die('go away script kiddie!'); then: $sqledit = update activities set act_extra='.$act_extra.', act_extra_fr = '.$act_extra_fr.' where act_id = '.$act_id.'; very minor point - but why not save your eyes a little: $sqledit = UPDATE activities SET act_extra='{$act_extra}', act_extra_fr='{$act_extra_fr}' WHERE act_id={$act_id}; to check: echo $sqledit; it should work now. hope this helped. -afan This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the single quote so it is shown as a single quote on a webpage when I get it from the database I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- 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] replace single and double quotes
Reinhart Viane wrote: This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; this indicates 'bad' database design ... because adding a language involves having to change the database schema. I personally think that there should be no need to change the database schema and/or queries and/or code just because the client wants an extra language. it also indicates that you have a glaring SQL injection problem. what happens when I craft a POST request that contains an 'editid' parameter with the following in it: '1 OR 1' or '1; DELETE * FROM activities' google 'SQL injection', do some reading and get into the habit of sanitizing your user input. Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the WRONG - you only replace with quot when you OUTPUTTING the string as part of a webpage. the database should contain the actual single quote so it is shown as a single quote on a webpage when I get it from the database mysql_real_escape_string() search this archive; there is plenty of discussion about escaping data so that it can be inserted into a database (mostly concerning MySQL). I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace single and double quotes
Assumning $act_id is integer: $act_extra = mysql_real_escape_string($_POST[editextra]); $act_extra_fr = mysql_real_escape_string($_POST[editextrafr]) $act_id = $_POST[editid]; $sql = sprint(UPDATE activities SET act_extra='%s', act_extra_fr='%s' WHERE act_id=%d, $act_extra, $act_extra_fr, $act_id); Notice the %d for the id part if $act_id should be integer. /Peter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 29, 2006 8:28 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] replace single and double quotes since I had something similar as a problem, let m etry to anser ang see did I get it correct :) first, and most important: never store in DB row submitted string $act_extra = mysql_real_escape_string($_POST[editextra]); $act_extra_fr = mysql_real_escape_string($_POST[editextrafr]) $act_id = mysql_real_escape_string($_POST[editid]); then: $sqledit = update activities set act_extra='.$act_extra.', act_extra_fr = '.$act_extra_fr.' where act_id = '.$act_id.'; to check: echo $sqledit; it should work now. hope this helped. -afan This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the single quote so it is shown as a single quote on a webpage when I get it from the database I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace single and double quotes
About the language remark: I believe you try to say I need to find a way that the client can add 25 languages without me having to change the database layout or the coding? Well I can assure you this will not be the fact. The client only needs these two languages but maybe I should look into it anyway About SQl injection: I must say this is very interesting. I always wondered what are does and donts when inserting data from a form into a database and how to check someone did not enter any php code. Besides the google lookup is there maybe an site or paper dedicated to this? Thx again, didn't think this question was about to bring up what I was looking for in the back of my head -Oorspronkelijk bericht- Van: Jochem Maas [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 29 augustus 2006 15:37 Aan: [EMAIL PROTECTED] CC: php-general@lists.php.net Onderwerp: Re: [PHP] replace single and double quotes Reinhart Viane wrote: This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; this indicates 'bad' database design ... because adding a language involves having to change the database schema. I personally think that there should be no need to change the database schema and/or queries and/or code just because the client wants an extra language. it also indicates that you have a glaring SQL injection problem. what happens when I craft a POST request that contains an 'editid' parameter with the following in it: '1 OR 1' or '1; DELETE * FROM activities' google 'SQL injection', do some reading and get into the habit of sanitizing your user input. Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the WRONG - you only replace with quot when you OUTPUTTING the string as part of a webpage. the database should contain the actual single quote so it is shown as a single quote on a webpage when I get it from the database mysql_real_escape_string() search this archive; there is plenty of discussion about escaping data so that it can be inserted into a database (mostly concerning MySQL). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace single and double quotes
Ok 'ill give this a shot together with the guidelines from jochen. Thx afan. -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 29 augustus 2006 15:28 Aan: [EMAIL PROTECTED] CC: php-general@lists.php.net Onderwerp: Re: [PHP] replace single and double quotes since I had something similar as a problem, let m etry to anser ang see did I get it correct :) first, and most important: never store in DB row submitted string $act_extra = mysql_real_escape_string($_POST[editextra]); $act_extra_fr = mysql_real_escape_string($_POST[editextrafr]) $act_id = mysql_real_escape_string($_POST[editid]); then: $sqledit = update activities set act_extra='.$act_extra.', act_extra_fr = '.$act_extra_fr.' where act_id = '.$act_id.'; to check: echo $sqledit; it should work now. hope this helped. -afan This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the single quote so it is shown as a single quote on a webpage when I get it from the database I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image manipulation with php
I have an saved images I output with this... img src=includes/viewphoto.php?id=?=$photo? I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php script (ii) comparing and reducing the file Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace single and double quotes
Reinhart Viane wrote: About the language remark: I believe you try to say I need to find a way that the client can add 25 languages without me having to change the database layout or the coding? Well I can assure you this will not be the fact. The client only needs these two languages but maybe I should look into it anyway it's more a of a theoretical thing. but if the client wants french and flemish (or dutch) now there is a distinct chance that they will want to add dutch, english and/or german in the forseeable future... going by my experience of building multilingual sites for [west] european companies (I have one client that actually wanted flemish as well as dutch so that they could tailor texts in the flemish pages specifically to [search] terms regularly used in belgium). your db design may very well be sufficient for this particular case. About SQl injection: I must say this is very interesting. I always wondered what are does and donts when inserting data from a form into a database and how to check someone did not enter any php code. Besides the google lookup is there maybe an site or paper dedicated to this? phpsec.org - recommended to read it back to front! Thx again, didn't think this question was about to bring up what I was looking for in the back of my head -Oorspronkelijk bericht- Van: Jochem Maas [mailto:[EMAIL PROTECTED] Verzonden: dinsdag 29 augustus 2006 15:37 Aan: [EMAIL PROTECTED] CC: php-general@lists.php.net Onderwerp: Re: [PHP] replace single and double quotes Reinhart Viane wrote: This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; this indicates 'bad' database design ... because adding a language involves having to change the database schema. I personally think that there should be no need to change the database schema and/or queries and/or code just because the client wants an extra language. it also indicates that you have a glaring SQL injection problem. what happens when I craft a POST request that contains an 'editid' parameter with the following in it: '1 OR 1' or '1; DELETE * FROM activities' google 'SQL injection', do some reading and get into the habit of sanitizing your user input. Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the WRONG - you only replace with quot when you OUTPUTTING the string as part of a webpage. the database should contain the actual single quote so it is shown as a single quote on a webpage when I get it from the database mysql_real_escape_string() search this archive; there is plenty of discussion about escaping data so that it can be inserted into a database (mostly concerning MySQL). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image manipulation with php
Ross wrote: I have an saved images I output with this... img src=includes/viewphoto.php?id=?=$photo? I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php script why is this a problem? getimagesize() just needs a path to the image. given that this is all new to you you might consider that storing the image data directly in the DB is best left to crazy fools who really know where their towels are at. (ii) comparing and reducing the file RTFM or STFW - there are lots of examples related to image resampling/thumbnailing/etc and even more readymade scripts that do more or less what you want. Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace single and double quotes
It might be bad database design yes, however, it all depends on what he is trying to do. I do it your way Jochem (normalizing the database), but in some cases the budget to do that might not be big enough. If the client gives you a task and an budget, normalizing the database might be a waste of time. I do recommend he should do some reading about SQL injection, phpsec.org is probably good enough. But to get him going he could just learn that he should always mysql_real_escape_string on strings, and if he expect integers to come, use the sprintf and %d. You can read my blog http://www.lauri.se/article/4/security-hole-in-golfdatase about a big and important golf organization in Sweden and how they screwed up about their security. Hrm, I might be wrong here :) /Peter -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 29, 2006 8:37 PM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] replace single and double quotes Reinhart Viane wrote: This is the code is use to insert/update text into a database field: $sqledit=update activities set act_extra='$_POST[editextra]', act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]; this indicates 'bad' database design ... because adding a language involves having to change the database schema. I personally think that there should be no need to change the database schema and/or queries and/or code just because the client wants an extra language. it also indicates that you have a glaring SQL injection problem. what happens when I craft a POST request that contains an 'editid' parameter with the following in it: '1 OR 1' or '1; DELETE * FROM activities' google 'SQL injection', do some reading and get into the habit of sanitizing your user input. Now both $_POST[editextra] and $_POST[editextrafr] can contain single or double quotes. So the query almost always gives me an error. I know I have to replace with quot, but I do not know how to replace the WRONG - you only replace with quot when you OUTPUTTING the string as part of a webpage. the database should contain the actual single quote so it is shown as a single quote on a webpage when I get it from the database mysql_real_escape_string() search this archive; there is plenty of discussion about escaping data so that it can be inserted into a database (mostly concerning MySQL). I have been looking into str_replace and preg_replace. But what I really need is a solution that 'replaces' single quotes, double quotes en curly quotes so I tackle all possible problems and the same text as it was inputed in the textarea is shown on the webpage. Thx in advance -- 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] switch()
I have something like this: ?php $query = mysql_query( SELECT col_1, col_2 FROM table ); $result = mysql_fetch_array($query); if ($result['col_1'] == 'value_1') { // do something } if ($result['col_2'] == 'value_2') { // do something } ? when I tried to use swiitch() ?php switch (true) { case ($result['col_1'] == 'value_1'): // do something break; case ($result['col_2'] == 'value_2'): // do something break; } ? it will give me only the first true case. if $result['col_1'] == 'value_1' is true 2nd case will never be executed? Does it mean I CANNOT use switch() in this case? -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch()
On Tuesday 29 August 2006 13:31, [EMAIL PROTECTED] wrote: I have something like this: ?php $query = mysql_query( SELECT col_1, col_2 FROM table ); $result = mysql_fetch_array($query); if ($result['col_1'] == 'value_1') { // do something } if ($result['col_2'] == 'value_2') { // do something } ? when I tried to use swiitch() ?php switch (true) { case ($result['col_1'] == 'value_1'): // do something break; case ($result['col_2'] == 'value_2'): // do something break; } ? it will give me only the first true case. if $result['col_1'] == 'value_1' is true 2nd case will never be executed? Does it mean I CANNOT use switch() in this case? -afan Using a switch like this is more equivalent of if(something){ // true } else { // false } You're doing : if(something1){ // true 1 } if(something2){ // true2 } hope that helps. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch()
On Tuesday 29 August 2006 13:44, Ray Hauge wrote: Using a switch like this is more equivalent of if(something){ // true } else { // false } Actually, it's more like an if/elseif/else (if you use default:) or if/elseif (without default:) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: image manipulation with php
Ross escreveu: I have an saved images I output with this... img src=includes/viewphoto.php?id=?=$photo? I want to use getimagesize() to get the height and width of the image and if it is above a certain size then scale/ reduce it. The problems are (i) using getimage() without a url just my viewphoto.php script (ii) comparing and reducing the file Ross http://www.educar.pro.br/abc/gdlib/index.php?pageNum_rsNVER=22totalRows_rsNVER=67 zerof -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch()
Means, my first solution was the only solution. Thanks. -afan Using a switch like this is more equivalent of if(something){ // true } else { // false } You're doing : if(something1){ // true 1 } if(something2){ // true2 } hope that helps. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- 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] Re: character set when sending emails with PHP
Hello, on 08/29/2006 09:04 AM Angelo Zanetti said the following: I have various PHP CRONTAB scripts that run and send automated emails to people, the subject often contains the TM character: ™, in most of the email clients the character shows correctly but in some webmail applications the character is replaced with a square, it obviously doesnt recognise the character. Now if I forward one the mails from the email client to the webmail account it then recognises and shows the character correctly? Very weird as it is the same mail just forwarded, is the problem that the mail forwarded from the email client uses a different content type when sent? The one specified in the PHP script is as follows: $mail-setHeader(Content-type, text/plain; charset=iso-8859-1); Or is there something wrong with the charset that I'm specifying above? The content-type header only applies to that message body part. The character set of the headers is defined in a different way using q-encoding. Take a look at this class that lets you define headers with whatever encoding and character set you need to use: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos Metastorage - Data object relational mapping layer generator http://www.metastorage.net/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch()
No. They are two if statements because they are indepedent. On Tuesday 29 August 2006 13:44, Ray Hauge wrote: Using a switch like this is more equivalent of if(something){ // true } else { // false } Actually, it's more like an if/elseif/else (if you use default:) or if/elseif (without default:) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- 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] switch()
On Tuesday 29 August 2006 14:12, [EMAIL PROTECTED] wrote: No. They are two if statements because they are indepedent. On Tuesday 29 August 2006 13:44, Ray Hauge wrote: Using a switch like this is more equivalent of if(something){ // true } else { // false } Actually, it's more like an if/elseif/else (if you use default:) or if/elseif (without default:) -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I was unclear. Using a switch to replace an if statement would be replacing the if/elseif/else with the switch. You are right though. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch()
What you're saying in that case is either col_1 evaluates to value1 or col_2 evaluates to value2. Correct. To be more specific (it was better I did from begining :)) After an order is submitted, the code is checking are there any coments about tax charges (col_1) and/or billing charges (col_2). If there is comment in col_1 send it by email to person in charge. If there is something in col_2 send it by email to (other) person in charge. I hope it does now make a sence. Sorry for this. Unless you have some program logic to prevent both from being true, you are comparing apples and oranges. And any time col_1, evaluates to true, the break keyword will stop your switch ladder. Remove break, and that won't happen. of course, if you do that, then the question arises about why you are using a switch ladder in the first place. I forgot about this break (sounds crazy :)). Thanks for making this clear to me. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] send a file or stream
Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
RE: [PHP] replace single and double quotes
At 5:04 PM +0200 8/29/06, Reinhart Viane wrote: About the language remark: I believe you try to say I need to find a way that the client can add 25 languages without me having to change the database layout or the coding? Well I can assure you this will not be the fact. The client only needs these two languages but maybe I should look into it anyway Depends upon what's in the dB -- if it's language specific, then you'll have to change it. If it's not, then you won't. For what it's worth, the language independent code that I've written in the past used constants for language specific labels. From there, I would program using English for my code, but those constants could be changed by a single setting allowing them to be their language counterparts. Food for thought. About SQl injection: I must say this is very interesting. I always wondered what are does and donts when inserting data from a form into a database and how to check someone did not enter any php code. Besides the google lookup is there maybe an site or paper dedicated to this? There are different types of injection. I recommend Essential PHP Security by Shifiett: http://www.amazon.com/gp/product/059600656X/ref=nosim/102-4387829-1116967?camp=2025dev-t=D26XECQVNV6NDQlink%5Fcode=xm2n=283155 Well worth the money. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace single and double quotes
Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
[PHP] Strange situation when saving a file
Hi all, I'm using ob_start() in order to save the content of a web page into a variable string and then save it into a file in the file system. Every thing is done OK. The only workaround I'm doing is adding a .doc file extension when saving the file, in order to open the file in Word. Once the file has been created and saved as I doc file (not a doc format!), I e-mail it! When the client gets the e-mail, he/she should open the file either by saving the file to the local system or openning the file directly from the e-mail attachment. Either way, I got a blank page in Word. If I open the document directly from the web server, without having it sent by e-mail, it opens correctly in Word. The only problem is when the file is been emailed!!! What could be going wrong?? Any ideas?? Thanks in advance!! --- Miguel Guirao Aguilera Logistica R8 TELCEL Tel. (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Test!
Hello! this is a test, can anyone tell me if u are getting my emails?? Thank you
Re: [PHP] Test!
On Tue, 2006-08-29 at 23:00 -0400, Rafael Mora wrote: Hello! this is a test, can anyone tell me if u are getting my emails?? I'm not getting them :/ Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] send a file or stream
Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] send a file or stream
-- Forwarded message -- From: Rafael Mora [EMAIL PROTECTED] Date: Aug 29, 2006 11:09 PM Subject: Re: [PHP] send a file or stream To: Peter Lauri [EMAIL PROTECTED] 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
RE: [PHP] send a file or stream
?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then. if you know the path to the file :) _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:10 AM To: Peter Lauri Subject: Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
Re: [PHP] send a file or stream
ok thank you Im going to test it!! =) On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then… if you know the path to the file :) -- *From:* Rafael Mora [mailto:[EMAIL PROTECTED] *Sent:* Wednesday, August 30, 2006 10:10 AM *To:* Peter Lauri *Subject:* Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, *Peter Lauri* [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
Re: [PHP] send a file or stream
I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3· ¿¨$1¯D¡¸¤(3/] LÖ so the user should read that?? this is my code: ?php $params = array('level' = 6, 'window' = 15, 'memory' = 9); $texto_original = This is a test.\nThis is only a test.\nThis is not an important string.\n; //echo El texto original tiene . strlen($texto_original) . caracteres.\n; $da = fopen('stations.gzip', 'w'); stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params); fwrite($da, $texto_original); fclose($da); header(Content-Type: application/octet-stream); readfile(stations.gzip); On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then. if you know the path to the file :) _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:10 AM To: Peter Lauri Subject: Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
RE: [PHP] send a file or stream
You need to make sure that you are not outputting ANYTHING before you do this. I might guess that you have a whitespace in the top of the script. As soon as you output, the server can not send any more header information, and the browser will think it is just text instead of treating it as an octet-stream. /Peter _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:25 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] send a file or stream I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=®(??/§C0/¿D!1O!3· ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code: ?php $params = array('level' = 6, 'window' = 15, 'memory' = 9); $texto_original = This is a test.\nThis is only a test.\nThis is not an important string.\n; //echo El texto original tiene . strlen($texto_original) . caracteres.\n; $da = fopen('stations.gzip', 'w'); stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params); fwrite($da, $texto_original); fclose($da); header(Content-Type: application/octet-stream); readfile(stations.gzip); On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then. if you know the path to the file :) _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:10 AM To: Peter Lauri Subject: Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
Re: [PHP] send a file or stream
Ok it works, but it returns me the same .php file, not the one I am creating On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: You need to make sure that you are not outputting ANYTHING before you do this. I might guess that you have a whitespace in the top of the script. As soon as you output, the server can not send any more header information, and the browser will think it is just text instead of treating it as an octet-stream. /Peter _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:25 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] send a file or stream I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3· ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code: ?php $params = array('level' = 6, 'window' = 15, 'memory' = 9); $texto_original = This is a test.\nThis is only a test.\nThis is not an important string.\n; //echo El texto original tiene . strlen($texto_original) . caracteres.\n; $da = fopen('stations.gzip', 'w'); stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params); fwrite($da, $texto_original); fclose($da); header(Content-Type: application/octet-stream); readfile(stations.gzip); On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then. if you know the path to the file :) _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:10 AM To: Peter Lauri Subject: Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa
RE: [PHP] send a file or stream
Try this: header(Pragma: public); header(Expires: 0); // set expiration time header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-Type: application/octet-stream); header('Content-Disposition: attachment; filename=stations.gzip'); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize(stations.gzip)); readfile(stations.gzip); /Peter PS! To maintain the list and its functionality, do not post same message multiple times DS! -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 11:01 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] send a file or stream Ok it works, but it returns me the same .php file, not the one I am creating On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: You need to make sure that you are not outputting ANYTHING before you do this. I might guess that you have a whitespace in the top of the script. As soon as you output, the server can not send any more header information, and the browser will think it is just text instead of treating it as an octet-stream. /Peter _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:25 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] send a file or stream I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3· ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code: ?php $params = array('level' = 6, 'window' = 15, 'memory' = 9); $texto_original = This is a test.\nThis is only a test.\nThis is not an important string.\n; //echo El texto original tiene . strlen($texto_original) . caracteres.\n; $da = fopen('stations.gzip', 'w'); stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params); fwrite($da, $texto_original); fclose($da); header(Content-Type: application/octet-stream); readfile(stations.gzip); On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? Should do it then. if you know the path to the file :) _ From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 10:10 AM To: Peter Lauri Subject: Re: [PHP] send a file or stream 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. I want to send back the file to the user On 8/29/06, Peter Lauri [EMAIL PROTECTED] wrote: Do you mean the following: 1. A user sends a request to your server to get a compressed file 2. You compress the file on the server 3. You want to send back to compressed file to the server It is number 3 you asking for? In that case: ?php header(Content-Type: application/octet-stream); readfile(path_to_compressed_file); ? /Peter -Original Message- From: Rafael Mora [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 30, 2006 2:34 AM To: php-general@lists.php.net Subject: [PHP] send a file or stream Hi! i want to send a file or output stream in a .php, but first compress it, I tryed the example to compress files but how do i do to send as answer to the http request?? Rafa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php