WebCalendar PHP Cross Reference Groupware Applications

Source: /icons.php - 85 lines - 2317 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: icons.php,v 1.12.2.2 2007/08/06 02:28:30 cknudsen Exp $ */
   3  include_once  'includes/init.php';
   4  $icon_path = 'icons/';
   5  
   6  $can_edit = ( is_dir ( $icon_path ) &&
   7    ( $ENABLE_ICON_UPLOADS == 'Y' || $is_admin ) );
   8  
   9  if ( ! $can_edit )
  10    do_redirect ( 'category.php' );
  11  
  12  print_header ( array ( 'js/visible.php' ), '', '', true );
  13  
  14  $icons = array ();
  15  
  16  if ( $d = dir ( $icon_path ) ) {
  17    while ( false !== ( $entry = $d->read () ) ) {
  18      if ( substr ( $entry, -3, 3 ) == 'gif' ) {
  19        $data = '';
  20        // We''ll compare the files to eliminate duplicates.
  21        $fd = @fopen ( $icon_path . $entry, 'rb' );
  22        if ( $fd ) {
  23          // We only need to compare the first 1kb.
  24          $data .= fgets ( $fd, 1024 );
  25          $icons[md5 ( $data )] = $entry;
  26        }
  27        fclose ( $fd );
  28      }
  29    }
  30    $d->close ();
  31    // Remove duplicates and replace keys with 0...n.
  32    $icons = array_unique ( $icons );
  33    //Convert associative array into numeric array
  34    $icons = array_values ( $icons );
  35    $title_str = translate ( 'Click to Select' );
  36  
  37    ?>
  38    <script language="JavaScript" type="text/javascript">
  39    <!-- <![CDATA[
  40    function sendURL ( url ) {
  41      var
  42        thisInput = window.opener.document.catform.urlname,
  43        thisPic = window.opener.document.images.urlpic,
  44        thistr1 = window.opener.document.getElementById ('cat_icon'),
  45        thistr2 = window.opener.document.getElementById ('remove_icon');
  46      thisInput.value = url.substring (6);
  47      thisPic.src = url;
  48      thistr1.style.visibility =
  49      thistr2.style.visibility = "visible";
  50      window.close ();
  51    }
  52    //]]> -->
  53    </script>
  54  
  55  <?php
  56    ob_start ();
  57    echo '
  58      <table align="center" border="0">
  59        <tr>
  60          <td colspan="8" align="center"><h2>'
  61     . translate ( 'Current Icons on Server' ) . '</h2></td>
  62        </tr>
  63        <tr>';
  64    for ( $i = 0, $cnt = count ( $icons ); $i < $cnt; $i++ ) {
  65      echo '
  66          <td><a href="#" onclick="sendURL( \'' . $icon_path . $icons[$i]
  67       . '\' )" ><img src="' . $icon_path . $icons[$i] . '" border="0" title="'
  68       . $title_str . '" alt="' . $title_str . '" /></a></td>'
  69       . ( $i > 0 && $i % 8 == 0 ? '
  70        </tr>
  71        <tr>' : '' );
  72    }
  73    echo '
  74        </tr>
  75        <tr>
  76          <td colspan="8" align="center">' . $title_str . '</td>
  77        </tr>
  78      </table>
  79    </body>
  80  </html>';
  81  
  82    ob_end_flush ();
  83  }
  84  
  85  ?>

title

Description

title

Description

title

Description

title

title

Body