[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: ошибки в скрипте голосования
liver1981
доброго утра, уважаемые форумчане

опять борюсь с видеошколой евгения попова
на сей раз ошибки возникли в скрипте голосования

сначала программа ругалась на eregi - заменил на preg_replace
получил вот такие ошибки:

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114
Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114
Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114


Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_pollcomment.php on line 205


Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_plist.php on line 66


Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_pollcomment.php on line 342

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_pollcomment.php on line 351

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_pollcomment.php on line 205


Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_poll.php on line 114

Warning: preg_replace() [function.preg-replace]: No ending delimiter '"' found in Z:\home\localhost\www\phpblog\poll\include\class_pollcomment.php on line 205


подскажите пожалуйста что это такое и как это исправить?

class_poll.php
<?php
/**
* ----------------------------------------------
* Advanced Poll 2.0.8 (PHP/MySQL)
* Copyright © Chi Kien Uong
* URL:
http://www.proxy2.de
* ----------------------------------------------
*/


class poll {

var $db;
var $tbl;
var $pollvars;
var $poll_view_html;
var $poll_result_html;
var $options;
var $options_text;
var $poll_question;
var $form_forward;
var $template_set;
var $ip;

function poll() {
global $POLLTBL, $CLASS;
$this->tbl = $POLLTBL;
$this->poll_view_html = array();
$this->poll_result_html = array();
$this->options = array();
$this->options_text = array();
$this->poll_question = array();
$this->form_forward = basename($_SERVER['PHP_SELF']);

$this->ip = getenv("REMOTE_ADDR");
$this->db = &$CLASS["db"];
$this->pollvars = $this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_config']));
$this->template_set = "default";

if ($this->pollvars['result_order'] == "asc") {
$this->pollvars['result_order'] = "ORDER BY votes ASC";
} elseif ($this->pollvars['result_order'] == "desc") {
$this->pollvars['result_order'] = "ORDER BY votes DESC";
} else {
$this->pollvars['result_order'] = '';
}
}


function set_template_set($template_set='') {
if (!empty($template_set)) {
$template_set = addslashes($template_set);
$this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_tplset']." WHERE tplset_name='$template_set'"));
if ($this->db->record) {
$this->template_set = $template_set;
} else {
$this->template_set = "default";
}
}
else {
$this->template_set = "default";
}
return $this->template_set;
}

function set_display_order($order='') {
switch ($order) {
case "asc":
$this->pollvars['result_order'] = "ORDER BY votes ASC";
break;
case "desc":
$this->pollvars['result_order'] = "ORDER BY votes DESC";
break;
default:
$this->pollvars['result_order'] = "";
return false;
}
return true;
}

function set_display_result($result='') {
switch ($result) {
case "votes":
$this->pollvars['type'] = "votes";
break;
case "percent":
$this->pollvars['type'] = "percent";
break;
default:
return false;
}
return true;
}

function set_max_bar_length($max_bar_length=0) {
if ($max_bar_length && $max_bar_length>0) {
$this->pollvars['img_length'] = $max_bar_length;
return true;
} else {
return false;
}
}


function set_max_bar_height($max_bar_height=0) {
if ($max_bar_height && $max_bar_height>0) {
$this->pollvars['img_height'] = $max_bar_height;
return true;
} else {
return false;
}
}


function get_poll_tpl($tpl) {
$tpl = addslashes($tpl);
$this->db->fetch_array($this->db->query("SELECT x.*, y.* from ".$this->tbl['poll_tplset']." x, ".$this->tbl['poll_tpl']." y where x.tplset_name='$this->template_set' and x.tplset_id=y.tplset_id AND y.title='$tpl'"));
if ($this->db->record['template']) {
$this->db->record['template'] = preg_replace("\"", "\\\"", $this->db->record['template']);
return $this->db->record['template'];
} else {
return false;
}
}


function get_poll_data($poll_id) {
$poll_id = intval($poll_id);
if (!isset($this->options[$poll_id])) {
$this->db->query("SELECT SUM(votes) as total FROM ".$this->tbl['poll_data']." WHERE (poll_id = '$poll_id')");
$this->db->fetch_array($this->db->result);
$this->options[$poll_id]['total'] = $this->db->record['total'];
$this->db->query("SELECT * FROM ".$this->tbl['poll_data']." WHERE (poll_id = '$poll_id') ".$this->pollvars['result_order']);
while ($this->db->fetch_array($this->db->result)) {
$option_id_arr[] = $this->db->record['option_id'];
$option_text_arr[] = $this->db->record['option_text'];
$option_votes_arr[] = $this->db->record['votes'];
$option_color_arr[] = $this->db->record['color'];
}
$this->options[$poll_id]['option_id'] = $option_id_arr;
$this->options[$poll_id]['option_text'] = $option_text_arr;
$this->options[$poll_id]['votes'] = $option_votes_arr;
$this->options[$poll_id]['color'] = $option_color_arr;
for ($i=0,$maxvote=0; $i<sizeof($option_votes_arr); $i++) {
$maxvote = ($option_votes_arr[$i]>$maxvote) ? $option_votes_arr[$i] : $maxvote;
}
$this->options[$poll_id]['maxvote'] = $maxvote;
}
return $this->options[$poll_id];
}

function get_poll_option($poll_id) {
$poll_id = intval($poll_id);
if (!isset($this->options_text[$poll_id])) {
$query = $this->db->query("SELECT option_id, option_text FROM ".$this->tbl['poll_data']." WHERE (poll_id = '$poll_id') order by option_id asc");
while ($data = $this->db->fetch_array($query)) {
$option_id_arr[] = $this->db->record['option_id'];
$option_text_arr[] = $this->db->record['option_text'];
}
$this->options_text[$poll_id]['option_id'] = $option_id_arr;
$this->options_text[$poll_id]['option_text'] = $option_text_arr;
}
return $this->options_text[$poll_id];
}

function get_poll_question($poll_id) {
$poll_id = intval($poll_id);
if (!isset($this->poll_question[$poll_id])) {
$row = $this->db->fetch_array($this->db->query("SELECT question FROM ".$this->tbl['poll_index']." WHERE (poll_id = '$poll_id')"));
$this->poll_question[$poll_id] = $row['question'];
}
return $this->poll_question[$poll_id];
}

function display_poll($poll_id) {
$poll_id = intval($poll_id);
if (!isset($this->poll_view_html[$poll_id]) || !isset($this->poll_view_html[$poll_id][$this->template_set])) {
$pollvars = $this->pollvars;
if (!isset($this->options_text[$poll_id])) {
$this->get_poll_option($poll_id);
}
$question = $this->get_poll_question($poll_id);
eval("\$display_html = \"".$this->get_poll_tpl("display_head")."\";");
$loop_html = $this->get_poll_tpl("display_loop");
for ($i=0;$i<sizeof($this->options_text[$poll_id]['option_id']);$i++) {
$data['option_text'] = $this->options_text[$poll_id]['option_text'][$i];
$data['option_id'] = $this->options_text[$poll_id]['option_id'][$i];
eval("\$display_html .= \"$loop_html\";");
}
eval("\$display_html .= \"".$this->get_poll_tpl("display_foot")."\";");
$this->poll_view_html[$poll_id][$this->template_set] = $display_html;
}
return $this->poll_view_html[$poll_id][$this->template_set];
}

function view_poll_result($poll_id,$vote_stat=0) {
$poll_id = intval($poll_id);
if (!isset($this->poll_result_html[$poll_id]) || !isset($this->poll_result_html[$poll_id][$this->template_set])) {
$pollvars = $this->pollvars;
$row = $this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_index']." WHERE (poll_id = '$poll_id')"));
if (!$row) {
return "";
}
$question = $row['question'];
$VOTE = ($vote_stat==1) ? $this->pollvars['voted'] : '';
$COMMENT = ($row['comments']==1) ? "<a href=\"javascript:void(window.open('$pollvars[base_url]/comments.php?action=send&id=$poll_id&template_set=$this->template_set','$poll_id','width=230,height=320,toolbar=no,statusbar=no'))\">".$this->pollvars['send_com']."</a>" : '';
eval("\$result_html = \"".$this->get_poll_tpl("result_head")."\";");
$i=0;
$loop_html = $this->get_poll_tpl("result_loop");
if (!isset($this->options[$poll_id])) {
$this->get_poll_data($poll_id);
}
$maxvote = ($this->options[$poll_id]['maxvote'] == 0) ? 1 : $this->options[$poll_id]['maxvote'];
$totalvotes = ($this->options[$poll_id]['total'] == 0) ? 1 : $this->options[$poll_id]['total'];
for ($i=0;$i<sizeof($this->options[$poll_id]['option_id']);$i++) {
$img_width = (int) ($this->options[$poll_id]['votes'][$i]*$this->pollvars['img_length']/$maxvote);
$vote_count = $this->options[$poll_id]['votes'][$i];
$vote_percent = sprintf("%.2f",($this->options[$poll_id]['votes'][$i]*100/$totalvotes));
$vote_val = ($this->pollvars['type'] == "percent") ? sprintf("%.1f",($this->options[$poll_id]['votes'][$i]*100/$totalvotes))."%" : $vote_count;
$option_text = $this->options[$poll_id]['option_text'][$i];
$option_votes = $this->options[$poll_id]['votes'][$i];
$poll_color = $this->options[$poll_id]['color'][$i];
eval("\$result_html .= \"$loop_html\";");
}
$total_votes = $this->options[$poll_id]['total'];
eval("\$result_html .= \"".$this->get_poll_tpl("result_foot")."\";");
$this->poll_result_html[$poll_id][$this->template_set] = $result_html;
}
return $this->poll_result_html[$poll_id][$this->template_set];
}

function update_poll($poll_id,$option_id) {
$poll_id = intval($poll_id);
$option_id = intval($option_id);
$this->db->query("UPDATE ".$this->tbl['poll_data']." SET votes=votes+1 WHERE (poll_id='$poll_id') AND (option_id='$option_id')");
$row = $this->db->fetch_array($this->db->query("SELECT logging as logging FROM ".$this->tbl['poll_index']." WHERE (poll_id = '$poll_id')"));
$timestamp = time();
if ($this->pollvars['check_ip'] == 2) {
$this->db->query("INSERT INTO ".$this->tbl['poll_ip']." (poll_id,ip_addr,timestamp) VALUES ('$poll_id','$this->ip','$timestamp')");
}
if ($row['logging'] == 1) {
$host = @gethostbyaddr($this->ip);
$agent = addslashes(getenv("HTTP_USER_AGENT"));
$this->db->query("INSERT INTO ".$this->tbl['poll_log']." (poll_id,option_id,timestamp,ip_addr,host,agent) VALUES ('$poll_id','$option_id','$timestamp','$this->ip','$host','$agent')");
}
}


function get_latest_poll_id() {
$this->db->query("SELECT poll_id FROM ".$this->tbl['poll_index']." WHERE (status < '2') ORDER BY TIMESTAMP DESC LIMIT 1");
$this->db->fetch_array($this->db->result);
return (!isset($this->db->record['poll_id'])) ? 0 : $this->db->record['poll_id'];
}

function get_random_poll_id() {
$timestamp = time();
$this->db->query("SELECT poll_id FROM ".$this->tbl['poll_index']." WHERE (status=1 AND exp_time>$timestamp) OR (status=1 AND expire=0)");
while ($this->db->fetch_array($this->db->result)) {
$poll_id_arr[] = $this->db->record['poll_id'];
}
if (!isset($poll_id_arr)) {
return 0;
}
$available = sizeof($poll_id_arr)-1;
srand((double) microtime() * 1000000);
$random_id = ($available>0) ? rand(0,$available) : 0;
return $poll_id_arr[$random_id];
}

function is_active_poll_id($poll_id) {
$poll_id = intval($poll_id);
$this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_index']." WHERE (poll_id='$poll_id' AND status=1)"));
if (!$this->db->record) {
return false;
} elseif ($this->db->record['expire']==0) {
return true;
}
return ($this->db->record['exp_time']<time()) ? false : true;
}

function is_valid_poll_id($poll_id) {
$poll_id = intval($poll_id);
if ($poll_id>0) {
$this->db->fetch_array($this->db->query("SELECT poll_id FROM ".$this->tbl['poll_index']." WHERE poll_id=$poll_id AND status<'2'"));
return ($this->db->record['poll_id']) ? true : false;
} else {
return false;
}
}


function has_voted($poll_id) {
$poll_id = intval($poll_id);
$pollcookie = $poll_id;
if (isset($_COOKIE['AdvancedPoll'][$pollcookie])) {
return true;
}
if ($this->pollvars['check_ip']==2) {
$today = time()-$this->pollvars['lock_timeout']*3600;
$this->db->query("DELETE FROM ".$this->tbl['poll_ip']." WHERE (timestamp < $today)");
$this->db->fetch_array($this->db->query("SELECT * FROM ".$this->tbl['poll_ip']." WHERE (ip_addr = '$this->ip' and poll_id='$poll_id')"));
return ($this->db->record) ? true : false;
}
}


function get_query_strg($self) {
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
if (preg_replace("($self=[0-9]+)",$_SERVER['QUERY_STRING'],$regs)) {
$_SERVER['QUERY_STRING'] = str_replace($regs[1], "", $_SERVER['QUERY_STRING']);
}
$_SERVER['QUERY_STRING'] = str_replace("$self=", "", $_SERVER['QUERY_STRING']);
if (empty($_SERVER['QUERY_STRING'])) {
$append = $_SERVER['PHP_SELF']."?";
} else {
$query_vars = explode("&",$_SERVER['QUERY_STRING']);
$append = $_SERVER['PHP_SELF']."?";
for ($i=0; $i<sizeof($query_vars); $i++) {
if (!empty($query_vars[$i])) {
$append .= $query_vars[$i]."&";
}
}
}
}
else {
$append = $_SERVER['PHP_SELF']."?";
}
return $append;
}

function poll_process($poll_id='') {
$poll_ident = (isset($_POST['poll_ident'])) ? intval($_POST['poll_ident']) : "";
if ($poll_ident == "") {
if (isset($_GET['poll_ident'])) {
$poll_ident = intval($_GET['poll_ident']);
}
}


$option_id = (isset($_POST['option_id'])) ? intval($_POST['option_id']) : "";
if ($option_id == "") {
if (isset($_GET['option_id'])) {
$option_id = intval($_GET['option_id']);
}
}


$action = (isset($_POST['action'])) ? trim($_POST['action']) : "";
if ($action == "") {
if (isset($_GET['action'])) {
$action = trim($_GET['action']);
}
}


if ($poll_id=="random") {
$poll_id = (empty($poll_ident)) ? $this->get_random_poll_id() : $poll_ident;
} elseif ($poll_id=="newest") {
$poll_id = $this->get_latest_poll_id();
}
if ($this->is_valid_poll_id($poll_id)) {
$voted = $this->has_voted($poll_id);
$is_active = $this->is_active_poll_id($poll_id);
if ($action=="results" && $poll_id==$poll_ident) {
return $this->view_poll_result($poll_id,0);
} elseif (!$is_active) {
return $this->view_poll_result($poll_id,0);
} elseif ($is_active && $voted) {
return $this->view_poll_result($poll_id,1);
} elseif (!$voted && isset($option_id) && $action=="vote" && $poll_id==$poll_ident) {
$this->update_poll($poll_id,$option_id);
return $this->view_poll_result($poll_id,0);
} else {
return $this->display_poll($poll_id);
}
}
else {
$error = "<b>Poll ID <font color=red>".intval($poll_id)."</font> does not exist.</b>";
return $error;
}
}

}


