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
|
<?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");
$adsort = htmlspecialchars($_POST["adsort"],ENT_QUOTES); $adlinken = htmlspecialchars($_POST["adlinken"],ENT_QUOTES); $adlinktc = htmlspecialchars($_POST["adlinktc"],ENT_QUOTES); $adlinksc = htmlspecialchars($_POST["adlinksc"],ENT_QUOTES); $adtarget = htmlspecialchars($_POST["adtarget"],ENT_QUOTES); $nowdate = date("Y-m-d H:i:s"); //print_r($_POST);
$sql = "select max(adid) as maxid "; $sql .= "from ad "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $adid = $row{maxid}+1;
// Upload File if ($_FILES['adimageen']['name'] <> '') { if (($_FILES["adimageen"]["type"] == "image/bmp") || ($_FILES["adimageen"]["type"] == "image/BMP") || ($_FILES["adimageen"]["type"] == "image/gif") || ($_FILES["adimageen"]["type"] == "image/GIF") || ($_FILES["adimageen"]["type"] == "image/jpg") || ($_FILES["adimageen"]["type"] == "image/JPG") || ($_FILES["adimageen"]["type"] == "image/jpeg") || ($_FILES["adimageen"]["type"] == "image/JPEG") || ($_FILES["adimageen"]["type"] == "image/pjpeg") || ($_FILES["adimageen"]["type"] == "image/PJEG") || ($_FILES["adimageen"]["type"] == "image/png") || ($_FILES["adimageen"]["type"] == "image/x-png") || ($_FILES["adimageen"]["type"] == "image/PNG") || ($_FILES["adimageen"]["type"] == "image/X-PNG")) { move_uploaded_file ($_FILES['adimageen']['tmp_name'], "../ad/".$adid."_en_".$_FILES['adimageen']['name']) or die ("Could not copy the file: AD"); $adimageen = $adid."_en_".$_FILES['adimageen']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $adimageen = ""; }
if ($_FILES['adimagetc']['name'] <> '') { if (($_FILES["adimagetc"]["type"] == "image/bmp") || ($_FILES["adimagetc"]["type"] == "image/BMP") || ($_FILES["adimagetc"]["type"] == "image/gif") || ($_FILES["adimagetc"]["type"] == "image/GIF") || ($_FILES["adimagetc"]["type"] == "image/jpg") || ($_FILES["adimagetc"]["type"] == "image/JPG") || ($_FILES["adimagetc"]["type"] == "image/jpeg") || ($_FILES["adimagetc"]["type"] == "image/JPEG") || ($_FILES["adimagetc"]["type"] == "image/pjpeg") || ($_FILES["adimagetc"]["type"] == "image/PJEG") || ($_FILES["adimagetc"]["type"] == "image/png") || ($_FILES["adimagetc"]["type"] == "image/x-png") || ($_FILES["adimagetc"]["type"] == "image/PNG") || ($_FILES["adimagetc"]["type"] == "image/X-PNG")) { move_uploaded_file ($_FILES['adimagetc']['tmp_name'], "../ad/".$adid."_tc_".$_FILES['adimagetc']['name']) or die ("Could not copy the file: AD"); $adimagetc = $adid."_tc_".$_FILES['adimagetc']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $adimagetc = ""; }
if ($_FILES['adimagesc']['name'] <> '') { if (($_FILES["adimagesc"]["type"] == "image/bmp") || ($_FILES["adimagesc"]["type"] == "image/BMP") || ($_FILES["adimagesc"]["type"] == "image/gif") || ($_FILES["adimagesc"]["type"] == "image/GIF") || ($_FILES["adimagesc"]["type"] == "image/jpg") || ($_FILES["adimagesc"]["type"] == "image/JPG") || ($_FILES["adimagesc"]["type"] == "image/jpeg") || ($_FILES["adimagesc"]["type"] == "image/JPEG") || ($_FILES["adimagesc"]["type"] == "image/pjpeg") || ($_FILES["adimagesc"]["type"] == "image/PJEG") || ($_FILES["adimagesc"]["type"] == "image/png") || ($_FILES["adimagesc"]["type"] == "image/x-png") || ($_FILES["adimagesc"]["type"] == "image/PNG") || ($_FILES["adimagesc"]["type"] == "image/X-PNG")) { move_uploaded_file ($_FILES['adimagesc']['tmp_name'], "../ad/".$adid."_sc_".$_FILES['adimagesc']['name']) or die ("Could not copy the file: AD"); $adimagesc = $adid."_sc_".$_FILES['adimagesc']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $adimagesc = ""; }
// Sort if ($adsort == '' || $adsort == '0') { $sql = "select max(adsort) as maxid "; $sql .= "from ad "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $adsort = $row{maxid}+1; } if( mysql_num_rows(mysql_query("SELECT adid FROM ad WHERE adsort=$adsort ")) > 0){ mysql_query("UPDATE ad SET adsort= adsort+1 WHERE adsort >=$adsort "); }
$sql = "insert into ad (adid, adimageen, adimagetc, adimagesc, adlinken, adlinktc, adlinksc, adsort, adstatus, creationday, modifyday, cmsloginid) values ('$adid', '$adimageen', '$adimagetc', '$adimagesc', '$adlinken', '$adlinktc', '$adlinksc', '$adsort', '1', '$nowdate', '$nowdate', '".$_SESSION['cmsloginid']."')"; mysql_query($sql); if( mysql_errno() > 0 ){ echo 'Add AD Error:<br />'. mysql_error() .'<br />SQL: '. $sql; exit; }
mysql_close($dbh);
header("Location: ad_index.php?msg=Add Successful"); ?>
|