ext_skel_win32.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /* $Id$ */
  3. if (php_sapi_name() != "cli") {
  4. echo "Please run this script using the CLI version of PHP\n";
  5. exit;
  6. }
  7. /*
  8. This script can be used on Win32 systems
  9. 1) Make sure you have CygWin installed
  10. 2) Adjust the $cygwin_path to match your installation
  11. 3) Change the environment cariable PATHEXT to include .PHP
  12. 4) run ext_skel --extname=...
  13. the first time you run this script you will be asked to
  14. associate it with a program. chooses the CLI version of php.
  15. */
  16. $cygwin_path = 'c:\cygwin\bin';
  17. $path = getenv("PATH");
  18. putenv("PATH=$cygwin_path;$path");
  19. array_shift($argv);
  20. system("sh ext_skel " . implode(" ", $argv));
  21. $extname = "";
  22. $skel = "skeleton";
  23. foreach($argv as $arg) {
  24. if (strtolower(substr($arg, 0, 9)) == "--extname") {
  25. $extname = substr($arg, 10);
  26. }
  27. if (strtolower(substr($arg, 0, 6)) == "--skel") {
  28. $skel = substr($arg, 7);
  29. }
  30. }
  31. $fp = fopen("$skel/skeleton.dsp", "rb");
  32. if ($fp) {
  33. $dsp_file = fread($fp, filesize("$skel/skeleton.dsp"));
  34. fclose($fp);
  35. $dsp_file = str_replace("extname", $extname, $dsp_file);
  36. $dsp_file = str_replace("EXTNAME", strtoupper($extname), $dsp_file);
  37. $fp = fopen("$extname/$extname.dsp", "wb");
  38. if ($fp) {
  39. fwrite($fp, $dsp_file);
  40. fclose($fp);
  41. }
  42. }
  43. $fp = fopen("$extname/$extname.php", "rb");
  44. if ($fp) {
  45. $php_file = fread($fp, filesize("$extname/$extname.php"));
  46. fclose($fp);
  47. $php_file = str_replace("dl('", "dl('php_", $php_file);
  48. $fp = fopen("$extname/$extname.php", "wb");
  49. if ($fp) {
  50. fwrite($fp, $php_file);
  51. fclose($fp);
  52. }
  53. }
  54. ?>