function render_comment_actual($settings) { if ($this->g->o["comments_active"] != 1) { return ""; } $post_id = intval($settings[1]); $comment_id = intval($settings[2]); $comment_author = intval($settings[3]); $rd_is_page = intval($settings[4]); $post_author = intval($settings[5]); $user_id = intval($settings[6]); $override["tpl"] = intval($settings[7]); $override["read_only"] = intval($settings[8]); $override["size"] = intval($settings[9]); $override["style"] = $this->g->g->stars[$settings[10]]->folder; $override["style_ie6"] = $this->g->g->stars[$settings[11]]->folder; $dbg_allow = "F"; $already_voted = false; $allow_vote = $override["read_only"] == 0; $allow_vote = apply_filters("gdsr_allow_vote_stars_comment", $allow_vote, $post_id); if ($this->g->is_ban && $this->g->o["ip_filtering"] == 1) { if ($this->g->o["ip_filtering_restrictive"] == 1) { return ""; } else { $allow_vote = false; } $dbg_allow = "B"; } $rd_unit_count = $this->g->o["cmm_stars"]; $rd_unit_width = $override["size"]; $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"]; $rd_post_id = intval($post_id); $rd_user_id = intval($user_id); $rd_comment_id = intval($comment_id); $post_data = wp_gdget_post($rd_post_id); if (!is_object($post_data)) { GDSRDatabase::add_default_vote($rd_post_id, $rd_is_page); $post_data = wp_gdget_post($rd_post_id); $this->g->c[$rd_post_id] = 1; } $rules_comments = $post_data->rules_comments != "I" ? $post_data->rules_comments : $this->g->get_post_rule_value($rd_post_id, "rules_comments", "default_voterules_comments"); if ($rules_comments == "H") { return ""; } $comment_data = wp_gdget_comment($rd_comment_id); if (count($comment_data) == 0) { GDSRDatabase::add_empty_comment($rd_comment_id, $rd_post_id); $comment_data = wp_gdget_comment($rd_comment_id); } if ($allow_vote) { if ($this->g->o["cmm_author_vote"] == 1 && $rd_user_id == $comment_author && $rd_user_id > 0) { $allow_vote = false; $dbg_allow = "A"; } } if ($allow_vote) { if ($rules_comments == "" || $rules_comments == "A" || $rules_comments == "U" && $rd_user_id > 0 || $rules_comments == "V" && $rd_user_id == 0) { $allow_vote = true; } else { $allow_vote = false; $dbg_allow = "R_" . $rules_comments; } } $already_voted = !wp_gdget_commentlog($rd_comment_id); if ($allow_vote) { $allow_vote = !$already_voted; if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($rd_comment_id, "comment"); if (!$allow_vote) { $dbg_allow = "C"; } } $votes = 0; $score = 0; if ($rules_comments == "A" || $rules_comments == "N") { $votes = $comment_data->user_voters + $comment_data->visitor_voters; $score = $comment_data->user_votes + $comment_data->visitor_votes; } else { if ($rules_comments == "V") { $votes = $comment_data->visitor_voters; $score = $comment_data->visitor_votes; } else { $votes = $comment_data->user_voters; $score = $comment_data->user_votes; } } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $comment_author ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array("CMM_CSS_BLOCK" => $this->g->o["cmm_class_block"], "CMM_CSS_HEADER" => $this->g->o["srb_class_header"], "CMM_CSS_STARS" => $this->g->o["cmm_class_stars"], "CMM_CSS_TEXT" => $this->g->o["cmm_class_text"]); $template_id = $override["tpl"]; $rating_block = GDSRRenderT2::render_crb($template_id, array("already_voted" => $already_voted, "cmm_id" => $rd_comment_id, "class" => "ratecmm", "type" => "c", "votes" => $votes, "score" => $score, "style" => $rd_unit_style, "unit_width" => $rd_unit_width, "unit_count" => $rd_unit_count, "allow_vote" => $allow_vote, "user_id" => $rd_user_id, "typecls" => "comment", "tags_css" => $tags_css, "header_text" => $this->g->o["cmm_header_text"], "debug" => $debug, "wait_msg" => $this->loader_comment)); return $rating_block; }
function comment_save($comment_id) { global $userdata; $user_id = is_object($userdata) ? $userdata->ID : 0; $user = intval($user_id); $ip = $_SERVER["REMOTE_ADDR"]; if ($this->post_comment["review"] > -1) { $comment_data = GDSRDatabase::get_comment_data($comment_id); if (count($comment_data) == 0) { GDSRDatabase::add_empty_comment($comment_id, $this->post_comment["post_id"], $this->post_comment["review"]); } else { GDSRDatabase::save_comment_review($comment_id, $this->post_comment["review"]); } } $std_minimum = $this->o["int_comment_std_zero"] == 1 ? -1 : 0; $mur_minimum = $this->o["int_comment_mur_zero"] == 1 ? 0 : 1; $id = $this->post_comment["post_id"]; if ($this->post_comment["standard_rating"] > $std_minimum) { $votes = $this->post_comment["standard_rating"]; $ua = $this->o["save_user_agent"] == 1 ? $_SERVER["HTTP_USER_AGENT"] : ""; $allow_vote = true; if ($this->o["cmm_integration_prevent_duplicates"] == 1) { $allow_vote = intval($votes) <= $this->o["stars"]; if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($id); } if ($allow_vote) { $allow_vote = gdsrBlgDB::check_vote($id, $user, 'article', $ip, false, false); } } if ($allow_vote) { gdsrBlgDB::save_vote($id, $user, $ip, $ua, $votes, $comment_id); if ($this->o["cmm_integration_prevent_duplicates"] == 1) { gdsrFrontHelp::save_cookie($id); } do_action("gdsr_vote_rating_article_integrate", $id, $user, $votes); } } if ($this->post_comment["multi_id"] > 0 && $this->post_comment["multi_rating"] != "") { $set_id = $this->post_comment["multi_id"]; $set = gd_get_multi_set($set_id); $values = explode("X", $this->post_comment["multi_rating"]); $allow_vote = true; foreach ($values as $v) { if ($v > $set->stars || $v < $mur_minimum) { $allow_vote = false; break; } } if ($this->o["cmm_integration_prevent_duplicates"] == 1) { if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($id . "#" . $set_id, "multis"); } if ($allow_vote) { $allow_vote = GDSRDBMulti::check_vote($id, $user, $set_id, 'multis', $ip, false, false); } } if ($allow_vote) { $ip = $_SERVER["REMOTE_ADDR"]; $ua = $this->o["save_user_agent"] == 1 ? $_SERVER["HTTP_USER_AGENT"] : ""; $data = GDSRDatabase::get_post_data($id); GDSRDBMulti::save_vote($id, $set->multi_id, $user, $ip, $ua, $values, $data, $comment_id); GDSRDBMulti::recalculate_multi_averages($id, $set->multi_id, "", $set, true); if ($this->o["cmm_integration_prevent_duplicates"] == 1) { gdsrFrontHelp::save_cookie($id . "#" . $set_id, "multis"); } do_action("gdsr_vote_rating_multis_integrate", $id, $user, $set_id, $values); } } }
function add_empty_comments($post_id) { global $wpdb, $table_prefix; $dbt_data_comment = $table_prefix . 'gdsr_data_comment'; $sql = sprintf("select c.comment_ID from %s c left join %s g on c.comment_ID = g.comment_ID where (isnull(g.post_id) or g.post_id < 1) and c.comment_approved = 1 and c.comment_type = '' and c.comment_post_id = %s", $wpdb->comments, $dbt_data_comment, $post_id); $cmms = $wpdb->get_results($sql); foreach ($cmms as $c) { GDSRDatabase::add_empty_comment($c->comment_ID, $post_id); } }
function render_comment($post, $comment, $user, $override = array()) { if ($this->o["comments_active"] != 1) { return ""; } if ($this->is_bot) { return ""; } $dbg_allow = "F"; $allow_vote = true; if ($this->is_ban && $this->o["ip_filtering"] == 1) { if ($this->o["ip_filtering_restrictive"] == 1) { return ""; } else { $allow_vote = false; } $dbg_allow = "B"; } $rd_unit_width = $this->o["cmm_size"]; $rd_unit_count = $this->o["cmm_stars"]; $rd_unit_style = $this->is_ie6 ? $this->o["cmm_style_ie6"] : $this->o["cmm_style"]; $rd_post_id = intval($post->ID); $rd_user_id = intval($user->ID); $rd_comment_id = intval($comment->comment_ID); $rd_is_page = $post->post_type == "page" ? "1" : "0"; if ($this->p) { $post_data = $this->p; } else { if (is_single() || is_page()) { $this->init_post(); $post_data = $this->p; } else { $post_data = GDSRDatabase::get_post_data($rd_post_id); if (count($post_data) == 0) { GDSRDatabase::add_default_vote($rd_post_id, $rd_is_page); $post_data = GDSRDatabase::get_post_data($rd_post_id); } } } if ($post_data->rules_comments == "H") { return ""; } $comment_data = GDSRDatabase::get_comment_data($rd_comment_id); if (count($comment_data) == 0) { GDSRDatabase::add_empty_comment($rd_comment_id, $rd_post_id); $comment_data = GDSRDatabase::get_comment_data($rd_comment_id); } if ($allow_vote) { if ($this->o["cmm_author_vote"] == 1 && $rd_user_id == $comment->user_id && $rd_user_id > 0) { $allow_vote = false; $dbg_allow = "A"; } } if ($allow_vote) { if ($post_data->rules_comments == "" || $post_data->rules_comments == "A" || $post_data->rules_comments == "U" && $rd_user_id > 0 || $post_data->rules_comments == "V" && $rd_user_id == 0) { $allow_vote = true; } else { $allow_vote = false; $dbg_allow = "R_" . $post_data->rules_comments; } } if ($allow_vote) { $allow_vote = GDSRDatabase::check_vote($rd_comment_id, $rd_user_id, 'comment', $_SERVER["REMOTE_ADDR"], $this->o["cmm_logged"] != 1, $this->o["cmm_allow_mixed_ip_votes"] == 1); if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = $this->check_cookie($rd_comment_id, "comment"); if (!$allow_vote) { $dbg_allow = "C"; } } $votes = 0; $score = 0; if ($post_data->rules_comments == "A" || $post_data->rules_comments == "N") { $votes = $comment_data->user_voters + $comment_data->visitor_voters; $score = $comment_data->user_votes + $comment_data->visitor_votes; } else { if ($post_data->rules_comments == "V") { $votes = $comment_data->visitor_voters; $score = $comment_data->visitor_votes; } else { $votes = $comment_data->user_voters; $score = $comment_data->user_votes; } } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $comment->user_id ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array(); $tags_css["CMM_CSS_BLOCK"] = $this->o["cmm_class_block"]; $tags_css["CMM_CSS_HEADER"] = $this->o["srb_class_header"]; $tags_css["CMM_CSS_STARS"] = $this->o["cmm_class_stars"]; $tags_css["CMM_CSS_TEXT"] = $this->o["cmm_class_text"]; if ($override["tpl"] > 0) { $template_id = $override["tpl"]; } else { $template_id = $this->o["default_crb_template"]; } $rating_block = GDSRRenderT2::render_crb($template_id, $rd_comment_id, "ratecmm", "c", $votes, $score, $rd_unit_style, $rd_unit_width, $rd_unit_count, $allow_vote, $rd_user_id, "comment", $tags_css, $this->o["cmm_header_text"], $debug, $this->loader_comment); return $rating_block; }