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

📄 class_pollcomment.php

📁 具有多種面版可以選擇的"投票程式" 多國語言版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * ---------------------------------------------- * Advanced Poll 2.0.3 (PHP/MySQL) * Copyright (c)2001 Chi Kien Uong * URL: http://www.proxy2.de * ---------------------------------------------- */class pollcomment extends poll {    var $comment_form_html;    var $poll_comment_html;    var $comment_data;    var $comment_records;    var $comment_tpl;    var $comment_order;    var $comment_index;    var $total_comments;        var $form_fields;    var $form_message;    var $date_format;    var $word_length;    function pollcomment() {        global $HTTP_GET_VARS, $HTTP_POST_VARS;        $this->comment_form_html = array();        $this->poll_comment_html = array();        $this->comment_index = '';        $this->comment_data = array();        $this->comment_records = '';        $this->comment_tpl = '';        $this->comment_order = '';        $this->total_comments = array();        $this->form_message = array();        $this->date_format = "m/d/Y H:i";        $this->word_length = 35;                $this->comment_index = (isset($HTTP_GET_VARS['c_page'])) ? trim($HTTP_GET_VARS['c_page']) : 0;        $this->comment_index = (isset($HTTP_POST_VARS['c_page'])) ? trim($HTTP_POST_VARS['c_page']) : $this->comment_index;        if (empty($this->comment_index) || $this->comment_index<0) {            $this->comment_index = 0;        }        $this->form_fields = array("name","email","message");        $this->poll();    }    function set_comments_per_page($records) {        if (is_integer($records) && $records>0) {            $this->comment_records = $records;            return true;        } else {            return false;        }    }    function set_form_error($error_msg_arr) {        for ($i=0; $i<sizeof($this->form_fields); $i++) {            if (isset($error_msg_arr[$this->form_fields[$i]]) && !empty($error_msg_arr[$this->form_fields[$i]])) {                $error_msg_arr[$this->form_fields[$i]] = trim($error_msg_arr[$this->form_fields[$i]]);                $this->form_message[$this->form_fields[$i]] = $error_msg_arr[$this->form_fields[$i]];            }        }    }    function get_poll_comments($poll_id) {        if (!isset($this->comment_data[$poll_id])) {            $record = ($this->comment_records>0) ? $this->comment_records : $this->pollvars['entry_pp'];                        if (!isset($this->total_comments[$poll_id])) {                $this->get_total_comments($poll_id);            }            $pages = (int) ($this->total_comments[$poll_id]/$record);            if (($this->comment_index>$pages*$record) && $pages>0) {                $this->comment_index = $this->total_comments[$poll_id]-$record;            }               $this->db->query("SELECT * FROM ".$this->tbl['poll_comment']." WHERE (poll_id = '$poll_id') ".$this->comment_order." LIMIT ".$this->comment_index.",$record");                        if ($this->total_comments[$poll_id]>0) {                for ($i=0; $i<$record; $i++) {                    if ($this->db->fetch_array($this->db->result)) {                        $option_time_arr[] = $this->db->record['time'];                        $option_host_arr[] = $this->db->record['host'];                        $option_browser_arr[] = $this->db->record['browser'];                        $option_name_arr[] = $this->db->record['name'];                        $option_email_arr[] = $this->db->record['email'];                        $option_message_arr[] = $this->db->record['message'];                    } else {                        break;                    }                }                $comment_fields = array("time","host","browser","name","email","message");                for($i=0;$i<sizeof($comment_fields);$i++) {                    $field = "option_".$comment_fields[$i]."_arr";                    $this->comment_data[$poll_id][$comment_fields[$i]] = $$field;                }            } else {                $this->comment_data[$poll_id] = '';            }        }        return $this->comment_data[$poll_id];    }    function data_order_by($by, $order) {        if (($by != "time") && ($by != "name") && ($by != "email") && ($by != "host") && ($by != "browser") && ($by != "message")) {            $by = "time";        }        switch ($order) {            case "asc":                $this->comment_order = "ORDER BY $by ASC";                break;            case "desc":                $this->comment_order = "ORDER BY $by DESC";                break;            default:                $this->comment_order = "";                return false;        }        return true;    }    function get_total_comments($poll_id) {        if (!isset($this->total_comments[$poll_id])) {            $this->db->fetch_array($this->db->query("SELECT COUNT(*) AS total FROM ".$this->tbl['poll_comment']." WHERE (poll_id = '$poll_id')"));            $this->total_comments[$poll_id] = $this->db->record["total"];            return $this->total_comments[$poll_id];        } else {            return $this->total_comments[$poll_id];        }    }    function get_pages($total_records, $current_index, $records_per_page, $page_name, $max_pages=10, $separate=" | ") {        $pages_html = '';        if ($total_records>0) {                        $append = $this->get_query_strg($page_name);            $remain = $total_records % $records_per_page;                            $i = $total_records-$remain;            $pages = (int) ($total_records/$records_per_page);            $show_max = ($max_pages<$pages && $max_pages>0) ? $max_pages : $pages;                            $index = $current_index;            if (($current_index>($total_records-$show_max*$records_per_page)) && $pages>0) {                $index = $total_records-$show_max*$records_per_page;            }            for ($k=0; $k<$pages; $k++) {                $pages_arr[] = $k*$records_per_page+$remain;               }            if ($pages>0 && $records_per_page!=$total_records) {                if (($current_index > ($total_records-$max_pages*$records_per_page)) && ($total_records-$max_pages*$records_per_page)>0) {                    $index = $total_records-(($max_pages-1)*$records_per_page);                }                $next_page = $current_index+$records_per_page;                $prev_page = $current_index-$records_per_page;                                   $prev_page = ($prev_page<0 && $pages>0) ? 0 : $prev_page;                if ($prev_page >= 0 && $current_index>0) {                    $pages_html .= "<a href=\"$append"."$page_name=$prev_page\">&lt;</a>&nbsp;";                }                if ($index > ($total_records-$pages*$records_per_page)) {                    $index -= $records_per_page;                     }                                    $current_page = (int) ($index / $records_per_page);                for ($j=1; $j<=$show_max; $j++) {                    $page_number = $current_page + $j;                                           $position = $page_number-1;                    if ($position >= sizeof($pages_arr)) {                        $position = sizeof($pages_arr)-1;                    }                    $pages_html .= " <a href=\"$append"."$page_name=$pages_arr[$position]\">$page_number</a>$separate";                }                if ($next_page < $total_records) {                    $pages_html .= "&nbsp;<a href=\"$append"."$page_name=$next_page\">&gt;</a>";                }             }           }        return $pages_html;    }    function get_comment_pages($poll_id, $max_pages=10, $separate=" | ") {        if (!isset($this->comment_pages_html[$poll_id])) {            $record = ($this->comment_records>0) ? $this->comment_records : $this->pollvars['entry_pp'];            if (!isset($this->total_comments[$poll_id])) {                $this->get_total_comments($poll_id);            }            if ($this->total_comments[$poll_id]>0) {                $this->comment_pages_html[$poll_id] = $this->get_pages($this->total_comments[$poll_id], $this->comment_index, $record, "c_page", $max_pages, $separate);                    } else {                $this->comment_pages_html[$poll_id] = '';            }        }        return $this->comment_pages_html[$poll_id];            }    function set_date_format($date_strg) {        if (!empty($date_strg)) {            $this->date_format = $date_strg;            return true;

⌨️ 快捷键说明

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