12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- require_once __DIR__ . '/project.php';
- require_once __DIR__ . '/config.php';
- require_once __DIR__ . '/user_settings.php';
- require_once __DIR__ . '/api.php';
- require_once __DIR__ . '/page_structure.php';
- load_settings($_COOKIE);
- require_once __DIR__ . '/lang/' . $settings['language'] . '.php';
- function get_string($path) {
- global $strings;
- $pointer = &$strings;
- $levels = explode('.', $path);
- foreach ($levels as $level) {
- if (!isset($pointer[$level])) return false;
- $pointer = &$pointer[$level];
- }
- return $pointer;
- }
- function get_proxy_url($url) {
- return BASE_URL . '/proxy/' . substr($url, 8);
- }
- function get_closest_mode() {
- global $settings;
- if (
- $settings['show-r15'] == 'on'
- && ($settings['show-r18'] == 'on' || $settings['show-r18g'] == 'on')
- ) return 'all';
- return 'safe';
- }
- function get_xrestrict_string($xRestrict) {
- return [false, 'R-18' , 'R-18G'][$xRestrict];
- }
- function artwork_is_hidden($artwork) {
- global $settings;
- if ($artwork->sl >= 4 && (SSFW_ONLY || $settings['show-r15'] == 'off')) return 'r15';
- else if ($artwork->xRestrict == 1 && (SFW_ONLY || $settings['show-r18'] == 'off')) return 'r18';
- else if ($artwork->xRestrict == 2 && (SFW_ONLY || $settings['show-r18g'] == 'off')) return 'r18g';
- else if ($artwork->aiType == 2 && $settings['show-aigc'] == 'off') return 'aigc';
- return false;
- }
- function die_with_message($status_code, $message) {
- http_response_code($status_code);
- $title = get_string('error');
- render_page_header($title); ?>
- <div class="container container-small center">
- <h1><?= $title ?></h1>
- <p><?= $message ?></p>
- </div><?php
- render_page_footer();
- die;
- }
- function render_collapsed_content($page_count, $button_text, callable $render_page) {
- for ($page = 0; $page < $page_count; $page ++) {
- if ($page > 0) echo '<details class="collapsed"><summary>' . $button_text .'</summary>';
- call_user_func($render_page, $page);
- }
- echo str_repeat('</details>', $page_count - 1);
- }
- function format_date($date_string, $timezone = 'UTC') {
- global $settings;
- $date = new DateTime($date_string, new DateTimeZone($timezone));
- $date->setTimezone(new DateTimeZone($settings['timezone']));
- return $date->format(get_string('date-format'));
- }
|