home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / file_dialog.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  7.1 KB  |  247 lines

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <?php
  3. /**
  4.  * Advanced Web Interface to phpDocumentor
  5.  *
  6.  * Customized for PEAR
  7.  * @see phpdoc.php
  8.  * @package  phpDocumentor
  9.  * @subpackage PEAR
  10.  * @filesource
  11.  */
  12. //
  13. // +------------------------------------------------------------------------+
  14. // | phpDocumentor :: docBuilder Web Interface                              |
  15. // +------------------------------------------------------------------------+
  16. // | Copyright (c) 2003 Andrew Eddie, Greg Beaver                           |
  17. // +------------------------------------------------------------------------+
  18. // | This source file is subject to version 3.00 of the PHP License,        |
  19. // | that is available at http://www.php.net/license/3_0.txt.               |
  20. // | If you did not receive a copy of the PHP license and are unable to     |
  21. // | obtain it through the world-wide-web, please send a note to            |
  22. // | license@php.net so we can mail you a copy immediately.                 |
  23. // +------------------------------------------------------------------------+
  24. //
  25.  
  26.  
  27. /**
  28. * common file information
  29. */
  30. require_once 'PhpDocumentor/phpDocumentor/common.inc.php';
  31. require_once 'PhpDocumentor/HTML_TreeMenu-1.1.2/TreeMenu.php';
  32. require_once( 'C:\xampp\php\pear\data' . PATH_DELIMITER . 'PhpDocumentor/docbuilder/includes/utilities.php' );
  33.  
  34. $root_dir = 'PhpDocumentor';
  35.  
  36. if (!function_exists( 'version_compare' )) {
  37.     print "phpDocumentor requires PHP version 4.1.0 or greater to function";
  38.     exit;
  39. }
  40.  
  41. // set up include path so we can find all files, no matter what
  42. $GLOBALS['_phpDocumentor_install_dir'] = $root_dir;
  43.  
  44. // find the .ini directory by parsing phpDocumentor.ini and extracting _phpDocumentor_options[userdir]
  45. $ini = phpDocumentor_parse_ini_file('C:\xampp\php\pear\data' . PATH_DELIMITER . 'PhpDocumentor/phpDocumentor.ini', true);
  46. if (isset($ini['_phpDocumentor_options']['userdir'])) {
  47.     $configdir = $ini['_phpDocumentor_options']['userdir'];
  48. } else {
  49.     $configdir = 'C:\xampp\php\pear\data' . PATH_DELIMITER . 'PhpDocumentor/user';
  50. }
  51.  
  52. // allow the user to change this at runtime
  53. if (!empty( $_REQUEST['altuserdir'] )) {
  54.     $configdir = $_REQUEST['altuserdir'];
  55. }
  56. ?>
  57. <html>
  58. <head>
  59.     <title>
  60.         File browser
  61.     </title>
  62.     <style type="text/css">
  63.         body, td, th, select, input {
  64.             font-family: verdana,sans-serif;
  65.             font-size: 9pt;
  66.         }
  67.         .text {
  68.             font-family: verdana,sans-serif;
  69.             font-size: 9pt;
  70.             border: solid 1px #000000;
  71.         }
  72.         .button {
  73.             border: solid 1px #000000;
  74.         }
  75.         .small {
  76.             font-size: 7pt;
  77.         }
  78.     </style>
  79.  
  80.     <script src="../HTML_TreeMenu-1.1.2/TreeMenu.js" language="JavaScript" type="text/javascript"></script>
  81.  
  82. <?php
  83.     set_time_limit(0);    // six minute timeout
  84.     ini_set("memory_limit","256M");
  85.  
  86.     /**
  87.      * Directory Node
  88.      * @package HTML_TreeMenu
  89.      */
  90.     class DirNode extends HTML_TreeNode
  91.     {
  92.         /**
  93.         * full path to this node
  94.         * @var string
  95.         */
  96.         var $path;
  97.         
  98.         function DirNode($text = false, $link = false, $icon = false, $path, $events = array())
  99.         {
  100.             $this->path = $path;
  101.             $options = array();
  102.             if ($text) $options['text'] = $text;
  103.             if ($link) $options['link'] = $link;
  104.             if ($icon) $options['icon'] = $icon;
  105.             HTML_TreeNode::HTML_TreeNode($options,$events);
  106.         }
  107.     }
  108.  
  109.  
  110.     $menu  = new HTML_TreeMenu();
  111.     $filename = '';
  112.     if (isset($_GET) && isset($_GET['fileName'])) {
  113.         $filename = $_GET['fileName'];
  114.     }
  115.     $filename = realpath($filename);
  116.     $pd = (substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/';
  117.     $test = ($pd == '/') ? '/' : 'C:\\';
  118.     if (empty($filename) || ($filename == $test)) {
  119.         $filename = ($pd == '/') ? '/' : 'C:\\';
  120.         $node = false;
  121.         getDir($filename,$node);
  122.     } else {
  123.         flush();
  124. //            if ($pd != '/') $pd = $pd.$pd;
  125.         $anode = false;
  126.         switchDirTree($filename,$anode);
  127. //            recurseDir($filename,$anode);
  128.         $node = new HTML_TreeNode(array('text' => "Click to view ".addslashes($filename),'link' => "",'icon' => 'branchtop.gif'));
  129.         $node->addItem($anode);
  130.     };
  131.     $menu->addItem($node);
  132.     $DHTMLmenu = &new HTML_TreeMenu_DHTML($menu,
  133.                         array('images' => '../HTML_TreeMenu-1.1.2/images'));
  134. ?>
  135. <script type="text/javascript" language="Javascript">
  136. /**
  137.    Creates some global variables
  138. */
  139. function initializate() {
  140. //
  141. //The "platform independent" newLine
  142. //
  143. //Taken from http://developer.netscape.com/docs/manuals/communicator/jsref/brow1.htm#1010426
  144.     if (navigator.appVersion.lastIndexOf( 'Win' ) != -1) {
  145.         $pathdelim="\\";
  146.         $newLine="\r\n";
  147.     } else {
  148.         $newLine="\n";
  149.         $pathdelim="/";
  150.     }
  151.     /* for($a=0;$a<document.dataForm.elements.length;$a++) {
  152.      alert("The name is '"+document.dataForm.elements[$a].name+"' "+$a);
  153.      }
  154.     */
  155. }
  156. /** Sets the contents of the help box, and submits the form
  157. */
  158. function setHelp( $str ) {
  159.     document.helpForm.fileName.value = $str;
  160.     document.helpForm.submit();
  161. }
  162.  
  163. /** Sets the contents of the help box only
  164. */
  165. function setHelpVal( $str ) {
  166.     document.helpForm.fileName.value = $str;
  167. }
  168. /**Takes a given string and leaves it ready to add a new string
  169.    That is, puts the comma and the new line if needed
  170. */
  171. function prepareString($myString) {
  172.  //First verify that a comma is not at the end
  173.  if($myString.lastIndexOf(",") >= $myString.length-2) {
  174.   //We have a comma at the end
  175.   return $myString;
  176.  }
  177.  if($myString.length > 0) {
  178.   $myString+=","+$newLine;
  179.  }
  180.  return $myString;
  181. }
  182.  
  183.  
  184.  function myReplace($string,$text,$by) {
  185.  // Replaces text with by in string
  186.      var $strLength = $string.length, $txtLength = $text.length;
  187.      if (($strLength == 0) || ($txtLength == 0)) return $string;
  188.  
  189.      var $i = $string.indexOf($text);
  190.      if ((!$i) && ($text != $string.substring(0,$txtLength))) return $string;
  191.      if ($i == -1) return $string;
  192.  
  193.      var $newstr = $string.substring(0,$i) + $by;
  194.  
  195.      if ($i+$txtLength < $strLength)
  196.          $newstr += myReplace($string.substring($i+$txtLength,$strLength),$text,$by);
  197.  
  198.      return $newstr;
  199.  }
  200. </script>
  201.  
  202. </head>
  203.  
  204. <body bgcolor="#ffffff" onload="javascript:initializate()">
  205. <strong>Directory Browser</strong>
  206.  
  207. <table cellpadding="1" cellspacing="1" border="0" width="100%">
  208.  
  209. <form name="helpForm" action="<?php print $_SERVER['PHP_SELF']; ?>" method="get" enctype="multipart/form-data">
  210. <tr>
  211.     <td colspan="2" width="100%">
  212.         Use this to find directories and files which can be used below:
  213.     </td>
  214. </tr>
  215. <tr>
  216.     <td align="right">
  217.         <a href="javascript:document.helpForm.submit();" title="browse tree">
  218. <?php
  219.     echo showImage( 'images/rc-gui-install-24.png', '24', '24' );
  220. ?>
  221.         </a>
  222.     </td>
  223.     <td>
  224.         <input size="60" type="text" name="fileName" value="<?php print $filename;?>" class="text" />
  225.     </td>
  226. </tr>
  227. <tr>
  228.     <td>
  229.         <input type="submit" name="helpdata" value="close" class="button" onclick="window.close();" />
  230.     </td>
  231.     <td align="right">
  232.         <input type="submit" name="helpdata" value="accept" class="button" onclick="opener.setFile(document.helpForm.fileName.value);window.close();" />
  233.     </td>
  234. </tr>
  235. <tr>
  236.     <td colspan="2">
  237.         <div id='menuLayer'></div>
  238.         <?php $DHTMLmenu->printMenu(); ?>
  239.     </td>
  240. </tr>
  241. </form>
  242.  
  243. </table>
  244.  
  245. </body>
  246. </html>
  247.