Re: [PHP] Re: PHP preg_replace help

2007-09-18 Thread Arpad Ray
Apologies if you already received this message, I tried to send it earlier from my webmail but it doesn't seem to have worked. Al wrote: Just use stripslashes() on your submitted data and forget about testing for magic_quotes. It's good practice anyhow. \ is not legit text regardless.

Re: [PHP] PHP preg_replace help

2007-09-17 Thread Arpad Ray
Jim Lucas wrote: Here is a nice little hack that I use. Little hack it is, nice it isn't. Ideally just turn off magic_quotes_gpc - you can do so in php.ini, or perhaps your web server configuration files (httpd.conf, .htaccess etc.). If you don't have access to any of the above then

Re: [PHP] repetition of tedious references

2007-07-19 Thread Arpad Ray
. It remains to be seen in the final version whether that notice is raised or that this operator exists at all Arpad it would be great if php 6 could have a solution for this. php is sweet when it's compact! On 18/07/07, Arpad Ray [EMAIL PROTECTED] wrote: You can use empty() to take one of them out

Re: [PHP] repetition of tedious references

2007-07-18 Thread Arpad Ray
Olav Mørkrid wrote: consider the following statement: $language = isset($_SERVER[HTTP_ACCEPT_LANGUAGE]) $_SERVER[HTTP_ACCEPT_LANGUAGE] != ? $_SERVER[HTTP_ACCEPT_LANGUAGE] : *; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three* times,

Re: [PHP] magic quotes

2007-07-17 Thread Arpad Ray
Phil Princely wrote: What do people on this list usually do with this kind of problem. To me, the .htaccess seems the easiest solution, since I don't have to change any scripts. I would certainly turn it off in php.ini or apache config files if possible (the .htaccess line should be php_flag

Re: [PHP] magic quotes

