public function initialize(array $options)
 {
     $this->logFile = static::DEFAULT_LOG_FILE;
     if (isset($options["file"]) && !empty($options["file"])) {
         $this->logFile = $options["file"];
     }
     $this->logFile = preg_replace("'[\\\\/]+'", "/", $this->logFile);
     if (substr($this->logFile, 0, 1) !== "/" && !preg_match("#^[a-z]:/#", $this->logFile)) {
         $this->logFile = Main\Application::getDocumentRoot() . "/" . $this->logFile;
     }
     $this->logFileHistory = $this->logFile . ".old";
     $this->maxLogSize = static::MAX_LOG_SIZE;
     if (isset($options["log_size"]) && \Bitrix\Main\Type\Int::isInteger($options["log_size"]) && $options["log_size"] > 0) {
         $this->maxLogSize = intval($options["log_size"]);
     }
 }
Example #2
0
 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;
 }
Example #3
0
 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 = "Bitrix 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);
             }
         }
     }
 }