Example #1
0
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);
        ?>
%;">&nbsp;</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 
            }
        }
    }
}
Example #2
0
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 
        }
    }
}
Example #3
0
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);
            ?>
%;">&nbsp;</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;
    }
}
Example #4
0
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);
            ?>
%;">&nbsp;</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 Vote($post_ID, $user_ID, $type)
{
    global $wpdb;
    //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='******'");
        $result = 'true';
    } else {
        //The user voted, thus the script will not update the votes in the article
        $result = 'false';
    }
    return $result;
    //returns '' on failure, returns 'true' if votes were casted, returns 'false' if user already casted a vote
}
function GuestVote($post_ID, $type = 'vote')
{
    global $wpdb, $voteiu_databasetable;
    $result = false;
    $user_ID = md5($_SERVER['REMOTE_ADDR']);
    //Prevents SQL injection
    $p_ID = $wpdb->escape($post_ID);
    $u_ID = $wpdb->escape($user_ID);
    if (!UserVoted($post_ID, $user_ID)) {
        if ($type == 'vote') {
            InsertVote($p_ID, $u_ID, 'guestvote');
        } else {
            InsertVote($p_ID, $u_ID, 'guestsink');
        }
        $result = true;
    }
    return $result;
    //returns true if the vote is saved, false if no changes were made
}
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
}
Example #8
0
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 
            }
        }
    }
}