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

Размер файла: 15.15Kb
<?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';
if (empty($datepref))
{
echo '<center><font size="4" color="red">CLICK ON CONFIG</font></center>';
exit;
}

$connect = mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);

// form to album settings
?>
<script language="JavaScript">
<!--
function MM_popupMsg(msg) {
  alert(msg);
}
//-->
</script>

<?php
if ($albumlevel != '')
{
  $query =  "SELECT level, comment, ecard, selection, upload  FROM mcgallery_albumphoto  WHERE idalbum = $albumlevel";
  $res = mysql_query($query);
  $row = mysql_fetch_array($res);
  echo '<table border="0" cellspacing="1" cellpadding="3" align="center">';
  echo '<form method="post" action="index.php">';
  echo '<tr><td bgcolor="black" align="center" colspan="3"><font face="verdana" size="2" color="white">'.$l_Album.' <b>'.$albumlevel.'</b></font></td</tr>';
  echo '<tr><td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$l_Album.' '.$l_Level.'</font></td>';
  echo '<td bgcolor="#CCCCCC"><input type="text" name="alb_level" value="'.$row['level'].'" size="3"></ td>';
  echo '<td bgcolor="#CCCCCC">&nbsp;&nbsp;';
  echo '<a href="#" onClick="MM_popupMsg(\''.$l_pop_level.'\')">';
  echo '<img src="../images/b_help.gif" border="0" alt=""></a></td></tr>';
  echo '<tr><td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$l_Comments.'</font></td>';
  echo '<td bgcolor="#CCCCCC"><select name="alb_comment">';
  echo '<option value="'.$row['comment'].'" checked>'.$row['comment'].'</option>';
  echo '<option value="">&nbsp;</option>';
  echo '<option value="1">1</option>';
  echo '<option value="2">2</option>';
  echo '<option value="3">3</option>';
  echo '<option value="4">4</option>';
  echo '<option value="5">5</option>';
  echo '<option value="6">6</option>';
  echo '</select></ td>';
  echo '<td bgcolor="#CCCCCC">&nbsp;&nbsp;';
  echo '<a href="#" onClick="MM_popupMsg(\''.$l_pop_comment.'\')">';
  echo '<img src="../images/b_help.gif" border="0" alt=""></a></td></tr>';
  echo '<tr><td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$l_Ecard.'</font></td>';
  echo '<td bgcolor="#CCCCCC"><select name="alb_ecard">';
  echo '<option value="'.$row['ecard'].'" checked>'.$row['ecard'].'</option>';
  echo '<option value="">&nbsp;</option>';
  echo '<option value="1">1</option>';
  echo '<option value="2">2</option>';
  echo '<option value="3">3</option>';
  echo '</select></ td>';
  echo '<td bgcolor="#CCCCCC">&nbsp;&nbsp;';
  echo '<a href="#" onClick="MM_popupMsg(\''.$l_pop_ecard.'\')">';
  echo '<img src="../images/b_help.gif" border="0" alt=""></a></td></tr>';
  echo '<tr><td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$l_sel_add.'</font></td>';
  echo '<td bgcolor="#CCCCCC"><select name="alb_selection">';
  echo '<option value="'.$row['selection'].'" checked>'.$row['selection'].'</option>';
  echo '<option value="">&nbsp;</option>';
  echo '<option value="1">1</option>';
  echo '<option value="2">2</option>';
  echo '</select></ td>';
  echo '<td bgcolor="#CCCCCC">&nbsp;&nbsp;';
  echo '<a href="#" onClick="MM_popupMsg(\''.$l_pop_select.'\')">';
  echo '<img src="../images/b_help.gif" border="0" alt=""></a></td></tr>';
  echo '<tr><td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.$l_Uploads.'</font></td>';
  echo '<td bgcolor="#CCCCCC"><select name="alb_upload">';
  echo '<option value="'.$row['upload'].'" checked>'.$row['upload'].'</option>';
  echo '<option value="">&nbsp;</option>';
  echo '<option value="1">1</option>';
  echo '<option value="2">2</option>';
  echo '<option value="3">3</option>';
  echo '</select></ td>';
  echo '<td bgcolor="#CCCCCC">&nbsp;&nbsp;';
  echo '<a href="#" onClick="MM_popupMsg(\''.$l_pop_upload.'\')">';
  echo '<img src="../images/b_help.gif" border="0" alt=""></a></td></tr>';
  echo '<td bgcolor="#CCCCCC" colspan="3" align="right"><input type="submit" name="submit" value="OK">';
  echo '<input type="hidden" name="start" value="'.$start.'">';
  echo '<input type="hidden" name="set_level" value="'.$albumlevel.'"></td></tr>';
  echo '</form></table><br>';
}