?>


class_pollcomment.php

<?php
/**
* ----------------------------------------------
* Advanced Poll 2.0.8 (PHP/MySQL)
* Copyright © 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() {
$this->comment_form_html = array();
$this->poll_comment_html = array();
$this->comment_data = array();
$this->comment_records = 0;
$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($_GET['c_page'])) ? intval($_GET['c_page']) : 0;
$this->comment_index = (isset($_POST['c_page'])) ? intval($_POST['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","captcha");
$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) {
$poll_id = intval($poll_id);
if (!isset($this->comment_data[$poll_id])) {
$poll_id = intval($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) {
$poll_id = intval($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\"><</a> ";
}
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 .= " <a href=\"$append"."$page_name=$next_page\">></a>";
}
}
}

return $pages_html;
}

function get_comment_pages($poll_id, $max_pages=10, $separate=" | ") {
$poll_id = intval($poll_id);
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;
} else {
return false;
}
}


function view_poll_comments($poll_id) {
$poll_id = intval($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'] = preg_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)) {
$title = addslashes($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) {
$poll_id = intval($poll_id);
for ($i=0; $i<sizeof($this->form_fields); $i++) {
$field_name = $this->form_fields[$i];
if (isset($_POST[$field_name])) {
$$field_name = $this->format_string($_POST[$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 = addslashes(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) {
$poll_id = intval($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='') {
$poll_id = intval($poll_id);
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($_POST[$this->form_fields[$i]]) && !empty($msg)) {
$comment[$this->form_fields[$i]] = stripslashes(htmlspecialchars($this->format_string($_POST[$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'] = preg_replace("\"", "\\\"", $row['template']);
} else {
$row['template'] = $this->get_poll_tpl("comment");
}
$poll_time = time();
$POLL_CAPTCHA = "";
$pollvars = $this->pollvars;
if ($this->pollvars['captcha'] == "on") {
$row2 = $this->db->fetch_array($this->db->query("SELECT template FROM ".$this->tbl['poll_tpl']." WHERE (title = 'poll_captcha' and tplset_id='0')"));
$captcha_template = preg_replace("\"", "\\\"", $row2['template']);
eval("\$POLL_CAPTCHA = \"".$captcha_template."\";");
}
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) {
$poll_id = intval($poll_id);
if (!$this->is_valid_poll_id($poll_id)) {
return "";
}
if (isset($_GET['action']) || isset($_POST['action'])) {
$action = (isset($_POST['action'])) ? trim($_POST['action']) : trim($_GET['action']);
} else {
$action = '';
}
if (isset($_POST['pcomment']) && $_POST['pcomment']>0) {
$pcomment = intval($_POST['pcomment']);
} else {
$pcomment = -1;
}
if (empty($poll_id)) {
$msg = "Poll ID <b>".intval($poll_id)."</b> does not exist or is disabled!";
return $msg;
} else {
$msg = '';
}
if (!$this->is_comment_allowed($poll_id)) {
return "";
}
if ($action == "add" && $this->is_comment_allowed($poll_id) && $poll_id==$pcomment) {
if ($this->pollvars['captcha'] == "on") {
$captcha = new CaptchaTest;
$captcha->secretCode .= $this->db->db['pass'];
$validCaptcha = true;
if (!isset($_POST['time']) || !isset($_POST['captcha'])) {
$validCaptcha = false;
} elseif (!$captcha->isValid($_POST['captcha'], $_POST['time'])) {
$validCaptcha = false;
}
if ($validCaptcha == false) {
$msg = (isset($this->form_message['captcha'])) ? $this->form_message['captcha'] : " ";
}
}

for (reset($this->form_message); $key=key($this->form_message); next($this->form_message)) {
if (!empty($this->form_message[$key])) {
if (isset($_POST[$key])) {
$_POST[$key] = trim($_POST[$key]);
}
if (!isset($_POST[$key]) || empty($_POST[$key])) {
$msg = $this->form_message[$key];
break;
}
}
}

if ($msg == "") {
$this->add_comment($poll_id);
}
}

return $this->poll_form($poll_id,$msg);
}

}


?>


class_plist.php

<?php
/**
* ----------------------------------------------
* Advanced Poll 2.0.8 (PHP/MySQL)
* Copyright © Chi Kien Uong
* URL:
http://www.proxy2.de
* ----------------------------------------------
*/


