/var/www/hkosl.com/kelvin/webadmin/material_logo_add.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
<?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_logolinken        check_input($_POST["material_logolinken"]);
$material_logolinktc        check_input($_POST["material_logolinktc"]);

$nowdate             date("Y-m-d H:i:s");



    
$sql "select max(material_logoid) as maxid ";
    
$sql .= "from material_logo ";
    
$result=mysql_query($sql);
    
$row mysql_fetch_array($result,MYSQL_ASSOC);
    
$material_logoid $row{maxid}+1;


    
$sql "select max(sort) as maxid ";
    
$sql .= "from material_logo ";
    
$result=mysql_query($sql);
    
$row mysql_fetch_array($result,MYSQL_ASSOC);
    
$sort $row{maxid}+1;

    
// 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 "";
    }


            
$sql2 "insert into material_logo (material_logoid, sort, material_logolinken, material_logolinktc, status, createdate, lastupdate, createby, lastupby,material_logoimgtc,material_logoimgen) values ('$material_logoid', '$sort','$material_logolinken', '$material_logolinktc', '1', '$nowdate', '$nowdate', '".$_SESSION['cmsloginid']."', '".$_SESSION['cmsloginid']."', '$material_logoimgtc', '$material_logoimgen')";


            
mysql_query($sql2);

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


    
mysql_close($dbh);

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

    
?>