/** * 应用程序执行 * * * @return null */ public static function run() { $className = application::getControllerName(); $classPath = application::getControllerPath(); $method = application::getControllerMethod(); $arguments = router::arguments(); //加载controller if (file_exists($classPath)) { zotop::load($classPath); } else { zotop::run('system.404', array('filepath' => $classPath)); return false; } if (class_exists($className, false)) { $controller = new $className(); if (method_exists($controller, $method) && $method[0] != '_') { call_user_func_array(array($controller, '__before'), $arguments); call_user_func_array(array($controller, $method), $arguments); call_user_func_array(array($controller, '__after'), $arguments); return true; } //当方法不存在时,默认调用类的_empty()函数,你可以在控制器中重写此方法 return call_user_func_array(array($controller, '__empty'), array($method, $arguments)); } return false; }
public function onDefault() { $site = array(); $site['name'] = zotop::config('zotop.site.name'); $site['totalsize'] = zotop::config('zotop.ftp.size'); $site['totalsize'] = (int) $site['totalsize'] == 0 ? '--' : format::byte($site['totalsize']); $database = array(); $database['size'] = zotop::db()->size(); $database['size'] = format::byte($database['size']); $page['title'] = '控制中心'; $page['css'][] = url::module() . '/admin/css/main.css'; zotop::add('zotop.main.main', array(&$this, 'notepad')); zotop::add('zotop.main.main', array(&$this, 'mylog')); page::header($page); page::top(); page::navbar($this->navbar(), 'main'); page::add(''); page::add('<div id="user" class="clearfix">'); page::add(' <div id="userface"><span class="image">' . html::image(zotop::user('image')) . '</span></div>'); page::add(' <div id="userinfo">'); page::add(' <h2 id="welcome">欢迎您,' . zotop::user('name') . ' <span id="sign">' . zotop::user('sign') . '</span></h2>'); page::add(' <div id="login">登录时间:' . time::format(zotop::user('logintime')) . ' 登录次数:' . zotop::user('loginnum') . ' 登录IP:' . zotop::user('loginip') . '</div>'); //加载hook zotop::run('zotop.main.action'); page::add(''); page::add('</div>'); page::add('<div class="grid-m-s">'); page::add('<div class="col-main">'); page::add('<div class="col-main-inner">'); zotop::run('zotop.main.main'); page::add('</div>'); page::add('</div>'); page::add('<div class="col-sub">'); zotop::run('zotop.main.sub'); block::header(array('title' => '网站信息', 'action' => '<a class="more" href="' . zotop::url('zotop/info/site') . '">详细</a>')); echo '<table class="table">'; echo '<tr><td class="w80">网站名称:</td><td>' . $site['name'] . '</td></tr>'; echo '<tr><td class="w80">空间占用:</td><td>' . $site['totalsize'] . '</td></tr>'; echo '<tr><td class="w80">已上传文件:</td><td></td></tr>'; echo '<tr><td class="w80">数据库大小:</td><td>' . $database['size'] . '</td></tr>'; echo '</table>'; block::footer(); block::header(array('title' => '系统信息', 'action' => '<a class="more" href="' . zotop::url('zotop/main/system') . '">详细</a>')); echo '<table class="table">'; echo '<tr><td class="w80">程序版本:</td><td>' . zotop::config('zotop.version') . '</td></tr>'; echo '<tr><td class="w80">程序设计:</td><td>' . zotop::config('zotop.author') . '</td></tr>'; echo '<tr><td class="w80">程序开发:</td><td>' . zotop::config('zotop.authors') . '</td></tr>'; echo '<tr><td class="w80">官方网站:</td><td><a href="' . zotop::config('zotop.homepage') . '" target="_blank">' . zotop::config('zotop.homepage') . '</a></td></tr>'; echo '<tr><td class="w80">安装时间:</td><td>' . zotop::config('zotop.install') . '</td></tr>'; echo '</table>'; block::footer(); page::add('</div>'); page::add('</div>'); page::bottom('<span class="zotop-tip">上次登录时间:' . time::format(zotop::user('logintime')) . '</span>'); page::footer(); }
public function isValidUsername($username) { if (empty($username)) { return false; } //首先检查是否含有特殊字符 $badwords = array("\\", '&', ' ', "'", '"', '/', '*', ',', '<', '>', "\r", "\t", "\n", "#"); foreach ($badwords as $badword) { if (strpos($username, $badword) !== false) { return false; } } //检查用户名是否有效 zotop::run('zotop.user.username.valid', $username); return true; }
public function deleteAction($id) { $user = zotop::model('zotop.user'); $usergroup = zotop::model('zotop.usergroup'); $usergroup->id = $id; $usergroup->read(); if ($usergroup->id == 1) { msg::error('超级管理员组无法被删除'); } if ($user->countByGroupid($id) > 0) { msg::error('该用户组下面尚有用户,无法被删除'); } zotop::run('zotop.usergroup.delete', $usergroup); if ($usergroup->delete()) { $usergroup->cache(); msg::success('删除成功,正在重载数据,请稍后……', zotop::url('zotop/usergroup')); } }
public function delete($where = array()) { $modelcontent = zotop::model('content.modelcontent'); if (empty($where)) { $where = array('id', '=', $this->id); } $data = $this->db()->select('id', 'modelid', 'globalid')->where($where)->getAll(); foreach ($data as $item) { //删除模型内容数据 if ($item['modelid']) { $modelcontent->modelid = $item['modelid']; $modelcontent->delete(); } //删除内容数据 parent::delete(array('id', '=', $item['id'])); //删除附件 //删除钩子,可以调用该钩子删除其他模块的相关数据 zotop::run('content.delete', $item['id']); } return true; }
/** * 应用程序执行 * * * @return null */ public static function run() { $classname = router::controllerName(); $filepath = router::controllerPath(); $method = router::controllerMethod(); $arguments = router::arguments(); //加载controller if (file_exists($filepath)) { zotop::load($filepath); } if (class_exists($classname, false)) { $controller = new $classname(); if (method_exists($controller, $method) && $method[0] != '_') { return call_user_func_array(array($controller, $method), $arguments); } else { //当方法不存在时,默认调用类的_empty()函数,你可以在控制器中重写此方法 return call_user_func_array(array($controller, '_empty'), $arguments); } } zotop::run('system.404', array('filepath' => $filepath)); }
echo zotop::url('system/login/logout'); ?> " id="logout" class="confirm {content:'<h1>您确定要退出登录?</h1><div>退出登陆后将默认将返回系统登录页面</div>',yes:'安全退出'}">安全退出</a> </span> </div> <div id="navbar"> <ul> <li><a href="javascript:void(0);" onclick="top.go('<?php echo zotop::url('system/index/side'); ?> ','<?php echo zotop::url('system/index/main'); ?> ')"><span>控制中心</span></a></li> <?php zotop::run('system.navbar'); ?> <li><a href="javascript:void(0);" onclick="top.go('<?php echo zotop::url('system/file/side'); ?> ','<?php echo zotop::url('system/file/index'); ?> ')"><span>文件管理</span></a></li> <li><a href="javascript:void(0);" onclick="top.go('<?php echo zotop::url('system/system/side'); ?> ','<?php echo zotop::url('system/system/index'); ?> ')"><span>系统管理</span></a></li>
public function deleteAction($id) { $user = zotop::model('zotop.user'); $user->id = $id; $user->read(); if ($user->id == 1 || $user->groupid === 0) { msg::error('系统管理员无法被删除'); } zotop::run('zotop.user.delete', $user); if ($user->delete()) { msg::success('删除成功,正在重载数据,请稍后……', zotop::url('zotop/user')); } }
<?php box::header(array('title' => '系统工具', 'icon' => '', 'class' => 'expanded')); box::add('<ul class="list">'); box::add('<li><a href="' . zotop::url('system/setting') . '" target="mainIframe">系统设置</a></li>'); box::add('<li><a href="' . zotop::url('system/config') . '" target="mainIframe">注册表管理</a></li>'); box::add('<li><a href="' . zotop::url('system/module') . '" target="mainIframe">模块管理</a><span class="extra"><a href="' . zotop::url('zotop/module/uninstalled') . '" target="mainIframe">模块安装</a></span></li>'); zotop::run('zotop.system.side.tools'); box::add('</ul>'); box::footer(); ?> <?php box::header(array('title' => '文件管理', 'icon' => '', 'class' => 'expanded')); box::add('<ul class="list">'); box::add('<li><a href="' . zotop::url('system/file') . '" target="mainIframe">文件管理</a></li>'); box::add('<li><a href="' . zotop::url('system/file/add') . '" target="mainIframe">上传文件</a></li>'); box::add('</ul>'); box::footer(); zotop::run('zotop.system.side.file'); ?> <?php box::header(array('title' => '系统用户', 'icon' => '', 'class' => 'expanded')); box::add('<ul class="list">'); box::add('<li><a href="' . zotop::url('system/user') . '" target="mainIframe">系统用户管理</a></li>'); box::add('<li><a href="' . zotop::url('system/usergroup') . '" target="mainIframe">系统用户组管理</a></li>'); zotop::run('zotop.system.side.user'); box::add('</ul>'); box::footer(); $this->bottom(); $this->footer();
?> </div> </div> </div> <div class="grid-m-s clearfix"> <div class="col-main"> <div class="col-main-inner"> <?php zotop::run('system.main.main'); ?> </div> </div> <div class="col-sub"> <?php zotop::run('system.main.side'); ?> <div class="box clearfix "> <div class="box-header"> <h2>系统信息</h2> <h3><a class="more" href="<?php echo zotop::url('system/system/info'); ?> ">详细</a></h3> </div> <div class="box-body clearfix"> <table class="table"> <tr><td class="w80">程序名称:</td><td><?php echo zotop::config('zotop.name'); ?> </td></tr>
<?php $this->header(); ?> <?php block::header(array('title' => '快捷操作', 'class' => 'expanded', 'icon' => '', 'action' => '<a href="#">管理</a>')); block::add($modules); block::footer(); block::header(array('title' => '我的信息', 'class' => 'expanded', 'icon' => '')); block::add('<ul class="list">'); block::add('<li><a href="' . zotop::url('zotop/mine/changeinfo') . '" target="mainIframe">修改我的资料</a></li>'); block::add('<li><a href="' . zotop::url('zotop/mine/changepassword') . '" target="mainIframe">修改我的密码</a></li>'); zotop::run('zotop.index.side.mine'); block::add('</ul>'); block::footer(); $this->footer();
<ul> <?php foreach ($categorys as $c) { ?> <li<?php echo $categoryid == $c['id'] ? ' class="selected"' : ''; ?> ><a class="textflow" href="<?php echo zotop::url('blog/list/' . $c['id']); ?> "><span class="zotop-icon zotop-icon-folder"></span><?php echo $c['title']; ?> </a></li> <?php } ?> </ul> </div> <?php box::footer(); ?> <?php zotop::run('blog.side', $blog); ?> </div> </div> </div> <?php $this->bottom(); $this->footer();
?> </div> </div> </div> <div class="grid-m-s"> <div class="col-main"> <div class="col-main-inner"> <?php zotop::run('zotop.main.main'); ?> </div> </div> <div class="col-sub"> <?php zotop::run('zotop.main.side'); ?> <div class="block clearfix "> <div class="block-header"> <h2>网站信息</h2> <h3><a class="more" href="<?php echo zotop::url('zotop/site/info'); ?> ">详细</a></h3> </div> <div class="block-body clearfix"> <table class="table"> <tr> <td class="w80">网站名称:</td><td><?php echo zotop::config('site.name'); ?>
?> " target="mainIframe">修改我的密码</a><b>|</b> <a href="<?php echo zotop::url('zotop/login/logout'); ?> " id="logout" class="confirm {content:'<h1>您确定要退出登录?</h1><div>退出登陆后将默认将返回系统登录页面</div>',yes:'安全退出'}">安全退出</a> </span> </div> <div id="navbar"> <ul> <li><a href="<?php echo zotop::url('zotop/main/side'); ?> " target="sideIframe"><span>我的面板</span></a></li> <?php zotop::run('zotop.index.navbar'); ?> <li><a href="<?php echo zotop::url('zotop/system/side'); ?> " target="sideIframe"><span>系统管理</span></a></li> </ul> </div> <div id="favorate"><a href="<?php echo zotop::url('zotop/favorate'); ?> " class="button ibutton dialog" title="打开收藏夹"><span class="button-icon zotop-icon zotop-icon-favorate"></span><span class="button-text">收藏夹</span></a></div> </div> </div> <div id="position"> <div id="position-side">
/** * 应用程序执行 * * * @return null */ public static function execute() { if (zotop::module(application::module()) === null || (int) zotop::module(application::module(), 'status') < 0) { msg::error(array('title' => '404 error', 'content' => zotop::t('<h2>未能找到模块,模块可能尚未安装或者已经被禁用?</h2>'), 'detail' => zotop::t('模块名称:{$module}', array('module' => application::$module)))); } define('ZOTOP_MODULE', application::module()); define('ZOTOP_MODULE_PATH', zotop::module(application::module(), 'path')); define('ZOTOP_MODULE_URL', zotop::module(application::module(), 'url')); $controllerPath = ZOTOP_MODULE_PATH . DS . ZOTOP_APPLICATION . DS . application::controller() . '.php'; if (zotop::load($controllerPath)) { } elseif (zotop::load(ZOTOP_MODULE_PATH . DS . ZOTOP_GROUP . DS . 'default.php')) { $controllerPath = ZOTOP_MODULE_PATH . DS . ZOTOP_GROUP . DS . 'default.php'; application::$arguments = array_merge(array(application::$controller), array(application::$action), application::$arguments); application::$controller = 'default'; application::$action = ''; } else { zotop::error(array('title' => '404 error', 'content' => zotop::t('<h2>未能找到控制器,请检查控制器文件是否存在?</h2>'), 'detail' => zotop::t('文件名称:{$file}', array('file' => $controllerPath)))); } define('ZOTOP_CONTROLLER', application::controller()); $class = application::module() . '_controller_' . application::controller(); if (class_exists($class, false)) { //实例化控制器 $controller = new $class(); if (!method_exists($controller, 'action' . ucfirst(application::action()))) { if (strlen(application::action()) > 0) { application::$arguments = array_merge(array(application::$action), application::$arguments); } application::$action = $controller->action; } define('ZOTOP_ACTION', application::action()); if (method_exists($controller, 'action' . ucfirst(application::action()))) { zotop::run("system.execute.before"); call_user_func_array(array($controller, 'action' . ucfirst(application::action())), application::arguments()); zotop::run("system.execute.after"); } else { call_user_func_array(array($controller, '__empty'), array(application::action(), application::arguments())); } } else { zotop::error(array('title' => '404 error', 'content' => zotop::t('<h2>未能找到控制器类,请检查控制器文件中是否存在控制器类?</h2>'), 'detail' => zotop::t('类名称:{$className}', array('className' => $class)))); } }
/** * 系统重启 * * @return string */ public static function reboot() { zotop::boot(); zotop::run('system.reboot'); }
/** * 删除数据 * * @param mix $where 删除条件 * * @return mix */ public function delete($where = array()) { if (empty($where) || !is_array($where)) { $key = $this->key(); if (empty($where)) { $where = array($key, '=', $this->{$key}); } if (is_numeric($where) || is_string($where)) { $where = array($key, '=', $where); } } zotop::run($this->table() . '.delete', $where); return $this->db()->where($where)->delete(); }
/** * URI别名,实现自定义路由,如果需要请覆写此函数 * * @param string $uri 当前的URI * @return string 处理过的URI */ public static function alias($uri) { //uri hook zotop::run('zotop.uri', $uri); }
<?php define('APP_NAME', 'admin'); define('APP_ROOT', dirname(__FILE__)); define('APP_BASE', basename(__FILE__)); define('APP_URL', dirname($_SERVER['SCRIPT_NAME'])); define('DS', DIRECTORY_SEPARATOR); define('ZPATH_SYSTEM', dirname(APP_ROOT)); define('ZURL_ROOT', dirname(dirname(dirname($_SERVER['SCRIPT_NAME'])))); //加载启动文件 require ZPATH_SYSTEM . DS . 'boot.php'; //系统运行 zotop::run('system.boot'); zotop::run('system.route'); zotop::run('system.ready'); zotop::run('system.run'); zotop::run('system.shutdown');
<div id="content" class="content clearfix"> <?php echo $content->content; ?> </div> </div> </div> </div> <div class="column-sub"> <div class="column-sub-inner"> <?php box::header(array('title' => '分类')); ?> <div class="navbarlist"> <ul> </ul> </div> <?php box::footer(); ?> <?php zotop::run('content.side', $content); ?> </div> </div> </div> <?php $this->bottom(); $this->footer();