/** * 生成文章页面 */ function article() { //读取总数 if (!$_SESSION['article']['total']) { $_SESSION['article']['total'] = (int) sf::getModel("articles")->getTotal("`is_html` = 0"); $_SESSION['article']['num'] = 0; } //生成静态页面 if ($_SESSION['article']['total'] == 0 || $_SESSION['article']['num'] >= $_SESSION['article']['total']) { $_SESSION['article']['num'] = 0; $_SESSION['article']['total'] = 0; exit('{total:1,num:1}'); } $result = sf::getModel("articles")->selectAll("is_html = 0", '', 1); while ($article = $result->getObject()) { view::set("article", $article); view::apply("inc_body", "template/article_show"); $htmlStr = view::parse("template/page"); $path = WEBROOT . "/html/" . $article->getTypeStr(); if (!is_dir($path)) { sf::getLib("Files")->mDir($path); exit('{total:' . $_SESSION['article']['total'] . ',num:0}'); } sf::getLib("Files")->write($path . "/article-show-" . $article->getId() . ".html", $htmlStr); $article->setIsHtml(1); $article->save(); $_SESSION['article']['num']++; } exit('{total:' . $_SESSION['article']['total'] . ',num:' . $_SESSION['article']['num'] . '}'); }
function createmodel($table) { $tool = sf::getModel("tool"); $fields = $tool->showFields($table); $tools = new tools_model($table, $fields); $tools->generate(); }
public function getJson($addWhere = '', $addSql = '', $showMax = 12) { $sort = input::getInput("mix.sort") ? input::getInput("mix.sort") : 'id'; $order = input::getInput("mix.order") ? input::getInput("mix.order") : "asc"; $page = input::getInput("mix.page") ? input::getInput("mix.page") : 1; $rows = input::getInput("mix.rows") ? input::getInput("mix.rows") : 10; $db = sf::getLib("db"); if ($select) { $sql = $select . " "; } else { $sql = "SELECT * FROM `" . $this->table . "` "; } $addWhere && ($sql .= "WHERE " . $addWhere . " "); if ($addSql) { $sql .= $addSql . " "; } else { $sql .= " ORDER BY {$sort} {$order} "; } if (!router::get("totalnum" . $key)) { $query = $db->query($sql); $total = $db->num_rows($query); } else { $total = router::get("totalnum" . $key); } $sql .= "LIMIT " . $rows * ($page - 1) . "," . $rows; $query = $db->query($sql); while ($row = $db->fetch_array($query)) { $result[] = $this->fillObject($row)->toArray(); } return '{"total":' . $total . ',"rows":' . json_encode($result) . '}'; }
/** * 发送简历 */ function send() { if (input::getInput("post")) { $back = sf::getModel("backs"); $back->setSubject(input::getInput("post.subject")); $back->setUserName(input::getInput("post.user_name")); $back->setUserSex(input::getInput("post.user_sex")); $back->setUserAge(input::getInput("post.user_age")); $back->setUserDegree(input::getInput("post.user_degree")); $back->setIdcard(input::getInput("post.idcard")); $back->setUserPhone(input::getInput("post.user_phone")); $back->setUserIm(input::getInput("post.user_im")); $back->setUserEmail(input::getInput("post.user_email")); $back->setUserAddress(input::getInput("post.user_address")); $back->setPostCode(input::getInput("post.post_code")); $back->setWorkAt(input::getInput("post.work_at")); $back->setStudyList(input::getInput("post.study_list")); $back->setWorkList(input::getInput("post.work_list")); $back->setUpdatedAt(date("Y-m-d H:i:s")); $back->save(); $this->page_debug(lang::get("Has been saved!"), site_url("job/index")); } view::set("job", sf::getModel("jobs", input::getInput("get.id"))); view::apply("inc_body", "template/job_send"); view::display("template/page"); }
function main() { $data['user'] = sf::getModel("managers", input::getInput("session.userid")); view::set($data); view::apply("inc_body", "admin/main"); view::display("admin/page"); }
function getTotal($where = '') { $db = sf::getLib("db"); $sql = 'SELECT `id` FROM `' . $this->table . '` '; $where && ($sql .= 'WHERE ' . $where); $query = $db->query($sql); return $db->num_rows($query); }
function index() { $page = sf::getModel("pages")->showPage($this->type, input::getInput("get.id")); config::set('title', $page->getSubject()); view::set("page", $page); view::apply("inc_body", "template/about_us"); view::display("template/page"); }
function showFields($table = 'test') { $db = sf::getLib("db"); $query = $db->query("SELECT * FROM `{$table}` limit 1 "); while ($field = $db->fetch_fields($query)) { $fileds[] = $field; } return $fileds; }
/** * 查看产品 */ function show() { $product = sf::getModel("products", input::getInput("get.id")); //设置页面title config::set('title', $product->getSubject()); view::set("product", $product); view::apply("inc_body", "template/product_show"); view::display("template/page"); }
/** * 查看新闻 */ function show() { $article = sf::getModel("articles", input::getInput("get.id")); //设置页面title config::set('title', $article->getSubject()); view::set("article", $article); view::apply("inc_body", "template/article_show"); view::display("template/page"); }
function rebuildTree() { $data = $this->getFormatList(); $db = sf::getLib("db"); for ($i = 0, $n = count($data); $i < $n; $i++) { $result = array("left" => $data[$i]['left'], "right" => $data[$i]['right'], "head_str" => $data[$i]['HeadStr'], "level" => $data[$i]['level']); $db->update($result, "id = '" . $data[$i]['id'] . "'", $this->table); } }
function showPage($type = 'default', $id = 0) { $result = sf::getModel("pages", $id); if ($result->isNew()) { return sf::getModel("pages")->selectAll("`type_str` = '" . $type . "'", "ORDER BY is_default DESC", 1)->getObject(); } else { return $result; } }
/** * 删除数据 */ function delete() { if (input::getInput("post.select_id")) { $ids = implode("','", input::getInput("post.select_id")); } else { $ids = input::getInput("get.id"); } sf::getModel("Authorizations")->remove("`id` IN('" . $ids . "')"); $this->page_debug(lang::get("Has been deleted!"), getFromUrl()); }
/** * 删除数据 */ function delete() { if (input::getInput("post.select_id")) { $ids = implode("','", input::getInput("post.select_id")); } else { $ids = input::getInput("get.id"); } if (sf::getModel("Order_froms")->remove("`id` IN ('" . $ids . "')")) { $this->page_debug(lang::get("Has been deleted!"), getFromUrl()); } else { $this->page_debug(lang::get("Nothing to do!"), getFromUrl()); } }
public static function parse($tpl) { foreach (self::$viewTpl as $key => $file) { self::getContent($file, $key); } self::$content = self::getContent($tpl); if (config::get("auto_create_html", false)) { $file = $_SERVER[PATH_INFO]; if ($file) { $file = WEBROOT . $file; sf::getLib("Files")->write($file, self::$content); } } return self::$content; }
function getUserGroupName($dv = ',', $is_array = false) { $ids = explode(",", parent::getUserGroupIds()); foreach ((array) $ids as $id) { if ($id == '-1') { $result[] = '<s style="color:red">禁止使用</s>'; } else { $result[] = sf::getModel("user_groups", $id)->getUserGroupName(); } } if ($is_array) { return $result; } else { return implode($dv, $result); } }
function password() { $user = sf::getModel("users", input::getInput("session.userid")); if (input::getInput("post.password")) { if ($user->check(input::getInput("post.oldpassword"))) { $user->setUserPassword(input::getInput("post.password")); $user->setUpdatedAt(date("Y-m-d H:i:s")); $user->save(); $this->page_debug(lang::get("Has been changed!"), site_url("login/index")); } else { $msg = lang::get("Password is error!"); } } view::set("msg", $msg); view::set("user", $user); view::apply("inc_body", "template/user_password"); view::display("template/page"); }
function edit() { if (input::getInput("session.SafetyCode") != input::getInput("post.SafetyCode")) { $this->page_debug(lang::get("The safety code is error!"), getFromUrl()); } $book = sf::getModel("books", input::getInput("post.id") ? input::getInput("post.id") : input::getInput("get.id")); if (input::getInput("post.content")) { $book->setContent(input::getInput("post.content")); $book->setUserName(input::getInput("post.user_name")); $book->setUserPhone(input::getInput("post.user_phone")); $book->setUserQq(input::getInput("post.user_qq")); $book->setUserEmail(input::getInput("post.user_email")); $book->setUpdatedAt(date("Y-m-d H:i:s")); $book->save(); $this->page_debug(lang::get("Has been saved!"), getFromUrl()); } $this->page_debug(lang::get("Has been saved!"), getFromUrl()); }
/** * AJAX取得数据 */ function ajax() { $comment = sf::getModel("comments"); $type = input::getInput("post.type") ? input::getInput("post.type") : input::getInput("get.type"); if (input::getInput("post.content")) { if (input::getInput("session.SafetyCode") != input::getInput("post.SafetyCode")) { $this->page_debug(lang::get("The safety code is error!"), getFromUrl()); } $comment->setTypeStr(input::getInput("post.type")); $comment->setContent(input::getInput("post.content")); $comment->setUserId(input::getInput("session.userid")); $comment->setUserName(input::getInput("post.user_name") ? input::getInput("post.user_name") : 'Guest'); $comment->setUpdatedAt(date("Y-m-d H:i:s")); $comment->save(); } view::set("type", $type); view::set("pager", $comment->selectAll("`type_str` = '" . $type . "' ", "ORDER BY updated_at DESC", 5)); view::display("comment/comment"); }
public static function parse($tpl) { foreach (self::$viewTpl as $key => $file) { self::getContent($file, $key); } self::$content = self::getContent($tpl); if (config::get("auto_create_html", false)) { $file = trim($_SERVER['PATH_INFO'], '/'); //是否需要获取token if (config::get('token_open', false) && config::get('parse_mode', 'PATH_INFO') == 'PATH_INFO') { $info = explode("/", $file); $token = array_shift($info); $file = implode('/', $info); } if ($file) { $file = WEBROOT . '/' . $file; sf::getLib("Files")->write($file, self::$content); } } return self::$content; }
public function getPager($addWhere = '', $addSql = '', $showMax = 20, $select = '', $key = '', $form_vars = array()) { $db = sf::getLib("db"); if ($select) { $sql = $select . " "; } else { $sql = "SELECT * FROM `" . $this->table . "` "; } $addWhere && ($sql .= "WHERE " . $addWhere . " "); $addSql && ($sql .= $addSql . " "); if (!router::get("totalnum" . $key)) { $query = $db->query($sql); $total = $db->num_rows($query); } else { $total = router::get("totalnum" . $key); } $pager = sf::getLib("pager", $total, $showMax, $key, $form_vars); $sql .= "LIMIT " . $pager->getStartNum() . "," . $pager->getShowNum(); $query = $db->query($sql); $pager->setField($db->result_array($query)); $pager->setObject(clone $this); return $pager; }
function generate($id = 0) { $this->ads = sf::getModel("ads", $id); switch ($this->ads->getTypeStr()) { case 'image': return $this->getImageHtmlStr(); break; case 'text': return $this->getTextHtmlStr(); break; case 'flash': return $this->getFlashHtmlStr(); break; case 'magic': return $this->getMagicHtmlStr(); break; case 'code': return $this->getCodeHtmlStr(); break; default: return ''; break; } }
/** * иб╦═╝Ы└Щ */ function index() { if (input::getInput("post")) { $order = sf::getModel("order_froms"); $order->setSubject(input::getInput("post.subject")); $order->setNumber(input::getInput("post.number")); $order->setPrice(input::getInput("post.price")); $order->setUserId(input::getInput("session.userid")); $order->setUserName(input::getInput("post.user_name")); $order->setUserSex(input::getInput("post.user_sex")); $order->setUserMobile(input::getInput("post.user_mobile")); $order->setUserPhone(input::getInput("post.user_phone")); $order->setUserFax(input::getInput("post.user_fax")); $order->setUserEmail(input::getInput("post.user_email")); $order->setUserAddress(input::getInput("post.user_address")); $order->setNotebook(input::getInput("post.notebook")); $order->setUpdatedAt(date("Y-m-d H:i:s")); $order->save(); $this->page_debug(lang::get("Has been saved!"), getFromUrl()); } view::set("subject", input::getInput("get.subject")); view::apply("inc_body", "template/order_from"); view::display("template/page"); }
/** * 评论 */ function comment() { $comment = sf::getModel("comments"); $type = input::getInput("post.type") ? input::getInput("post.type") : 'common'; if (input::getInput("post.content")) { if (config::get('comment_must_login', false) && !input::getInput("session.userid")) { exit('{state:false,msg:"' . lang::get("You do not have permission to visit!") . '"}'); } $comment->setTypeStr($type); input::getInput("post.subject") && $comment->setSubject(input::getInput("post.subject")); input::getInput("post.content") && $comment->setContent(input::getInput("post.content")); $comment->setUserId(input::getInput("session.userid") ? input::getInput("session.userid") : 0); $comment->setUserName(input::getInput("session.username") ? input::getInput("session.username") : 'Guest'); $comment->setUpdatedAt(date("Y-m-d H:i:s")); if ($comment->save()) { exit('{state:true,msg:"' . lang::get('Has been save!') . '",subject:"' . $comment->getSubject() . '",content:"' . $comment->getContent() . '",username:"******",date:"' . $comment->getUpdatedAt("Y/m/d") . '"}'); } else { exit('{state:false,msg:"' . lang::get('Save error!') . '"}'); } } view::set("pager", $comment->selectAll("type_str = '" . $type . "' ", 'ORDER BY `updated_at` DESC', config::get('comment_show_max_in_page', 5))); $htmlStr = view::getContent("common/comment"); exit("{state:true,htmlStr:'" . $htmlStr . "'}"); }
public function delete($where = "") { if (!$this->id) { return false; } $db = sf::getLib("db"); $db->query("DELETE FROM `{$this->table}` WHERE `id` = '{$this->id}' {$where} "); return $db->affected_rows(); }
function show() { !input::getInput("get.id") && $this->page_debug(lang::get("Lack of parameters!")); header("location:" . site_path("up_files/" . sf::getModel("filemanager", input::getInput("get.id"))->getFilePath())); }
function getUserGroupName() { return sf::getModel("user_groups", parent::getUserGroupId())->getUserGroupName(); }
public function auth() { if (!sf::getModel("Authorizations")->isAuth()) { $this->page_debug(lang::get("You do not have permission to visit!"), getFromUrl()); } }
/** * 删除数据 */ function delete() { sf::getModel("pages", input::getInput("get.id"))->delete(); $this->page_debug(lang::get("Has been deleted!"), getFromUrl()); }
<li><img src="<?php echo site_path("up_files/" . $images[$i]); ?> " width="150" height="100" alt="" /><input name="images[]" type="checkbox" checked="checked" value="<?php echo $images[$i]; ?> " /></li> <?php } ?> </ul></td> </tr> <tr> <th align="center">详细描述</th> <td colspan="3" align="center"><?php echo sf::getPlugin("Fckeditor", "content", $product->getContent(), '100%', 600)->create(); ?> </td> </tr> <tr> <td colspan="4" align="center"><input type="submit" name="button" id="button" value="保存资料" /> <input name="id" type="hidden" id="id" value="<?php echo $product->getId(); ?> " /> <input name="fromUrl" type="hidden" id="fromUrl" value="<?php echo getFromUrl(); ?> " /></td> </tr> </form>