12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- class postRating
- {
- // rateIt(): Affiche si nécessaire le formulaire
- function rateIt($ret='<form action ="" method="POST"><select name="ri_value"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select><input type="submit" value="Valider"><input type="hidden" name="ri_id" value="%s"></form>')
- {
- global $con;
- $rs = $con->select('SELECT rate_ip FROM '.DB_PREFIX.'rate WHERE rate_post_id='.$GLOBALS['news']->f('post_id').' AND rate_ip=\''.$_SERVER["REMOTE_ADDR"].'\'','recordset', false);
- // Sinon, s'il n'a jamais voté on affiche le formulaire
- if ($rs->isEmpty())
- {
- printf($ret, $GLOBALS['news']->f('post_id'));
- }
- }
-
- // getRate(): Renvois la note moyenne du billet
- function getRate($ret='Rating for this post: %s(%s)')
- {
- global $con;
- $rs = $con->select('SELECT rate_value FROM '.DB_PREFIX.'rate WHERE rate_post_id='.$GLOBALS['news']->f('post_id'),'recordset', false);
- if ($rs->isEmpty())
- {
- printf($ret,0,0);
-
- }else{
- $tot=0;
- while ($rs->fetch())
- $tot += $rs->f('rate_value');
- printf($ret, round(($tot / $rs->int_row_count), 2), $rs->int_row_count);
- }
- }
- function checkNewVersion($current, $check)
- {
- $current = explode('.',$current);
- $check = explode('.',$check);
- if( $check[0] > $current[0] )
- {
- return true;
- }elseif(( $check[0] == $current[0] ) && ( $check[1] > $current[1] )){
- return true;
- }else{
- return false;
- }
- }
- }
- ?>
|