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

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
  7. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  8. // | Web           http://www.phpdoc.org                                    |
  9. // | Mirror        http://phpdocu.sourceforge.net/                          |
  10. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  11. // +------------------------------------------------------------------------+
  12. // | This source file is subject to version 3.00 of the PHP License,        |
  13. // | that is available at http://www.php.net/license/3_0.txt.               |
  14. // | If you did not receive a copy of the PHP license and are unable to     |
  15. // | obtain it through the world-wide-web, please send a note to            |
  16. // | license@php.net so we can mail you a copy immediately.                 |
  17. // +------------------------------------------------------------------------+
  18. //
  19.  
  20. /**
  21.  * Common variables/functions used by other files in phpDocumentor
  22.  * @package phpDocumentor
  23.  * @filesource
  24.  */
  25. /** phpDocumentor version */
  26. define("PHPDOCUMENTOR_VER","1.2.3");
  27. /** phpDocumentor version */
  28. define("PHPDOCUMENTOR_WEBSITE","http://www.phpdoc.org");
  29. define('SMART_PATH_DELIMITER', DIRECTORY_SEPARATOR ); // set the correct path delimiter
  30. define('tokenizer_ext', extension_loaded('tokenizer') && version_compare(phpversion(),"4.3.0",">="));
  31. // we just replace all the \ with / so that we can just operate on /
  32. define('PATH_DELIMITER', '/' ); // set the correct path delimiter
  33. define('PHPDOCUMENTOR_WINDOWS',substr(PHP_OS, 0, 3) == 'WIN');
  34.  
  35. /** used in phpdoc.php and new_phpdoc.php */
  36. function phpDocumentor_ConfigFileList($directory)
  37. {
  38.     $ret = array();
  39.     if (@is_dir($directory))
  40.     {
  41.         $ret = array();
  42.         $d = @dir($directory); // thanks to Jason E Sweat (jsweat@users.sourceforge.net) for fix
  43.         while($d && $entry=$d->read())
  44.         {
  45.             $getentry = false;
  46.             if (strcmp($entry,".") != 0 && strcmp($entry,"..") != 0)
  47.             {
  48.                 if (substr($entry,0,1) != ".") $getentry = true;
  49.             }
  50.             if ($getentry == true)
  51.             {
  52.                 if (strpos($entry,'.ini'))
  53.                 if (is_file($directory . PATH_DELIMITER . $entry))
  54.                 {
  55.                     $ret[] = str_replace('.ini','',$entry);
  56.                 }
  57.             }
  58.         }
  59.         if ($d) $d->close();
  60.     } else
  61.     {
  62.     }
  63.     return $ret;
  64. }
  65.  
  66.  
  67. /**
  68.  * Parse an .ini file
  69.  * 
  70.  * Works like {@link parse_ini_file}, except it will take a section like:
  71.  *
  72.  * <pre>
  73.  * [MYVAR]
  74.  * value1
  75.  * value2
  76.  * value3
  77.  * </pre>
  78.  *
  79.  * and return an associative array(MYVAR => array(value1, value2, value3))
  80.  * @return array
  81.  * @param string full path to the ini file
  82.  * @param boolean add an associative index for each section [in brackets]
  83.  */
  84. function phpDocumentor_parse_ini_file($filename, $process_sections = false)
  85. {
  86.     $ini_array = array();
  87.     $sec_name = "";
  88.     $lines = @file($filename);
  89.     if( !$lines) return $lines;
  90.     foreach($lines as $line)
  91.     {
  92.         // code by Greg Beaver, ignore comments
  93.         if ($line[0] == ';') continue;
  94.         $line = trim($line);
  95.         
  96.         if($line == "")
  97.         {
  98.             continue;
  99.         }
  100.         if($line[0] == "[" && $line[strlen($line) - 1] == "]")
  101.         {
  102.             $sec_name = substr($line, 1, strlen($line) - 2);
  103.         } else
  104.         {
  105.             if (strpos($line,"="))
  106.             {
  107.                 $pos = strpos($line, "=");
  108.                 $property = trim(substr($line, 0, $pos));
  109.                 // code by Greg Beaver
  110.                 $value = trim(substr($line, $pos + 1));
  111.                 if ($value == 'false') $value = false;
  112.                 if ($value == 'true') $value = true;
  113.                 if (substr($value,0,1) == '"' && substr($value,-1) == '"')
  114.                 {
  115.                     $value = stripcslashes(substr($value,1,count($value) - 2));
  116.                 }
  117.                 // done additions
  118.                 
  119.                 if($process_sections)
  120.                 {
  121.                     if ($sec_name != '')
  122.                     $ini_array[$sec_name][$property] = $value;
  123.                     else
  124.                     $ini_array[$property] = $value;
  125.                 } else
  126.                 {
  127.                     $ini_array[$property] = $value;
  128.                 }
  129.             } else
  130.             {
  131.                 // code by Greg Beaver
  132.                 if (trim($line[0]) == ';') continue;
  133.                 if($process_sections)
  134.                 {
  135.                     $ini_array[$sec_name][] = trim($line);
  136.                 }
  137.                 // done additions
  138.             }
  139.         }
  140.     }
  141.     return $ini_array;
  142. }
  143.  
  144.  
  145. if (!function_exists('array_key_exists'))
  146. {
  147. /** @ignore */
  148. function array_key_exists($key, $search)
  149. {
  150.     foreach($search as $keys => $nul)
  151.     {
  152.         if ($key == $keys) return true;
  153.     }
  154.     return false;
  155. }
  156. }
  157. if (!function_exists('is_a'))
  158. {
  159. /** @ignore */
  160. function is_a($classname, $classquery)
  161. {
  162.     $father = get_parent_class($classname);
  163.     if (strtolower($father) == strtolower($classquery))
  164.     {
  165.         return true;
  166.     } elseif (!empty($father))
  167.     {
  168.         return is_a($father, $classquery);
  169.     } else
  170.     {
  171.         return false;
  172.     }
  173. }
  174. }
  175.  
  176.  
  177. /** Debugging output */
  178. function debug($s)
  179. {
  180.     echo "$s\n";
  181. }
  182.  
  183. /**
  184.  * Returns a formatted var_dump for debugging purposes.
  185.  * @param string $s string to display
  186.  * @param mixed $v variable to display with var_dump()
  187.  * @param mixed $v... unlimited number of additional variables to display with var_dump()
  188.  */
  189. function fancy_debug($s,$v)
  190. {
  191.     if (isset($GLOBALS['dont_debug']) && $GLOBALS['dont_debug']) return;
  192.     debug($s."\n\n</pre><blockquote><pre>");
  193.     var_dump($v);
  194.     if (func_num_args()>2)
  195.     {
  196.         for($i=2;$i<func_num_args();$i++)
  197.         {
  198.             $a = func_get_arg($i);
  199. //            debug(" ");
  200.             var_dump($a);
  201.         }
  202.     }
  203.     debug("</pre></blockquote><pre>\n\n");
  204. }
  205.  
  206. ?>