Размер файла: 5.55Kb
<?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
--------------------------------------------------------------------------------------------*/
include './header_pop.php';
include './admin/conf.inc.php';
include './lang/'.$lang;
$dir="./upload";
if (!empty($_FILES))
{
$uploadedfile = $_FILES['uploadedfile']['name'];
$uploaded = $_FILES['uploadedfile']['tmp_name'];
$uploadedfile_type = $_FILES['uploadedfile']['type'];
$fsize = $_FILES['uploadedfile']['size'];
}
if (!isset($func))
{
$func = "one";
}
switch ($func) {
case one:
echo '<form method="post" enctype="multipart/form-data" action="upload.php" OnSubmit="return envoi()">';
echo '<table border="0" align="center" cellspacing="1" cellpadding="3">';
echo '<tr><td class="td0" align="center" colspan="2"><font size="2">';
echo $l_Upload.'</font></td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Auteur.'</font></td>';
echo '<td class="td2" align="left"><input type="text" size="22" name="upauthor" value="'.$upauthor.'">';
echo '</td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Email.'</font></td>';
echo '<td class="td2" align="left"><input type="text" size="22" name="upemail" value="'.$upemail.'">';
echo '</td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Site.'</font></td>';
echo '<td class="td2" align="left"><input type="text" size="22" name="upurl" value="'.$upurl.'">';
echo '<font size="1"> (http://www.site.com)</font>';
echo '</td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Photo.'</font></td>';
echo '<td class="td2" align="left"><input type="file" name="uploadedfile" size="30">';
echo '</td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Titre.'</font></td>';
echo '<td class="td2" align="left"><input type="text" size="22" name="uptitle" value="'.$uptitle.'">';
echo '</td></tr>';
echo '<tr><td class="td2" align="right"><font size="1">';
echo $l_Description.'</font></td>';
echo '<td class="td2" align="left"><textarea cols="40" rows="4" name="updescr">'.$updescr.'</textarea>';
echo ' <input type="hidden" name="uptype" value="'.$type.'">';
echo ' <input type="hidden" name="upalbum" value="'.$album.'">';
echo '<input type="hidden" name="func" value="two">';
echo '</td></tr>';
echo '<tr><td class="td2"> </td>';
echo '<td class="td2"><input type="submit" name="submitfile" value="OK"></td></tr>';
echo '<tr><td class="td1" align="center" colspan="2"><font size="1">';
echo $l_Maxko.' '.$max_upload.' KB.</font></td></tr>';
echo '<tr><td class="td0" colspan="2"> </td>';
echo '</tr></table></form><br><br><br><br>';
break;
case two:
echo '<br><br><table align="center"><tr><td class="td2" align="center"><font size="2">';
$ext = $uploadedfile_type;
$ime = date("mdHis");
$len = strlen($ext);
$pos = strpos($ext,'/')+1;
$extension = substr($ext, $pos, $len);
$email_ok = eregi("^[_\.0-9a-z-]+@([0-9a-z-]+\.)+[a-z]{2,4}$", $upemail);
if (!$email_ok )
{
echo '<br>'.$l_EmailNo.'.<br><a href="#" onclick="window.history.back()" class="lien1"><b>'.$l_again.'</b></a></font>';
$func = 'one';
break;
}
if($extension=="pjpeg"){ $extension="jpg"; }
if($extension=="PJPEG"){ $extension="jpg"; }
if($extension=="jpeg"){ $extension="jpg"; }
if($extension=="JPEG"){ $extension="jpg"; }
if($extension != 'jpg' && $extension != 'JPG')
{
unset($uploadedfile);
echo '<b>Server error (bad file extension)</b>.<br>'.$l_Maxko.'<br>'.$max_upload.' KB.<br><a href="#" onclick="window.history.back()" class="lien1"><b>'.$l_again.'</b></a></font>';
$func = 'one';
break;
}
//build new name of name that you specified, . and extension of image
else
{
$ime.='.'.strtolower($extension);
}
//if image exist, upload it in correct dir
if($uploadedfile <> 'none')
{
if(!copy($uploaded, "$dir/$ime") && !move_uploaded_file($uploaded, "$dir/$ime"))
{
//display errors
echo '<b>Server error (can\'t upload)</b>.<br><a href="upload.php?album='.$album.'" class="lien1"><b>'.$l_again.'</b></a></font>';
}
//or finish
else
{
chmod("./upload/$ime", 0777 );
$fsize = filesize("./upload/$ime");
if ($fsize > ($max_upload * 1024))
{
unlink ("./upload/$ime");
echo '<b>Server error (file size)</b>.<br>'.$l_Maxko.'<br>'.$max_upload.' KB.<br><a href="upload.php?idalbum='.$album.'" class="lien1"><b>'.$l_again.'</b></a></font>';
}
else
{
echo $l_uploaded.'<br>';
echo '<a href="#" onclick="javascript:window.close()" class="lien1"><b>OK</b></a></font>';
$upauthor = addslashes($upauthor);
$title = addslashes($uptitle);
$descr = addslashes($updescr);
$mysql_link = mysql_connect($host,$login,$pass);
mysql_select_db($base, $mysql_link);
$query = "INSERT INTO mcgallery_upload VALUES('', '$upalbum', '$ime', '$upauthor', '$upemail', '$upurl', '$title', '$descr')";
mysql_query($query);
if ($mail_function == 1)
{
email("mcgallerypro",$email_admin,"mcgallerypro - Upload","$l_uploadNew\n\n$site/admin");
}
else
{
mail($email_admin, "mcgallerypro - Upload", "$l_uploadNew\n\n$site/admin", "From: $email_admin");
}
}
}
}
break;
echo '</td></tr></table>';
}
?>
</body>
</html>