// albums settings
if (!empty($set_level))
{
$query = "SELECT idalbum FROM mcgallery_albumphoto WHERE idalbum=$set_level";
$result = mysql_query($query);
$nba = mysql_num_rows($result);
if ($nba == 1)
$query = "UPDATE mcgallery_albumphoto SET level='$alb_level', comment='$alb_comment', ecard='$alb_ecard', selection='$alb_selection', upload='$alb_upload' WHERE idalbum=$set_level";
else
$query = "INSERT INTO mcgallery_albumphoto VALUES($set_level, '','',$alb_level, $alb_comment, $alb_ecard, $alb_selection, $alb_upload)";

mysql_query($query);
}

// update database with new photos
if ($id_album != '')
{
$dir = '../photos/'.$id_album;
$handle = opendir($dir);
rewinddir($handle);
       while ($file = readdir($handle))
       {
          if ($file != "." && $file != ".." && $file != "small" && $file != "big" && $file!= "Thumbs.db" && $file!="index.php" && $file!="_vti_cnf" && $file!="_vti_pvt" && $file!="_vti_script" && $file!="_vti_txt")
          {
$file = $id_album.'_'.$file;
$date = date("Y-m-d");
$query = "INSERT INTO mcgallery_photo (file, idalbum, album, cat, add_date) VALUES('$file',$id_album,'$album_name','$cat','$date')";
$result = mysql_query($query);
          }
       }
closedir($handle);
echo '<div align="center"><font face="verdana" size="2" color="black">'.$l_maj.' '.$id_album.'<br>';
echo '</font></div>';

}

// form to specify album's author
if ($author != '')
{
  echo '<form method="post" action="index.php">';
  echo '<table border="0" cellspacing="0" cellpadding="3" align="center">';
  echo '<tr><td bgcolor="black" align="center"><font face="verdana" size="2" color="white">'.$l_auteur1.'<br>'.$author.'<br>'.$l_auteur2.':</font></td</tr>';
  echo '<tr><td bgcolor="#CCCCCC" align="right"><font face="verdana" size="1" color="black">';
  echo $l_Name.': <input type="text" name="unique_author">&nbsp;<br>';
  echo $l_Email.': <input type="text" name="unique_email">&nbsp;<br>';
  echo $l_Site.': <input type="text" name="unique_url">&nbsp;<br>';
  echo '<input type="hidden" name="start" value="'.$start.'">';
  echo '<input type="submit" name="submit" value="OK">&nbsp;';
  echo '<input type="hidden" name="album_author" value="'.$author.'"></font></td></tr>';
  echo '</table></form>';
}

// update database with album's author
if ($unique_author != '')
{
 $query = "UPDATE mcgallery_photo SET author='$unique_author', email='$unique_email', url='$unique_url' WHERE idalbum=$album_author";
 mysql_query($query);
}

// Give a name to an album
if ($act == 'name')
{
$query =  "UPDATE mcgallery_photo SET album='$album_name' WHERE idalbum=$idalbum";
mysql_query($query);
}

if ( empty($albumlevel) && empty($author)) include 'add_album.php';

// START DISPLAYING ALBUMS

