function get_one($id) { $this->db->close_cache(); $sql = " SELECT * "; $sql .= " FROM " . $this->db->prefix . "list "; $sql .= " WHERE id='" . $id . "'"; $sql .= " AND status='1' "; $rs = $this->db->get_one($sql); if (!$rs) { $this->db->open_cache(); return false; } if ($rs["thumb_id"]) { $tmp_thumb = sys_format_list($rs["thumb_id"], "img"); $rs["thumb"] = $tmp_thumb[0]; unset($tmp_thumb); } $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"]); $rs[$value["field"]] = $value["val"]; } } $this->db->open_cache(); return $rs; }
function phpok($var, $vartext = "") { if (!$var) { return false; } $app = sys_init(); $app->load_lib("phpok"); $app->phpok_lib->langid($_SESSION["sys_lang_id"]); $app->load_model("phpok"); $app->phpok_m->langid($_SESSION["sys_lang_id"]); $rs = $app->phpok_m->get_one_sign($var); if (!$rs) { return false; } $in_var = array(); if ($rs["vartext"]) { $varlist = explode(",", $rs["vartext"]); foreach ($varlist as $key => $value) { $in_var[$value] = $app->trans_lib->safe($value); } } $app->phpok_lib->set_rs($rs); //合并传过来的数组 if ($vartext) { if (is_array($vartext) && count($vartext) > 0) { $in_var = array_merge($in_var, $vartext); } else { $varlist = explode("&", $vartext); $v_list = array(); foreach ($varlist as $key => $value) { $v = explode("=", $value); $v_list[$v[0]] = $v[1]; } $in_var = array_merge($in_var, $v_list); } } if (!$rs["typetext"]) { return false; } $content = sys_eval($rs["typetext"], $in_var); $content = sys_format_content($content); //格式化内容代码信息 return array("title" => $rs["title"], "content" => $content); }
function get_one($id, $status = true, $pageid = 1) { $this->db->close_cache(); $sql = " SELECT m.* "; $sql .= " FROM " . $this->db->prefix . "list m "; $sql .= " WHERE m.id='" . $id . "'"; if ($status) { $sql .= " AND m.status='1' "; } $rs = $this->db->get_one($sql); if (!$rs) { $this->db->open_cache(); return false; } if ($rs["thumb_id"]) { $tmp_thumb = sys_format_list($rs["thumb_id"], "img"); $rs["thumb"] = $tmp_thumb[0]; unset($tmp_thumb); } //取得扩展字段信息,并对内容进行格式化 $sql = "SELECT e.field,e.val,m.input FROM " . $this->db->prefix . "list_ext e JOIN " . $this->db->prefix . "list l ON(e.id=l.id) JOIN " . $this->db->prefix . "module_fields m ON(l.module_id=m.module_id AND e.field=m.identifier) WHERE e.id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $rs[$value["field"]] = sys_format_list($value["val"], $value["input"]); } } unset($tmp_rs); $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"], $rs, $pageid); $rs[$value["field"]] = $value["val"]; } } $this->db->open_cache(); return $rs; }
function phpok($var, $vartext = "") { if (!$var) { return false; } $app = sys_init(); $app->load_lib("phpok"); $app->phpok_lib->langid($_SESSION["sys_lang_id"]); $app->load_model("phpok"); $app->phpok_m->langid($_SESSION["sys_lang_id"]); $rs = $app->phpok_m->get_one_sign($var); if (!$rs) { return false; } $in_var = array(); if ($rs["vartext"]) { $varlist = explode(",", $rs["vartext"]); foreach ($varlist as $key => $value) { $in_var[$value] = $app->trans_lib->safe($value); } } $app->phpok_lib->set_rs($rs); $app->phpok_lib->thumbtype($rs["inpic"]); //指定小图类型 //获取所有字段信息 if ($rs["mid"]) { $mid = $rs["mid"]; $in_var["mid"] = $rs["mid"]; } if ($rs["cid"]) { $cid = $rs["cid"]; $in_var["cid"] = $rs["cid"]; } //如果系统有设置主题标签 if ($rs["extsign"] && $rs["maxcount"] == 1) { $in_var["ts"] = $rs["extsign"]; } //合并传过来的数组 if ($vartext) { if (is_array($vartext) && count($vartext) > 0) { $in_var = array_merge($in_var, $vartext); } else { $varlist = explode("&", $vartext); $v_list = array(); foreach ($varlist as $key => $value) { $v = explode("=", $value); $v_list[$v[0]] = $v[1]; } $in_var = array_merge($in_var, $v_list); } } //执行内容信息 if ($rs["intype"] == "sql") { if (!$rs["typetext"]) { return false; } $get_type = $rs["maxcount"] == 1 ? "get_one" : "get_all"; $sql = sys_eval($rs["typetext"], $in_var); //参数替换值 //过滤html代码 $sql = str_replace("<div>", "", $sql); $sql = str_replace("</div>", "", $sql); return $app->phpok_lib->exec_sql($sql, $get_type); } elseif ($rs["intype"] == "sign") { //增加父级缓存信息数 if ($rs["datatype"] == "cate") { $cache_key = md5("cate:" . serialize($in_var)); $rslist = $app->cache_lib->cache_read($cache_key); if (!$rslist) { $rslist = $app->phpok_lib->cate_sql($in_var); if ($rslist) { $app->cache_lib->cache_write($cache_key, $rslist); } } } else { $cache_key = md5("list:" . serialize($in_var) . "-phpok-" . serialize($rs)); $rslist = $app->cache_lib->cache_read($cache_key); if (!$rslist) { $rslist = $app->phpok_lib->list_sql($in_var, $rs["maxcount"], $rs["orderby"]); if ($rslist) { $app->cache_lib->cache_write($cache_key, $rslist); } } } return $rslist; } else { if (!$rs["typetext"]) { return false; } $content = sys_eval($rs["typetext"], $in_var); $content = sys_format_content($content); //格式化内容代码信息 return array("title" => $rs["title"], "content" => $content); } }
function get_one($id, $ext = "") { $sql = "SELECT l.*,m.if_thumb _if_thumb,m.inpic _inpic,m.if_biz _if_biz,c.inpic _inpic2 FROM " . $this->db->prefix . "list l JOIN " . $this->db->prefix . "module m ON(l.module_id=m.id) LEFT JOIN " . $this->db->prefix . "cate c ON(l.cate_id=c.id) WHERE l.id='" . $id . "'"; if ($this->phpok_rs["pic_required"]) { $sql .= " AND l.thumb_id>0 "; } if ($this->phpok_rs["attr"]) { $sql .= " AND l." . $this->phpok_rs["attr"] . ">0 "; } $rs = $this->db->get_one($sql); if ($ext && is_array($ext)) { $thumb_type = $rs["inpic"]; } else { $thumb_type = $rs["_inpic2"] ? $rs["_inpic2"] : $rs["_inpic"]; //如果有图片配置 } $rs["picture"] = $this->get_picture_one($rs["thumb_id"], $thumb_type); if ($rs["_if_biz"]) { //[判断是否有电子商务代码] $sql = "SELECT * FROM " . $this->db->prefix . "list_biz WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_one($sql); if ($tmp_rs) { $rs = array_merge($rs, $tmp_rs); } } //取得扩展字段信息 $sql = "SELECT e.field,e.val,m.input FROM " . $this->db->prefix . "list_ext e JOIN " . $this->db->prefix . "list l ON(e.id=l.id) JOIN " . $this->db->prefix . "module_fields m ON(l.module_id=m.module_id AND e.field=m.identifier) WHERE e.id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $rs[$value["field"]] = sys_format_list($value["val"], $value["input"]); } } unset($tmp_rs); $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"]); $rs[$value["field"]] = $value["val"]; } } return $rs; }
function index_cate($cid) { $rs = $this->cate_m->get_one($cid); $this->phpok_seo($rs); $pageurl = list_url($rs, 0, true, false); // $module_rs = $this->module_m->get_one($rs["module_id"]); $this->tpl->assign("mid", $rs["module_id"]); $this->tpl->assign("cid", $cid); $this->tpl->assign("m_rs", $module_rs); $this->tpl->assign("cateid", $cid); //分类ID //指定模板文件 if ($rs["if_index"]) { $this->tplfile = $rs["tpl_index"] ? $rs["tpl_index"] : "index_" . $module_rs["identifier"]; //判断封页面 $create_html_type = "index"; } else { $this->tplfile = $rs["tpl_list"] ? $rs["tpl_list"] : "list_" . $module_rs["identifier"]; $create_html_type = "list"; } //分类未启用 if (!$rs["status"]) { sys_header(HOME_PAGE); } //分类下的模块未启用 if (!$module_rs["status"]) { sys_header(HOME_PAGE); } $rs["note"] = sys_format_content($rs["note"]); $this->tpl->assign("rs", $rs); //导航信息 $this->load_cate_msg($rs); //通过递归获取子分类ID $array = array($cid); $this->cate_m->get_sonid_array($array, $cid); //判断权限 $popedom = sys_user_popedom("read"); //获取阅读权限 if (!$popedom || !$popedom["category"]) { error($this->lang["not_popedom"], site_url("usercp")); } if ($popedom != "all") { $array = array_intersect($array, $popedom["category"]); if (!$array || count($array) < 1) { error($this->lang["not_popedom"], site_url("usercp")); } } $idstring = sys_id_string($array); if (!$idstring) { error($this->lang["not_popedom"], site_url("usercp")); } $this->idstring = $idstring; //如果存在分类至主题 if (!$module_rs["if_list"] && $module_rs["if_msg"]) { //读取当前第一个主题 $rslist = $this->cate_m->get_cate2sub($idstring, $rs["ordertype"]); $header_url = msg_url($rslist); sys_header($header_url); } //判断是否启用单页面信息 if ($rs["ifspec"]) { $newtpl = $rs["tpl_file"] ? $rs["tpl_file"] : "msg_" . $module_rs["identifier"] . "_spec"; $this->tpl->display($newtpl . "." . $this->tpl->ext); exit; } //如果启用封面页功能,将停止下一步操作的执行 if ($rs["if_index"]) { $this->tpl->display($this->tplfile . "." . $this->tpl->ext); } else { //读取列表数据 $this->list_m->set_cate($rs); $this->list_m->set_idstring($idstring); $this->list_m->set_module($module_rs); $total = $this->list_m->get_count_from_cate(); //取得总数量 $this->tpl->assign("total", $total); $psize = $rs["psize"] ? $rs["psize"] : SYS_PSIZE; $offset = $this->pageid > 0 ? ($this->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($this->tplfile . "." . $this->tpl->ext); } }