Размер файла: 13.46Kb
<?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
--------------------------------------------------------------------------------------------*/
session_start();
if (empty($_SESSION['private_login']))
{
include "./sess.php";
exit;
}
include './header.php';
$connect = mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);
// confirm deleting album
if($del_alb != '')
{
echo '<div align="center"><font face="verdana" color="red" size="2"><b>'.$l_Attention.'</b><br><a href="detailphoto.php?act=delalb&idalbum='.$idalbum.'" class="lien1"><b>OK</b></a></font></div>';
}
// delete album and all photos and thumbnails
if($act == 'delalb')
{
$query = "select id FROM mcgallery_photo WHERE idalbum=$idalbum";
$res = mysql_query($query);
while ($row = mysql_fetch_row($res))
{
$query = "DELETE FROM mcgallery_comment WHERE id_photo ='$row[0]' AND type='P'";
mysql_query($query);
}
$query = "DELETE FROM mcgallery_photo WHERE idalbum=$idalbum";
mysql_query($query);
$query = "DELETE FROM mcgallery_albumphoto WHERE idalbum=$idalbum";
mysql_query($query);
$dir = '../photos/'.$idalbum.'/small';
$handle = opendir($dir);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
$file1 = $idalbum.'_'.$file;
$query = "DELETE FROM mcgallery_select WHERE file ='$file1' AND type='P'";
mysql_query($query);
$file2 = 'photos/'.$idalbum.'/'.$file;
$query = "UPDATE mcgallery_card SET image='x' WHERE image ='$file2'";
mysql_query($query);
unlink($dir.'/'.$file);
}
}
rmdir('../photos/'.$idalbum.'/small');
if (file_exists('../photos/'.$idalbum.'/big'))
{
$dir = '../photos/'.$idalbum.'/big';
$handle=opendir($dir);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
unlink($dir.'/'.$file);
}
}
rmdir('../photos/'.$idalbum.'/big');
}
$dir = '../photos/'.$idalbum;
$handle = opendir($dir);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
unlink($dir.'/'.$file);
}
}
rmdir('../photos/'.$idalbum);
echo '<div align="center"><font face="verdana" size="2"><a href="./index.php" class="lien1"><b>'.$l_Retour.'</b></a></font></div>';
exit();
}
// delete a photo and its thumbnail
if($act == 'del')
{
$file1 = $idalbum.'_'.$file;
$query = "select id FROM mcgallery_photo WHERE file ='$file1' AND idalbum=$idalbum";
$res = mysql_query($query);
$row = mysql_fetch_row($res);
$file2 = 'photos/'.$idalbum.'/'.$file;
$query = "UPDATE mcgallery_card SET image='x' WHERE image ='$file2'";
mysql_query($query);
$query = "DELETE FROM mcgallery_comment WHERE id_photo ='$row[0]' AND type='P'";
mysql_query($query);
$query = "DELETE FROM mcgallery_photo WHERE file ='$file1' AND idalbum=$idalbum";
mysql_query($query);
$query = "DELETE FROM mcgallery_select WHERE file ='$file1' AND type='P'";
mysql_query($query);
unlink('../photos/'.$idalbum.'/'.$file);
unlink('../photos/'.$idalbum.'/small/'.$file);
}
// give details to a photo
if ($submit != '')
{
$title = addslashes($title);
$author = addslashes($author);
$descr = addslashes($descr);
$string = addslashes($string);
$query = "UPDATE mcgallery_photo SET title='$title', author='$author', email='$email', url='$url', descr='$descr', ref='$ref', watermark=$watermark, string='$string' WHERE id =$id";
mysql_query($query);
unset($submit);
}
// give a category to an album
if ($subcat != '')
{
if ($category2 != '') { $category = $category2; }
$query = "UPDATE mcgallery_photo SET cat='$category' WHERE idalbum = $idalbum";
mysql_query($query);
}
// give a decription to an album
if ($subdescr != '')
{
$alb_descr = addslashes($alb_descr);
$query = "UPDATE mcgallery_albumphoto SET descr='$alb_descr' WHERE idalbum =$idalbum";
echo mysql_error();
mysql_query($query);
unset($subdescr);
}
$query = "SELECT album FROM mcgallery_photo WHERE idalbum=$idalbum";
$result = mysql_query($query);
$nb = mysql_num_rows($result);
$nom_album = mysql_fetch_row($result);
$query = "SELECT * FROM mcgallery_albumphoto where idalbum=$idalbum";
$res = mysql_query($query);
if (mysql_num_rows($res) == 0 && $nb >0)
{
$query = "INSERT INTO mcgallery_albumphoto (idalbum) VALUES ($idalbum)";
mysql_query($query);
}
$alb_descr = mysql_fetch_row($res);
$querycat1 = "SELECT cat FROM mcgallery_photo WHERE idalbum = $idalbum";
$rescat1 = mysql_query($querycat1);
$rowcat1 = mysql_fetch_row($rescat1);
if ($use_cat > 0 && $rowcat1[0] == '') $cat_alert = '<img src="../images/b_warning.gif" border="0" alt="">';
include './add_photo.php';
?>
<table border="0" cellspacing="1" cellpadding="1" align="center">
<tr><form method="post" action="detailphoto.php">
<td bgcolor="#OOOOOO" colspan="8"><font face="verdana" size="3" color="white"><?php echo stripslashes($nom_album[0]); ?></font>
<font face="verdana" size="2" color="white"> (<?php echo $nb.' '.$l_photos; ?>)</font><div align="center"><input type="submit" name="del_alb" value="<?php echo $l_Delete; ?>">
<input type="hidden" name="idalbum" value="<?php echo $idalbum; ?>">
<input type="hidden" name="start" value="<?php echo $start; ?>"></td>
</form></tr>
<tr>
<form method="post" action="detailphoto.php">
<td bgcolor="#CCCCCC" colspan="2"><font face="verdana" size="2" color="black"><?php echo $l_Category; ?>:
<br><br><font size="1"><?php echo $l_CategoryC; ?>:
<br><select name="category">
<?PHP
echo '<option value="'.stripslashes($rowcat1[0]).'" selected>'.stripslashes($rowcat1[0]).'</option>';
echo '<option value="">______</option>';
$querycat = "SELECT cat, idalbum FROM mcgallery_photo GROUP BY cat";
$rescat = mysql_query($querycat);
while ($rowcat = mysql_fetch_row($rescat))
{
echo '<option value="'.stripslashes($rowcat[0]).'">'.stripslashes($rowcat[0]).'</option>';
}
?>
</select>
<?php echo $cat_alert.'<br>'.$l_CategoryN; ?>:
<br><input type="text" name="category2">
</font></font>
<br>
<input type="hidden" name="start" value="<?php echo $start; ?>">
<input type="hidden" name="idalbum" value="<?php echo $idalbum; ?>">
<input type="submit" name="subcat" value="OK"></td>
</form>
<form method="post" action="detailphoto.php">
<td bgcolor="#CCCCCC" colspan="4"><font face="verdana" size="2" color="black"><?php echo $l_Alb_descr; ?>:</font>
<br><textarea name="alb_descr" cols="40" rows="6"><?php echo htmlspecialchars(stripslashes($alb_descr[1])); ?></textarea>
<input type="submit" name="subdescr" value="OK">
<input type="hidden" name="start" value="<?php echo $start; ?>">
<input type="hidden" name="idalbum" value="<?php echo $idalbum; ?>"></td>
</form>
<?php
if (is_file('../photos/'.$idalbum.'/small/'.$alb_descr[2])) $mini_thumbnail = '../photos/'.$idalbum.'/small/'.$alb_descr[2];
else $mini_thumbnail = '../images/b_help.gif';
?>
<td bgcolor="#CCCCCC" align="center" colspan="2"><font face="verdana" size="1"><a href="alb_thumb.php?t=P&idalbum=<?php echo $idalbum; ?>" class="lien1"><b><?php echo $l_Thumb; ?></b>:</font>
<br><img src="<?php echo $mini_thumbnail; ?>" border="0" alt="?"></a></td>
</tr>
<tr>
<td bgcolor="#OOOOOO" colspan="8"><font face="verdana" size="2" color="white"><?php echo $l_page; ?>:
<?php
$nbre_pages = ceil($nb / 10);
$i=1;
while ($i < (($start + 10) / 10))
{
echo '<font face="verdana" size="1"><a href="detailphoto.php?start='.(10 *($i - 1)).'&idalbum='.$idalbum.'" class="lien2">'.$i.'</a></font> ';
$i++;
}
echo '<font face="verdana" color="white" size="1"><b> '.$i.' </b></font> ';
$i++;
while ($i <= ceil($nb / 10))
{
echo '<font face="verdana" size="1"><a href="detailphoto.php?start='.(10 *($i - 1)).'&idalbum='.$idalbum.'" class="lien2">'.$i.'</a></font> ';
$i++;
}
?>
</font></td>
</tr>
<tr>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Photo; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Fichier; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_ref; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Titre; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Auteur; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Watermark; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Description; ?></font></td>
<td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"> </font></td>
</tr>
<?php
if ($start == '') { $start = 0; }
$query = "SELECT * FROM mcgallery_photo WHERE idalbum=$idalbum ORDER BY file ASC LIMIT $start, 10";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
echo '<form method="post" action="detailphoto.php">';
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1));
$card = 'photos/'.$row['idalbum'].'/'.$image;
$imagesize = getimagesize('../'.$card);
$querye ="SELECT id FROM mcgallery_card WHERE image='$card'";
$resultat = mysql_query($querye);
$ecard = mysql_num_rows($resultat);
$queryc = "SELECT id FROM mcgallery_comment WHERE type='P' AND id_photo='$row[id]'";
$res = mysql_query($queryc);
$comm = mysql_num_rows($res);
echo '<tr><td bgcolor="#CCCCCC" align="center"><a href="#" onclick="javascript:window.open(\'see.php?im=../'.$card.'&w='.($imagesize[0] / 2).'&h='.($imagesize[1] / 2).'\',\'\',\'width='.($imagesize[0] / 2).',height='.($imagesize[1] / 2).',left=100, top=100\');"><img src="../photos/'.$idalbum.'/small/'.$image.'" border="0" width="80" height="60"></a></td>';
echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$image.'<br>';
echo '<a href="detailphoto.php?start='.$start.'&act=del&file='.$image.'&idalbum='.$row['idalbum'].'" class="lien1"><b>'.$l_Suppr.'</b></a><br>';
echo '<a href="#" onclick="javascript:window.open(\'./move.php?t=P&id='.$row['id'].'\',\'\',\'width=300, height=120,left=200, top=200, margin-top=0, margin=0\');" class="lien1"><b>'.$l_Move.'</b></a><br>';
echo $row['visite'].' '.$l_affichages.'<br>';
if ($ecard > 0)
{
echo '<a href="ecard.php?image='.urlencode('../photos/'.$idalbum.'/small/'.$image).'" class="lien1"><b>'.$ecard.' '.$l_Ecard.'</b></a>';
}
else { echo '0 '.$l_Ecard; }
if ($comm > 0)
{
echo '<br><a href="comments.php?t=P&id='.$row['id'].'&image='.urlencode('../photos/'.$idalbum.'/small/'.$image).'" class="lien1"><b>'.$comm.' '.$l_Comments.'</b></a>';
}
else { echo '<br>0 '.$l_Comments; }
$datepref = 'fr';
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'];
if ($row['watermark'] == 1) $check1 = 'checked';
elseif ($row['watermark'] == 2) $check2 = 'checked';
elseif ($row['watermark'] == 3) $check3 = 'checked';
echo '</font></td>';
echo '<td bgcolor="#CCCCCC"><input type="text" name="ref" size="10" value="'.$row['ref'].'"></td>';
echo '<td bgcolor="#CCCCCC"><input type="text" name="title" size="10" value="'.htmlspecialchars(stripslashes($row['title'])).'"></td>';
echo '<td bgcolor="#CCCCCC" align="right"><font face="verdana" size="1" color="black">';
echo $l_Name.': <input type="text" name="author" size="18" value="'.htmlspecialchars(stripslashes($row['author'])).'"><br>';
echo $l_Email.': <input type="text" name="email" size="18" value="'.$row['email'].'"><br>';
echo $l_Site.': <input type="text" name="url" size="18" value="'.$row['url'].'"><br>';
echo $l_Added.': '.$datedis;
echo '</font></td>';
echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">';
echo '<input type="radio" name="watermark" value="1" '.$check1.'> '.$l_watermark_def.'<br>';
echo '<input type="radio" name="watermark" value="2" '.$check2.'> '.$l_watermark_no.'<br>';
echo '<input type="radio" name="watermark" value="3" '.$check3.'> '.$l_watermark_other.'<br>';
echo '<input type="text" name="string" size="14" value="'.htmlspecialchars(stripslashes($row['string'])).'"></td>';
echo '<td bgcolor="#CCCCCC"><textarea name="descr" cols="30" rows="4">'.htmlspecialchars(stripslashes($row['descr'])).'</textarea></td>';
echo '<td bgcolor="#CCCCCC"><input type="submit" name="submit" value="OK"></td></tr>';
echo '<input type="hidden" name="id" value="'.$row['id'].'">';
echo '<input type="hidden" name="start" value="'.$start.'">';
echo '<input type="hidden" name="idalbum" value="'.$row['idalbum'].'">';
echo '</form>';
unset($check1);
unset($check2);
unset($check3);
}
?>
</table>
<?php
include './footer.php';
?>