За последние 24 часа нас посетили 63226 программистов и 1740 роботов. Сейчас ищут 899 программистов ...

Помогите подправить скрипт (нужно добавить фильтр)

Тема в разделе "PHP для новичков", создана пользователем Extremist, 27 июл 2011.

  1. Extremist

    Extremist Активный пользователь

    С нами с:
    18 авг 2009
    Сообщения:
    52
    Симпатии:
    0
    Адрес:
    Новосибирск
    Всем добрый
    Иеется такой файл - он парсит в каталоге файлы с именем HLTV_-1100122153-stalkyard.zip и публикует их списком (формат цифр это - \год\мес\день\час\минуты\ - карта

    в общем это скрипт парсинга демок для Half-life

    скрип выводит весь список на страницу, хотел бы добавить фильтр по дням - т.к. демки сохраняются за 7 дней
    и фильт по картам, т.к. список карт один и тот же, чтоб было как в Excel поставил фильтр он выдал только то что по фильтру, снял фильтр, он вывел опять все
    код парсера
    Код (Text):
    1.  
    2. <?php
    3. echo ("<html>");
    4. echo ("<head>");
    5. echo ("<title>Демки</title>");
    6. echo ("</head>");
    7. echo ("<body align=center bgcolor=\"#FBFBFB\" link=\"#8B0000\" vlink=\"#997777\">");
    8. function format_size($size, $round = 0) {
    9.     //Size must be bytes!
    10.         $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    11.         for ($i=0; $size > 1024 && isset($sizes[$i+1]); $i++) $size /= 1024;
    12.             return round($size,$round)." ".$sizes[$i];
    13.         }
    14.        
    15.        
    16.         $path = "."; // folder
    17.         $count = 0; // Arrays start
    18.         $chandle = 0; // boolean for tables
    19.        
    20.         if($dir=opendir($path))
    21.         {
    22.             while($file=readdir($dir))
    23.                 {
    24.                     if (!is_dir($file) && $file != "." && $file != ".." && $file != "index.php" && $file != "hltv.jpg" && $file != "register.php" && $file != "script.php" && $file != "logout.php" && $file != "pq_test.php" && $file != "plrhist.php" && $file != "imgsess.php")
    25.                     if (!is_dir($file) && $file != "themes.php" && $file != "awards.php" && $file != "server.php" && $file != "player.php" && $file != "role.php" && $file != "maps.php" && $file != "live.php" && $file != "clan.php" && $file != "dem_copy.php" && $file != "favicon.ico")
    26.                     if (!is_dir($file) && $file != "weapons.php" && $file != "imgconn.php" && $file != "weapon.php" && $file != "heatimg.php" && $file != "editplr.php" && $file != "editclan.php" && $file != "logo.jpg" && $file != "overview.php" && $file != "imgquick.php" && $file != "opt.php")
    27.                     if (!is_dir($file) && $file != "map.php" && $file != "demos.php" && $file != "Desktop.ini" && $file != "dem.php" && $file != "search.php" && $file != "config.php" && $file != "2.php" && $file != "mapheat.php" && $file != "roles.php" && $file != "query.php" && $file != "login.php" && $file != "imgcc.php" && $file != "clans.php" && $file != "logo2.jpg")
    28.                         {
    29.                                 $tmpfilesize = filesize($file);
    30.                            
    31.                                         $data[$count][year]     = substr($file,5,2); // position 11 because of: "warserver1-09...
    32.                                             $data[$count][month]     = substr($file,7,2);
    33.                                                     $data[$count][day]         = substr($file,9,2);
    34.                                                         $data[$count][hour]     = substr($file,11,2);
    35.                                                                 $data[$count][minute]     = substr($file,13,2);
    36.                                                                 $data[$count][map]      =substr($file,16,-8);
    37.                                                                             $data[$count][file]     = $file;
    38.                                                                                 $data[$count][size]     = format_size($tmpfilesize);
    39.                                                                                
    40.                                                                                         $count++;
    41.                                                                                         }
    42.                                                                                         }
    43.                                                                                         closedir($dir);
    44.                                                                                         }
    45.                                                                                         sort($data);
    46.                                                                                         $data = array_reverse($data);
    47.                                                                                        
    48.                                                                                         echo ("<table border=1 width=100% cellpadding=0 cellspacing=0>");
    49.                                                                                         echo ("<tr align=center>");
    50.                                                                                         echo ("<td width=150><b>Карта</b></td>");
    51.                                                                                         echo ("<td width=150><b>Дата</b></td>");
    52.                                                                                         echo ("<td width=150><b>Время</b></td>");
    53.                                                                                         echo ("<td width=150><b>Размер</b></td>");
    54.                                                                                         echo ("<td><b>Скачать</b></td>");
    55.                                                                                         echo ("</tr>");
    56.                                                                                        
    57.                                                                                         foreach($data as $field)
    58.                                                                                         {
    59.                                                                                             if ($chandle == 0)
    60.                                                                                             {
    61.                                                                                                     echo ("<tr align=center bgcolor=\"#EEEEEE\">");
    62.                                                                                                         $chandle = 1;
    63.                                                                                                         }
    64.                                                                                                         else
    65.                                                                                                             {
    66.                                                                                                                 echo ("<tr align=center bgcolor=\"#D0D0D0\">");
    67.                                                                                                                     $chandle = 0;
    68.                                                                                                                     }
    69.                                                                                                                         echo ("<td>$field[map]</td>");
    70.                                                                                                                         echo ("<td>$field[day].$field[month].$field[year]</td>");
    71.                                                                                                                         echo ("<td>$field[hour]:$field[minute]</td>");
    72.                                                                                                                         echo ("<td>$field[size]</td>");
    73.                                                                                                                         echo ("<td><a href=\"$field[file]\">Скачать</a></td>");
    74.                                                                                                                             echo ("</tr>");
    75.                                                                                                                                 }
    76.                                                                                                                                
    77.                                                                                                                                 echo ("</table>");
    78.  
    79.                                                                                                                                 echo ("</body>");
    80.                                                                                                                                 echo ("</html>");
    81.  
    82. ?>
    83. <?php
    84. echo ("<html>");
    85. echo ("<head>");
    86. echo ("<title>Демки</title>");
    87. echo ("</head>");
    88. echo ("<body align=center bgcolor=\"#FBFBFB\" link=\"#8B0000\" vlink=\"#997777\">");
    89. function format_size($size, $round = 0) {
    90.     //Size must be bytes!
    91.         $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    92.         for ($i=0; $size > 1024 && isset($sizes[$i+1]); $i++) $size /= 1024;
    93.             return round($size,$round)." ".$sizes[$i];
    94.         }
    95.        
    96.        
    97.         $path = "."; // folder
    98.         $count = 0; // Arrays start
    99.         $chandle = 0; // boolean for tables
    100.        
    101.         if($dir=opendir($path))
    102.         {
    103.             while($file=readdir($dir))
    104.                 {
    105.                     if (!is_dir($file) && $file != "." && $file != ".." && $file != "index.php" && $file != "hltv.jpg" && $file != "register.php" && $file != "script.php" && $file != "logout.php" && $file != "pq_test.php" && $file != "plrhist.php" && $file != "imgsess.php")
    106.                     if (!is_dir($file) && $file != "themes.php" && $file != "awards.php" && $file != "server.php" && $file != "player.php" && $file != "role.php" && $file != "maps.php" && $file != "live.php" && $file != "clan.php" && $file != "dem_copy.php" && $file != "favicon.ico")
    107.                     if (!is_dir($file) && $file != "weapons.php" && $file != "imgconn.php" && $file != "weapon.php" && $file != "heatimg.php" && $file != "editplr.php" && $file != "editclan.php" && $file != "logo.jpg" && $file != "overview.php" && $file != "imgquick.php" && $file != "opt.php")
    108.                     if (!is_dir($file) && $file != "map.php" && $file != "demos.php" && $file != "Desktop.ini" && $file != "dem.php" && $file != "search.php" && $file != "config.php" && $file != "2.php" && $file != "mapheat.php" && $file != "roles.php" && $file != "query.php" && $file != "login.php" && $file != "imgcc.php" && $file != "clans.php" && $file != "logo2.jpg")
    109.                         {
    110.                                 $tmpfilesize = filesize($file);
    111.                            
    112.                                         $data[$count][year]     = substr($file,5,2); // position 11 because of: "warserver1-09...
    113.                                             $data[$count][month]     = substr($file,7,2);
    114.                                                     $data[$count][day]         = substr($file,9,2);
    115.                                                         $data[$count][hour]     = substr($file,11,2);
    116.                                                                 $data[$count][minute]     = substr($file,13,2);
    117.                                                                 $data[$count][map]      =substr($file,16,-8);
    118.                                                                             $data[$count][file]     = $file;
    119.                                                                                 $data[$count][size]     = format_size($tmpfilesize);
    120.                                                                                
    121.                                                                                         $count++;
    122.                                                                                         }
    123.                                                                                         }
    124.                                                                                         closedir($dir);
    125.                                                                                         }
    126.                                                                                         sort($data);
    127.                                                                                         $data = array_reverse($data);
    128.                                                                                        
    129.                                                                                         echo ("<table border=1 width=100% cellpadding=0 cellspacing=0>");
    130.                                                                                         echo ("<tr align=center>");
    131.                                                                                         echo ("<td width=150><b>Карта</b></td>");
    132.                                                                                         echo ("<td width=150><b>Дата</b></td>");
    133.                                                                                         echo ("<td width=150><b>Время</b></td>");
    134.                                                                                         echo ("<td width=150><b>Размер</b></td>");
    135.                                                                                         echo ("<td><b>Скачать</b></td>");
    136.                                                                                         echo ("</tr>");
    137.                                                                                        
    138.                                                                                         foreach($data as $field)
    139.                                                                                         {
    140.                                                                                             if ($chandle == 0)
    141.                                                                                             {
    142.                                                                                                     echo ("<tr align=center bgcolor=\"#EEEEEE\">");
    143.                                                                                                         $chandle = 1;
    144.                                                                                                         }
    145.                                                                                                         else
    146.                                                                                                             {
    147.                                                                                                                 echo ("<tr align=center bgcolor=\"#D0D0D0\">");
    148.                                                                                                                     $chandle = 0;
    149.                                                                                                                     }
    150.                                                                                                                         echo ("<td>$field[map]</td>");
    151.                                                                                                                         echo ("<td>$field[day].$field[month].$field[year]</td>");
    152.                                                                                                                         echo ("<td>$field[hour]:$field[minute]</td>");
    153.                                                                                                                         echo ("<td>$field[size]</td>");
    154.                                                                                                                         echo ("<td><a href=\"$field[file]\">Скачать</a></td>");
    155.                                                                                                                             echo ("</tr>");
    156.                                                                                                                                 }
    157.                                                                                                                                
    158.                                                                                                                                 echo ("</table>");
    159.  
    160.                                                                                                                                 echo ("</body>");
    161.                                                                                                                                 echo ("</html>");
    162.  
    163. ?>
     
  2. Gromo

    Gromo Активный пользователь

    С нами с:
    24 май 2010
    Сообщения:
    2.786
    Симпатии:
    2
    Адрес:
    Ташкент