/** * Returns object with all needed rating properties for comment. * * @global object $comment comment data * @global GDStarRating $gdsr main rating class instance * @param int $post_id post to get rating for, leave 0 to get post from loop * @return object rating post properties */ function wp_gdsr_rating_comment($comment_id = 0) { if ($comment_id < 1) { global $comment; $comment_id = $comment->comment_ID; } $comment_data = GDSRDatabase::get_comment_data($comment_id); if (count($comment_data) == 0) { return null; } return new GDSRCommentRating($comment_data); }
function import_srfr_execute($sql, $review_rating = 5, $max_value = 5) { global $wpdb, $table_prefix; $data = $wpdb->get_results($sql); foreach ($data as $row) { $id = $row->ID; $is_page = $row->post_type == 'page' ? '1' : '0'; $old_rating = $row->rating; $rating = number_format($old_rating * ($review_rating / $max_value), 1); $sql_update = sprintf("update %sgdsr_data_article set review = '%s' where post_id = %s", $table_prefix, $rating, $id); $wpdb->query($sql_update); if ($wpdb->rows_affected == 0) { GDSRDatabase::add_default_vote($id, $is_page, $rating); } } }
function update_settings($ids, $upd_am, $upd_ar, $upd_cm, $upd_cr, $upd_am_rcc, $upd_ar_rcc, $upd_cm_rcc, $upd_cr_rcc, $ids_array) { global $wpdb, $table_prefix; GDSRDatabase::add_defaults($ids, $ids_array); $dbt_data_article = $table_prefix . 'gdsr_data_article'; $update = array(); if ($upd_am != '') { $update[] = "moderate_articles = '" . $upd_am . "'"; } if ($upd_cm != '') { $update[] = "moderate_comments = '" . $upd_cm . "'"; } if ($upd_ar != '') { $update[] = "rules_articles = '" . $upd_ar . "'"; } if ($upd_cr != '') { $update[] = "rules_comments = '" . $upd_cr . "'"; } if ($upd_am_rcc != '') { $update[] = "recc_moderate_articles = '" . $upd_am_rcc . "'"; } if ($upd_cm_rcc != '') { $update[] = "recc_moderate_comments = '" . $upd_cm_rcc . "'"; } if ($upd_ar_rcc != '') { $update[] = "recc_rules_articles = '" . $upd_ar_rcc . "'"; } if ($upd_cr_rcc != '') { $update[] = "recc_rules_comments = '" . $upd_cr_rcc . "'"; } if (count($update) > 0) { $updstring = join(", ", $update); $wpdb->query(sprintf("update %s set %s where post_id in %s", $dbt_data_article, $updstring, $ids)); } }
<?php global $comment, $gdsr; $review = GDSRDatabase::get_comment_review($comment->comment_ID); ?> <div id="gdsrreviewdiv" class="stuffbox"> <h3>GD Star Rating</h3> <div class="inside"> <?php wp_gdsr_new_comment_review($review); ?> <input type="hidden" id="gdsr_comment_edit" name="gdsr_comment_edit" value="edit" /> </div> </div>
function render_multi_rating_actual($settings) { if ($this->g->is_bot && $this->g->o["bot_message"] != "normal") { return GDSRRender::render_locked_response($this->g->o["bot_message"]); } $rd_post_id = intval($settings[1]); $rd_is_page = intval($settings[2]); $post_author = intval($settings[3]); $post_date = intval($settings[4]); $override["id"] = intval($settings[11]); $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]); $override["average_size"] = intval($settings[12]); $override["average_stars"] = $this->g->g->stars[$settings[13]]->folder; $override["average_stars_ie6"] = $this->g->g->stars[$settings[14]]->folder; $set = gd_get_multi_set($override["id"]); if ($set == null) { return ""; } $rd_unit_width = $override["size"]; $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"]; $rd_unit_width_avg = $override["average_size"]; $rd_unit_style_avg = $this->g->is_ie6 ? $override["average_stars_ie6"] : $override["average_stars"]; $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, $override["id"]); if ($this->g->override_readonly_multis) { $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"; } $remaining = 0; $deadline = ""; $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 ($this->g->o["author_vote"] == 1 && $rd_user_id == $post_author) { $allow_vote = false; $dbg_allow = "A"; } } 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; } } $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 = !GDSRDBMulti::check_vote($rd_post_id, $rd_user_id, $set->multi_id, 'multis', $_SERVER["REMOTE_ADDR"], $this->g->o["logged"] != 1, $this->g->o["mur_allow_mixed_ip_votes"] == 1); if ($allow_vote) { $allow_vote = !$already_voted; if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($rd_post_id . "#" . $set->multi_id, "multis"); if (!$allow_vote) { $dbg_allow = "C"; } } $multi_record_id = GDSRDBMulti::get_vote($rd_post_id, $set->multi_id, count($set->object)); $multi_data = GDSRDBMulti::get_values($multi_record_id); $votes = array(); foreach ($multi_data as $md) { $single_vote = array(); $single_vote["votes"] = 0; $single_vote["score"] = 0; if ($rules_articles == "A" || $rules_articles == "N") { $single_vote["votes"] = $md->user_voters + $md->visitor_voters; $single_vote["score"] = $md->user_votes + $md->visitor_votes; } else { if ($rules_articles == "V") { $single_vote["votes"] = $md->visitor_voters; $single_vote["score"] = $md->visitor_votes; } else { $single_vote["votes"] = $md->user_voters; $single_vote["score"] = $md->user_votes; } } $rating = $single_vote["votes"] > 0 ? $single_vote["score"] / $single_vote["votes"] : 0; if ($rating > $set->stars) { $rating = $set->stars; } $single_vote["rating"] = @number_format($rating, 1); $votes[] = $single_vote; } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $post_author ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array("MUR_CSS_BUTTON" => $this->g->o["mur_class_button"], "MUR_CSS_BLOCK" => $this->g->o["mur_class_block"], "MUR_CSS_HEADER" => $this->g->o["mur_class_header"], "MUR_CSS_STARS" => $this->g->o["mur_class_stars"], "MUR_CSS_TEXT" => $this->g->o["mur_class_text"]); $mur_button = $this->g->o["mur_button_active"] == 1; if (!$allow_vote) { $mur_button = false; } $template_id = $override["tpl"]; return GDSRRenderT2::render_mrb($template_id, array("already_voted" => $already_voted, "style" => $rd_unit_style, "allow_vote" => $allow_vote, "votes" => $votes, "post_id" => $rd_post_id, "set" => $set, "height" => $rd_unit_width, "header_text" => $this->g->o["mur_header_text"], "tags_css" => $tags_css, "avg_style" => $rd_unit_style_avg, "avg_size" => $rd_unit_width_avg, "star_factor" => 1, "time_restirctions" => $expiry_type, "time_remaining" => $remaining, "time_date" => $deadline, "button_active" => $mur_button, "button_text" => $this->g->o["mur_button_text"], "debug" => $debug, "wait_msg" => $this->loader_multis)); }
function gd_get_rating_ajax($post) { $rating = GDSRDatabase::get_post_data($post->ID); $uservoters = $rating->user_voters; $visitorvoters = $rating->visitor_voters; $votes = $uservoters + $visitorvotes; $uservotes = $rating->user_votes; $visitorvotes = $rating->visitor_votes; if ($votes > 0) { $finalrating = number_format(($visitorvotes + $uservotes) / ($visitorvoters + $uservoters), 1); } return GDSRRender::render_static_stars("magnovus", "20", "5", $finalrating, "", "", 1); }
function vote_comment($votes, $id, $tpl_id, $unit_width) { global $userdata; $user = is_object($userdata) ? $userdata->ID : 0; $ip = $_SERVER["REMOTE_ADDR"]; if ($this->g->o["save_user_agent"] == 1) { $ua = $_SERVER["HTTP_USER_AGENT"]; } else { $ua = ""; } $vote_value = $votes; wp_gdsr_dump("VOTE_CMM", "[CMM: " . $id . "] --" . $votes . "-- [" . $user . "] " . $unit_width . "px"); $allow_vote = intval($votes) <= $this->g->o["cmm_stars"] && intval($votes) > 0; if ($allow_vote) { $allow_vote = gdsrFrontHelp::check_cookie($id, 'comment'); } if ($allow_vote) { $allow_vote = gdsrBlgDB::check_vote($id, $user, 'comment', $ip, $this->g->o["cmm_logged"] != 1, $this->g->o["cmm_allow_mixed_ip_votes"] == 1); } if ($allow_vote) { gdsrBlgDB::save_vote_comment($id, $user, $ip, $ua, $votes); gdsrFrontHelp::save_cookie($id, 'comment'); do_action("gdsr_vote_rating_comment", $id, $user, $votes); } $data = GDSRDatabase::get_comment_data($id); $post_data = GDSRDatabase::get_post_data($data->post_id); $unit_count = $this->g->o["cmm_stars"]; $votes = $score = 0; if ($post_data->rules_comments == "A" || $post_data->rules_comments == "N") { $votes = $data->user_voters + $data->visitor_voters; $score = $data->user_votes + $data->visitor_votes; } else { if ($post_data->rules_comments == "V") { $votes = $data->visitor_voters; $score = $data->visitor_votes; } else { $votes = $data->user_voters; $score = $data->user_votes; } } if ($votes > 0) { $rating2 = $score / $votes; } else { $rating2 = 0; } $rating1 = @number_format($rating2, 1); $rating_width = number_format($rating2 * $unit_width, 0); include STARRATING_PATH . 'code/t2/templates.php'; $template = new gdTemplateRender($tpl_id, "CRB"); $rt = GDSRRenderT2::render_crt($template->dep["CRT"], array("rating" => $rating1, "unit_count" => $unit_count, "votes" => $votes, "vote_value" => $vote_value)); $rating_width = apply_filters("gdsr_vote_rating_comment_return", $rating_width, $unit_width, $rating1, $vote_value); return '{ "status": "ok", "value": "' . $rating_width . '", "rater": "' . str_replace('"', '\\"', $rt) . '" }'; }
GDSRDatabase::get_combo_users($filter_user); ?> <input class="button-secondary delete" type="submit" name="gdsr_filter" value="Filter" /> </div> <div class="tablenav-pages"> <?php echo $pager; ?> </div> </div> <br class="clear"/> <?php if ($vt == "post") { $sql = GDSRDatabase::get_moderation_joined($id, ($page_id - 1) * $posts_per_page, $posts_per_page, $filter_user); } else { $sql = GDSRDatabase::get_moderation($id, $vt, ($page_id - 1) * $posts_per_page, $posts_per_page, $filter_user); } $rows = $wpdb->get_results($sql, OBJECT); ?> <table class="widefat"> <thead> <tr> <th class="check-column" scope="col"><input type="checkbox" onclick="checkAll(document.getElementById('gdsr-moderation'));"/></th> <th scope="col"><?php _e("Date And Time", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("User", "gd-star-rating"); ?> </th>
function moderation_approve($ids, $ids_array) { global $wpdb, $table_prefix; $sql = sprintf("select * from %s where record_id in %s", $table_prefix . "gdsr_moderate", $ids); $rows = $wpdb->get_results($sql); foreach ($rows as $row) { if ($row->vote_type == "article") { GDSRDatabase::add_vote($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote); } if ($row->vote_type == "comment") { GDSRDatabase::add_vote_comment($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote); } } GDSRDB::moderation_delete($ids); }
function render_multi_rating($post, $user, $settings) { if ($this->is_bot) { return ""; } if (is_feed()) { return ""; } $set = gd_get_multi_set($settings["id"]); if ($set == null) { 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 ($settings["read_only"] == 1) { $dbg_allow = "RO"; $allow_vote = false; } if (is_single() || is_page() && $this->o["display_comment_page"] == 1) { $this->init_post(); } $rd_post_id = intval($post->ID); $rd_user_id = intval($user->ID); $rd_is_page = $post->post_type == "page" ? "1" : "0"; $remaining = 0; $deadline = ""; 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->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; } } 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->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 = GDSRDBMulti::check_vote($rd_post_id, $rd_user_id, $set->multi_id, 'multis', $_SERVER["REMOTE_ADDR"], $this->o["logged"] != 1, $this->o["mur_allow_mixed_ip_votes"] == 1); if (!$allow_vote) { $dbg_allow = "D"; } } if ($allow_vote) { $allow_vote = $this->check_cookie($rd_post_id . "#" . $set->multi_id, "multis"); if (!$allow_vote) { $dbg_allow = "C"; } } $multi_record_id = GDSRDBMulti::get_vote($rd_post_id, $set->multi_id, count($set->object)); $multi_data = GDSRDBMulti::get_values($multi_record_id); $votes = array(); foreach ($multi_data as $md) { $single_vote = array(); $single_vote["votes"] = 0; $single_vote["score"] = 0; if ($post_data->rules_articles == "A" || $post_data->rules_articles == "N") { $single_vote["votes"] = $md->user_voters + $md->visitor_voters; $single_vote["score"] = $md->user_votes + $md->visitor_votes; } else { if ($post_data->rules_articles == "V") { $single_vote["votes"] = $md->visitor_voters; $single_vote["score"] = $md->visitor_votes; } else { $single_vote["votes"] = $md->user_voters; $single_vote["score"] = $md->user_votes; } } if ($single_vote["votes"] > 0) { $rating = $single_vote["score"] / $single_vote["votes"]; } else { $rating = 0; } if ($rating > $set->stars) { $rating = $set->stars; } $single_vote["rating"] = @number_format($rating, 1); $votes[] = $single_vote; } $debug = $rd_user_id == 0 ? "V" : "U"; $debug .= $rd_user_id == $post->post_author ? "A" : "N"; $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]"; $tags_css = array(); $tags_css["MUR_CSS_BLOCK"] = $this->o["mur_class_block"]; $tags_css["MUR_CSS_HEADER"] = $this->o["mur_class_header"]; $tags_css["MUR_CSS_TEXT"] = $this->o["mur_class_text"]; $tags_css["MUR_CSS_BUTTON"] = $this->o["mur_class_button"]; if ($settings["tpl"] > 0) { $template_id = $settings["tpl"]; } else { $template_id = $this->o["default_mrb_template"]; } return GDSRRenderT2::render_mrb($this->o["mur_style"], $template_id, $allow_vote, $votes, $rd_post_id, $set, $this->o["mur_size"], $this->o["mur_header_text"], $tags_css, $settings["average_stars"], $settings["average_size"], $post_data->expiry_type, $remaining, $deadline, $this->o["mur_button_active"] == 1, $this->o["mur_button_text"], $debug, $this->loader_multis); }
_e("Comment Author", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("Comment Excerpt", "gd-star-rating"); ?> </th> <?php } ?> </tr> </thead> <tbody> <?php $log = GDSRDatabase::get_user_log($user_id, $vote_type, $filter_vote, ($page_id - 1) * $posts_per_page, $posts_per_page); $ips = array(); $idx = array(); foreach ($log as $l) { if (!in_array($l->ip, $ips)) { $ips[] = $l->ip; $idx[] = 1; } else { $idx[count($idx) - 1]++; } } $counter = 0; $tr_class = ""; for ($i = 0; $i < count($idx); $i++) { for ($j = 0; $j < $idx[$i]; $j++) { echo '<tr id="post-' . $log[$counter]->record_id . '" class="' . $tr_class . ' author-self status-publish" valign="top">';
function wp_gdget_comment($comment_id) { global $gdsr_cache_posts_cmm_data; $cmm = $gdsr_cache_posts_cmm_data->get($comment_id); if (!is_null($cmm) && is_object($cmm)) { return $cmm; } else { $cmm = GDSRDatabase::get_comment_data($comment_id); if (!is_object($cmm)) { return null; } $gdsr_cache_posts_cmm_data->set($comment_id, $cmm); return $cmm; } }
GDSRDatabase::ban_ip_range($ip_start, $ip_end); } } if ($_POST["action"] == "maskip") { $ip_part_1 = $_POST["gdsr_ip_mask_1"]; $ip_part_2 = $_POST["gdsr_ip_mask_2"]; $ip_part_3 = $_POST["gdsr_ip_mask_3"]; $ip_part_4 = $_POST["gdsr_ip_mask_4"]; $ip = $ip_part_1 . "." . $ip_part_2 . "." . $ip_part_3 . "." . $ip_part_4; GDSRDatabase::ban_ip($ip, 'M'); } if ($_POST["action"] == "deletebans") { $gdsr_items = $_POST["gdsr_item"]; if (count($gdsr_items) > 0) { $ids = "(" . join(", ", $gdsr_items) . ")"; GDSRDatabase::unban_ips($ids); } } ?> <div class="gdsr"> <div class="wrap"> <h2 class="gdptlogopage">GD Star Rating: <?php _e("IP's", "gd-star-rating"); ?> </h2> <div id="gdsr_tabs" class="gdsrtabs"> <ul> <li><a href="#fragment-1"><span><?php _e("Ban New", "gd-star-rating"); ?>
echo $this->get_field_name('publish_date'); ?> -month" style="display: <?php echo $instance['publish_date'] == 'month' ? 'block' : 'none'; ?> "> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="100"></td> <td width="150" nowrap="nowrap"><?php _e("Month", "gd-star-rating"); ?> :</td> <td align="right"> <?php GDSRDatabase::get_combo_months($instance['publish_month'], $this->get_field_name('publish_month')); ?> </td> </tr> </table> </div> <div id="<?php echo $this->get_field_name('publish_date'); ?> -range" style="display: <?php echo $instance['publish_date'] == 'range' ? 'block' : 'none'; ?> "> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="100"></td>
?> </select> <input class="button-secondary delete" type="submit" name="gdsr_filter" value="<?php _e("Filter", "gd-star-rating"); ?> " /> </div> <div class="tablenav-pages"> <?php echo $pager; ?> </div> </div> <br class="clear"/> <?php $sql = GDSRDatabase::get_visitors($post_id, $vote_type, $filter_date, $filter_vote, $select, ($page_id - 1) * $posts_per_page, $posts_per_page, $sort_column, $sort_order); $rows = $wpdb->get_results($sql, OBJECT); $col[0] = gdFunctionsGDSR::column_sort_vars("user_id", $sort_order, $sort_column); $col[1] = gdFunctionsGDSR::column_sort_vars("user_nicename", $sort_order, $sort_column); $col[2] = gdFunctionsGDSR::column_sort_vars("vote", $sort_order, $sort_column); $col[3] = gdFunctionsGDSR::column_sort_vars("voted", $sort_order, $sort_column); $col[4] = gdFunctionsGDSR::column_sort_vars("ip", $sort_order, $sort_column); $col[5] = gdFunctionsGDSR::column_sort_vars("user_agent", $sort_order, $sort_column); ?> <table class="widefat"> <thead> <tr> <th class="check-column" scope="col"><input type="checkbox" onclick="checkAll(document.getElementById('gdsr-articles'));"/></th> <th scope="col" nowrap="nowrap"><a href="<?php echo $b_url . $col[0]["url"];
echo $options["admin_width"]; ?> px"> <form id="gdsr-articles" method="post" action=""> <h2 class="gdptlogopage">GD Star Rating: <?php _e("Multi Set Results", "gd-star-rating"); ?> : <?php _e("Voters", "gd-star-rating"); ?> </h2> <div class="tablenav"> <div class="alignleft"> <?php GDSRDatabase::get_combo_months($filter_date); GDSRDatabase::get_combo_categories($filter_cats); ?> <input class="button-secondary delete" type="submit" name="gdsr_filter" value="<?php _e("Filter", "gd-star-rating"); ?> " /> </div> <div class="tablenav-pages"> <?php echo $pager; ?> </div> </div> <br class="clear"/> </form>
$log_url = $url . "&gdsr=userslog"; $url .= "&gdsr=users"; $page_id = 1; if (isset($_GET["pg"])) { $page_id = $_GET["pg"]; } $number_posts = GDSRDatabase::get_valid_users_count(); $max_page = floor($number_posts / $posts_per_page); if ($max_page * $posts_per_page != $number_posts) { $max_page++; } if ($max_page > 1) { $pager = GDSRHelper::draw_pager($max_page, $page_id, $url, "pg"); } $users = array(); $pre_users = GDSRDatabase::get_valid_users(); $count = -1; $usrid = -1; foreach ($pre_users as $user) { if ($user->user_id != $usrid) { $count++; } $users[$count]["id"] = $user->user_id; $users[$count][$user->vote_type]["votes"] = $user->votes; $users[$count][$user->vote_type]["voters"] = $user->voters; $users[$count][$user->vote_type]["ips"] = $user->ips; $users[$count]["name"] = $user->user_id == 0 ? __("Visitor", "gd-star-rating") : $user->display_name; $users[$count]["email"] = $user->user_id == 0 ? "/" : $user->user_email; $users[$count]["url"] = $user->user_id == 0 ? "/" : $user->user_url; $usrid = $user->user_id; }
function detect_ban() { $ip = $_SERVER["REMOTE_ADDR"]; $ban = false; $ban = GDSRDatabase::check_ip_single($ip); if (!$ban) { $ban = GDSRDatabase::check_ip_range($ip); } if (!$ban) { $ban = GDSRDatabase::check_ip_mask($ip); } return $ban; }
} if (isset($_POST["gdsr_update"]) && $_POST["gdsr_update"] == __("Update", "gd-star-rating")) { $gdsr_items = $_POST["gdsr_item"]; if (count($gdsr_items) > 0) { $ids = "(" . join(", ", $gdsr_items) . ")"; if ($_POST["gdsr_delete_articles"] != "") { GDSRDatabase::delete_votes($ids, $_POST["gdsr_delete_articles"], $gdsr_items); } if ($_POST["gdsr_delete_articles_recc"] != "") { GDSRDatabase::delete_votes($ids, $_POST["gdsr_delete_articles_recc"], $gdsr_items, true); } if ($_POST["gdsr_delete_comments"] != "") { GDSRDatabase::delete_votes($ids, $_POST["gdsr_delete_comments"], $gdsr_items); } if ($_POST["gdsr_delete_comments_recc"] != "") { GDSRDatabase::delete_votes($ids, $_POST["gdsr_delete_comments_recc"], $gdsr_items, true); } if ($_POST["gdsr_review_rating"] != "") { $review = $_POST["gdsr_review_rating"]; if ($_POST["gdsr_review_rating_decimal"] != "" && $_POST["gdsr_review_rating"] < $options["review_stars"]) { $review .= "." . $_POST["gdsr_review_rating_decimal"]; } gdsrAdmDB::update_reviews($ids, $review, $gdsr_items); } if ($_POST["gdsr_timer_type"] != "") { gdsrAdmDB::update_restrictions($ids, $_POST["gdsr_timer_type"], GDSRHelper::timer_value($_POST["gdsr_timer_type"], $_POST["gdsr_timer_date_value"], $_POST["gdsr_timer_countdown_value"], $_POST["gdsr_timer_countdown_type"])); } if ($_POST["gdsr_timer_type_recc"] != "") { gdsrAdmDB::update_restrictions_thumbs($ids, $_POST["gdsr_timer_type_recc"], GDSRHelper::timer_value($_POST["gdsr_timer_type_recc"], $_POST["gdsr_timer_date_value_recc"], $_POST["gdsr_timer_countdown_value_recc"], $_POST["gdsr_timer_countdown_type_recc"])); } gdsrAdmDB::update_settings($ids, $_POST["gdsr_article_moderation"], $_POST["gdsr_article_voterules"], $_POST["gdsr_comments_moderation"], $_POST["gdsr_comments_voterules"], $_POST["gdsr_article_moderation_recc"], $_POST["gdsr_article_voterules_recc"], $_POST["gdsr_comments_moderation_recc"], $_POST["gdsr_comments_voterules_recc"], $gdsr_items);
function get_article_rating($post_id, $is_page = '') { $post_data = wp_gdget_post($post_id); if (count($post_data) == 0) { GDSRDatabase::add_default_vote($post_id, $is_page); $post_data = wp_gdget_post($post_id); } $votes = $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; } } return array($votes, $score); }
function get_comments($post_id) { global $wpdb, $table_prefix; $dbt_data_comment = $table_prefix . 'gdsr_data_comment'; GDSRDatabase::add_empty_comments($post_id); $sql = sprintf("select g.*, c.comment_content, c.comment_author, c.comment_author_email, c.comment_author_url, c.comment_date from %s c left join %s g on c.comment_ID = g.comment_ID where c.comment_approved = 1 and c.comment_type = '' and c.comment_post_id = %s order by c.comment_date desc", $wpdb->comments, $dbt_data_comment, $post_id); return $sql; }
<td class="gdsrright"> <input style="text-align: right;" size="8" type="text" name="publishDays" id="publishDays" value="0" /> </td> </tr> </table> </div> <div id="gdsr-pd-month[tinymce]" style="display: none"> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td class="gdsrleft"><?php _e("Month", "gd-star-rating"); ?> :</td> <td class="gdsrright"> <?php GDSRDatabase::get_combo_months("0", "publishMonth"); ?> </td> </tr> </table> </div> <div id="gdsr-pd-range[tinymce]" style="display: none"> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td class="gdsrleft"><?php _e("Range", "gd-star-rating"); ?> :</td> <td align="right" width="85"><input class="widefat" style="text-align: right; width: 85px" type="text" name="publishRangeFrom" id="publishRangeFrom" value="YYYYMMDD" /></td> <td align="center" width="10">-</td> <td align="right" width="85"><input class="widefat" style="text-align: right; width: 85px" type="text" name="publishRangeTo" id="publishRangeTo" value="YYYYMMDD" /></td>
_e("Record Id", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("Type", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("IP", "gd-star-rating"); ?> </th> </tr> </thead> <tbody> <?php $rows = GDSRDatabase::get_all_banned_ips(($page_id - 1) * $posts_per_page, $posts_per_page); $tr_class = ""; foreach ($rows as $row) { echo '<tr id="post-' . $row->id . '" class="' . $tr_class . ' author-self status-publish" valign="top">'; echo '<th scope="row" class="check-column"><input name="gdsr_item[]" value="' . $row->id . '" type="checkbox"></th>'; echo '<td>' . $row->id . '</td>'; echo '<td><strong>'; switch ($row->mode) { case "S": echo "Single"; break; case "M": echo "Masked"; break; case "R": echo "Range";
} ?> </tr> </thead> <tbody> <?php $tr_class = ""; foreach ($rows as $row) { $ratings = GDSRDBMulti::calculate_set_rating($set, $row->id); echo '<tr id="post-' . $row->pid . '" class="' . $tr_class . ' author-self status-publish" valign="top">'; echo '<th scope="row" class="check-column"><input name="gdsr_item[]" value="' . $row->pid . '" type="checkbox"></th>'; echo '<td><strong>' . sprintf('<a href="./post.php?action=edit&post=%s">%s</a>', $row->pid, $row->post_title) . '</strong></td>'; echo '<td nowrap="nowrap">'; echo '<a href="' . get_permalink($row->pid) . '" target="_blank"><img src="' . STARRATING_URL . 'gfx/view.png" border="0" /></a> '; echo '</td>'; echo '<td>' . GDSRDatabase::get_categories($row->pid) . '</td>'; echo '<td>'; if ($ratings["visitors"]["votes"] == 0) { echo sprintf("[ 0 ] %s: /<br />", __("visitors", "gd-star-rating")); } else { echo sprintf('[ <a href="./admin.php?page=gd-star-rating-multi-sets&gdsr=murset&sid=%s&pid=%s&filter=visitor"><strong style="color: red;">%s</strong></a> ] %s: <strong style="color: red;">%s</strong><br />', $set_id, $row->pid, $ratings["visitors"]["votes"], __("visitors", "gd-star-rating"), $ratings["visitors"]["rating"]); } if ($ratings["users"]["votes"] == 0) { echo sprintf("[ 0 ] %s: /<br />", __("users", "gd-star-rating")); } else { echo sprintf('[ <a href="./admin.php?page=gd-star-rating-multi-sets&gdsr=murset&sid=%s&pid=%s&filter=user"><strong style="color: red;">%s</strong></a> ] %s: <strong style="color: red;">%s</strong>', $set_id, $row->pid, $ratings["users"]["votes"], __("users", "gd-star-rating"), $ratings["users"]["rating"]); } echo '</td>'; echo '<td>'; if ($ratings["total"]["votes"] == 0) { echo sprintf("[ 0 ] %s: /", __("rating", "gd-star-rating"));
function import_wpr_check($import_status) { if ($import_status == 0) { return GDSRImport::import_check(GDSRDatabase::table_exists("ratings")); } else { _e("Data imported.", "gd-star-rating"); return false; } }
if (isset($_GET["pg"])) { $page_id = $_GET["pg"]; } if (isset($_POST["gdsr_update"]) && $_POST["gdsr_update"] == __("Update", "gd-star-rating")) { $gdsr_items = $_POST["gdsr_item"]; if (count($gdsr_items) > 0) { $items = $ids = array(); foreach ($gdsr_items as $it) { $parts = explode(",", $it); $ids[] = $parts[1]; $items[$parts[1]] = $parts[0]; } gdsrAdmDB::update_category_settings("(" . join(", ", $gdsr_items) . ")", $ids, $items, $_POST["gdsr_article_moderation"], $_POST["gdsr_article_voterules"], $_POST["gdsr_comments_moderation"], $_POST["gdsr_comments_voterules"], $_POST["gdsr_integration_mur"], $_POST["gdsr_integration_active_std"], $_POST["gdsr_integration_active_mur"]); } } $all_cats = GDSRDatabase::get_all_categories(); $categories = GDSRHelper::get_categories_hierarchy($all_cats); $number_posts = count($categories); $max_page = floor($number_posts / $posts_per_page); if ($max_page * $posts_per_page != $number_posts) { $max_page++; } $pager = $max_page > 1 ? gdFunctionsGDSR::draw_pager($max_page, $page_id, $url, "pg") : ""; $cat_from = ($page_id - 1) * $posts_per_page; $cat_to = $page_id * $posts_per_page; if ($cat_to > $number_posts) { $cat_to = $number_posts; } ?> <div class="wrap">
$pager = $max_page > 1 ? gdFunctionsGDSR::draw_pager($max_page, $page_id, $url, "pg") : ""; ?> <div class="tablenav"> <div class="alignleft"> </div> <div class="tablenav-pages"> <?php echo $pager; ?> </div> </div> <br class="clear"/> <?php $sql = GDSRDatabase::get_comments($id, ($page_id - 1) * $posts_per_page, $posts_per_page); $rows = $wpdb->get_results($sql, OBJECT); ?> <table class="widefat"> <thead> <tr> <th class="check-column" scope="col"><input type="checkbox" onclick="checkAll(document.getElementById('gdsr-moderation'));"/></th> <th scope="col"><?php _e("Comment", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("User", "gd-star-rating"); ?> </th>
function save_vote($id, $user, $ip, $ua, $vote, $comment_id = 0) { global $wpdb, $table_prefix; $ua = str_replace("'", "''", $ua); $ua = substr($ua, 0, 250); $sql = sprintf("SELECT * FROM %sgdsr_data_article WHERE post_id = %s", $table_prefix, $id); $post_data = $wpdb->get_row($sql); if (count($post_data) == 0) { GDSRDatabase::add_default_vote($id); $post_data = $wpdb->get_row($sql); } if ($post_data->moderate_articles == "" || $post_data->moderate_articles == "N" || $post_data->moderate_articles == "V" && $user > 0 || $post_data->moderate_articles == "U" && $user == 0) { gdsrBlgDB::add_vote($id, $user, $ip, $ua, $vote, $comment_id); } else { $modsql = sprintf("INSERT INTO %sgdsr_moderate (id, vote_type, user_id, vote, voted, ip, user_agent, comment_id) VALUES (%s, 'article', %s, %s, '%s', '%s', '%s', %s)", $table_prefix, $id, $user, $vote, str_replace("'", "''", current_time('mysql')), $ip, $ua, $comment_id); $wpdb->query($modsql); } }
echo $wpnm; ?> ]" style="display: <?php echo $wpno['publish_date'] == 'month' ? 'block' : 'none'; ?> "> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="100"></td> <td width="150" nowrap="nowrap"><?php _e("Month", "gd-star-rating"); ?> :</td> <td align="right"> <?php GDSRDatabase::get_combo_months($wpno['publish_month'], $wpfn . "[publish_month]"); ?> </td> </tr> </table> </div> <div id="gdsr-pd-range[<?php echo $wpnm; ?> ]" style="display: <?php echo $wpno['publish_date'] == 'range' ? 'block' : 'none'; ?> "> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="100"></td>