[PHP] user auth

2002-05-30 Thread Justin Blake

I will soon be developing a user authentication system with different access levels. I 
will need to check the users against a mysql database. How secure is checking for a 
session var, and then redirecting with header('Location:...') ? Is there a way to get 
around this method of protection?

-- 
Justin Blake
http://blaix.org/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] variables

2002-04-20 Thread Justin Blake

Jule Slootbeek wrote:
 Hey guys,
 i have this script that changes pages in a table with the include()
command,
 but i ran into trouble when i tried to change the pages by linking to
 index.php?left=theband because it would feed it to the index.php, but
 index.php would just change left back to news which is the default, how do
i
 make it that it opens the theband page in stead of the default, and when i
go
 to plain index.php the defaults come back?
 any help apreciated
 thanks

 Jule
 ---SCRIPT---
 ?php

 $top = navbar;
 $left = news;
 $righttop = welcome;
 $rightbottom = pic;

 $toptitle = index;
 $lefttitle = index;
 $righttoptitle = index;
 $rightbottomtitle =index;

 $extention = .php;

 print (table border=0);
 print (tr);
 print (td align=center colspan=3);
 include ($top/$toptitle$extention);
 print (/td);
 print (/tr);
 print (tr);
 print (td rowspan=2 align=center width=40%);
 include ($left/$lefttitle$extention);
 print (/td);
 print (td align=center width=60% height=40%);
 include ($righttop/$title$righttoptitle$extention);
 print (/td);
 print (/tr);
 print (tr);
 print (td align=center width=60% height=55%);
 include (rightbottom/$rightbottomtitle$extention);
 print (/td);
 print (/tr);
 print (/table);
 ?
 ---SCRIPT---

just check to see if $left is already set,
either:

$left = isset($left) ? $left : news;

or:

if(empty($left)) $left = news;

Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Problem with file()

2002-04-16 Thread Justin Blake

Zambra - Michael wrote:

 What kind of line ending does the file() function include in the array
 elements. I'm having problem with file() combined with implode() when
 reading in complete HTML files in a Windows environment. After parsing
these
 resulting strings I get tons of white lines (??).

 I'd appreciate any advice.

When it puts each line into the array, the newline is still attached,
so if you are adding more newlines when parsing this could be the problem.

Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] str_replace question

2002-04-15 Thread Justin Blake

Andras Kende [EMAIL PROTECTED] wrote:

 Is a nicer way to remove any number 1-0 from a string???
 
 Currently:
 $metakeywords=str_replace(1,'',strtolower($metakeywords));
 $metakeywords=str_replace(2,'',strtolower($metakeywords));
 $metakeywords=str_replace(3,'',strtolower($metakeywords));
 $metakeywords=str_replace(4,'',strtolower($metakeywords));
 $metakeywords=str_replace(5,'',strtolower($metakeywords));
 $metakeywords=str_replace(6,'',strtolower($metakeywords));
 ..

use a regular expression with ereg_replace(), like this:

$metakeywords = ereg_replace('[0-9]', '', $metakeywords);

hope that helps
justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] variable question...

2002-04-15 Thread Justin Blake

Phil Schwarzmann [EMAIL PROTECTED] wrote:

 Let's say I a variable called $var1 and it's values is one
 
 ...I want to access them by doing something like this...
 
 $i = 1;
 if (var.$i == one) echo Hello!;
 
 ...I want the combination of var and $i to equal $var1
 
 How do I do this??
 The code I just wrote will not print out Hello!

You can use variable variable names by adding another '$'.
so if $i == 1 and $var1 == one, you can do this:

$var_name = var.$i;
if($$var_name == one) echo Hello!;

That should work,
Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] smarter way to write config file?

2002-04-15 Thread Justin Blake

Justin French [EMAIL PROTECTED] has the same first name as me :)
and wrote:

 Currently i've got a config file for each website, and I split it into
 essentially two config files, based on the server name, so that I can have
1
 file for both my local server and the live server.

 something like:

 ?

 if($local)
 {
 $cfgAdminEmail = [EMAIL PROTECTED];
 $cfgReportErrors = 1;
 $cfgSendMail = 0;
 }
 else
 {
 $cfgAdminEmail = [EMAIL PROTECTED];
 $cfgReportErrors = 0;
 $cfgSendMail = 1;
 }

 ?

 But of course, there's more like 20 config elements.  The small problem
I'm
 having is making sure that I keep both halves (live and local) the same
(but
 with different settings).


 What i was hoping was that there may be a way of writing the config once,
 and having it work in both situations, perhaps with a switch, or with some
 other language construct I have no idea about:

 I know this isn't the answer, but I was hoping for something like:

 ?
 $cfgAdminEmail = [EMAIL PROTECTED]|[EMAIL PROTECTED];
 $cfgReportErrors = 1|0;
 $cfgSendMail = 0|1;
 ?

 Where both the options local|live were declared in one hit.


 Whatever solution there is (arrays?  switches?) it has to be easy to
 maintain, otherwise it's a step backwards I guess.


 Any suggestions appreciated, or pointers to stuff in the manual i've never
 heard of!!!

You could do it by making each variable an array with a key of 'local' and
'live' like this:

?
$cfgAdminEmail = array(local = localaddress, live = liveaddress);
etc.
etc.
?

Then you could set something like $server to local or live
and refer to the var's by $cfgAdminEmail[$server];

Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php