File: ext_skel_win32.php

package info (click to toggle)
php5 5.2.0-8%2Betch1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 58,836 kB
  • ctags: 45,575
  • sloc: ansic: 535,107; sh: 17,819; php: 11,336; cpp: 4,289; xml: 3,861; yacc: 2,446; lex: 2,174; makefile: 1,150; tcl: 1,128; awk: 693; perl: 71; sql: 22; pascal: 15
file content (65 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/* $Id: ext_skel_win32.php,v 1.6 2003/10/29 05:42:05 fmk Exp $ */

if (php_sapi_name() != "cli") {
	echo "Please run this script using the CLI version of PHP\n";
	exit;
}
/*
	This script can be used on Win32 systems
	
	1) Make sure you have CygWin installed
	2) Adjust the $cygwin_path to match your installation
	3) Change the environment cariable PATHEXT to include .PHP
	4) run ext_skel --extname=...
		the first time you run this script you will be asked to 
		associate it with a program. chooses the CLI version of php.
*/

$cygwin_path = 'c:\cygwin\bin';

$path = getenv("PATH");
putenv("PATH=$cygwin_path;$path");

array_shift($argv);
system("sh ext_skel " . implode(" ", $argv));

$extname = "";
$skel = "skeleton";
foreach($argv as $arg) {
	if (strtolower(substr($arg, 0, 9)) == "--extname") {
		$extname = substr($arg, 10);
	}
	if (strtolower(substr($arg, 0, 6)) == "--skel") {
		$skel = substr($arg, 7);
	}
}

$fp = fopen("$skel/skeleton.dsp", "rb");
if ($fp) {
	$dsp_file = fread($fp, filesize("$skel/skeleton.dsp"));
	fclose($fp);
	
	$dsp_file = str_replace("extname", $extname, $dsp_file);
	$dsp_file = str_replace("EXTNAME", strtoupper($extname), $dsp_file);
	$fp = fopen("$extname/$extname.dsp", "wb");
	if ($fp) {
		fwrite($fp, $dsp_file);
		fclose($fp);
	}
}

$fp = fopen("$extname/$extname.php", "rb");
if ($fp) {
	$php_file = fread($fp, filesize("$extname/$extname.php"));
	fclose($fp);
	
	$php_file = str_replace("dl('", "dl('php_", $php_file);
	$fp = fopen("$extname/$extname.php", "wb");
	if ($fp) {
		fwrite($fp, $php_file);
		fclose($fp);
	}
}

?>