function render_article_actual($settings) { $rd_post_id = intval($settings[1]); $rd_is_page = intval($settings[2]); $post_author = intval($settings[3]); $post_date = intval($settings[4]); $override["tpl"] = intval($settings[5]); $override["read_only"] = intval($settings[6]); $override["size"] = intval($settings[7]); $override["style"] = $this->g->g->stars[$settings[8]]->folder; $override["style_ie6"] = $this->g->g->stars[$settings[9]]->folder; $rd_user_id = intval($settings[10]); $dbg_allow = "F"; $already_voted = false; $allow_vote = $override["read_only"] == 0; $allow_vote = apply_filters("gdsr_allow_vote_stars_article", $allow_vote, $rd_post_id); if ($this->g->override_readonly_standard) { $allow_vote = false; $dbg_allow = "RTO"; } 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"; } if ($override["read_only"] == 1) { $dbg_allow = "RO"; } $rd_unit_count = $this->g->o["stars"]; $rd_unit_width = $override["size"]; $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"]; $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_articles = $post_data->rules_articles != "I" ? $post_data->rules_articles : $this->g->get_post_rule_value($rd_post_id, "rules_articles", "default_voterules_articles"); if ($rules_articles == "H") { return ""; } if ($allow_vote) { if ($rules_articles == "" || $rules_articles == "A" || $rules_articles == "U" && $rd_user_id > 0 || $rules_articles == "V" && $rd_user_id == 0) { $allow_vote = true; } else { $allow_vote = false; $dbg_allow = "R_" . $rules_articles; } } if ($allow_vote) { if ($this->g->o["author_vote"] == 1 && $rd_user_id == $post_author) { $allow_vote = false; $dbg_allow = "A"; } } $remaining = 0; $deadline = ''; $expiry_type = 'N'; if ($allow_vote && ($post_data->expiry_type == 'D' || $post_data->expiry_type == 'T' || $post_data->expiry_type == 'I')) { $expiry_type = $post_data->expiry_type != 'I' ? $post_data->expiry_type : $this->g->get_post_rule_value($rd_post_id, "expiry_type", "default_timer_type"); $expiry_value = $post_data->expiry_type != 'I' ? $post_data->expiry_value : $this->g->get_post_rule_value($rd_post_id, "expiry_value", "default_timer_value"); switch ($expiry_type) { case "D": $remaining = gdsrFrontHelp::expiration_date($expiry_value); $deadline = $expiry_value; break; case "T": $remaining = gdsrFrontHelp::expiration_countdown($post_date, $expiry_value); $deadline = gdsrFrontHelp::calculate_deadline($remaining); break; } if ($remaining < 1) { gdsrBlgDB::lock_post($rd_post_id); $allow_vote = false; $dbg_allow = "T"; } } $already_voted = !wp_gdget_postlog($rd_post_id); if ($allow_vote) { $allow_vote = !$already_voted; if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($rd_post_id); if (!$allow_vote) { $dbg_allow = "C"; } } $votes = $score = 0; if ($rules_articles == "A" || $rules_articles == "N") { $votes = $post_data->user_voters + $post_data->visitor_voters; $score = $post_data->user_votes + $post_data->visitor_votes; } else { if ($rules_articles == "V") { $votes = $post_data->visitor_voters; $score = $post_data->visitor_votes; } else { $votes = $post_data->user_voters; $score = $post_data->user_votes; } } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $post_author ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array("CSS_BLOCK" => $this->g->o["srb_class_block"], "CSS_HEADER" => $this->g->o["srb_class_header"], "CSS_STARS" => $this->g->o["srb_class_stars"], "CSS_TEXT" => $this->g->o["srb_class_text"]); $template_id = $override["tpl"]; $rating_block = GDSRRenderT2::render_srb($template_id, array("already_voted" => $already_voted, "post_id" => $rd_post_id, "class" => "ratepost", "type" => "a", "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" => "article", "tags_css" => $tags_css, "header_text" => $this->g->o["header_text"], "debug" => $debug, "wait_msg" => $this->loader_article, "time_restirctions" => $expiry_type, "time_remaining" => $remaining, "time_date" => $deadline)); return $rating_block; }
function render_article($post_gd, $user_gd, $override = array("tpl" => 0)) { 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"; } if (is_single() || is_page() && $this->o["display_comment_page"] == 1) { $this->init_post(); } $rd_unit_width = $this->o["size"]; $rd_unit_count = $this->o["stars"]; $rd_unit_style = $this->is_ie6 ? $this->o["style_ie6"] : $this->o["style"]; $rd_post_id = intval($post_gd->ID); $rd_user_id = intval($user_gd->ID); $rd_is_page = $post_gd->post_type == "page" ? "1" : "0"; if ($this->p) { $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_articles == "H") { return ""; } if ($allow_vote) { if ($this->o["author_vote"] == 1 && $rd_user_id == $post_gd->post_author) { $allow_vote = false; $dbg_allow = "A"; } } if ($allow_vote) { if ($post_data->rules_articles == "" || $post_data->rules_articles == "A" || $post_data->rules_articles == "U" && $rd_user_id > 0 || $post_data->rules_articles == "V" && $rd_user_id == 0) { $allow_vote = true; } else { $allow_vote = false; $dbg_allow = "R_" . $post_data->rules_articles; } } $remaining = 0; $deadline = ''; if ($allow_vote && ($post_data->expiry_type == 'D' || $post_data->expiry_type == 'T')) { switch ($post_data->expiry_type) { case "D": $remaining = GDSRHelper::expiration_date($post_data->expiry_value); $deadline = $post_data->expiry_value; break; case "T": $remaining = GDSRHelper::expiration_countdown($post_gd->post_date, $post_data->expiry_value); $deadline = GDSRHelper::calculate_deadline($remaining); break; } if ($remaining < 1) { GDSRDatabase::lock_post($rd_post_id); $allow_vote = false; $dbg_allow = "T"; } } if ($allow_vote) { $allow_vote = GDSRDatabase::check_vote($rd_post_id, $rd_user_id, 'article', $_SERVER["REMOTE_ADDR"], $this->o["logged"] != 1, $this->o["allow_mixed_ip_votes"] == 1); if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = $this->check_cookie($rd_post_id); if (!$allow_vote) { $dbg_allow = "C"; } } $votes = 0; $score = 0; if ($post_data->rules_articles == "A" || $post_data->rules_articles == "N") { $votes = $post_data->user_voters + $post_data->visitor_voters; $score = $post_data->user_votes + $post_data->visitor_votes; } else { if ($post_data->rules_articles == "V") { $votes = $post_data->visitor_voters; $score = $post_data->visitor_votes; } else { $votes = $post_data->user_voters; $score = $post_data->user_votes; } } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $post_gd->post_author ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array(); $tags_css["CSS_BLOCK"] = $this->o["srb_class_block"]; $tags_css["CSS_HEADER"] = $this->o["srb_class_header"]; $tags_css["CSS_STARS"] = $this->o["srb_class_stars"]; $tags_css["CSS_TEXT"] = $this->o["srb_class_text"]; if ($override["tpl"] > 0) { $template_id = $override["tpl"]; } else { $template_id = $this->o["default_srb_template"]; } $rating_block = GDSRRenderT2::render_srb($template_id, $rd_post_id, "ratepost", "a", $votes, $score, $rd_unit_style, $rd_unit_width, $rd_unit_count, $allow_vote, $rd_user_id, "article", $tags_css, $this->o["header_text"], $debug, $this->loader_article, $post_data->expiry_type, $remaining, $deadline); return $rating_block; }