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

Размер файла: 5.04Kb
<?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 'conf.inc.php';
include '../lang/'.$lang_def;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $l_Move; ?></title>
<style type="text/css">
<!--
a.lien1:link {  font-family: Verdana, Arial; color: #333333; text-decoration: none}
a.lien1:visited {  font-family: verdana, Arial; color: #333333; text-decoration: none}
a.lien1:hover {  font-family: Verdana, Arial; color: #FFFFFF; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#EEEEEE" text="black">
<?php
$connect= mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);

	if ($t == 'P')
	{
	$table = 'mcgallery_photo';
	$table_album = 'mcgallery_albumphoto';
	$path = 'photos';
	}
	elseif ($t == 'V')
	{
	$table = 'mcgallery_video';
	$table_album = 'mcgallery_albumvideo';
	$path = 'videos';
	}
	elseif ($t == 'F')
	{
	$table = 'mcgallery_flash';
	$table_album = 'mcgallery_albumflash';
	$path = 'flash';
	}

if ($submit == 'OK')
{
$nquery = "SELECT album, cat FROM $table WHERE idalbum = $newalb";
$nres = mysql_query($nquery);
$nrow = mysql_fetch_array($nres);
$oquery = "SELECT file, idalbum FROM $table WHERE id = $id";
$ores = mysql_query($oquery);
$orow = mysql_fetch_array($ores);

// update ecards table
$file = substr($orow['file'], (strlen($orow['idalbum']) + 1));
$oldcard = $path.'/'.$orow['idalbum'].'/'.$file;
$newcard = $path.'/'.$newalb.'/'.$file;
$query = "UPDATE mcgallery_card SET image = '$newcard' WHERE image = '$oldcard'";
mysql_query($query);

// update main table
$newfile = $newalb.'_'.$file;
$newalbum = addslashes($nrow['album']);
$newcat = addslashes($nrow['cat']);
$query = "UPDATE $table SET file = '$newfile', idalbum = $newalb, album = '$newalbum', cat = '$newcat' WHERE id = $id";
mysql_query($query);

// remove if it was used as album thumbnail
list($name, $ext) = split('\.', $file);
$query = "UPDATE $table_album SET thumb='' WHERE thumb LIKE '$name.%' AND idalbum = $orow[idalbum]";
mysql_query($query);

// update select table
$query = "UPDATE mcgallery_select SET file = '$newfile' WHERE id = $id";
mysql_query($query);

// move main file
rename('../'.$path.'/'.$orow['idalbum'].'/'.$file, '../'.$path.'/'.$newalb.'/'.$file);

// move thumbnail
$oldalbum = $orow['idalbum'];
if ($t != 'P')
	{
	if (file_exists('../'.$path.'/'.$oldalbum.'/small/'.$name.'.jpg'))
		rename('../'.$path.'/'.$oldalbum.'/small/'.$name.'.jpg', '../'.$path.'/'.$newalb.'/small/'.$name.'.jpg');
	elseif (file_exists('../'.$path.'/'.$oldalbum.'/small/'.$name.'.JPG'))
		rename('../'.$path.'/'.$oldalbum.'/small/'.$name.'.JPG', '../'.$path.'/'.$newalb.'/small/'.$name.'.JPG');
	elseif (file_exists('../'.$path.'/'.$oldalbum.'/small/'.$name.'.png'))
		rename('../'.$path.'/'.$oldalbum.'/small/'.$name.'.png', '../'.$path.'/'.$newalb.'/small/'.$name.'.png');
	elseif (file_exists('../'.$path.'/'.$oldalbum.'/small/'.$name.'.PNG'))
		rename('../'.$path.'/'.$oldalbum.'/small/'.$name.'.PNG', '../'.$path.'/'.$newalb.'/small/'.$name.'.PNG');
	}
else
	{
	rename('../'.$path.'/'.$oldalbum.'/small/'.$file, '../'.$path.'/'.$newalb.'/small/'.$file);
	if (file_exists('../'.$path.'/'.$oldalbum.'/big/'.$file))
		rename('../'.$path.'/'.$oldalbum.'/big/'.$file, '../'.$path.'/'.$newalb.'/big/'.$file);
	}
echo '<br /><div style="font-family:arial; text-align: center; color: blue; border-color: red; border-style:dotted;">Done !';
echo '<br /><a href="#" onclick="javascript:window.close()" class="lien1"><b>OK</b></a></div>';
}
else
{
$query = "SELECT idalbum, album FROM $table GROUP BY idalbum ORDER BY idalbum";
$res = mysql_query($query);
?>

<form method="post" action="move.php">
<table border="0" cellspacing="0" align="center" bgcolor="black">
<tr>
<td align="center"  bgcolor="black" colspan="2"><font face="verdana, arial" size="2" color="white"><?php echo $l_Move; ?></font></td>
</tr>
<tr>
<td align="right" bgcolor="#DDDDDD"><font size="1">Move this Photo to:</font></td>
<td bgcolor="#DDDDDD">
<select name="newalb">
<option value=""></option>
<?php
while ($sel = mysql_fetch_row($res))
{
echo '<option value="'.$sel[0].'">'.$sel[0].' - '.$sel[1].'</option>';
}
?>
</select></td>
</tr>
<tr>
<td align="center" bgcolor="#DDDDDD" colspan="2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="t" value="<?php echo $t; ?>">
<input type="submit" name="submit" value="OK">
</td>
</tr>
<tr>
<td align="center"  bgcolor="black" colspan="2">&nbsp;</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>