home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / filesystem / search.inc < prev    next >
Text File  |  2004-03-08  |  10KB  |  245 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. $time = get_time();
  14. $year = date("Y", $time);
  15. $month = date("m", $time);
  16. $day = date("j", $time);
  17. $hour = date("H", $time);
  18. $minute = date("i", $time);
  19.  
  20. $keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
  21.  
  22. $hours = array("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
  23. $mins = array("00","05","10","15","20","25","30","35","34","45","50","55");
  24. for ($i=1;$i<32;$i++)
  25. {
  26.     $num_days[] = $i;
  27. }
  28.  
  29. for ($i=1;$i<13;$i++)
  30. {
  31.     $num_months[] = $i;
  32. }
  33. $search_on_modified_earlier_check = isset($_REQUEST['search_on_modified_earlier']) ? 'checked' : '';
  34. $search_on_modified_later_check = isset($_REQUEST['search_on_modified_later']) ? 'checked' : '';
  35. ?>
  36. <input type="hidden" name="task" value="search" />
  37. <h1><img src="<?php echo $GO_THEME->images['search']; ?>" border="0" height="32" width="32" /> <?php echo $search_title; ?></h1>
  38. <table border="0">
  39. <tr>
  40.     <td valign="top">
  41.     <?php require('treeview.inc'); ?>
  42.     </td>
  43.     <td valign="top">
  44.     <table border="0">
  45.     <tr>
  46.         <td></td>
  47.         <td><?php echo $fbPath; ?>:</td>
  48.         <td>
  49.         <?php
  50.         echo $page_title;
  51.         ?>
  52.         </td>
  53.     </tr>
  54.     <tr>
  55.         <td></td>
  56.         <td><?php echo $fs_keyword; ?>:</td>
  57.         <td>
  58.         <input type="text" name="keyword" size="31" maxlength="255" class="textbox" value="<?php echo $keyword; ?>">
  59.         </td>
  60.     </tr>
  61.     <tr>
  62.         <td><input onclick="update_form();" type="checkbox" name="search_on_modified_later" value="true" <?php echo $search_on_modified_later_check; ?> /></td>
  63.         <td><?php echo $fs_modified_after; ?>:</td>
  64.         <td>
  65.         <?php
  66.         if (!isset($modified_later_then_month)) $modified_later_then_month = $month;
  67.         if (!isset($modified_later_then_day)) $modified_later_then_day = $day;
  68.         if ($_SESSION['GO_SESSION']['date_format'] == "m-d-Y H:i")
  69.         {
  70.             $dropbox = new dropbox();
  71.             $dropbox->add_arrays($num_months, $months);
  72.             $dropbox->print_dropbox("modified_later_then_month", $modified_later_then_month);
  73.  
  74.             $dropbox = new dropbox();
  75.             $dropbox->add_arrays($num_days, $num_days);
  76.             $dropbox->print_dropbox("modified_later_then_day", $modified_later_then_day);
  77.         }else
  78.         {
  79.             $dropbox = new dropbox();
  80.             $dropbox->add_arrays($num_days, $num_days);
  81.             $dropbox->print_dropbox("modified_later_then_day", $modified_later_then_day);
  82.  
  83.             $dropbox = new dropbox();
  84.             $dropbox->add_arrays($num_months, $months);
  85.             $dropbox->print_dropbox("modified_later_then_month", $modified_later_then_month);
  86.         }
  87.         $years[4] = $year;
  88.         $years[3] = $year-1;
  89.         $years[2] = $year-2;
  90.         $years[1] = $year-3;
  91.         $years[0] = $year-4;
  92.  
  93.         $modified_later_then_year = isset($modified_later_then_year) ? $modified_later_then_year : $year;
  94.         $dropbox = new dropbox();
  95.         $dropbox->add_arrays($years, $years);
  96.         $dropbox->print_dropbox("modified_later_then_year", $modified_later_then_year);
  97.         echo '  ';
  98.         if (!isset($modified_later_then_hour)) $modified_later_then_hour = $hour;
  99.         $dropbox = new dropbox();
  100.         $dropbox->add_arrays($hours, $hours);
  101.         $dropbox->print_dropbox("modified_later_then_hour", $modified_later_then_hour);
  102.  
  103.         echo ' : ';
  104.         $modified_later_then_min = isset($modified_later_then_min) ? $modified_later_then_min : $minute;
  105.         $dropbox = new dropbox();
  106.         $dropbox->add_arrays($mins, $mins);
  107.         $dropbox->print_dropbox("modified_later_then_min", $modified_later_then_min);
  108.         ?>
  109.         </td>
  110.     </tr>
  111.     <tr>
  112.         <td><input onclick="update_form();" type="checkbox" name="search_on_modified_earlier" value="true" <?php echo $search_on_modified_earlier_check; ?> /></td>
  113.         <td><?php echo $fs_modified_before; ?>:</td>
  114.         <td>
  115.         <?php
  116.         $modified_earlier_then_month = isset($_POST['modified_earlier_then_month']) ? $_POST['modified_earlier_then_month'] : $month;
  117.         $modified_earlier_then_day = isset($_POST['modified_earlier_then_day']) ? $_POST['modified_earlier_then_day'] : $day;
  118.         if ($_SESSION['GO_SESSION']['date_format'] == "m-d-Y H:i")
  119.         {
  120.             $dropbox = new dropbox();
  121.             $dropbox->add_arrays($num_months, $months);
  122.             $dropbox->print_dropbox("modified_earlier_then_month", $modified_earlier_then_month);
  123.  
  124.             $dropbox = new dropbox();
  125.             $dropbox->add_arrays($num_days, $num_days);
  126.             $dropbox->print_dropbox("modified_earlier_then_day", $modified_earlier_then_day);
  127.         }else
  128.         {
  129.             $dropbox = new dropbox();
  130.             $dropbox->add_arrays($num_days, $num_days);
  131.             $dropbox->print_dropbox("modified_earlier_then_day", $modified_earlier_then_day);
  132.  
  133.             $dropbox = new dropbox();
  134.             $dropbox->add_arrays($num_months, $months);
  135.             $dropbox->print_dropbox("modified_earlier_then_month", $modified_earlier_then_month);
  136.         }
  137.  
  138.  
  139.         $modified_earlier_then_year = isset($_POST['modified_earlier_then_year']) ? $_POST['modified_earlier_then_year'] : $year;
  140.         $dropbox = new dropbox();
  141.         $dropbox->add_arrays($years, $years);
  142.         $dropbox->print_dropbox("modified_earlier_then_year", $modified_earlier_then_year);
  143.         echo '  ';
  144.         if (!isset($modified_earlier_then_hour)) $modified_earlier_then_hour = $hour;
  145.         $dropbox = new dropbox();
  146.         $dropbox->add_arrays($hours, $hours);
  147.         $dropbox->print_dropbox("modified_earlier_then_hour", $modified_earlier_then_hour);
  148.  
  149.         echo ' : ';
  150.         $modified_earlier_then_min = isset($_POST['modified_earlier_then_min']) ? $_POST['modified_earlier_then_min'] : $minute;
  151.         $dropbox = new dropbox();
  152.         $dropbox->add_arrays($mins, $mins);
  153.         $dropbox->print_dropbox("modified_earlier_then_min", $modified_earlier_then_min);
  154.         ?>
  155.         </td>
  156.     </tr>
  157.     <tr>
  158.         <td colspan="3">
  159.         <?php
  160.         $button = new button($fs_search,'javascript:document.forms[0].submit();');
  161.         echo '  ';
  162.         $button = new button($cmdClose,"javascript:document.location='".$_SERVER['PHP_SELF']."';");
  163.         ?>
  164.         </td>
  165.     </tr>
  166.     <tr>
  167.         <td colspan="3">
  168.         <br />
  169.         <?php
  170.         if ($_SERVER['REQUEST_METHOD'] == 'POST')
  171.         {
  172.             if ($keyword != '')
  173.             {
  174.                 if (isset($_POST['search_on_modified_later']))
  175.                 {
  176.                     $modified_earlier_then = mktime($modified_earlier_then_hour, $modified_earlier_then_min,0, $modified_earlier_then_month, $modified_earlier_then_day, $modified_earlier_then_year);
  177.                 }else
  178.                 {
  179.                     $modified_earlier_then = 0;
  180.                 }
  181.  
  182.                 if (isset($_POST['search_on_modified_later']))
  183.                 {
  184.                     $modified_later_then = mktime($modified_later_then_hour, $modified_later_then_min,0, $modified_later_then_month, $modified_later_then_day, $modified_later_then_year);
  185.                 }else
  186.                 {
  187.                     $modified_later_then = 0;
  188.                 }
  189.                 $results = $fs->search($path, $keyword,$modified_later_then,$modified_earlier_then);
  190.                 $count = count($results);
  191.  
  192.                 echo '<table border="0" cellspacing="0" cellpadding="0" width="500"><tr>';
  193.                 echo '<td colspan="2" class="TableHead2" width="16">'.$strName.'</td>';
  194.                 echo '<td colspan="2" class="TableHead2" width="16">Lokatie</td></tr>';
  195.  
  196.                 while($result = array_shift($results))
  197.                 {
  198.                     if (!is_dir($result['path']))
  199.                     {
  200.                         $extension = get_extension($result['name']);
  201.                         echo '<tr height="18"><td width="16"><img width="16" height="16" border="0" src="'.$GO_CONFIG->control_url.'icon.php?extension='.$extension.'" /></td>';
  202.                         echo '<td nowrap> <a target="_blank" href="download.php?path='.urlencode($result['path']).'">'.$result['name'].'</a></td>';
  203.                     }else
  204.                     {
  205.                         echo '<tr height="18"><td width="16"><img width="16" height="16" border="0" src="'.$GO_THEME->images['folder'].'" /></td>';
  206.                         echo '<td nowrap> <a target="_self" href="'.$_SERVER['PHP_SELF'].'?path='.urlencode($result['path']).'">'.$result['name'].'</a></td>';
  207.                     }
  208.                     $location = dirname($result['path']);
  209.  
  210.                     echo '<td nowrap> <a href="'.$_SERVER['PHP_SELF'].'?path='.urlencode($location).'">'.str_replace($GO_CONFIG->file_storage_path,$GO_CONFIG->slash,$location).'</a></td></tr>';
  211.                     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  212.                 }
  213.                 echo '<tr><td colspan="99" class="small" height="18"> '.$count.' '.$fbItems.'</td></tr>';
  214.                 echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  215.                 echo '</table>';
  216.             }else
  217.             {
  218.                 echo '<p class="Error">'.$fs_enter_keyword.'</p>';
  219.             }
  220.         }
  221.         ?>
  222.         </td>
  223.     </tr>
  224.     </table>
  225.     </td>
  226. </tr>
  227. </table>
  228.  
  229. <script type="text/javascript" language="javascript">
  230. function update_form()
  231. {
  232.     document.forms[0].modified_earlier_then_min.disabled = !document.forms[0].search_on_modified_earlier.checked;
  233.     document.forms[0].modified_earlier_then_hour.disabled = !document.forms[0].search_on_modified_earlier.checked;
  234.     document.forms[0].modified_earlier_then_month.disabled = !document.forms[0].search_on_modified_earlier.checked;
  235.     document.forms[0].modified_earlier_then_day.disabled = !document.forms[0].search_on_modified_earlier.checked;
  236.     document.forms[0].modified_earlier_then_year.disabled = !document.forms[0].search_on_modified_earlier.checked;
  237.  
  238.     document.forms[0].modified_later_then_min.disabled = !document.forms[0].search_on_modified_later.checked;
  239.     document.forms[0].modified_later_then_hour.disabled = !document.forms[0].search_on_modified_later.checked;
  240.     document.forms[0].modified_later_then_month.disabled = !document.forms[0].search_on_modified_later.checked;
  241.     document.forms[0].modified_later_then_day.disabled = !document.forms[0].search_on_modified_later.checked;
  242.     document.forms[0].modified_later_then_year.disabled = !document.forms[0].search_on_modified_later.checked;
  243. }
  244. update_form();
  245. </script>