Skip to content

Commit

Permalink
checksecurity function now uses htaccess class, also switch to in_arr…
Browse files Browse the repository at this point in the history
…ay instead of array_search

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@1915 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
David Olivier committed Aug 13, 2006
1 parent 35191d9 commit e2fdcca
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions common.php
Expand Up @@ -760,20 +760,23 @@ function checksecurity()
// Check that the names in the htpasswd file match up with the names in the database.
// Any names missing in htpasswd file should be removed from users table
global $homedir, $dbprefix, $connect;
$fname = "$homedir/.htpasswd";
$htpasswds = file($fname);
$realusers[] = "DUMMYRECORD"; //dummy entry because in_array never finds the first one!
foreach ($htpasswds as $htp)
{
include_once("classes/core/htaccess.class.php");
$ht = new htaccess("$homedir/.htaccess","$homedir/.htpasswd");

$users=$ht->getUsers();
//$realusers[] = "DUMMYRECORD";
foreach ($users as $htp)
{
list ($fuser, $fpass) = split(":", $htp);
$realusers[] = $fuser;
}
$realusers[] = $htp[0];
}

$usquery = "SELECT user FROM ".db_table_name('users');
$usresult = db_execute_assoc($usquery);
if (!$usresult) {return "Database Error";}
while ($usrow = $usresult->FetchRow())
{
if (!array_search($usrow['user'], $realusers))
if (!in_array($usrow['user'], $realusers))
{
$dlusquery = "DELETE FROM ".db_table_name('users')." WHERE user='{$usrow['user']}'";
$dlusresult = $connect->Execute($dlusquery);
Expand Down

0 comments on commit e2fdcca

Please sign in to comment.