Skip to content

Commit

Permalink
Crypted password, other fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 30, 2004
1 parent 44a1ba2 commit 42d48f9
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions vendor/index.php
Expand Up @@ -72,8 +72,10 @@ function op_renderpapertrail()
} // op_renderpapertrail


function update_vendor_login($loginname, $pw)
function update_vendor_login($loginname, $pw, $allowreplace)
{
if (!welcome_here()) return;

$action = 'Added';
$users = file("./.htpasswd");

Expand All @@ -83,6 +85,27 @@ function update_vendor_login($loginname, $pw)
return;
} // if

$cmd = escapeshellcmd("htpasswd -b -n $loginname $pw");
$cryptedpw = system($cmd);
if ($cryptedpw == false)
{
write_error("Can't crypt password");
return;
} // if

if (!$allowreplace)
{
foreach ($users as $u)
{
$chop = str_replace(strchr($u, ':'), "", $u);
if ($chop == $loginname)
{
write_error("Username already exists.");
return;
} // if
} // foreach
} // if

if (!copy('./.htpasswd', '.htpasswd_knowngood'))
{
write_error("couldn't archive old vendor list.");
Expand Down Expand Up @@ -127,7 +150,7 @@ function op_confirmpw()
return;
} // if

update_vendor_login($_SERVER['REMOTE_USER'], $pw1);
update_vendor_login($_SERVER['REMOTE_USER'], $pw1, true);
} // op_confirmpw


Expand Down Expand Up @@ -167,7 +190,7 @@ function op_confirmaddvendor()
return;
} // if

update_vendor_login($loginname, $pw1);
update_vendor_login($loginname, $pw1, false);
} // op_confirmaddvendor


Expand Down

0 comments on commit 42d48f9

Please sign in to comment.