Re: [PHP] preg for unicode strings?
Andy, try that one: /^[a-zA-Z]{3}|\p{Sc}$/u You don't want to put \p{Sc} in square brackets as \p{Sc} itself already is a character class. Umm.. Kinda don't make myself clear here, do I? You just don't want to, it's 5am in the morning here I gotta go to the next bed ;p Regards, Niels Andy Pieters: Hi Thank you for your reply. My regexp was /^([a-zA-Z]{3,}|[\W])/ Meaning match any string that is either 3 letters or 1 word character I'd like to change this to 3 letters or 1 currency character So I changed the regexp accordingly /^([a-zA-Z]{3,}|[\p{Sc}])/u And I tested with £ but it fails. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg for unicode strings?
Andy, you might want to check out http://www.regular-expressions.info/unicode.html Please note two things while using the described syntax: 1. You have to additionally use the u modificator. 2. While \p{Ll} for instance works in PHP, \p{Lowercase_Letter} doesn't. Regards, Niels Hi List I am doing some data validation and the following regexp fails [\W] When using characters like £ or € Obviously because they are technically more then one character, even though they are only displayed as one. The script is encoded in UTF-8 Anybody know a fix for this? With kind regards Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach / unset
Why should this be unsafe (whatever the heck that means) in any way? Of course you can do it. Regards, Niels. [sorry for mailing to your private address. wrong button :)] Anyway, can you do *this* safely as a DOCUMENTED FEATURE: foreach($array as $k = $v){ if (...) unset($array[$k]); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ICQ
so I'd suggest taking a look at the Perl libraries for ICQ/AIM and other IM clients that you can probably adapt to PHP without too much work. Check www.cpan.org for this. Or sniff the traffic of a normal ICQ client and learn the protocol that way. Alternatively you could search for a library, I'm quite sure there are some out there. Try liboscar, libicq or libaim.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling competing edits in a wiki engine?
Skippy: The real downside I see it having to rely on JavaScript, but that's that. The real downside - if I understand the concept correctly - ist that an open browser window isn't equal to an 'active' session. I.e. the famous lunch break still breaks the application as the ping is sent to the server without an user actually sitting in front of the page and editing it. All those session based systems are at best suboptimal anyway. Besides the timeout-problem there are other issues to consider such as editing outside of the page (in a client based editor) an then just copy 'n' paste the changes back into the page. So I'd say the mediawiki approach as outlined by Jasper is the best possible in the context of a stateless protocol such as HTTP. Regards, Niels -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change the order in which Objects are unloaded
Thanks for your reply, Jasper. auto_append_file has been my first alternative approach too and so far it seems to be the best option available. But the show-stopper to me is that if you exit() out of your script, the file won't be appended. I did write some sort of wrapper function to first append the file and then do an exit(), however an error (obviously no notices or warnings) will still prevent the file from being loaded. You may argue that e.g. an E_ERROR will stop exection of the script anyway and no shutdown handler will be called whatsoever but this is only partially right as an error in an included file won't stop the shutdown handler (registered in the including file) from being called. So if i depend on objects (which have been initialized during script runtime) even after an error occured, apparently there still is no way to do it. You may wonder what all the fuss is about, thinking that this is only a theoretical problem. I'm collecting debugging information during script runtime and store them in an object's properties. At the very end of my script I want those information to either be displayed or logged. As you can imagine, those information are a lot more valuable in an error context. I _could_ save them in a global variable which I could access without any problem in my shutdown function, however I'm quite happy with the flexibility of my object oriented approach and rather wouldn't like to change it. Anymory ideas? Regards, Niels Jasper Bryant-Greene: Niels Ganser wrote: I use a Debugger-Class to collect debugging information (now that was a hard guess, wasn't it..) during script runtime. In order to collect everything there is to collect, I instantiate a debugger object right at the start of my scripts and unload this object at the very end of my shutdown function. Unfortunately as of PHP 5.0.5 objects get unloaded before the shutdown function is even called and as Jani Taskinen pointed out [1] this behaviour is very much intended and won't get changed (whatever the reason for this decision might be..) with all related bugs marked Bogus [2] or a documentation issue [3]. I have to admit that it wouldn't be much of a deal to store the debugging information outside the object but I like the approach I took and fear that I might run into other problems with objects getting destroyed before others which depend on the previous ones, so my question is (tadaa): Is there a way to sort of customize the order in which objects are unloaded during the shutdown procedure? I have to stress that defining the classes and/or instantiate the objects in a specific order is _not_ an option. [1] http://marc.theaimsgroup.com/?l=php-devm=112556389406774 [2] http://bugs.php.net/bug.php?id=34377 [3] http://bugs.php.net/bug.php?id=33772 This is a really nasty bug, which has been preventing me from upgrading to PHP 5.0.5. Unfortunately it doesn't look like it will be fixed any time soon. The most descriptive bug report is [3], bug ID 33772, above. The only workaround I've come up with (although pretty ugly) is to use an auto_append_file [1] that executes the necessary destructors in the order you want them. This file will be executed before PHP starts destroying objects. HTH [1] http://php.net/ini.core#ini.auto-append-file -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sanitize paths
Hi, I'm working on a script which basically loads an image, the user requested and wonder how to properly sanitize the passed path. For instance the user should never ever be able to do somtehing like ?load=../../../etc/passwd. My approach so far is to simply urldecode() the given string and return an error if .. is found in it. Maybe I'm a little paranoid but is this really enough? For clarification: All paths are prefixed with some kind of a root path. All images within this root path may be accessed but jumping out of it should not be allowed. Regards, Niels. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sanitize paths
Thanks for your reply, Philip. realpath() is your friend... That has been my first impression too, but... realpath() expands all symbolic links I am actually using symlinks :) I trust the files on my server so local redirects via symlinks are no problem, the user submitted data is. Regards, Niels. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] launch app
No way. PHP is server based you can't trigger anything on the client side. Use Javascript, ActiveX, XUL or the like. What's the best way to send an executable to a client desktop in PHP? I'm doing a project where we need to check and see which files need to be updated on a client-desktop. The idea is for a user to visit the website, an executable launches, checks the files on the drive, and then sends the data back to the website. It's all on the up and up - I'm not trying to do anything bad to the user. The site is designed to maintain a product that they're purchasing from us. Screens will explain what's going on. I also believe the browser will display something - not completely sure how to trigger this, but I think it's something to do with having executables signed - I'd appreciate if you have any advice on how to do this also. Thanks, Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Accessing images in a protected directory
Unfortunately, you can't pass along a username/password to apache in a simple way. Well, what about http://user:[EMAIL PROTECTED] I personally wouldn't send cleartext passwords to a client's browser which might cache them and stuff, but possible it is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array2string
string implode(string glue, array pieces) [1] Regards, Niels [1] http://php.net/manual/en/function.implode.php Pardon my ignorance and lack of ability to form the right search for google, but I'm trying to figure out if there's a simple function in PHP to convert array values to a string with a separator for each value. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switching php version
Choose the right module. Search your apache config for LoadModule php5_module resp. LoadModule php4_module. How to configure apache to select one particular from several installed php? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert a timestamp to RFC822??
Usually you can use a function in your SELECT statement to change the format of your timestamp. In MySQL it's DATE_FORMAT [1]. Otherwise use PHP's Date and Time Functions [2]. You could for instance extract the ingredients of your database's timestamp with strptime [3] and reformat it with strftime [4]. Regards, Niels [1] http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html#id2728257 [2] http://php.net/manual/en/ref.datetime.php [3] http://php.net/manual/en/function.strptime.php [4] http://php.net/manual/en/function.strftime.php I get my timestamp from the db in this format (I don't have control over this): 2004-05-14 13:24:48 I need to convert it to RFC822 to make it a valid RSS pubDate field like this: Wed, 02 Oct 2002 13:00:00 GMT How can I do that? I'm tearing my hair out here (what's left)... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Change the order in which Objects are unloaded
Hi everybody. I use a Debugger-Class to collect debugging information (now that was a hard guess, wasn't it..) during script runtime. In order to collect everything there is to collect, I instantiate a debugger object right at the start of my scripts and unload this object at the very end of my shutdown function. Unfortunately as of PHP 5.0.5 objects get unloaded before the shutdown function is even called and as Jani Taskinen pointed out [1] this behaviour is very much intended and won't get changed (whatever the reason for this decision might be..) with all related bugs marked Bogus [2] or a documentation issue [3]. I have to admit that it wouldn't be much of a deal to store the debugging information outside the object but I like the approach I took and fear that I might run into other problems with objects getting destroyed before others which depend on the previous ones, so my question is (tadaa): Is there a way to sort of customize the order in which objects are unloaded during the shutdown procedure? I have to stress that defining the classes and/or instantiate the objects in a specific order is _not_ an option. Any hint would be appreciated. Thanks in advance, Niels. [1] http://marc.theaimsgroup.com/?l=php-devm=112556389406774 [2] http://bugs.php.net/bug.php?id=34377 [3] http://bugs.php.net/bug.php?id=33772 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php