| 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/dirsignage_old/html/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("function_cropimg.php");
require_once("mime_type_lib.php");
$nowdate = date("Y-m-d H:i:s");
// Sort
$sql1 = "select max(slideid) as maxid from slideshow";
if (!($sth1 = $dbh->prepare($sql1))) {
throw new Exception('[' . $sth1->errorCode() . ']: ' . print_r($sth1->errorInfo()));
}
if (!$sth1->execute()) {
throw new Exception('[' . $sth1->errorCode() . ']: ' . print_r($sth1->errorInfo()));
}
$row = $sth1->fetch(PDO::FETCH_ASSOC);
$slideid = $row{"maxid"} + 1;
$sql1 = "select max(sort) as maxid from slideshow where deleted = 0";
if (!($sth1 = $dbh->prepare($sql1))) {
throw new Exception('[' . $sth1->errorCode() . ']: ' . print_r($sth1->errorInfo()));
}
if (!$sth1->execute()) {
throw new Exception('[' . $sth1->errorCode() . ']: ' . print_r($sth1->errorInfo()));
}
$row = $sth1->fetch(PDO::FETCH_ASSOC);
$sort = $row{"maxid"} + 1;
foreach ($arraylangcode as $langcode => $langname) {
$slidelink[$langcode] = "";
// Upload File
if ($_FILES["slideimg_" . $langcode]['name'] <> '') {
//check if image type is valid or not
$mime = get_file_mime_type($_FILES["slideimg_" . $langcode]['name']);
if ((!strpos($mime,"image/gif") || !strpos($mime,"image/jpeg") || !strpos($mime,"image/png"))) {
$filename = $_FILES["slideimg_" . $langcode]['name'];
preg_match("/\.([^\.]+)$/", $filename, $file_ext);
$newfilename = random_string() . "_slideid_" . $slideid . "." . $file_ext[1]; // default length 8
move_uploaded_file($_FILES["slideimg_" . $langcode]['tmp_name'], "../images/slideshow/" . $newfilename) or die ("Could not copy the file");
//$slideimg_path = "../images/slideshow/".$newfilename;
//createthumb($slideimg_path, $slideimg_path, 680, 350);
$slideimg[$langcode] = $newfilename;
} else {
echo '<script language="javascript">
alert("圖片格式必須是 JPEG, GIF, or PNG");
history.back();
</script>';
exit;
}
} else {
$slideimg[$langcode] = "";
}
}
$sql = "insert into slideshow (slideid, sort, slidelink_en, slideimg_en,slidelink_tc, slideimg_tc, createdate, createby, lastupdate, lastupby) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$parameters = array($slideid, $sort, $slidelink["en"], $slideimg["en"],$slidelink["tc"], $slideimg["tc"], $nowdate, $_SESSION['cmsloginid'], $nowdate, $_SESSION['cmsloginid']);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
if (!$sth->execute($parameters)) {
throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth->errorInfo()));
}
$dbh = null;
header("Location: slideshow_index.php?msg=新增成功");
?>