function rate_article($aid, $rate, $uid) { $rated = check_if_user_rate_article($aid, $uid); if ($rated) { update_rate($aid, $rate, $uid); } else { add_rate($aid, $rate, $uid); } }
function rate_change() { global $_STATE; if ($_SERVER['REQUEST_METHOD'] == "POST") { //POST carries rate data save_input(); $_STATE->replies = array(); } else { foreach ($_GET as $field => $reply) { //GET carries replies $_STATE->replies[$field] = $reply; } } if (!audit_input()) { return; } if ($_STATE->rates[$_STATE->rate_ndx]["ID"] == 0) { add_rate(); } elseif ($_STATE->new_rate["eff"] == 0) { delete_rate(); } else { update_rate(); } }