function config($rs) { $app = sys_init(); if ($rs["ext"]) { $rs["ext"] = unserialize($rs["ext"]); } $app->file_lib->vi($rs, ROOT_PLUGIN . $rs["identifier"] . "/config.php", "config"); }
function get_one($currency = "RMB") { $app = sys_init(); if ($app->currency->{$currency}) { return $app->currency->{$currency}; } else { $sql = "SELECT * FROM " . $app->db->prefix . "currency WHERE code='" . $currency . "'"; $rs = $this->db->get_one($sql); if (!$rs) { return false; } $app->currency($rs, $currency); return $rs; } }
function load_setting() { $this->app = sys_init(); if ($this->app->db->dbcache) { $this->iscache = true; } $this->cache_type = $this->app->db->cache_type; $this->cache_server = $this->app->db->cache_server; $this->cache_port = $this->app->db->cache_port; $this->cache_time = $this->app->db->cache_time; if ($this->cache_type == "sql") { $this->app->load_model("cache_model", true); //加载SQL里的缓存 } }
function phpok() { $rs = $this->config["ext"] ? $this->config["ext"] : array(); $width = $rs["width"] ? $rs["width"] : 330; $height = $rs["height"] ? $rs["height"] : 190; $phpok = $rs["phpok"] ? $rs["phpok"] : ""; //取得插件扩展配置 $app = sys_init(); $swfurl = "plugins/" . $this->config["identifier"] . "/templates/player.swf"; $xmlfile = rawurlencode($app->url("plugin", "plugin=picplay&phpok=" . $phpok, "&")); $app->tpl->assign("swfurl", $swfurl); $app->tpl->assign("xmlfile", $xmlfile); $app->tpl->assign("width", $width); $app->tpl->assign("height", $height); $app->tpl->plugin($this->config["identifier"], "templates/play.html"); }
function format_subject($val) { $val = sys_id_string($val, ",", "intval"); if (!$val) { return false; } $app = sys_init(); $sql = "SELECT l.*,c.cate_name,u.filename picture FROM " . $this->db->prefix . "list l LEFT JOIN " . $this->db->prefix . "cate c ON(l.cate_id = c.id) "; $sql .= " LEFT JOIN " . $this->db->prefix . "upfiles u ON (l.thumb_id=u.id) "; $sql .= " WHERE l.id IN(" . $val . ")"; $rslist = $this->db->get_all($sql, "id"); if (!$rslist) { return false; } $sql = "SELECT * FROM " . $this->db->prefix . "list_ext WHERE id IN(" . $val . ")"; $tmplist = $this->db->get_all($sql); if (!$tmplist) { $tmplist = array(); } foreach ($tmplist as $key => $value) { $rslist[$value["id"]][$value["field"]] = $value["val"]; } unset($tmplist); $sql = "SELECT * FROM " . $this->db->prefix . "list_c WHERE id IN(" . $val . ")"; $tmp_rs = $this->db->get_all($sql); if (!$tmp_rs) { $tmp_rs = array(); } foreach ($tmp_rs as $key => $value) { $rslist[$value["id"]][$value["field"]] = $value["val"]; } unset($tmp_rs); $list = array(); foreach ($rslist as $key => $value) { $list[] = $value; } unset($rslist); return $list; }
function __construct() { $this->app = sys_init(); }
function sys_app($var) { $app = sys_init(); return $app->{$var}; }
function auto_app() { $app = sys_init(); $this->app = $app; }
function sys_search($mid = 0, $cateid = 0, $keywords = "", $ext = "", $tplfile = "", $bgcolor = "") { if (is_array($ext)) { $tmp = array(); foreach ($ext as $key => $value) { $tmp[] = "ext_keywords[" . $key . "]=" . rawurlencode($value); } $ext = implode("&", $tmp); } $app = sys_init(); $html = "<script type='text/javascript'>\n"; $html .= "function __" . $mid . "__iFrameHeight() {\n\t"; $html .= "var ifm= document.getElementById('__" . $mid . "__iframepage');\n\t"; $html .= "var subWeb = document.frames ? document.frames['__" . $mid . "__iframepage'].document : ifm.contentDocument;\n\t"; $html .= "if(ifm != null && subWeb != null) {\n\t\t"; $html .= "ifm.height = subWeb.body.scrollHeight + 30;\n\t"; $html .= "}\n}\n</script>\n"; $url_ext = "mid=" . $mid; if ($cateid) { $url_ext .= "&cateid=" . $cateid; } if ($bgcolor) { $url_ext .= "&bgcolor=" . rawurlencode($bgcolor); } if ($keywords) { $url_ext .= "&keywords=" . rawurlencode($keywords); } if ($tplfile) { $url_ext .= "&tplfile=" . rawurlencode($tplfile); } $url_ext .= "&randtime=" . time() . rand(0, 100); $iframe_url = $app->url("search,iframe", $url_ext); if ($ext) { $iframe_url .= $ext; } $html .= "<iframe src='" . $iframe_url . "' id='__" . $mid . "__iframepage' name='__" . $mid . "__iframepage' frameBorder=0 scrolling=no width='100%' onLoad='__" . $mid . "__iFrameHeight()' style='z-index:50'></iframe>"; return $html; }
function phpok_star($id) { if (!$id) { return false; } $app = sys_init(); $app->load_model("reply"); $rslist = $app->reply_m->getlist_star($id); $rs = array(0, 1, 2, 3, 4, 5); $mylist = array(); foreach ($rs as $key => $value) { if ($rslist[$value]) { $mylist[$value] = $rslist[$value]["mycount"]; } else { $mylist[$value] = 0; } } return $mylist; }
function format_edit_msg($msg) { if (!$msg) { return false; } if (function_exists("base_url")) { $url = base_url(); } else { $app = sys_init(); if ($app->config["siteurl"]) { $url = $app->config["siteurl"]; } else { return false; } } $imgArray = array(); preg_match_all("/src=[\"|'| ]((.*)\\.(gif|jpg|jpeg|bmp|png|swf))/isU", $msg, $imgArray); $imgArray = array_unique($imgArray[1]); $count = count($imgArray); if ($count < 1) { return $msg; } foreach ($imgArray as $key => $value) { $value = trim($value); if (strpos($value, "http://") === false && $value) { $msg = str_replace($value, $url . $value, $msg); } } return $msg; }
function cache_clear() { $app = sys_init(); return $app->cache_lib->cache_clear(); }
function __construct() { $this->app = sys_init(); //执行读取list类 $this->app->load_model("list_model", true); }
function format_video_subject($val) { $app = sys_init(); $app->load_model("msg"); return $app->msg_m->get_one($val); }
function page_rewrite($url, $total, $ifarray = false, $ifselect = true) { if (!$this->lang) { $this->langs(); } if (!$total || !$url) { return false; } $app = sys_init(); //$urlend = ".html"; $url = substr($url, 0, -5); $pageid = $this->pageid; if ($pageid < 1) { $pageid = 1; } $half_page = $this->half; #[共有页数] $total_page = intval($total / $this->psize); if ($total % $this->psize) { $total_page++; #[判断是否存余,如存,则加一 } #[判断如果分页ID超过总页数时] if ($pageid > $total_page) { $pageid = $total_page; } #[Html] $array_m = 0; if ($pageid > 0) { $returnlist[$array_m]["url"] = $url . ".html"; $returnlist[$array_m]["name"] = $this->lang["home"]; $returnlist[$array_m]["status"] = 0; if ($pageid > 1) { $array_m++; $returnlist[$array_m]["url"] = $pageid > 2 ? $url . "-" . ($pageid - 1) . ".html" : $url . ".html"; $returnlist[$array_m]["name"] = $this->lang["prev"]; $returnlist[$array_m]["status"] = 0; } } if ($half_page > 0) { #[添加中间项] for ($i = $pageid - $half_page, $i > 0 || ($i = 0), $j = $pageid + $half_page, $j < $total_page || ($j = $total_page); $i < $j; $i++) { $l = $i + 1; $array_m++; $returnlist[$array_m]["url"] = $l == 1 ? $url . ".html" : $url . "-" . $l . ".html"; $returnlist[$array_m]["name"] = $l; $returnlist[$array_m]["status"] = $l == $pageid ? 1 : 0; } } if ($half_page < 1) { $half_page = 5; } #[添加尾项] if ($pageid < $total_page) { $array_m++; $t_pageid = $pageid + 1 > 1 ? $pageid + 1 : "index"; $returnlist[$array_m]["url"] = $pageid + 1 > 1 ? $url . "-" . ($pageid + 1) . ".html" : $url . ".html"; $returnlist[$array_m]["name"] = $this->lang["next"]; $returnlist[$array_m]["status"] = 0; } $array_m++; if ($pageid != $total_page) { $returnlist[$array_m]["url"] = $url . "-" . $total_page . ".html"; $returnlist[$array_m]["name"] = $this->lang["last"]; $returnlist[$array_m]["status"] = 0; } if ($ifarray) { return $returnlist; } #[组织样式] $msg = "<table class='pagelist' cellpadding='0' cellspacing='1'><tr><td class='n'>" . $this->psize . "/" . $total . "</td>"; foreach ($returnlist as $key => $value) { if ($value["status"]) { $msg .= "<td class='m'>" . $value["name"] . "</td>"; } else { $msg .= "<td class='n'><a href='" . $value["url"] . "'>" . $value["name"] . "</a></td>"; } } $msg .= "</tr></table>"; unset($returnlist); return $msg; }
function sys_user_popedom($chktype = "read") { $app = sys_init(); $app->load_model("usergroup"); if ($_SESSION["user_id"]) { $rs = $_SESSION["group_id"] ? $app->usergroup_m->get_one($_SESSION["group_id"]) : $app->usergroup_m->get_default(); if (!$rs) { return false; } } else { $rs = $app->usergroup_m->get_guest(); if (!$rs) { return false; } } //格式化权限 $popedom = ""; if ($chktype == "read") { $popedom = $rs["popedom_read"]; } if ($chktype == "post") { $popedom = $rs["popedom_post"]; } if ($chktype == "reply") { $popedom = $rs["popedom_reply"]; } if (!$popedom) { return false; } if ($popedom == "all") { return $popedom; } //格式化权限 $array = $m = $c = array(); $popedom = sys_id_list($popedom); foreach ($popedom as $key => $value) { $tmp = explode(":", $value); if ($tmp[0] == "m") { $m[] = $tmp[1]; } else { $c[] = $tmp[1]; } } unset($popedom); if ((!$m || count($m) < 1) && (!$c || count($c) < 1)) { return false; } $popedom = array(); $popedom["module"] = $m ? $m : false; $popedom["category"] = $c ? $c : false; return $popedom; }
function sys_rtype($type = "") { $app = sys_init(); if ($type == "tpl") { error($app->lang["no_popedom"]); } elseif ($type == "ajax") { exit($app->lang["no_popedom"]); } else { return false; } }
function phpok_c($id, $field = "content", $pageid = 1, $is_span = true) { if (!$id || !$field) { return false; } $app = sys_init(); $app->load_model("msg"); $content = $app->msg_m->get_c($id, $field); if (!$content) { return false; } $content = preg_replace("/<div/isU", "<p", $content); $content = preg_replace("/<\\/div>/isU", "</p>", $content); //格式化内容 $rslist = explode("[:page:]", $content); $content_count = count($rslist); if ($content_count < 2) { return $content; } unset($content); $html = "<div class='content-page' align='center'>"; $html .= "<table cellpadding='0' cellspacing='0'><tr>"; foreach ($rslist as $key => $value) { $html .= '<td>'; $html .= '<a href="javascript:phpok_content_page(' . $id . ',\'' . $field . '\',' . ($key + 1) . ');void(0);"'; if ($key + 1 == $pageid) { $html .= ' class="now"'; } $html .= '>' . ($key + 1) . "</a>"; $html .= "</td>"; } $html .= "</tr></table>"; $html .= "</div>"; $keyid = $pageid - 1; $content = $rslist[$keyid] ? $rslist[$keyid] : $rslist[$content_count - 1]; if ($is_span) { return "<span id='phpok_c_" . $field . "'>" . $content . $html . "</span>"; } else { return $content . $html; } }
function load_plugin($string, $rs = "", $is_return = false) { if (!$string) { return false; } $string = "[" . PLUGIN_NAME . "]" . $string . "[/" . PLUGIN_NAME . "]"; $app = sys_init(); $app->load_model("plugin_model", true); $rslist = $app->plugin_model->get_all($string); if (!$rslist) { return false; } $tmplist = array(); $is_html = false; foreach ($rslist as $key => $value) { //获取扩展插件 $hooks = str_replace(array("\t", "\r"), "", $value["hooks"]); $hooks_array = explode("\n", $hooks); $action = "content"; foreach ($hooks_array as $k => $v) { $tmp_v = str_replace($string, "", $v); if ($tmp_v != $v) { $action = $tmp_v ? $tmp_v : "content"; //break; } } $myplugin = $app->plugin($value["identifier"]); $methods = get_class_methods($myplugin); if (!in_array($action, $methods)) { $action = "content"; } $mytmp = $myplugin->{$action}($rs); if (!is_int($mytmp) && !is_bool($mytmp)) { $is_html = true; $tmplist[] = $mytmp; } } $content = ""; if (count($tmplist) > 0) { $content = implode("", $tmplist); } if ($is_return) { return $content; } else { $app->tpl->assign("plugin_html", $content); } return true; }