コード例 #1
0
ファイル: authentication.php プロジェクト: ASDAFF/open_bx
 protected function updateDigest($userId, $password)
 {
     if (empty($userId)) {
         throw new Main\ArgumentNullException("userId");
     }
     if (!Main\Type\Int::isInteger($userId)) {
         throw new Main\ArgumentTypeException("userId");
     }
     $userId = intval($userId);
     $connection = Main\Application::getDbConnection();
     $sqlHelper = $connection->getSqlHelper();
     $recordset = $connection->query("SELECT U.LOGIN, UD.DIGEST_HA1 " . "FROM b_user U " . "   LEFT JOIN b_user_digest UD on U.ID = UD.USER_ID " . "WHERE U.ID = " . $userId);
     if ($record = $recordset->fetch()) {
         $realm = Main\Config\Configuration::getValue("http_auth_realm");
         if (is_null($realm)) {
             $realm = "Freetrix Site Manager";
         }
         $digest = md5($record["LOGIN"] . ':' . $realm . ':' . $password);
         if ($record["DIGEST_HA1"] == '') {
             //new digest
             $connection->queryExecute("INSERT INTO b_user_digest (USER_ID, DIGEST_HA1) " . "VALUES('" . $userId . "', '" . $sqlHelper->forSql($digest) . "')");
         } else {
             //update digest (login, password or realm were changed)
             if ($record["DIGEST_HA1"] !== $digest) {
                 $connection->queryExecute("UPDATE b_user_digest SET " . "   DIGEST_HA1 = '" . $sqlHelper->forSql($digest) . "' " . "WHERE USER_ID = " . $userId);
             }
         }
     }
 }
コード例 #2
0
ファイル: currentuser.php プロジェクト: ASDAFF/open_bx
 public static function createFromArray(array $data)
 {
     if (empty($data)) {
         throw new Main\ArgumentNullException("data");
     }
     if (!isset($data["USER_ID"]) || !Main\Type\Int::isInteger($data["USER_ID"])) {
         throw new Main\ArgumentOutOfRangeException("data");
     }
     if (isset($data["AUTHORIZED"]) && $data["AUTHORIZED"] != "Y") {
         throw new SecurityException();
     }
     $user = new static($data["USER_ID"]);
     $ar = array("LOGIN" => "login", "EMAIL" => "email", "FIRST_NAME" => "firstName", "SECOND_NAME" => "secondName", "LAST_NAME" => "lastName", "ADMIN" => "isAdmin", "TIME_ZONE" => "timezone");
     foreach ($ar as $k => $v) {
         if (isset($data[$k])) {
             $user->{$v} = $data[$k];
         }
     }
     if (isset($data["AUTO_TIME_ZONE"])) {
         $user->isAutoTimezone = $data["AUTO_TIME_ZONE"] == "Y";
     }
     if (isset($data["POLICY"])) {
         $user->policy = $data["POLICY"];
     }
     if (isset($data["GROUPS"])) {
         $user->userGroups = $data["GROUPS"];
     }
     //		$_SESSION["SESS_AUTH"]["CONTROLLER_ADMIN"] = false;
     //		$_SESSION["SESS_AUTH"]["STORED_AUTH_ID"] = $stored_id;
     return $user;
 }