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
151
152
|
<?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"); ; $contentid = check_input($_REQUEST["contentid"]); $contentdesctc = preg_replace("/'/","\'",$_POST["contentdesctc"]); $contentdescen = preg_replace("/'/","\'",$_POST["contentdescen"]); $belongpage = check_input($_REQUEST["menuid"]); $belongcatid = check_input($_REQUEST["belongcatid"]);
//$sort = '1'; $nowdate = date("Y-m-d H:i:s");
//Delete execiting Image file $sql2 = "SELECT * FROM mate_tech_content WHERE contentid='$contentid' "; $result2=mysql_query($sql2); $row2 = mysql_fetch_array($result2,MYSQL_ASSOC); if ($_FILES['contentimgtc']['name'] <> '' or $_POST['delimagetc'] > 0 ) { unlink("../images/".$row{'contentimgtc'}); $sql = "update mate_tech_content set contentimgtc=''"; $sql .= " where contentid=". $contentid ." "; mysql_query($sql); }
if ($_FILES['contentimgen']['name'] <> '' or $_POST['delimageen'] > 0 ) { unlink("../images/".$row{'contentimgen'}); $sql = "update mate_tech_content set contentimgen=''"; $sql .= " where contentid=". $contentid ." "; mysql_query($sql); }
$filelimit = 2 * 1048576; //Filelimit in 2MB if ($_FILES['contentimgen']['name'] <> '') { if ($_FILES['contentimgen']['size'] < $filelimit ){
if (($_FILES["contentimgen"]["type"] == "image/gif") || ($_FILES["contentimgen"]["type"] == "image/GIF") || ($_FILES["contentimgen"]["type"] == "image/jpg") || ($_FILES["contentimgen"]["type"] == "image/JPG") || ($_FILES["contentimgen"]["type"] == "image/jpeg") || ($_FILES["contentimgen"]["type"] == "image/JPEG") || ($_FILES["contentimgen"]["type"] == "image/pjpeg") || ($_FILES["contentimgen"]["type"] == "image/PJEG") || ($_FILES["contentimgen"]["type"] == "image/png") || ($_FILES["contentimgen"]["type"] == "image/x-png") || ($_FILES["contentimgen"]["type"] == "image/PNG") || ($_FILES["contentimgen"]["type"] == "image/X-PNG")) { $filename=$_FILES['contentimgen']['name']; preg_match("/\.([^\.]+)$/", $filename, $file_ext);
copy ($_FILES['contentimgen']['tmp_name'], "../images/mate_tech_content_en_".$contentid.".".$file_ext[1]) or die ("Could not copy the file: Product Photo(thumb)");
$imagethumb = "../images/mate_tech_content_en_".$contentid.".".$file_ext[1]; //createthumb($imagethumb, $imagethumb, 200, 200);
$contentimgen = "mate_tech_content_en_".$contentid.".".$file_ext[1]; $contentimgen = htmlspecialchars($contentimgen,ENT_QUOTES); }
} 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 { $contentimgen =""; }
$filelimit = 2 * 1048576; //Filelimit in 2MB if ($_FILES['contentimgtc']['name'] <> '') { if ($_FILES['contentimgtc']['size'] < $filelimit ){
if (($_FILES['contentimgtc']["type"] == "image/gif") || ($_FILES['contentimgtc']["type"] == "image/GIF") || ($_FILES['contentimgtc']["type"] == "image/jpg") || ($_FILES['contentimgtc']["type"] == "image/JPG") || ($_FILES['contentimgtc']["type"] == "image/jpeg") || ($_FILES['contentimgtc']["type"] == "image/JPEG") || ($_FILES['contentimgtc']["type"] == "image/pjpeg") || ($_FILES['contentimgtc']["type"] == "image/PJEG") || ($_FILES['contentimgtc']["type"] == "image/png") || ($_FILES['contentimgtc']["type"] == "image/x-png") || ($_FILES['contentimgtc']["type"] == "image/PNG") || ($_FILES['contentimgtc']["type"] == "image/X-PNG")) { $filename=$_FILES['contentimgtc']['name']; preg_match("/\.([^\.]+)$/", $filename, $file_ext);
copy ($_FILES['contentimgtc']['tmp_name'], "../images/mate_tech_content_tc_".$contentid.".".$file_ext[1]) or die ("Could not copy the file: Product Photo(thumb)");
$imagethumb = "../images/mate_tech_content_tc_".$contentid.".".$file_ext[1]; //createthumb($imagethumb, $imagethumb, 200, 200);
$contentimgtc = "mate_tech_content_tc_".$contentid.".".$file_ext[1]; $contentimgtc = htmlspecialchars($contentimgtc,ENT_QUOTES); }
} 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 { $contentimgtc =""; }
// Modify $sql = "update mate_tech_content set belongpage='$belongpage', belongcatid='$belongcatid',contentdesctc='$contentdesctc', contentdescen='$contentdescen', lastupdate='$nowdate', lastupby='".$_SESSION['cmsloginid']."' ";
if ($contentimgen <> '' or $_POST['delimageen'] > 0 ) $sql .= ", contentimgen='$contentimgen'";
if ($contentimgtc <> '' or $_POST['delimagetc'] > 0 ) $sql .= ", contentimgtc='$contentimgtc'";
$sql .= " where contentid='$contentid'";
mysql_query($sql);
if( mysql_errno() > 0 ){ echo 'Modify Content Error:<br />'. mysql_error() .'<br />SQL: '. $sql; exit; }
mysql_close($dbh);
$menuid = $belongpage; header("Location: mate_tech_content_index.php?menuid=$menuid&msg=Modify Successful"); ?>
|