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

Размер файла: 5.93Kb
<?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;
}


if (!empty($_FILES))
{
$uploadedfile = $_FILES['uploadedfile']['name'];
$uploaded = $_FILES['uploadedfile']['tmp_name'];
$uploadedfile_type = $_FILES['uploadedfile']['type'];

$uploadedfile2 = $_FILES['uploadedfile2']['name'];
$uploaded2 = $_FILES['uploadedfile2']['tmp_name'];
$uploadedfile2_type = $_FILES['uploadedfile2']['type'];
}

if (!isset($func))
{
$func = "one";
}

switch ($func) {
case one:
$dir = '../flash/'.$idalbum;
echo '<form method="post" enctype="multipart/form-data" action="detailflash.php">';
echo '<table border="0" align="center" cellspacing="1" cellpadding="3" bgcolor="#000000">';
echo '<tr><td bgcolor="#DDDDDD" align="center" colspan="5"><font face="verdana" size="2" color="black">';
echo $l_Addflash.' <b>'.stripslashes($nom_album[0]).'</b></font></td>';
echo '<td bgcolor="#000000" align="left"><font face="verdana" size="1" color="white">'.$l_Flash.': </font><input type="file" name="uploadedfile" size="25" maxlenght="90">';
echo '</td>';
echo '<td bgcolor="#000000" align="left"><font face="verdana" size="1" color="white">'.$l_Thumb.': </font><input type="file" name="uploadedfile2" size="25" maxlenght="90">';
echo '</td>';
echo ' <input type="hidden" name="idalbum" value="'.$idalbum.'">';
echo ' <input type="hidden" name="album" value="'.stripslashes($nom_album[0]).'">';
echo '<input type="hidden" name="func" value="two">';
echo '<td bgcolor="#000000"><input type="submit" name="submitfile" value="OK"></td></tr>';
echo '</table></form>';

break;

case two:

echo '<table align="center"><tr><td class="td2" align="center"><font face="verdana" size ="2" color="red">';
$uploadedfile = strtr($uploadedfile, "АБВГДЕабвгдеТУФХЦШтуфхцшИЙКЛийклЗзМНОПмнопЩЪЫЬщъыьяСс", "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
$ext = $uploadedfile_type;
$len = strlen($ext);
$dir = '../flash/'.$idalbum;
$pos = strpos($ext,'/')+1;
$extension = substr($ext, $pos, $len);

$ext2 = $uploadedfile2_type;
$len2 = strlen($ext2);
$pos2 = strpos($ext2,'/')+1;
$extension2 = substr($ext2, $pos2, $len2);

if($uploadedfile == '' || $uploadedfile2 == '')
{
unset($uploadedfile);
unset($uploadedfile2);
echo $l_Addflash_err0.'<br>';
   echo '<a href="detailflash.php?idalbum='.$idalbum.'" class="lien1"><b>'.$l_Retour.'</a></b>.</font>';
   exit();
}

if($extension=="SWF"){ $extension="swf"; }
if($extension=="x-shockwave-flash"){ $extension="swf"; }
if($extension != 'swf')
{
unset($uploadedfile);
unset($uploadedfile2);
echo $l_Addflash_err1.'<br>';       
   echo '<a href="detailflash.php?idalbum='.$idalbum.'" class="lien1"><b>'.$l_Retour.'</a></b>.</font>';
   exit();
}

if($extension2=="pjpeg"){ $extension2="jpg"; }
if($extension2=="PJPEG"){ $extension2="jpg"; }
if($extension2=="jpeg"){ $extension2="jpg"; }
if($extension2=="JPEG"){ $extension2="jpg"; }

if($extension2 != 'jpg' && $extension2 != 'JPG')
{
unset($uploadedfile);
unset($uploadedfile2);
echo $l_Addvideo_err2.'<br>';
   echo '<a href="detailflash.php?idalbum='.$idalbum.'" class="lien1"><b>'.$l_Retour.'</a></b>.</font>';
   exit();
}

if (file_exists("$dir/$uploadedfile"))
{
unset($uploadedfile);
unset($uploadedfile2);
echo $l_Addphoto_err2.'<br>';
   echo '<a href="detailflash.php?idalbum='.$idalbum.'" class="lien1"><b>'.$l_Retour.'</a></b>.</font>';
   exit();
}

//if image exist, upload it in correct dir
if($uploadedfile <> 'none' && $uploadedfile2 <> 'none')
{
//$uploadedfile2 = str_replace($extension2, 'jpg', $uploadedfile);

  if (!copy($uploaded, "$dir/$uploadedfile") || !copy($uploaded2, "$dir/small/$uploadedfile2"))
  {
//display errors
   echo 'Server error (can\'t upload).<br>';
   echo '<a href="detailflash.php?idalbum='.$idalbum.'" class="lien1"><b>'.$l_Retour.'</a></b>.</font>';
   exit();
  }
//or finish
  else
  {
   chmod("$dir/$uploadedfile", 0777 );
   chmod("$dir/small/$uploadedfile2", 0777 );
   rename($dir.'/small/'.$uploadedfile2, $dir.'/small/'.str_replace($extension, 'jpg', $uploadedfile));

   $newfile = $idalbum.'_'.$uploadedfile;
   $newalbum = addslashes($nom_album[0]);
   $newcat = addslashes($rowcat1[0]);
   $date = date("Y-m-d");
   $sql = "INSERT INTO mcgallery_flash (file, idalbum, album, cat, add_date) VALUES('$newfile', $idalbum, '$newalbum', '$newcat', '$date')";
   mysql_query($sql);

   $dir = '../flash/'.$idalbum;
   echo '<form method="post" enctype="multipart/form-data" action="detailflash.php">';
   echo '<table border="0" align="center" cellspacing="1" cellpadding="3" bgcolor="#000000">';
   echo '<tr><td bgcolor="#DDDDDD" align="center" colspan="5"><font face="verdana" size="2" color="black">';
   echo $l_Addflash.' <b>'.stripslashes($nom_album[0]).'</b></font></td>';
   echo '<td bgcolor="#000000" align="left"><font face="verdana" size="1" color="white">'.$l_Flash.': </font><input type="file" name="uploadedfile" size="25">';
   echo '</td>';
   echo '<td bgcolor="#000000" align="left"><font face="verdana" size="1" color="white">'.$l_Thumb.': </font><input type="file" name="uploadedfile2" size="25">';
   echo '</td>';
   echo ' <input type="hidden" name="idalbum" value="'.$idalbum.'">';
   echo ' <input type="hidden" name="album" value="'.stripslashes($nom_album[0]).'">';
   echo '<input type="hidden" name="func" value="two">';
   echo '<td bgcolor="#000000"><input type="submit" name="submitfile" value="OK"></td></tr>';
   echo '</table></form>';
  }
}

break;
echo '</td></tr></table>';
}
?>