function index_f() { $id = $this->trans_lib->int("id"); $ts = $this->trans_lib->safe("ts"); //增加分页 $pageid = $this->trans_lib->int(SYS_PAGEID); if ($pageid < 1) { $pageid = 1; } $this->tpl->assign("pageid", $pageid); if (!$id && !$ts) { error($this->lang["msg_not_id"], site_url("index")); } if ($id) { $rs = $this->msg_m->get_one($id, true, $pageid); } else { $rs = $this->msg_m->get_one_fromtype($ts, $_SESSION["sys_lang_id"], $pageid); } if (!$rs) { error($this->lang["msg_not_rs"], site_url("index")); } //判断阅读权限 $popedom = sys_user_popedom("read"); //获取阅读权限 if ($rs["cate_id"]) { if (!$popedom || !$popedom["category"] || $popedom != "all" && !in_array($rs["cate_id"], $popedom["category"])) { error($this->lang["not_popedom"], site_url("usercp")); } } else { if (!$popedom || !$popedom["module"] || $popedom != "all" && !in_array($rs["module_id"], $popedom["module"])) { error($this->lang["not_popedom"], site_url("usercp")); } } //判断如果语言包不一样,自动刷新一遍 if ($rs["langid"] != $_SESSION["sys_lang_id"]) { $_SESSION["sys_lang_id"] = $rs["langid"]; sys_header(site_url("msg", "id=" . $rs["id"])); } //如果存在分类 $this->subject = $rs["title"]; $this->load_module_msg($rs["module_id"]); if ($rs["cate_id"]) { $this->load_cate_msg($rs["cate_id"]); } $this->phpok_seo($rs); $id = $rs["id"]; $this->tpl->assign("id", $id); $this->tpl->assign("rs", $rs); $this->tpl->assign("cateid", $rs["cate_id"]); //读取自定义配置字段的数据信息 if ($rs["tplfile"]) { $this->tplfile = $rs["tplfile"]; } //更新点击率 $this->msg_m->update_hits($rs["id"]); $this->tpl->display($this->tplfile . "." . $this->tpl->ext); }
function index_module($mid) { //判断权限 $popedom = sys_user_popedom("read"); //获取阅读权限 if (!$popedom || !$popedom["module"]) { error($this->lang["not_popedom"], site_url("usercp")); } if ($popedom != "all" && !in_array($mid, $popedom["module"])) { error($this->lang["not_popedom"], site_url("usercp")); } $rs = $this->module_m->get_one($mid); $this->tpl->assign("mid", $mid); $this->tpl->assign("m_rs", $rs); $this->phpok_seo($rs); $this->tplfile = "list_" . $rs["identifier"]; if (!$rs["status"]) { error($this->lang["module_is_close"], HOME_PAGE); } //判断是否有分类,且分类路至主题 if (!$rs["if_list"] && $rs["if_msg"]) { $msg_rs = $this->module_m->get_module_sub_one($mid); $header_url = msg_url($msg_rs); sys_header($header_url); } else { $list_rs = $this->module_m->get_module_cateid($mid); if ($list_rs) { $header_url = list_url($list_rs); sys_header($header_url); exit; } $sitetitle = $rs["title"]; $this->tpl->assign("sitetitle", $sitetitle); $leader[0] = array("title" => $rs["title"]); $this->tpl->assign("leader", $leader); //读取列表信息 $pageid = $this->trans_lib->int(SYS_PAGEID); $pageurl = module_url($rs, 0, true, false); //读取列表数据 $this->list_m->set_module($rs); $this->list_m->langid($_SESSION["sys_lang_id"]); $total = $this->list_m->get_count_from_cate(); //取得总数量 $this->tpl->assign("total", $total); $psize = $rs["psize"] ? $rs["psize"] : SYS_PSIZE; $offset = $pageid > 0 ? ($pageid - 1) * $psize : 0; $this->page_lib->set_psize($psize); $pagelist = $this->page_lib->page_www($pageurl, $total, true); //分页数组 $this->tpl->assign("pagelist", $pagelist); $rslist = $this->list_m->get_list_from_cate($offset, $psize); $this->tpl->assign("rslist", $rslist); $this->tpl->display("list_" . $rs["identifier"] . "." . $this->tpl->ext); } }
function set_f() { //返回上一级网址 $referurl = $this->trans_lib->safe("referurl"); $referurl = $referurl ? $referurl : $_SERVER["HTTP_REFERER"]; if (!$referurl) { $referurl = $this->url(); } $iframe = $this->trans_lib->safe("iframe"); if ($iframe == "true") { $referurl = ""; } $this->tpl->assign("referurl", $referurl); //现在判断是否有权限 $no_popedom = $this->lang["post_not_popedom"]; //没有权限的提示语 $popedom = sys_user_popedom("post"); //获取发布权限 if (!$popedom) { error($no_popedom, $referurl); } //判断是否有主题ID $id = $this->trans_lib->int("id"); if ($id) { //锁定主题,限制非会员不允许编辑主题 if (!$_SESSION["user_id"]) { error($no_popedom, $referurl); } $rs = $this->post_m->get_one($id); //获取主题为空时提示错误! if (!$rs) { error($this->lang["msg_not_rs"], $referurl); } //判断会员和发布人是否一致,不一致禁止执行操作 if ($rs["author"] != $_SESSION["user_name"] || $rs["author_type"] != "user") { error($no_popedom, $referurl); } $this->tpl->assign("rs", $rs); $this->tpl->assign("id", $id); $module_id = $rs["module_id"]; $cate_id = $rs["cate_id"]; } else { $module_id = $this->trans_lib->int("module_id"); if (!$module_id) { $ms = $this->trans_lib->safe("ms"); $module_id = $this->module_m->get_mid_from_code($ms); if (!$module_id) { error($this->lang["post_not_mid"], $referurl); } } $cate_id = $this->trans_lib->int("cate_id"); } $this->tpl->assign("module_id", $module_id); $m_rs = $this->_load_moduel($module_id); //读取内容 $ifcate = $m_rs["if_cate"] ? true : false; $this->tpl->assign("ifcate", $ifcate); if ($ifcate) { //判断无分类权限时,禁止执行操作 if (!$popedom["category"] && !$id) { error($no_popedom, $referurl); } $condition = "c.id IN(" . sys_id_string($popedom["category"], ",", "intval") . ") "; $chk_return = $this->cate_m->get_catelist($module_id, $condition); if (!$chk_return) { //如果同时没有指定ID,那么返回无权限 if (!$id) { error($no_popedom, $referurl); } $cate_rs = $this->cate_m->get_one($cate_id); $cate_html = "<select name='cate_id' id='cate_id'><option value='" . $cate_id . "'>" . $cate_rs["cate_name"] . "</option></select>"; } else { $cate_html = $this->cate_m->html_select("cate_id", $cate_id, $this->lang["category_select"]); } $this->tpl->assign("cate_html", $cate_html); } else { //无主题时,如果也没有相匹配的模块ID,则提示无权限操作! if (!$popedom["module"] && !$id) { error($no_popedom, $referurl); } if (!in_array($module_id, $popedom["module"]) && !$id) { error($no_popedom, $referurl); } } $ext_list = $this->module_m->fields_index($module_id); if ($ext_list && is_array($ext_list) && count($ext_list) > 0) { $optlist = array(); $this->load_lib("phpok_input"); $extlist_must = $extlist_need = array(); foreach ($ext_list as $key => $value) { if (!$value["if_post"] && !$value["if_guest"]) { continue; } $_field_name = $value["identifier"]; $value["default_val"] = $rs[$_field_name] ? $rs[$_field_name] : $value["default_val"]; $extlist = $this->phpok_input_lib->get_html($value); $extlist_must[] = $extlist; if ($value["input"] == "opt") { $optlist[] = $value; } $extlist_need[] = $value; } $this->tpl->assign("extlist_must", $extlist_must); $this->tpl->assign("optlist", $optlist); $this->tpl->assign("extlist", $extlist_need); } $tplfile = "post_" . $m_rs["identifier"]; if ($iframe == "true") { $tplfile = "iframe_post"; $chk_tplfile = ROOT . $this->tpl->tpldir . "/iframe_post." . $this->tpl->ext; $bgcolor = $this->trans_lib->safe("bgcolor"); if (!$bgcolor) { $bgcolor = "#FFF"; } $this->tpl->assign("bgcolor", $bgcolor); //返回地址 $goback = $this->trans_lib->safe("_goback"); if (!$goback) { $goback = $this->url("list", "ms=" . $m_rs["identifier"]); } $this->tpl->assign("_goback", $goback); } else { $chk_tplfile = ROOT . $this->tpl->tpldir . "/" . $tplfile . "." . $this->tpl->ext; } //取得参数外的其他扩展数据 $_ext = array($this->config->c, $this->config->f, $this->config->d, "ms", "module_id", "cate_id", "id"); foreach ($_GET as $key => $value) { if (!in_array($key, $_ext) && $value) { $value = $this->trans_lib->safe($key); $this->tpl->assign($key, $value); } } if (file_exists($chk_tplfile)) { $this->tpl->display($tplfile . "." . $this->tpl->ext); } else { $this->tpl->display("post_set." . $this->tpl->ext); } }