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
|
<?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");
$hadvsort = $_POST["hadvsort"]; $hadvlinken = htmlspecialchars($_POST["hadvlinken"],ENT_QUOTES); $hadvlinksc = htmlspecialchars($_POST["hadvlinksc"],ENT_QUOTES); $hadvtitleen = htmlspecialchars($_POST["hadvtitleen"],ENT_QUOTES); $hadvtitlesc = htmlspecialchars($_POST["hadvtitlesc"],ENT_QUOTES); $nowdate = date("Y-m-d H:i:s"); //print_r($_POST);
$sql = "select max(hadvid) as maxid "; $sql .= "from h_adv "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $hadvid = $row{maxid}+1;
if ($_FILES['hadvimgen']['name'] <> '') { if (($_FILES["hadvimgen"]["type"] == "image/bmp") || ($_FILES["hadvimgen"]["type"] == "image/BMP") || ($_FILES["hadvimgen"]["type"] == "image/gif") || ($_FILES["hadvimgen"]["type"] == "image/GIF") || ($_FILES["hadvimgen"]["type"] == "image/jpg") || ($_FILES["hadvimgen"]["type"] == "image/JPG") || ($_FILES["hadvimgen"]["type"] == "image/jpeg") || ($_FILES["hadvimgen"]["type"] == "image/JPEG") || ($_FILES["hadvimgen"]["type"] == "image/pjpeg") || ($_FILES["hadvimgen"]["type"] == "image/PJEG") || ($_FILES["hadvimgen"]["type"] == "image/png") || ($_FILES["hadvimgen"]["type"] == "image/x-png") || ($_FILES["hadvimgen"]["type"] == "image/PNG") || ($_FILES["hadvimgen"]["type"] == "image/X-PNG")) { $filename=$_FILES['hadvimgen']['name']; preg_match("/\.([^\.]+)$/", $filename, $file_ext); copy ($_FILES['hadvimgen']['tmp_name'], "../adv/id_".$hadvid."_en.".$file_ext[1]) or die ("Could not copy the file: 主页 广告(EN)"); $hadvimgen = "id_".$hadvid."_en.".$file_ext[1]; $hadvimgen = htmlspecialchars($hadvimgen,ENT_QUOTES); } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $hadvimgen = ""; }
if ($_FILES['hadvimgsc']['name'] <> '') { if (($_FILES["hadvimgsc"]["type"] == "image/bmp") || ($_FILES["hadvimgsc"]["type"] == "image/BMP") || ($_FILES["hadvimgsc"]["type"] == "image/gif") || ($_FILES["hadvimgsc"]["type"] == "image/GIF") || ($_FILES["hadvimgsc"]["type"] == "image/jpg") || ($_FILES["hadvimgsc"]["type"] == "image/JPG") || ($_FILES["hadvimgsc"]["type"] == "image/jpeg") || ($_FILES["hadvimgsc"]["type"] == "image/JPEG") || ($_FILES["hadvimgsc"]["type"] == "image/pjpeg") || ($_FILES["hadvimgsc"]["type"] == "image/PJEG") || ($_FILES["hadvimgsc"]["type"] == "image/png") || ($_FILES["hadvimgsc"]["type"] == "image/x-png") || ($_FILES["hadvimgsc"]["type"] == "image/PNG") || ($_FILES["hadvimgsc"]["type"] == "image/X-PNG")) { $filename=$_FILES['hadvimgsc']['name']; preg_match("/\.([^\.]+)$/", $filename, $file_ext); copy ($_FILES['hadvimgsc']['tmp_name'], "../adv/id_".$hadvid."_sc.".$file_ext[1]) or die ("Could not copy the file: 主页 广告(EN)"); $hadvimgsc = "id_".$hadvid."_sc.".$file_ext[1]; $hadvimgsc = htmlspecialchars($hadvimgsc,ENT_QUOTES); } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $hadvimgsc = ""; }
// Sort if ($hadvsort == '' || $hadvsort == '0') { $sql = "select max(hadvsort) as maxid "; $sql .= "from h_adv "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $hadvsort = $row{maxid}+1; } if( mysql_num_rows(mysql_query("SELECT hadvid FROM h_adv WHERE hadvsort=$hadvsort ")) > 0){ mysql_query("UPDATE h_adv SET hadvsort= hadvsort+1 WHERE hadvsort >=$hadvsort "); }
$sql = "insert into h_adv (hadvid, hadvimgen, hadvimgsc, hadvlinken, hadvlinksc, hadvtitleen, hadvtitlesc, hadvsort, hadvstatus, creationday, modifyday, cmsloginid) values ('$hadvid', '$hadvimgen', '$hadvimgsc', '$hadvlinken', '$hadvlinksc', '$hadvtitleen', '$hadvtitlesc', '$hadvsort', '1', '$nowdate', '$nowdate', '".$_SESSION['cmsloginid']."')"; mysql_query($sql); if( mysql_errno() > 0 ){ echo 'Add 主页 广告 Error:<br />'. mysql_error() .'<br />SQL: '. $sql; exit; }
mysql_close($dbh);
header("Location: h_adv_index.php?msg=建立成功"); ?>
|