⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 post.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
            return false;        }        if ($post->isTopic()) {            $sql = "UPDATE " . $this->db->prefix("bb_topics") . " SET approved = 1 WHERE topic_id = " . $post->getVar('topic_id');            if (!$result = $this->db->queryF($sql)) {                echo "<br />approve post error:" . $sql;                return false;            }            $sql = sprintf("UPDATE %s SET topic_last_post_id = %u, topic_time = %u WHERE topic_id = %u", $this->db->prefix("bb_topics"), $post_id, time(), $post->getVar('topic_id'));            if (!$result = $this->db->queryF($sql)) {            }        } else {            $sql = "UPDATE " . $this->db->prefix("bb_topics") . " SET topic_replies=topic_replies+1, topic_last_post_id = " . $post_id . ", topic_time = " . time() . " WHERE topic_id =" . $post->getVar('topic_id') . "";            if (!$result = $this->db->queryF($sql)) {            }        }        if ($post->isTopic()) $increment = " forum_topics = forum_topics+1, ";        else $increment = '';        $sql = sprintf("UPDATE %s SET forum_posts = forum_posts+1, " . $increment . " forum_last_post_id = %u WHERE forum_id = %u", $this->db->prefix("bb_forums"), $post_id, $post->getVar('forum_id'));        $result = $this->db->queryF($sql);        if (!$result) {        } ;        $member_handler = &xoops_gethandler('member');        $poster = &$member_handler->getUser($post->getVar('uid'));        if (is_object($poster)) {	        $poster->setVar('posts',$poster->getVar('posts') + 1);	        $res=$member_handler->insertUser($poster, true);            //$res = $poster->incrementPost(); 	// In order to make this work, we have to set            									//$_SERVER['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD'] = 'POST';            unset($poster);        }        return true;    }    function unApprove($post_id)    {        $sql = "UPDATE " . $this->db->prefix("bb_posts") . " SET approved = 0 WHERE post_id = $post_id";        if (!$result = $this->db->queryF($sql)) {            echo "<br />unapprove post error:" . $sql;            return false;        }        return true;    }    function insertnewsubject($topic_id, $subject)    {        $sql = "UPDATE " . $this->db->prefix("bb_topics") . " SET topic_subject = " . intval($subject) . " WHERE topic_id = $topic_id";        $result = $this->db->queryF($sql);        if (!$result) {            echo "<br />update topic subject error:" . $sql;            return false;        }        return true;    }    function insert(&$post)    {        global $xoopsUser, $xoopsConfig;        if (!$post->isDirty()) return true;        if (!$post->cleanVars())return false;        $post->prepareVars();        foreach ($post->cleanVars as $k => $v) {            ${$k} = $v;        }        if ($post->isNew()) {            $post_time = time();            if (empty($topic_id)) {                $topic_id = $this->db->genId($this->db->prefix("bb_topics") . "_topic_id_seq");                $sql = "INSERT INTO " . $this->db->prefix("bb_topics") . "                			(topic_id,  topic_title, topic_poster, forum_id,  topic_time, poster_name,  approved)                        VALUES                        	($topic_id, $subject,    $uid,        $forum_id, $post_time, $poster_name, $approved)";                if (!$result = $this->db->query($sql)) {                    $post->deleteAttachment();                    echo "<br />Insert topic error:" . $sql;                    return false;                }                if ($topic_id == 0) {                    $topic_id = $this->db->getInsertId();                }                $post->setVar('topic_id', $topic_id);            }            $pid = isset($pid)?intval($pid):0;            $post_id = $this->db->genId($this->db->prefix("bb_posts") . "_post_id_seq");            $sql = "INSERT INTO " . $this->db->prefix("bb_posts") . "            			( post_id,  pid,  topic_id,  forum_id,  post_time,  uid,  poster_ip,  poster_name,  subject,  dohtml,  dosmiley,  doxcode,  doimage,  dobr, icon,  attachsig,  attachment,  approved,  post_karma, require_reply)					VALUES                    	($post_id, $pid, $topic_id, $forum_id, $post_time, $uid, $poster_ip, $poster_name, $subject, $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $icon, $attachsig, $attachment, $approved, $post_karma, $require_reply)";            if (!$result = $this->db->query($sql)) {                echo "<br />Insert post error:" . $sql;                return false;            }            if ($post_id == 0) $post_id = $this->db->getInsertId();            $sql = sprintf("INSERT INTO %s (post_id, post_text) VALUES (%u, %s)", $this->db->prefix("bb_posts_text"), $post_id, $post_text);            if (!$result = $this->db->query($sql)) {                $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("bb_posts"), $post_id);                $this->db->query($sql);                return false;            }            if ($approved) {                if ($pid == 0) {                    $sql = sprintf("UPDATE %s SET topic_last_post_id = %u, topic_time = %u WHERE topic_id = %u", $this->db->prefix("bb_topics"), $post_id, $post_time, $topic_id);                    if (!$result = $this->db->query($sql)) {                    }                } else {                    $sql = "UPDATE " . $this->db->prefix("bb_topics") . " SET topic_replies=topic_replies+1, topic_last_post_id = " . $post_id . ", topic_time = $post_time WHERE topic_id =" . $topic_id . "";                    if (!$result = $this->db->query($sql)) {                    }                }                if (is_object($xoopsUser)) {                    $xoopsUser->incrementPost();                }	            if ($post->isTopic()) $increment = " forum_topics = forum_topics+1, ";	            else $increment = '';	            $sql = sprintf("UPDATE %s SET forum_posts = forum_posts+1, " . $increment . " forum_last_post_id = %u WHERE forum_id = %u", $this->db->prefix("bb_forums"), $post_id, $forum_id);	            $result = $this->db->query($sql);	            if (!$result) {	            } ;            }            $post->setVar('post_id', $post_id);        } else {            if ($post->isTopic()) {                $sql = "UPDATE " . $this->db->prefix("bb_topics") . " SET topic_title = $subject, approved = $approved WHERE topic_id = " . $post->getVar('topic_id');                if (!$result = $this->db->query($sql)) {                    echo "<br />update topic error:" . $sql;                    return false;                }            }            $sql = "UPDATE " . $this->db->prefix("bb_posts") . " SET subject = $subject, dohtml= $dohtml, dosmiley= $dosmiley, doxcode = $doxcode, doimage = $doimage, dobr = $dobr, icon= $icon, attachsig= $attachsig, attachment= $attachment, approved = $approved, post_karma = $post_karma, require_reply = $require_reply WHERE post_id = " . $post->getVar('post_id');            $result = $this->db->query($sql);            if (!$result = $this->db->query($sql)) {                echo "<br />update post error:" . $sql;                return false;            }            $post_id = $post->getVar('post_id');            $sql = "UPDATE " . $this->db->prefix("bb_posts_text") . " SET post_text = $post_text, post_edit = $post_edit WHERE post_id = " . $post->getVar('post_id');            $result = $this->db->query($sql);            if (!$result) {                echo "<br />update post text error:" . $sql;                return false;            }        }        return $post->getVar('post_id');    }    function delete(&$post, $isDeleteOne = true)    {        global $xoopsModule, $xoopsModuleConfig;        $sql = "SELECT * FROM " . $this->db->prefix("bb_posts") . " WHERE post_id= " . $post->getVar('post_id');        if (!$result = $this->db->query($sql)) {            return false;        }        if ($post->isTopic()) $isDeleteOne = false;        include_once(XOOPS_ROOT_PATH . "/class/xoopstree.php");        $mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid");        $arr = $mytree->getAllChild($post->getVar('post_id'));        if ($isDeleteOne) {            $arr = $mytree->getFirstChild($post->getVar('post_id'));            for ($i = 0; $i < count($arr); $i++) {                $sql = "UPDATE " . $this->db->prefix("bb_posts") . " SET pid = " . $post->getVar('pid') . " WHERE post_id = " . $arr[$i]['post_id'] . " AND pid=" . $post->getVar('post_id');                if (!$result = $this->db->query($sql)) {                    echo "<br />Could not update post " . $arr[$i]['post_id'] . "<br />" . $sql . " ; original pid:" . $arr[$i]['pid'];                }            }        } else {            $arr = $mytree->getAllChild($post->getVar('post_id'));            for ($i = 0; $i < count($arr); $i++) {                $childpost = &$this->create(false);                $childpost->setVar('post_id', $arr[$i]["post_id"]);                $this->delete($childpost);                unset($childpost);            }        }        $post->deleteAttachment();        $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("bb_posts"), $post->getVar('post_id'));        if (!$result = $this->db->query($sql)) {            return false;        }        $sql = sprintf("DELETE FROM %s WHERE post_id = %u", $this->db->prefix("bb_posts_text"), $post->getVar('post_id'));        if (!$result = $this->db->query($sql)) {            echo "Could not remove posts text for Post ID:" . $post->getVar('post_id') . ".<br />";        }        if ($post->getVar('uid')) {            $sql = sprintf("UPDATE %s SET posts=posts-1 WHERE uid = %u", $this->db->prefix("users"), $post->getVar('uid'));            if (!$result = $this->db->query($sql)) {                echo "Could not update user posts.";            }        }        if ($post->isTopic()) {            $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $this->db->prefix("bb_topics"), $post->getVar('topic_id'));            if (!$result = $this->db->query($sql)) {                echo "Could not delete topic.";            }        }    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -