1<?php // vim: et ts=4 sw=4 2/* $Id$ */ 3 4 5define("REALM", "PHP Subversion Repository"); 6 7function gen_svn_pass($username, $password) { 8 return md5(sprintf("%s:%s:%s", $username, REALM, $password)); 9} 10 11function verify_password($user, $pass) 12{ 13 db_connect(); 14 15 $res = db_query_safe("SELECT svnpasswd FROM users WHERE cvsaccess AND username = ?", [$user]); 16 17 if ($res && mysql_num_rows($res) == 1) { 18 $row = mysql_fetch_array($res); 19 return gen_svn_pass($user, $pass) === $row["svnpasswd"]; 20 } 21 22 return false; 23} 24 25function verify_username($user) { 26 db_connect(); 27 $res = db_query_safe("SELECT 1 FROM users WHERE cvsaccess AND username = ?", [$user]); 28 return $res && mysql_num_rows($res) == 1; 29} 30