public function index() { if (IS_POST) { if (empty($_POST['catid'])) { $this->error("请选择数据来源"); } $map['catid'] = array('in', $_POST['catid']); $map['status'] = array('eq', 1); $article = M('Article'); $articlelist = $article->where($map)->order('create_time desc')->select(); $download = M('Download'); $downloadlist = $download->where($map)->order('create_time desc')->select(); $photo = M('Photo'); $photolist = $photo->where($map)->order('create_time desc')->select(); if (isset($_POST['sitemaptype'])) { $type = $_POST['sitemaptype']; } $sitemapstr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; switch ($type) { case 0: $sitemapstr .= "<urlset>\r\n"; break; case 1: $sitemapstr .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n"; break; } foreach ($articlelist as $value) { $sitemapstr .= "<url>\r\n"; $sitemapstr .= "<loc>Article/show?id=" . $value['id'] . "</loc>\r\n"; $sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n"; $sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n"; $sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n"; $sitemapstr .= "</url>\r\n\r\n"; } foreach ($downloadlist as $value) { $sitemapstr .= "<url>\r\n"; $sitemapstr .= "<loc>Download/show?id=" . $value['id'] . "</loc>\r\n"; $sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n"; $sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n"; $sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n"; $sitemapstr .= "</url>\r\n\r\n"; } foreach ($photolist as $value) { $sitemapstr .= "<url>\r\n"; $sitemapstr .= "<loc>Photo/show?id=" . $value['id'] . "</loc>\r\n"; $sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n"; $sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n"; $sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n"; $sitemapstr .= "</url>\r\n\r\n"; } $sitemapstr .= "</urlset>"; file_put_contents("../sitemap.xml", $sitemapstr); $this->success("sitemap在线生成完成"); } else { $cate = new CategoryModel(); $this->list = $cate->getMyCategory(); //加载栏目 $this->display(); } }
public function menu() { $this->checkUser(); if (isset($_SESSION[C('USER_AUTH_KEY')])) { //显示菜单项 $menu = array(); if (isset($_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]])) { //如果已经缓存,直接读取缓存 $menu = $_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]]; } else { //读取数据库模块列表生成菜单项 $node = M("Node"); $map['level'] = 2; $map['status'] = 1; $list = $node->where($map)->field('id,name,pid,title')->order('sort asc')->select(); $accessList = $_SESSION['_ACCESS_LIST']; foreach ($list as $key => $module) { if (isset($accessList[strtoupper(APP_NAME)][strtoupper($module['name'])]) || $_SESSION['administrator']) { //设置模块访问权限 $module['access'] = 1; $menu[$key] = $module; } } //缓存菜单访问 $_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]] = $menu; } if (isset($_GET['tag'])) { $tag = $_GET['tag']; if (0 == $tag) { $this->assign('menuTitle', '扩展功能'); } else { $mapid['id'] = array('eq', $tag); $node = M("Node"); $title = $list = $node->where($mapid)->getField('title'); $this->assign('menuTitle', $title); } $this->assign('menuTag', $tag); } else { $this->assign('menuTitle', '内容管理'); } $this->assign('menu', $menu); } //显示站点栏目 $cate = new CategoryModel(); $this->cate = $list = $cate->getMyCategory(); //加载栏目 $menu = $cate->getMyCategory1(); //加载栏目 $menu = arrToTree($menu, 0); $tree = outMenuNode($menu); $this->assign('tree', $tree); $this->display(); }