?>
   <table border="0" cellspacing="1" cellpadding="2" align="center">
   <tr>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Albums; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Photos; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Thumbs; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_thumbs_create; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Base; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Ajuster; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_N_Albums; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Detail; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Levels; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Auteur_unique; ?></font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><? echo $l_Thumb; ?></font></td>
   </tr>
   <tr>
   <td bgcolor="#OOOOOO" colspan="11"><font face="verdana, arial" size="1" color="white">

<?php
echo $l_page.': </font>';
$d = dir("../photos");

$album_array = array();
while($albums_list_array = $d->read())
{
  if ($albums_list_array != "." && $albums_list_array != ".." && $albums_list_array != "index.php" && $albums_list_array != "_vti_cnf" && $$albums_list_array != "_vti_pvt" && $albums_list_array != "_vti_script" && $albums_list_array != "_vti_txt")
  {
  $albums_list[] = $albums_list_array;
  }
}
sort($albums_list);
$nbre_pages = ceil(count($albums_list) / 10);
   $np=1;
   if (empty($start)) $start = 0;
   while ($np < (($start + 10) / 10))
    {
     echo '<font face="verdana, arial" size="1"><a href="index.php?start='.(10 * ($np-1)).'" class="lien2"><b> '.$np.'</b></a></font>&nbsp;';
     $np++;
    }
     echo '<font face="verdana, arial" color="white" size="1"> '.$np.'</font>&nbsp;';
     $np++;
     while ($np <= ceil(count($albums_list) / 10))
    {
     echo '<font face="verdana, arial" size="1"><a href="index.php?start='.(10 * ($np-1)).'" class="lien2"><b>'.$np.'</b></a></font>&nbsp;';
     $np++;
    }

	echo '</td></tr>';

