/var/www/hkosl.com/kelvin/webadmin/material_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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?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");
    
$material_logoid check_input($_POST["material_logoid"]);
    
$material_logolinken        check_input($_POST["material_logolinken"]);
    
$material_logolinktc        check_input($_POST["material_logolinktc"]);
    

    
//$levelnum            = $_POST["levelnum"];
    
$nowdate             date("Y-m-d H:i:s");
//print_r($_POST); 


    
$sql "SELECT * FROM material_logo WHERE material_logoid='$material_logoid'";
$result=mysql_query($sql);
$row mysql_fetch_array($result,MYSQL_ASSOC);
if (
$_FILES['material_logoimgtc']['name'] <> '' or $_POST['delimagetc'] > )    {
unlink("../images/material_logo/".$row{'material_logoimgtc'});

    
$sql "update material_logo set material_logoimgtc='' ";
    
$sql .= " where material_logoid='$material_logoid'";
    
mysql_query($sql);
}

    if (
$_FILES['material_logoimgen']['name'] <> '' or $_POST['delimagesc'] > )    {

        
unlink("../images/material_logo/".$row{'material_logoimgen'});
        
$sql "update material_logo set material_logoimgen='' ";
        
$sql .= " where material_logoid='$material_logoid'";
        
mysql_query($sql);

    }



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

            if ((
$_FILES['material_logoimgtc']["type"] == "image/gif") || ($_FILES['material_logoimgtc']["type"] == "image/GIF") || ($_FILES['material_logoimgtc']["type"] == "image/jpg") || ($_FILES['material_logoimgtc']["type"] == "image/JPG") || ($_FILES['material_logoimgtc']["type"] == "image/jpeg") || ($_FILES['material_logoimgtc']["type"] == "image/JPEG") || ($_FILES['material_logoimgtc']["type"] == "image/pjpeg") || ($_FILES['material_logoimgtc']["type"] == "image/PJEG") || ($_FILES['material_logoimgtc']["type"] == "image/png") || ($_FILES['material_logoimgtc']["type"] == "image/x-png") || ($_FILES['material_logoimgtc']["type"] == "image/PNG") || ($_FILES['material_logoimgtc']["type"] == "image/X-PNG"))
            {


                
$filename=$_FILES['material_logoimgtc']['name'];
                
preg_match("/\.([^\.]+)$/"$filename$file_ext);

                
copy ($_FILES['material_logoimgtc']['tmp_name'], "../images/material_logo/material_logo_tc_".$material_logoid.".".$file_ext[1])
                or die (
"Could not copy the file: Project Photo(large)");

                
$imagelarge "../images/material_logo/material_logo_tc_".$material_logoid.".".$file_ext[1];
                
//createthumb($imagelarge, $imagelarge, 600, 600);

                
$material_logoimgtc "material_logo_tc_".$material_logoid.".".$file_ext[1];
                
$material_logoimgtc check_input($material_logoimgtc);


            }

        }
        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
    {
        
$material_logoimgtc "";
    }

    
//material_logoimgen
    
if ($_FILES['material_logoimgen']['name'] <> '')
    {
        if (
$_FILES['material_logoimgen']['size'] < $filelimit ){

            if ((
$_FILES['material_logoimgen']["type"] == "image/gif") || ($_FILES['material_logoimgen']["type"] == "image/GIF") || ($_FILES['material_logoimgen']["type"] == "image/jpg") || ($_FILES['material_logoimgen']["type"] == "image/JPG") || ($_FILES['material_logoimgen']["type"] == "image/jpeg") || ($_FILES['material_logoimgen']["type"] == "image/JPEG") || ($_FILES['material_logoimgen']["type"] == "image/pjpeg") || ($_FILES['material_logoimgen']["type"] == "image/PJEG") || ($_FILES['material_logoimgen']["type"] == "image/png") || ($_FILES['material_logoimgen']["type"] == "image/x-png") || ($_FILES['material_logoimgen']["type"] == "image/PNG") || ($_FILES['material_logoimgen']["type"] == "image/X-PNG"))
            {

                
$filename=$_FILES['material_logoimgen']['name'];
                
preg_match("/\.([^\.]+)$/"$filename$file_ext);

                
copy ($_FILES['material_logoimgen']['tmp_name'], "../images/material_logo/material_logo_en_".$material_logoid.".".$file_ext[1])
                or die (
"Could not copy the file: Project Photo(large)");

                
$imagelarge "../images/material_logo/material_logo_en_".$material_logoid.".".$file_ext[1];
                
//createthumb($imagelarge, $imagelarge, 600, 600);

                
$material_logoimgen "material_logo_en_".$material_logoid.".".$file_ext[1];
                
$material_logoimgen check_input($material_logoimgen);

            }

        }
        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
    {
        
$material_logoimgen "";
    }


    
    
$sql "update material_logo set material_logolinktc='$material_logolinktc', material_logolinken='$material_logolinken',
lastupdate='
$nowdate', lastupby='".$_SESSION['cmsloginid']."' ";

    if (
$material_logoimgtc <> '' or $_POST['delimagetc'] > )
        
$sql .= ", material_logoimgtc='$material_logoimgtc' ";

    if (
$material_logoimgen <> '' or $_POST['delimagesc'] > )
        
$sql .= ", material_logoimgen='$material_logoimgen' ";
$sql .= " where material_logoid='$material_logoid'";

mysql_query($sql);
    if( 
mysql_errno() > ){
        echo 
'Modify Material Logo Error:<br />'mysql_error() .'<br />SQL: '$sql;
        exit;
    }
mysql_close($dbh);

header("Location: material_logo_index.php?msg=Update Successful");
?>