DirectoryIndex index.php index.html RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^index\\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Header set Cache-Control "no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" Header always set Referrer-Policy "strict-origin-when-cross-origin" ExpiresActive On ExpiresByType image/png "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresDefault "access plus 1 month" # Conditional Basic auth: activates only if the file exists AuthType Basic AuthName "Restricted Area" AuthBasicProvider file AuthUserFile "{$absHtpasswd}" Require valid-user # Перехоплення 401 → редирект на головну ErrorDocument 401 / EOT; if (!file_exists($htaccess_file)) { file_put_contents($htaccess_file, $htaccess_base); } // Page options and theme settings $options = [ 'exclusion' => ['favicon.*', '*.php', '*.exe', '*.gz', '*.7zip', '*.dat', '.*', '*.log', '#*', 'google*', '@*', '*.db', 'assets', 'error*', '*.json', 'stat*', 'index*'], 'theme' => 'night', ]; $themes = [ 'dark' => [ 'primary' => 'rgba(19, 5, 42, 1.0)', 'secondary' => 'rgba(192, 192, 192, 0.75)', 'tertiary' => 'rgb(232, 232, 249)', 'banner' => 'rgba(192, 192, 192, 1.0)', ], 'night' => [ 'primary' => 'rgb(15, 22, 48)', // #0f1630 'secondary' => 'rgba(107, 114, 128, 1.0)', // #6b7280 'tertiary' => 'rgba(233, 230, 243, 0.8)', // #e9e6f3 'banner' => 'rgb(159, 176, 200)', // #9fb0c8 ], ]; $theme = $themes[$options['theme']]; $style_template = << .t90, .rowresize > .t80 { display: flex; align-items: center; } /* Адаптивність */ @media (max-width: 768px) { html { font-size: 0.875em; } } @media (max-width: 320px) { .rowresize { font-size: 0.8em; } } @media (max-width: 568px) { .columns { flex-direction: column; } .rowresize { grid-template-columns: 1fr 4.1em 5em; } .rowresize > :first-child { display: none; } } @media (max-width: 480px) { .rowresize { grid-template-columns: 1fr 5em; } .rowresize > :nth-child(3) { display: none; } } @media (max-width: 320px) { .rowresize { grid-template-columns: 1fr; } .rowresize > :nth-child(4) { display: none; } } @media (min-device-width: 768px) and (max-device-width: 1024px) { body { font-size: 16px; padding: 10px; } img { max-width: 100%; height: auto; } } CSS; // Підготуємо мапінг CSS-перемінних на ключі теми $map = [ 'color-bkg' => $theme['primary'] ?? $themes['dark']['primary'], 'color-secondary' => $theme['secondary'] ?? $themes['dark']['secondary'], 'color-tertiary' => $theme['tertiary'] ?? $themes['dark']['tertiary'], 'color-banner' => $theme['banner'] ?? $themes['dark']['banner'], ]; // Формуємо рядок :root{...} $root_parts = []; foreach ($map as $k => $v) { if ($v === null || $v === '') continue; $root_parts[] = '--' . $k . ': ' . $v . ';'; } $root_css = ':root{' . implode('', $root_parts) . '}'; // Підмінюємо існуючий блок :root{...} у шаблоні (якщо є), або додаємо на початок if (preg_match('/:root\s*\{[^}]*\}/', $style_template)) { $style = preg_replace('/:root\s*\{[^}]*\}/', $root_css, $style_template); } else { $style = $root_css . $style_template; } // Initialize variables $up = realpath(__DIR__) === realpath($_SERVER['DOCUMENT_ROOT']) ? '' : "
"; $current_name = str_replace(['_', ' '], ' ', mb_strtoupper(basename(__DIR__))); // Create assets directories $assets_dir = './assets/'; $picture_dir = $assets_dir . 'picture/'; foreach ([$assets_dir, $picture_dir] as $dir) { if (!file_exists($dir)) { mkdir($dir, 0777, true); } } // Agreement $agreement_content = <<Домовленість

