function vote_article_ajax($votes, $id, $tpl_id) { global $userdata; $ip = $_SERVER["REMOTE_ADDR"]; if ($this->o["save_user_agent"] == 1) { $ua = $_SERVER["HTTP_USER_AGENT"]; } else { $ua = ""; } $user = intval($userdata->ID); wp_gdsr_dump("VOTE", "[POST: " . $id . "] --" . $votes . "-- [" . $user . "]"); $allow_vote = intval($votes) <= $this->o["stars"]; if ($allow_vote) { $allow_vote = $this->check_cookie($id); } if ($allow_vote) { $allow_vote = GDSRDatabase::check_vote($id, $user, 'article', $ip, $this->o["logged"] != 1, $this->o["allow_mixed_ip_votes"] == 1); } if ($allow_vote) { GDSRDatabase::save_vote($id, $user, $ip, $ua, $votes); $this->save_cookie($id); } $data = GDSRDatabase::get_post_data($id); $unit_width = $this->o["size"]; $unit_count = $this->o["stars"]; $votes = 0; $score = 0; if ($data->rules_articles == "A" || $data->rules_articles == "N") { $votes = $data->user_voters + $data->visitor_voters; $score = $data->user_votes + $data->visitor_votes; } else { if ($data->rules_articles == "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 = $rating2 * $unit_width; include $this->plugin_path . 'code/t2/gd-star-t2-templates.php'; $template = new gdTemplateRender($tpl_id, "SRB"); $rt = GDSRRenderT2::render_srt($template->dep["SRT"], $rating1, $unit_count, $votes, $post_id); return "{ status: 'ok', value: " . $rating_width . ", rater: '" . $rt . "' }"; }