| 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/alliancealliance/webadmin/ |
Upload File : |
<?php
require_once('check_login.php');
require_once("function_cropimg.php");
require_once("mime_type_lib.php");
$id = (int)$_POST["id"];
$sql = "select * from course_category where id = ? ";
$parameters = array($id);
$old_course_category_info = bind_pdo($sql, $parameters, "selectone");
$messgae = "";
if(empty($_POST["name_en"])){
$messgae .= "Please enter name.\\n\\n";
}
if(empty($_POST["menu_id"])){
$messgae .= "Please select a menu.\\n\\n";
}
if(!empty($messgae)){
echo "<script>alert('".$messgae."'); history.back();</script>";
exit;
}
foreach ($arraylangcode as $langcode => $langname) {
// Upload File
$filelimit = 10 * 1048576; //Filelimit in 10MB
if ($_FILES["icon_" . $langcode]['name'] <> '') {
if ($_FILES["icon_" . $langcode]['size'] < $filelimit) {
//check if image type is valid or not
$mime = get_file_mime_type($_FILES["icon_" . $langcode]['name']);
if (($mime == "image/gif") || ($mime == "image/jpeg") || ($mime == "image/png")) {
$filename = $_FILES["icon_" . $langcode]['name'];
preg_match("/\.([^\.]+)$/", $filename, $file_ext);
$newfilename = random_string() . "_course_category_id_" . $id . "." . $file_ext[1]; // default length 8
move_uploaded_file($_FILES["icon_" . $langcode]['tmp_name'], "../images/course_category/" . $newfilename) or die ("Could not copy the file");
$icon_path = "../images/course_category/".$newfilename;
createthumb($icon_path, $icon_path, 100, 100);
$icon[$langcode] = $newfilename;
} else {
echo '<script language="javascript">
alert("Image format should be JPEG, GIF or PNG. Image size should be lower than 10MB");
history.back();
</script>';
exit;
}
} else {
echo '<script language="javascript">
alert("Image format should be JPEG, GIF or PNG. Image size should be lower than 10MB");
history.back();
</script>';
exit;
}
} else {
$icon[$langcode] = "";
//$messgae .= "Please select a banner image.\\n\\n";
}
}
if(isset($_POST["show_home"]) && $_POST["show_home"] == 1){
$show_home = 1;
}else{
$show_home = 0;
}
$sql = "update course_category set show_home=?, menu_id=?, lastupdate=?, lastupby=?, ";
$parameters = array($show_home, (int)$_POST["menu_id"], $nowdate, $_SESSION['cmsloginid']);
foreach ($arraylangcode as $langcode => $langname) {
$sql .= "name_" . $langcode . "=?, desc1_" . $langcode . "=?, desc2_" . $langcode . "=?, ";
$parameters[] = $_POST["name_" . $langcode];
$parameters[] = $_POST["desc1_" . $langcode];
$parameters[] = $_POST["desc2_" . $langcode];
if ($icon[$langcode] != '' || $_POST['delimage_' . $langcode] > 0) {
$sql .= "icon_" . $langcode . "=?, ";
$parameters[] = $icon[$langcode];
//unlink image
$unlink_file_path = "../images/course_category/" . $old_course_category_info["icon_" . $langcode];
if (is_file($unlink_file_path)) {
unlink($unlink_file_path);
}
}
}
$sql = substr_replace($sql, "", -2);
$sql .= " where id=?";
$parameters[] = $id;
bind_pdo($sql, $parameters);
$dbh = null;
header("Location: course_category_index.php?msg=2");