View file script/comment.php

File size: 3.09Kb
<?php
/*-----------------------------------------------------------------------------------------
mcGalleryPRO
All code is © 2003 Marc Cagninacci.
No files may be redistributed in whole or significant part.
----------------- mcgalleryPRO IS NOT FREE SOFTWARE -------------------
You should have receive a file called license.txt in this package
--------------------------------------------------------------------------------------------*/

function courte($tottext)
{
$chap = explode("<br />", $tottext);
while (list($key, $text) = each($chap))
{
  $text = trim($text); 
  $tab_w = explode(" ", $text);
  $nb_w = count($tab_w);
  $nb_i = 0; 
  $string = ""; 
  for ($i = 0; $i < $nb_w; $i++)
  { 
   $tmp_w = strip_tags($tab_w[$i]);
   $nb_i+= strlen($tmp_w);
   if ($nb_i < 110)
   { 
    $nb_i+= 1; 
    $string.= $tab_w[$i]." "; //
   } 
   else 
   { 
    $string.= "<br>".$tab_w[$i]." "; //
    $nb_i = strlen($tmp_w);
   }
  }
  $out.= '<br>'.$string;
}
return $out;
}

$id = $row['id'];
$query = "SELECT COUNT(note) as nb, AVG(note) as avg FROM mcgallery_comment WHERE id_photo=$id AND valid='Y' AND type='$selt' AND note != '' GROUP BY id_photo";
$result=mysql_query($query);
$raw = mysql_fetch_row($result);
if ($raw[0] > 0)
{
echo '<tr><td class="td1" align="right" colspan="2"><font size="1">';
echo $l_rating_av.': ';
echo '<img src="images/orange.gif" width="'.($raw[1] * 10).'" height="8" alt="'.round($raw[1], 2).'/10 ('.$raw[0].' '.$l_rates.')" border="0">';
echo '<img src="images/grey.gif" width="'.(100 - ($raw[1] * 10)).'" height="8" alt="'.round($raw[1], 2).'/10 ('.$raw[0].' '.$l_rates.')" border="0">';
echo '</font></td></tr>';
}
$query = "SELECT id, date, email, author, text, note  FROM mcgallery_comment WHERE id_photo=$id AND valid='Y' AND type='$selt' ORDER BY date DESC, id DESC";
$result=mysql_query($query);

include 'smilies.php';

while ($comm=mysql_fetch_array($result))
 {
 echo '<tr><td class="td2">';
 echo '<font size="1">&nbsp;'.$comm['date'].'&nbsp;<b>'.stripslashes($comm['author']).'</b>';
 echo '<a href="#" onclick="javascript:window.open(\'./mailto.php?to='.$comm['id'].'\',\'\',\'width=300,height=350,left=100, top=100\');" onMouseOver="window.status=\'\';return true"><img src="images/ecrire.gif" border="0" alt=""></a>';
 echo '</font></td>';
 echo '<td class="td2" align="right"><font size="1">';
 	if ($comm['note'] != '')
 	{
  	echo $l_rating.': <img src="images/orange.gif" width="'.($comm['note'] * 10).'" height="8" alt="'.$comm['note'].'/10" border="0">';
  	echo '<img src="images/grey.gif" width="'.(100 - ($comm['note'] * 10)).'" height="8" alt="'.$comm['note'].'/10" border="0">';
  	}
 	else echo '&nbsp;';
 echo '</font></tr>';
 echo '<tr><td class="td2" colspan="2" width="'.($taille[0]*1.1).'">';
 echo '<font size="1">';
 $comm['text'] = preg_replace('/([^ ]{50})/si','\\1 ',$comm['text']);
 $texte = courte(nl2br(htmlspecialchars(stripslashes($comm['text']))));
 $texte = str_replace($images, $smilies, $texte);
 echo $texte;
 echo '</font></td></tr>';
 echo '<tr><td class="td1" colspan="2" height="2">';
 } 
?>