2007-07-17 Thread Arpad Ray
Phil Princely wrote: thanks for all the help. My code was wrong in the first post, I just copied it straight from the web. This one works: if (get_magic_quotes_gpc()) { stripslashes_array($_GET); stripslashes_array($_POST); stripslashes_array($_REQUEST);

Re: [PHP] regular expression and forbidden words

2007-07-17 Thread Arpad Ray
Nicolas Quirin wrote: Hi, i'm french, i'm using regular expressions in php in order to rewrite hyperlink tags in a specific way before apache output is beeing sent to client. Purpose is to replace href attribute of any A html tag by a javascript function calling an ajax loader. Currently I

Re: [PHP] Removing Spaces from Array Values

2007-07-03 Thread Arpad Ray
Jim Lucas wrote: foreach ( $someArray AS $k = $v ) { $someArray[$k] = preg_replace('!\s!', '', $v);// Removes white space ' ', \n, \r\n, etc... $someArray[$k] = str_replace(' ', '', $v);// Removes only spaces } str_replace() also operates on arrays so there's no need for

Re: [PHP] php and Ajax problem

2007-05-29 Thread Arpad Ray
Richard Kurth wrote: if(response.indexOf('|' != -1)) { Spot the misplaced bracket. if($_GET['takeaction']==delete){ $uid=$_GET['uid']; echo $uid; This is wide open to XSS attacks, you need to be just as careful with scripts intended to be accessed via javascript as you do with

Re: [PHP] Re: self:: vs this

2007-05-11 Thread Arpad Ray
M.Sokolewicz wrote: Basically what you can remember here is: :: calls a property or method in a STATIC context (ie. without access to the object's (if any) actual properties) - calls a propert or method in a DYNAMIC context (ie. WITH access to that specific object's collection of methods and

Re: [PHP] Separating words based on capital letter

2007-04-24 Thread Arpad Ray
Roman Neuhauser wrote: implode(' ', preg_split('~(?=[[:upper:]])~', 'FooBarBaz', -1, PREG_SPLIT_NO_EMPTY)); Or just.. preg_replace('/\B[A-Z]/', ' $0', 'FooBarBaz') Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Duplicate dates in array

2007-04-02 Thread Arpad Ray
Dave Goodchild wrote: Any ideas on the most efficient way to do it? I am working on using combinations of array_search, in_array and so on and want to avoid regular expressions if I can. Many thanks in advance for any suggestions! If you mean that you only want one date for each month (you'll

Re: [PHP] Form Handler Script Security Discussion

2007-03-29 Thread Arpad Ray
Many legitimate users will have their referrer blocked by proxies or by browser preference so you'll also have false negatives. Arpad cajbecu wrote: ? if($_POST eregi(getenv(SERVER_NAME),getenv(HTTP_REFERER))) { // This is a safe POST }

Re: [PHP] Populating array with function

2007-02-27 Thread Arpad Ray
Brad Bonkoski wrote: $files[] = $entry; perhaps look into the array_push() function http://www.php.net/array_push $files[] = $entry; is perfectly fine. $thumbnailFiles=listFiles($thumbnailsDirectory); printpre; print_r($thumbnailsFiles); print/pre; The code is fine, spot the

Re: [PHP] Problems processing UNIX timestamps in events directory

2007-02-20 Thread Arpad Ray
Dave Goodchild wrote: I have converted the user-friendly date output to timestamps to check and sure enough, when the user selects a start date before March 26 2007, March 26 2007 is output as: 1174863600 ...after that it becomes: 117486 ...a difference of 3600 Is this anything to do

Re: [PHP] Re: How to upload files up to 40MB with a html post form?

2007-02-14 Thread Arpad Ray
Sergiu Voicu wrote: In the second case, and if PHP isn't in safe mode, at the beggining of your script place this line ini_set(upload_max_filesize,41M); ini_set() will have no effect there because by the time the script is executed, the upload has finished. You can probably use php_value to

Re: [PHP] Retrieve value of newly inserted row.

2007-02-14 Thread Arpad Ray
Dan Shirah wrote: On my second insert statement, please note credit_card_id. This is an auto_increment column in table1. What I need to do is pull the value of credit_card_id from the newly inserted row from insert1 and put that value in a variable to assign it to credit_card_id in insert2.

Re: [PHP] how to get original post data?

2007-02-12 Thread Arpad Ray
$post = file_get_contents('php://input'); Or for older versions of PHP, just use $HTTP_RAW_POST_DATA. Arpad Nicholas Yim wrote: Hello EveryOne, like parse the soap request body not through $_POST nor $_FILE Best regards, Nicholas Yim [EMAIL PROTECTED] 2007-02-12 --

Re: [PHP] OT - Regular Expression

2007-02-09 Thread Arpad Ray
Roman Neuhauser wrote: This shouldn't do too much backtracking, try it out: *8* = /^(?:\d*8\d*){4}$/ The {4} in there repeats the subpattern 4 times, rather than limiting it to 4 characters. I really can't think of an elegant to do what you ask with regex - why limit yourself to regex

Re: [PHP] convert date to reversed date

2007-01-30 Thread Arpad Ray
$filename = implode(array_reverse(explode('/', $value))); Arpad Reinhart Viane wrote: Is this a good way to convert 01/02/2007 to 20070201 $value='01/02/2007'; list($day, $month, $year) = split('[/.-]', $value); $filename=$year.''.$month.''.$day; It does work but i would like to

Re: [PHP] preg_match problem

2007-01-20 Thread Arpad Ray
Martin Alterisio wrote: Double slash to prevent PHP interpreting the slashes. Also using single quotes would be a good idea: if (preg_match('/[\\w\\x2F]{6,}/',$a)) Just switching to single quotes would do the trick - you don't need to escape anything but single quotes, and backslashes if

Re: [PHP] Normalized Numbers

2007-01-12 Thread Arpad Ray
Have you checked out the PEAR Validate packages? http://pear.php.net/package/Validate_ISPN in particular might help you along ;) And BTW, most servers are set up to display php files renamed to .phps with syntax highlighting, so give that a try instead of .php.txt next time. Regards, Arpad

Re: [PHP] Regular Expression help

2007-01-04 Thread Arpad Ray
Those patterns aren't anchored to the ends of the string, so as long as the string contains one matching character, the succeeds. ^ anchors the pattern to the beginning, \z to the end, so you want: /^[A-Za-z]+\z/ Or test the opposite case to see if it fails: /[^A-Za-z]/ Arpad Chris Boget

Re: [PHP] Regular Expression help

2007-01-04 Thread Arpad Ray
Note that $ allows a trailing newline, but \z doesn't. Arpad Stut wrote: Chris Boget wrote: ?php echo 'Is String: [' . ( is_string( 'a1b2c3' ) preg_match( '/[A-Za-z]+/', 'a1b2c3' )) . ']br'; echo 'Is Numeric: [' . ( is_numeric( 'a1b2c3' ) preg_match( '/[0-9]+/', 'a1b2c3' )) . ']br'; echo

Re: [PHP] help with \n\r in strings

2006-12-29 Thread Arpad Ray
Angelo Zanetti wrote: So is there a way to test for \r\n? or what else can I use to delimit these two values (last column of row and first column of next row)? Since it's coming from a file, you might as well just read it with file(), which will split

Re: [PHP] http_build_query ... argh

2006-11-10 Thread Arpad Ray
Jochem Maas wrote: Arpad Ray wrote: return preg_replace('#%5[bd](?=[^]*=)#ei', 'urldecode(\0)', $s); could you explain your regexp - I'd like to replace my version with your (if for no other reason than that shorter code is easier to read than longer code!) BUT until I really understand

Re: [PHP] http_build_query ... argh

2006-11-09 Thread Arpad Ray
Jochem Maas wrote: function inputPostQueryUnBorker($s) { return preg_replace('#(\?|(?:amp;)?)([^=]*)=#eU', '\\1'.str_replace(array('%5B','%5D'), array('[',']'), '\\2').'=', $s); } so how bad is it This is a bit more concise. I

Re: [PHP] heredoc usage [WAS: OPTION]

2006-10-26 Thread Arpad Ray
Incidentally, a nice side effect of heredoc is that some editors (like vim) recognise EOHTML, EOSQL etc and highlight the contents accordingly. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] any one can give an idea on this question ?

2006-10-26 Thread Arpad Ray
Sancar Saran wrote: For example I had a several php pages. In this page there was an array named $arrHede It has lots of values. in index.php $arrHede['antin']='yada'; in config.php $arrHede['kuntin']='bada'; and so. So I want to write a scrpit check all those files to get all $arrHede

Re: [PHP] Date verification

2006-10-09 Thread Arpad Ray
Ron Piggott (PHP) wrote: Is there a PHP function which verifies a valid date has been entered (-MM-DD)? Ron preg_match('/^(\d{4})-(\d\d)-(\d\d)\z/', $s, $m) checkdate($m[2], $m[3], $m[1]) Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] correctly reading binary data from http post

2006-09-15 Thread Arpad Ray
Marek 'MMx' Ludha wrote: I need to send large binary data over http post (so that urlencoding or base64 encoding is not an option). I use request like this: http://people.ksp.sk/~mmx/request (there is a zero byte between A and B). There are 3 bytes of data, but when I do ?php echo

Re: [PHP] Ajax and PHP: XMLHTTP

2006-09-11 Thread Arpad Ray
Micky Hulse wrote: ?=$_SERVER['PHP_SELF']? Can I replace the above with some sort of XMLHTTP request? As noted, that's a javascript question. However your PHP code is vulnerable to XSS attacks; you should at least encode the output with htmlspecialchars() so that URLs like

Re: [PHP] switch it button

2006-08-23 Thread Arpad Ray
Ford, Mike wrote: How about something like: a href=?php echo $_SERVER['PHP_SELF'] ??session_switch=?php $_GET['session_switch']?0:1 ?switch/a Beware that PHP_SELF is injectable like several other $_SERVER variables, so you must at least encode it to prevent XSS attacks. Eg.

Re: [PHP] Emphasizing first letter of string?

2006-08-22 Thread Arpad Ray
?php foreach ($strings as $key = $string) { $strings[$key] = 'em' . $string[0] . '/em' . substr($string, 1); } ? Micky Hulse wrote: Hi, It is getting late, and I do not think I am thinking clearly... What would be the best way to wrap em/em tag around the first letter of a string? I

Re: [PHP] Overriding core functions

2006-08-22 Thread Arpad Ray
You can't just define a new function with the same name. The only way I know to literally redefine the function is using the runkit extension - http://pecl.php.net/package/runkit That allows you to rename functions as well as moving them, so you could rename it to something like

Re: [PHP] Overriding core functions

2006-08-22 Thread Arpad Ray
Brad Bonkoski wrote: Some already good workarounds given for this question... BUT. Is it even possible to override a core function? Like I wrote a function called 'exit' and I got a parser error, which leads me to believe it is not even possible to override the core functions. Is this true of