/var/www/hkosl.com/alliancealliance/webadmin/course_category_modify.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?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_path100100);

                
$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");