| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/kelvin/webadmin/ |
Upload File : |
<?php
include 'config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1'))
{
header("Location: login.php");
exit;
}
require("configure.php");
require("function_resizethumb.php");
$pdid = $_POST["pdid"];
$pimgid = $_POST["pimgid"];
$nowdate = date("Y-m-d H:i:s");
//print_r($_POST);
$sql = "SELECT * FROM product_image WHERE pimgid=". $pimgid ." ";
$result=mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
if ($_FILES['pimgfile']['name'] <> '' or $_POST['delimage'] > 0 ) {
unlink("../images/product/large/".$row{'pimgfile'});
unlink("../images/product/mid/".$row{'pimgfile'});
unlink("../images/product/thumb/".$row{'pimgfile'});
}
$filelimit = 2 * 1048576; //Filelimit in 2MB
if ($_FILES['pimgfile']['name'] <> '')
{
if ($_FILES['pimgfile']['size'] < $filelimit ){
if (($_FILES["pimgfile"]["type"] == "image/gif") || ($_FILES["pimgfile"]["type"] == "image/GIF") || ($_FILES["pimgfile"]["type"] == "image/jpg") || ($_FILES["pimgfile"]["type"] == "image/JPG") || ($_FILES["pimgfile"]["type"] == "image/jpeg") || ($_FILES["pimgfile"]["type"] == "image/JPEG") || ($_FILES["pimgfile"]["type"] == "image/pjpeg") || ($_FILES["pimgfile"]["type"] == "image/PJEG") || ($_FILES["pimgfile"]["type"] == "image/png") || ($_FILES["pimgfile"]["type"] == "image/x-png") || ($_FILES["pimgfile"]["type"] == "image/PNG") || ($_FILES["pimgfile"]["type"] == "image/X-PNG"))
{
$filename=$_FILES['pimgfile']['name'];
preg_match("/\.([^\.]+)$/", $filename, $file_ext);
copy ($_FILES['pimgfile']['tmp_name'], "../images/product/large/product_".$pdid."_".$pimgid.".".$file_ext[1])
or die ("Could not copy the file: Product Photo(large)");
$imagelarge = "../images/product/large/product_".$pdid."_".$pimgid.".".$file_ext[1];
createthumb($imagelarge, $imagelarge, 800, 800);
copy ($_FILES['pimgfile']['tmp_name'], "../images/product/mid/product_".$pdid."_".$pimgid.".".$file_ext[1])
or die ("Could not copy the file: Project Photo(mid)");
$imagemid = "../images/product/mid/product_".$pdid."_".$pimgid.".".$file_ext[1];
createthumb($imagemid, $imagemid, 180, 180);
copy ($_FILES['pimgfile']['tmp_name'], "../images/product/thumb/product_".$pdid."_".$pimgid.".".$file_ext[1])
or die ("Could not copy the file: Product Photo(thumb)");
$imagethumb = "../images/product/thumb/product_".$pdid."_".$pimgid.".".$file_ext[1];
createthumb($imagethumb, $imagethumb, 400, 400);
$pimgfile = "product_".$pdid."_".$pimgid.".".$file_ext[1];
$pimgfile = htmlspecialchars($pimgfile,ENT_QUOTES);
}
}
else
{
// upload error
?>
<script language="javascript">
alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
history.back();
</script>
<?php
exit;
}
}
else
{
$pimgfile = "";
}
// Modify
$sql = "update product_image set modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' ";
if ($pimgfile <> '' or $_POST['delimage'] > 0 )
$sql .= ", pimgfile='$pimgfile' ";
$sql .= " where pimgid=". $pimgid ." ";
mysql_query($sql);
if( mysql_errno() > 0 ){
echo 'Modify Product Detail(Images) Error:<br />'. mysql_error() .'<br />SQL: '. $sql;
exit;
}
mysql_close($dbh);
header("Location: product_image_index.php?pdid=$pdid&msg=Modify Successful");
?>