Решил проблему на сессиях и куках, написав вот такой класс:
class PassAuth extends core {
private $project_id;
private $password;
private $is_authorized = false;
function __construct() {
$this->db_config = $this->getConfig('db_config');
$this->db = $this->getDb();
}
public static function validProjectPass()
{
if (!empty($_SESSION["project_id"])) {
return (bool) $_SESSION["project_id"];
}
return false;
}
public function checkPass($password, $remember=false)
{
$pass = $this->passwordHash($password);
$select = "SELECT name, pass FROM ?n WHERE pass = ?s";
$ret = $this->db->getOne($select, 'projects', $pass);
if (!$ret) {
$this->is_authorized = false;
} else {
$this->is_authorized = true;
$this->project_id = $ret['name'];
$this->saveSession($remember);
}
return $this->is_authorized;
}
public function saveSession($remember = false, $http_only = true, $days = 7)
{
$_SESSION["project_id"] = $this->project_id;
if ($remember) {
// Save session id in cookies
$sid = session_id();
$expire = time() + $days * 24 * 3600;
$domain = ""; // default domain
$secure = false;
$path = "/";
$cookie = setcookie('project_id', $sid, $expire, $path, $domain, $secure, $http_only);
}
}
public static function passwordHash($password, $iterations = 2)
{
$hash = md5(md5($password));
for ($i = 0; $i < $iterations; ++$i) {
$hash = md5(md5(sha1($hash)));
}
return $hash;
}
}
теперь осталось отладить)), но это уже дело техники.