php-general Digest 22 Jul 2009 07:41:20 -0000 Issue 6243
php-general Digest 22 Jul 2009 07:41:20 - Issue 6243 Topics (messages 295637 through 295658): Re: Converting SQL Dialects 295637 by: Ashley Sheridan 295640 by: Matt Neimeyer 295641 by: Andrew Ballard 295657 by: Paul M Foster Re: Search Query on two tables not working (RESOLVED) 295638 by: Miller, Terion Re: PHP and FoxPro 295639 by: Matt Neimeyer 295642 by: Floyd Resler Re: RFC/Survey for Our Newer Folks (Including Lurkers) 295643 by: Shawn McKenzie Re: A prepared statements question 295644 by: Shawn McKenzie Re: How to set find pathes for PHP CLI? 295645 by: Shawn McKenzie Doubt regarding session_destroy() in PHP 5 295646 by: Guruprasad 295647 by: Devendra Jadhav 295648 by: Phpster 295649 by: Floyd Resler 295650 by: Guruprasad 295652 by: Devendra Jadhav 295653 by: Lenin Back again with query problems and row problems 295651 by: Miller, Terion 295654 by: Jim Lucas newbie - Is there a calendar module for date entry? 295655 by: cool.hosting4days.com 295656 by: Jonathan Tapicer Re: Newbie: Composition by Association - Pagination Class general question. 295658 by: MEM Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote: Has anyone come across / written a script that will convert one flavor or Dialect of SQL to another? I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL. For the most part the problems are converting VFP functions to the equivalent SQL. For example, Visual FoxPro has a function inlist() that is used like inlist(X,1,2,3) which converts to the MySQL query X IN (1,2,3). That's easy enough (relatively speaking) but VFP also has stuff like EMPTY(X) where any of Null, the Empty String (for Char), -00-00 (or the VFP equivalent anyways for dates), False (for Boolean), 0 (for Numeric) are considered empty without needing to know the data type. So that starts getting a lot more complex since I'd need to check the data type of the field in the right table... to be able to convert it to something like (X is null OR X=) or (X is null OR x=0) etc... These are for customer stored queries... I've already manually converted system queries and I'm frustrated to the point of giving up and adding a column untested and let the end user figure it out but that seems bad from the standpoint of lazy and poor customer experience. Thanks! Matt P.S. I'm also going to post this to the MySQL general list but my fear is that they MIGHT say We only know MySQL so we can't help you with that other DBMS I'm hoping that by posting here someone might say well it's not to MySQL but I ran script XYZ to convert my VFP to PostgreSQL... or similar. I'm not sure it's as easy as you think it might be. As you get more into the various flavours of SQL, you notice their little idiosyncrasies that only exist within that one particular language branch. As such, it's often a task best left to people to try and convert from one to the other, rather than leave it to a machine. How complex are the queries that you are trying to convert anyway? Thanks Ash www.ashleysheridan.co.uk ---End Message--- ---BeginMessage--- Um... It depends? :) These are customer entered queries and vary based on the end user and the customizations they have. It could be as simple as WHERE inlist(SalesPerson,Bob,Bill,Fred) OR it could be something 12 lines long that pulls in criteria from multiple tables each of those with their own criteria. And by easy I meant simply that I would feel comfortable hacking together something to handle inlist(x,1,2,3) and change it to X in (1,2,3) it's the rest that worries me. Having slept on it, I'm probably going to write something that converts IN, checks for a list of forbidden words and then flags the resulting updated query if it contains any of those words. This way I can catch some of the low hanging fruit. My hope is that if X% of queries don't contain foxpro specific functions, and IN auto-conversions covers another X% of upgrades, and auto-convert FunctionX (whatever it is...) gives us another X% of upgrades... that this will result in a hopefully small number of saved queries that are flagged for manual upgrading. (And not be so painful in development that it still nets us saved time) Matt On Tue, Jul 21, 2009 at 1:54 PM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote: Has anyone come across / written a script that will convert one flavor or Dialect of SQL to
RE: [PHP] Re: Newbie: Composition by Association - Pagination Class general question.
As for (1) even in my pre-OO days I was used to using a single generic DAO for all database access. The only time that more than one DAO existed was for a different DBMS engine. This is why I have one DAO class for MySQL, one for PostgreSQL and another for Oracle. If you are incapable of writing a single generic DAO then it just shows that you still have a lot to learn. For an idea on how this works take a look at http://www.tonymarston.net/php-mysql/databaseobjects.html Before I dig in on this DAO, I'm wondering, where should I, and how could I, properly place a JOIN on this kind of pattern? Is it easy done or, on a JOIN scenario (and I will have a lot of them) I choose probably choose another pattern? Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: On Wed, Jul 22, 2009 at 3:24 AM, L.Guruprasad lgp171...@gmail.com wrote: Hi, Floyd Resler wrote: Keep in mind that sessions are based on the domain. I've run into situations where someone will be working in several different sites that we host. Each site is accessed via http://domain/site. Each site has it's own database, users, etc. However, because they all hang off the same domain, they get one session. That can really mess things up for the users as they go from site to site. I got around this by using MySQL-based sessions. It keeps things nice and separated. Take care, Floyd Will this be causing issues when http://1.a.b and http://2.a.b are the two PHP sites running on the same web server using virtualhosts? As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Tue, 2009-07-21 at 22:17 -0300, Jonathan Tapicer wrote: On Tue, Jul 21, 2009 at 10:06 PM, c...@hosting4days.comc...@hosting4days.com wrote: newbie ... - is there a calendar module for date fields? - so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...? BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for... http://us2.php.net/manual/en/intro.calendar.php -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan That's not what the op asked for. When I do these sorts of things, I tend to use Tigra calendar. They do two versions, the free and the pro version, but tbh, the free one does everything you need. It's very easy to set up too. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, Jul 22, 2009 at 2:46 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! *Storing Session Data In A Database *When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database. source: http://www.acunetix.com/websitesecurity/php-security-6.htm I have also studied Zend Certification Study guide by Davey Shafik and Ben Ramsey who said similar things in the book. Lenin http://twitter.com/nine_L
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, 2009-07-22 at 16:07 +0700, Lenin wrote: On Wed, Jul 22, 2009 at 2:46 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! *Storing Session Data In A Database *When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database. source: http://www.acunetix.com/websitesecurity/php-security-6.htm I have also studied Zend Certification Study guide by Davey Shafik and Ben Ramsey who said similar things in the book. Lenin http://twitter.com/nine_L And is the database not readable and writeable by PHP? Just seems that this sort of thing could be properly sorted by the right permissions level on the file, as I assume you'd be protecting the database in a similar manner by locking down that to specific users, and determining what they could and couldn't do. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
Check jQuery UI On 7/22/09, c...@hosting4days.com c...@hosting4days.com wrote: newbie ... - is there a calendar module for date fields? - so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...? BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for... http://us2.php.net/manual/en/intro.calendar.php -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Sent from my mobile device Use ROT26 for best security -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Replace in a string with regex
Hello, Im tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',_([0-9])), array(test,,), $file) The idea is to remove /temp and the last _1 from the file name..but im only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you
Re: [PHP] Replace in a string with regex
On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Newbie: Composition by Association - Pagination Class general question.
MEM tal...@gmail.com wrote in message news:000201ca0a9f$ca3fb110$5ebf13...@com... As for (1) even in my pre-OO days I was used to using a single generic DAO for all database access. The only time that more than one DAO existed was for a different DBMS engine. This is why I have one DAO class for MySQL, one for PostgreSQL and another for Oracle. If you are incapable of writing a single generic DAO then it just shows that you still have a lot to learn. For an idea on how this works take a look at http://www.tonymarston.net/php-mysql/databaseobjects.html Before I dig in on this DAO, I'm wondering, where should I, and how could I, properly place a JOIN on this kind of pattern? Is it easy done or, on a JOIN scenario (and I will have a lot of them) I choose probably choose another pattern? Regards, Márcio Adding a JOIN to the SQL statement which is generated by the framework is very easy, as shown in my FAQ at http://www.tonymarston.net/php-mysql/infrastructure-faq.html#faq08. You have two choices where you can place the code: (1) In the component script. (2) In the table class, as shown in http://www.tonymarston.net/php-mysql/infrastructure-faq.html#faq84 -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
On Wed, 2009-07-22 at 13:02 +0100, rszeus wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you Well, you seem to have some problems with the syntax you're using on str_replace(). According to your script, you want to remove the following: 7a45gfdi6icpan1jtb1j99o925- which you haven't even enclosed in quote marks 'temp/' ’_([0-9])’- which are using weird back ticks, not quote marks and you are trying to replace those three things with “test” - again, not proper quote marks ”” - not proper quote marks Afaik, str_replace() doesn't allow for text replacement using regular expressions, for that you'd have to use something like preg_replace() Also, make sure your strings are correctly enclosed in quote marks, and that the quote marks you use are actual quote marks and not the accented 'pretty' ones that are offered up by word processors, etc. A regex which would do the job would look something like this: ^([^/]+)[^_]+\/(.+)$ That should create 2 matches, one for the initial directory and the other for the latter part of the filename. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
You can do so much more with storing sessions in a database. For example, I can determine which of my users is currently on by looking in the sessions table. Not only does using a database for sessions offer more security, it also offers more flexibility. Take care, Floyd On Jul 22, 2009, at 5:13 AM, Ashley Sheridan wrote: On Wed, 2009-07-22 at 16:07 +0700, Lenin wrote: On Wed, Jul 22, 2009 at 2:46 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! *Storing Session Data In A Database *When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database. source: http://www.acunetix.com/websitesecurity/php-security-6.htm I have also studied Zend Certification Study guide by Davey Shafik and Ben Ramsey who said similar things in the book. Lenin http://twitter.com/nine_L And is the database not readable and writeable by PHP? Just seems that this sort of thing could be properly sorted by the right permissions level on the file, as I assume you'd be protecting the database in a similar manner by locking down that to specific users, and determining what they could and couldn't do. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, 2009-07-22 at 08:32 -0400, Floyd Resler wrote: You can do so much more with storing sessions in a database. For example, I can determine which of my users is currently on by looking in the sessions table. Not only does using a database for sessions offer more security, it also offers more flexibility. Take care, Floyd On Jul 22, 2009, at 5:13 AM, Ashley Sheridan wrote: On Wed, 2009-07-22 at 16:07 +0700, Lenin wrote: On Wed, Jul 22, 2009 at 2:46 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! *Storing Session Data In A Database *When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database. source: http://www.acunetix.com/websitesecurity/php-security-6.htm I have also studied Zend Certification Study guide by Davey Shafik and Ben Ramsey who said similar things in the book. Lenin http://twitter.com/nine_L And is the database not readable and writeable by PHP? Just seems that this sort of thing could be properly sorted by the right permissions level on the file, as I assume you'd be protecting the database in a similar manner by locking down that to specific users, and determining what they could and couldn't do. Thanks Ash www.ashleysheridan.co.uk But *how* does it offer more security? You've not actually mentioned that! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, Jul 22, 2009 at 3:50 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 22:17 -0300, Jonathan Tapicer wrote: On Tue, Jul 21, 2009 at 10:06 PM, c...@hosting4days.comc...@hosting4days.com wrote: newbie ... - is there a calendar module for date fields? - so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...? BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for... http://us2.php.net/manual/en/intro.calendar.php -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan That's not what the op asked for. When I do these sorts of things, I tend to use Tigra calendar. They do two versions, the free and the pro version, but tbh, the free one does everything you need. It's very easy to set up too. Thanks Ash www.ashleysheridan.co.uk Um what's the difference? I've used both the YUI and Tigra's free calendar. In both, you click on a button and a small calander widget pops up allowing the user to select a date for a field on a web form. Neither is a PHP feature; both rely on JavaScript. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, 2009-07-22 at 08:59 -0400, Andrew Ballard wrote: On Wed, Jul 22, 2009 at 3:50 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Tue, 2009-07-21 at 22:17 -0300, Jonathan Tapicer wrote: On Tue, Jul 21, 2009 at 10:06 PM, c...@hosting4days.comc...@hosting4days.com wrote: newbie ... - is there a calendar module for date fields? - so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...? BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for... http://us2.php.net/manual/en/intro.calendar.phpphp cannot connect to mysql -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan That's not what the op asked for. When I do these sorts of things, I tend to use Tigra calendar. They do two versions, the free and the pro version, but tbh, the free one does everything you need. It's very easy to set up too. Thanks Ash www.ashleysheridan.co.uk Um what's the difference? I've used both the YUI and Tigra's free calendar. In both, you click on a button and a small calander widget pops up allowing the user to select a date for a field on a web form. Neither is a PHP feature; both rely on JavaScript. Andrew Sorry, my bad, I misread the URL. Having a lot of stress here at the moment getting my laptop fixed :-/ Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, Jul 22, 2009 at 9:02 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: Sorry, my bad, I misread the URL. Having a lot of stress here at the moment getting my laptop fixed :-/ Isn't that called withdrawal? ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
Totally right on the corrections. Sorry, i did not copy paste from the source code, I wrote here to change to other names and wrote it bad. It should be: $file = 'screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg'; echo $a = str_replace(array('7a45gfdi6icpan1jtb1j99o925', 'temp/',’_([0-9])’), array('test','',''), $file) Already understand that str_replace doesn't work with regex, but not getting any luck making one preg_replace() to my needs. Thank you -Mensagem original- De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Enviada: quarta-feira, 22 de Julho de 2009 13:20 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, 2009-07-22 at 13:02 +0100, rszeus wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you Well, you seem to have some problems with the syntax you're using on str_replace(). According to your script, you want to remove the following: 7a45gfdi6icpan1jtb1j99o925- which you haven't even enclosed in quote marks 'temp/' ’_([0-9])’- which are using weird back ticks, not quote marks and you are trying to replace those three things with “test” - again, not proper quote marks ”” - not proper quote marks Afaik, str_replace() doesn't allow for text replacement using regular expressions, for that you'd have to use something like preg_replace() Also, make sure your strings are correctly enclosed in quote marks, and that the quote marks you use are actual quote marks and not the accented 'pretty' ones that are offered up by word processors, etc. A regex which would do the job would look something like this: ^([^/]+)[^_]+\/(.+)$ That should create 2 matches, one for the initial directory and the other for the latter part of the filename. Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
With proper permissions I'm not sure that it's any more secure but it certainly is a whole lot more scalable. And it is very easy to set up. A web search will yield a lot of examples of using a database. I use a PHP class which I really like. Take care, Floyd On Jul 22, 2009, at 8:36 AM, Ashley Sheridan wrote: On Wed, 2009-07-22 at 08:32 -0400, Floyd Resler wrote: You can do so much more with storing sessions in a database. For example, I can determine which of my users is currently on by looking in the sessions table. Not only does using a database for sessions offer more security, it also offers more flexibility. Take care, Floyd On Jul 22, 2009, at 5:13 AM, Ashley Sheridan wrote: On Wed, 2009-07-22 at 16:07 +0700, Lenin wrote: On Wed, Jul 22, 2009 at 2:46 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-07-22 at 03:45 +0700, Lenin wrote: As Floyd suggested keeping your sessions in the DB will give you better session management and security as well. Why would putting the session data in a database offer more security? I'm not meaning to try and poke holes in your idea, I genuinely don't know the answer! *Storing Session Data In A Database *When you use on-disk files to store session data, those files must be readable and writeable by PHP. On a multi-user hosting system, it is possible for other users to access your session data through the PHP process (but see the commentary on open_basedir in part 5 of this series. The best way to secure your session data is to store it in a database. source: http://www.acunetix.com/websitesecurity/php-security-6.htm I have also studied Zend Certification Study guide by Davey Shafik and Ben Ramsey who said similar things in the book. Lenin http://twitter.com/nine_L And is the database not readable and writeable by PHP? Just seems that this sort of thing could be properly sorted by the right permissions level on the file, as I assume you'd be protecting the database in a similar manner by locking down that to specific users, and determining what they could and couldn't do. Thanks Ash www.ashleysheridan.co.uk But *how* does it offer more security? You've not actually mentioned that! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, Jul 22, 2009 at 8:36 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: But *how* does it offer more security? You've not actually mentioned that! One way would be to encapsulate data access in stored procedures and deny direct table access on the session data. That way, even though the PHP account has access to the database where all sessions are stored, it can only call a ReadSession procedure that requires the session_id() as a parameter. That way, PHP would have to know the ID of the session and could not simply SELECT * FROM sessions. However, I haven't found many examples that use stored procedures. Most just use regular INSERT/SELECT/UPDATE/DELETE statements, which means that the PHP user has full access to the entire table. In that case, it's no more trivial to scan the session table than it is to scan the session save path looking for interesting stuff. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
rszeus wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Sometimes it's helpful to break a problem into smaller problems: ?php $a = str_replace( '/temp/', '/', $file ); $a = preg_replace( '#_\d+_#', '_', $a ); echo $a.\n; ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
You can disregard this, it's wrong (I missed a part of the requirements :) and there's other solutions already provided (my email client is weird when you switch to a folder it always displays the first entry as the last read, so sometimes I miss that there are new posts above... I just switched a few weeks ago. Cheers, Rob. Robert Cummings wrote: rszeus wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Sometimes it's helpful to break a problem into smaller problems: ?php $a = str_replace( '/temp/', '/', $file ); $a = preg_replace( '#_\d+_#', '_', $a ); echo $a.\n; ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, 2009-07-22 at 09:08 -0400, Andrew Ballard wrote: On Wed, Jul 22, 2009 at 9:02 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: Sorry, my bad, I misread the URL. Having a lot of stress here at the moment getting my laptop fixed :-/ Isn't that called withdrawal? ;-) Not quite, I have my main computer, but being without the laptop is quite annoying! The only thing now is getting the ruddy thing set up back to the way I want it! Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
The nice thing about the database, though, is that you can specify which MySQL user has access to the sessions table. That way you can really lock it down by giving access to only INSERT, SELECT, UPDATE, and DELETE just for that table. Thanks! Floyd On Jul 22, 2009, at 9:36 AM, Andrew Ballard wrote: On Wed, Jul 22, 2009 at 8:36 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: But *how* does it offer more security? You've not actually mentioned that! One way would be to encapsulate data access in stored procedures and deny direct table access on the session data. That way, even though the PHP account has access to the database where all sessions are stored, it can only call a ReadSession procedure that requires the session_id() as a parameter. That way, PHP would have to know the ID of the session and could not simply SELECT * FROM sessions. However, I haven't found many examples that use stored procedures. Most just use regular INSERT/SELECT/UPDATE/DELETE statements, which means that the PHP user has full access to the entire table. In that case, it's no more trivial to scan the session table than it is to scan the session save path looking for interesting stuff. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
Floyd Resler wrote: The nice thing about the database, though, is that you can specify which MySQL user has access to the sessions table. That way you can really lock it down by giving access to only INSERT, SELECT, UPDATE, and DELETE just for that table. Thanks! Floyd On Jul 22, 2009, at 9:36 AM, Andrew Ballard wrote: On Wed, Jul 22, 2009 at 8:36 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: But *how* does it offer more security? You've not actually mentioned that! One way would be to encapsulate data access in stored procedures and deny direct table access on the session data. That way, even though the PHP account has access to the database where all sessions are stored, it can only call a ReadSession procedure that requires the session_id() as a parameter. That way, PHP would have to know the ID of the session and could not simply SELECT * FROM sessions. However, I haven't found many examples that use stored procedures. Most just use regular INSERT/SELECT/UPDATE/DELETE statements, which means that the PHP user has full access to the entire table. In that case, it's no more trivial to scan the session table than it is to scan the session save path looking for interesting stuff. A custom session handler that writes to files could easily encrypt session data so that only the user with the correct session ID can decrypt it. I think you're confusing the issue by claiming database sessions are more secure when what you really mean is that custom sessions are more secure than the default session system. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] putenv usage
Hi All, I have a page where the user specifies in which timezone they belong to and based on that i have to show the date time. So I have to set the different timezones. For this I am using putenv function like: putenv(TZ=US/Eastern); Now my question is whether it is fine to use putenv in the production environment? Whether the putenv changes the timezone value globally for all request or for the current request only? Please advise. Regards, Manoj
Re: [PHP] putenv usage
2009/7/22 Manoj Singh manojsingh2...@gmail.com: Now my question is whether it is fine to use putenv in the production environment? Whether the putenv changes the timezone value globally for all request or for the current request only? The environment variable will only exist for the duration of the current request. - www.php.net/putenv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
On Wed, Jul 22, 2009 at 9:59 AM, Robert Cummingsrob...@interjinn.com wrote: A custom session handler that writes to files could easily encrypt session data so that only the user with the correct session ID can decrypt it. I think you're confusing the issue by claiming database sessions are more secure when what you really mean is that custom sessions are more secure than the default session system. What would you use for the encryption key? (I'm not saying you're wrong here; I'm just not sure I see it.) If the key is the same for all requests, then it is no more secure than if they were unencrypted, other than not being able to read the contents in a text editor. If it is based on the session_id, you can get that from the file name. That's a little more secure, but not much. A value stored in $_SESSION is out, for obvious reasons. I guess you could store the key in $_COOKIE or even a use a combination of (or hash derived from) session_id() and another value stored in $_COOKIE as the key. It seems to me that anything you can do to make file-based sessions secure could also be layered into a database approach, making the database sessions even that much more secure. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. I tested this, with the double quotes and the curly braces around the middle argument (to avoid PHP getting confused) and it didn't recognise the matches by the numbered $1, $3, etc. I know I'm not the op who asked the original question, but it might help him/her? Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. I tested this, with the double quotes and the curly braces around the middle argument (to avoid PHP getting confused) and it didn't recognise the matches by the numbered $1, $3, etc. I know I'm not the op who asked the original question, but it might help him/her? Thanks Ash www.ashleysheridan.co.uk To avoid confusion, rather than something like $1{$id}$3 Which looks really indecipherable, I'd definitely think something like '$1' . $id . '$3' is a lot easier to read and understand what's going on by immediately looking at it. As an added bonus, it'll definitely work ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I tested this, with the double quotes and the curly braces around the middle argument (to avoid PHP getting confused) and it didn't recognise the matches by the numbered $1, $3, etc. I know I'm not the op who asked the original question, but it might help him/her? Thanks Ash www.ashleysheridan.co.uk Don't you also have to escape the $'s for the matches since it's in double quotes? \$1{$id}\$3 Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doubt regarding session_destroy() in PHP 5
Andrew Ballard wrote: On Wed, Jul 22, 2009 at 9:59 AM, Robert Cummingsrob...@interjinn.com wrote: A custom session handler that writes to files could easily encrypt session data so that only the user with the correct session ID can decrypt it. I think you're confusing the issue by claiming database sessions are more secure when what you really mean is that custom sessions are more secure than the default session system. What would you use for the encryption key? (I'm not saying you're wrong here; I'm just not sure I see it.) If the key is the same for all requests, then it is no more secure than if they were unencrypted, other than not being able to read the contents in a text editor. If it is based on the session_id, you can get that from the file name. That's a little more secure, but not much. A value stored in $_SESSION is out, for obvious reasons. I guess you could store the key in $_COOKIE or even a use a combination of (or hash derived from) session_id() and another value stored in $_COOKIE as the key. It seems to me that anything you can do to make file-based sessions secure could also be layered into a database approach, making the database sessions even that much more secure. Andrew Well, if you're using a custom session handler to encrypt the files, then you can also determine what the session file names are. So don't put the session id in the file name. Maybe use a secure hash of the session id for the filename and then use the session id as the encryption key. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Jul 21, 2009, at 6:17 PM, Jonathan Tapicer wrote: That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/ calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The Yahoo UI looks great. On Jul 22, 2009, at 12:50 AM, Ashley Sheridan wrote: When I do these sorts of things, I tend to use Tigra calendar. They do two versions, the free and the pro version, but tbh, the free one does everything you need. It's very easy to set up too. Hi Ashley - the free one seems to be just the thing. - thanks Thanks to all - They both look good - I'm checking them out now! Another newbie question: storing dates and times... I'm trying to build a simple notepad page where I can attach a date and even time field. So this Tigra or yahoo calendar will be great date picker helper. This is for the US, so I'd like the user to see normal us formatting like: date field - 7/1/2009 and separate time field like: 11:30 AM mysql can use a DATE or TIME or datetime field type. and seems to use a different standard like: -MM-DD I want to to be able to do date calcs and such - so what is the best way (types) to store these fields in mysql and display them on the page with php? I do know about some of the cool php functions like: echo date('m-d-y g:i a', strtotime($row_this['myDate'])); so do I? ... store the date and time in separate fields then manipulate the display with php functions or??? - just looking for any favorite practices -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, 2009-07-22 at 08:41 -0700, c...@hosting4days.com wrote: On Jul 21, 2009, at 6:17 PM, Jonathan Tapicer wrote: That is javascript thing, not PHP. The Yahoo UI has a nice one, here you have an example: http://developer.yahoo.com/yui/examples/calendar/ calcontainer_clean.html, and here the module reference: http://developer.yahoo.com/yui/calendar/ Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The Yahoo UI looks great. On Jul 22, 2009, at 12:50 AM, Ashley Sheridan wrote: When I do these sorts of things, I tend to use Tigra calendar. They do two versions, the free and the pro version, but tbh, the free one does everything you need. It's very easy to set up too. Hi Ashley - the free one seems to be just the thing. - thanks Thanks to all - They both look good - I'm checking them out now! Another newbie question: storing dates and times... I'm trying to build a simple notepad page where I can attach a date and even time field. So this Tigra or yahoo calendar will be great date picker helper. This is for the US, so I'd like the user to see normal us formatting like: date field - 7/1/2009 and separate time field like: 11:30 AM mysql can use a DATE or TIME or datetime field type. and seems to use a different standard like: -MM-DD I want to to be able to do date calcs and such - so what is the best way (types) to store these fields in mysql and display them on the page with php? I do know about some of the cool php functions like: echo date('m-d-y g:i a', strtotime($row_this['myDate'])); so do I? ... store the date and time in separate fields then manipulate the display with php functions or??? - just looking for any favorite practices -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] If you want to be doing date calculations within MySQL then you should MySQL's datetime or date type. You can use the date() function of PHP to format the date for display however you wish though, which might be worth looking at? Thanks Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - Is there a calendar module for date entry?
On Wed, Jul 22, 2009 at 08:41:23AM -0700, c...@hosting4days.com wrote: snip Another newbie question: storing dates and times... I'm trying to build a simple notepad page where I can attach a date and even time field. So this Tigra or yahoo calendar will be great date picker helper. This is for the US, so I'd like the user to see normal us formatting like: date field - 7/1/2009 and separate time field like: 11:30 AM mysql can use a DATE or TIME or datetime field type. and seems to use a different standard like: -MM-DD I want to to be able to do date calcs and such - so what is the best way (types) to store these fields in mysql and display them on the page with php? The -MM-DD is an ISO date format which makes date sorting simple. I typically store dates in this format in databases (though it's usually configurable). For outside-database uses, I coded a date class which uses Julian days as its basic unit of storage. One of the issues I wanted to avoid is the upcoming Y2K-like issue with Unix timestamps. In many places, unix timestamps are stored as 32 bit integers, which will reach their capacity, I believe, in 2038. (We'll probably all have 64 bit machines by then.) Thus, the class generally doesn't consult Unix timestamps This makes duration and date calculations simple. If you like, I can email you the class privately. Store times as a separate field. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
Hi, It doens't work. I get 0_main.jpg if I do that.. I don't undestand the point of $1 $2 and $3.. In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 and $3 ? $ I already knwo it's the (.+?) but the others didnt' get it. Thank you... -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 16:03 Para: a...@ashleysheridan.co.uk Cc: Jim Lucas; rszeus; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridana...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeusrsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeusrsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. I tested this, with the double quotes and the curly braces around the middle argument (to avoid PHP getting confused) and it didn't recognise the matches by the numbered $1, $3, etc. I know I'm not the op who asked the original question, but it might help him/her? Thanks Ash www.ashleysheridan.co.uk To avoid confusion, rather than something like $1{$id}$3 Which looks really indecipherable, I'd definitely think something like '$1' . $id . '$3' is a lot easier to read and understand what's going on by immediately looking at it. As an added bonus, it'll definitely work ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Confusion.
On Wed, Jul 22, 2009 at 1:19 PM, Dare Williamsdarrenwi...@yahoo.com wrote: Dear Forums, Kindly advice me professionally because, am getting more confused on what to do about my application that needed to be online very soon. The fear is about Session and Authentication. Here are my questions. 1. Must a Page Authentication be done by Session or Cookie. If not what are the other options. hidden id field in the html form 2. How secured is Session without encoding. encoding data? can be done, but as long as the session is stored local to the site and not in a shared folder on a shared hosting machine, its pretty safe Another option is to store the session in the database 3. Must you encode Sessions at all time and if not what type of Session. all depends on the application and your own level of paranoia 4. Is it dangerous to pass one Session on several Page. Nope, its the essence of sessions. How else to get the session data shared between pages? 5. What about locking a Session to an IP ..(tips needed) Don't. Some ISPs host a pool of addresses and the user's IP may switch during a single session. 5. Session Security tips please. This was just discussed in another thread here on sessions today. Search the archives. Thank You All. Williams. -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replace in a string with regex
rszeus wrote: Thank you. I undestand now. Anh it’s already workyng the replacemente with letteres. Bu if the variabele is a number it doens’t work. Any ideas ? $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = '70'; echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); You have a great big capital I in there... Try removing that and see what happens. I get 0 $id = 'test'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); I get screen/test Any ideas ? Thank you De: Kyle Smith [mailto:kyle.sm...@inforonics.com] Enviada: quarta-feira, 22 de Julho de 2009 17:22 Para: rszeus Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex The first match inside () is assigned to $1, the second is assigned to $2, and so on. rszeus wrote: Hi, It doens't work. I get 0_main.jpg if I do that.. I don't undestand the point of $1 $2 and $3.. In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 and $3 ? $ I already knwo it's the (.+?) but the others didnt' get it. Thank you... -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 16:03 Para: a...@ashleysheridan.co.uk Cc: Jim Lucas; rszeus; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridan mailto:a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular expressions, may I suggest you read up on them? http://www.regular-expressions.info/ is a pretty great free resource, as ridiculous as the design is. I tested this, with the double quotes and the curly braces around the middle argument (to avoid PHP getting confused) and it didn't recognise the matches by the numbered $1, $3, etc. I know I'm not the op who asked the original question, but it might help him/her? Thanks Ash www.ashleysheridan.co.uk To avoid confusion, rather than something like $1{$id}$3 Which looks really indecipherable, I'd definitely think something like '$1' . $id . '$3' is a lot easier to read and understand what's going on by immediately looking at it. As an added
[PHP] Client Side PHP
I need help on my project I want to have my browser do compling of PHP scripts. Can someone please send me some concepts and if possible codes to do this. I know this aspect will pose great security threat to the server and client but I will still love any help with this. Thanks, J. K
Re: [PHP] Client Side PHP
Javed Khan wrote: I need help on my project I want to have my browser do compling of PHP scripts. Can someone please send me some concepts and if possible codes to do this. I know this aspect will pose great security threat to the server and client but I will still love any help with this. Thanks, J. K Build an extension for FF... :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Client Side PHP
On Wed, Jul 22, 2009 at 1:56 PM, Javed Khaniankha...@yahoo.com wrote: I need help on my project I want to have my browser do compling of PHP scripts. Can someone please send me some concepts and if possible codes to do this. I know this aspect will pose great security threat to the server and client but I will still love any help with this. Thanks, J. K PHP is a server side language. If you want to have php as an executable on the client, you could look at www.roadsend.com for the compiler. Otherwise, you could create a dll on windows for for execution in IE or as jim mentioned, write an extension for FF -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
No, sory, my bad typing. It's not the problem.. I have the same on both caxses, only chnage the variable $id $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg $id = '70'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: 0 file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = test; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: screen/test What is wrong with having na integer on the var ? Thank you -Mensagem original- De: Jim Lucas [mailto:li...@cmsws.com] Enviada: quarta-feira, 22 de Julho de 2009 18:44 Para: rszeus Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex rszeus wrote: Thank you. I undestand now. Anh it’s already workyng the replacemente with letteres. Bu if the variabele is a number it doens’t work. Any ideas ? $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = '70'; echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); You have a great big capital I in there... Try removing that and see what happens. I get 0 $id = 'test'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); I get screen/test Any ideas ? Thank you De: Kyle Smith [mailto:kyle.sm...@inforonics.com] Enviada: quarta-feira, 22 de Julho de 2009 17:22 Para: rszeus Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex The first match inside () is assigned to $1, the second is assigned to $2, and so on. rszeus wrote: Hi, It doens't work. I get 0_main.jpg if I do that.. I don't undestand the point of $1 $2 and $3.. In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 and $3 ? $ I already knwo it's the (.+?) but the others didnt' get it. Thank you... -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 16:03 Para: a...@ashleysheridan.co.uk Cc: Jim Lucas; rszeus; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridan mailto:a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the second parameter, $2 is the string you'd want to replace to test so change '$1$2$3' to '$1test$3'. It seems like you're having trouble with regular
Re: [PHP] Replace in a string with regex
rszeus wrote: No, sory, my bad typing. It's not the problem.. I have the same on both caxses, only chnage the variable $id $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg $id = '70'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: 0 file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = test; Well, here you are trying to use a constant called test to set your variable $id. I would try surrounding test with single or double quotes echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: screen/test What is wrong with having na integer on the var ? Thank you -Mensagem original- De: Jim Lucas [mailto:li...@cmsws.com] Enviada: quarta-feira, 22 de Julho de 2009 18:44 Para: rszeus Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex rszeus wrote: Thank you. I undestand now. Anh it’s already workyng the replacemente with letteres. Bu if the variabele is a number it doens’t work. Any ideas ? $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = '70'; echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); You have a great big capital I in there... Try removing that and see what happens. I get 0 $id = 'test'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); I get screen/test Any ideas ? Thank you De: Kyle Smith [mailto:kyle.sm...@inforonics.com] Enviada: quarta-feira, 22 de Julho de 2009 17:22 Para: rszeus Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex The first match inside () is assigned to $1, the second is assigned to $2, and so on. rszeus wrote: Hi, It doens't work. I get 0_main.jpg if I do that.. I don't undestand the point of $1 $2 and $3.. In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 and $3 ? $ I already knwo it's the (.+?) but the others didnt' get it. Thank you... -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 16:03 Para: a...@ashleysheridan.co.uk Cc: Jim Lucas; rszeus; php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 11:01 AM, Ashley Sheridan mailto:a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk wrote: On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote: rszeus wrote: Thank you. What about instead test i want to insert a variable ? Like $id = 30; $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file); Sure that can be done. But you will need to change the second argument to have double quotes so it will be parsed by PHP. Then I would surround YOUR variable with curly brackets to separate it from the rest. echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#', $1{$id}$3, $file); I am confusing and '. Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 14:12 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 9:07 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hi. It Works to remove the _1 but it doesn't replace '7a45gfdi6icpan1jtb1j99o925' for 'test' Thank you -Mensagem original- De: Eddie Drapkin [mailto:oorza...@gmail.com] Enviada: quarta-feira, 22 de Julho de 2009 13:11 Para: rszeus Cc: php-general@lists.php.net Assunto: Re: [PHP] Replace in a string with regex On Wed, Jul 22, 2009 at 8:02 AM, rszeus mailto:rsz...@gmail.com rsz...@gmail.com wrote: Hello, I’m tryng to make some replacements on a string. Everything goês fine until the regular expression. $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo $a = str_replace(array(7a45gfdi6icpan1jtb1j99o925, 'temp/',’_([0-9])’), array(“test”,,””), $file) The idea is to remove /temp and the last _1 from the file name..but i’m only getting this: screens/test_1_main.jpg I want it to be: screens/test_main.jpg Thank you If you're trying to do a regular expression based search and replace, you probably ought to use preg_replace instead of str_replace, as str_replace doesn't parse regular expressions. Try this one out, I think I got what you wanted to do: ?php $file = screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg; echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file); In the
Re: [PHP] Session Confusion.
Dear Dare, I would recommend you to get the free copy of *chapter 10: Security from Zend Certification Study guide* by Ben Ramsey Davey Shafik at www.zceguide.com shorter tips: 1. You can apply session_regenerate_id() to prevent *session riding* or *session fixation* 2. You can keep $_SESSION['user_agent']=$_SERVER['HTTP_USER_AGENT'] and check for logged in user to prevent *session hijacking* 3. Cookie must be encrypted. 4. Filter All inputs and validate them 5. Escape all output 6. while filtering inputs use whitelist blacklist method Regards Lenin http://twitter.com/nine_L
RE: [PHP] Re: Newbie: Composition by Association - Pagination Class general question.
Thanks a lot Tony. Unfortunately for me, I'm seeing myself in no conditions for properly learning a framework. I want to learn PHP and a framework bring so many concepts at once, that I found extremely complex and time consuming do dig in, at once, right now. Since I have no more than a few months on PHP, I really need to keep it, as simple as possible, even if not perfectly structured, but, the understanding of all the steps involved should be included. Thanks a lot for your help, and sorry for, in some way, having wasting your time on this. Regards, Márcio Adding a JOIN to the SQL statement which is generated by the framework is very easy, as shown in my FAQ at http://www.tonymarston.net/php-mysql/infrastructure-faq.html#faq08. You have two choices where you can place the code: (1) In the component script. (2) In the table class, as shown in http://www.tonymarston.net/php-mysql/infrastructure-faq.html#faq84 -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- 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] Client Side PHP
On Thu, Jul 23, 2009 at 1:06 AM, Bastien Koert phps...@gmail.com wrote: On Wed, Jul 22, 2009 at 1:56 PM, Javed Khaniankha...@yahoo.com wrote: I need help on my project I want to have my browser do compling of PHP scripts. Can someone please send me some concepts and if possible codes to do this. I know this aspect will pose great security threat to the server and client but I will still love any help with this. Thanks, J. K PHP is a server side language. If you want to have php as an executable on the client, you could look at www.roadsend.com for the compiler. Otherwise, you could create a dll on windows for for execution in IE or as jim mentioned, write an extension for FF Sorry to Bastien and posting to the list again: @Javed Khan: If you just want to have php functions in client side JS then visit www.phpjs.org Did you try any good php IDE? like NetBeans 7.0 or Zend Studio or did you try Dreamweaver with site defined?
[PHP] unsetting a referenced parameter in a function
though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Client Side PHP
On Wed, Jul 22, 2009 at 4:03 PM, Leninle...@phpxperts.net wrote: www.phpjs.org That's hilarious! Thanks for that laugh =) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Confusion.
Hello For the authentication you can do a form, it will pass the login informations to some class who do the sql validation and put in session the informations of user, but not the password, i prefer put in session because when he close the browser the session will down for 2 , On the first point, session variables are not something people can get to from the client side unless you send them to them. What you see on the client side is a session identifier that allows the server to retrieve the actual session values. for 3 You dont need encode all the session for the security, if you want more security for some variables, encode just these for 4 One of the intentions of the session is store informations for the easy aplication access for 5 I think its not a good idea, the ip can change in the middle of the aplication Yuri Yarlei. Programmer PHP, CSS, Java, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Wed, 22 Jul 2009 10:19:44 -0700 From: darrenwi...@yahoo.com To: php-general@lists.php.net Subject: [PHP] Session Confusion. Dear Forums, Kindly advice me professionally because, am getting more confused on what to do about my application that needed to be online very soon. The fear is about Session and Authentication. Here are my questions. 1. Must a Page Authentication be done by Session or Cookie. If not what are the other options. 2. How secured is Session without encoding. 3. Must you encode Sessions at all time and if not what type of Session. 4. Is it dangerous to pass one Session on several Page. 5. What about locking a Session to an IP ..(tips needed) 5. Session Security tips please. Thank You All. Williams. _ Descubra todas as novidades do novo Internet Explorer 8 http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmailutm_medium=Taglineutm_campaign=IE8
[PHP] newbie question - php parsing
Hi all, A little doubt caught me while I was writing this snippet of code for a wordpress template: ?php if (the_title('','',FALSE) != 'Home') { ? h2 class=entry-header?php the_title(); ?/h2 ?php } ? I always thought that php was called only between the ?php ? tags, and I'm pretty sure that's right, while HTML code was simply wrote in document as is, without further logic. Now, I can't figure out how this snippet works: I mean, shouldn't HTML code be simply put on document, as it is outside php invoke? Effectively if the title of page is 'Home', the HTML part is totally skipped. Is the if construct that does all the magic inside? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] putenv usage
You can use the date_default_timezone_set(), it will set the default timezone to your timezone choose, some server denied the access to the environment variable Yuri Yarlei. Programmer PHP, CSS, Java, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. Date: Wed, 22 Jul 2009 15:16:25 +0100 From: phpm...@jawbone.freeserve.co.uk To: manojsingh2...@gmail.com CC: php-general@lists.php.net Subject: Re: [PHP] putenv usage 2009/7/22 Manoj Singh manojsingh2...@gmail.com: Now my question is whether it is fine to use putenv in the production environment? Whether the putenv changes the timezone value globally for all request or for the current request only? The environment variable will only exist for the duration of the current request. - www.php.net/putenv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Compartilhe os momentos mais importantes da sua vida. http://www.microsoft.com/brasil/windows/windowslive/products/photos-share.aspx?tab=1
[PHP] Re: newbie question - php parsing
You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? -- João Cândido de Souza Neto SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS Fone: (0XX41) 3033-3636 - JS www.siens.com.br Sebastiano Pomata lafayett...@gmail.com escreveu na mensagem news:70fe20d60907221355m3fa49a75ua053d2f1b9aca...@mail.gmail.com... Hi all, A little doubt caught me while I was writing this snippet of code for a wordpress template: ?php if (the_title('','',FALSE) != 'Home') { ? h2 class=entry-header?php the_title(); ?/h2 ?php } ? I always thought that php was called only between the ?php ? tags, and I'm pretty sure that's right, while HTML code was simply wrote in document as is, without further logic. Now, I can't figure out how this snippet works: I mean, shouldn't HTML code be simply put on document, as it is outside php invoke? Effectively if the title of page is 'Home', the HTML part is totally skipped. Is the if construct that does all the magic inside? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: newbie question - php parsing
2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? ?= the_title(); ? also works. -Shane -- João Cândido de Souza Neto SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS Fone: (0XX41) 3033-3636 - JS www.siens.com.br Sebastiano Pomata lafayett...@gmail.com escreveu na mensagem news:70fe20d60907221355m3fa49a75ua053d2f1b9aca...@mail.gmail.com... Hi all, A little doubt caught me while I was writing this snippet of code for a wordpress template: ?php if (the_title('','',FALSE) != 'Home') { ? h2 class=entry-header?php the_title(); ?/h2 ?php } ? I always thought that php was called only between the ?php ? tags, and I'm pretty sure that's right, while HTML code was simply wrote in document as is, without further logic. Now, I can't figure out how this snippet works: I mean, shouldn't HTML code be simply put on document, as it is outside php invoke? Effectively if the title of page is 'Home', the HTML part is totally skipped. Is the if construct that does all the magic inside? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: newbie question - php parsing
Ted Turner http://www.brainyquote.com/quotes/authors/t/ted_turner.html - Sports is like a war without the killing. 2009/7/23 Shane Hill shanehil...@gmail.com 2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? ?= the_title(); ? Short tag and not recommended as its deprecated now, would be void at PHP 6.0
Re: [PHP] Re: newbie question - php parsing
This is how I'd write this snippet ?php if ( 'Home' !== ( $title = the_title('','',FALSE))) { echo 'h2 class=entry-header', $title, '/h2'; } ? On Wed, Jul 22, 2009 at 6:31 PM, Lenin le...@phpxperts.net wrote: Ted Turner http://www.brainyquote.com/quotes/authors/t/ted_turner.html - Sports is like a war without the killing. 2009/7/23 Shane Hill shanehil...@gmail.com 2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? ?= the_title(); ? Short tag and not recommended as its deprecated now, would be void at PHP 6.0 -- Martin Scotta
[PHP] Calculating number of checkers (draughts) possible positions
I am trying to calculate the number of possible checkers position - at first without including promotion (queen/king). Each player starts with 12 pieces in his color, And the whole board has 32 places (64 / 2). At first glance I thought - each place can be occupied by either black piece, white piece, or nothing. Which means 3^32 is the answer. Then I realized it can't be, since there is maximum of 12 pieces in each color, And if are for example 10 white pieces (-2), then: +2 empty squares. I thought about the following - We got minimum of 8 places that aren't occupied, So I start with 1 ^ 8 (which is 1) I got 12 squares that have either white or nothing - which means 1^8 * 2^12 And of course another 12 taken by black or nothing Which means 1^8 * 2^12 * 2^12 = 2^24 Its not the final number, There are a lot less, I just don't know how to add it to the equation... -- Use ROT26 for best security
[PHP] Re: unsetting a referenced parameter in a function
Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie question - php parsing
João Cândido de Souza Neto wrote: You made a mistake in your code: ?php the_title(); ? must be: ?php echo the_title(); ? I haven't used worpress in a long time, but the the_title() function might echo the title unless you pass the FALSE parameter, in which case it just returns it. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Replace in a string with regex
-Original Message- From: rszeus [mailto:rsz...@gmail.com] Sent: 22 July 2009 19:23 To: 'Jim Lucas' Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php- gene...@lists.php.net Subject: RE: [PHP] Replace in a string with regex No, sory, my bad typing. It's not the problem.. I have the same on both caxses, only chnage the variable $id $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg $id = '70'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: 0 file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = test; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: screen/test What is wrong with having na integer on the var ? Well, the problem here is that when you concatenate $id containing 70 on to '$1', you effectively end up with '$170' -- which the manual page at http://php.net/preg-replace makes clear is ambiguous, but is likely to be treated as $17 followed by a zero, rather than $1 followed by 70. Since $17 doesn't exist (as you don't have that many capturing subpatterns in your pattern!), it is taken to be the null string -- leaving just the left over 0 as the result of the replacement. QED. The workaround for this is also given on the page referenced above, which is to make your replacement be '${1}'.$id. Incidentally, I don't really see the need for the $1, or the equivalent parentheses in the pattern -- since a fixed string is involved, why not just use it directly in both places? Like this: preg_replace('#screen/temp/(.+?)_1(.+?\.jpg)#', 'screen/'.$id, $file); which completely sidesteps the problem. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
RE: [PHP] Replace in a string with regex
Thank you very much! Understand. And it Works very well now. Cheers -Mensagem original- De: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] Enviada: quinta-feira, 23 de Julho de 2009 00:04 Para: php-general@lists.php.net Assunto: RE: [PHP] Replace in a string with regex -Original Message- From: rszeus [mailto:rsz...@gmail.com] Sent: 22 July 2009 19:23 To: 'Jim Lucas' Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php- gene...@lists.php.net Subject: RE: [PHP] Replace in a string with regex No, sory, my bad typing. It's not the problem.. I have the same on both caxses, only chnage the variable $id $file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg $id = '70'; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: 0 file = screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg; $id = test; echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id, $file); Get: screen/test What is wrong with having na integer on the var ? Well, the problem here is that when you concatenate $id containing 70 on to '$1', you effectively end up with '$170' -- which the manual page at http://php.net/preg-replace makes clear is ambiguous, but is likely to be treated as $17 followed by a zero, rather than $1 followed by 70. Since $17 doesn't exist (as you don't have that many capturing subpatterns in your pattern!), it is taken to be the null string -- leaving just the left over 0 as the result of the replacement. QED. The workaround for this is also given on the page referenced above, which is to make your replacement be '${1}'.$id. Incidentally, I don't really see the need for the $1, or the equivalent parentheses in the pattern -- since a fixed string is involved, why not just use it directly in both places? Like this: preg_replace('#screen/temp/(.+?)_1(.+?\.jpg)#', 'screen/'.$id, $file); which completely sidesteps the problem. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: unsetting a referenced parameter in a function
On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the variable wasn't destroyed. once i understood what was happening, i thought it a bit confusing to have such scope-dependent differences in behavior of a language element. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: unsetting a referenced parameter in a function
On Wed, Jul 22, 2009 at 9:27 PM, Tom Worster f...@thefsb.org wrote: On 7/22/09 6:09 PM, Shawn McKenzie nos...@mckenzies.net wrote: Tom Worster wrote: though the manual is perfectly clear that this should be expected, i was a bit surprised that the result of the following is 42 ?php function foo($a) { $a = 42; unset($a); $a = 'meaning'; } foo($a); print($a\n); ? normally i would expect unset() to free some memory. but in this example it doesn't and has a different behavior: it releases foo's reference to the global $a, allowing the next line to define a local $a. i think i'd have preferred compile error. Well, you unset the reference and then you assigned 'meaning' to a local function variable $a. Why would you get a compile error? when you state it in those terms (which are clearly correct) i wouldn't. but if the way i think is unset() destroys the specified variables (as the manual puts it) then i expect that the specified variable would be destroyed, not the reference. so, as i said, i was a bit surprised when the variable wasn't destroyed. once i understood what was happening, i thought it a bit confusing to have such scope-dependent differences in behavior of a language element. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php RTM: http://php.net/unset The behavior of *unset()* inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is *unset()* inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before *unset()* was called. / ... / If a variable that is PASSED BY REFERENCE is *unset()* inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before *unset()* was called. I think the manual is very clear about unset. -- Martin Scotta
[PHP] help with stream filter
Hi, everyone Has anyone tried to use stream filter to decompress a large file? My problem when doing this is memory consume. My php process requires more and more memory as time goes. Is this a bug or just I don’t get the right usage? My code as follows: 26 $fp = fopen ( $filename, 'r' ); 27 $filter = stream_filter_append($fp, 'bzip2.decompress', STREAM_FILTER_READ); 28 29 $counter = 0; 30 while ( ! feof ( $fp ) ) 31 { 32 $counter ++; 33 $line = fgets ( $fp ); Thanks!
[PHP] How to build an FF extension
How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K
Re: [PHP] How to build an FF extension
On Wed, Jul 22, 2009 at 08:31:10PM -0700, Javed Khan wrote: How to build an FF extension and how to install it. I'm using Fedora 10 operating system. Can someone please provide me with the steps Thanks J.K Let me substitute for Dan here. You're asking this on a PHP list, which isn't the appropriate venue for such a question. Firefox/Mozilla lists would be a better place to ask. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mediawiki's url confusion
Hi everyone: I've been studying the codes of Mediawiki for some time. I'm convinced that the file index.php is the only entrance to the whole site. But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? My first post ^_^ .And,I'm not sure if this issue should be talked here^_^. thank you however~ Lamp Deng 09/07/23
Re: [PHP] newbie - Is there a calendar module for date entry?
Here is a simple but effective one, which has the advantage of optionally doing datetime. -- -- http://www.rainforestnet.com If anyone knows of others that do both date and datetime, I'd love to see them. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mediawiki's url confusion
On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?? wrote: Hi everyone: I've been studying the codes of Mediawiki for some time. I'm convinced that the file index.php is the only entrance to the whole site. But I cannot help myself with the url pattern : /somepath_to_mediawiki/index.php/pagetitle. How can this kind of url be parsed to the file index.php and the pagetitle be parsed as params? Why the web server not go straight into path index.php/ and look for the file named pagetitle ? This type of thing is common for sites using the MVC or Model-View-Controller paradigm. The index.php file is what's called a front controller. A front controller is usually the entrance to all the other pages of a site. URLs like this often take advantage of an Apache feature called mod_rewrite, which tells Apache how to handle URLs which look like this. You can look on wikipedia.org for these terms or google for them, and find full explanations. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php