<?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($text)
{
$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 < 40)
{
$nb_i+= 1;
$string.= $tab_w[$i]." "; //
}
else
{
$string.= "<br>".$tab_w[$i]." "; //
$nb_i = strlen($tmp_w);
}
}
return $string;
}
if ($tab == 'p')
{
$table = 'mcgallery_photo';
$liste = $listeP;
$type = 'P';
$like = 'photos%';
$shadow = 'shadow20';
$t = 'P';
}
elseif ($tab == 'v')
{
$table = 'mcgallery_video';
$liste = $listeV;
$type = 'V';
$like = 'videos%';
$shadow = 'shadow22';
$t = 'V';
}
elseif ($tab == 'f')
{
$table = 'mcgallery_flash';
$liste = $listeF;
$type = 'F';
$like = 'flash%';
$shadow = 'shadow23';
$t = 'F';
}
echo '<table border="0" align="center" class="td1" cellspacing="1" cellpadding="1" width="60%">';
echo '<tr><td class="td0" colspan="2" align="center"><font size="2">';
if ($top == 'date')
{
echo $l_top_date.'</font></td></tr>';
$query = "SELECT id, file, idalbum, album, title, cat, author, add_date FROM $table WHERE idalbum IN ($liste) ORDER BY add_date DESC LIMIT 0, 10";
$res = mysql_query($query);
while ($row = mysql_fetch_array($res))
{
list($y, $m, $d) = split('-', $row['add_date']);
if ($datepref == 'fr') $datedis = $d.'/'.$m.'/'.$y;
elseif ($datepref == 'en') $datedis = $m.'/'.$d.'/'.$y;
else $datedis = $row['add_date'];
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
if ($tab != 'p') { list($fich, $ext) = split('\.', $image); $image = $fich; }
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($row['idalbum'], $image, $tab, $top, $row['id']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'.$l_Added.': '.$datedis.'</b><br>';
if (!empty($row['title'])) echo $l_Titre.': '.stripslashes($row['title']).'<br>';
if (!empty($row['author'])) echo $l_Auteur.': '.stripslashes($row['author']).'<br>';
echo $l_Album.': '.stripslashes($row['album']).'<br>';
if (!empty($row['cat'])) echo $l_Category.': '.stripslashes($row['cat']).'<br>';
echo '</font></td></tr>';
}
}
if ($top == 'com')
{
include 'smilies.php';
echo $l_top_com.'</font></td></tr>';
$query = "SELECT t.id, t.id_photo, t.date, t.author, t.email, t.text, t.note, $table.file, $table.idalbum FROM mcgallery_comment as t LEFT JOIN $table ON t.id_photo = $table.id WHERE $table.idalbum IN ($liste) AND t.type = '$type' AND t.valid = 'Y' ORDER BY t.date DESC LIMIT 0, 10";
$res = mysql_query($query); echo mysql_error();
while ($row = mysql_fetch_array($res))
{
list($y, $m, $d) = split('-', $row['date']);
if ($datepref == 'fr') $datedis = $d.'/'.$m.'/'.$y;
elseif ($datepref == 'en') $datedis = $m.'/'.$d.'/'.$y;
else $datedis = $row['date'];
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
if ($tab != 'p') { list($fich, $ext) = split('\.', $image); $image = $fich; }
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($row['idalbum'], $image, $tab, $top, $row['id_photo']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'.$datedis.' | '.$row['author'].' </b>';
echo '<a href="#" onclick="javascript:window.open(\'./mailto.php?to='.$row['id'].'\',\'\',\'width=300,height=350,left=100, top=100\');" onMouseOver="window.status=\'\';return true"><img src="images/ecrire.gif" alt="" border="0"></a><br>';
if ($row['note'] != '')
{
echo $l_rating.': <img src="images/orange.gif" width="'.($row['note'] * 10).'" height="8" alt="'.$row['note'].'/10" border="0">';
echo '<img src="images/grey.gif" width="'.(100 - ($row['note'] * 10)).'" height="8" alt="'.$row['note'].'/10" border="0"><br>';
}
$texte = preg_replace('/([^ ]{50})/si','\\1 ',$row['text']);
$texte = nl2br(courte(htmlspecialchars(stripslashes($texte))));
$texte = str_replace($images, $smilies, $texte);
echo $texte;
echo '</font></td></tr>';
}
}
if ($top == 'dis')
{
echo $l_top_dis.'</font></td></tr>';
$query = "SELECT id, file, idalbum, album, title, cat, author, add_date, visite FROM $table WHERE idalbum IN ($liste) ORDER BY visite DESC LIMIT 0, 10";
$res = mysql_query($query);
while ($row = mysql_fetch_array($res))
{
list($y, $m, $d) = split('-', $row['add_date']);
if ($datepref == 'fr') $datedis = $d.'/'.$m.'/'.$y;
elseif ($datepref == 'en') $datedis = $m.'/'.$d.'/'.$y;
else $datedis = $row['add_date'];
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
if ($tab != 'p') { list($fich, $ext) = split('\.', $image); $image = $fich; }
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($row['idalbum'], $image, $tab, $top, $row['id']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'.$l_Visite.' '.$row['visite'].' '.$l_times.'</b><br>';
if (!empty($row['title'])) echo $l_Titre.': '.stripslashes($row['title']).'<br>';
if (!empty($row['author'])) echo $l_Auteur.': '.stripslashes($row['author']).'<br>';
echo $l_Album.': '.stripslashes($row['album']).'<br>';
if (!empty($row['cat'])) echo $l_Category.': '.stripslashes($row['cat']).'<br>';
echo $l_Added.': '.$datedis;
echo '</font></td></tr>';
}
}
if ($top == 'rate')
{
echo $l_top_rate.'</font></td></tr>';
$query = "SELECT t.id_photo, COUNT(t.note) as tot, AVG(t.note) as avg, $table.file, $table.idalbum, $table.album, $table.title, $table.author, $table.cat FROM mcgallery_comment as t LEFT JOIN $table ON t.id_photo = $table.id WHERE $table.idalbum IN ($liste) AND t.note != '' AND t.type = '$type' GROUP BY t.id_photo ORDER BY avg DESC LIMIT 0, 10";
$res = mysql_query($query);
while ($row = mysql_fetch_array($res))
{
list($y, $m, $d) = split('-', $row['date']);
if ($datepref == 'fr') $datedis = $d.'/'.$m.'/'.$y;
elseif ($datepref == 'en') $datedis = $m.'/'.$d.'/'.$y;
else $datedis = $row['date'];
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
if ($tab != 'p') { list($fich, $ext) = split('\.', $image); $image = $fich; }
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($row['idalbum'], $image, $tab, $top, $row['id_photo']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'. $l_rating_av.': </b>';
echo '<img src="images/orange.gif" width="'.($row['avg'] * 10).'" height="8" alt="'.round($row['avg'], 2).'/10 ('.$row['tot'].' '.$l_rates.')" border="0">';
echo '<img src="images/grey.gif" width="'.(100 - ($row['avg'] * 10)).'" height="8" alt="'.round($row['avg'], 2).'/10 ('.$row['tot'].' '.$l_rates.')" border="0"><br>';echo $row['moyen'];
if (!empty($row['title'])) echo $l_Titre.': '.stripslashes($row['title']).'<br>';
if (!empty($row['author'])) echo $l_Auteur.': '.stripslashes($row['author']).'<br>';
echo $l_Album.': '.stripslashes($row['album']).'<br>';
if (!empty($row['cat'])) echo $l_Category.': '.stripslashes($row['cat']).'';
echo '</font></td></tr>';
}
}
if ($top == 'card')
{
echo $l_top_card.'</font></td></tr>';
$query = "SELECT image, COUNT(id) as tot FROM mcgallery_card WHERE image LIKE '$like' GROUP BY image ORDER BY tot DESC LIMIT 0, 10";
$res = mysql_query($query);
$liste_array = split(',', $liste);
while ($row = mysql_fetch_array($res))
{
list($tt, $al, $im) = split('/', $row['image']);
if (in_array($al, $liste_array))
{
$file = $al.'_'.$im;
$query = "SELECT id, album, title, author, cat FROM $table WHERE file = '$file'";
$result = mysql_query($query); echo mysql_error();
$fic = mysql_fetch_array($result);
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($al, $im, $tab, $top, $fic['id']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'. ucfirst($l_tip_card).' '.$row['tot'].' '.$l_times.'</b><br>';
if (!empty($fic['title'])) echo $l_Titre.': '.stripslashes($fic['title']).'<br>';
if (!empty($fic['author'])) echo $l_Auteur.': '.stripslashes($fic['author']).'<br>';
echo $l_Album.': '.stripslashes($fic['album']).'<br>';
if (!empty($fic['cat'])) echo $l_Category.': '.stripslashes($fic['cat']).'';
echo '</font></td></tr>';
}
}
}
if ($top == 'rev')
{
echo $l_top_rev.'</font></td></tr>';
$query = "SELECT t.id_photo, COUNT(t.id) as tot, $table.file, $table.idalbum, $table.album, $table.title, $table.author, $table.cat FROM mcgallery_comment as t LEFT JOIN $table ON t.id_photo = $table.id WHERE $table.idalbum IN ($liste) AND t.valid = 'Y' AND t.type = '$type' GROUP BY t.id_photo ORDER BY tot DESC LIMIT 0, 10";
$res = mysql_query($query);echo mysql_error();
while ($row = mysql_fetch_array($res))
{
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
if ($tab != 'p') { list($fich, $ext) = split('\.', $image); $image = $fich; }
echo '<tr><td class="td2" width="'.$thumb_width.'">';
echo $shadow($row['idalbum'], $image, $tab, $top, $row['id_photo']).'</td>';
echo '<td class="td2" valign="top"><font size="1"><b>'. ucfirst($l_top_Com).' '.$row['tot'].' '.$l_times.'</b><br>';
if (!empty($row['title'])) echo $l_Titre.': '.stripslashes($row['title']).'<br>';
if (!empty($row['author'])) echo $l_Auteur.': '.stripslashes($row['author']).'<br>';
echo $l_Album.': '.stripslashes($row['album']).'<br>';
if (!empty($row['cat'])) echo $l_Category.': '.stripslashes($row['cat']).'';
echo '</font></td></tr>';
}
}
if ($top == 'aut')
{
echo $l_top_aut.'</font></td></tr>';
$query = "SELECT author, COUNT(id) as tot FROM $table WHERE idalbum IN ($liste) AND author != '' GROUP BY author ORDER BY tot DESC LIMIT 0, 10";
$res = mysql_query($query);
while ($row = mysql_fetch_array($res))
{
echo '<tr><td class="td2" width="'.$thumb_width.'" align="right"><font size="1">';
echo '<a href="index.php?album=1&submit=OK&searchwhere='.$l_Auteur.'&searchalb=3&t='.$t.'&searchit='.$row['author'].'" class="lien2" onMouseOver="window.status=\'\';return true"><b>'.$row['author'].'</b></a></font></td>';
echo '<td class="td2" valign="top"><font size="1">'.$row['tot'].' '.$l_photos;
echo '</font></td></tr>';
}
}
echo '<tr><td colspan="2" class="td0"><font size="1"> </font></td></tr></table>';
?>