<?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="detailvideo.php?act=delalb&idalbum='.$idalbum.'" class="lien1"><b>OK</b></a></font></div>';
}
// delete album and all videos and thumbnails
if($act == 'delalb')
{
$query = "select id FROM mcgallery_video 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='V'";
mysql_query($query);
}
$query = "DELETE FROM mcgallery_video WHERE idalbum=$idalbum";
mysql_query($query);
$query = "DELETE FROM mcgallery_albumvideo WHERE idalbum=$idalbum";
mysql_query($query);
$dir = '../videos/'.$idalbum.'/small';
$handle = opendir($dir);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'mpg')) $file_gen= substr($file, 0, -3).'mpg';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'avi')) $file_gen= substr($file, 0, -3).'avi';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'MPG')) $file_gen= substr($file, 0, -3).'MPG';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'AVI')) $file_gen= substr($file, 0, -3).'AVI';
$file_sel = $album.'_'.$file_gen;
$query = "DELETE FROM mcgallery_select WHERE file ='$file_sel' AND type='V'";
mysql_query($query);
$file_card = 'videos/'.$album.'/'.$file_gen;
$query = "UPDATE mcgallery_card SET image='x' WHERE image ='$file_card'";
mysql_query($query);
unlink($dir.'/'.$file);
}
}
rmdir('../videos/'.$idalbum.'/small');
$dir = '../videos/'.$idalbum;
$handle = opendir($dir);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
unlink($dir.'/'.$file);
}
}
rmdir('../videos/'.$idalbum);
echo '<div align="center"><font face="verdana" size="2"><a href="./indexvideo.php" class="lien1"><b>'.$l_Retour.'</b></a></font></div>';
exit();
}
// delete a video and its thumbnail
if($act == 'del')
{
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'mpg')) $file_gen= substr($file, 0, -3).'mpg';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'avi')) $file_gen= substr($file, 0, -3).'avi';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'MPG')) $file_gen= substr($file, 0, -3).'MPG';
if (file_exists(substr('../videos/'.$album.'/'.$file, 0, -3).'AVI')) $file_gen= substr($file, 0, -3).'AVI';
$file_sel = $album.'_'.$file_gen;
$query = "select id FROM mcgallery_video WHERE file ='$file_sel' AND idalbum=$idalbum";
$res = mysql_query($query);
$row = mysql_fetch_row($res);
$file_card = 'videos/'.$album.'/'.$file_gen;
$query = "UPDATE mcgallery_card SET image='x' WHERE image ='$file_card'";
mysql_query($query);
$query = "DELETE FROM mcgallery_comment WHERE id_photo ='$row[0]' AND type='V'";
mysql_query($query);
$query = "DELETE FROM mcgallery_video WHERE file ='$file_sel' AND idalbum=$idalbum";
mysql_query($query);
$query = "DELETE FROM mcgallery_select WHERE file ='$file_sel' AND type='V'";
mysql_query($query);
unlink('../videos/'.$idalbum.'/'.$file_gen);
unlink('../videos/'.$idalbum.'/small/'.$file);
}
// give details to a video
if ($submit != '')
{
$title = addslashes($title);
$author = addslashes($author);
$descr = addslashes($descr);
$query = "UPDATE mcgallery_video SET title='$title', author='$author', email='$email', url='$url', descr='$descr', ref='$ref' WHERE id =$id";
mysql_query($query);
unset($submit);
}
// give a category to an album
if ($subcat != '')
{
if ($category2 != '') { $category = $category2; }
$category = addslashes($category);
$query = "UPDATE mcgallery_video 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_albumvideo SET descr='$alb_descr' WHERE idalbum =$idalbum";
mysql_query($query);
unset($subdescr);
}
$query = "SELECT album FROM mcgallery_video WHERE idalbum=$idalbum";
$result = mysql_query($query);
$nb = mysql_num_rows($result);
$nom_album = mysql_fetch_row($result);
$query = "SELECT * FROM mcgallery_albumvideo where idalbum=$idalbum";
$res = mysql_query($query);
if (mysql_num_rows($res) == 0 && $nb >0)
{
$query = "INSERT INTO mcgallery_albumvideo VALUES ($idalbum,'','')";
mysql_query($query);
}
$alb_descr = mysql_fetch_row($res);
$querycat1 = "SELECT cat FROM mcgallery_video 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_video.php';
?>
<table border="0" cellspacing="1" cellpadding="1" align="center">
<tr><form method="post" action="detailvideo.php">
<td bgcolor="#OOOOOO" colspan="7"><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_videos; ?>)</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="detailvideo.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_video 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="detailvideo.php">
<td bgcolor="#CCCCCC" colspan="3"><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('../videos/'.$idalbum.'/small/'.$alb_descr[2])) $mini_thumbnail = '../videos/'.$idalbum.'/small/'.$alb_descr[2];
else $mini_thumbnail = '../images/b_help.gif';
?>
<td bgcolor="#CCCCCC" align="center"><font face="verdana" size="1"><a href="alb_thumb.php?t=V&idalbum=<?php echo $idalbum; ?>" class="lien1"><b><?php echo $l_Thumb; ?></b></a>:</font>
<img src="<?php echo $mini_thumbnail; ?>" border="0" alt=""></td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#OOOOOO" colspan="7"><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="detailvideo.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="detailvideo.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_Video; ?></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_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_video WHERE idalbum=$idalbum ORDER BY file ASC";
$result = mysql_query($query);
while ($row=mysql_fetch_array($result))
{
echo '<form method="post" action="detailvideo.php">';
$len = strlen($row['idalbum']);
$image = substr($row['file'], ($len + 1), -3).'jpg';
$image2 = substr($row['file'], ($len + 1));
$card = 'videos/'.$row['idalbum'].'/'.$image2;
$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='V' 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?vi=../'.$card.'&w='.$video_width.'&h='.$video_height.'\',\'\',\'width='.$video_width.',height='.$video_height.',left=100, top=100\');"><img src="../videos/'.$idalbum.'/small/'.$image.'" border="0" alt="" width="80" height="60"></td>';
echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$image.'<br>';
echo '<a href="detailvideo.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=V&id='.$row['id'].'\',\'\',\'width=300,height=100,left=200, top=200\');" class="lien1"><b>'.$l_Move.'</b></a><br>';
echo $row['visite'].' '.$l_affichages.'<br>';
if ($ecard > 0)
{
echo '<a href="ecard.php?image='.urlencode('../videos/'.$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=V&id='.$row['id'].'&image='.urlencode('../videos/'.$idalbum.'/small/'.$image).'" class="lien1"><b>'.$comm.' '.$l_Comments.'</b></a>';
}
else { echo '<br>0 '.$l_Comments; }
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'];
echo '</font></td>';
echo '<td bgcolor="#CCCCCC"><input type="text" name="ref" size="14" value="'.$row['ref'].'"></td>';
echo '<td bgcolor="#CCCCCC"><input type="text" name="title" size="14" 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"><textarea name="descr" cols="30" rows="3">'.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>';
}
echo '</table>';
include './footer.php';
?>