svn: web/php-master/trunk/include/ cvs-auth.inc

From: Date: Sun, 19 Jul 2009 22:14:12 +0000
Subject: svn: web/php-master/trunk/include/ cvs-auth.inc
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-5420@lists.php.net to get a copy of this message
bjori Sun, 19 Jul 2009 22:14:12 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=284388 Changed paths: U web/php-master/trunk/include/cvs-auth.inc Log: Use the database rather then the passwd file... Modified: web/php-master/trunk/include/cvs-auth.inc =================================================================== --- web/php-master/trunk/include/cvs-auth.inc 2009-07-19 21:17:23 UTC (rev 284387) +++ web/php-master/trunk/include/cvs-auth.inc 2009-07-19 22:14:12 UTC (rev 284388) @@ -7,20 +7,19 @@ function find_password($user) { - if (LOGIN_IGNORE_PWD) return " "; // should be at least one char - $fp = fopen(LOGIN_PWD_FILE, "r"); - if (!$fp) { - die("ERROR: Unable to open CVS users file!"); + @mysql_connect("localhost","nobody","") + or die("unable to connect to database"); + @mysql_select_db("phpmasterdb"); + + $username = escape($user); + $res = @mysql_query("SELECT passwd FROM users WHERE passwd != '' AND cvsaccess AND username = '$username'"); + + // Nonexisting?.. + if ($res && mysql_num_rows($res) == 1) { + $row = @mysql_fetch_array($res); + return $row["passwd"]; } - while(!feof($fp)) { - $line = fgets($fp, 120); - list($luser, $passwd, $junk) = explode(":", $line); - if ($user == $luser) { - fclose($fp); - return $passwd; - } - } - fclose($fp); + return ""; }

« previous php.webmaster (#5420) next »