<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
	<channel>
		<title>cotonti.com : multiple page ratings.</title>
		<link>https://www.cotonti.com</link>
		<description>Останні повідомлення в темі</description>
		<generator>Cotonti</generator>
		<language>en</language>
		<pubDate>Wed, 15 Apr 2026 09:38:37 -0000</pubDate>

		<item>
			<title>Trustmaster</title>
			<description><![CDATA[Will check this later. Could you please use <a href="http://www.cotonti.com/pastebin/">Pastebin</a> for code snippets?]]></description>
			<pubDate>Сб, 04 Кві 2009 12:04:22 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/ua/forums?m=posts&q=2541&d=0#post11014]]></link>
		</item>
		<item>
			<title>Elgan</title>
			<description><![CDATA[hey so im not a fan of javascript or a guru and hardly know it. but i gave this a go, it all works, posting it here as i dont actually know what to do with it and plan to sleep more tomorrow. some can look, validate, improve, check js etc.  To fix the issue of multiple ratings on a single page.<br />
<br />
ive implamented the code on my demo site here.<br />
<a href="http://www.mods-r-us.net/demo/plug.php?e=medialibrary&amp;category=2" rel="nofollow">http://www.mods-r-us.net/demo/plug.php?e=medialibrary&amp;category=2</a><br />
<br />
Plus some people could look through and slate.<br />
<br />
i noticed on the star plugin they released a new version. so i downlaoded this to implament as new usually means better.<br />
was this wrong? as the last jquery.rating.js had been edited for cotonti. I thought if i didnt edit it, it would be easier to update later tho.<br />
so i havent.<br />
 <br />
jquery.rating.js is default and downloaded here<br />
<a href="http://jquery-star-rating-plugin.googlecode.com/svn/trunk/jquery.rating.js" rel="nofollow">http://jquery-star-rating-plugin.googlecode.com/svn/trunk/jquery.rating.js</a><br />
<br />
because of the update i also used the css from their new version download here<br />
<a href="http://jquery-star-rating-plugin.googlecode.com/svn/trunk/jquery.rating.css" rel="nofollow">http://jquery-star-rating-plugin.googlecode.com/svn/trunk/jquery.rating.css</a><br />
<br />
<br />
<br />
ratings.tpl<br />
<div class="highlight"><pre class="html">
&lt;!-- BEGIN: RATINGS --&gt;


&lt;!-- BEGIN: RATINGS_INCLUDES --&gt;
	&lt;script type=&quot;text/javascript&quot; src=https://www.cotonti.com/&quot;js/jquery.rating.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
	//&lt;!&#091;CDATA&#091;
	$(function() {
		$('.rating_submit').hide();

		/*
			### Default implementation ###
		*/
		$('input&#091;type=radio&#093;.star').rating
		(
			//options
			{
				half: true,
				callback: function(value, link) 
				{
					ratingval = link.getAttribute('tabindex');
					$('&#091;name=' + $(this).attr(&quot;name&quot;) + '&#093;.rating_submit').show();
				}
			}
		); 


		$('.rating_submit').click(
			function() {
				
				var name =  $(this).attr(&quot;name&quot;);
				var formname = 'newrating_' + name;
				var datastr = $(&quot;#&quot; + formname).serialize();
				//datastr += '&amp;rcde=' + name;
				
				//hide away the submit button again
				$('&#091;name=' + name + '&#093;.rating_submit').hide();
				
				//get rating block
				var rating = $('&#091;name=' + name + '&#093;.rating');				
				//get rating_average block
				var rating_average = $('&#091;name=' + name + '&#093;.rating_average');				

				rating.hide();

				ajaxSend({
					method: 'POST',
					formId: formname,
					divId: 'loading',
					data:  datastr,
				});
				
				var getdata = &quot;&amp;rcde=&quot; + name;
				var get_url = &quot;{RATINGS_AJAX_REQUEST}&quot;;
				get_url += &quot;&amp;rcde=&quot; + name;
				//append which rating we are to the get url
				$.get(get_url,
					{
					'rcde=': name
					},

					function(data) 
					{
						if(data)
						{	
							
							rating_average.addClass('rating').removeClass('rating_average').show();
							rating_average.replaceWith('&lt;div name=&quot;' + name + '&quot; class=&quot;rating&quot;&gt;'+data+'&lt;/div&gt;');
							rating.remove();
						}
						else
						{
							//alert(&quot;failed&quot;);
							rating.show();
						}
					}					
				);

				return false;
		});
	});
	//&#093;&#093;&gt;
	&lt;/script&gt;
	&lt;!-- END: RATINGS_INCLUDES --&gt;
&lt;!-- BEGIN: NOTVOTED --&gt;

&lt;form action=&quot;{RATINGS_FORM_SEND}&quot; method=&quot;post&quot; id=&quot;{FORM_NAME}&quot; name=&quot;{FORM_NAME}&quot; style=&quot;display:inline;clear:none;margin:0;padding:0&quot;&gt;
	&lt;div class=&quot;rating&quot; name=&quot;{RATING_NAME}&quot;&gt;
		&lt;!-- BEGIN: RATINGS_ROW --&gt;
			&lt;noscript&gt;{RATINGS_ROW_VALUE}&lt;/noscript&gt;
			&lt;input type=&quot;radio&quot; name=&quot;{RATING_NAME}&quot; type=&quot;radio&quot; class=&quot;star&quot; value=&quot;{RATINGS_ROW_VALUE}&quot; title=&quot;{RATINGS_ROW_TITLE}&quot; {RATINGS_ROW_CHECKED} {RATINGS_ROW_DISABLED}/&gt;
		&lt;!-- END: RATINGS_ROW --&gt;

		&lt;input type=&quot;submit&quot; value=&quot;{PHP.skinlang.ratings.Rateit}&quot; class=&quot;rating_submit&quot;  name=&quot;{RATING_NAME}&quot; /&gt;
	&lt;/div&gt;

	&lt;div style=&quot;display:inline;clear:none;margin:0;padding:0&quot;&gt;
		&lt;div name=&quot;{RATING_NAME}&quot; class=&quot;rating_average&quot; style=&quot;display:none;&quot;&gt;
			{RATINGS_FANCYIMG}
		&lt;/div&gt;
	&lt;/div&gt;

&lt;/form&gt;

&lt;!-- END: NOTVOTED --&gt;

&lt;!-- BEGIN: VOTED --&gt;
&lt;div style=&quot;display:inline;clear:none;margin:0;padding:0&quot;&gt;
	&lt;div name=&quot;{RATING_NAME}&quot; class=&quot;rating&quot;&gt;
		{RATINGS_FANCYIMG}
	&lt;/div&gt;
&lt;/div&gt;
&lt;!-- END: VOTED --&gt;

&lt;!-- END: RATINGS --&gt;

</pre></div>
<br />
sed_build_ratings<br />
<br />
<div class="highlight"><pre class="php">
function sed_build_ratings($code, $url, $display)
{
	global $db_ratings, $db_rated, $db_users, $cfg, $usr, $sys, $L;
	static $called = false;

	//$url .= '&amp;amp;rcde='.$code;
	$is_code = sed_import('rcde','G','ALP');
	$p_is_code = sed_import('rcde','P','ALP');

	$is_code = (!empty($p_is_code)) ? $p_is_code : $is_code;

	//if we are not the comment element thats being updated then skip
	if(!empty($is_code) )
	{
		if($is_code != $code)
		{
			return (array('',''));
		}
		else{


		}
	}

	list($usr&#091;'auth_read_rat'&#093;, $usr&#091;'auth_write_rat'&#093;, $usr&#091;'isadmin_rat'&#093;) = sed_auth('ratings', 'a');

	if ($cfg&#091;'disable_ratings'&#093; || !$usr&#091;'auth_read_rat'&#093;)
	{
		return (array('',''));
	}

	$sql = sed_sql_query(&quot;SELECT * FROM $db_ratings WHERE rating_code='$code' LIMIT 1&quot;);

	if($row = sed_sql_fetcharray($sql))
	{
		$rating_average = $row&#091;'rating_average'&#093;;
		$yetrated = TRUE;
		if($rating_average&lt;1)
		{ $rating_average = 1; }
		elseif ($rating_average&gt;10)
		{ $rating_average = 10; }
		$rating_cntround = round($rating_average, 0);
	}
	else
	{
		$yetrated = FALSE;
		$rating_average = 0;
		$rating_cntround = 0;
	}
	$rating_fancy =  '';
	for($i = 1; $i &lt;= 10; $i++)
	{
		$checked = $i == $rating_cntround ? 'checked=&quot;checked&quot;' : '';
		$star_class = ($i &lt;= $rating_cntround) ? 'star-rating star_group_newrate star-rating-readonly star-rating-on' : 'star-rating star_group_newrate star-rating-readonly';
		$star_margin = (in_array(($i/2), array(1,2,3,4,5))) ? '-8' : '0';
		$rating_fancy .= '&lt;div style=&quot;width: 8px;&quot; class=&quot;'.$star_class.'&quot;&gt;&lt;a style=&quot;margin-left: '.$star_margin.'px;&quot; tabindex=&quot;'.$i.'&quot; title=&quot;'.$L&#091;'rat_choice' . $i&#093;.'&quot;&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;';
	}
	if(!$display)
	{
		return array($rating_fancy, '');
	}

	if($_GET&#091;'ajax'&#093;)
	{
		ob_clean();
		echo $rating_fancy;
		ob_flush();
		exit;
	}

	$sep = mb_strstr($url, '?') ? '&amp;amp;' : '?';

	$t = new XTemplate(sed_skinfile('ratings'));

	$t-&gt;assign(array(
	'RATING_NAME' =&gt; $code,
	&quot;FORM_NAME&quot; =&gt; &quot;newrating_$code&quot;,
	));

	$inr = sed_import('inr','G','ALP');

	//$newrate = sed_import('newrate','P','INT');
	$newrate = sed_import($code,'P','INT');
	$newrate = (!empty($newrate)) ? $newrate : 0;

	if(!$cfg&#091;'ratings_allowchange'&#093;)
	{
		$alr_rated = sed_sql_result(sed_sql_query(&quot;SELECT COUNT(*) FROM &quot;.$db_rated.&quot; WHERE rated_userid=&quot;.$usr&#091;'id'&#093;.&quot; AND rated_code = '&quot;.sed_sql_prep($code).&quot;'&quot;), 0, 'COUNT(*)');
	}
	else
	{
		$alr_rated = 0;
	}


	if ($inr=='send' &amp;&amp; $newrate&gt;=0 &amp;&amp; $newrate&lt;=10 &amp;&amp; $usr&#091;'auth_write_rat'&#093; &amp;&amp; $alr_rated&lt;=0)
	{
		/* == Hook for the plugins == */
		$extp = sed_getextplugins('ratings.send.first');
		if (is_array($extp))
		{ foreach($extp as $k =&gt; $pl) { include_once($cfg&#091;'plugins_dir'&#093;.'/'.$pl&#091;'pl_code'&#093;.'/'.$pl&#091;'pl_file'&#093;.'.php'); } }
		/* ===== */

		$sql = sed_sql_query(&quot;DELETE FROM $db_rated WHERE rated_code='&quot;.sed_sql_prep($code).&quot;' AND rated_userid='&quot;.$usr&#091;'id'&#093;.&quot;' &quot;);

		if (!$yetrated)
		{
			$sql = sed_sql_query(&quot;INSERT INTO $db_ratings (rating_code, rating_state, rating_average, rating_creationdate, rating_text) VALUES ('&quot;.sed_sql_prep($code).&quot;', 0, &quot;.(int)$newrate.&quot;, &quot;.(int)$sys&#091;'now_offset'&#093;.&quot;, '') &quot;);
		}

		$sql = ($newrate) ? sed_sql_query(&quot;INSERT INTO $db_rated (rated_code, rated_userid, rated_value) VALUES ('&quot;.sed_sql_prep($code).&quot;', &quot;.(int)$usr&#091;'id'&#093;.&quot;, &quot;.(int)$newrate.&quot;)&quot;) : '';
		$sql = sed_sql_query(&quot;SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code'&quot;);
		$rating_voters = sed_sql_result($sql, 0, &quot;COUNT(*)&quot;);
		if ($rating_voters&gt;0)
		{
			$ratingnewaverage = sed_sql_result(sed_sql_query(&quot;SELECT AVG(rated_value) FROM $db_rated WHERE rated_code='$code'&quot;), 0, &quot;AVG(rated_value)&quot;);
			$sql = sed_sql_query(&quot;UPDATE $db_ratings SET rating_average='$ratingnewaverage' WHERE rating_code='$code'&quot;);
		}
		else
			{ $sql = sed_sql_query(&quot;DELETE FROM $db_ratings WHERE rating_code='$code' &quot;); }

		/* == Hook for the plugins == */
		$extp = sed_getextplugins('ratings.send.done');
		if (is_array($extp))
		{ foreach($extp as $k =&gt; $pl) { include_once($cfg&#091;'plugins_dir'&#093;.'/'.$pl&#091;'pl_code'&#093;.'/'.$pl&#091;'pl_file'&#093;.'.php'); } }
		/* ===== */



		header('Location: ' . SED_ABSOLUTE_URL . $url);
		exit;

	}

	if ($usr&#091;'id'&#093;&gt;0)
	{
		$sql1 = sed_sql_query(&quot;SELECT rated_value FROM $db_rated WHERE rated_code='$code' AND rated_userid='&quot;.$usr&#091;'id'&#093;.&quot;' LIMIT 1&quot;);

		if ($row1 = sed_sql_fetcharray($sql1))
		{
			$alreadyvoted = ($cfg&#091;'ratings_allowchange'&#093;) ? FALSE : TRUE;
			$rating_uservote = $L&#091;'rat_alreadyvoted'&#093;.&quot; (&quot;.$row1&#091;'rated_value'&#093;.&quot;)&quot;;
		}
	}
	if(!$called &amp;&amp; $usr&#091;'id'&#093;&gt;0 &amp;&amp; !$alreadyvoted)
	{
		// Link JS and CSS
		$sep = mb_strstr($url, '?') ? '&amp;' : '?';
		$t-&gt;assign('RATINGS_AJAX_REQUEST', $url . $sep .'ajax=true');
		$t-&gt;parse('RATINGS.RATINGS_INCLUDES');
		$called = true;
	}
	/* == Hook for the plugins == */
	$extp = sed_getextplugins('ratings.main');
	if (is_array($extp))
	{ foreach($extp as $k =&gt; $pl) { include_once($cfg&#091;'plugins_dir'&#093;.'/'.$pl&#091;'pl_code'&#093;.'/'.$pl&#091;'pl_file'&#093;.'.php'); } }
	/* ===== */

	$sep = mb_strstr($url, '?') ? '&amp;amp;' : '?';

	if ($yetrated)
	{
		$sql = sed_sql_query(&quot;SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' &quot;);
		$rating_voters = sed_sql_result($sql, 0, &quot;COUNT(*)&quot;);
		$rating_average = $row&#091;'rating_average'&#093;;
		$rating_since = $L&#091;'rat_since'&#093;.&quot; &quot;.date($cfg&#091;'dateformat'&#093;, $row&#091;'rating_creationdate'&#093; + $usr&#091;'timezone'&#093; * 3600);
		if ($rating_average&lt;1)
		{ $rating_average = 1; }
		elseif ($ratingaverage&gt;10)
		{ $rating_average = 10; }

		$rating = round($rating_average,0);
		$rating_averageimg = &quot;&lt;img src=https://www.cotonti.com/\&quot;skins/&quot;.$usr&#091;'skin'&#093;.&quot;/img/system/vote&quot;.$rating.&quot;.gif\&quot; alt=\&quot;\&quot; /&gt;&quot;;
		$sql = sed_sql_query(&quot;SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' &quot;);
		$rating_voters = sed_sql_result($sql, 0, &quot;COUNT(*)&quot;);
	}
	else
	{
		$rating_voters = 0;
		$rating_since = '';
		$rating_average = 0;
		$rating_averageimg = '';
	}

	$t-&gt;assign(array(
	&quot;RATINGS_AVERAGE&quot; =&gt; $rating_average,
	&quot;RATINGS_RATING&quot; =&gt; $rating,
	&quot;RATINGS_AVERAGEIMG&quot; =&gt; $rating_averageimg,
	&quot;RATINGS_VOTERS&quot; =&gt; $rating_voters,
	&quot;RATINGS_SINCE&quot; =&gt; $rating_since,
	&quot;RATINGS_FANCYIMG&quot; =&gt; $rating_fancy,
	&quot;RATINGS_USERVOTE&quot; =&gt; $rating_uservote
	));

	/* == Hook for the plugins == */
	$extp = sed_getextplugins('ratings.tags');
	if (is_array($extp))
	{ foreach($extp as $k =&gt; $pl) { include_once($cfg&#091;'plugins_dir'&#093;.'/'.$pl&#091;'pl_code'&#093;.'/'.$pl&#091;'pl_file'&#093;.'.php'); } }
	/* ===== */

	$vote_block = ($usr&#091;'id'&#093;&gt;0 &amp;&amp; !$alreadyvoted) ? 'NOTVOTED.' : 'VOTED.';
	for($i = 1; $i &lt;= 10; $i++)
	{
		$checked = $i == $rating_cntround ? 'checked=&quot;checked&quot;' : '';
		$t-&gt;assign(array(
			'RATINGS_ROW_VALUE' =&gt; $i,
			'RATINGS_ROW_TITLE' =&gt; $L&#091;'rat_choice' . $i&#093;,
			'RATINGS_ROW_CHECKED' =&gt; $checked,
		));
		$t-&gt;parse('RATINGS.'.$vote_block.'RATINGS_ROW');
	}
	if($vote_block == 'NOTVOTED.')
	{
		$t-&gt;assign(&quot;RATINGS_FORM_SEND&quot;, $url . $sep . &quot;inr=send&amp;amp;rcde=&quot;.$code);
		$t-&gt;parse('RATINGS.NOTVOTED');
	}
	else
	{
		$t-&gt;parse('RATINGS.VOTED');
	}
	$t-&gt;parse('RATINGS');
	$res = $t-&gt;text('RATINGS');

	return array($res, '');
}
</pre></div>]]></description>
			<pubDate>Сб, 04 Кві 2009 10:57:04 -0000</pubDate>
			<link><![CDATA[https://www.cotonti.com/ua/forums?m=posts&q=2541&d=0#post11008]]></link>
		</item>
	</channel>
</rss>