Ejemplo n.º 1
0
function pullRating($id, $show5 = false, $showPerc = false, $showVotes = false, $static = NULL)
{
    // Check if they have already voted...
    $text = '';
    $sel = mysql_query("SELECT id FROM ratings WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "' AND beer_id = '{$id}'");
    if (mysql_num_rows($sel) > 0 || $static == 'novote' || isset($_COOKIE['has_voted_' . $id])) {
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $text .= 'Rated <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        }
        if ($showPerc) {
            $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($id) . '</span>)';
        }
        if ($showVotes) {
            $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($id) . '</span>)';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '</div>';
        }
        return $text . '
			<ul class="star-rating2" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="return false;" href="#" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="return false;" href="#" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="return false;" href="#" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="return false;" href="#" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="return false;" href="#" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			<div id="loading_' . $id . '"></div>';
    } else {
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $show5bool = 'true';
            $text .= 'Rated <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        } else {
            $show5bool = 'false';
        }
        if ($showPerc) {
            $showPercbool = 'true';
            $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($id) . '</span>)';
        } else {
            $showPercbool = 'false';
        }
        if ($showVotes) {
            $showVotesbool = 'true';
            $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($id) . '</span>)';
        } else {
            $showVotesbool = 'false';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '</div>';
        }
        return $text . '
			<ul class="star-rating" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="rate(\'1\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=1" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="rate(\'2\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="rate(\'3\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="rate(\'4\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="rate(\'5\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			<div id="loading_' . $id . '"></div>';
    }
}
Ejemplo n.º 2
0
function pullRating($media, $id, $show5 = false, $showPerc = false, $showVotes = false, $static = NULL)
{
    $sql = "SELECT * FROM media_rating WHERE media_id = '{$id}' AND media_type = '{$media}' AND user_id = '{$user}'";
    $query = @mysql_query($sql);
    $count = @mysql_num_rows($query);
    if ($count > 0) {
        $msg = " --  You have voted all ready!";
        exit;
        $text = '';
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $text .= '<b>Rated:&nbsp;</b><span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        }
        if ($showPerc) {
            $text .= '(<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
        }
        if ($showVotes) {
            $text .= '(<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '';
        }
        return $text . '
		  <span class="inline-rating">
			<ul class="star-rating2" id="rater_' . $id . '">
			<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
			<li><a onclick="return false;" title="1 star out of 5 ' . $msg . '" class="one-star">1</a></li>
			<li><a onclick="return false;" title="2 stars out of 5 ' . $msg . '" class="two-stars">2</a></li>
			<li><a onclick="return false;" title="3 stars out of 5 ' . $msg . '" class="three-stars">3</a></li>
			<li><a onclick="return false;" title="4 stars out of 5 ' . $msg . '" class="four-stars">4</a></li>
			<li><a onclick="return false;" title="5 stars out of 5 ' . $msg . '" class="five-stars">5</a></li>
			</ul>
		  </span>
			</div>
			<div id="loading_' . $id . '"></div>';
        exit;
    } else {
        $sel = mysql_query("SELECT user_id FROM media_rating WHERE IP = '" . $_SERVER['REMOTE_ADDR'] . "' AND media_type = '{$media}' AND media_id = '{$id}'");
        if (mysql_num_rows($sel) > 0 || $static == 'novote' || $_COOKIE['has_voted_' . $media . '_' . $id]) {
            if ($static == 'novote') {
                $msg = " Please Login to vote";
                $text = '';
            } else {
                $msg = " --  You have voted for this item";
                $text = '';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '<div class="rated_text">';
            }
            if ($show5) {
                $text .= '<b>Rated:&nbsp;</b> <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($media, $id) . '</span>/5';
            }
            if ($showPerc) {
                $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
            }
            if ($showVotes) {
                $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '';
            }
            return $text . '
			<span class="inline-rating">
			<ul class="star-rating2" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="return false;" title="1 star out of 5 ' . $msg . '" class="one-star">1</a></li>
				<li><a onclick="return false;" title="2 stars out of 5 ' . $msg . '" class="two-stars">2</a></li>
				<li><a onclick="return false;" title="3 stars out of 5 ' . $msg . '" class="three-stars">3</a></li>
				<li><a onclick="return false;" title="4 stars out of 5 ' . $msg . '" class="four-stars">4</a></li>
				<li><a onclick="return false;" title="5 stars out of 5 ' . $msg . '" class="five-stars">5</a></li>
			</ul>
			</span>
			</div>
			<div id="loading_' . $id . '"></div>';
        } else {
            if ($show5 || $showPerc || $showVotes) {
                $text .= '<div class="rated_text">';
            }
            if ($show5) {
                $show5bool = 'true';
                $text .= '<b>Rated:&nbsp;</b><span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($media, $id) . '</span>/5';
            } else {
                $show5bool = 'false';
            }
            if ($showPerc) {
                $showPercbool = 'true';
                $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
            } else {
                $showPercbool = 'false';
            }
            if ($showVotes) {
                $showVotesbool = 'true';
                $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
            } else {
                $showVotesbool = 'false';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '';
            }
            return $text . '
			<span class="inline-rating">
			<ul class="star-rating" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="rate(\'' . $media . '\',\'1\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=1" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'2\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'3\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'4\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'5\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			</span>
			</div>
			<div id="loading_' . $id . '"></div>';
        }
    }
}