I've been working on the voting of cpg,
I thought it could use some new voting pic.
Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!
Solution to this ex-problem can be found at the bottom
To intall this, follow these steps:
First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images
Then in your "template.html" add the following above the </head> tag:
<script type="text/javascript" src="scripts/rating/rating.js"></script>
And as a last change, in your "theme.php" file add the following code before "?>"
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact">{RATESCRIPT}</td>
</tr>
</table>
EOT;
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
global $template_image_rating, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
'{VOTES}' => $votes,
'{WIDTH}' => $CONFIG['picture_table_width'],
'{LOCATION}' => $location, //theme dir or default images directory
);
return template_eval($template_image_rating, $params);
}
To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
header('Location: displayimage.php?pos=' . (- $pic));
exit;
}
Now it works.
Have fun.