123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- require_once('include/config.php');
- require_once('include/db.php');
- $content = '';
- $script = '';
- $mode = @$_GET['mode'];
- switch ($mode) {
- default: admin_main_menu(); break;
- case 'dirfill': admin_dir_fill(); break;
- }
- function admin_main_menu() {
- global $content;
- $content = '<a href="admin.php?mode=dirfill">Automagiczne uzupełnianie katalogów</a>';
- }
- function admin_dir_fill() {
- global $content;
- global $config;
- global $script;
-
- $path = $config['basedir'];
- $dir_handle = @opendir($path) or die('Błąd otwarcia basedir');
- $dirlist = [];
- while ($file = readdir($dir_handle)) {
- if(!is_dir($path.$file)) continue;
- if (in_array($file, array('miniatury', 'include', '.git', '.', '..')))
- continue;
- $dirlist[] = array('name' => $file, 'date' => filemtime($path.$file));
- }
- usort($dirlist, 'dir_compare');
- $content .= '<form id="dirfillForm" onsubmit="return dirfill_submit(event)"><table><tr><th>Ścieżka</th><th>Nazwa</th><th>Data</th><th>Komentarz</th><th>Już jest</th><th>Dodaj<br><a id="addSelectAll" href="#">Zaznacz wszystko<br><a id="addDeselectAll" href="#">Odznacz wszystko</a></th></tr>';
- foreach($dirlist as $dir) {
- $dirinfo = get_dir_info($dir['name']);
- $dirname = htmlspecialchars($dir['name']);
- $dirselect = md5($dir['name']);
- if ($dirinfo) {
- $content .= '<tr><td>' . $dirname . '</td>';
- $content .= '<td><input type="text" id="' . $dirselect . '-name" value="' . htmlspecialchars($dirinfo['name']) . '"></td>';
- $content .= '<td>Baza danych: <input type="text" id="' . $dirselect . '-date" value="' . $dirinfo['date'] . '"><br>Katalog: ' . $dir['date'] . '</td>';
- $content .= '<td><textarea id="' . $dirselect . '-comment">' . htmlspecialchars($dirinfo['comment']) . '</textarea></td>';
- $content .= '<td>Tak</td><td><input type="checkbox" id="' . $dirselect . '-add" class="addBox">(tylko brakujące pliki)</td></tr>';
- $content .= '<input type="hidden" id="' . $dirselect . '-new" value="0">';
- } else {
- $content .= '<tr><td>' . $dirname . '</td>';
- $content .= '<td><input type="text" id="' . $dirselect . '-name" value="' . $dirname . '"></td>';
- $content .= '<td><input type="text" id="' . $dirselect . '-date" value="' . $dir['date'] . '"></input></td>';
- $content .= '<td><textarea id="' . $dirselect . '-comment"></textarea></td>';
- $content .= '<td>Nie</td><td><input type="checkbox" checked="checked" id="' . $dirselect . '-add" class="addBox"></td></tr>';
- $content .= '<input type="hidden" id="' . $dirselect . '-new" value="1">';
- }
- }
- $content .= '</table><input type="submit" value="OK"></form>';
- // $content = '<pre>' . print_r($dirlist, true) . '</pre>';
- $dirlist_json = json_encode($dirlist);
- $script = 'const dirlist = ' . $dirlist_json . ';';
- }
- function dir_compare($a, $b){
- return $b['date']-$a['date'];
- }
- ?><!DOCTYPE html>
- <html>
- <head>
- <title>Obrazki: Admin</title>
- <link rel="stylesheet" href="/obrazki/style.css" type="text/css">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <script type="text/javascript" src="https://k4be.pl/jquery/jquery-3.6.3.min.js"></script>
- <script type="text/javascript" src="admin.js"></script>
- <script type="text/javascript" src="md5.js"></script>
- <script type="text/javascript">
- <?=$script?>
- </script>
- </head>
- <body>
- <?=$content?>
- </body>
- </html>
|