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
|
<?php include 'config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1')) { header("Location: login.php"); exit; } ?> <?php require("configure.php"); $homeid = $_POST["homeid"]; $homeintro = preg_replace("/'/","\'",$_POST["homeintro"]); $homedesc = preg_replace("/'/","\'",$_POST["homedesc"]);
$nowdate = date("Y-m-d H:i:s"); //print_r($_POST);
// Upload File if ($_FILES['homeimage1']['name'] <> '') { if (($_FILES["homeimage1"]["type"] == "image/bmp") || ($_FILES["homeimage1"]["type"] == "image/BMP") || ($_FILES["homeimage1"]["type"] == "image/gif") || ($_FILES["homeimage1"]["type"] == "image/GIF") || ($_FILES["homeimage1"]["type"] == "image/jpg") || ($_FILES["homeimage1"]["type"] == "image/JPG") || ($_FILES["homeimage1"]["type"] == "image/jpeg") || ($_FILES["homeimage1"]["type"] == "image/JPEG") || ($_FILES["homeimage1"]["type"] == "image/pjpeg") || ($_FILES["homeimage1"]["type"] == "image/PJEG") || ($_FILES["homeimage1"]["type"] == "image/png") || ($_FILES["homeimage1"]["type"] == "image/x-png") || ($_FILES["homeimage1"]["type"] == "image/PNG") || ($_FILES["homeimage1"]["type"] == "image/X-PNG")) { copy ($_FILES['homeimage1']['tmp_name'], "home/id_".$homeid."_A_".$_FILES['homeimage1']['name']) or die ("Could not copy the file"); $homeimage1 = "id_".$homeid."_A_".$_FILES['homeimage1']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $homeimage1 = ""; }
if ($_FILES['homeimage2']['name'] <> '') { if (($_FILES["homeimage2"]["type"] == "image/bmp") || ($_FILES["homeimage2"]["type"] == "image/BMP") || ($_FILES["homeimage2"]["type"] == "image/gif") || ($_FILES["homeimage2"]["type"] == "image/GIF") || ($_FILES["homeimage2"]["type"] == "image/jpg") || ($_FILES["homeimage2"]["type"] == "image/JPG") || ($_FILES["homeimage2"]["type"] == "image/jpeg") || ($_FILES["homeimage2"]["type"] == "image/JPEG") || ($_FILES["homeimage2"]["type"] == "image/pjpeg") || ($_FILES["homeimage2"]["type"] == "image/PJEG") || ($_FILES["homeimage2"]["type"] == "image/png") || ($_FILES["homeimage2"]["type"] == "image/x-png") || ($_FILES["homeimage2"]["type"] == "image/PNG") || ($_FILES["homeimage2"]["type"] == "image/X-PNG")) { copy ($_FILES['homeimage2']['tmp_name'], "home/id_".$homeid."_B_".$_FILES['homeimage2']['name']) or die ("Could not copy the file"); $homeimage2 = "id_".$homeid."_B_".$_FILES['homeimage2']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $homeimage2 = ""; }
if ($_FILES['homeimage3']['name'] <> '') { if (($_FILES["homeimage3"]["type"] == "image/bmp") || ($_FILES["homeimage3"]["type"] == "image/BMP") || ($_FILES["homeimage3"]["type"] == "image/gif") || ($_FILES["homeimage3"]["type"] == "image/GIF") || ($_FILES["homeimage3"]["type"] == "image/jpg") || ($_FILES["homeimage3"]["type"] == "image/JPG") || ($_FILES["homeimage3"]["type"] == "image/jpeg") || ($_FILES["homeimage3"]["type"] == "image/JPEG") || ($_FILES["homeimage3"]["type"] == "image/pjpeg") || ($_FILES["homeimage3"]["type"] == "image/PJEG") || ($_FILES["homeimage3"]["type"] == "image/png") || ($_FILES["homeimage3"]["type"] == "image/x-png") || ($_FILES["homeimage3"]["type"] == "image/PNG") || ($_FILES["homeimage3"]["type"] == "image/X-PNG")) { copy ($_FILES['homeimage3']['tmp_name'], "home/id_".$homeid."_C_".$_FILES['homeimage3']['name']) or die ("Could not copy the file"); $homeimage3 = "id_".$homeid."_C_".$_FILES['homeimage3']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $homeimage3 = ""; }
// Modify $sql = "update home set homeintro='$homeintro', homedesc='$homedesc', modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' "; if ($homeimage1 <> '') $sql .= ", homeimage1='$homeimage1' "; if ($homeimage2 <> '') $sql .= ", homeimage2='$homeimage2' "; if ($homeimage3 <> '') $sql .= ", homeimage3='$homeimage3' "; $sql .= " where homeid=". $homeid ." "; mysql_query($sql);
if( mysql_errno() > 0 ){ echo 'Modify Home Error:<br />'. mysql_error() .'<br />SQL: '. $sql; exit; }
mysql_close($dbh);
header("Location: home_modifyform.php?msg=Modify Successful"); ?>
|