public function __construct($config = array()) { if (!$this->test()) { zotop::error(zotop::t('The memcache extension is not available')); } $host = $config['host']; $host = empty($host) ? zotop::config('system.cache.memcache.host') : $host; $host = empty($host) ? '127.0.0.1' : $host; $post = $config['post']; $port = empty($port) ? zotop::config('system.cache.memcache.port') : $port; $port = empty($port) ? '11211' : $port; $timeout = isset($config['timeout']) ? (bool) $config['timeout'] : false; $persistent = isset($config['persistent']) ? (bool) $config['persistent'] : false; unset($config); //是否持久链接 $connect = $persistent ? 'pconnect' : 'connect'; $this->memcache =& new Memcache(); if ($timeout === false) { $this->connected = @$this->memcache->{$connect}($host, $port); } else { $this->connected = @$this->memcache->{$connect}($host, $port, $timeout); } if (!$this->connected) { zotop::error(zotop::t('无法连接memcache服务器 “{$host}:{$port}”,请检查参数配置是否正确', array('host' => $host, 'port' => $port))); } }
public function onDefault() { if (form::isPostBack()) { msg::error('开发中', '数据保存开发中,请稍后……'); } $header['title'] = '系统设置'; page::header($header); page::top(); page::navbar($this->navbar(), 'main'); form::header(); block::header('网站基本信息'); form::field(array('type' => 'text', 'label' => zotop::t('网站名称'), 'name' => 'zotop.site.title', 'value' => zotop::config('zotop.site.title'), 'description' => zotop::t('网站名称,将显示在标题和导航中'))); form::field(array('type' => 'text', 'label' => zotop::t('网站域名'), 'name' => 'zotop.site.domain', 'value' => zotop::config('zotop.site.domain'), 'description' => zotop::t('网站域名地址,不包含http://,如:www.zotop.com'))); form::field(array('type' => 'text', 'label' => zotop::t('备案信息'), 'name' => 'zotop.site.icp', 'value' => zotop::config('zotop.site.icp'), 'description' => zotop::t('页面底部可以显示 ICP 备案信息,如果网站已备案,在此输入您的授权码,它将显示在页面底部,如果没有请留空'))); form::field(array('type' => 'select', 'options' => array('0' => '不显示', '1' => '显示'), 'label' => zotop::t('授权信息'), 'name' => 'zotop.site.license', 'value' => zotop::config('zotop.site.license'), 'description' => zotop::t('页脚部位显示程序官方网站链接'))); form::field(array('type' => 'textarea', 'label' => zotop::t('网站简介'), 'name' => 'zotop.site.about', 'value' => zotop::config('zotop.site.about'))); block::footer(); block::header('联系信息设置'); form::field(array('type' => 'text', 'label' => zotop::t('公司名称'), 'name' => 'zotop.site.title', 'value' => '', 'description' => zotop::t('网站隶属的公司或者组织名称'))); form::field(array('type' => 'textarea', 'label' => zotop::t('网站简介'), 'name' => 'zotop.site.about', 'value' => '')); block::footer(); form::buttons(array('type' => 'submit'), array('type' => 'back')); form::footer(); page::bottom(); page::footer(); }
public function actionIndex($parentid = 0) { $folder = zotop::model('system.folder'); if (form::isPostBack()) { $post = form::post(); foreach ((array) $post['id'] as $i => $id) { $folder->update(array('order' => $i + 1), $id); } if (!$folder->error()) { msg::success('保存成功', zotop::url('system/folder/index')); } msg::error($folder->msg()); } $folders = $folder->getAll(); $tree = new tree($folders, 0); $rows = $tree->getChild($parentid); $position = $tree->getPosition($parentid); foreach ($position as $p) { $pos[zotop::url('system/folder/index/' . $p['id'])] = $p['title']; } $page = new page(); $page->set('title', zotop::t('文件管理')); $page->set('navbar', $this->navbar($parentid)); $page->set('position', array(zotop::url('system/file') => zotop::t('文件管理'), zotop::url('system/folder') => zotop::t('分类管理')) + (array) $pos + array('列表')); $page->set('folders', $folders); $page->set('rows', $rows); $page->set('hash', $hash); $page->display(); }
public function onDefault() { if (form::isPostBack()) { $post = array(); $post['username'] = request::post('username'); $post['password'] = request::post('password'); $post['logintime'] = time(); $user = zotop::model('zotop.user'); $data = $user->read($post['username'], 'username'); //zotop::dump($data); if ($data == false) { msg::error('登陆失败', zotop::t('账户名称`{$username}`不存在,请检查!', array('username' => $post['username']))); } zotop::user($data); msg::success('登陆成功', '登陆成功,系统正在加载中', 'reload', 2); } if (zotop::user() != null) { zotop::redirect('zotop/index'); } $header['title'] = '用户登录'; $header['js'] = url::module() . '/admin/js/login.js'; $header['body']['class'] = "login"; page::header($header); block::header(array('id' => 'LoginWindow', 'title' => '用户登录')); form::header(array('title' => '', 'description' => '请输入用户名和密码', 'class' => 'small')); form::field(array('type' => 'text', 'label' => zotop::t('帐 户(U)'), 'name' => 'username', 'value' => zotop::user('username'), 'valid' => 'required:true')); form::field(array('type' => 'password', 'label' => zotop::t('密 码(P)'), 'name' => 'password', 'value' => '')); form::buttons(array('type' => 'submit', 'value' => '登 陆'), array('type' => 'button', 'name' => 'options', 'value' => '选 项')); form::footer(); block::footer(); page::footer(); }
public function actionIndex() { $page = new page(); $page->title = zotop::t('系统管理'); $page->navbar = $this->navbar(); $page->display(); }
public function editAction($tablename) { if (form::isPostBack()) { $tablename = request::post('tablename'); $name = request::post('name'); $comment = request::post('comment'); $primary = request::post('primary'); if (strtolower($tablename) !== strtolower($name)) { $rename = zotop::db()->table($tablename)->rename($name); } if ($comment !== NULL) { $comment = zotop::db()->table($name)->comment($comment); } if ($primary) { $primary = zotop::db()->table($name)->primary($primary); } $this->success('数据表设置成功,正在刷新页面,请稍后……', zotop::url('database/table')); } $db = zotop::db(); $database = $db->config(); $tables = $db->tables(true); $table = $tables[$tablename]; if (!isset($table)) { $this->error(zotop::t('数据表{$tablename}不存在', array('tablename' => $tablename))); } $page = new dialog(); $page->title = '数据库管理:' . $database['database'] . ' @ ' . $database['hostname'] . '<i>></i> 编辑:' . $tablename; $page->set('database', $database); $page->set('table', $table); $page->display(); }
public function changePasswordAction() { $user = zotop::model('zotop.user'); $user->id = (int) zotop::user('id'); $user->username = (string) zotop::user('username'); if (form::isPostBack()) { $user->read(); $password = request::post('password'); $newpassword = request::post('newpassword'); if ($user->password($password) != $user->password) { msg::error(zotop::t('您输入的原密码:<b>{$password}</b>错误,请确认', array('password' => $password))); } if ($newpassword != request::post('newpassword2')) { msg::error(zotop::t('两次输入的新密码不一致,请确认')); } if ($newpassword != $password) { $update = $user->update(array('id' => $user->id, 'password' => $user->password($newpassword))); } msg::success(zotop::t('密码修改成功,请记住您的新密码'), url::current()); } $page = new page(); $page->title = '修改我的密码'; $page->set('user', $user); $page->set('navbar', $this->navbar()); $page->display(); }
public function actionIndex($type = '') { $file = zotop::model('zotop.file'); if (!empty($type)) { $where = array('type', '=', $type); } $files = $file->db()->where($where)->orderby('createtime', 'desc')->getPage(); $pagination = new pagination(); $pagination->page = $files['page']; $pagination->pagesize = $files['pagesize']; $pagination->total = $files['total']; $p = $pagination->render(); $totalsize = $file->totalsize(); $totalcount = $file->count(); $page = new page(); $page->set('title', zotop::t('文件管理')); $page->set('navbar', $this->navbar()); $page->set('page', $files['page']); $page->set('pagesize', $files['pagesize']); $page->set('total', $files['total']); $page->set('files', $files['data']); $page->set('totalsize', $totalsize); $page->set('totalcount', $totalcount); $page->set('pagination', $p); $page->display(); }
public function actionDelete($tablename) { $delete = zotop::db()->table($tablename)->drop(); if (!$delete) { msg::error(zotop::t('删除数据表{$tablename}失败', array('tablename' => $tablename))); } msg::success('删除成功', zotop::url('database/table')); }
public function types($type = '') { $types = array('core' => zotop::t('核心模块'), 'com' => zotop::t('功能模块'), 'plugin' => zotop::t('插件模块')); if (empty($type)) { return $types; } return $types[$type]; }
public function actionSide() { $category = zotop::model('content.category'); $tree = $category->getTree(0, '<span class="zotop-icon zotop-icon-$icon"></span><a href="' . zotop::url('content/content/index/$id') . '" target="mainIframe">$title</a>'); $page = new side(); $page->set('title', zotop::t('文件管理')); $page->set('tree', $tree); $page->display(); }
public function add($data = array()) { $this->bind($data); if ((int) $this->id <= 0) { $this->error(zotop::t('编号不能为空')); return false; } $this->insert(); return $this->error() ? false : true; }
/** * 显示成功消息 * */ public static function success($content = '', $url = '', $life = 2) { $msg = array('type' => 'success', 'title' => zotop::t('success'), 'content' => '', 'detail' => '', 'url' => $url, 'life' => $life, 'action' => ''); if (is_array($content)) { $msg = array_merge($msg, $content, array('type' => 'success')); } else { $msg['content'] = $content; } msg::show($msg); }
public function onSend() { $header['title'] = '发送短消息'; dialog::header($header); form::header(array('title' => '', 'description' => '请输入收信人的账户并输入短消息内容', 'class' => 'small')); form::field(array('type' => 'text', 'label' => zotop::t('收信人'), 'name' => 'sendto', 'value' => '', 'description' => '请输入收信人的账户名称,多个账户之间请用’逗号‘隔开')); form::field(array('type' => 'textarea', 'label' => zotop::t('内 容'), 'name' => 'content', 'value' => '')); form::buttons(array('type' => 'submit', 'value' => '发 送'), array('type' => 'button', 'name' => 'close', 'value' => '取消', 'class' => 'zotop-dialog-close')); form::footer(); dialog::footer(); }
public function onBing() { $header['title'] = 'Bing搜索'; dialog::header($header); dialog::navbar($this->navbar(), 'bing'); form::header(array('title' => '', 'description' => '<span class="zotop-tip">请先搜索图片,然后插入</span>')); dialog::add(html::iframe('images', 'about:blank', array('width' => '100%', 'style' => 'width:100%;height:200px;'))); form::buttons(array('id' => 'UploadImages', 'type' => 'submit', 'value' => '插入图片'), array('type' => 'button', 'value' => zotop::t('取消'), 'class' => 'zotop-dialog-close')); form::footer(); dialog::footer(); }
/** * 写入登陆信息 * */ public function login($data = array()) { $data = array_merge($this->bind(), (array) $data); $data = zotop::filter('zotop.user.login', $data); //刷新信息 $this->refresh(); //记录用户数据 zotop::user($data); zotop::log('login', zotop::t('用户 <b>{$username}</b> 于 {$time} 登陆成功', array('username' => $data['username'], 'time' => TIME))); return true; }
function site_keywords($attrs) { //$html[] = html::script('$common/js/zotop.keywords.js'); $html[] = '<div class="field-wrapper clearfix">'; $html[] = ' ' . field::text($attrs); $html[] = ' <span class="field-handle">'; $html[] = ' <a class="setkeywords" style="display:inline-block;" valueto="' . $attrs['name'] . '" title="' . zotop::t('常用关键词') . '"><span class="zotop-icon zotop-icon-keywords"></span></a>'; $html[] = ' </span>'; $html[] = '</div>'; return implode("\n", $html); }
public function top() { $html[] = ''; $html[] = '<div id="header" class="clearfix">'; $html[] = ' <div id="page-title">' . $this->title . '</div>'; $html[] = ' <div id="page-description">' . $this->position() . '</div>'; $html[] = '</div>'; $html[] = '<div id="topbar">'; $html[] = ' <a id="favorate" href="' . zotop::url('zotop/favorate/add') . '" class="dialog" title="' . zotop::t('将该页面加入我的收藏夹') . '"><span class="zotop-icon zotop-icon-favorate"></span><span>' . zotop::t('加入收藏') . '</span></a>'; $html[] = '</div>'; $html[] = '<div id="body" class="clearfix">'; echo implode("\n", $html); }
public function uninstallAction($id) { $module = zotop::model('zotop.module'); $module->id = $id; $module->read(); if ($module->type == 'system') { msg::error('系统模块不能被卸载!'); } $uninstall = $module->uninstall($id); if ($uninstall) { $module->cache(); msg::success(zotop::t('模块卸载成功'), zotop::url('zotop/module')); } }
public function save($data = array()) { $data = array_merge($this->bind(), $data); if (empty($data['id'])) { if (empty($data['title'])) { $this->error(zotop::t('分类名称不能为空')); return false; } $data['id'] = $this->max('id') + 1; $data['parentid'] = empty($data['parentid']) ? 0 : (int) $data['parentid']; $data['order'] = $data['id']; return $this->insert($data); } }
public function indexAction() { $user = zotop::model('zotop.user'); if (form::isPostBack()) { $post = array(); $post['username'] = request::post('username'); $post['password'] = request::post('password'); $post['logintime'] = time(); zotop::cookie('admin.username', $post['username'], 3600); if (empty($post['username'])) { msg::error(zotop::t('登陆失败,请输入登陆账户名称')); } if (empty($post['password'])) { msg::error(zotop::t('登陆失败,请输入登陆账户密码')); } if (!$user->isValidUserName($post['username'])) { msg::error(zotop::t('登陆失败,请输入有效的账户名称')); } if (!$user->isValidPassword($post['password'])) { msg::error(zotop::t('登陆失败,请输入有效的账户密码')); } //读取用户 $data = $user->read(array('username', '=', $post['username'])); //验证 if ($data == false) { msg::error(zotop::t('账户名称`{$username}`不存在,请检查是否输入有误!', array('username' => $post['username']))); } if ($user->password($post['password']) != $data['password']) { msg::error(zotop::t('账户密码`{$password}`错误,请检查是否输入有误!', array('password' => $post['password']))); } //用户登入 $user->login(); //跳转 msg::success('登陆成功,系统正在加载中', url::current(), 2); } if (!empty($this->user)) { $this->redirect('zotop/index'); } $data = $user->read(array('username', '=', 'admin')); $page = new page(); $page->title = '系统登陆'; $page->body = array('class' => 'login'); $page->addScript('$this/js/login.js'); $page->display(); }
public function actionTheme() { $config = zotop::model('system.config'); if (form::isPostBack()) { $post = form::post(); $config->save($post); if ($config->error()) { msg::error($config->msg()); } msg::success('保存成功'); } $theme = $config->fields('system.theme'); $page = new page(); $page->set('title', zotop::t('系统设置')); $page->set('navbar', $this->navbar()); $page->set('theme', $theme); $page->display(); }
public function onEdit($file) { if (form::isPostBack()) { $content = request::post('source'); msg::success('保存测试', '测试,继续编辑或者返回' . zotop::dump($content, true), 'reload'); } $source = file::read(ROOT . $file); $page['title'] = '文件编辑器'; page::header($page); page::top(); page::navbar($this->navbar()); form::header(array('class' => 'sourceEditor')); form::field(array('type' => 'label', 'label' => zotop::t('文件名称'), 'name' => 'filename', 'value' => $file, 'valid' => '', 'description' => zotop::t(''))); form::field(array('type' => 'source', 'label' => zotop::t('文件内容'), 'name' => 'source', 'value' => $source, 'valid' => 'required:true', 'description' => zotop::t(''))); form::buttons(array('type' => 'submit', 'value' => '保存文件'), array('type' => 'back')); form::footer(); page::bottom(); page::footer(); }
public function actionInfo() { $user = zotop::model('system.user'); $user->id = (int) zotop::user('id'); if (form::isPostBack()) { $post = form::post(); $update = $user->update($post, $user->id); if ($update) { msg::success('资料设置成功,正在刷新页面,请稍后……', url::location()); } msg::error(); } $data = $user->read(); $page = new page(); $page->title = zotop::t('个人中心'); $page->set('navbar', $this->navbar()); $page->set('globalid', $user->globalid()); $page->set('data', $data); $page->display(); }
public function actionEdit($id) { $model = zotop::model('content.model'); if (form::isPostBack()) { $post = form::post(); $model->edit($post, $id); if (!$model->error()) { msg::success('保存成功', zotop::url('content/model/index/')); } msg::error($model->msg()); } $data = $model->read($id); $data['settings'] = $model->settings(); $page = new page(); $page->set('title', zotop::t('模型管理')); $page->set('position', array(zotop::url('content') => zotop::t('内容管理'), zotop::url('content/model') => zotop::t('模型管理'), zotop::t('编辑模型'))); $page->set('navbar', $this->navbar()); $page->set('data', $data); $page->display(); }
public function actionIndex() { $user = zotop::model('system.user'); if (form::isPostBack()) { $post = form::post(); $user->login($post); if (!$user->error()) { msg::success(zotop::t('登陆成功,系统正在加载中'), zotop::url(), 2); } msg::error($user->msg()); } if (!empty($this->user)) { header("Location: " . zotop::url()); exit; } $page = new page(); $page->set('title', zotop::t('系统管理登陆')); $page->set('body', array('class' => 'login')); $page->display(); }
/** * 类初始化 * * @param string|array config 配置 * @return object */ public function __construct($config = array()) { //支持json格式的缓存配置 if (is_string($config)) { $config = json_decode($config, true); } if (is_array($config)) { $config += array('driver' => zotop::config('system.cache.driver'), 'expire' => (int) zotop::config('system.cache.expire')); } if (empty($config['driver'])) { $config['driver'] = 'file'; } //缓存驱动程序 $driver = 'cache_' . strtolower($config['driver']); //加载驱动程序 if (!zotop::autoload($driver)) { zotop::error(zotop::t('未能找到缓存驱动 "{$driver}"', $config)); } $this->driver = new $driver($config); return $this->driver; }
public function actionIndex($parentid = 'root') { $config = zotop::model('system.config'); if (form::isPostBack()) { $post = form::post(); //保存并排序 $save = $config->save($post, true); if ($save) { msg::success(zotop::t('保存成功')); } msg::error($save); } $configs = $config->db()->where('parentid', '=', $parentid)->orderby('order', 'asc')->getAll(); $position = $config->position($parentid, ' <cite>></cite> <a href=\\"' . zotop::url('system/config/index') . '/$id\\">$title</a>'); $position = '<a href="' . zotop::url('system/config/index') . '">' . zotop::t('首页') . '</a>' . $position; $page = new page(); $page->set('title', zotop::t('注册表管理 ')); $page->set('position', $position); $page->set('navbar', $this->navbar($parentid)); $page->set('configs', $configs); $page->display(); }
public function actionIndex($type = 'all', $folderid = 0) { $file = zotop::model('system.file'); $folder = zotop::model('system.folder'); if (!empty($type) && $type != 'all') { $where = array('file.type', '=', $type); } $files = $file->db()->select('file.*', 'user.name as user_name', 'user.username as user_username')->join('user', 'user.id', 'file.userid')->where($where)->orderby('file.createtime', 'desc')->getPage(); //zotop::dump($file->db()->Sql()); $types = $file->types(); $pagination = new pagination(); $pagination->page = $files['page']; $pagination->pagesize = $files['pagesize']; $pagination->total = $files['total']; $p = $pagination->render(); $totalsize = $file->totalsize($where); $totalcount = $file->count(); $folders = $folder->getAll(); $tree = new tree($folders, 0); $position = $tree->getPosition($folderid); foreach ($position as $p) { $pos[zotop::url('system/file/index/' . $type . '/' . $p['id'])] = $p['title']; } $page = new page(); $page->set('title', zotop::t('文件管理')); $page->set('position', array(zotop::url('system/file') => zotop::t('文件管理'), zotop::url('system/file/' . $type . '/0') => zotop::t('全部文件')) + (array) $pos + array('列表')); $page->set('navbar', $this->navbar()); $page->set('page', $files['page']); $page->set('pagesize', $files['pagesize']); $page->set('total', $files['total']); $page->set('files', $files['data']); $page->set('totalsize', $totalsize); $page->set('totalcount', $totalcount); $page->set('pagination', $p); $page->set('types', $types); $page->set('type', $type); $page->set('folderid', $folderid); $page->display(); }
/** * 执行一个sql语句 query,相当于包装后的mysql_query * * @param $sql * @param $silent * @return unknown_type */ public function query($sql, $silent = false) { if (!is_resource($this->connect)) { $this->connect(); } if ($sql = $this->parseSql($sql)) { //echo $this->sql; if ($this->query) { $this->free(); //释放前次的查询结果 } $this->query = @mysql_query($sql, $this->connect); //查询数据 if ($this->query === false) { if ($silent) { return false; } zotop::error(-3, '查询语句错误', zotop::t('<h2>SQL: {$sql}</h2>{$error}', array('sql' => $sql, 'error' => @mysql_error()))); } $this->numRows = mysql_num_rows($this->query); return $this->query; } return false; }