class plist extends pollcomment {

var $poll_list_html;
var $plist_data;
var $list_index;
var $list_page_html;
var $poll_records;

function plist() {
$this->poll_list_html = array();
$this->plist_data = array();
$this->list_page_html = '';
$this->poll_records = 0;
$this->list_index = (isset($_GET['l_page'])) ? intval($_GET['l_page']) : 0;
$this->list_index = (isset($_POST['l_page'])) ? intval($_POST['l_page']) : $this->list_index;
if (empty($this->list_index) || $this->list_index<0) {
$this->list_index = 0;
}
$this->pollcomment();
}

function get_poll_list() {
if (sizeof($this->plist_data)<1) {
$record = ($this->poll_records>0) ? $this->poll_records : $this->pollvars['polls_pp'];
$this->db->query("SELECT * FROM ".$this->tbl['poll_index']." WHERE (status < '2') ORDER BY poll_id DESC LIMIT ".$this->list_index.",$record");
$total_polls = $this->db->num_rows($this->db->result);
if ($total_polls>0) {
for ($i=0; $i<$record; $i++) {
if ($this->db->fetch_array($this->db->result)) {
$poll_id_arr[] = $this->db->record['poll_id'];
$question_arr[] = $this->db->record['question'];
$timestamp_arr[] = $this->db->record['timestamp'];
$exp_time_arr[] = $this->db->record['exp_time'];
$expire_arr[] = $this->db->record['expire'];
$comments_arr[] = $this->db->record['comments'];
} else {
break;
}
}

$this->plist_data['poll_id'] = $poll_id_arr;
$this->plist_data['question'] = $question_arr;
$this->plist_data['timestamp'] = $timestamp_arr;
$this->plist_data['exp_time'] = $exp_time_arr;
$this->plist_data['expire'] = $expire_arr;
$this->plist_data['comments'] = $comments_arr;
} else {
$this->plist_data = array();
}
}

return $this->plist_data;
}

function view_poll_list() {
$PHP_SELF = $_SERVER['PHP_SELF'];
if (!isset($this->poll_list_html[$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'] = preg_replace("\"", "\\\"", $row['template']);
$list_html = '';
if (sizeof($this->plist_data)<1) {
$this->get_poll_list();
}
if (sizeof($this->plist_data)>0) {
for ($i=0;$i<sizeof($this->plist_data['poll_id']);$i++) {
$data['timestamp'] = date($this->date_format,$this->plist_data['timestamp'][$i]+$this->pollvars['time_offset']*3600);
$data['exp_time'] = date($this->date_format,$this->plist_data['exp_time'][$i]+$this->pollvars['time_offset']*3600);
$data['poll_id'] = $this->plist_data['poll_id'][$i];
$data['question'] = $this->plist_data['question'][$i];
$data['comments'] = $this->plist_data['comments'][$i];
$data['expire'] = $this->plist_data['expire'][$i];
eval("\$list_html .= \"$row[template]\";");
}
$this->poll_list_html[$this->comment_tpl] = $list_html;
} else {
$this->poll_list_html[$this->comment_tpl] = '';
}
}

return $this->poll_list_html[$this->comment_tpl];
}

function set_polls_per_page($records) {
if (is_integer($records) && $records>0) {
$this->poll_records = $records;
return true;
} else {
return false;
}
}


function get_total_polls() {
$this->db->fetch_array($this->db->query("SELECT COUNT(*) AS total FROM ".$this->tbl['poll_index']." WHERE (status < '2')"));
return $this->db->record["total"];
}

function get_list_pages($max_pages=10, $separate=" | ") {
if (empty($this->list_page_html)) {
$record = ($this->poll_records>0) ? $this->poll_records : $this->pollvars['polls_pp'];
$total_polls = $this->get_total_polls();
if ($total_polls>0) {
$this->list_page_html = $this->get_pages($total_polls, $this->list_index, $record, "l_page", $max_pages, $separate);
} else {
$this->list_page_html = '';
}
}

return $this->list_page_html;
}

}


?>


???



Спустя 20 минут, 17 секунд (1.09.2010 - 08:52) twin написал(а):
Ты на кой вываливаешь сюда такие портянки?
У Попова есть свой форум, там что, не могут ответить?

Спустя 6 минут, 13 секунд (1.09.2010 - 08:59) liver1981 написал(а):
twin, Попов не отвечает на вопросы которые понижают рейтинг его видеошкол. Это я ещё заметил когда столкнулся с первой ошибкой. Там люди задавали вопросы на которые не получали ответов.

Спустя 5 минут, 42 секунды (1.09.2010 - 09:04) twin написал(а):
Ответ в прошлой твоей теме

Спустя 1 минута, 28 секунд (1.09.2010 - 09:06) linker написал(а):
preg_replace("\"", "\\\"", $this->db->record['template']);
как минимум
preg_replace("/\"/", "\\\"", $this->db->record['template']);
а вообще для таких целей есть str_replace(), eregi() - деприкейт, нужно использовать preg_match() и т.д. и т.п. Попова в топку.

Спустя 1 минута, 59 секунд (1.09.2010 - 09:08) liver1981 написал(а):
linker, twin я исправлял на preg_replace - те же warning

Спустя 6 минут, 57 секунд (1.09.2010 - 09:15) twin написал(а):
Дык ты не все подряд бездумно исправляй то...
Разберись сначала для чего это, потом делай.

Интересно... Где Попов такой код спер... И что он там в уроках не рассказывает что к чиму?

Спустя 4 минуты, 54 секунды (1.09.2010 - 09:20) liver1981 написал(а):
twin, это скрипт который устанавливает блок голосования
попов в видеокурсе просто устанавливает этот скрипт, информации о том где он его взял не даёт
потом подключает этот скрипт в левом блоке блога и настраивает его соединение с базой данных, изменяет конфигурационный фай
просто копипастит скрипт - ничего не обьясняет о его коде, так пару слов
про eregi там вобще ни слова нет
я же не могу что то обдуманно исправлять потому как я ещё мало что знаю, 2й раз в жизни копипастю скрипт, отсюда и мои такие вопросы
ну а что ещё делать
надо же чтобы оно хоть заработало чтоб хоть как то в нем разобраться или я уже не знаю.

Спустя 12 минут, 56 секунд (1.09.2010 - 09:32) Basili4 написал(а):
liver1981
Попова в топку иди на http://irbis-team.com/15 и учись потихоньку, тупо меняя вызовы ничему не научишься.

Спустя 3 минуты, 11 секунд (1.09.2010 - 09:36) liver1981 написал(а):
Basili4, спасибо добавил в закладки
но у попова свои ошибки там возможно будут другие ну чтож я так и буду по разным школам ходить? всё время всё менять, так кажется, ничему не научусь.

Спустя 4 минуты, 20 секунд (1.09.2010 - 09:40) Basili4 написал(а):
liver1981
Будут ошибки пость ошибки с кодом на этом форуме. А от Попова одна польза, неиссякаемый источник лулзов. Вот и сейчас читаю этот код и ржу.

   if (isset($_GET['action']) || isset($_POST['action'])) {




Спустя 2 минуты, 33 секунды (1.09.2010 - 09:43) liver1981 написал(а):
Basili4, спасибо, буду постить
жаль вот столько труда теперь насмарку - я же уже почти весь его диск изучил - там буквально 2 урока остается, эх...

Спустя 1 час, 18 минут, 41 секунда (1.09.2010 - 11:01) twin написал(а):
liver1981

Цитата
надо же чтобы оно хоть заработало чтоб хоть как то в нем разобраться или я уже не знаю.

Это далеко не самый простой скрипт, чтобы начать учиться с его разбора. Тебе бы основы изучить сначала, если действительно хочешь сам научиться прогать. А если просто настроить скрипт и хоть трава не расти, то проще дать кому-нить на мороженое и спать спокойно.

Вопросы на форумах тоже нужно учиться задавать.
Ну скажи, на кой ты вывалил сюда полтора километра кода? Ты серьёзно думаешь, что кто то кинется его разбирать? Тем более ты сразу обозначил его принадлежность...

Есть ошибка, смотрим строку, смотрим текст ошибки, смотрим функцию. Идем в мануал, разбираемся, что делает эта функция и почему не хочет работать.

Можно даже обнаглеть и скормить текст ошибки гуглу. Чем черт не шутит.
Если ничего не помогло, берешь этот участок кода, а не всю портянку, описываешь подробненько проблему и сюда.

А лучше начни все сначала, фтопку Попова.

Спустя 40 минут, 53 секунды (1.09.2010 - 11:42) linker написал(а):
Напрасно потраченное время действительно жалко, но если ты начнешь все сначала и не с Попова, то хоть и потратишь определенное время, однако пожалеть об этом не сможешь.

Спустя 1 час, 54 минуты, 7 секунд (1.09.2010 - 13:36) liver1981 написал(а):
linker, с попова или нет начинать не важно - важен результат. относится к попову можно как угодно, но всё же кое чему он меня научил учитывая то что я вообще ничего не знал в этой области. в любой школе есть плюсы и есть минусы. мне уже столько раз попадались учебники с опечятками и устаревшим по. к вам же обратился лишь подкоректировать десяток ошибок из тем которые мне пока что по определению не известны ибо это мой лишь 2й веб проект в жизни. спасибо что помогали в прошлых темах.

twin, гуглил я но на ресурсах куда я попадал люди общаются уже на профессиональном уровне и языке а у меня не хватает пока что профессионализма их понять. а код то 2 сек. в дримвьюер или пхп дизайнер вставить и запустить в броузере, не мог представить что это проблема. спасибо что помогали в прошлых темах. на мороженое дать не могу ибо сам исключительно не всегда на хлебе. хотя мороженое это вы определенно заслуживаете!

всем успехов, спасибо

Спустя 16 минут, 54 секунды (1.09.2010 - 13:53) twin написал(а):
Цитата
linker, с попова или нет начинать не важно - важен результат.
Вот именно... А его нет.
Цитата
но всё же кое чему он меня научил.
Ой ли?

Поставь скрипт как есть и первой строчкой напиши это
ini_set('display_errors', 0);
error_reporting(0);

Вообще так делать нельзя, но этому коду уже ниченго не повредит.

Спустя 3 часа, 36 минут, 2 секунды (1.09.2010 - 17:29) liver1981 написал(а):
twin, поставил в начало.
ошибки не выдаёт - это хорошо но и скрипт не работает - это плохо.

Спустя 4 часа, 4 минуты, 3 секунды (1.09.2010 - 21:33) linker написал(а):
Найди все свои preg_replace() и сделай из них как положено мануалом, а не Поповым. Пример
preg_replace('/\s+/', ' ', 'Hello      world');
Т.е. как минимум
preg_replace('/шаблон/', 'на что менять', 'где менять');
или
preg_replace('~шаблон~', 'на что менять', 'где менять');
или
preg_replace('#шаблон#', 'на что менять', 'где менять');
или
....
Попов, насколько я заметил, не учит как пользоваться умными мануалами, а без них ну ни как.

Спустя 7 минут, 7 секунд (1.09.2010 - 21:40) liver1981 написал(а):
linker, мануалы у меня есть
интернет есть
буду работать.
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.