/var/www/hkosl.com/citysuper/webadmin/logo_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
<?php
    
require_once("check_login.php");
    require_once(
"function_cropimg.php");
    require_once(
"mime_type_lib.php");

    
$message "";

    if (empty(
$_FILES["logo_img"]['name'])) {
        
$message .= "Please select a image.\\n\\n";
    }


    if (!empty(
$message)) {
        echo 
"<script>alert('" $message "'); history.back();</script>";
        exit;
    }

    
$id $_POST["id"];

    
$sql "select * from logo where id = ?";
    
$parameters = array($id);
    
$logo_info bind_pdo($sql$parameters"selectone");

    
// Upload File

    
$filelimit 1048576//Filelimit in 2MB
    
if ($_FILES["logo_img"]['name'] <> '') {
        if (
$_FILES["logo_img"]['size'] < $filelimit) {

            
//check if image type is valid or not
            
$mime get_file_mime_type($_FILES["logo_img"]['name']);

            if ((
$mime == "image/gif") || ($mime == "image/jpeg") || ($mime == "image/png")) {

                
$filename $_FILES["logo_img"]['name'];
                
preg_match("/\.([^\.]+)$/"$filename$file_ext);
                
$newfilename random_string() . "_id_" $id "." $file_ext[1]; // default length 8

                
move_uploaded_file($_FILES["logo_img"]['tmp_name'], "../images/logo/" $newfilename) or die ("Could not copy the file");

                
//$logo_imgpath = "../images/slideshow/".$newfilename;
                //createthumb($logo_imgpath, $logo_imgpath, 680, 350);
                
$logo_img $newfilename;

            } else {
                echo 
'<script language="javascript">
                alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
                history.back();
            </script>'
;

                exit;
            }

        } else {
            echo 
'<script language="javascript">
                alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
                history.back();
            </script>'
;

            exit;
        }

    } else {
        
$logo_img "";
    }

    
$sql        "update logo set logo_img=?, lastupdate=?, lastupby=? where id=?";
    
$parameters = array($logo_img$nowdate$_SESSION['cmsloginid'], $id);
    
bind_pdo($sql$parameters);

    if (!empty(
$logo_img) || $_POST["delimage"] > 0) {
        
$targetfilepath "../images/logo/" $logo_info["logo_img"];
        if (
is_file($targetfilepath)) {
            
unlink($targetfilepath);
        }
    }

    
$dbh null;

    
header("Location: logo_index.php?msg=Modify Successfully");