protected function _initialize() { if (!self::$init) { self::$init = true; //标记已经进入初始化,否则new AdminAction将陷入死递归 define('TH_VERSION', '1.1.3'); //所有action初始化代码放在这个大括号内部,否则下面的AdminAction实例化时又将重复执行一次初始化代码,注意不同功能代码可能需要一定的顺序 ///////自定义扩展区/////////////// ///////cookie初始化区域/////////// if (C('COOKIE_PATH') == '/') { C('COOKIE_PATH', __ROOT__); } if (C('COOKIE_PREFIX') == '') { $prefix = trim(__ROOT__ . '_', '/\\'); C('COOKIE_PREFIX', $prefix); } $listapp = new AdminAction(); $list = $listapp->listAPP(); if ($list == false) { $this->assign('noapp', "<span>还没有添加任何项目,或者applist.xml文件读取异常</span>"); cookie('config_path', ''); cookie('base_dir', ''); cookie('app_name', '暂无'); cookie('app_index', '暂无'); cookie('app_url', ''); } else { $this->assign('listapp', $list); if (cookie('switch') != 'on' && (!cookie('config_path') || !cookie('base_dir'))) { $default = $list[0]; //cookie设置 cookie('config_path', CheckConfig::dirModifier($default['path']) . 'Conf/config.php'); cookie('base_dir', CheckConfig::dirModifier($default['path'])); cookie('app_name', $default['name']); cookie('app_index', $default['index']); cookie('app_url', $default['url']); } } cookie('think_path', CheckConfig::dirModifier(THINK_PATH)); cookie('tp_helper', CheckConfig::dirModifier(APP_PATH)); cookie('version', THINK_VERSION); ///////include模板变量分配区域///////// $this->include_assign(); } }
public function index() { if (isset($_GET['config_path'])) { cookie('config_path', realpath($_GET['config_path'])); //为前台ajax更新config_path } $dir = cookie('base_dir'); if (is_dir($dir)) { $configs = (include $dir . 'Conf/config.php'); chdir($dir); $config_list = glob('Conf' . DIRECTORY_SEPARATOR . '{*,*' . DIRECTORY_SEPARATOR . '*}.php', GLOB_BRACE); if (isset($configs['APP_GROUP_MODE'], $configs['APP_GROUP_PATH']) && $configs['APP_GROUP_MODE'] == '1' && $configs['APP_GROUP_PATH']) { $config_list2 = glob(CheckConfig::dirModifier($configs['APP_GROUP_PATH']) . '*/Conf/{*,*/*}.php', GLOB_BRACE); $config_list = array_merge($config_list, $config_list2); } chdir(APP_PATH); $config_list = preg_grep('/alias.php$|tags.php$/iU', $config_list, PREG_GREP_INVERT); if (count($config_list) > 0) { $this->assign('config_list', $config_list); $this->assign('dir', $dir); } } $this->display(); }
protected static function dirCopy($source, $dest) { $rdi = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::CURRENT_AS_SELF); $rii = new RecursiveIteratorIterator($rdi, RecursiveIteratorIterator::SELF_FIRST); $dest = CheckConfig::dirModifier($dest); mkdir($dest); foreach ($rii as $k => $v) { if (is_file($k)) { copy($k, $dest . $v->getSubPathname()); } elseif (is_dir($k)) { mkdir($dest . $v->getSubPathname()); } } }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once "lib/autoload.php"; $status = -1; $elapsed = microtime(true); try { $config = dirname(__FILE__) . "/logmon.conf.php"; $requiredConfigs = array($config); CheckConfig::configs($requiredConfigs); require_once $config; $requiredExtensions = array("mbstring", "pcre", "PDO"); CheckConfig::extensions($requiredExtensions); mb_internal_encoding("UTF-8"); Options::setDebug(DEBUG || array_search("--debug", $argv)); Options::setPretend(array_search("--pretend", $argv)); Options::setVerbose(Options::debug() || Options::pretend() || array_search("--verbose", $argv)); Log::open(__FILE__, true, Options::verbose(), Options::debug()); Log::notice(sprintf("Running '%s'...", implode(" ", $argv))); $monitor = Monitor::create(dirname(__FILE__) . "/monitor"); if ($monitor !== false) { $sources = $monitor->getEnabledSources(); $dbh = new DBH(DBDSN, DBUSER, DBPASS); $processor = new Processor($dbh); foreach ($sources as $source) { $processor->process($monitor, $source); } $processor->discard(EVENT_DISCARD_THRESHOLD);
public function switchAPP() { if (isset($_GET['name'])) { $app = $this->listAPP($_GET['name']); if (is_object($app)) { cookie('config_path', CheckConfig::dirModifier((string) $app['path']) . 'Conf/config.php'); cookie('base_dir', CheckConfig::dirModifier((string) $app['path'])); cookie('app_name', (string) $app['name']); cookie('app_index', strtr((string) $app['index'], '\\', '/')); cookie('app_url', (string) $app['url']); cookie('switch', 'on', 0); cookie('think_path', CheckConfig::dirModifier(THINK_PATH)); cookie('tp_helper', CheckConfig::dirModifier(APP_PATH)); cookie('version', THINK_VERSION); } } $this->success('切换项目成功,即将返回首页', U('Index/index')); }