for($l = $start; $l < $start + 10; $l++)
{
if ($l == count($albums_list))
{
$d->close();
 echo ' </table>';
include './footer.php';
exit();
}
    echo '<tr><td bgcolor="#CCCCCC" align="center"><font face="verdana" color="black" size="2">';
    if ($albums_list[$l] == $id_album)  { echo '<b>'; }
    echo $albums_list[$l].'</font>';
    if ($albums_list[$l] == $id_album)  { echo '</b>'; }

$dir = '../photos/'.$albums_list[$l];
$handle = opendir($dir);
rewinddir($handle);
         $i = 0;
       while ($file = readdir($handle))
       {
             if ($file != "." && $file != ".." && $file != "small" && $file != "big" && $file!="Thumbs.db" && $file!="index.php" && $file!="_vti_cnf" && $file!="_vti_pvt" && $file!="_vti_script" && $file!="_vti_txt")
             {
             $i++;
             }
       }
    echo '</td><td bgcolor="#CCCCCC"><font face="verdana" color="black" size="1">'.$i.' '.$l_photos.'</font>';
closedir($handle);

$dir = '../photos/'.$albums_list[$l].'/small';
$handle = opendir($dir);
rewinddir($handle);
         $j = 0;
       while ($file = readdir($handle))
       {
             if ( $file != "." && $file != ".." && $file != "Thumbs.db" && $file != "big" && $file != "index.php" && $file != "_vti_cnf" && $file != "_vti_pvt" && $file != "_vti_script" && $file != "_vti_txt")
             {
             $j++;
             }
       }
closedir($handle);

$query = "SELECT id, album, cat FROM mcgallery_photo WHERE idalbum=$albums_list[$l]";
$result = mysql_query($query);
$nb = mysql_num_rows($result);
$row = mysql_fetch_array($result);
    echo '</td><td bgcolor="#CCCCCC"><font face="verdana" color="black" size="1">'.$j.' '.$l_thumbs.'</font></td>';
    echo '<td bgcolor="#CCCCCC" align="center">';
      if ($i > $j)
      {
        echo '<a href="resize.php?start='.$start.'&dir='.$albums_list[$l].'"><img src="../images/b_warning.gif" border="0"></a>';
      }
       else { echo '&nbsp;'; }
    echo '</td><td bgcolor="#CCCCCC"><font face="verdana" color="black" size="1">'.$nb.' '.$l_photos.'</font></td>';
    echo '<td bgcolor="#CCCCCC" align="center">';
      if ($j != $nb)
      {
	  	if (empty($row['album'])) $row['album'] = '?';
      echo '<a href="index.php?start='.$start.'&cat='.stripslashes($row['cat']).'&album_name='.stripslashes($row['album']).'&id_album='.$albums_list[$l].'"><img src="../images/b_warning.gif" border="0"></a></td>';
      }

      else	  echo '&nbsp;</td>';

	  if ($nb > 0)
	  {
	  echo '<form method="post" action="index.php?act=name">';
	  echo '<td bgcolor="#CCCCCC"><input type="text size="10" name="album_name" value="'.htmlspecialchars(stripslashes($row['album'])).'">';
	  echo '<input type="hidden" name="start" value="'.$start.'">';
  	  echo '<input type="hidden" name="idalbum" value="'.$albums_list[$l].'"><input type="submit" value="OK"></td>';
	  echo '</form>';
	  }

	  else echo '<td bgcolor="#CCCCCC">&nbsp;</td>';

	  echo '<td bgcolor="#CCCCCC" align="center">';
	  echo '<a href="detailphoto.php?idalbum='.$albums_list[$l].'"><img src="../images/b_go.gif" border="0"></a>';
	  echo "</td>\n";

// DEBUT LEVELS
    $query = "SELECT thumb, level, comment, ecard, selection, upload FROM mcgallery_albumphoto where idalbum=$albums_list[$l]";
    $res = mysql_query($query);
    $alb_descr = mysql_fetch_array($res);
	$alb_exists = mysql_num_rows($res);

	if (empty($alb_descr['level'] )) $im_level = '../images/b_warning.gif';
	else $im_level = '../images/b_ok.gif';

	if (empty($alb_descr['comment'] )) $im_comment = '../images/b_warning.gif';
	else $im_comment = '../images/b_ok.gif';

		if (empty($alb_descr['ecard'])) $im_ecard = '../images/b_warning.gif';
	else $im_ecard = '../images/b_ok.gif';

	if (empty($alb_descr['selection'] )) $im_selection = '../images/b_warning.gif';
	else $im_selection = '../images/b_ok.gif';

	if (empty($alb_descr['upload'] )) $im_upload = '../images/b_warning.gif';
	else $im_upload = '../images/b_ok.gif';

echo '<td bgcolor="#CCCCCC" align="center">';
	if ($nb > 0 && $j == $nb)
 {
 echo '<a href="index.php?start='.$start.'&albumlevel='.$albums_list[$l].'">';
	echo '<img src="'.$im_level.'" border="0" alt="">';
	echo '<img src="'.$im_comment.'" border="0" alt="">';
	echo '<img src="'.$im_ecard.'" border="0" alt="">';
	echo '<img src="'.$im_selection.'" border="0" alt="">';
	echo '<img src="'.$im_upload.'" border="0" alt="">';
 echo '</a>';
 }
 else echo '&nbsp;';
echo '</td>';
echo "\n";
// FIN LEVELS
	echo '<td bgcolor="#CCCCCC" align="center">';
	if ($nb > 0)
	{
	echo '<a href="index.php?start='.$start.'&author='.$albums_list[$l].'"><img src="../images/b_go.gif" border="0"></a>';
	}
	else echo '&nbsp;';

	echo '</td>';
    echo '<td bgcolor="#CCCCCC" align="center">';
	 if ($nb == 0) echo '&nbsp;';
     elseif (is_file('../photos/'.$albums_list[$l].'/small/'.$alb_descr['thumb']))
     {
     echo '<img src="../photos/'.$albums_list[$l].'/small/'.$alb_descr['thumb'].'" border="0" alt="" width="'.$thumb_title.'" height="'.($thumb_title /4*3).'">';
     }
     else
     {
	 echo '<a href="alb_thumb.php?t=P&idalbum='.$albums_list[$l].'"><img src="../images/b_help.gif" border="0" alt=""></a>';
     }
    echo '</td></tr>';
}


$d->close();
 echo ' </table>';
include './footer.php';
?>