[PHP] How to correctly validate url?
Hello, how to correctly validate url? now the special local characters like ÜÕÖÄ etc are allowed as well... Br, Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to correctly validate url?
it doesn't work. please see the results: var_dump(filter_var('http://example.com', FILTER_VALIDATE_URL)); var_dump(filter_var('http://example', FILTER_VALIDATE_URL)); var_dump(filter_var('http://exämple.com', FILTER_VALIDATE_URL)); http://example should be false http://exämple.com should be true -- please note the a with dots! Br, Tanel 18.01.2012 13:36, Vikash Kumar kirjutas: Best way is to use filter_var: http://in2.php.net/manual/en/function.filter-var.php filter_var('http://example.com', FILTER_VALIDATE_URL) On 18 January 2012 16:58, Tanel Tammikkeevit...@gmail.com wrote: Does anyone have a preg expression to validate the url which includes these special characters like ÜÕÄÖ included? Br, Tanel 18.01.2012 12:21, Mokaddim Akm kirjutas: Sent from a handheld device On 18-Jan-2012, at 4:05 PM, Tanel Tammikkeevit...@gmail.com wrote: Hello, how to correctly validate url? now the special local characters like ÜÕÖÄ etc are allowed as well... The generic URI syntax mandates that new URI schemes that provide for the representation of character data in a URI must, in effect, represent characters from the unreserved set without translation, and **should convert all other characters to bytes according to UTF-8, and then percent-encode those values**. This requirement was introduced in January 2005 with the publication of RFC 3986. URI schemes introduced before this date are not affected.[1] [1] http://en.wikipedia.org/wiki/**Percent-encodinghttp://en.wikipedia.org/wiki/Percent-encoding Br, Tanel -- 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] $_SERVER['REMOTE_ADDR'] and sql injection
Hi, is there a vulnerability with using $_SERVER['REMOTE_ADDR'] in sql queries? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['REMOTE_ADDR'] and sql injection
I was wondering, if there is a chance to manipulate the data this variable holds? Br Tanel Rene Veerman rene7...@gmail.com wrote in message news:aanlktikwldeucxkru-4ni4pet5lq_5cc_vstnwrtx...@mail.gmail.com... unlikely. it's a apache delivered ip address.. very little chance of insert vulnerabilities, imho. On Wed, Jun 23, 2010 at 8:53 AM, Tanel Tammik keevit...@gmail.com wrote: Hi, is there a vulnerability with using $_SERVER['REMOTE_ADDR'] in sql queries? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Greetings from Rene7705, My free open source webcomponents: http://code.google.com/u/rene7705/ http://mediabeez.ws/downloads (and demos) My music (i'm DJ firesnake) http://mediabeez.ws/music http://www.facebook.com/rene7705 - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['REMOTE_ADDR'] and sql injection
Michael Shadle mike...@gmail.com wrote in message news:aanlktildd_gdnlffpuwdx5acwwk45jbu4i6ybbmgj...@mail.gmail.com... On Wed, Jun 23, 2010 at 12:06 AM, Rene Veerman rene7...@gmail.com wrote: unlikely. it's a apache delivered ip address.. very little chance of insert vulnerabilities, imho. still, the overhead for a db escape is better than your site being trashed. also, you could look at converting the IP to an INT(10) (at least for IPv4) and save ip in string - 123.456.789.123 - up to 15 bytes - varchar(15) ip in integer format - 4 bytes - int(10) I've done this on a variety of projects. Arjen even mentions it back in 2005: http://arjen-lentz.livejournal.com/44290.html It does make things a bit harder to read, and at one point I did get different results when calculating it in PHP vs. MySQL (I forget when and how, and haven't seen the issue again) but if you're looking for IP ranges it can come in handy too - integer math is much cleaner than IP address math :) how do i convert it? with ip2long() or in sql with INET_ATON()? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Delete File With Any File Extension
Shaun Thornburgh shaunthornbu...@hotmail.com wrote in message news:bay148-w43caac3698e0134dfacc28ab...@phx.gbl... Hi, I need to delete a file with any file extension where i know the name of the file, is it possible to use regular expressions with the unlink function? Thanks _ http://clk.atdmt.com/UKM/go/19780/direct/01/ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now Hi, use glob() and then unlink with array_walk() Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array key's: which is correct?
Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] finding the web root
Hi, i like to find the web root where the current file is. is there a better solution? it must work both on linux and windows machines... ?php $root = explode('/', $_SERVER['DOCUMENT_ROOT']); $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); $web_root = '/' . implode('/', array_diff($cwd, $root)); echo $web_root; ? maybe there is a function for that :D:D:D Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] finding the web root
Jim Lucas li...@cmsws.com wrote in message news:4c0e99d9.20...@cmsws.com... Tanel Tammik wrote: Hi, i like to find the web root where the current file is. is there a better solution? it must work both on linux and windows machines... ?php $root = explode('/', $_SERVER['DOCUMENT_ROOT']); $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); $web_root = '/' . implode('/', array_diff($cwd, $root)); echo $web_root; ? maybe there is a function for that :D:D:D Br Tanel If I understand what you are asking for, I think this will work. ?php $web_root = basename($_SERVER['QUERY_STRING']); ? -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? var_dump($_SERVER['QUERY_STRING']); //outputs: string(0) Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] empty() and method return values
Hi, empty() cannot check the return value of the method or function. which would be the best workaround? empty($class-method()) // gets an error i could do $method_return_value = $class-method() and then run empty() on $method_return_value or is there an better option? i would like to do it in if statement i wrote an class for handling file uploads and there is an method getErrors() which returns empty array in case of 0 errors and i need to check it before i move any files. i'm just curious, what is the right way to do that! Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expression
Peter Lind peter.e.l...@gmail.com wrote in message news:aanlktilqkz8dnc0zacfv70tctf2wqkgpzojccqtuw...@mail.gmail.com... On 1 June 2010 17:33, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-01 at 16:31 +0100, Richard Quadling wrote: $re1 = '/^[a-z]++$/i'; $re2 = '/^[a-z ]++$/i'; -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling Why the double ++ in the expressions there? Surely one + would match the 1 or more characters that you need and the second one would just be surplus? Equally important: why have three people already done this persons homework. 5 minutes googling would have answered this ... -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype i made an regular expression now by myself. i need to check if string starts with 'get' and is followed only by letters a-z case insensitive. am i correct? '/^get[a-z]++$/i' Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] empty() and method return values
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275940320.2248.40.ca...@localhost... On Mon, 2010-06-07 at 22:40 +0300, Tanel Tammik wrote: Hi, empty() cannot check the return value of the method or function. which would be the best workaround? empty($class-method()) // gets an error i could do $method_return_value = $class-method() and then run empty() on $method_return_value or is there an better option? i would like to do it in if statement i wrote an class for handling file uploads and there is an method getErrors() which returns empty array in case of 0 errors and i need to check it before i move any files. i'm just curious, what is the right way to do that! Br Tanel Are you sure this is what is giving you the error, as people are using this fine in their examples on the manual page for empty() Thanks, Ash http://www.ashleysheridan.co.uk from the php manual: Note: empty() only checks variables as anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] empty() and method return values
Peter Lind peter.e.l...@gmail.com wrote in message news:aanlktinmvaqv-hdgjlq_dwoquvojbbmbfrixnxvqk...@mail.gmail.com... On 7 June 2010 21:52, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2010-06-07 at 22:40 +0300, Tanel Tammik wrote: Hi, empty() cannot check the return value of the method or function. which would be the best workaround? empty($class-method()) // gets an error i could do $method_return_value = $class-method() and then run empty() on $method_return_value or is there an better option? i would like to do it in if statement i wrote an class for handling file uploads and there is an method getErrors() which returns empty array in case of 0 errors and i need to check it before i move any files. i'm just curious, what is the right way to do that! Br Tanel Are you sure this is what is giving you the error, as people are using this fine in their examples on the manual page for empty() Empty only works on variables, not return values from functions. If you're checking the return value from a function, just do if ($class-method()). The return value will be cast to bool - look here for the conversions: http://dk2.php.net/manual/en/language.types.boolean.php Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype Thanks! It works... ?php class TestClass { protected $errors = array(); function getErrors() { return $this-errors; } } $class = new TestClass; if($class-getErrors()) { echo 'there is an value!'; } else { echo 'empty'; } ? No need to complicate things. Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: convert files utf8
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275607105.2217.31.ca...@localhost... On Fri, 2010-06-04 at 00:38 +0300, Tanel Tammik wrote: OP win xp pro Tanel Tammik keevit...@gmail.com wrote in message news:91.07.07323.be028...@pb1.pair.com... Hi, does anyone know how to convert all files in a directory and in it's subdirectories into utf8 encoding? i am using komodo edit as text-editor. may it has a feature which i cannot find... Br Tanel Could you not just open them all and save them again as utf8 files? Even notepad can save to utf8. Thanks, Ash http://www.ashleysheridan.co.uk Isn't there a xp program for that to convert all files at once? Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysql search html tags excluded
Hello, if there is some webpage content with html tags in database is it possible to search it without tags? data : 'div style=you need some styling!/div' when i now search for 'you style' i don't want to get any rows! is it possible? when i search 'you styling' i get the row! Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql search html tags excluded
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275651371.2217.46.ca...@localhost... On Fri, 2010-06-04 at 14:12 +0300, Tanel Tammik wrote: Hello, if there is some webpage content with html tags in database is it possible to search it without tags? data : 'div style=you need some styling!/div' when i now search for 'you style' i don't want to get any rows! is it possible? when i search 'you styling' i get the row! Br Tanel Use a second field in the DB that stores the content without any HTML tags. That way, you can search and not worry about tags and attribute values getting in the way. Thanks, Ash http://www.ashleysheridan.co.uk Is this the only way? Couldn't i do it in mysql query? Seems much cleaner... Br, Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql search html tags excluded
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275652342.2217.51.ca...@localhost... On Fri, 2010-06-04 at 14:44 +0300, Tanel Tammik wrote: Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275651371.2217.46.ca...@localhost... On Fri, 2010-06-04 at 14:12 +0300, Tanel Tammik wrote: Hello, if there is some webpage content with html tags in database is it possible to search it without tags? data : 'div style=you need some styling!/div' when i now search for 'you style' i don't want to get any rows! is it possible? when i search 'you styling' i get the row! Br Tanel Use a second field in the DB that stores the content without any HTML tags. That way, you can search and not worry about tags and attribute values getting in the way. Thanks, Ash http://www.ashleysheridan.co.uk Is this the only way? Couldn't i do it in mysql query? Seems much cleaner... Br, Tanel You could try and do it in MySQL with a regex to filter out the HTML tags. The regex would be real complex though, and prone to failure if the HTML wasn't perfectly formed. And it would be a *lot* slower than searching a plain text field. I think it's far cleaner to use a second field like that. Thanks, Ash http://www.ashleysheridan.co.uk OK! then i should use preg_replace before making the serch entry for DB storage? What would be the regular expression for that? Basically i need to get rid everything between the html tags with tags included? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql search html tags excluded
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275652880.2217.54.ca...@localhost... On Fri, 2010-06-04 at 14:54 +0300, Tanel Tammik wrote: Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275652342.2217.51.ca...@localhost... On Fri, 2010-06-04 at 14:44 +0300, Tanel Tammik wrote: Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1275651371.2217.46.ca...@localhost... On Fri, 2010-06-04 at 14:12 +0300, Tanel Tammik wrote: Hello, if there is some webpage content with html tags in database is it possible to search it without tags? data : 'div style=you need some styling!/div' when i now search for 'you style' i don't want to get any rows! is it possible? when i search 'you styling' i get the row! Br Tanel Use a second field in the DB that stores the content without any HTML tags. That way, you can search and not worry about tags and attribute values getting in the way. Thanks, Ash http://www.ashleysheridan.co.uk Is this the only way? Couldn't i do it in mysql query? Seems much cleaner... Br, Tanel You could try and do it in MySQL with a regex to filter out the HTML tags. The regex would be real complex though, and prone to failure if the HTML wasn't perfectly formed. And it would be a *lot* slower than searching a plain text field. I think it's far cleaner to use a second field like that. Thanks, Ash http://www.ashleysheridan.co.uk OK! then i should use preg_replace before making the serch entry for DB storage? What would be the regular expression for that? Basically i need to get rid everything between the html tags with tags included? Br Tanel No, you'd have to use a regex within MySQL, not PHP. Like I said, it would be very complex, and I wouldn't know where to begin writing a query that would search for specific strings and ignore any content within thewithout writing sub-queries. Also, you did see that I said it would be a lot slower didn't you? Imagine at the moment a query is taking a second to complete. With this sort of complex regex it could take maybe 5 seconds. That's 5 seconds per person searching. Are you not able to make a second field in the DB? Thanks, Ash http://www.ashleysheridan.co.uk Yes i can. You misunderestood me or i didn't express myself correctly. how can i get rid of the tags before entering the data into the second field created for search engine? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] constant from variable
Hi, define('MYCONST', 'something'); $my = 'my'; $const = 'const'; is it possible to get the value of MYCONST using variables $my and $const_ Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] convert files utf8
Hi, does anyone know how to convert all files in a directory and in it's subdirectories into utf8 encoding? i am using komodo edit as text-editor. may it has a feature which i cannot find... Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: convert files utf8
OP win xp pro Tanel Tammik keevit...@gmail.com wrote in message news:91.07.07323.be028...@pb1.pair.com... Hi, does anyone know how to convert all files in a directory and in it's subdirectories into utf8 encoding? i am using komodo edit as text-editor. may it has a feature which i cannot find... Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regular expression
How to check with regular expression (preg) if string has: 1. only letters 2. only letters and spaces Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get classname without namespace
Adam Richardson simples...@gmail.com wrote in message news:aanlktin0wqqlgwgm2lowcdv4i0c6bzsbfxhjwxv_j...@mail.gmail.com... On Sat, May 29, 2010 at 4:20 PM, Tanel Tammik keevit...@gmail.com wrote: Hi, is there a way to get the called classname without the namespace? ?php //PHP 5.3.x namespace some\where; abstract class ParentClass { public static function name() { return strtolower(get_called_class()); } public static function get_name() { echo 'name: ' . static::name(); } } class ChildClass extends ParentClass { } ChildClass::get_name(); ? the result i need: childclass the result i get: some\where\childclass also is it possible to get the name() into the static variable if only static method is called? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $childclass = end(explode('\', $class_name_with_ns)); also is it possible to get the name() into the static variable if only static method is called? Not sure I understand this part. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com yes, the static method is called and it's not possible... basicalli i'm making dynamic class for database manipulation where the child classname == tablename i just thought it would be not good to each time call name() as a method when tablename is need for sql query! Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MVC logic
Hello, i'm trying to break this thing down for my self. i made little application for that. could someone please take a look and let me know if what i wrote resembles MVC inviroment or not. http://keevitaja.com/kool http://keevitaja.com/kool/kool.rar Idea is to create it from scratch for educational purpose! Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get classname without namespace
Hi, is there a way to get the called classname without the namespace? ?php //PHP 5.3.x namespace some\where; abstract class ParentClass { public static function name() { return strtolower(get_called_class()); } public static function get_name() { echo 'name: ' . static::name(); } } class ChildClass extends ParentClass { } ChildClass::get_name(); ? the result i need: childclass the result i get: some\where\childclass also is it possible to get the name() into the static variable if only static method is called? Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php