[PHP] RE: need a find/replace command to fix my require_once
> -Original Message- > From: Nathan Rixham [mailto:nrix...@gmail.com] > Sent: Friday, November 20, 2009 1:29 AM > To: Daevid Vincent > Cc: php-general@lists.php.net > Subject: Re: need a find/replace command to fix my require_once > > Daevid Vincent wrote: > > I was reading this: > http://pear.php.net/manual/en/standards.including.php > > and it states: > > > > "Note: include_once and require_once are statements, > not functions. > > Parentheses should not surround the subject filename." > > > > I never knew that. I've always (wrongly) used: > > > > require_once('/path/to/my/file'); > > > > if it ain't broken don't fix it - why not just ensure you do it the > correct way (or preferred way) in the future. > > sure the time could better be invested fixing a bug, writing a test or > documenting something. I considered this of course. But... [a] Other coders will no doubt take a completed page as a template and modify, thereby causing MORE erroneous syntactical code. [b] I can't think of any other language that uses parenthesis for an 'include' (C, Perl, Java, Ruby, etc.) with the exception of maybe LOLcode. [c] It does seem to be the PHP blessed way (PEAR or not) looking at their examples even. [d] it was a good exercise in learning more about 'sed', 'find' and bash pipes. Not that I wrote it all, but deciphering what others showed me really helped. [e] because I'm a guy and a coder, and that's what we do. We do stuff 'just cause' and we 'refactor' useless shit for our own satisfaction. ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: need a find/replace command to fix my require_once [webform solved]
> I tried to post this note to here: > http://us2.php.net/manual/add-note.php > But the stupid-ass form says: > "Your note contains a prohibited (usually SPAM) word. Please > remove it and try again." > WTF!? It doesn't even TELL me what f'n word is the problem. > Seriously? It already asked me the stpid math question and now this B.S.? I have to laugh because I removed the text: http://php.net/manual/en/function.include.php http://php.net/manual/en/function.require.php http://php.net/manual/en/function.require-once.php http://php.net/manual/en/function.include-once.php And the submit note worked. LOL. So apparently one of those words in there is considered SPAM by PHP's own web form. Ha! Suckas. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating users and generating privileges for users
Hey can one help me in creating different users using mysql for php and assigning different privileges for them ..any sample code available? -- PASULA NITIN REDDY Graduate Student in Computer Science Department University of Minnesota,Twin Cities Minneapolis.
RE: [PHP] Re: need a find/replace command to fix my require_once [solved]
> -Original Message- > From: Shawn McKenzie [mailto:nos...@mckenzies.net] > Sent: Friday, November 20, 2009 7:42 AM > To: Nathan Rixham > Cc: Daevid Vincent; php-general@lists.php.net > Subject: [PHP] Re: need a find/replace command to fix my require_once > > Nathan Rixham wrote: > > Daevid Vincent wrote: > >> I was reading this: > http://pear.php.net/manual/en/standards.including.php > >> and it states: > >> > >>"Note: include_once and require_once are statements, > not functions. > >> Parentheses should not surround the subject filename." > >> > >> I never knew that. I've always (wrongly) used: > >> > >> require_once('/path/to/my/file'); > >> > > > > if it ain't broken don't fix it - why not just ensure you do it the > > correct way (or preferred way) in the future. > > > > sure the time could better be invested fixing a bug, > writing a test or > > documenting something. > > > > s'all your call though :) > > I agree. That's a PEAR coding standard, so unless you're > coding a PEAR > package it doesn't matter. It's the PEAR groups opinion. If you look > at some other project, they may require the parentheses for > readability. Well now, I am confused because these pages: http://us2.php.net/manual/en/function.include.php http://us2.php.net/manual/en/function.require.php http://us2.php.net/manual/en/function.require-once.php http://us2.php.net/manual/en/function.include-once.php All show them as functions: Include(), require(), require_once(), include_once() Yet ALL of their examples show the PEAR way: http://pear.php.net/manual/en/standards.including.php include_once "a.php"; I opted to just do it anyways since it seems that is the "official" way. To change all require_once('foo.php'); to require_once 'foo.php' execute this: cd /var/www/ find . -name '*.php' -print | xargs egrep -l \ 'require_once\s*(\(.*\));'\ | xargs sed -i.sedorig -e \ 's/require_once\s*(\(.*\));/require_once \1;/' (thanks to Robert Hajime Lanning for that) Then to remove all the ".php.sedorig" backup files execute this: find . -name "*.php.sedorig" -type f -exec rm -rf {} \; I tried to post this note to here: http://us2.php.net/manual/add-note.php But the stupid-ass form says: "Your note contains a prohibited (usually SPAM) word. Please remove it and try again." WTF!? It doesn't even TELL me what f'n word is the problem. Seriously? It already asked me the stupid math question and now this B.S.? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which query is more correct?
On Fri, Nov 20, 2009 at 04:41:58PM -0600, LAMP wrote: > Hi, > I need to pull all records from the table Registrants they are NOT > in the table ToBeRecleared > > Registrants.Reg_ID is PK > ToBeRecleared.tbrc_Reg_ID is PK > > Which query is more correct? > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM > toberecleared) > > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where > tbrc_reg_id=r.reg_id) = 0 > > I checked explain of bot queries - but can't "read" them. :-) SELECT t1.* FROM registrants t1 LEFT JOIN ToBeRecleared t2 on t1.reg_id = t2.tbrc_reg_id where t2.tbrc_reg_id is NULL -- "Every major horror of history was committed in the name of an altruistic motive." -- Ayn Rand, The Fountainhead, 1943 Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Which query is more correct?
On Fri, 20 Nov 2009 16:41:58 -0600, LAMP wrote: > SELECT r.* > FROM registrants r > where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM > toberecleared) > > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where > tbrc_reg_id=r.reg_id) = 0 > > I checked explain of bot queries - but can't "read" them. :-) Like Ashley, I'd probably go with the first one. The other one seems a little backwards. Out of curiosity, what *does* EXPLAIN say about them? /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
On Nov 20, 2009, at 2:29 PM, Ashley Sheridan wrote: > On Fri, 2009-11-20 at 17:23 -0500, Phil Matt wrote: > >> Ashley Sheridan wrote: >> >>> put >>> >>> var_dump($row); >>> >> I inserted this line in the script at the end of the html table, still >> inside the PHP echo statement. >> >> This yields: >> >> bool(false) >> >> Cheers --- Phil > > > That means that $row doesn't contain what you thought it did. It > contains the boolean value false (which is different from the string > 'false') Are you sure you spelt the varialbe correctly in all of your > code? This may be a dumb question, but did you actually fetch the db query's results and put them in $row before trying to use $row? In MySQL you could do something like: $query = "select * from my_table"; $result = mysql_query($query); $row = mysql_fetch_array($result); //this statement would need to be inside of a loop if there is more than one result -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which query is more correct?
On Fri, 2009-11-20 at 16:41 -0600, LAMP wrote: > Hi, > I need to pull all records from the table Registrants they are NOT in > the table ToBeRecleared > > Registrants.Reg_ID is PK > ToBeRecleared.tbrc_Reg_ID is PK > > Which query is more correct? > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM > toberecleared) > > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where > tbrc_reg_id=r.reg_id) = 0 > > I checked explain of bot queries - but can't "read" them. :-) > > Thanks, > L > I'd go with the first, just because thats how I'd code it if I was doing this myself, as it just makes more sense to the way I write my queries Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Which query is more correct?
Hi, I need to pull all records from the table Registrants they are NOT in the table ToBeRecleared Registrants.Reg_ID is PK ToBeRecleared.tbrc_Reg_ID is PK Which query is more correct? SELECT r.* FROM registrants r where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM toberecleared) SELECT r.* FROM registrants r where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where tbrc_reg_id=r.reg_id) = 0 I checked explain of bot queries - but can't "read" them. :-) Thanks, L -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 17:23 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > put > > > > var_dump($row); > > > I inserted this line in the script at the end of the html table, still > inside the PHP echo statement. > > This yields: > > bool(false) > > Cheers --- Phil That means that $row doesn't contain what you thought it did. It contains the boolean value false (which is different from the string 'false') Are you sure you spelt the varialbe correctly in all of your code? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: put var_dump($row); I inserted this line in the script at the end of the html table, still inside the PHP echo statement. This yields: bool(false) Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 17:08 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > > As Mike pointed out, I meant var_dump(), sorry! > > > > Is the idea to put the variable in question within the parentheses? > > I tried the statement, > > var_dump($row[3]; > > And I got in the output: > > NULL > > Also tried > > var_dump(); > > And I got in the output: > > Warning: Wrong parameter count for var_dump() in... > > I reread the PHP manual for var_dump. I still don't see where it goes in > the PHP script or how to implement it. > > Cheers --- Phil put var_dump($row); Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: As Mike pointed out, I meant var_dump(), sorry! Is the idea to put the variable in question within the parentheses? I tried the statement, var_dump($row[3]; And I got in the output: NULL Also tried var_dump(); And I got in the output: Warning: Wrong parameter count for var_dump() in... I reread the PHP manual for var_dump. I still don't see where it goes in the PHP script or how to implement it. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Does PHP block requests?
> -Original Message- > From: Peter Ford [mailto:p...@justcroft.com] > Sent: 20 November 2009 16:40 > You're right about trying to use the same session - that was the > plan to get the > progress state passed across from one call to the other. > Closing the session on the generator script has the effect of > stopping any > further changes to the session variable, so I get the initial value > at each > request after that. Yes, that would be the expected effect of putting in a session_commit() at the beginning. > Perhaps I can do it with some other message passing mechanism (e.g. > a temporary > file) instead of the $_SESSION. Yes, that would be a way to go. Another alternative is to re-start the session each time you want to write an updated value into it and then immediately close it again. The cost of opening and closing a session to write a value into it compared to opening and closing a file to write a value into it may be a factor here, but I leave that comparison as an exercise for the reader. Others on the list may, of course, chip in with further options, or have other useful, or at least witty, comments. 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] Change styling depending on var value
On Fri, 2009-11-20 at 16:41 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > That's not a vardump, a vardump would contain the type of variable. I > > wanted to see the whole thing. > > I played with this for a while and checked the PHP manual; not sure how > to use this. > > > Cheers --- Phil As Mike pointed out, I meant var_dump(), sorry! Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: That's not a vardump, a vardump would contain the type of variable. I wanted to see the whole thing. I played with this for a while and checked the PHP manual; not sure how to use this. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Change styling depending on var value
> -Original Message- > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: 20 November 2009 21:16 > To: Phil Matt > Cc: php-general@lists.php.net > Subject: Re: [PHP] Change styling depending on var value > > On Fri, 2009-11-20 at 16:17 -0500, Phil Matt wrote: > > > Ashley Sheridan wrote: > > > > > copy the results of this: > > > > > > vardump($row); > > > > > Sirloin Steak freshAcmemeat > > Chicken Breast frozen Acmemeat > > Decaf Columbianpantry Giant coffee > > Ice Cream frozen Giant dessert > > > > All looks as expected. > > NB: This is just test data until I get the formatting right. > > > > Cheers --- Phil > > > That's not a vardump, a vardump would contain the type of variable. > I > wanted to see the whole thing. > Ash, you mean var_dump! Phil, put var_dump($row); right before your if statement and report the result back to this list. 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] Change styling depending on var value
On Fri, 2009-11-20 at 16:17 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > copy the results of this: > > > > vardump($row); > > > Sirloin SteakfreshAcmemeat > Chicken Breast frozen Acmemeat > Decaf Columbian pantry Giant coffee > Ice Creamfrozen Giant dessert > > All looks as expected. > NB: This is just test data until I get the formatting right. > > Cheers --- Phil That's not a vardump, a vardump would contain the type of variable. I wanted to see the whole thing. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: copy the results of this: vardump($row); Sirloin Steak freshAcmemeat Chicken Breast frozen Acmemeat Decaf Columbianpantry Giant coffee Ice Cream frozen Giant dessert All looks as expected. NB: This is just test data until I get the formatting right. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 15:52 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > Copying back the phplist *again*! > Sorry. I'll remember to copy in... > > > > what does your code currently look like now, with the right == in? > > $entree="meat"; > $beverage="coffee"; > if ($row[3] == $entree) > { > $newcolor="color:red"; > } > elseif ($row[3] == $beverage) > { > $newcolor="color:red"; > } > else > { > $newcolor="color:green"; > > > The result is that all of the text in the styled cell is green. > > '.$row[3].' > > I know the script is running through the conditional statement, because > if I change the ELSE value of $newcolor, all of the styled cells change > to whatever color I specify there. > > I went back and browsed the db table to see to make sure I had the right > row and that the entries matched my references - no probs there. > > Cheers --- Phil > copy the results of this: vardump($row); Thanks, Ash http://www.ashleysheridan.co.uk
Re: RES: [PHP] CSS and variables
Jônatas Zechim wrote: Try: echo '' . $row[1] . ''; Thanks, Jônatas. This was the solution. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Dan McCullough wrote: To add to what Ashley said about $row[3], remember that when you are returning from the db the counter for fields will start at 0 not 1, so if its the 3rd field that will be $row[2]. You might also want to do switch rather then elseif but thats always a good debate. Thanks, Dan. I had checked that a while ago. I also tried the same script on a different row, changing the strings in the variables to match the data in the fields - same result, always defaults to the ELSE color. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
Ashley Sheridan wrote: Copying back the phplist *again*! Sorry. I'll remember to copy in... what does your code currently look like now, with the right == in? $entree="meat"; $beverage="coffee"; if ($row[3] == $entree) { $newcolor="color:red"; } elseif ($row[3] == $beverage) { $newcolor="color:red"; } else { $newcolor="color:green"; The result is that all of the text in the styled cell is green. '.$row[3].' I know the script is running through the conditional statement, because if I change the ELSE value of $newcolor, all of the styled cells change to whatever color I specify there. I went back and browsed the db table to see to make sure I had the right row and that the entries matched my references - no probs there. Cheers --- Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change styling depending on var value
To add to what Ashley said about $row[3], remember that when you are returning from the db the counter for fields will start at 0 not 1, so if its the 3rd field that will be $row[2]. You might also want to do switch rather then elseif but thats always a good debate. On Fri, Nov 20, 2009 at 3:16 PM, Ashley Sheridan wrote: > On Fri, 2009-11-20 at 15:11 -0500, Phil Matt wrote: > > > Ashley Sheridan wrote: > > > > > Well, you're main problem here is that you are only using a single = > > > character. What that is saying to PHP is: "if you let me assign the > > > value of $beverage to $row[3] then do this next bit", but what I think > > > you wanted it to say was "if $row[3] is the same as $beverage then do > > > this next bit", which would need == instead of = > > > > > > > Thanks, Ashley. I don't do enough PHP to get used to the syntax. > > > > I changed the operators to ==, but my conditional apparently isn't > > working correctly. I checked to make sure the values in the cells were > > the strings as I've specified them, but the resultant formatting always > > defaults to the ELSE color. > > > > Must be something very simple, but I'm just not getting it. > > > > Cheers --- Phil > > > Don't forget to reply to all! > > Just a quick question, what do you get if you do: > > print $row[3]; > > Does it contain a string like you expect? > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > >
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 15:30 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > print $row[3]; > > > > Does it contain a string like you expect? > > > > Yes. I'm going to try the same kind of formatting on a different $row > cell and see what happens. > > Cheers and thanks again --- Phil Copying back the phplist *again*! what does your code currently look like now, with the right == in? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 15:11 -0500, Phil Matt wrote: > Ashley Sheridan wrote: > > > Well, you're main problem here is that you are only using a single = > > character. What that is saying to PHP is: "if you let me assign the > > value of $beverage to $row[3] then do this next bit", but what I think > > you wanted it to say was "if $row[3] is the same as $beverage then do > > this next bit", which would need == instead of = > > > > Thanks, Ashley. I don't do enough PHP to get used to the syntax. > > I changed the operators to ==, but my conditional apparently isn't > working correctly. I checked to make sure the values in the cells were > the strings as I've specified them, but the resultant formatting always > defaults to the ELSE color. > > Must be something very simple, but I'm just not getting it. > > Cheers --- Phil Don't forget to reply to all! Just a quick question, what do you get if you do: print $row[3]; Does it contain a string like you expect? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Change styling depending on var value
On Fri, 2009-11-20 at 14:45 -0500, Phil Matt wrote: > I am trying to style HTML table cells depending on the values stored in > a MySQL db. Thanks to other on this list, I can now refer to the > variable that holds a CSS styling value. > > Now, I need to apply different values of that variable, depending on the > content of the table cell itself. > > I tried something like this, where $row[3] contains string values: > > $entree ="meat"; > $dessert ="ice cream"; > $beverage="coffee"; > > (then the query that returns the data) > > if ($row[3] = $entree) > { > $rowcolor = "color:red"; > elseif ($row[3] = $dessert) > { > $rowcolor = "color:blue"; > elseif ($row[3] = $beverage) > { > $rowcolor = "color:green"; > } > else > { > $rowcolor ="color:black"; > } > > I think I'm not properly expressing that I want the values in the > $row[3] compared to those in the specified vars > > Thanks again. > Well, you're main problem here is that you are only using a single = character. What that is saying to PHP is: "if you let me assign the value of $beverage to $row[3] then do this next bit", but what I think you wanted it to say was "if $row[3] is the same as $beverage then do this next bit", which would need == instead of = Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] How to create a web application like igoogle?
On Fri, 2009-11-20 at 23:15 +0330, Ali Asghar Toraby Parizy wrote: > Hi > How can i create a web page that include some gadgets? what kind of > technology do i have to use to creating web pages like igoogle and gmail? > How can i create them by php? Wow! Well, first what is it you want to do? Make another iGoogle or Gmail, as they are both pretty different beasts. One is a page of 'gadgets' as you call them, the other is a web-based email application. I'm guessing from your post that PHP is new to you. First then, I guess you need to decide on where are you getting the gadget parts from? If you can find things online that you can embed as Flash apps or iframes, then you probably won't need PHP at all. If you are planning on building them yourself, then you really will need to learn PHP. There is no magic solution to this question I'm afraid, and the scope of it is pretty huge, so you need to think about the parts that make it up and tackle each one. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Change styling depending on var value
I am trying to style HTML table cells depending on the values stored in a MySQL db. Thanks to other on this list, I can now refer to the variable that holds a CSS styling value. Now, I need to apply different values of that variable, depending on the content of the table cell itself. I tried something like this, where $row[3] contains string values: $entree ="meat"; $dessert ="ice cream"; $beverage="coffee"; (then the query that returns the data) if ($row[3] = $entree) { $rowcolor = "color:red"; elseif ($row[3] = $dessert) { $rowcolor = "color:blue"; elseif ($row[3] = $beverage) { $rowcolor = "color:green"; } else { $rowcolor ="color:black"; } I think I'm not properly expressing that I want the values in the $row[3] compared to those in the specified vars Thanks again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to create a web application like igoogle?
Hi How can i create a web page that include some gadgets? what kind of technology do i have to use to creating web pages like igoogle and gmail? How can i create them by php?
Re: [PHP] securing php pages
From: nitin reddy To: php-general@lists.php.net Sent: Fri, November 20, 2009 8:56:39 AM Subject: [PHP] securing php pages Hi I am a new user of PHP..in my project i have put login forms and i am able to login successful but the pages after the login can be accessed directly by typing the address so if any one can help in this matter. Thank you, -- Nitin I'm a PHP noob in general, but I'll throw in my 2 cents: Every page you want to keep people from accessing if they aren't logged in, needs to check the status of the login. Here is a link to a login system I used in learning more about setting this up, it may help you to understand better; http://evolt.org/PHP-Login-System-with-Admin-Features -- Aaron
Re: [PHP] securing php pages
On Fri, Nov 20, 2009 at 8:56 AM, nitin reddy wrote: > Hi I am a new user of PHP..in my project i have put login forms and i am > able to login successful but the pages after the login can be accessed > directly by typing the address so if any one can help in this matter. > > > Thank you, > > -- > Nitin > Are you certain you aren't already logged in when you attempt to access these pages directly? Does authentication expire? And to on the subject, the best way to secure any program is to write it to a CD and set it on your desk. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] CSS and variables
Try: echo '' . $row[1] . ''; -Mensagem original- De: Phil Matt [mailto:ad...@philmatt.com] Enviada em: sexta-feira, 20 de novembro de 2009 14:12 Para: php-general@lists.php.net Assunto: [PHP] CSS and variables De-lurking here. I'm trying, with no success, to use some CSS styling on my PHP output. Here's the code I want to style: echo ''.$row[0].''.$row[1].' I want to use a CSS style for the second cell, picking up the style from the value of a variable. I tried this: $newcolor = "color: red"; '.$row[1].' But it doesn't work. No problem with th "spacer" class, works fine. I just can't get the syntax for pulling a CSS style from a PHP var. TIA for your help! -- 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] Does PHP block requests?
Ford, Mike wrote: >> -Original Message- >> From: Peter Ford [mailto:p...@justcroft.com] >> Sent: 20 November 2009 15:18 >> To: php-general@lists.php.net >> Subject: [PHP] Does PHP block requests? >> >> I have a tricky problem. >> >> I'm trying to make a progress feedback mechanism to keep users >> informed about a >> slowish process on the server end of a web app. The backend is >> generating a PDF >> file from a bunch of data which extends to many pages. I can keep >> tabs on the >> progress of this generation by working out how many lines of data is >> present, >> and how much of it has been processed. I use that information to set >> a session >> variable with a unique name - so for each step I set >> >> $_SESSION['some-unique- >> name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); > > The progress-counter Ajax script uses a session -- but does the PDF generator > use the same session? If so, I'm guessing you don't manually close the > session at any point and all the progress-checking calls are blocked until > the session auto-commits at the end of the generator script. To counter this, > you need to manually session_commit() somewhere near the beginning of the > generator script. > > Cheers! > > Mike > -- > You're right about trying to use the same session - that was the plan to get the progress state passed across from one call to the other. Closing the session on the generator script has the effect of stopping any further changes to the session variable, so I get the initial value at each request after that. I put together a simple "Generator" script to test this: 10,'count'=>0); for ($i=0; $i<10; $i++) { sleep(1); $_SESSION[$fcode]['count']++; } echo "Done"; ?> and the code for the progress backend is like this: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS and variables
On Fri, Nov 20, 2009 at 9:12 AM, Phil Matt wrote: > De-lurking here. > > I'm trying, with no success, to use some CSS styling on my PHP output. > > Here's the code I want to style: > > echo ''.$row[0].''.$row[1].' > > I want to use a CSS style for the second cell, picking up the style > from the value of a variable. I tried this: > > $newcolor = "color: red"; > > '.$row[1].' > > But it doesn't work. No problem with th "spacer" class, works fine. I just > can't get the syntax for pulling a CSS style from a PHP var. > > TIA for your help! > You can't use PHP tags inside a string. You just need to concatenate the variable into the string you're echoing. echo ''.$row[0].''.$row[1].''; PHP tags may only contain PHP statements. You can't nest additional PHP tags within. They won't be evaluated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upgrading PHP versions
You may be right, I keep thinking of the bugs that were dropped out of 6.0, like magic quotes and register globals. They're only deprecated in 5.3. bm -Original Message- From: David Stoltz [mailto:dsto...@shh.org] Sent: Friday, November 20, 2009 10:59 AM To: Bob McConnell; php-general@lists.php.net Subject: RE: [PHP] Upgrading PHP versions Bob - I checked the changelog - 99% of it are bug fixes I don't see anything about 5.2.x features not being available as you suggest. But thanks for the reply. -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: Friday, November 20, 2009 10:50 AM To: David Stoltz; php-general@lists.php.net Subject: RE: [PHP] Upgrading PHP versions Assumption 2 is invalid. You need to take a close look at the change log. Many "features" from 5.2 are no longer available and will break code that depends on them. Bob McConnell -Original Message- From: David Stoltz [mailto:dsto...@shh.org] Sent: Friday, November 20, 2009 10:50 AM To: php-general@lists.php.net Subject: [PHP] Upgrading PHP versions Hi, We are currently using PHP version 5.2.6. in production, and I'd like to upgrade to the latest 5.3.1 My Assumptions: - I can simply download the Windows binary file, and install it. - None of the 5.2.6 code will break Will there be a momentary interruption of web services during the install? Will the current PHP applications stop working during the upgrade? Thanks for any info. -- 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] Upgrading PHP versions
> We are currently using PHP version 5.2.6. in production, and I'd like to > upgrade to the latest 5.3.1 Before upgrading production, upgrade your staging server and do QA. Any big changes like this should be tested in staging before being pushed to production. Also take a look at http://php.net/ChangeLog-5.php to be sure you know what has changed between 5.2.6 and 5.3.1. > My Assumptions: > - I can simply download the Windows binary file, and install it. I don't use PHP on Windows, but I would never make this assumption. Things never seem to be as easy as I expect them to be. Try on a staging server before making a change like this in production. > - None of the 5.2.6 code will break That's a big assumption. The only way I know of to test it is running the code on a box with 5.3.1 and test it. > Will there be a momentary interruption of web services during the > install? Will the current PHP applications stop working during the > upgrade? I've never used IIS, so I may not be helpful here. If you're using Apache on Windows you'll need to restart Apache is generally a very fast operation. Brady -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS and variables
Hi, > $newcolor = "color: red"; > > '.$row[1].' > > But it doesn't work. No problem with th "spacer" class, works fine. I just > can't get the syntax for pulling a CSS style from a PHP var. You could do this: {$row[1]}"; ?> -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 14th November) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CSS and variables
De-lurking here. I'm trying, with no success, to use some CSS styling on my PHP output. Here's the code I want to style: echo ''.$row[0].''.$row[1].' I want to use a CSS style for the second cell, picking up the style from the value of a variable. I tried this: $newcolor = "color: red"; '.$row[1].' But it doesn't work. No problem with th "spacer" class, works fine. I just can't get the syntax for pulling a CSS style from a PHP var. TIA for your help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Thread Safe?
David Stoltz wrote: > Forgot to ask: > > On the Windows download page, there are options like: > > VC9 Thread Safe > VC9 Non-Thread Safe > VC6 Thread Safe > ...etc > > What is the VC, and what is thread safe? > > Thanks! VC = Microsoft Visual C. 9 and 6 are the versions. http://en.wikipedia.org/wiki/Thread_safety Thread Safe PHP on Linux isn't recommended because some extensions may not be thread safe but I think on Windows it's ok if you need 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] securing php pages
You can use either cookies of sessions to maintain security: Some pseudo code: Login page: Login successful? If yes, set session value "LOGIN" = "YES" Then on all other pages, 1st check session value "LOGIN"if != "YES" then bump them to the login page. Make sense? -Original Message- From: nitin reddy [mailto:chintu.ni...@gmail.com] Sent: Friday, November 20, 2009 10:57 AM To: php-general@lists.php.net Subject: [PHP] securing php pages Hi I am a new user of PHP..in my project i have put login forms and i am able to login successful but the pages after the login can be accessed directly by typing the address so if any one can help in this matter. Thank you, -- Nitin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upgrading PHP versions
Bob - I checked the changelog - 99% of it are bug fixes I don't see anything about 5.2.x features not being available as you suggest. But thanks for the reply. -Original Message- From: Bob McConnell [mailto:r...@cbord.com] Sent: Friday, November 20, 2009 10:50 AM To: David Stoltz; php-general@lists.php.net Subject: RE: [PHP] Upgrading PHP versions Assumption 2 is invalid. You need to take a close look at the change log. Many "features" from 5.2 are no longer available and will break code that depends on them. Bob McConnell -Original Message- From: David Stoltz [mailto:dsto...@shh.org] Sent: Friday, November 20, 2009 10:50 AM To: php-general@lists.php.net Subject: [PHP] Upgrading PHP versions Hi, We are currently using PHP version 5.2.6. in production, and I'd like to upgrade to the latest 5.3.1 My Assumptions: - I can simply download the Windows binary file, and install it. - None of the 5.2.6 code will break Will there be a momentary interruption of web services during the install? Will the current PHP applications stop working during the upgrade? Thanks for any info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] securing php pages
Hi I am a new user of PHP..in my project i have put login forms and i am able to login successful but the pages after the login can be accessed directly by typing the address so if any one can help in this matter. Thank you, -- Nitin
[PHP] Re: DOM append to the top
Matthew Croud wrote: > The XML looks like: > > > ... > ... > ... > <- new items are added here > > > This is what my code looks like: > > $y = $dom -> getElementsByTagName("item"); > $dom -> documentElement -> insertBefore($Xitem,$y); > > If trying to pass the top most "item" node to insertbefore() but without > any luck. Any ideas ? been very verbose on purpose so you get the idea -> $newItem = ''; // your new node to insert $items = $dom->getElementsByTagName("item"); $firstItem = $items->item(0); $clothes = $firstItem->parentNode; $newItem = $clothes->insertBefore( $newItem , $firstItem ); short version is.. $y = $dom->getElementsByTagName("item")->item(0); $Xitem = $y->parentNode->insertBefore( $Xitem, $y ); please note: haven't checked this but should all work. problem with your code was you were supplying $y which was a DOMNodeList; and as the docs say: "If not supplied, newnode is appended to the children." which yuo can translate as it'll be appended if the second param of insertBefore is incorrect i guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upgrading PHP versions
Assumption 2 is invalid. You need to take a close look at the change log. Many "features" from 5.2 are no longer available and will break code that depends on them. Bob McConnell -Original Message- From: David Stoltz [mailto:dsto...@shh.org] Sent: Friday, November 20, 2009 10:50 AM To: php-general@lists.php.net Subject: [PHP] Upgrading PHP versions Hi, We are currently using PHP version 5.2.6. in production, and I'd like to upgrade to the latest 5.3.1 My Assumptions: - I can simply download the Windows binary file, and install it. - None of the 5.2.6 code will break Will there be a momentary interruption of web services during the install? Will the current PHP applications stop working during the upgrade? Thanks for any info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Thread Safe?
Forgot to ask: On the Windows download page, there are options like: VC9 Thread Safe VC9 Non-Thread Safe VC6 Thread Safe ...etc What is the VC, and what is thread safe? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upgrading PHP versions
Hi, We are currently using PHP version 5.2.6. in production, and I'd like to upgrade to the latest 5.3.1 My Assumptions: - I can simply download the Windows binary file, and install it. - None of the 5.2.6 code will break Will there be a momentary interruption of web services during the install? Will the current PHP applications stop working during the upgrade? Thanks for any info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need a find/replace command to fix my require_once
Nathan Rixham wrote: > Daevid Vincent wrote: >> I was reading this: http://pear.php.net/manual/en/standards.including.php >> and it states: >> >> "Note: include_once and require_once are statements, not functions. >> Parentheses should not surround the subject filename." >> >> I never knew that. I've always (wrongly) used: >> >> require_once('/path/to/my/file'); >> > > if it ain't broken don't fix it - why not just ensure you do it the > correct way (or preferred way) in the future. > > sure the time could better be invested fixing a bug, writing a test or > documenting something. > > s'all your call though :) I agree. That's a PEAR coding standard, so unless you're coding a PEAR package it doesn't matter. It's the PEAR groups opinion. If you look at some other project, they may require the parentheses for readability. -- 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] Does PHP block requests?
> -Original Message- > From: Peter Ford [mailto:p...@justcroft.com] > Sent: 20 November 2009 15:18 > To: php-general@lists.php.net > Subject: [PHP] Does PHP block requests? > > I have a tricky problem. > > I'm trying to make a progress feedback mechanism to keep users > informed about a > slowish process on the server end of a web app. The backend is > generating a PDF > file from a bunch of data which extends to many pages. I can keep > tabs on the > progress of this generation by working out how many lines of data is > present, > and how much of it has been processed. I use that information to set > a session > variable with a unique name - so for each step I set > > $_SESSION['some-unique- > name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); The progress-counter Ajax script uses a session -- but does the PDF generator use the same session? If so, I'm guessing you don't manually close the session at any point and all the progress-checking calls are blocked until the session auto-commits at the end of the generator script. To counter this, you need to manually session_commit() somewhere near the beginning of the generator script. 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] Does PHP block requests?
I have a tricky problem. I'm trying to make a progress feedback mechanism to keep users informed about a slowish process on the server end of a web app. The backend is generating a PDF file from a bunch of data which extends to many pages. I can keep tabs on the progress of this generation by working out how many lines of data is present, and how much of it has been processed. I use that information to set a session variable with a unique name - so for each step I set $_SESSION['some-unique-name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); Now on the front end I'm doing an AJAX call to a script that just encodes this session variable into a JSON string and sends it back. The problem is that while the PDF is being generated, the AJAX calls to get the progress data (on a 1-second interval) are being blocked and I don't get why. The PDF generation is also triggered by an AJAX call to a script which generates the PDF in a given file location, then returns a URL to retrieve it with. So it appears that the problem is that I can't have two AJAX calls to different PHP scripts at the same time? WTF? Checking the requests with Wireshark confirms the the browser is certainly sending the progress calls while the original PDF call is waiting, so it's not the browser side that's the problem: and once the PDF call is finished the outstanding progress calls are all serviced (returning 100% completion of course - not much use!) Different browsers (Firefox, IE, Chrome at least) give the same result. For reference, the server is Apache 2.2.10 on a SuSE linux 11.1 box using mod_php5 and mpm_prefork - is that part of the problem, and is there an alternative? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need browser auto-form predictable fill-in randomizer addon
From: Daevid Vincent > I have a form with probably 100+ elements from input, checkbox, select > boxes, textareas, etc. It's extremely tedious to fill these in all the time > and submit while developing/testing. > > Anyone know of a plugin to Firefox (or IE for that matter) that will fill in > the fields, select stuff, check stuff, etc. with some modicum of > predictability. Random text only goes so far when debugging as you don't > necessarily know what the field SHOULD contain. The Selenium IDE plug-in records a macro when you fill out the form. You can run, edit and save that macro, or export it to a half dozen different languages, then copy and edit those scripts, etc. I record whole session scenarios, export them to Perl and run them through the Selenium Remote Control server. I manage them with Perl's Test::Harness. I am slowly building up a regression test suite for a commercial site. I tried to do it in PHP, but couldn't find a functional test harness that wasn't OO based. (Unfortunately, after 40 years of procedural programming, mostly in assembly languages, I have no class.) One note, the IDE will not import scripts once they are exported. You can only load scripts that were saved. These appear to be an xhtml format. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM append to the top
Yo! I have a working form that adds user input to an XML file, it adds the new "item" element to the bottom of the list of previously created "item" elements. I would now like the new elements to be added to the top of the list. So far i've tried using: insertBefore() but i'm still getting elements added to the bottom. The XML looks like: ... ... ... <- new items are added here This is what my code looks like: $y = $dom -> getElementsByTagName("item"); $dom -> documentElement -> insertBefore($Xitem,$y); If trying to pass the top most "item" node to insertbefore() but without any luck. Any ideas ? Cheers Mongoose -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Noob question: Making search results clickable.
Ford, Mike wrote: >> -Original Message- >> From: Nisse Engström [mailto:news.nospam.0ixbt...@luden.se] >> Sent: 19 November 2009 14:54 >> To: php-general@lists.php.net >> Subject: Re: [PHP] Noob question: Making search results clickable. >> >> On Wed, 18 Nov 2009 10:31:59 -0500, Paul M Foster wrote: >> >>> Replace your query with: >>> >>> "SELECT title, id FROM videos WHERE topid1 = '$topic'" >>> >>> or whatever index you have to select a particular video from your >> table. >>> Replace your echo statement above with: >>> >>> echo "> href="video_display.php?video_id=$row[id]">$row[title]"; >> >> Without actually checking, I don't think "$row[...]" >> is going to work in double quoted strings. I'm pretty >> sure it needs to be in braces. You also need to escape >> the double quotes and put the array indexes in single >> quotes: > > You should have checked, because "...$row[title]..." is a valid alternative > for "...{$row['title']}...". > > Personally, I never use it because of it not having the same meaning outside > a double-quoted string -- but it is a documented feature. > yup, which sucks and breaks at the drop of a hat, like.. http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need a find/replace command to fix my require_once
Daevid Vincent wrote: > I was reading this: http://pear.php.net/manual/en/standards.including.php > and it states: > > "Note: include_once and require_once are statements, not functions. > Parentheses should not surround the subject filename." > > I never knew that. I've always (wrongly) used: > > require_once('/path/to/my/file'); > if it ain't broken don't fix it - why not just ensure you do it the correct way (or preferred way) in the future. sure the time could better be invested fixing a bug, writing a test or documenting something. s'all your call though :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need browser auto-form predictable fill-in randomizer addon
Daevid Vincent wrote: > I have a form with probably 100+ elements from input, checkbox, select > boxes, textareas, etc. It's extremely tedious to fill these in all the time > and submit while developing/testing. > > Anyone know of a plugin to Firefox (or IE for that matter) that will fill in > the fields, select stuff, check stuff, etc. with some modicum of > predictability. Random text only goes so far when debugging as you don't > necessarily know what the field SHOULD contain. > why not kill two birds with one stone and use selenium to test properly and automate the process? http://seleniumhq.org/ bit of integration testing certainly won't harm you. however - to take O.Lavell's comment on board if you can ("If it is tedious for you it will be tedious for your future users. And as a rule, they have far less patience than you have.") regards, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need a find/replace command to fix my require_once
On Thu, 2009-11-19 at 17:43 -0800, Daevid Vincent wrote: > I was reading this: http://pear.php.net/manual/en/standards.including.php > and it states: > > "Note: include_once and require_once are statements, not functions. > Parentheses should not surround the subject filename." > > I never knew that. I've always (wrongly) used: > > require_once('/path/to/my/file'); > > Anyone have a bash command line snippet (or other code is fine too I guess) > that will fix all my directory tree? > > The tricks are that I think there can be several variations and several > instances with a given file too: > > require_once('/path/to/my/file'); > require_once ('/path/to/my/file'); > require_once("/path/to/my/file"); > require_once(ROOTPATH."/my/file"); > > etc. Note the space before the parens, the single vs. double quotes and the > use of a global define. > > I think this regex should work: > > require_once\s?\((.*?)\); > > I just don't know the magic sed/awk/grep/whatever to do the search and > replace on all my .php files recursively. > > This seems like a useful 'routine' to post up on that page, as I'm sure I'm > not the only one who didn't know this little subtlety (considering PHP > doesn't puke on it either). > > You could try something like this: find . -maxdepth 1 -name "*.php" -type f -exec sed -i 's/find text/replace text/' {} \; Note that the find and replace strings are regular expressions, separated by the / character here, so ()'s will need to be escaped as they have a special meaning in regular expressions. The maxdepth parameter of find can be set to higher than 1 to let the script work recursively on files within directories. Thanks, Ash http://www.ashleysheridan.co.uk