0) { $salt .= substr( sha1(dcCore::app()->getNonce() . date('U')), 2, $saltlen - strlen($salt) ); $secret = crypt($secret, $salt); } return $secret; } /** * Setting: active * * @return bool True if module is active */ public static function isActive(): bool { return !is_null(dcCore::app()->blog) && (bool) dcCore::app()->blog->settings->get(My::id())->get('active'); } /** * Setting: crypt * * @return string The crypt method */ public static function cryptMethod(): string { return is_null(dcCore::app()->blog) ? '' : (string) dcCore::app()->blog->settings->get(My::id())->get('crypt'); } /** * Setting: message * * @return string The frontend message */ public static function httpMessage(): string { return is_null(dcCore::app()->blog) ? '' : (string) dcCore::app()->blog->settings->get(My::id())->get('message'); } /** * Get passwords file path * * @return string The passwords file path (empty on error) */ public static function passwordFile(): string { return is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->public_path . DIRECTORY_SEPARATOR . My::FILE_PASSWORD; } /** * Check passwords file * * @return bool True if passwords file is writable */ public static function isWritable(): bool { if (false === ($fp = fopen(self::passwordFile(), 'a+'))) { return false; } fclose($fp); return true; } /** * Send HTTP message */ public static function sendHttp401(): void { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="' . utf8_decode(htmlspecialchars_decode(self::httpMessage())) . '"'); exit(0); } }