- move them to tools.
This commit is contained in:
@@ -1,212 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is used to check the language items and actions.
|
||||
*/
|
||||
/* Define an emtpty control class as the base class of every module. */
|
||||
class control {}
|
||||
|
||||
/* set module root path and included the resource of group module. */
|
||||
$moduleRoot = '../../module/';
|
||||
include $moduleRoot . '/group/lang/resource.php';
|
||||
foreach(glob($moduleRoot . '/group/ext/lang/zh-cn/*.php') as $resourceFile)
|
||||
{
|
||||
include $resourceFile;
|
||||
}
|
||||
|
||||
$whiteList[] = 'api-getsessionid';
|
||||
$whiteList[] = 'admin-setflow';
|
||||
$whiteList[] = 'admin-cleardata';
|
||||
$whiteList[] = 'bug-buildtemplates';
|
||||
$whiteList[] = 'bug-sendmail';
|
||||
$whiteList[] = 'board-managechild';
|
||||
$whiteList[] = 'company-create';
|
||||
$whiteList[] = 'company-delete';
|
||||
$whiteList[] = 'file-buildform';
|
||||
$whiteList[] = 'file-printfiles';
|
||||
$whiteList[] = 'file-export2csv';
|
||||
$whiteList[] = 'file-export2xml';
|
||||
$whiteList[] = 'file-export2html';
|
||||
$whiteList[] = 'file-export2excel';
|
||||
$whiteList[] = 'file-export2word';
|
||||
$whiteList[] = 'file-senddownheader';
|
||||
$whiteList[] = 'help-field';
|
||||
$whiteList[] = 'index-testext';
|
||||
$whiteList[] = 'productplan-commonaction';
|
||||
$whiteList[] = 'project-managechilds';
|
||||
$whiteList[] = 'project-tips';
|
||||
$whiteList[] = 'project-commonaction';
|
||||
$whiteList[] = 'project-sendmail';
|
||||
$whiteList[] = 'release-commonaction';
|
||||
$whiteList[] = 'task-commonaction';
|
||||
$whiteList[] = 'task-sendmail';
|
||||
$whiteList[] = 'testtask-sendmail';
|
||||
$whiteList[] = 'user-login';
|
||||
$whiteList[] = 'user-deny';
|
||||
$whiteList[] = 'user-logout';
|
||||
$whiteList[] = 'user-setreferer';
|
||||
$whiteList[] = 'svn-run';
|
||||
$whiteList[] = 'admin-ignore';
|
||||
$whiteList[] = 'admin-register';
|
||||
$whiteList[] = 'admin-win2unix';
|
||||
$whiteList[] = 'admin-bind';
|
||||
$whiteList[] = 'story-commonaction';
|
||||
$whiteList[] = 'story-sendmail';
|
||||
$whiteList[] = 'webapp-ajaxaddview';
|
||||
$whiteList[] = 'report-remind';
|
||||
|
||||
/* checking actions of every module. */
|
||||
echo '-------------action checking-----------------' . "\n";
|
||||
foreach(glob($moduleRoot . '*') as $modulePath)
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
if(strpos('install|upgrade|convert|common|misc|editor', $moduleName) !== false) continue;
|
||||
$controlFile = $modulePath . '/control.php';
|
||||
if(file_exists($controlFile))
|
||||
{
|
||||
include $controlFile;
|
||||
if(class_exists($moduleName))
|
||||
{
|
||||
$class = new ReflectionClass($moduleName);
|
||||
$methods = $class->getMethods();
|
||||
foreach($methods as $method)
|
||||
{
|
||||
$methodRef = new ReflectionMethod($method->class, $method->name);
|
||||
if($methodRef->isPublic() and strpos($method->name, '__') === false)
|
||||
{
|
||||
$methodName = $method->name;
|
||||
if(in_array($moduleName . '-' . strtolower($method->name), $whiteList)) continue;
|
||||
if(strpos($methodName, 'ajax') !== false) continue;
|
||||
|
||||
$exits = false;
|
||||
foreach($lang->resource->$moduleName as $key => $label)
|
||||
{
|
||||
if(strtolower($methodName) == strtolower($key)) $exits = true;
|
||||
}
|
||||
if(!$exits) echo $moduleName . "\t" . $methodName . " not in the list. \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Checking extension files. */
|
||||
$extControlFiles = glob($modulePath . '/ext/control/*.php');
|
||||
if($extControlFiles)
|
||||
{
|
||||
foreach($extControlFiles as $extControlFile)
|
||||
{
|
||||
$methodFile = substr($extControlFile, strrpos($extControlFile, '/') + 1);
|
||||
$methodName = substr($methodFile, 0, strpos($methodFile, '.'));
|
||||
if(in_array($moduleName . '-' . strtolower($methodName), $whiteList)) continue;
|
||||
if(strpos($methodName, 'ajax') !== false) continue;
|
||||
|
||||
$exits = false;
|
||||
foreach($lang->resource->$moduleName as $key => $label)
|
||||
{
|
||||
if(strtolower($methodName) == strtolower($key)) $exits = true;
|
||||
}
|
||||
if(!$exits) echo $moduleName . "\t" . $methodName . " not in the list. \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* checking actions of every module. */
|
||||
echo '-------------lang checking-----------------' . "\n";
|
||||
include '../../module/common/lang/zh-cn.php';
|
||||
include '../../config/config.php';
|
||||
foreach(glob($moduleRoot . '*') as $modulePath)
|
||||
{
|
||||
unset($lang);
|
||||
$moduleName = basename($modulePath);
|
||||
$mainLangFile = $modulePath . '/lang/zh-cn.php';
|
||||
if(!file_exists($mainLangFile)) continue;
|
||||
$mainLines = file($mainLangFile);
|
||||
|
||||
foreach($config->langs as $langKey => $langName)
|
||||
{
|
||||
if($langKey == 'zh-cn' or $langKey == 'zh-tw') continue;
|
||||
$langFile = $modulePath . '/lang/' . $langKey . '.php';
|
||||
if(!file_exists($langFile)) continue;
|
||||
$lines = file($langFile);
|
||||
foreach($mainLines as $lineNO => $line)
|
||||
{
|
||||
if(strpos($line, '$lang') === false)
|
||||
{
|
||||
//if($line != $lines[$lineNO]) echo $moduleName . ' ' . $langKey . ' ' . $lineNO . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
list($mainKey, $mainValue) = explode('=', $line);
|
||||
list($key, $value) = explode('=', $lines[$lineNO]);
|
||||
if(trim($mainKey) != trim($key))
|
||||
{
|
||||
$key = trim($key);
|
||||
$lineNO = $lineNO + 1;
|
||||
echo "module $moduleName need checking, command is:";
|
||||
echo " vim -O +$lineNO ../../module/$moduleName/lang/zh-cn.php +$lineNO ../../module/$moduleName/lang/en.php \n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(glob($modulePath . '/ext/lang/zh-cn/*.php') as $extMainLangFile)
|
||||
{
|
||||
$extMainLines = file($extMainLangFile);
|
||||
$extLangFile = basename($extMainLangFile);
|
||||
$extEnFile = $modulePath . '/ext/lang/en/' . $extLangFile;
|
||||
$extLines = file($extEnFile);
|
||||
foreach($extMainLines as $lineNO => $line)
|
||||
{
|
||||
if(strpos($line, '$lang') === false)
|
||||
{
|
||||
//if($line != $lines[$lineNO]) echo $moduleName . ' ' . $langKey . ' ' . $lineNO . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
list($mainKey, $mainValue) = explode('=', $line);
|
||||
list($key, $value) = explode('=', $extLines[$lineNO]);
|
||||
if(trim($mainKey) != trim($key))
|
||||
{
|
||||
$key = trim($key);
|
||||
$lineNO = $lineNO + 1;
|
||||
echo "module $moduleName need checking, command is:";
|
||||
echo " vim -O +$lineNO ../../module/$moduleName/ext/lang/zh-cn/$extLangFile +$lineNO ../../module/$moduleName/ext/lang/en/$extLangFile \n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '-------------php5.4 synatax checking-----------------' . "\n";
|
||||
class app {function loadLang() {}}
|
||||
$app = new app;
|
||||
$lang = new stdclass();
|
||||
|
||||
error_reporting(E_WARNING | E_STRICT );
|
||||
foreach(glob($moduleRoot . '*') as $modulePath)
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
$cnLangFile = $modulePath . '/lang/zh-cn.php';
|
||||
$enLangFile = $modulePath . '/lang/en.php';
|
||||
$configFile = $modulePath . '/config.php';
|
||||
|
||||
if(!isset($lang->$moduleName)) $lang->$moduleName = new stdclass();
|
||||
if(file_exists($cnLangFile)) include $cnLangFile;
|
||||
if(file_exists($enLangFile)) include $enLangFile;
|
||||
if(file_exists($configFile)) include $configFile;
|
||||
}
|
||||
|
||||
echo '-------------demo data checking. -----------------' . "\n";
|
||||
$demoSQL = file("../../db/demo.sql");
|
||||
foreach($demoSQL as $line => $sql)
|
||||
{
|
||||
if(strpos($sql, 'INSERT') === false) continue;
|
||||
|
||||
if(strpos($sql, $config->db->prefix . 'config') !== false or
|
||||
strpos($sql, $config->db->prefix . 'company') !== false or
|
||||
strpos($sql, $config->db->prefix . 'group') !== false)
|
||||
{
|
||||
die('line ' . ($line + 1) . " has error\n");
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
$langType = 'zh-tw';
|
||||
$langDesc = 'zh-tw';
|
||||
if(empty($langType)) die('lang') . "\n";
|
||||
foreach(glob('../../module/*') as $moduleName)
|
||||
{
|
||||
$moduleLangPath = realpath($moduleName) . '/lang/';
|
||||
$defaultLangFile = $moduleLangPath . 'zh-cn.php';
|
||||
$targetLangFile = $moduleLangPath . $langType . '.php';
|
||||
if(!file_exists($defaultLangFile)) continue;
|
||||
|
||||
system("cconv -f utf-8 -t UTF8-TW $defaultLangFile > $targetLangFile");
|
||||
$defaultLang = file_get_contents($targetLangFile);
|
||||
$targetLang = str_replace('zh-cn', $langDesc, $defaultLang);
|
||||
file_put_contents($targetLangFile, $targetLang);
|
||||
}
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
$langType = $argv[1];
|
||||
$langDesc = $argv[2];
|
||||
if(empty($langType)) die('lang') . "\n";
|
||||
foreach(glob('../../module/*') as $moduleName)
|
||||
{
|
||||
$moduleLangPath = realpath($moduleName) . '/lang/';
|
||||
$defaultLangFile = $moduleLangPath . 'zh-cn.php';
|
||||
$targetLangFile = $moduleLangPath . $langType . '.php';
|
||||
if(!file_exists($defaultLangFile)) continue;
|
||||
|
||||
$defaultLang = file_get_contents($defaultLangFile);
|
||||
$targetLang = str_replace('zh-cn', $langDesc, $defaultLang);
|
||||
file_put_contents($targetLangFile, $targetLang);
|
||||
}
|
||||
?>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
class control {}
|
||||
$moduleRoot = rtrim($argv[1], '/') . '/';
|
||||
|
||||
foreach(glob($moduleRoot . '*') as $modulePath)
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
$controlFile = $modulePath . '/control.php';
|
||||
if(file_exists($controlFile))
|
||||
{
|
||||
include $controlFile;
|
||||
$lines = explode("\n", file_get_contents($controlFile));
|
||||
if(class_exists($moduleName))
|
||||
{
|
||||
$class = new ReflectionClass($moduleName);
|
||||
$methods = $class->getMethods();
|
||||
foreach($methods as $method)
|
||||
{
|
||||
$methodRef = new ReflectionMethod($method->class, $method->name);
|
||||
if($methodRef->isPublic() and strpos($method->name, '__') === false)
|
||||
{
|
||||
echo "\$lang['action']['$moduleName']['$method->name'] = '$method->name';\n";
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
$langType = empty($argv[1]) ? 'zh-cn' : $argv[1];
|
||||
$modules = glob('../../module/*');
|
||||
$maxLength = 0;
|
||||
foreach($modules as $modulePath)
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
if(strlen($moduleName) > $maxLength) $maxLength = strlen($moduleName);
|
||||
}
|
||||
|
||||
foreach($modules as $modulePath)
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
if($moduleName == 'help' or $moduleName == 'editor') continue;
|
||||
$langFile = $modulePath . "/lang/$langType.php";
|
||||
if(!file_exists($langFile)) continue;
|
||||
include $langFile;
|
||||
|
||||
$moduleTitle = '';
|
||||
if(isset($lang->$moduleName->common))
|
||||
{
|
||||
$moduleTitle = $lang->$moduleName->common;
|
||||
}
|
||||
|
||||
echo "\$lang->editor->modules['$moduleName'] " . str_pad('', $maxLength - strlen($moduleName)) . "= '$moduleTitle';\n";
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of common module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2013 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chen congzhi <congzhi@cnezsoft.com>
|
||||
* @package common
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
include '../../config/config.php';
|
||||
|
||||
$modules = array();
|
||||
$moduleRoot = realpath('../../module/') . '/';
|
||||
|
||||
if(is_dir($moduleRoot))
|
||||
{
|
||||
if($dh = opendir($moduleRoot))
|
||||
{
|
||||
while($module = readdir($dh))
|
||||
{
|
||||
if(strpos(basename($module), '.') === false) $modules[] = $module;
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
die("The module you input does not exist. \n");
|
||||
}
|
||||
|
||||
foreach($modules as $module)
|
||||
{
|
||||
/* 设定各个目录。*/
|
||||
$extRoot = $moduleRoot . DIRECTORY_SEPARATOR. $module . DIRECTORY_SEPARATOR . 'ext';
|
||||
$extControl = $extRoot . DIRECTORY_SEPARATOR . 'control';
|
||||
$extModel = $extRoot . DIRECTORY_SEPARATOR . 'model';
|
||||
$extView = $extRoot . DIRECTORY_SEPARATOR . 'view';
|
||||
$extCSS = $extRoot . DIRECTORY_SEPARATOR . 'css';
|
||||
$extJS = $extRoot . DIRECTORY_SEPARATOR . 'js';
|
||||
$extConfig = $extRoot . DIRECTORY_SEPARATOR . 'config';
|
||||
$extLang = $extRoot . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
|
||||
|
||||
/* 建立各个扩展目录 */
|
||||
if(!file_exists($extRoot)) mkdir($extRoot, 0777);
|
||||
if(!file_exists($extControl)) mkdir($extControl, 0777);
|
||||
if(!file_exists($extModel)) mkdir($extModel, 0777);
|
||||
if(!file_exists($extView)) mkdir($extView, 0777);
|
||||
if(!file_exists($extCSS)) mkdir($extCSS, 0777);
|
||||
if(!file_exists($extJS)) mkdir($extJS, 0777);
|
||||
if(!file_exists($extConfig)) mkdir($extConfig, 0777);
|
||||
if(!file_exists($extLang)) mkdir($extLang, 0777);
|
||||
|
||||
/* Touch .gitkeep file. */
|
||||
touch($extControl . '/.gitkeep');
|
||||
touch($extModel . '/.gitkeep');
|
||||
touch($extView . '/.gitkeep');
|
||||
touch($extCSS . '/.gitkeep');
|
||||
touch($extJS . '/.gitkeep');
|
||||
touch($extConfig . '/.gitkeep');
|
||||
|
||||
/* 创建语言目录。*/
|
||||
$langs = array_keys($config->langs);
|
||||
foreach($langs as $lang)
|
||||
{
|
||||
$langPath = $extLang . $lang;
|
||||
if(!file_exists($langPath)) mkdir($langPath, 0777);
|
||||
touch($langPath . '/.gitkeep');
|
||||
}
|
||||
|
||||
echo "init $module ... \n";
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is used to compress css and js files.
|
||||
*/
|
||||
|
||||
$baseDir = dirname(dirname(dirname(__FILE__)));
|
||||
|
||||
//--------------------------------- PROCESS JS FILES ------------------------------ //
|
||||
|
||||
/* Set jsRoot and jqueryRoot. */
|
||||
$jsRoot = $baseDir . '/www/js/';
|
||||
$jqueryRoot = $jsRoot . 'jquery/';
|
||||
|
||||
/* Set js files to combined. */
|
||||
$jsFiles[] = $jqueryRoot . 'lib.js';
|
||||
$jsFiles[] = $jsRoot . 'my.full.js';
|
||||
$jsFiles[] = $jqueryRoot . 'colorbox/min.js';
|
||||
$jsFiles[] = $jqueryRoot . 'chosen/chosen.min.js';
|
||||
$jsFiles[] = $jqueryRoot . 'treeview/min.js';
|
||||
$jsFiles[] = $jqueryRoot . 'datepicker/date.js';
|
||||
$jsFiles[] = $jqueryRoot . 'datepicker/min.js';
|
||||
$jsFiles[] = $jqueryRoot . 'alert/min.js';
|
||||
$jsFiles[] = $jqueryRoot . 'colorize/min.js';
|
||||
|
||||
/* Combine these js files. */
|
||||
$allJSFile = $jsRoot . 'all.js';
|
||||
$jsCode = '';
|
||||
foreach($jsFiles as $jsFile) $jsCode .= "\n". file_get_contents($jsFile);
|
||||
file_put_contents($allJSFile, $jsCode);
|
||||
|
||||
/* Compress it. */
|
||||
`java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type js $allJSFile -o $allJSFile`;
|
||||
|
||||
/* Set mobile js files to combined. */
|
||||
$mobileJsFiles[] = $jqueryRoot . 'mobile/jquery-1.10.1.min.js';
|
||||
$mobileJsFiles[] = $jsRoot . 'm.my.full.js';
|
||||
$mobileJsFiles[] = $jqueryRoot . 'mobile/jquery.mobile.min.js';
|
||||
$mobileJsFiles[] = $jqueryRoot . 'jquery.pjax.js';
|
||||
|
||||
/* Combine these js files. */
|
||||
$allJSFile = $jsRoot . 'm.all.js';
|
||||
$jsCode = '';
|
||||
foreach($mobileJsFiles as $jsFile) $jsCode .= "\n". file_get_contents($jsFile);
|
||||
file_put_contents($allJSFile, $jsCode);
|
||||
|
||||
/* Compress it. */
|
||||
`java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type js $allJSFile -o $allJSFile`;
|
||||
|
||||
//-------------------------------- PROCESS CSS FILES ------------------------------ //
|
||||
|
||||
/* Define the themeRoot. */
|
||||
$themeRoot = $baseDir . '/www/theme/';
|
||||
|
||||
/* Iinclude config and lang file to get langs and themes. */
|
||||
include $baseDir . '/config/config.php';
|
||||
include $baseDir . '/module/common/lang/zh-cn.php';
|
||||
$langs = array_keys($config->langs);
|
||||
$themes = array_keys($lang->themes);
|
||||
|
||||
/* Create css files for every them and every lang. */
|
||||
foreach($langs as $lang)
|
||||
{
|
||||
foreach($themes as $theme)
|
||||
{
|
||||
/* Common css files. */
|
||||
$cssCode = file_get_contents($themeRoot . 'default/yui.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/style.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/colorbox.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/chosen.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/treeview.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/datepicker.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/alert.css');
|
||||
|
||||
/* Css file for current lang and current them. */
|
||||
$cssCode .= file_get_contents($themeRoot . "lang/$lang.css");
|
||||
if($theme != 'default')
|
||||
{
|
||||
$themCode = file_get_contents($themeRoot . $theme . '/style.css');
|
||||
$cssCode .= str_replace('./images', "../$theme/images", $themCode);
|
||||
}
|
||||
|
||||
/* Combine them. */
|
||||
$cssFile = $themeRoot . "default/$lang.$theme.css";
|
||||
file_put_contents($cssFile, $cssCode);
|
||||
|
||||
/* Compress it. */
|
||||
`java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type css $cssFile -o $cssFile`;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create css files for every them and every lang. */
|
||||
foreach($langs as $lang)
|
||||
{
|
||||
/* Common css files. */
|
||||
$cssCode = file_get_contents($themeRoot . 'default/jquery.mobile.css');
|
||||
$cssCode .= file_get_contents($themeRoot . 'default/m.style.css');
|
||||
|
||||
/* Css file for current lang and current them. */
|
||||
$cssCode .= file_get_contents($themeRoot . "lang/$lang.css");
|
||||
|
||||
/* Combine them. */
|
||||
$cssFile = $themeRoot . "default/m.$lang.default.css";
|
||||
file_put_contents($cssFile, $cssCode);
|
||||
|
||||
/* Compress it. */
|
||||
`java -jar ~/bin/yuicompressor/build/yuicompressor.jar --type css $cssFile -o $cssFile`;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
include '../../config/config.php';
|
||||
connectDB();
|
||||
|
||||
$databases[] = 'zentao_03';
|
||||
$databases[] = 'zentao_04';
|
||||
$databases[] = 'zentao_05';
|
||||
$databases[] = 'zentao_06';
|
||||
$databases[] = 'zentao_10';
|
||||
$databases[] = 'zentao_101';
|
||||
$databases[] = 'zentao_11';
|
||||
$databases[] = 'zentao_12';
|
||||
$databases[] = 'zentao_13';
|
||||
$databases[] = 'zentao_14';
|
||||
$databases[] = 'zentao_15';
|
||||
|
||||
if(!isset($argv[1])) die(__FILE__ . ' restore' . "\n");
|
||||
|
||||
$cmd = $argv[1];
|
||||
if($cmd == 'backup') backupDB();
|
||||
if($cmd == 'restore') restore();
|
||||
|
||||
/* Backup new installed database. */
|
||||
function backupDB()
|
||||
{
|
||||
global $databases;
|
||||
foreach($databases as $database)
|
||||
{
|
||||
$backupDatabase = "back_$database";
|
||||
mysql_query("DROP DATABASE $backupDatabase");
|
||||
mysql_query("CREATE DATABASE $backupDatabase");
|
||||
$cmd = "mysqldump -u root $database > $database.sql;\n";
|
||||
$cmd .= "mysql -uroot $backupDatabase < $database.sql;\n";
|
||||
$cmd .= "rm -fr $database.sql";
|
||||
system($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore stored backup databases. */
|
||||
function restore()
|
||||
{
|
||||
global $databases;
|
||||
foreach($databases as $database)
|
||||
{
|
||||
$backupDatabase = "back_$database";
|
||||
mysql_query("DROP DATABASE $database");
|
||||
mysql_query("CREATE DATABASE $database");
|
||||
$cmd = "mysqldump -u root $backupDatabase > $database.sql;\n";
|
||||
$cmd .= "mysql -uroot $database < $database.sql;\n";
|
||||
$cmd .= "rm -fr $database.sql";
|
||||
system($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Connect to database. */
|
||||
function connectDB()
|
||||
{
|
||||
global $config;
|
||||
mysql_connect($config->db->host, $config->db->user, $config->db->password);
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* This file is used to sync extension files to the target pms directory.
|
||||
*
|
||||
* @author chunsheng wang chunsheng@cnezsoft.com
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
//sudo pecl install channel://pecl.php.net/inotify-0.1.5
|
||||
|
||||
//extension=inotify.so" to php.ini
|
||||
|
||||
/* Get params from argvs. */
|
||||
if(!isset($argv[1])) die("php syncext.php from target sleep\n");
|
||||
$from = $argv[1];
|
||||
$target = isset($argv[2]) ? $argv[2] : '/home/z/zentaopms';
|
||||
$sleep = isset($argv[3]) ? $argv[3] : 5;
|
||||
|
||||
/* sync files. */
|
||||
while(true)
|
||||
{
|
||||
syncFiles(getFiles($from), $from, $target);
|
||||
sleep($sleep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get files under a directory recursive.
|
||||
*
|
||||
* @param string $dir
|
||||
* @param array $exceptions
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
function getFiles($dir, $exceptions = array())
|
||||
{
|
||||
static $files = array();
|
||||
|
||||
if(!is_dir($dir)) return $files;
|
||||
|
||||
$dir = realpath($dir) . '/';
|
||||
$entries = scandir($dir);
|
||||
|
||||
foreach($entries as $entry)
|
||||
{
|
||||
if($entry == '.' or $entry == '..' or $entry == '.svn' or $entry == 'db') continue;
|
||||
if(in_array($entry, $exceptions)) continue;
|
||||
|
||||
$fullEntry = $dir . $entry;
|
||||
if(is_file($fullEntry))
|
||||
{
|
||||
$files[] = $dir . $entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nextDir = $dir . $entry;
|
||||
getFiles($nextDir);
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync extension files to target.
|
||||
*
|
||||
* @param array $files
|
||||
* @param string $from
|
||||
* @param string $target
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function syncFiles($files, $from, $target)
|
||||
{
|
||||
$from = realpath($from);
|
||||
$target = realpath($target);
|
||||
static $copied = array();
|
||||
|
||||
foreach($files as $file)
|
||||
{
|
||||
$relativePath = str_replace($from, '', $file);
|
||||
$targetFile = $target . $relativePath;
|
||||
$targetPath = dirname($targetFile);
|
||||
|
||||
/* If file not exists, remove the target. */
|
||||
if(!is_file($file))
|
||||
{
|
||||
@unlink($targetFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!is_dir($targetPath)) mkdir($targetPath, 0755, true);
|
||||
$ctime = filectime($file);
|
||||
if(!isset($copied[$file]) or $copied[$file] != $ctime)
|
||||
{
|
||||
copy($file, $targetFile);
|
||||
$copied[$file] = $ctime;
|
||||
echo "$file copyed\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/* This file is used to crete a tag of subverion. */
|
||||
|
||||
$config->zentaophp->svnRoot = 'https://zentaophp.googlecode.com/svn/';
|
||||
$config->zentaophp->svnTrunk = 'trunk/';
|
||||
$config->zentaophp->svnTags = 'tags/';
|
||||
|
||||
$config->zentaopms->svnRoot = 'https://ZenTaoPMS.googlecode.com/svn/';
|
||||
$config->zentaopms->svnTrunk = 'trunk/';
|
||||
$config->zentaopms->svnTags = 'tags/';
|
||||
|
||||
if(count($argv) != 4) die(__FILE__ . " repo version releasetype:beta|alpa|stable\n");
|
||||
|
||||
$repo = $argv[1];
|
||||
$version = $argv[2];
|
||||
$release = $argv[3];
|
||||
|
||||
$sourceURL = $config->$repo->svnRoot . $config->$repo->svnTrunk;
|
||||
$targetURL = $config->$repo->svnRoot . $config->$repo->svnTags . $repo . '_' . $version . '_' . $release . '_' . date('Ymd');
|
||||
|
||||
$svnCMD = "svn rm $targetURL -m 'remove it'; svn cp $sourceURL $targetURL -m 'tag $version of $repo'";
|
||||
system($svnCMD);
|
||||
Reference in New Issue
Block a user