Просмотр файла script/admin/detailflash.php

Размер файла: 12.64Kb
<?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="detailflash.php?act=delalb&idalbum='.$idalbum.'" class="lien1"><b>OK</b></a></font></div>';
}

// delete album and all flash and thumbnails
if($act == 'delalb')
{
  $query = "select id FROM mcgallery_flash 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='F'";
  mysql_query($query);
  }

  $query = "DELETE FROM mcgallery_flash WHERE idalbum=$idalbum";
  mysql_query($query);

  $query = "DELETE FROM mcgallery_albumflash WHERE idalbum=$idalbum";
  mysql_query($query);

  $dir ='../flash/'.$idalbum.'/small';
  $handle = opendir($dir);
       while ($file = readdir($handle))
       {
         if ($file != "." && $file != "..")
         {
          $file1 = $idalbum.'_'.substr($file, 0, -3).'swf';
          $query = "DELETE FROM mcgallery_select WHERE file ='$file1' AND type='F'";
          mysql_query($query);

          $file2 = 'flash/'.$idalbum.'/'.substr($file, 0, -3).'swf';
          $query = "UPDATE mcgallery_card SET image='x' WHERE image ='$file2'";
          mysql_query($query);

          unlink($dir.'/'.$file);
         }
       }
  rmdir('../flash/'.$idalbum.'/small');
  $dir='../flash/'.$idalbum;
  $handle=opendir($dir);
       while ($file = readdir($handle))
       {
         if ($file != "." && $file != "..")
         {
          unlink($dir.'/'.$file);
         }
       }
  rmdir('../flash/'.$idalbum);
  echo '<div align="center"><font face="verdana" size="2"><a href="./indexflash.php" class="lien1"><b>'.$l_Retour.'</b></a></font></div>';
  exit();
}

// delete a flash and its thumbnail
if($act == 'del')
{
  $file1 = $idalbum.'_'.substr($file, 0, -3).'swf';
  $query = "select id FROM mcgallery_flash WHERE file ='$file1' AND idalbum=$idalbum";
  $res = mysql_query($query);
  $row = mysql_fetch_row($res);

  $file2 = 'flash/'.$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='F'";
  mysql_query($query);

  $query = "DELETE FROM mcgallery_flash WHERE file ='$file1' AND idalbum=$idalbum";
  mysql_query($query);

  $query = "DELETE FROM mcgallery_select WHERE file ='$file1' AND type='F'";
  mysql_query($query);



  unlink('../flash/'.$idalbum.'/'.substr($file, 0, -3).'swf');
  unlink('../flash/'.$idalbum.'/small/'.$file);
}

// give details to a flash
if ($submit != '')
{
  $title = addslashes($title);
  $author = addslashes($author);
  $descr = addslashes($descr);
  $query = "UPDATE mcgallery_flash 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_flash 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_albumflash SET descr='$alb_descr' WHERE idalbum =$idalbum";
echo mysql_error();
  mysql_query($query);
  unset($subdescr);
}

$query = "SELECT album FROM mcgallery_flash WHERE idalbum=$idalbum";
$result = mysql_query($query);
$nb = mysql_num_rows($result);
$nom_album = mysql_fetch_row($result);

$query = "SELECT * FROM mcgallery_albumflash where idalbum=$idalbum";
$res = mysql_query($query);
 if (mysql_num_rows($res) == 0 && $nb >0)
 {
  $query = "INSERT INTO mcgallery_albumflash VALUES ($idalbum,'','')";
  mysql_query($query);
 }
$alb_descr = mysql_fetch_row($res);

$querycat1 = "SELECT cat FROM mcgallery_flash 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_flash.php';
?>
   <table border="0" cellspacing="1" cellpadding="1" align="center">
   <tr><form method="post" action="detailflash.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">&nbsp;&nbsp;(<?php echo $nb.' '.$l_flash_anims; ?>)</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="detailflash.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 
$querycat1 = "SELECT cat FROM mcgallery_flash WHERE idalbum = $idalbum";
$rescat1 = mysql_query($querycat1);
$rowcat1 = mysql_fetch_row($rescat1);
echo '<option value="'.stripslashes($rowcat1[0]).'" selected>'.stripslashes($rowcat1[0]).'</option>';
echo '<option value="">______</option>';
$querycat = "SELECT cat, idalbum FROM mcgallery_flash GROUP BY cat";
$rescat = mysql_query($querycat);
while ($rowcat = mysql_fetch_row($rescat))
{
 echo '<option value="'.stripslashes($rowcat[0]).'">'.stripslashes($rowcat[0]).'</option>';
}
if (is_file('../flash/'.$idalbum.'/small/'.$alb_descr[2]))  $mini_thumbnail = '../flash/'.$idalbum.'/small/'.$alb_descr[2];
else $mini_thumbnail = '../images/b_help.gif';

?>
     </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="detailflash.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('../flash/'.$idalbum.'/small/'.$alb_descr[2]))  $mini_thumbnail = '../flash/'.$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=F&idalbum=<?php echo $idalbum; ?>" class="lien1"><b><?php echo $l_Thumb; ?></b></font>
       <img src="<?php echo $mini_thumbnail; ?>" border="0" alt=""></a></td>
    <td bgcolor="#CCCCCC">&nbsp;</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="detailflash.php?start='.(10 *($i-1)).'&idalbum='.$idalbum.'" class="lien2">'.$i.'</a></font>&nbsp;&nbsp;';
     $i++;
    }
     echo '<font face="verdana" color="white" size="1"><b> '.$i.' </b></font>&nbsp;&nbsp;';
     $i++;
     while ($i <= ceil($nb / 10))
    {
     echo '<font face="verdana" size="1"><a href="detailflash.php?start='.(10 *($i-1)).'&idalbum='.$idalbum.'" class="lien2">'.$i.'</a></font>&nbsp;&nbsp;';
     $i++;
    }
  ?>
   </font></td>
    </tr>
    <tr>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Flash; ?></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">&nbsp;</font></td>
   </tr>
<?php 
if ($start == '') { $start = 0; }
$query = "SELECT * FROM mcgallery_flash 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="detailflash.php">';
  $len = strlen($row['idalbum']);
  $image = substr($row['file'], ($len + 1), -3).'jpg';
  $image2 = substr($row['file'], ($len + 1));
  $card = 'flash/'.$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='F' 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?fl=../'.$card.'&w='.$flash_width.'&h='.$flash_height.'\',\'\',\'width='.$flash_width.',height='.$flash_height.',left=100, top=100\');"><img src="../flash/'.$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="detailflash.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=F&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('../flash/'.$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=F&id='.$row['id'].'&image='.urlencode('../flash/'.$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>';
}
?>
  </table>

<?php 
include './footer.php';
?>