public function add($data) { $data['id'] = empty($data['id']) ? $this->max('id') + 1 : $data['id']; $data['createtime'] = empty($data['createtime']) ? TIME : $data['createtime']; $data['updatetime'] = empty($data['updatetime']) ? TIME : $data['updatetime']; $data['order'] = (int) $data['order']; $data['userid'] = empty($data['userid']) ? (int) $this->user('id') : (int) $data['userid']; $data['link'] = (int) $data['link']; $color = arr::take('title_color', $data); $weight = arr::take('title_weight', $data); $data['style'] = (empty($color) ? '' : 'color:' . $color . ';') . (empty($weight) ? '' : 'font-weight:' . $weight . ';'); if (empty($data['title'])) { $this->error('标题不能为空'); return false; } if (!$data['link'] && empty($data['content'])) { $this->error('内容不能为空'); return false; } if ($data['link'] && empty($data['url'])) { $this->error('转向链接不能为空'); return false; } $this->id = $this->insert($data); //更新文件全局编号和状态 $file = zotop::model('system.file'); $file->refresh(zotop::post('_GLOBALID'), $this->globalid()); return $this->id; }
public function actionPassword() { $user = zotop::model('system.user'); $user->id = (int) zotop::user('id'); $user->username = (string) zotop::user('username'); if (form::isPostBack()) { $user->read(); $password = zotop::post('password'); $newpassword = zotop::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 = zotop::t('个人中心'); $page->set('user', $user); $page->set('navbar', $this->navbar()); $page->display(); }
public function actionIndex($parentid = 0) { $category = zotop::model('content.category'); if (form::isPostBack()) { $ids = zotop::post('id'); $category->order($ids); if (!$category->error()) { msg::success('保存成功'); } msg::error($category->msg()); } $categorys = $category->db()->where('parentid', '=', $parentid)->orderby('order', 'asc')->getAll(); $types = $category->types(); $model = zotop::model('content.model'); $models = $model->cache(); $position = $category->getPosition($parentid); foreach ($position as $p) { $pos[zotop::url('content/category/index/' . $p['id'])] = $p['title']; } $page = new page(); $page->set('title', zotop::t('栏目管理')); $page->set('position', array(zotop::url('content') => zotop::t('内容管理'), zotop::url('content/category') => zotop::t('栏目管理')) + (array) $pos + array('栏目列表')); $page->set('navbar', $this->navbar($parentid)); $page->set('categorys', $categorys); $page->set('models', $models); $page->set('types', $types); $page->display(); }
public function actionUpload() { $file = zotop::model('system.file'); $file->upload->allowexts = 'jpg|jpeg|png|gif'; $folder = zotop::model('system.folder'); if (form::isPostBack()) { $file->globalid = zotop::post('globalid'); $file->field = zotop::post('field'); $file->description = zotop::post('description'); $files = $file->upload(); if (!$file->error() && isset($files[0]['path'])) { msg::success('图片上传成功', zotop::url('system/image/upload')); } msg::error($file->msg()); } $folders = $folder->getAll(); $tree = new tree($folders, 0); $categorys = $tree->getOptionsArray(); $page = new dialog(); $page->set('title', '本地上传'); $page->set('navbar', $this->navbar()); $page->set('allowexts', $file->upload->allowexts); $page->set('maxsize', $file->upload->maxsize); $page->set('categorys', $categorys); $page->display(); }
public function actionEdit($tablename) { if (form::isPostBack()) { $tablename = zotop::post('tablename'); $name = zotop::post('name'); $comment = zotop::post('comment'); $primary = zotop::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); } msg::success('数据表设置成功,正在刷新页面,请稍后……', zotop::url('database/table')); } $db = zotop::db(); $database = $db->config(); $tables = $db->tables(true); $table = $tables[$tablename]; if (!isset($table)) { msg::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 static function referer($url = '') { static $referer; if (empty($url)) { $url = zotop::post('_REFERER'); return $url; } $referer = $url; return $referer; }
public function actionEditor($file) { $filepath = realpath(ZOTOP_PATH_ROOT . DS . trim($file, '/')); if (empty($file)) { return false; } if (form::isPostBack()) { $content = zotop::post('source'); $content = trim($content); if (empty($content)) { msg::error('内容为空,无法保存!'); } file::write($filepath, trim($content)); msg::success('内容保存成功!'); } $content = file::read($filepath); $page = new dialog(); $page->title = '文件编辑器'; $page->set('file', $file); $page->set('filepath', $filepath); $page->set('content', $content); $page->display(); }
public function actionInstall($id = '') { $id = empty($id) ? zotop::post('id') : $id; $module = zotop::model('system.module'); $modules = $module->getUnInstalled(); if (!isset($modules[$id])) { msg::error(array('title' => zotop::t('安装失败'), 'content' => zotop::t('未找到模块<b>{$id}</b>,请检查', array('id' => $id)))); } if (form::isPostBack()) { $install = $module->install($modules[$id]['path']); if ($install) { $module->cache(true); msg::success(zotop::t('模块安装成功'), zotop::url('system/module')); } } $moduleFile = $modules[$id]['path'] . DS . 'module.php'; if (!file::exists($moduleFile)) { msg::error(array('title' => zotop::t('安装失败'), 'content' => zotop::t('未找到模块标记文件<b>module.php</b>,请检查'))); } $page = new dialog(); $page->set('title', '安装模块'); $page->set('module', $modules[$id]); $page->display(); }
public function actionEdit($tablename, $fieldname) { if (form::isPostBack()) { $field = array(); $field['name'] = zotop::post('name'); $field['length'] = zotop::post('len'); $field['type'] = zotop::post('type'); $field['collation'] = zotop::post('collation'); $field['null'] = zotop::post('null'); $field['default'] = zotop::post('default'); $field['attribute'] = zotop::post('attribute'); $field['extra'] = zotop::post('extra'); $field['comment'] = zotop::post('comment'); $field['position'] = zotop::post('position'); $fieldname = zotop::post('fieldname'); if ($fieldname != $field['name']) { $result = zotop::db()->table($tablename)->field($fieldname)->rename($field['name']); } $result = zotop::db()->table($tablename)->modify($field); if ($result) { msg::success('字段修改成功', zotop::url('database/field/index/' . $tablename)); } } $tables = zotop::db()->tables(true); $table = $tables[$tablename]; $fields = array(); if (isset($table)) { $fields = zotop::db()->table($tablename)->fields(true); } $field = $fields[$fieldname]; if (!isset($field)) { msg::error('字段不存在,请勿修改浏览器参数'); } $positions = array(); $positions[-1] = '位于表头'; if ($fields) { foreach ($fields as $key => $val) { $positions[$key] = '位于 ' . $key . ' 之后'; } } $positions[0] = ' '; $page = new dialog(); $page->title = '编辑字段'; $page->set('database', $database); $page->set('tables', $tables); $page->set('field', $field); $page->set('positions', $positions); $page->display(); }
public function actionNewfile($dir = '') { $dir = empty($dir) ? zotop::get('dir') : $dir; $dir = trim(url::decode($dir), '/'); $file = 'newfile.php'; if (form::isPostBack()) { $file = zotop::post('name'); $title = zotop::post('title'); $description = zotop::post('description'); $filepath = site::template($dir . DS . $file); $filecontent = "<?php\r\n/**\r\n * title:{$title}\r\n * description:{$description}\r\n*/\r\n?>"; if (file::exists($filepath)) { msg::error(zotop::t('新建失败,当前目录已经存在文件:{$file}', array('file' => $file))); } if (file::write($filepath, $filecontent)) { msg::success('新建文件成功'); } msg::error('新建文件失败'); } $page = new dialog(); $page->title = zotop::t('模板编辑器'); $page->set('dir', $dir); $page->set('file', $file); $page->display(); }