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

📄 class_pollcomment.php

📁 具有多種面版可以選擇的"投票程式" 多國語言版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
        } else {            return false;        }    }    function view_poll_comments($poll_id) {        if (!isset($this->poll_comment_html[$poll_id]) || !isset($this->poll_comment_html[$poll_id][$this->comment_tpl])) {            $row = $this->db->fetch_array($this->db->query("SELECT template FROM ".$this->tbl['poll_tpl']." WHERE (title = '".$this->comment_tpl."' and tplset_id='0')"));            $row['template'] = ereg_replace("\"", "\\\"", $row['template']);            $display_html = '';            if (!isset($this->comment_data[$poll_id])) {                $this->get_poll_comments($poll_id);            }            if (is_array($this->comment_data[$poll_id])) {                for ($i=0;$i<sizeof($this->comment_data[$poll_id]['time']);$i++) {                    $data['time'] = date($this->date_format,$this->comment_data[$poll_id]['time'][$i]+$this->pollvars['time_offset']*3600);                    $data['host'] = $this->comment_data[$poll_id]['host'][$i];                    $data['browser'] = htmlspecialchars($this->comment_data[$poll_id]['browser'][$i]);                    $data['name'] = htmlspecialchars($this->comment_data[$poll_id]['name'][$i]);                    $data['email'] = $this->comment_data[$poll_id]['email'][$i];                                        $data['message'] = $this->strip_new_lines($this->comment_data[$poll_id]['message'][$i]);                    $data['message'] = $this->wrap_text($data['message'],$this->word_length);                    $data['message'] = htmlspecialchars($data['message']);                    $data['message'] = nl2br($data['message']);                                       eval("\$display_html .= \"$row[template]\";");                }                $this->poll_comment_html[$poll_id][$this->comment_tpl] = $display_html;            } else {                $this->poll_comment_html[$poll_id][$this->comment_tpl] = '';            }            }        return $this->poll_comment_html[$poll_id][$this->comment_tpl];    }    function set_template($title) {        if (!empty($title)) {            $this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_tpl']." WHERE title='$title'"));            if ($this->db->record) {                $this->comment_tpl = $title;                return true;            } else {                $this->comment_tpl = "";                return false;            }        } else {            return false;        }    }    function format_string($strg) {        if (!get_magic_quotes_gpc()) {            $strg = addslashes($strg);        }        $strg = trim($strg);        return $strg;    }    function wrap_text($strg, $max_word_length=60, $break="\n") {        if (!empty($strg)) {            $max_word_length += 1;            preg_match_all("/(\S{".$max_word_length.",})/", $strg, $matches_arr);            if (isset($matches_arr[1]) && sizeof($matches_arr[1])>0) {                for ($i=0; $i<sizeof($matches_arr[1]); $i++) {                    $break_x = (int) (strlen($matches_arr[1][$i])/$max_word_length);                    $new_word = '';                    for ($k=0; $k<$break_x; $k++) {                        $new_word .= substr($matches_arr[1][$i], ($k*$max_word_length), $max_word_length).$break;                    }                    $new_word .= substr($matches_arr[1][$i], -(strlen($matches_arr[1][$i])-$break_x*$max_word_length));                    $strg = str_replace($matches_arr[1][$i], $new_word, $strg);                }            }        }        return $strg;    }        function strip_new_lines($strg,$max_new_lines=2) {        $strg = str_replace("\r\n", "\n", $strg);        $strg = str_replace("\r", "\n", $strg);        $replace = str_repeat ("\n", $max_new_lines);        $strg = preg_replace("/\n{".$max_new_lines.",}/", $replace, $strg);        return $strg;    }    function add_comment($poll_id) {        global $HTTP_POST_VARS;        for ($i=0; $i<sizeof($this->form_fields); $i++) {            $field_name = $this->form_fields[$i];            if (isset($HTTP_POST_VARS[$field_name])) {                $$field_name = $this->format_string($HTTP_POST_VARS[$field_name]);            } else {                $$field_name = '';            }        }        if (empty($name)) {            $name = "anonymous";        }        if (!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\\.)+[0-9a-z]{1,6}$", $email) ) {            $email = '';        }        $this_time = time();        $host = @gethostbyaddr($this->ip);        $agent = @getenv("HTTP_USER_AGENT");        $this->db->query("INSERT INTO ".$this->tbl['poll_comment']." (poll_id,time,host,browser,name,email,message) VALUES ('$poll_id','$this_time','$host','$agent','$name','$email','$message')");        return ($this->db->result) ? true : false;    }    function print_message($strg,$autoclose=0) {        $msg ='';        if ($autoclose==1) {            $msg .= "<script language=\"JavaScript\">            setTimeout(\"closeWin()\",2000);            function closeWin() {                self.close();            }            </script>";        }        $msg .= "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$strg</font>";        return $msg;    }    function is_comment_allowed($poll_id) {        if ($poll_id>0) {            $this->db->fetch_array($this->db->query("SELECT comments FROM ".$this->tbl['poll_index']." WHERE poll_id=$poll_id AND status<2"));            return ($this->db->record['comments']==1) ? true : false;        } else {            return false;        }    }    function poll_form($poll_id,$msg='') {        global $HTTP_POST_VARS;        if (!isset($this->comment_form_html[$poll_id]) || !isset($this->comment_form_html[$poll_id][$this->comment_tpl])) {                        $question = $this->get_poll_question($poll_id);            for ($i=0; $i<sizeof($this->form_fields); $i++) {                if (isset($HTTP_POST_VARS[$this->form_fields[$i]]) && !empty($msg)) {                    $comment[$this->form_fields[$i]] = stripslashes(htmlspecialchars($this->format_string($HTTP_POST_VARS[$this->form_fields[$i]])));                } else {                    $comment[$this->form_fields[$i]] = '';                }            }            if (isset($this->comment_tpl) && !empty($this->comment_tpl)) {                $row = $this->db->fetch_array($this->db->query("SELECT template FROM ".$this->tbl['poll_tpl']." WHERE (title = '".$this->comment_tpl."' and tplset_id='0')"));                $row['template'] = ereg_replace("\"", "\\\"", $row['template']);            } else {                $row['template'] = $this->get_poll_tpl("comment");            }            eval("\$result_html = \"".$row['template']."\";");            $this->comment_form_html[$poll_id][$this->comment_tpl] = $result_html;        }        return $this->comment_form_html[$poll_id][$this->comment_tpl];    }    function comment_process($poll_id) {        global $HTTP_POST_VARS, $HTTP_GET_VARS;        if (isset($HTTP_GET_VARS['action']) || isset($HTTP_POST_VARS['action'])) {            $action = (isset($HTTP_POST_VARS['action'])) ? trim($HTTP_POST_VARS['action']) : trim($HTTP_GET_VARS['action']);        } else {            $action = '';        }        if (isset($HTTP_POST_VARS['pcomment']) && $HTTP_POST_VARS['pcomment']>0) {            $pcomment = $HTTP_POST_VARS['pcomment'];            } else {            $pcomment = '';        }            if (!isset($poll_id)) {            $msg = "Poll ID <b>".$poll_id."</b> does not exist or is disabled!";            return $this->poll_form($poll_id,$msg);        } else {            $msg = '';        }        if ($action == "add" && $this->is_comment_allowed($poll_id) && $poll_id==$pcomment) {            for (reset($this->form_message); $key=key($this->form_message); next($this->form_message)) {                if (!empty($this->form_message[$key])) {                    if (isset($HTTP_POST_VARS[$key])) {                        $HTTP_POST_VARS[$key] = trim($HTTP_POST_VARS[$key]);                    }                    if (!isset($HTTP_POST_VARS[$key]) || empty($HTTP_POST_VARS[$key])) {                        $msg = $this->form_message[$key];                        break;                    }                   }            }            if ($msg == "") {                $this->add_comment($poll_id);            }        }        return $this->poll_form($poll_id,$msg);    }}?>

⌨️ 快捷键说明

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