Розділ {$current_name} призначено для особистого користування. Скрипти підготовлено для приватних потреб із використанням матеріалів відкритих джерел. Ми дотримуємося принципів CC Zero, що дозволяють вільно поширювати, адаптувати та змінювати інформацію без додаткових вимог. Ви можете переглядати та ділитися посиланнями на цей ресурс, проте просимо врахувати, що вміст сторінок може бути змінено без попереднього повідомлення.

Попередження

Програмне забезпечення надається «як є», без будь‑яких гарантій. Автори та правовласники не несуть відповідальності за будь‑які збитки або претензії, що можуть виникнути внаслідок його використання. За запитами звертайтеся на електронну пошту: . .

EOT; $agreement_text = 'The directory has been created: ' . date('d-m-Y H:i') . "\n\n[En] Stub script for folders without an index file.\n" . strip_tags(str_replace("\t", '', $agreement_content)); // Statistics setup $stats_dir = $assets_dir . 'stats/'; if (!file_exists($stats_dir)) { mkdir($stats_dir, 0777, true); } $hash_db = $stats_dir . 'hash_db.json'; $count_db = $stats_dir . 'count_db.json'; // безпечне читання файлів $hash_data = (file_exists($hash_db) && filesize($hash_db) > 0) ? json_decode(file_get_contents($hash_db), true) : []; $count_data = (file_exists($count_db) && filesize($count_db) > 0) ? json_decode(file_get_contents($count_db), true) : []; // гарантуємо, що це масиви if (!is_array($hash_data)) $hash_data = []; if (!is_array($count_data)) $count_data = []; $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR']; $hashed_ip = hash('sha256', $ip); $today = date('d-m-Y'); $yesterday = date('d-m-Y', strtotime('-1 day')); // ініціалізація ключів $hash_data[$today] = $hash_data[$today] ?? []; $count_data[$today] = $count_data[$today] ?? 0; $count_data['total'] = $count_data['total'] ?? 0; // додаємо відвідувача, якщо його ще не було if (!in_array($hashed_ip, $hash_data[$today])) { $hash_data[$today][] = $hashed_ip; $count_data[$today] += 1; $count_data['total'] += 1; } // збереження у файли file_put_contents($hash_db, json_encode($hash_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); file_put_contents($count_db, json_encode($count_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); // значення для виводу $yesterday_visits = $count_data[$yesterday] ?? 0; // fallback → 0 $total_visits = $count_data['total'] ?? 0; $today_visits = $count_data[$today] ?? 0; // пошук дня з найбільшим трафіком $max_visitors = 0; $max_day = ''; foreach ($count_data as $day => $visitors) { if ($day === 'total') continue; if ($visitors > $max_visitors) { $max_visitors = $visitors; $max_day = $day; } } // PHP info shortcut if (!empty($_GET['phpinfo'])) { phpinfo(); exit; } // Server information $host_version = $_SERVER['SERVER_NAME']; $apache_version = ''; if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match('/Apache\/([\d\.]+)/', $_SERVER['SERVER_SOFTWARE'], $m)) { $apache_version = $m[1]; } $php_version = explode('-', phpversion())[0]; $mysql_version = explode('-', explode(' ', mysqli_get_client_info())[1] ?? '')[0] ?? ''; // SSL certificate info $url_ssl = "ssl://{$host_version}:443"; $context = stream_context_create([ 'ssl' => [ 'capture_peer_cert' => true, 'verify_peer' => false, 'verify_peer_name' => false, ] ]); $ssl_from = 'N/A'; $ssl_to = 'N/A'; $fp = @stream_socket_client($url_ssl, $err_no, $err_str, 30, STREAM_CLIENT_CONNECT, $context); if ($fp) { $cert_params = stream_context_get_params($fp); if (!empty($cert_params['options']['ssl']['peer_certificate'])) { $ssl = openssl_x509_parse($cert_params['options']['ssl']['peer_certificate']); if (!empty($ssl['validFrom_time_t'])) { $ssl_from = date('d-m-Y', $ssl['validFrom_time_t']); } if (!empty($ssl['validTo_time_t'])) { $ssl_to = date('d-m-Y', $ssl['validTo_time_t']); } } fclose($fp); } // Формування масиву інформації про сервер if ($apache_version === '' || $mysql_version === '') { $server = [ 'Host' => $host_version, 'Time zone' => date_default_timezone_get(), 'Protocol' => $_SERVER['SERVER_PROTOCOL'], 'SSL validate' => $ssl_from." to ".$ssl_to, ]; } else { $server = [ 'Host' => $host_version, 'Apache HTTP' => $apache_version, 'PHP version' => $php_version, 'SSL validate' => $ssl_from." to ".$ssl_to, ]; } // Calculating the catalog size for Linux (fast) function folderSize($dir) { $size = trim(shell_exec('du -sb ' . escapeshellarg($dir) . ' | cut -f1')); return sizeFilter((int)$size); } // Calculating the catalog size for others (slow) /* function folderSize($dir) { $size = 0; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS) ); foreach ($iterator as $file) { if ($file->isFile()) { $size += $file->getSize(); } } return sizeFilter($size); } */ function sizeFilter($bytes) { $labels = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $i = 0; while ($bytes >= 1024 && $i < count($labels) - 1) { $bytes /= 1024; $i++; } return round($bytes, 2) . ' ' . $labels[$i]; } function filenameMatch($patterns, $filename) { foreach ($patterns as $pattern) { if (fnmatch($pattern, $filename)) { return true; } } return false; } // List directory contents $directory_list = []; if ($handle = opendir('./')) { $items = []; while (false !== ($item = readdir($handle))) { if ($item === '.' || $item === '..' || filenameMatch($options['exclusion'], $item)) { continue; } $type = is_dir($item) ? 'dir' : 'file'; $items[] = ['name' => $item, 'type' => $type, 'order' => $type === 'dir' ? 1 : 0]; } array_multisort(array_column($items, 'order'), SORT_DESC, $items); $directory_list = $items; closedir($handle); } $dir_list = $file_list = ''; foreach ($directory_list as $item) { $name = str_replace(['_', ' '], ' ', $item['name']); if ($item['type'] === 'dir') { $name = strtoupper($name); $size = '― dir ―'; // Uncomment below for folder size // ATTENTION! Use with caution - calculating the size is a very slow function: // $size = folderSize($item['name']); $dir_list .= "
" . "
" . "" . "
" . date('d-m-y', filectime($item['name'])) . "
" . "
{$size}
" . "
"; } else { $name = strtolower($name); if (pathinfo($name, PATHINFO_EXTENSION) === 'html') { $name = pathinfo($name, PATHINFO_FILENAME); } $size = sizeFilter(filesize($item['name'])); $file_list .= "
" . "
" . "" . "
" . date('d-m-y', filectime($item['name'])) . "
" . "
{$size}
" . "
"; } } $file_list_combined = $dir_list . $file_list; // Page info table $yesterday_visits = $count_data[$yesterday] ?? 'none'; $stat_info = "
Total visits{$count_data['total']}
Today's{$count_data[$today]}
Yesterday's{$yesterday_visits}
With {$max_visitors} visitors, {$max_day} was the day with most traffic.
"; // Server info table $server_info = " "; foreach ($server as $label => $value) { if (!empty($value)) { $server_info .= " "; } } $server_info .= "
{$label}{$value}
"; ?> '; $favicon = 'data:image/svg+xml;base64,' . base64_encode($svg); ?> <?= $current_name ?>

Доба несе відбиток часу, а кожна мить - її окремий сенс..

Перед вами список файлів і каталогів, доступних для перегляду. Кешування не використовується, тому список формується на льоту, а захист забезпечується конфігурацією htaccess файла.

Трафік розділу "; $chart_html .= "
"; foreach ($last_days as $day => $visitors) { $weekday = date('w', strtotime($day)); $dot_color = ($weekday == 0) ? "var(--color-secondary)" : "rgba(150, 212, 212, 0.2)"; $dot_title = ($weekday == 0) ? "Неділя" : "День тижня"; $chart_html .= "
"; } $chart_html .= "
"; $chart_html .= "
"; echo $chart_html; ?>