List:General Discussion« Previous MessageNext Message »
From:Bob Ramsey Date:January 12 2004 6:26pm
Subject:wildcards the field
View as plain text  

I'd like to use a mysql database as a lookup to authorize people to edit a 
webpage.  The idea is that people would go to a main login page for 
authentication and then when they visit a page they are authorized to edit, 
they see an "edit this page" link.

What I'm envisioning is a really basic table structure like this:

id varchar (10)
path varchar (255)

id is a foreign key that links back to another table I have with more user 
information, but that isn't really important.

Entries might look like this, with explanation in brackets []:

'ramsey', '/' [I am the webmaster, I can edit all files in all directories]
'jones', '/data1' [jones can edit all files in the data1 directory]
'jones', '/data2/jonesdoc.php' [jones can also edit this one file in data2]
'smith', '/data2' [smith can edit all files in data2]
'smith', '/data2' [smith can also edit all files in data3]

People will generally have access to an entire directory, but not 
necessarily.  Most people will have access to more than one directory.

So if jones goes to, the php code on 
the page sees that the file is /data1/index.php.  It then needs to find out 
if jones can edit that file.

I'd like to be able to do a single mysql query.

select * from table where path = '/data1/index.php' and user 
='jones';[obviously won't work]

I can use php and get take the current page and turn it into '/data1' and 
then do:

select * from table where (path ='/data1/index.php' or path='/data1') and 
user ='jones';

but I'm curious if there's a way to have '/data1/index.php' match '/data1' 
using wildcards or something like that.



Bob Ramsey                       Applications Development & Support II
ph:  1(319)335-9956                              187 Boyd Law Building
fax: 1(319)335-9019                  University of Iowa College of Law
mailto:robert-ramsey@stripped                Iowa City, IA 52242-1113
For Hardware and Software questions, call 5-9124

wildcards the fieldBob Ramsey27 Jan