<?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
--------------------------------------------------------------------------------------------*/
if ($video == 1 || $t == 'V')
{
$table_album = 'mcgallery_albumvideo';
$table = 'mcgallery_video';
$type = 'video=1&';
$t = 'V';
}
if ($flash == 1 || $t == 'F')
{
$table_album = 'mcgallery_albumflash';
$table = 'mcgallery_flash';
$type = 'flash=1&';
$t = 'F';
}
if ($t != 'V' && $t != 'F' && empty($video) && empty($flash))
{
$table_album = 'mcgallery_albumphoto';
$table = 'mcgallery_photo';
$type = '';
$t = 'P';
}
$query = "SELECT * FROM $table_album WHERE idalbum = $album";
$res_album = mysql_query($query);
$row_album = mysql_fetch_array($res_album);
$level_user = explode (',', $_SESSION['level']);
if ($row_album['level'] > 1 && !in_array($row_album['level'], $level_user) && $_SESSION['level'] != 'admin' && $_SESSION['level'] != 'all')
{
echo '<form method="post" action="index.php">';
echo '<table border="0" cellspacing="1" cellpadding="2" width="200">';
echo '<tr><td class="td0" align="center"><font size="2">'.$l_Restricted.'</font></td></tr>';
echo '<tr><td class="td2" align="right"><font size="2">'.$l_Login.'</font> <input type="text" name ="private_login" size="10"> </td></tr>';
echo '<tr><td class="td2" align="right"><font size="2">'.$l_Pass.'</font> <input type="password" name ="private_pass" size="10"> </td></tr>';
echo '<tr><td class="td2" align="center"><font size="1"><a href="index.php?l=1" class="lien1"><b>'.$l_Perdu.' ?</b></a></font></td></tr>';
echo '<tr><td class="td1" align="center"><input type="submit" value="OK" name="valid">';
echo '<input type="hidden" name="album" value="'.$album.'"><input type="hidden" name="video" value="'.$video.'"></td></tr>';
echo '<tr><td class="td1" align="center"><font size="1">'.$l_log_restrict.' <a href="mailto:'.$email_admin.'" class="lien2">'.$l_contact.'</a></font></td></tr>';
echo '<tr><td class="td0" height="3"></td></tr>';
echo '</table></form>';
echo "\n";
exit();
}
function fill($j, $k, $thumb_cols, $thumb_rows, $thumb_width)
{
while ($j % $thumb_cols != 0)
{
echo '<td class="td3"><img src="images/blank.gif" width="'.$thumb_width.'" border="0" alt=""></td>';
$j++;
$tr = 1;
}
if ($tr == 1) { echo '</tr><tr>'; }
while ($k < $thumb_rows - 1)
{
echo '<td class="td3" colspan='.$thumb_cols.'><img src="images/blank.gif" border="0" alt="" width="'.$thumb_width.'" height="'.($thumb_width / 4*3).'"></td></tr><tr>';
$k++;
echo "\n";
}
}
$thumb_aff = $thumb_cols * $thumb_rows;
if ($searchit != '')
{
if ($searchwhere == $l_Auteur) { $field = 'author'; }
if ($searchwhere == $l_Titre) { $field = 'title'; }
if ($searchwhere == $l_Description) { $field = 'descr'; }
$search = stripslashes($searchit);
$search = str_replace("'", "\'", $search);
$search = str_replace(";", "|", $search);
$search = str_replace(",", "|", $search);
$search = str_replace(" ", "|", $search);
$search = explode("|", $search);
if ($search[0] != '') { $like = $field.' LIKE \'%'.$search[0].'%\''; }
if ($search[1] != '') { $like = $field.' LIKE \'%'.$search[0].'%\' AND '.$field.' LIKE \'%'.$search[1].'%\'';
$and1=$l_and; }
if ($search[2] != '') { $like = $field.' LIKE \'%'.$search[0].'%\' AND '.$field.' LIKE \'%'.$search[1].'%\' AND '.$field.' LIKE \'%'.$search[2].'%\'';
$and2=$l_and; }
if ($t == 'P') { $find = $l_Photos; $liste = $listeP; }
if ($t == 'V') { $find = $l_Videos; $liste = $listeV; }
if ($t == 'F') { $find = $l_Flash; $liste = $listeF; }
if ($searchalb == 1)
{
$where = 'idalbum ='.$album;
$ou = $l_Album;
}
elseif ($searchalb == 2)
{
if ($_SESSION['level'] =='admin' ||$_SESSION['level'] =='all') { $where = 'idalbum > 0 AND cat LIKE \''.$cats.'\''; }
else { $where = 'idalbum IN ('.$liste.') AND cat LIKE \''.$cats.'\''; }
$ou = $l_Category;
}
elseif ($searchalb == 3)
{
if ($_SESSION['level'] =='admin' ||$_SESSION['level'] =='all') { $where = 'idalbum > 0'; }
else { $where = 'idalbum IN ('.$liste.')'; }
$ou = $l_search_all;
}
$query = "SELECT id FROM $table WHERE $where AND $like";
$result = mysql_query($query);
$nbre = mysql_num_rows($result);
if ($start == '') { $start = 0; }
$query = "SELECT id, file, title, idalbum, author FROM $table WHERE $where AND $like ORDER BY title, file LIMIT $start, $thumb_aff";
$result = mysql_query($query);
echo '<table border="0" cellspacing="0" cellpadding="1" align="center"><tr><td class="td1">';
echo "\n";
echo '<table border="0" cellspacing="0" cellpadding="5"><tr>';
echo '<td align="center" class="td0" colspan="'.($thumb_cols - 1).'">';
echo '<font size="2">'.$l_your_search.'<br><b>'.stripslashes($search[0].'</b> '.$and1.' <b>'.$search[1].'</b> '.$and2.' <b>'.$search[2]).'</b> ('.$searchwhere.' / '.$ou.')</font></td>';
echo '<td class="td0" align="right">';
echo '<font size="1">('.$nbre.' '.$find.')</font></td></tr><tr>';
$j = 0;
$k = 0;
while ($row2 = mysql_fetch_array($result))
{
echo '<td class="td3" align="center">';
$id = $row2['id'];
$len = strlen($row2['idalbum']);
if ($t == 'P')
{
$image = substr($row2['file'], ($len + 1));
echo shadow5($row2['idalbum'], $image, $start, $searchit, $searchwhere, $id, $searchalb);
}
if ($t == 'V')
{
$image = substr($row2['file'], ($len + 1), -3).'jpg';
echo shadow6($row2['idalbum'], $image, $start, $searchit, $searchwhere, $id, $searchalb);
}
if ($t == 'F')
{
$image = substr($row2['file'], ($len + 1), -3).'jpg';
echo shadow10($row2['idalbum'], $image, $start, $searchit, $searchwhere, $id, $searchalb);
}
echo '<font size="1">';
if ($row2['title'] != '' && $aff_title == 1) { echo '<b>'.stripslashes($row2['title']).'</b>'; }
if ($aff_author == 1 && $aff_title == 1) { echo '<br>'; }
if ($row2['author'] != '' && $aff_author == 1) { echo stripslashes($row2['author']); }
echo '</font></td>';
$j++;
if ($j % $thumb_cols == 0)
{
echo '</tr><tr>';
echo "\n";
$k++;
}
}
fill($j, $k, $thumb_cols, $thumb_rows, $thumb_width);
echo '<td class="td1" colspan="'.$thumb_cols.'" align="right">';
echo '<font size="1">'.$l_page.': </font>';
// start navigation
$nbre_pages = ceil($nbre / $thumb_aff);
if ($nbre_pages > $nb_page_aff)
{
if (($start == 0) || ($start > 0 && $start < (($nbre_pages - 1) * $thumb_aff)))
{
if ($start == 0)
{
echo '<font size="1"><b>1</b></font> ';
}
elseif ($start > 0 && $start < (($nbre_pages - 1) * $thumb_aff))
{
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start=0" class="lien2">1</a> ...</font> ';
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.($start - ($thumb_aff)).'"><img src="images/gauche.gif" border="0" align="bottom"></a></font> ';
echo '<font size="1"><b>'.((ceil($start / $thumb_aff))+1).'</b> </font>';
}
echo '<font size="1"><a href="search.php?searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.($start + $thumb_aff).'&album='.$album.'"><img src="images/droit.gif" border="0" align="bottom"></a> ...</font> ';
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.(($nbre_pages-1)*($thumb_aff)).'" class="lien2">'.$nbre_pages.'</a></font> ';
}
if ($start == (($nbre_pages - 1) * $thumb_aff))
{
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start=0" class="lien2">1</a> ...</font> ';
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.($start - ($thumb_aff)).'" class="lien2"><img src="images/gauche.gif" border="0" align="bottom"></a></font> ';
echo '<font size="1"><b>'.$nbre_pages.'</b></font> ';
}
}
else
{
$i = 1;
while ($i < (($start + ($thumb_aff)) / $thumb_aff))
{
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.($thumb_aff *($i-1)).'" class="lien2">'.$i.'</a></font> ';
$i++;
echo "\n";
}
echo '<font size="1"><b> '.$i.' </b></font> ';
$i++;
while ($i <= ceil($nbre / $thumb_aff))
{
echo '<font size="1"><a href="index.php?album='.$album.'&searchwhere='.$searchwhere.'&searchit='.$searchit.'&t='.$t.'&start='.($thumb_aff *($i-1)).'" class="lien2">'.$i.'</a></font> ';
$i++;
echo "\n";
}
}
// end navigation
}
/// end search result ///////////////////////////////////////////////////////////////////////////
/// start diplaying thumbs ////////////////////////////////////////////////////////////////
else
{
$query = "SELECT id, album FROM $table WHERE idalbum='$album'";
$result = mysql_query($query);
$nbre = mysql_num_rows($result);
$row2 = mysql_fetch_array($result);
echo '<table border="0" cellspacing="0" cellpadding="1"><tr><td class="td1">';
echo '<table border="0" cellspacing="0" cellpadding="5"><tr>';
echo '<td align="center" class="td0" colspan="'.($thumb_cols - 1).'">';
echo '<font size="2">'.stripslashes($row2['album']).'</font></td>';
echo '<td class="td0" align="right">';
if ($start == '') { $start = 0; }
$query = "SELECT id,file, title, author FROM $table WHERE idalbum=$album ORDER BY title, file LIMIT $start, $thumb_aff";
$result = mysql_query($query);
echo '<font size="1">('.$nbre.' '.$l_photos.')</font></td></tr><tr>';
$j = 0;
$k = 0;
while ($row2 = mysql_fetch_array($result))
{
$idimage = $row2['id'];
$len = strlen($album);
echo '<td class="td3" align="center">';
if ($t == 'P')
{
$image = substr($row2['file'], ($len + 1));
echo shadow($album, $image, $start, $idimage);
}
else
{
$image = substr($row2['file'], ($len + 1), - 3).'jpg';
if ($t == 'V') echo shadow3($album, $image, $start, $idimage);
if ($t == 'F') echo shadow11($album, $image, $start, $idimage);
}
echo '<font size="1">';
if ($row2['title'] != '' && $aff_title == 1) { echo '<b>'.stripslashes($row2['title']).'</b>'; }
if ($aff_author == 1 && $aff_title == 1) { echo '<br> '; }
if ($row2['author'] != '' && $aff_author == 1) { echo stripslashes($row2['author']); }
echo '</font></td>';
$j++;
if ($j % $thumb_cols == 0)
{
echo '</tr><tr>';
$k++;
}
}
fill($j, $k, $thumb_cols, $thumb_rows, $thumb_width);
if ($t == 'P')
{
echo '<td class="td1" align="left"><font size="1"><a href="slide.php?album='.$album.'" class="lien2">'.$l_slide.'</a></font></td>';
echo '<td class="td1" colspan="'.($thumb_cols - 1).'" align="right">';
}
else
{
echo '<td class="td1" colspan="'.$thumb_cols.'" align="right">';
}
echo '<font size="1">'.$l_page.': </font>';
// start navigation
$nbre_pages = ceil($nbre / $thumb_aff);
if ($nbre_pages > $nb_page_aff)
{
if (($start == 0) || ($start > 0 && $start < (($nbre_pages - 1) * $thumb_aff)))
{
if ($start == 0)
{
echo '<font size="1"><b>1</b></font> ';
}
elseif ($start > 0 && $start < (($nbre_pages - 1) * $thumb_aff))
{
echo '<font size="1"><a href="index.php?'.$type.'start=0&album='.$album.'" class="lien2">1</a> ...</font> ';
echo '<font size="1"><a href="index.php?'.$type.'start='.($start - $thumb_aff).'&album='.$album.'"><img src="images/gauche.gif" border="0" align="bottom"></a></font> ';
echo '<font size="1"><b>'.((ceil($start / $thumb_aff)) + 1).'</b> </font>';
}
echo '<font size="1"><a href="index.php?'.$type.'start='.($start + $thumb_aff).'&album='.$album.'"><img src="images/droit.gif" border="0" align="bottom"></a> ...</font> ';
echo '<font size="1"><a href="index.php?'.$type.'start='.(($nbre_pages - 1) * $thumb_aff).'&album='.$album.'" class="lien2">'.$nbre_pages.'</a></font> ';
}
if ($start == (($nbre_pages - 1) * $thumb_aff))
{
echo '<font size="1"><a href="index.php?'.$type.'start=0&album='.$album.'" class="lien2">1</a> ...</font> ';
echo '<font size="1"><a href="index.php?'.$type.'start='.($start - $thumb_aff).'&album='.$album.'" class="lien2"><img src="images/gauche.gif" border="0" align="bottom"></a></font> ';
echo '<font size="1"><b>'.$nbre_pages.'</b></font> ';
}
}
else
{
$i = 1;
while ($i < (($start + $thumb_aff) / $thumb_aff))
{
echo '<font size="1"><a href="index.php?'.$type.'start='.($thumb_aff * ($i - 1)).'&album='.$album.'" class="lien2">'.$i.'</a></font> ';
$i++;
echo "\n";
}
echo '<font size="1"><b> '.$i.' </b></font> ';
$i++;
while ($i<=ceil($nbre/ $thumb_aff))
{
echo '<font size="1"><a href="index.php?'.$type.'start='.($thumb_aff * ($i - 1)).'&album='.$album.'" class="lien2">'.$i.'</a></font> ';
$i++;
echo "\n";
}
}
// end navigation
if ($t == 'P' && ($row_album['upload'] == 3 || (!empty($level) && $row_album['upload'] == 2)))
{
include 'uplist.php';
}
echo '</td></tr>';
echo "\n";
$query = "SELECT descr FROM $table_album WHERE idalbum=$album";
$res = mysql_query($query);
$alb_descr = mysql_fetch_row($res);
if ($alb_descr[0] != '')
{
echo '<tr><td class="td2" colspan="'.$thumb_cols.'" width="'.(($thumb_width * $thumb_cols) + 30).'"><font size="1">';
echo nl2br(stripslashes($alb_descr[0])).$width;
echo '</font></td></tr>';
}
}
?>
<tr><td class="td1" colspan="<?php echo $thumb_cols; ?>" height="4">
</td></tr>
<tr><td class="td1" align="center" colspan="<?php echo $thumb_cols; ?>">
<?php
echo "\n";
if ($search_allowed >= 1)
{
?>
<form method="post" action="index.php">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="td1" align="center">
<font size="1">
<?php echo $l_search_mode; ?></font>
</td>
</tr>
<tr>
<td class="td1" align="center">
<input type="text" name="searchit">
<select name="searchwhere">
<option value=""></option>
<?php
if ($search_allowed == 1 || $search_allowed == 3 || $search_allowed == 5 || $search_allowed == 7)
echo '<option value="'.$l_Auteur.'">'.$l_Auteur.'</option>';
if ($search_allowed == 2 || $search_allowed == 3 || $search_allowed == 6 || $search_allowed == 7)
echo '<option value="'.$l_Titre.'" selected>'.$l_Titre.'</option>';
if ($search_allowed == 4 || $search_allowed == 5 || $search_allowed == 6 || $search_allowed == 7)
echo '<option value="'.$l_Description.'">'.$l_Description.'</option>';
?>
</select>
<select name="searchalb">
<?php
if ($searchalb < 2) echo '<option value="1">'.$l_search_one.'</option>';
if (!empty($cat) && $cat != $l_allcat && $searchalb < 3) echo '<option value="2">'.$l_search_cat.'</option>';
?>
<option value="3"><?php echo $l_search_all; ?></option>
</select>
<?php
if (!empty($cat) && $cat != $l_allcat) echo '<input type="hidden" name="cats" value="'.$cats.'">';
?>
<input type="hidden" name="album" value="<?php echo $album; ?>">
<input type="hidden" name="t" value="<?php echo $t; ?>">
<input type="submit" value="OK"></td>
</tr>
</table>
</form>
<?php
echo "\n";
}
?>
</td>
</tr>
</table>
</td></tr>
<tr><td class="td0">
</td></tr></table>