public function index() { if ($this->user['perm'] != SUPER_MAN && SYSNAME != $this->user['channel']) { header("Location:/" . $this->user['channel'] . '/admin/'); exit; } $list = Lua::get_more("select * from lua_channel where status='1'"); $cssname = 'nav_list'; if (SYSNAME != ADMIN_ROOT) { $session = Doo::session('Lua'); $change_id = $session->get('change_id'); $set = Lua::get('set'); if ($set) { $session->change_id = empty($change_id) || $change_id == 0 ? 1 : 0; header("Location:/" . SYSNAME . "/" . ADMIN_ROOT . "/"); exit; } $set_id = $change_id || $change_id == 1 ? 1 : 0; if ($set_id == 0) { Doo::cache('php')->hashing = false; $tree = Doo::cache('php')->get('category'); $cssname = 'tree_list'; $html = ''; if ($tree) { $html = $this->_tree($tree, 0); } } } include Lua::display('frame', $this->dir); }
private function _tree($upid = 0, $force = 0, $addn = ' ') { $and = $force == 1 ? " and upid='{$upid}' " : ""; $list = Lua::get_more("select * from lua_category where systemname='" . SYSNAME . "' {$and} order by vieworder asc,id desc"); $back = array(); if ($list) { foreach ($list as $v) { $out[$v['id']] = $v; } $tree = new Tree($out); $tree->field = 'name'; $back = $tree->get($upid, 0, $addn); } return $back; }
private function del() { $id = Lua::get('id'); $db = $this->_get($id); $tables = Lua::get_more("select tablename from lua_model_table where model_id='{$id}'"); if ($tables) { foreach ($tables as $row) { Doo::db()->query("drop table " . $row['tablename']); } } Doo::db()->query("delete from lua_model_field where model_id='{$id}'"); Doo::db()->query("delete from lua_model_table where model_id='{$id}'"); Doo::db()->query("delete from lua_model where id='{$id}'"); Lua::write_log($this->user, '删除模型', "model_id={$id}<br />modelname=" . $db['modelname'], SYSNAME); Lua::admin_msg('提示信息', '成功删除', './model.htm'); }
private function _tree($id) { return Lua::get_more("select * from lua_" . $this->lua . " where systemname='" . SYSNAME . "' and upid='{$id}' order by vieworder asc,id desc"); }
private function export() { set_time_limit(0); $id = Lua::get('id'); $id = intval($id); $db = Lua::get_one("select * from lua_channel where id='{$id}'"); if (empty($db)) { Lua::admin_msg('错误提示', '所要导出的频道不存在'); } Doo::loadHelper('DooFile'); $fileManager = new DooFile(0777); Doo::cache('php')->hashing = false; $old_dir = LUA_ROOT . ADMIN_ROOT . '/cache/'; // 第一步 频道数据 Doo::cache('php')->set('channel', $db); // 第二步 模型数据 $list = Lua::get_more("select * from lua_model where cid='{$id}'"); Doo::cache('php')->set('model', $list); // 第三步 数据表数据 if ($list) { $dumpsql = ''; Doo::db()->query("SET SQL_QUOTE_SHOW_CREATE=1"); foreach ($list as $v) { $table = Lua::get_more("select * from lua_model_table where model_id='" . $v['id'] . "'"); Doo::cache('php')->set('model.' . $v['id'], $table); // 第四步 字段数据 if ($table) { foreach ($table as $k) { $field = Lua::get_more("select * from lua_model_field where model_id='" . $v['id'] . "' and table_id='" . $k['id'] . "'"); Doo::cache('php')->set('field.' . $v['id'] . '.' . $k['id'], $field); // 第五步 创建数据表 $r = Doo::db()->fetchRow("SHOW CREATE TABLE `" . $k['tablename'] . "`;"); $create = str_replace("\"", "\\\"", $r['Create Table']); $dumpsql .= "\r\nDoo::db()->query(\"" . $create . "\");\r\n"; // 第六步 导出数据 $data = Lua::get_more("select * from " . $k['tablename']); Doo::cache('php')->set('data.' . $k['id'], $data); } } } $fileManager->create($old_dir . 'create.php', '<?php' . $dumpsql . '?>'); } // 第七步 栏目数据 $list = Lua::get_more("select * from lua_category where systemname='" . $db['path'] . "'"); Doo::cache('php')->set('cate', $list); $list = Lua::get_more("select * from lua_piece where systemname='" . $db['path'] . "'"); Doo::cache('php')->set('piece', $list); // 第八步 打包数据 $new_dir = LUA_ROOT . $db['path'] . '/cache/update/'; $fileManager->copy($old_dir, $new_dir); // 第九步 删除数据 $fileManager->delete($old_dir, false); Lua::admin_msg('提示信息', '导出成功', './channel.htm'); }
private function _list($kindof) { return Lua::get_more("select * from lua_tpls where kindof='{$kindof}' and systemname='" . SYSNAME . "'"); }
private function _get() { return Lua::get_more("select * from lua_member_model where systemname='" . SYSNAME . "'"); }
private function any() { $tableid = Lua::get('tableid'); $db = array(); if ($tableid) { $db = $this->_table($tableid); } if ($db) { $url = "./piece.htm?action=any&tableid={$tableid}"; $fields = $this->_fields($db['tablename']); $count = Doo::db()->count("select count(*) from " . $db['tablename']); $tpp = 30; $limit = ($this->page - 1) * $tpp . ',' . $tpp; $pri = $this->_pri($fields); $list = Lua::get_more("select * from " . $db['tablename'] . " order by {$pri} desc limit " . $limit); $page = Lua::page($url, $this->page, $count, $tpp); } include Lua::display('piece_any', $this->dir); }
private function home() { $list = Lua::get_more("select * from lua_admin"); include Lua::display('admin', $this->dir); }