function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID); $barvotes = GetBarVotes($postID); if (function_exists('VoteItUp_options')) { ?> <span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID; ?> " style="width:<?php echo round($barvotes[0] * 2.5); ?> %;"> </span></span> <?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } ?> <?php } } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } ?> <?php } ?> <?php } else { /*Guest voting disabled*/ ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> <?php } } } }
function DisplayVotes($postID, $type = '') { global $user_ID, $guest_votes, $vote_text, $use_votetext, $allow_sinks, $voteiu_skin; $postID = wp_kses($postID, array()); // Sanitize, just in case $voteiu_skin = get_option('voteiu_skin'); $votes = GetVotes($postID); $barvotes = GetBarVotes($postID); switch ($type) { case '': // In the event no theme selected, use the current theme if ($voteiu_skin == '') { return DisplayVotes($postID, 'bar'); } else { if (!LoadSkin($voteiu_skin)) { return DisplayVotes($postID, 'bar'); } } break; // The following themes below are pre-defined themes in the event there are no other themes found // The following themes below are pre-defined themes in the event there are no other themes found case 'bar': ?> <span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID; ?> " style="width:<?php echo round($barvotes[0] * 2.5); ?> %;"> </span></span><?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <span><?php if (!UserVoted($postID, $user_ID)) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span><?php } else { if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } } ?> </span><?php } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <span><?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span><?php } ?> </span><?php } } break; case 'ticker': ?> <span class="tickercontainer" id="votes<?php the_ID(); ?> "><?php echo $votes; ?> </span><?php if ($user_ID != '') { ?> <span id="voteid<?php the_ID(); ?> "><?php if (!UserVoted($postID, $user_ID)) { ?> <span class="tickertext"><?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a><?php } else { ?> <span class="imagecontainer"><?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a><?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span><?php } ?> </span><?php } ?> </span><?php } else { if ($guest_votes == 'true') { ?> <span id="voteid<?php the_ID(); ?> "><?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="tickertext"><?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a></span><?php } else { ?> <span class="imagecontainer"><?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a><?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span><?php } ?> </span><?php } ?> </span><?php } } break; } }
if ($v_uid != '') { if ($v_uid == 0) { //Guest voting if ($_GET['type'] != 'sink') { GuestVote($v_pid, 'vote'); } else { GuestVote($v_pid, 'sink'); } } else { //Add vote if ($_GET['type'] != 'sink') { Vote($v_pid, $v_uid, 'vote'); } else { Vote($v_pid, $v_uid, 'sink'); } } } if ($v_tid == 'total') { echo GetVotes($v_pid, false); } else { if ($v_tid == 'percent') { //run the math as a percentage not total echo GetVotes($v_pid, true); } else { $barvotes = GetBarVotes($v_pid); echo $barvotes[0]; } } } else { echo '0'; }
} $showhits = ($referrer and preg_match("/.*?house=z/", $referrer)); if ($mpval and $vformfilled) { $mpprop = $mpval["mpprop"]; $party = $mpprop["party"]; $name = $mpprop["name"]; $constituency = $mpprop["constituency"]; $minentered_house = $mpval["minentered_house"]; $vnvotes = array("part4_terroristcertification" => array("2001-11-21", 75, "Power of Home Secretary to certify individuals as terrorists"), "part4_indefinitedetention" => array("2001-11-21", 76, "Power to detain certified terrorists indefinitely if foreign"), "public_emergency" => array("2001-11-21", 70, "Declaration of public emergency threatening the life of the nation"), "part4_siac" => array("2001-11-21", 77), "part4_privy" => array("2004-02-25", 59), "part4_renewal" => array("2004-03-03", 71, "Renewal of law for detaining certified terrorists indefinitely"), "d90days" => array("2005-11-09", 84, "Extention of period of detention without charge to 90 days"), "d28days" => array("2005-11-09", 85, "Extention of period of detention to 28 days (but not 60)"), "d42days_enable" => array("2008-06-11", 219, "Conditions to enable detention without charge up to 42 days"), "d42days_procedure" => array("2008-06-11", 220, "Power to detain suspects without charge for up to 42 days")); # book the values into a database #$db->query("drop table if exists pw_dyn_fortytwoday_comments"); #$db->query("create table pw_dyn_fortytwoday_comments (vterdet varchar(10), vpubem varchar(20), ltime timestamp, vrand int, vpostcode varchar(20), constituency varchar(80))"); #$db->query("INSERT INTO pw_dyn_fortytwoday_comments (vterdet, vpubem, ltime, vrand, vpostcode, constituency) # VALUES ('$vterdet', '$vpubem', NOW(), $vrand, '$vpostcode', '".mysql_real_escape_string($constituency)."')"); # looks up as a batch. Or we could look up individually for easier coding $votes = GetVotes($db, $mpprop["person"], 1039); foreach ($vnvotes as $vname => &$vnvote) { $vnvote[] = GetVote($votes, $vnvote[0], $vnvote[1]); } print "<div id=\"content\">\n"; $atcsa = "<a href=\"http://www.opsi.gov.uk/acts/acts2001/ukpga_20010024_en_1\">Anti-terrorism, Crime and Security Act 2001</a>"; $party = $mpprop["party"]; print "<p><b><a href=\"http://www.publicwhip.org.uk/mp.php?" . $mpprop["mpanchor"] . "\">{$name} MP ({$party})</a></b>,\n representing the constituency of <b>{$constituency}</b>,\n"; if ($minentered_house == "1997-05-01") { print " has been in Parliament long enough to vote on the detention of \n terrorist suspects without charge for up to 90 days, as well as \n on earlier laws of indefinite detention without charge of foreign suspects under the {$atcsa}.\n"; } else { print " entered Parliament on " . pretty_date($minentered_house) . ",\n"; print " and was able to vote on the detention of terrorist suspects without charge "; print " for up to 42 days"; if ($d90days != "notmp") { print " and to 90 days.";
function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID, true); if (function_exists('VoteItUp_options')) { ?> <span class="vote-it-up"> <span class="tickercontainer" id="votecount<?php the_ID(); ?> "><?php echo $votes == false ? "Vote" : $votes; ?> </span> <?php if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { ?> <span> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');" class="voteuplink"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');" class="votedownlink"><?php echo get_option('voteiu_sinktext'); ?> </a></span> <?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } ?> <?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <span id="voteid<?php the_ID(); ?> "> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');" class="voteuplink"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');" class="votedownlink"><?php echo get_option('voteiu_sinktext'); ?> </a></span><?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="tickertext" id="voteid<?php the_ID(); ?> "><span class="votelink"><?php echo get_option('voteiu_aftervotetext'); ?> </span></span><?php } ?> <?php } } else { /*Guest voting disabled*/ ?> <span class="tickertext"> <span class="votelink" id="voteid<?php the_ID(); ?> "><a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a></span><?php } ?> </span> </span> <?php } ?> <?php } } }
function DisplayVotes($postID, $type = '') { global $user_ID, $guest_votes, $vote_text, $use_votetext, $allow_sinks, $voteiu_skin, $user_login; $voteiu_skin = get_option('voteiu_skin'); $votes = GetVotes($postID); $barvotes = GetBarVotes($postID); switch ($type) { case '': if ($voteiu_skin == '') { DisplayVotes($postID, 'bar'); //Use default bar } else { if (!LoadSkin($voteiu_skin)) { DisplayVotes($postID, 'bar'); //Use default bar } } break; case 'bar': ?> <span class="barcontainer"><span class="barfill" id="votecount<?php echo $postID; ?> " style="width:<?php echo round($barvotes[0] * 2.5); ?> %;"> </span></span> <?php if ($user_ID != '') { if (!($user_login == get_the_author_meta('login') && !get_option('voteiu_allowownvote'))) { ?> <span> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a> <?php } ?> </span> <?php } else { ?> <?php if (get_option('voteiu_aftervotetext') != '') { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span><?php } ?> <?php } ?> </span> <?php } } else { if (get_option('voteiu_allowguests') == 'true') { ?> <span> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="bartext" id="voteid<?php the_ID(); ?> "> <a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a> <?php } ?> </span> <?php } ?> </span> <?php } } break; case 'ticker': ?> <span class="tickercontainer" id="votes<?php the_ID(); ?> "><?php echo $votes; ?> </span> <?php if ($user_ID != '') { ?> <span id="voteid<?php the_ID(); ?> "> <?php if (!UserVoted($postID, $user_ID)) { ?> <span class="tickertext"> <?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a> <?php } else { ?> <span class="imagecontainer"> <?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a> <?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span> <?php } ?> </span> <?php } ?> </span> <?php } else { if ($guest_votes == 'true') { ?> <span id="voteid<?php the_ID(); ?> "> <?php if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { ?> <span class="tickertext"> <?php if ($use_votetext == 'true') { ?> <a class="votelink" href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo $vote_text; ?> </a></span> <?php } else { ?> <span class="imagecontainer"> <?php if ($allow_sinks == 'true') { ?> <a href="javascript:sink_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="votedown" src="<?php echo VoteItUp_ExtPath(); ?> /votedown.png" alt="Vote down" border="0" /> </a> <?php } ?> <a href="javascript:vote_ticker(<?php echo $postID; ?> ,<?php echo $postID; ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"> <img class="voteup" src="<?php echo VoteItUp_ExtPath(); ?> /voteup.png" alt="Vote up" border="0" /> </a> </span> <?php } ?> </span> <?php } ?> </span> <?php } } break; } }
function GetBarVotes($post_ID) { //Some minor configuration $max_displayed_votes = 40; $vote_threshold = 30; $votes = GetVotes($post_ID); $votemax = $max_displayed_votes; $votebreak = 30; //votes at which bar changes color $bar[0] = 0; //The length of the bar $bar[1] = 0; //The state of the bar if ($votes > $votemax && $votes > -1) { $bar[0] = $votemax; } else { if ($votes > -1) { $bar[0] = $votes; } else { $bar[0] = 0; } } if ($votes > $votebreak) { $bar[1] = 1; } return $bar; }
function SortVotes() { global $wpdb, $voteiu_databasetable; mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); //Set a limit to reduce time taken for script to run $upperlimit = get_option('voteiu_limit'); if ($upperlimit == '') { $upperlimit = 100; } $lowerlimit = 0; $postarray = array(); $votesarray = array(); //Use wordpress posts table //For posts to be available for vote editing, they must be published posts. mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); //Sorts by date instead of ID for more accurate representation, also only count actual posts that are published $posttablecontents = mysql_query("SELECT ID FROM " . $wpdb->prefix . "posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT " . $lowerlimit . ", " . $upperlimit . "") or die(mysql_error()); $returnarray = array(); while ($row = mysql_fetch_array($posttablecontents)) { $post_id = $row['ID']; $vote_array = GetVotes($post_id, "array"); array_push($postarray, array($post_id)); array_push($votesarray, array(GetVotes($post_id))); } array_multisort($votesarray, SORT_DESC, $postarray); $output = array($postarray, $votesarray); return $output; }
function Vote($post_ID, $user_ID, $type) { global $wpdb; // this shit has prevent sql injection but not the login check. :@ and 49.721 sites use this crap? if (!current_user_can('read')) { return false; } //Prevents SQL injection $p_ID = $wpdb->escape($post_ID); $u_ID = $wpdb->escape($user_ID); //Create entries if not existant SetPost($p_ID); SetUser($u_ID); //Gets the votes $votes_raw = $wpdb->get_var("SELECT votes FROM " . $wpdb->prefix . "votes WHERE post='" . $p_ID . "'"); $sinks_raw = $wpdb->get_var("SELECT usersinks FROM " . $wpdb->prefix . "votes WHERE post='" . $p_ID . "'"); $uservotes_raw = $wpdb->get_var("SELECT votes FROM " . $wpdb->prefix . "votes_users WHERE user='******'"); $usersinks_raw = $wpdb->get_var("SELECT sinks FROM " . $wpdb->prefix . "votes_users WHERE user='******'"); //Gets the votes in array form $votes = explode(",", $votes_raw); $sinks = explode(",", $sinks_raw); $uservotes = explode(",", $uservotes_raw); $usersinks = explode(",", $usersinks_raw); //Check if user voted if (!UserVoted($post_ID, $user_ID)) { //user hasn't vote, so the script allows the user to vote if ($type != 'sink') { //Add vote to array $user_var[0] = $u_ID; $post_var[0] = $p_ID; $votes_result = array_merge($votes, $user_var); $votes_result_raw = implode(",", $votes_result); $uservotes_result = array_merge($uservotes, $post_var); $uservotes_result_raw = implode(",", $uservotes_result); $sinks_result_raw = $sinks_raw; $usersinks_result_raw = $usersinks_raw; } else { //Add sink to array $user_var[0] = $u_ID; $post_var[0] = $p_ID; $sinks_result = array_merge($sinks, $user_var); $sinks_result_raw = implode(",", $sinks_result); $usersinks_result = array_merge($usersinks, $post_var); $usersinks_result_raw = implode(",", $usersinks_result); $votes_result_raw = $votes_raw; $uservotes_result_raw = $votesinks_raw; } //Prevents SQL injection $votes_result_sql = $wpdb->escape($votes_result_raw); $sinks_result_sql = $wpdb->escape($sinks_result_raw); $uservotes_result_sql = $wpdb->escape($uservotes_result_raw); $usersinks_result_sql = $wpdb->escape($usersinks_result_raw); //Update votes $wpdb->query("UPDATE " . $wpdb->prefix . "votes SET votes='" . $votes_result_sql . "' WHERE post='" . $p_ID . "'"); $wpdb->query("UPDATE " . $wpdb->prefix . "votes SET usersinks='" . $sinks_result_sql . "' WHERE post='" . $p_ID . "'"); $wpdb->query("UPDATE " . $wpdb->prefix . "votes_users SET votes='" . $uservotes_result_sql . "' WHERE user='******'"); $wpdb->query("UPDATE " . $wpdb->prefix . "votes_users SET sinks='" . $usersinks_result_sql . "' WHERE user='******'"); // can't fix much in this crap, so just adding GetVote as a quick hack to add the vote count to post meta $result = GetVotes($post_ID); update_post_meta($post_ID, 'votes', $result); } else { //The user voted, thus the script will not update the votes in the article //$result = 'false'; // wtf? 'false'? // return votes count :) $result = GetVotes($post_ID); } return $result; //returns '' on failure, returns 'true' if votes were casted, returns 'false' if user already casted a vote }
function LoadVote() { global $user_ID, $user_login; $postID = get_the_ID(); $votes = GetVotes($postID); if (function_exists('VoteItUp_options')) { if ($user_ID != '') { if (!($user_login == get_the_author_login() && !get_option('voteiu_allowownvote'))) { /* Post author can vote own post */ if (!UserVoted($postID, $user_ID)) { /* User has not voted */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"><span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,<?php echo $user_ID; ?> ,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span></div> </div></div> <?php } else { /* User has voted */ if (get_option('voteiu_aftervotetext') != '') { /* After-vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div id="voteid<?php the_ID(); ?> " class="post_votebuttoncontainer"><span class="post_votebutton"><?php echo get_option('voteiu_aftervotetext'); ?> </span></div> </div></div> <?php } else { /* After-vote text not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Post author cannot vote own post */ if (get_option('voteiu_aftervotetext') != '') { /* After-vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"><span class="post_votebutton" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span></div> </div></div> <?php } else { /* After-vote text not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Guest is attempting to vote */ if (get_option('voteiu_allowguests') == 'true') { /* Guest voting allowed */ if (!GuestVoted($postID, md5($_SERVER['REMOTE_ADDR']))) { /* Guest has not voted */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:vote('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:sink('votecount<?php the_ID(); ?> ','voteid<?php the_ID(); ?> ','<?php echo get_option('voteiu_aftervotetext'); ?> ',<?php the_ID(); ?> ,0,'<?php echo VoteItUp_ExtPath(); ?> ');"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> </div></div></div> <?php } else { /* Guest has voted */ if (get_option('voteiu_aftervotetext') != '') { /* After vote text was set */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><?php echo get_option('voteiu_aftervotetext'); ?> </span> </div></div></div> <?php } else { /* After vote text was not set */ ?> <div class="post_postvote"><div class="post_votewidget_closed" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> </div></div> <?php } } } else { /* Guest voting disabled */ ?> <div class="post_postvote"><div class="post_votewidget" id="votewidget<?php the_ID(); ?> "> <div class="post_votecount" id="votecount<?php the_ID(); ?> "><?php echo $votes; ?> </div> <div class="post_votebuttoncontainer"> <span class="post_votebutton" id="voteid<?php the_ID(); ?> "><a href="javascript:regboxopen();"><?php echo get_option('voteiu_votetext'); ?> </a><?php if (get_option('voteiu_sinktext') != '') { ?> <a href="javascript:regboxopen();"><?php echo get_option('voteiu_sinktext'); ?> </a><?php } ?> </span> </div></div></div> <?php } } } }