addpackage.php:
- Code: Select all
#!/usr/bin/php4
<?php
// print help screen
if("help" == trim($argv[1])){
echo "Usage:","\n";
echo "php4 addpackage.php","\n";
echo "\n";
echo "Notice:","\n";
echo "1 please run this script in class directory.","\n";
echo "2 please move class/database/adodb,class/template/smarty,class/logger/log4php,class/mail/phpmailer to a bak directory first.","\n";
echo "3 run only once.","\n";
die;
}
function addPkgComment($file,$dir){
// read all lines of the $file into array $lines
$lines = file($file);
$head = array_shift($lines);
$pkgDeclare = array("\n",
" /**\n",
" * @package $dir\n",
" */\n",
"\n");
$result = array_merge($head,$pkgDeclare,$lines);
$fp = fopen($file,'w');
while($result){
$line = array_shift($result);
fwrite($fp,$line);
}
fclose($fp);
}
foreach(glob("*") as $dir){
if(is_dir($dir)) {
foreach(glob("$dir/*.php") as $file) {
addPkgComment($file,$dir);
}
}
}
echo "done.","\n","add package comments successfully!","\n";
?>
please run:
addpackage.php help
to get help:-)
Su baochen
