PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/php/pciconf

https://bitbucket.org/haggen/ibsolution-log-viewer
#! | 564 lines | 491 code | 73 blank | 0 comment | 0 complexity | 1be143a1a49efe73d3d659efd0566e03 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, GPL-2.0, LGPL-3.0, GPL-3.0, AGPL-3.0, AGPL-1.0, LGPL-2.0, Apache-2.0, MPL-2.0, BSD-3-Clause
  1. #!\xampp\php\.\php.exe
  2. <?php
  3. /**
  4. * The Predefined Classes/Constants array script generator.
  5. *
  6. * PHP version 5
  7. *
  8. * @category PHP
  9. * @package PHP_CompatInfo
  10. * @author Laurent Laville <pear@laurent-laville.org>
  11. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  12. * @version CVS: $Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  13. * @link http://pear.php.net/package/PHP_CompatInfo
  14. * @since File available since Release 1.9.0b1
  15. */
  16. if (version_compare(PHP_VERSION, '5.0.0') < 0) {
  17. print basename(__FILE__) . " require PHP5 or better to run. "
  18. . "Your current PHP version is " . PHP_VERSION
  19. . PHP_EOL;
  20. exit(1);
  21. }
  22. require_once 'Console/Getargs.php';
  23. $ds = DIRECTORY_SEPARATOR;
  24. $opts = array('enable' =>
  25. array('short' => 'e',
  26. 'desc' => 'A comma separated list of extensions '
  27. . 'you want only',
  28. 'default' => '',
  29. 'min' => 0 , 'max' => 1),
  30. 'disable' =>
  31. array('short' => 'd',
  32. 'desc' => 'A comma separated list of extensions '
  33. . 'you want to disable',
  34. 'default' => '',
  35. 'min' => 0 , 'max' => 1),
  36. 'sapi' =>
  37. array('short' => 's',
  38. 'desc' => 'A comma separated list of SAPI '
  39. . 'you want only',
  40. 'default' => 'apache2handler,cgi,cli',
  41. 'min' => 0 , 'max' => 1),
  42. 'exceptions' =>
  43. array('short' => 'x',
  44. 'desc' => 'File that provides exceptions results',
  45. 'default' => 'exceptions.conf.php',
  46. 'min' => 0 , 'max' => 1),
  47. 'output' =>
  48. array('short' => 'o',
  49. 'desc' => 'Target directory where to write results',
  50. 'default' => '@'.'php_dir@/PHP/CompatInfo',
  51. 'min' => 0 , 'max' => 1),
  52. 'verbose' =>
  53. array('short' => 'v',
  54. 'desc' => 'Set the verbose level',
  55. 'default' => 1,
  56. 'min' => 0 , 'max' => 1),
  57. 'version' =>
  58. array('short' => 'V',
  59. 'desc' => 'Print version information',
  60. 'max' => 0),
  61. 'help' =>
  62. array('short' => 'h',
  63. 'desc' => 'Show this help',
  64. 'max' => 0)
  65. );
  66. $args = Console_Getargs::factory($opts);
  67. if (PEAR::isError($args)) {
  68. $header = "PHP_CompatInfo Extensions Support List build system \n".
  69. 'Usage: '.basename($_SERVER['SCRIPT_NAME'])." [options]\n\n";
  70. if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER) {
  71. echo Console_Getargs::getHelp($opts, $header, $args->getMessage())."\n";
  72. } else if ($args->getCode() === CONSOLE_GETARGS_HELP) {
  73. echo Console_Getargs::getHelp($opts, $header)."\n";
  74. }
  75. exit(1);
  76. }
  77. // version
  78. if ($args->isDefined('V')) {
  79. echo 'PHP_CompatInfo Extensions Support List build system version 1.9.0';
  80. exit(0);
  81. }
  82. // verbose
  83. if ($args->isDefined('v')) {
  84. $verbose = $args->getValue('v');
  85. } else {
  86. $verbose = 1;
  87. }
  88. // output
  89. if ($args->isDefined('o')) {
  90. $o = $args->getValue('o');
  91. if (strpos($o, '@'.'php_dir@')) {
  92. $o = str_replace('@'.'php_dir@', '\xampp\php\pear', $o);
  93. }
  94. if (is_dir($o) && (is_writable($o))) {
  95. /* Directory where to write
  96. all "*_const_array.php" and "*_class_array.php" files
  97. Must ended with a trailing directory separator */
  98. if (substr($o, -1, 1) !== $ds) {
  99. $o .= $ds;
  100. }
  101. $target_directory = $o;
  102. } else {
  103. echo 'Invalid (or not writable) target directory';
  104. exit(1);
  105. }
  106. } else {
  107. $target_directory = '\xampp\php\pear' . $ds . 'PHP' .$ds . 'CompatInfo' . $ds;
  108. }
  109. // enable
  110. if ($args->isDefined('e')) {
  111. $extensions = explode(',', $args->getValue('e'));
  112. } else {
  113. $extensions = get_loaded_extensions();
  114. }
  115. // disable
  116. if ($args->isDefined('d')) {
  117. $d = explode(',', $args->getValue('d'));
  118. $extensions = array_diff($extensions, $d);
  119. }
  120. // sapi
  121. if ($args->isDefined('s')) {
  122. $sapis = explode(',', $args->getValue('s'));
  123. } else {
  124. $sapis = array('apache2handler', 'cgi', 'cli');
  125. }
  126. // exceptions
  127. if ($args->isDefined('x')) {
  128. $x = $args->getValue('x');
  129. if (file_exists($x)) {
  130. include_once $x;
  131. if (!function_exists('getExceptions')) {
  132. echo 'getExceptions() function does not exists';
  133. exit(1);
  134. }
  135. } else {
  136. echo 'Exceptions file does not exists';
  137. exit(1);
  138. }
  139. } else {
  140. include_once dirname(__FILE__) . $ds . 'scripts' . $ds . 'exceptions.conf.php';
  141. }
  142. $const_glob_list = array();
  143. $class_glob_list = array();
  144. $func_glob_list = array();
  145. // PHP Core constants
  146. $extName = 'internal';
  147. $extConstants = get_defined_constants(true);
  148. $const_glob_list[] = $extName;
  149. // default version to apply to each internal constant
  150. $ver = getExceptions($extName, 'version');
  151. if ($ver === false) {
  152. $ver = '4.0.0';
  153. }
  154. $constants = array();
  155. foreach ($extConstants[$extName] as $cst => $val) {
  156. $constants[$cst]['init'] = $ver;
  157. $constants[$cst]['name'] = $cst;
  158. }
  159. $exceptions = getExceptions($extName, 'constant');
  160. if ($exceptions === false) {
  161. // no constant exceptions for this extension
  162. } else {
  163. // apply exceptions to give final constant results
  164. $constants = array_merge($constants, $exceptions);
  165. }
  166. ksort($constants);
  167. file_put_contents($target_directory . $extName . '_const_array.php',
  168. "<?php
  169. /**
  170. * Internal Constant dictionary for PHP_CompatInfo 1.9.0a1 or better
  171. *
  172. * PHP versions 4 and 5
  173. *
  174. * @category PHP
  175. * @package PHP_CompatInfo
  176. * @author Davey Shafik <davey@php.net>
  177. * @author Laurent Laville <pear@laurent-laville.org>
  178. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  179. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  180. * @link http://pear.php.net/package/PHP_CompatInfo
  181. * @since version 1.9.0b2 (2008-12-19)
  182. */
  183. \$GLOBALS['_PHP_COMPATINFO_CONST_" . strtoupper($extName) . "'] = " .
  184. var_export($constants, true) . ";
  185. ?>");
  186. foreach ($extensions as $extension) {
  187. if (!extension_loaded($extension)) {
  188. continue; // skip this extension if not loaded : prevent error
  189. }
  190. $ext = new ReflectionExtension($extension);
  191. // name of the current Extension
  192. $extName = $ext->getName();
  193. // version of the current Extension
  194. $extVers = $ext->getVersion();
  195. if ($verbose > 0) {
  196. print 'Found '. $extName;
  197. if ($extVers) {
  198. print ' version '. $extVers;
  199. }
  200. print PHP_EOL;
  201. }
  202. // default version to apply to each constant and class predefined
  203. $ver = getExceptions($extName, 'version');
  204. if ($ver === false) {
  205. $ver = '4.0.0';
  206. }
  207. // constants described by the Extension interface
  208. $extConstants = $ext->getConstants();
  209. if (count($extConstants) > 0) {
  210. $const_glob_list[] = $extName;
  211. $constants = array();
  212. foreach ($extConstants as $cst => $val) {
  213. $constants[$cst]['init'] = $ver;
  214. $constants[$cst]['name'] = $cst;
  215. }
  216. $exceptions = getExceptions($extName, 'constant');
  217. if ($exceptions === false) {
  218. // no constant exceptions for this extension
  219. } else {
  220. // apply exceptions to give final constant results
  221. $constants = array_merge($constants, $exceptions);
  222. }
  223. ksort($constants);
  224. file_put_contents($target_directory . $extName . '_const_array.php',
  225. "<?php
  226. /**
  227. * $extName extension Constant dictionary for PHP_CompatInfo 1.9.0a1 or better
  228. *
  229. * PHP versions 4 and 5
  230. *
  231. * @category PHP
  232. * @package PHP_CompatInfo
  233. * @author Davey Shafik <davey@php.net>
  234. * @author Laurent Laville <pear@laurent-laville.org>
  235. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  236. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  237. * @link http://pear.php.net/package/PHP_CompatInfo
  238. * @since version 1.9.0a1 (2008-11-23)
  239. */
  240. \$GLOBALS['_PHP_COMPATINFO_CONST_" . strtoupper($extName) . "'] = " .
  241. var_export($constants, true) . ";
  242. ?>");
  243. }
  244. // classes described by the Extension interface
  245. $extClasses = $ext->getClassNames();
  246. if (count($extClasses) > 0) {
  247. $class_glob_list[] = $extName;
  248. $classes = array();
  249. foreach ($extClasses as $i => $cls) {
  250. $classes[$cls]['init'] = $ver;
  251. $classes[$cls]['name'] = $cls;
  252. $classes[$cls]['ext'] = $extName;
  253. $classes[$cls]['pecl'] = false;
  254. }
  255. $exceptions = getExceptions($extName, 'class');
  256. if ($exceptions === false) {
  257. // no class exceptions for this extension
  258. } else {
  259. // apply exceptions to give final class results
  260. $classes = array_merge($classes, $exceptions);
  261. }
  262. ksort($classes);
  263. file_put_contents($target_directory . $extName . '_class_array.php',
  264. "<?php
  265. /**
  266. * $extName extension Class dictionary for PHP_CompatInfo 1.9.0a1 or better
  267. *
  268. * PHP versions 4 and 5
  269. *
  270. * @category PHP
  271. * @package PHP_CompatInfo
  272. * @author Davey Shafik <davey@php.net>
  273. * @author Laurent Laville <pear@laurent-laville.org>
  274. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  275. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  276. * @link http://pear.php.net/package/PHP_CompatInfo
  277. * @since version 1.9.0a1 (2008-11-23)
  278. */
  279. \$GLOBALS['_PHP_COMPATINFO_CLASS_" . strtoupper($extName) . "'] = " .
  280. var_export($classes, true) . ";
  281. ?>");
  282. }
  283. // functions described by the Extension interface
  284. $extFunctions = $ext->getFunctions();
  285. if (count($extFunctions) > 0) {
  286. $func_glob_list[] = $extName;
  287. $functions = array();
  288. foreach ($extFunctions as $oFunction) {
  289. $func = $oFunction->getName();
  290. $functions[$func]['init'] = $ver;
  291. $functions[$func]['name'] = $func;
  292. $functions[$func]['ext'] = $extName;
  293. $functions[$func]['pecl'] = false;
  294. }
  295. $exceptions = getExceptions($extName, 'function');
  296. if ($exceptions === false) {
  297. // no class exceptions for this extension
  298. } else {
  299. // apply exceptions to give final function results
  300. $functions = array_merge($functions, $exceptions);
  301. }
  302. ksort($functions);
  303. file_put_contents($target_directory . $extName . '_func_array.php',
  304. "<?php
  305. /**
  306. * $extName extension Function dictionary for PHP_CompatInfo 1.9.0b2 or better
  307. *
  308. * PHP versions 4 and 5
  309. *
  310. * @category PHP
  311. * @package PHP_CompatInfo
  312. * @author Davey Shafik <davey@php.net>
  313. * @author Laurent Laville <pear@laurent-laville.org>
  314. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  315. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  316. * @link http://pear.php.net/package/PHP_CompatInfo
  317. * @since version 1.9.0b2 (2008-12-19)
  318. */
  319. \$GLOBALS['_PHP_COMPATINFO_FUNC_" . strtoupper($extName) . "'] = " .
  320. var_export($functions, true) . ";
  321. ?>");
  322. }
  323. }
  324. $sapi_glob_list = array();
  325. foreach ($sapis as $sapi) {
  326. $functions = getExceptions($sapi, 'function');
  327. if ($functions === false) {
  328. // no sapi functions
  329. continue;
  330. }
  331. if ($verbose > 0) {
  332. print 'Found SAPI '. $sapi . PHP_EOL;
  333. }
  334. $sapi_glob_list[] = $sapi;
  335. ksort($functions);
  336. file_put_contents($target_directory . $sapi . '_sapi_array.php',
  337. "<?php
  338. /**
  339. * $sapi SAPI Function dictionary for PHP_CompatInfo 1.9.0b2 or better
  340. *
  341. * PHP versions 4 and 5
  342. *
  343. * @category PHP
  344. * @package PHP_CompatInfo
  345. * @author Davey Shafik <davey@php.net>
  346. * @author Laurent Laville <pear@laurent-laville.org>
  347. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  348. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  349. * @link http://pear.php.net/package/PHP_CompatInfo
  350. * @since version 1.9.0b2 (2008-12-19)
  351. */
  352. \$GLOBALS['_PHP_COMPATINFO_SAPI_" . strtoupper($sapi) . "'] = " .
  353. var_export($functions, true) . ";
  354. ?>");
  355. }
  356. $const_glob_list = array_unique($const_glob_list);
  357. natcasesort($const_glob_list);
  358. $requires = '';
  359. $globals = '';
  360. foreach ($const_glob_list as $cstExt) {
  361. $requires .= "require_once 'PHP/CompatInfo/" . $cstExt . "_const_array.php';"
  362. . PHP_EOL;
  363. $globals .= " \$GLOBALS['_PHP_COMPATINFO_CONST_" . strtoupper($cstExt)
  364. . "'], " . PHP_EOL;
  365. }
  366. $globals = rtrim($globals, ", ".PHP_EOL);
  367. $globals .= PHP_EOL;
  368. file_put_contents($target_directory . 'const_array.php',
  369. "<?php
  370. /**
  371. * Constant dictionary for PHP_CompatInfo 1.1.1 or better
  372. *
  373. * PHP versions 4 and 5
  374. *
  375. * @category PHP
  376. * @package PHP_CompatInfo
  377. * @author Davey Shafik <davey@php.net>
  378. * @author Laurent Laville <pear@laurent-laville.org>
  379. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  380. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  381. * @link http://pear.php.net/package/PHP_CompatInfo
  382. * @since version 1.1.1 (2006-07-27)
  383. */
  384. ". $requires .
  385. "
  386. /**
  387. * Predefined Constants
  388. *
  389. * @link http://www.php.net/manual/en/reserved.constants.php
  390. * @global array \$GLOBALS['_PHP_COMPATINFO_CONST']
  391. */
  392. \$GLOBALS['_PHP_COMPATINFO_CONST'] = array_merge(
  393. ". $globals .
  394. " );
  395. ?>");
  396. $class_glob_list = array_unique($class_glob_list);
  397. natcasesort($class_glob_list);
  398. $requires = '';
  399. $globals = '';
  400. foreach ($class_glob_list as $clsExt) {
  401. $requires .= "require_once 'PHP/CompatInfo/" . $clsExt . "_class_array.php';"
  402. . PHP_EOL;
  403. $globals .= " \$GLOBALS['_PHP_COMPATINFO_CLASS_" . strtoupper($clsExt)
  404. . "'], " . PHP_EOL;
  405. }
  406. $globals = rtrim($globals, ", ".PHP_EOL);
  407. $globals .= PHP_EOL;
  408. file_put_contents($target_directory . 'class_array.php',
  409. "<?php
  410. /**
  411. * Class dictionary for PHP_CompatInfo 1.9.0a1 or better
  412. *
  413. * PHP versions 4 and 5
  414. *
  415. * @category PHP
  416. * @package PHP_CompatInfo
  417. * @author Davey Shafik <davey@php.net>
  418. * @author Laurent Laville <pear@laurent-laville.org>
  419. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  420. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  421. * @link http://pear.php.net/package/PHP_CompatInfo
  422. * @since version 1.9.0a1 (2008-11-23)
  423. */
  424. ". $requires .
  425. "
  426. /**
  427. * Predefined Classes
  428. *
  429. * > Standard Defined Classes
  430. * These classes are defined in the standard set of functions included in
  431. * the PHP build.
  432. * - Directory
  433. * - stdClass
  434. * - __PHP_Incomplete_Class
  435. *
  436. * > Predefined classes as of PHP 5
  437. * These additional predefined classes were introduced in PHP 5.0.0
  438. * - Exception
  439. * - php_user_filter
  440. *
  441. * > Miscellaneous extensions
  442. * define other classes which are described in their reference.
  443. *
  444. * @link http://www.php.net/manual/en/function.get-declared-classes.php
  445. * @link http://www.php.net/manual/en/reserved.classes.php
  446. * @global array \$GLOBALS['_PHP_COMPATINFO_CLASS']
  447. */
  448. \$GLOBALS['_PHP_COMPATINFO_CLASS'] = array_merge(
  449. ". $globals .
  450. " );
  451. ?>");
  452. $func_glob_list = array_unique($func_glob_list);
  453. natcasesort($func_glob_list);
  454. $requires = '';
  455. $globals = '';
  456. foreach ($func_glob_list as $funcExt) {
  457. $requires .= "require_once 'PHP/CompatInfo/" . $funcExt . "_func_array.php';"
  458. . PHP_EOL;
  459. $globals .= " \$GLOBALS['_PHP_COMPATINFO_FUNC_" . strtoupper($funcExt)
  460. . "'], " . PHP_EOL;
  461. }
  462. $globals = rtrim($globals, ", ".PHP_EOL);
  463. $globals .= PHP_EOL;
  464. file_put_contents($target_directory . 'func_array.php',
  465. "<?php
  466. /**
  467. * Function dictionary for PHP_CompatInfo 1.9.0a1 or better
  468. *
  469. * PHP versions 4 and 5
  470. *
  471. * @category PHP
  472. * @package PHP_CompatInfo
  473. * @author Davey Shafik <davey@php.net>
  474. * @author Laurent Laville <pear@laurent-laville.org>
  475. * @license http://www.opensource.org/licenses/bsd-license.php BSD
  476. * @version CVS: \$Id: configure.php,v 1.8 2008/12/26 18:50:51 farell Exp $
  477. * @link http://pear.php.net/package/PHP_CompatInfo
  478. * @since version 1.9.0a1 (2008-11-23)
  479. */
  480. ". $requires .
  481. "
  482. /**
  483. * Predefined Functions
  484. *
  485. * @global array \$GLOBALS['_PHP_COMPATINFO_FUNCS']
  486. */
  487. \$GLOBALS['_PHP_COMPATINFO_FUNCS'] = array_merge(
  488. ". $globals .
  489. " );
  490. ?>");
  491. ?>