[PHP] PHP to get mail headers
I run a small ISP and am looking at ways to automate grabbing the headers from email. I currently copy all email to a BSD box, then use Pine in header mode to get the IP addresses from which I build my spam filters. A search did not yield much in what I am trying to do: 1)Open the mailbox and extract the Received, From and Subject headers. 2)Drop those into a database that I can manage from the browser. Sounds simple enough and I am sure I am making it harder than it really is, but if you know of a project please let me know. Thanks! -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RedHat
John- This would best be asked on a Red Hat list, but I can tell you that if you are using Red Hat 7.3 I would not really count on getting them to release PHP 4.3 as once a major Red Hat release is out they usually only provide security updates - NOT feature updates. Red Hat also modifies the version numbers to reflect the security updates so if you have PHP 4.1 on Red Hat 7.3 it might be PHP 4.1.25 which is the Red Hat number. You can look around on www.rpmfind.net or www.freshrpms.net for an updated PHP, but it may not be compatible with the Red Hat version you are running. In the future if you want to count on program feature updates you would be best to install Apache, PHP and MySQL from source. -Scott On Sat, 5 Apr 2003, John Taylor-Johnston wrote: Where would I go on the redHat site to ask when they are going to upgrade to PHP 4.3 and MySQL 4.x (now in production). Our CS dept. won't install them for me until RedHat bundles it. I'm using RH 7.3. http://www.netcraft.com/?host=compcanlit.usherbrooke.caposition=limited Suggestions where to ask, to give them a nudge :) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript
Usually you would have the actual page between the () so it would be: echo a class=\white\ href=\javascript.openpopup('whatever.php?Unique_Id')\; -Scott At 04:10 PM 2/25/2003 -0800, Todd Barr wrote: I have tried this 3 different ways and none of them worked... I am trying to get javascript to generate a popup, with a variable passed along in the url. echoa class=white href='javascript.openpopup()' $Unique_Id; this doesn't work, neither does stopping PHP and then restarting... Blah, any advice on how to embed javascript? --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.456 / Virus Database: 256 - Release Date: 2/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.456 / Virus Database: 256 - Release Date: 2/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unix passwd file
At 04:54 AM 10/4/2002 -0600, Peter Janett wrote: You can just put the username and password in the MySQL database as normal text, then build your applications that are reading them to check the passwords with the UNIX Crypt function. Basically that is what I am trying to do. I just converted a BSDI passwd file to Linux to move the users to a new server. Now I want to move the user accounts to a MySQL table that Postfix, Radius and Apache/PHP can share to authenticate the users. In other words, just as your passwords are stored in a plain text file, store them in plain text in the db. Then to confirm them, take the first 2 characters of the crypted password, use them as the salt to crypt the password the user entered, and compare the results. If that are the same, they entered a valid password. So this would validate the user? What about if the user wants to change their password? In PHP can I crypt backwards and still be compatible with the Linux passwd file? I am trying to avoid manually typing in over 5,000 usernames and passwords. -Scott --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unix passwd file
At 01:54 PM 10/4/2002 +0200, lallous wrote: Peter, I think he's stuck with the parsing part? you can file() the /etc/passwd file then explode() it and add the username,passhash parts and/or more values into the mysql table. I can parse the file just fine, what I am trying to do is actually make use of the data coming out of the passwd file. In other words if you set up a simple table: UserID Username Password And then populate the table using a PHP script that parses the /etc/passwd file and then write your app to verify the user on that data can it be done? Username is no problem, the Unix encrypted password is the one I am trying to work out. If the user has a password of: phprocks and in /etc/passwd that encrypted password works out to be: !#@KJCKMSD, then I validate the user, they enter the correct username and password, will PHP be able to validate that the password they entered matches the encrypted password. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 9/19/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen
I am using fsockopen to test several of our SQL and WEB servers at our office. Testing ports 80, 1433 and 8080 work fine, but I would like to set something up to test ports on our mainframe. These are printers listening on 9100 and when I test it fails. I don't see anything in the online docs about going above a certain port - or is there something else. Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SQL Server test tool
Has anyone seen or know if it is possible to use PHP to test if a SQL server is alive on port 1433? I know I could run a query, but was looking for something to actually test on the port. Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparison again
Thank you Miguel! I was missing the /86400 and it works much better now :) On Thu, 9 May 2002, Miguel Cruz wrote: On Wed, 8 May 2002, Scott St. John wrote: Sorry to be so thick this morning, but I have a unix time stamp in my MS Sql server that is the date, plus 60 days to expire a password. I want to take today's date and compare to the two to see: 1)How many days until the password expires 2)If the password already expired then force a password change. I am missing something I am sure because I am not getting the answer I am looking for with this code: $expirePass = strtotime(now); -todays date $myPassword = (1026047985);-from the MS Sql field $itexpires = ($expirePass - $myPassword); $daysleft = intval(($mypassword - now()) / 86400)); miguel -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] adding 60 to a date
Morning I am working on a password aging system that will force a user to change their password every 60 days. Can anyone recommend the best method for taking the current date and adding 60 days to that number? Should I do a unix timestampe and add or strtotime and add 60 days? Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] adding 60 to a date
Will the fact that the server is on NT be a problem? On Tue, 7 May 2002, John S. Huggins wrote: On Tue, 7 May 2002, Scott St. John wrote: -Morning - -I am working on a password aging system that will force a user to change -their password every 60 days. Can anyone recommend the best method for -taking the current date and adding 60 days to that number? Should I do a -unix timestampe and add or strtotime and add 60 days? Yes, using the unix timestamp is most frequently the wise thing to do - at least for me :-| Just add 5,184,000 seconds to the current timestamp. ** John Huggins VANet [EMAIL PROTECTED] http://www.va.net/ ** -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Editors
I second that! I was to the point where I bought Ultra Dev but only used it for table layout and then spent the rest of my time in Home Site. Now with the new Dreamwever MX Home Site is built in. I was able to complete a site I was working on in PHP in about an hour last night! Since Home Site is built in you have the PHP syntax highlighting. I have not played with the db tools that it is supposed to have. GoLive is a joke in my eyes, even with the PHP stuff. -Scott On Wed, 1 May 2002, John Fishworld wrote: I've used Edit Plus and Dreamweaver as a combination for a while ! And the new Dreamweaver is worth getting ! I've set it up in 10 minutes with my Linux box using there PHP and MySQL and first impressions are very good ! Much better than Ultradev was and a hell of lot quicker and more stable than the new GoLive ! Good I've only been using it a day and half and so these are purely first impressions - but seeing as at least until June its free I'd recomend at least trying it ! (oh I also quite like TextPad but have somehow always got on better with EditPlus ) I would love to hear other people's experiences with these editors though. Second that. Has anyone used this new Dreamweaver? What's it like? I guess I'll have to download it tonite. Dreamweaver used to be my favorite, but it sucks for PHP so now I'm hooked on TextPad. Let us know if you have any experience using Dreamweaver MX. ---John Holmes... -- 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] PHP editor for windows
Macromedia/Allaire Home Site 5.0 has PHP color coding, not auto-complete, but you can customize it for auto-complete if you want. You can also make it tab 2 instead of 4 :) It's been my editor since the free version 1.0 and it's a work horse. And Home Site has Ultra Dev/Dream Weaver integration. PS-- This is MY opinion and NOT intended to start any Holy Wars. -Scott On Mon, 22 Apr 2002, .ben wrote: Other than notepad, interdev, ultraedit, etc (which i currently use for editing), does anyone know of a good editor for PHP for Windows, ideally with syntax colouring, etc? Cheers, .ben -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return more than 255 chars
Change nvarchar to varchar, ntext to text. I do not think you can return a nvarchar from SQL Server like that. Was this imported from Excel? -Scott On Mon, 22 Apr 2002, Jeff Hatcher wrote: I'm running Advance Server with MSSQL 2000 Enterprise. I can not get php to return more than 255 characters. In MSSQL I have set a column up as an ntext, nvarchar (4000), etc... But no matter what it only returns 255 characters. Its not the MSSQL Server because I have no trouble returning with other languages. Any Suggestion? -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql quickie..
Kelly- My way may not be perfect, but this is what I do. $sql_temp = select last_insert_id() as mainid from transfers; $sql_result_temp = mysql_query($sql_temp,$connection); $row_temp = mysql_fetch_array($sql_result_temp); $file_temp_id = $row_temp[mainid]; -Scott On Wed, 17 Apr 2002, Kelly Meeks wrote: Hi folks, I need to get the next auto_increment value of a mysql table thru php. Looking at my mysql manual, it makes reference to a last_insert_id() function? How would I use this via php, or is there some other way to do it? Thanks Kelly -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Conditions within a function
I have been trying to organize my code better by using functions, especially where I am repeating logic. The problem seems to be when I run a condition within the function, an if statement to check for results of a variable. As is the code seems to be bypasses, but if I put a die; in the function after the line that was skipped before I get the desired results. Code sample below is checking a table that lists a userID and if the user has ever logged onto the system before: function chkFirstTime($userID){ global $connection,$db,$userID; $sqlChkFirstTime = select fk_userID,firstTime from firstTime where fk_userID = '$userID'; $resultFirstTime = mssql_query($sqlChkFirstTime, $connection); $rowFirstTime = mssql_fetch_array($resultFirstTime); $firstTime = $rowFirstTime[firstTime]; if ($firstTime == ){ include ('includes/incFirstTime.php'); } } If I place a die; after the include it will run, of course it stops other users from getting in as well. Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditions within a function
On Tue, 16 Apr 2002, Erik Price wrote: First of all, try organizing your code using whitespace. Here is an example of the code, formatted to be a bit easier to read: Thank you, that was Pine doing some nice formatting tricks of it's own. Now, my first question, is why do you have $userID passed by parameter into the function, and also globalized in the function? I am trying to understand this function but this seems like a mistake. You should probably fix this. Also, I'm not sure what the $db variable is globalized for -- why is it needed? It isn't used in the function, as far as I can see. I see the error there and removed the global, I am moving from ASP functions to PHP functions and still learning. I misunderstood the global statement considering that I am passing the userID to the function. What I am also discovering is I have to use die; to halt execution for certain things. An example, I check to see if a user is still active in the system, if they are not I use a header to redirect them to a page that tells them they are inactive. if ($userActive == 0){ header ('Location: notice.php'); } As is it does not work until I do this: if ($userActive == 0){ header ('Location: notice.php'); die; } -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cookie sharing between asp and php
I have developed a security application for our intranet that handles a user login. It writes values to a cookie and uses that to verify them on the intranet sites until the sessions expire. Since we have not totally moved over to PHP I have some ASP applications I need to protect as well. Q1-I feel dump for asking this, but ASP can't read the PHP cookies, correct? My current solution might be to pass a variable from the php page to the asp page and have it write it's own set of cookies. Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: cookie sharing between asp and php
On Wed, 10 Apr 2002, Gordon Stewart wrote: As far as I know - ALL cookies set by a particular server - can be read re-set by any programme / process on the same server / website.. So your ASP script could read your PHP cookies vice-versa.. I'm just learning PHP, dont know cookies as yet (I use Perl/CGI for cookies) have no experience at all on ASP... I'll suggest to try a small PHP a small ASP page, try set/read the cookies. Thanks for the response. I was able to work it out, ugly, but it works! I am using PHP to redirect to an ASP page that then writes a cookie itself. Ugly having 2 cookies like that, but it's our intranet and until everything is ported from ASP to PHP this is the way I have to do it. -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom 404
Custom 404 what? Do you want to make one? On Tue, 2 Apr 2002, Craig Donnelly wrote: Custom 404 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hi to you anti-spammers HAHA
? echo phpinfo(); ? On Mon, 1 Apr 2002, vins wrote: Happy Happy Easter. and to all you peeps out there who don't celebrate this day. Hope you enjoyed your day. And just too keep the cool How do i run that script that give all the information about php ? Someone told me the you type PHPINFO(); but it sometimes doesn't work Cheerz Spammer Vins -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cookies
Help! I have not had a need to use sessions or cookies on PHP until now. My experience has been to use Sessions in ASP. I am building a system to have users log in and then drop a cookie on their machine so they can log onto other apps. It's an internal app. The cookie will contain a userid only. What am I doing wrong here: setcookie ('userID', $userID); I set this cookie and can call it on another page, but then I loose it. I have been wathching the cookie directory on my machine and oddly, a cookie never generates. Feeling, uh, clueless at the moment. Thanks, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: which php book 2 buy ?
I didn't think Programming PHP was out yet? On Tue, 26 Mar 2002, Rasmus Lerdorf wrote: Or, of course, if you want to be cool like Carl: http://lerdorf.com/buy/ ;) -Rasmus On Tue, 26 Mar 2002, Ralph Friedman wrote: In article [EMAIL PROTECTED], Septic Flesh wrote: I wanna buy a book from amazon . . .but don't know which one.. Do you know where I will find examples of shopping carts ? (which book ?) Creating Dynamic Web Pages Using PHP and MySQL by David Tansley. -- Rgds Ralph -- 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] Perl NewsGroup?
Not really a bad question as both are great tools. If you are new to Perl check out the Perl Beginners group. Wonderful group of people and very patient with newbies. Make sure you read up on things you are trying to do before you ask the how do I do this question. -Scott On Wed, 20 Mar 2002, David Duong wrote: This may be the worst place to put this but here goes: Does anyone know of a Perl NewsGroup? -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting values from multiple select
Yes, I have tried that. To view them on the next page I would call them as $choice[0];$choice[1];, etc, but only the first item in the list is available. -Scott On Thu, 14 Mar 2002, Erik Price wrote: Did you try putting brackets at the end of the input names? This tells PHP to put the values into an array, whose key is the name of the input. select name=choice[] multiple=yes option value=aA/option option value=bB/option option value=cC/option /select This might work for you, Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting values from multiple select
Ok, how about a code snipet since I seem to be blind this morning. The select box code: select multiple=yes name=groups id=av ? $sql = select groupID,groupName from groups order by groupName; $result = mssql_query($sql,$connection); while($row = mssql_fetch_array($result)){ $groupID = $row[groupID]; $groupName = $row[groupName]; echo option value=\$groupID\$groupName/option; } ? /select On the next page I tried the code Erik recommended doing this: foreach ($groups as $group_list){ echo $group_list; } Any eye openers? Thanks, -Scott On Thu, 14 Mar 2002, Erik Price wrote: Hm... have you tried using a loop to get their values, rather than using the numeric indexes? Like this: foreach ($choice as $array_element) { echo $array_element; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting values from multiple select
On Thu, 14 Mar 2002, Erik Price wrote: Sure! First go get a cup of coffee! :) Then change the first line to say this: select multiple=yes name=groups[] id=av Let me know how that works for you. Erik- I don't do coffee, but the Iced Tea works just as well :) Thank you, all is well and my happy face is back on. I was missing the [], I had tried that before but had an error because I forgot to update my javascript code. Thanks everyone, -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting values from multiple select
Hi gang- I am working on a javascript box that will allow the user to drag values from one select box to another. I will use this box to set the values. This is a standard, multiple select box. On the next page I need to figure out what PHP is doing with the data coming in. If I send 5 fields to the next page PHP will show me one when I echo the variable to the page. If I try to split the varaiable I still get only one value in the echo. Tried to reponse.write it in asp and I get the string with comma seperate values. Help! Thanks, -Scott -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] number_format
Hi everyone, I am trying to format a number for a report, the one consistant thing is the three decimal places. But I need to strip them, then fill in zero's from the left. So, if the number coming in is 8.000 I need to convert to 00800, 11.070 would convert to 01107. I have tried a combination of number_format and usually end up with 8000 or 00110. Help! Thank you! Mind in slow motion this morning. -Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] number_format
Ok, I think I got it using this: $anum = number_format($fie31,2); $anum = str_replace($replace_char, $replace_strings, $anum); On Fri, 8 Mar 2002, Alastair Battrick wrote: why not multiply the number by 1000 and then use str_pad($in,6,0,STR_PAD_LEFT) Alastair Battrick Senior Developer Lightwood Consultancy Ltd http://www.lightwood.net -Original Message- From: Scott St. John [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 17:02 To: [EMAIL PROTECTED] Subject: [PHP] number_format Hi everyone, I am trying to format a number for a report, the one consistant thing is the three decimal places. But I need to strip them, then fill in zero's from the left. So, if the number coming in is 8.000 I need to convert to 00800, 11.070 would convert to 01107. I have tried a combination of number_format and usually end up with 8000 or 00110. Help! Thank you! Mind in slow motion this morning. -Scott -- 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] REQUEST QUESTION
Call me silly, but I would just call the hidden values: $order1 and $order2 Did I miss why they both must be called order? On Tue, 5 Mar 2002, karthikeyan wrote: Hi Guys, I allready posted this question in detail but I believe I didn't explain it properly There are 2 hidden variable in my FORM 1 order = 10 and 2 order=20 I want to retrieve both the orders in the next page say somenamephp How do i do that Regards, karthikeyan -- -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] mySQL back up
1)Create the db in mysql: mysqladmin -u (your user name) -p (if you have a password) create (new database name) 2)mysql -D (the name you used above) (the text file) Works on Unix and 2000. Is that what you mean? -Scott On Mon, 4 Mar 2002, Wilbert Enserink wrote: Hi all, I have a mySQL back up q: I have a textfile which is filled with statements as: -- DROP TABLE Clients\g CREATE TABLE Clients( ID INT, date BLOB, name BLOB, age BLOB, PRIMARY KEY (ID) )\g INSERT INTO Clients VALUES ('all record data')\g INSERT INTO Clients VALUES ('next record data')\g ..and so on --- My Q: How an I restore the tables as mentioned in my text file? Is it possible to 'run' this file so to speak? thx in advance!! Wilbert - Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl [EMAIL PROTECTED] - -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Non printable page
Black background, white text used to work :) On Fri, 1 Mar 2002, Diana Castillo wrote: Is there any way tomake a page that cannot be printed?? -- -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] Non printable page
Seriously, another option that works in IE would be to use the link tag in the head of the document Put an alternate document in the tag so when they print the page you can control the content Here is the tag: link rel=alternate media=print href=whatevertxt -Scott On Fri, 1 Mar 2002, Diana Castillo wrote: Is there any way tomake a page that cannot be printed?? -- -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
Re: [PHP] how to use PHP on command line in windows
Just download the CGI version and call it from the command line I am doing a project now based entirely on the command line using PHP as a file parser on Win 2K You can add it to your path or just call it: c:\php\phpexe -q nameOfScriptphp Make sure you write it like a normal PHP script with the tags ? The -q will supress the HTTP headers -Scott On Fri, 1 Mar 2002, Peter J Schoenster wrote: Hi, I use NT for development and I like to write snippets of code and test them on my local box I can do this in Perl How can I do that in PHP without installing a webserver etc etc I guess I can install a version of PHP and just make sure I've got the path in my env Thanks, Peter http://wwwreadbrazilcom/ Answering Your Questions About Brazil -- -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
[PHP] intranet security
I am currently building an intranet security system to handle internal users and the web applications we have. When we are done we will have the ability to add/remove users, control what apps they can and can't see, etc. One thing I would like to be able to do is set up groups and have the ability to assign multiple groups to a person. Say you have these groups: Admin, Developer, Read-Only and I want to assign Scott to Admin and Developer. Then also be able to control rights on a user level. Can someone point me to some links or let me know how you handled these situations. I have a rough draft here, but would like to see what others are doing to handle these issues. Thanks, -Scott -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: intranet security
Thank you. What I am trying to avoid is doing a parsing of the string everytime a user comes in. My thought is to use a user table, a group table and then a permissions table that will allow the user to be a member of more than one group. Thank you, -Scott On Wed, 27 Feb 2002, Julio Nobrega Trabalhando wrote: I've done it :-) But be careful. There are dozens of way to implement this. My way is simple, but makes use of too many sql queries I believe. Could have stored everything in one line and grab it at user's login, but anyway My current way seems more logical to follow and update. I have created these 'groups of power', where you can add/remove users. Since an user can be part of more than one group, I store in a session array these groups ids. In a page where it's necessary to verify if the user (actually, the groups he's attached to) can perform certain actions, there's a little check like this: $var = ''; foreach ($_SESSION['user']['group_ids'] as $value) { $var .= OR group_id = '$value' ; } And a Mysql query: // 'groups' is a table with a collumn for every section of the site. $sql = SELECT section_power FROM groups WHERE id = 0 . $var . AND active = 1; $res = mysql_query($sql); while (list($section_power) = mysql_fetch_array($res)) { // using parse_str() since the data is stored om Mysql as: // r=1w=1d=0m=0 parse_str($section_power); // More on discover_power() below discover_powers($r,$w,$d,$m); } function discover_powers($r, $w, $d, $m) { // If there's no current power defined: if (!isset($_SESSION['user']['powers']['section']['w'])) { // User's power the same as the var; $_SESSION['user']['powers']['section']['w'] = $w; } else { // Else, in the while loop above, he's assigned to one group with power = 0 // and another one with power = 1, let the user get 1 if ($w $_SESSION['user']['powers']['section']['w']) { $_SESSION['user']['powers']['section']['w'] = $w; } } Well, pretty much is like this. I am close to redesign the whole thing because of the many SQL queries, the while loop calling two functions for every group the user is attached, and because it's plain a 'not-elegant' solution. Feel free to steal any ideas :-D -- Julio Nobrega. Um dia eu chego lá: http://sourceforge.net/projects/toca -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php