|
8 | 8 | * @Createdate 3/12/2010 12:11
|
9 | 9 | */
|
10 | 10 |
|
11 |
| -if (! defined('NV_IS_FILE_ADMIN')) { |
| 11 | +if (!defined('NV_IS_FILE_ADMIN')) { |
12 | 12 | die('Stop!!!');
|
13 | 13 | }
|
14 | 14 |
|
|
34 | 34 | include NV_ROOTDIR . '/includes/footer.php';
|
35 | 35 | }
|
36 | 36 |
|
37 |
| -$sql = 'SELECT id,login,full_name FROM ' . NV_BANNERS_GLOBALTABLE. '_clients ORDER BY login ASC'; |
| 37 | +$sql = 'SELECT id,login,full_name FROM ' . NV_BANNERS_GLOBALTABLE . '_clients ORDER BY login ASC'; |
38 | 38 | $result = $db->query($sql);
|
39 | 39 |
|
40 | 40 | $clients = array();
|
|
44 | 44 |
|
45 | 45 | $plans = array();
|
46 | 46 | $plans_form = array();
|
47 |
| -$sql = 'SELECT id, title, blang, form, require_image FROM ' . NV_BANNERS_GLOBALTABLE. '_plans ORDER BY blang, title ASC'; |
| 47 | +$sql = 'SELECT id, title, blang, form, require_image FROM ' . NV_BANNERS_GLOBALTABLE . '_plans ORDER BY blang, title ASC'; |
48 | 48 | $result = $db->query($sql);
|
49 | 49 | while ($row = $result->fetch()) {
|
50 |
| - $plans[$row['id']] = $row['title'] . ' (' . (! empty($row['blang']) ? $language_array[$row['blang']]['name'] : $lang_module['blang_all']) . ')'; |
| 50 | + $plans[$row['id']] = $row['title'] . ' (' . (!empty($row['blang']) ? $language_array[$row['blang']]['name'] : $lang_module['blang_all']) . ')'; |
51 | 51 | $require_image[$row['id']] = $row['require_image'];
|
52 | 52 | $plans_form[$row['id']] = $row['form'];
|
53 | 53 | }
|
|
64 | 64 | $clid = $nv_Request->get_int('clid', 'post', 0);
|
65 | 65 | $file_alt = nv_htmlspecialchars(strip_tags($nv_Request->get_string('file_alt', 'post', '')));
|
66 | 66 | $target = $nv_Request->get_string('target', 'post', '');
|
67 |
| - if (! isset($targets[$target])) { |
| 67 | + if (!isset($targets[$target])) { |
68 | 68 | $target = '_blank';
|
69 | 69 | }
|
70 | 70 | $bannerhtml = $nv_Request->get_editor('bannerhtml', '', NV_ALLOWED_HTML_TAGS);
|
71 | 71 | $click_url = strip_tags($nv_Request->get_string('click_url', 'post', ''));
|
72 | 72 | $publ_date = strip_tags($nv_Request->get_string('publ_date', 'post', ''));
|
73 | 73 | $exp_date = strip_tags($nv_Request->get_string('exp_date', 'post', ''));
|
74 | 74 |
|
75 |
| - if (! empty($publ_date) and ! preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $publ_date)) { |
| 75 | + if (!empty($publ_date) and !preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $publ_date)) { |
76 | 76 | $publ_date = '';
|
77 | 77 | }
|
78 |
| - if (! empty($exp_date) and ! preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $exp_date)) { |
| 78 | + if (!empty($exp_date) and !preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $exp_date)) { |
79 | 79 | $exp_date = '';
|
80 | 80 | }
|
81 | 81 |
|
82 |
| - if (! empty($clid) and ! isset($clients[$clid])) { |
| 82 | + if (!empty($clid) and !isset($clients[$clid])) { |
83 | 83 | $clid = 0;
|
84 | 84 | }
|
85 | 85 | if ($click_url == 'http://') {
|
86 | 86 | $click_url = '';
|
87 | 87 | }
|
88 | 88 |
|
89 |
| - $sql = 'SELECT require_image FROM ' . NV_BANNERS_GLOBALTABLE. '_plans where id = ' . $pid; |
90 |
| - $result = $db->query($sql); |
91 |
| - $array_require_image = $result->fetchAll(); |
| 89 | + $sql = 'SELECT require_image FROM ' . NV_BANNERS_GLOBALTABLE . '_plans where id = ' . $pid; |
| 90 | + $result = $db->query($sql); |
| 91 | + $array_require_image = $result->fetchAll(); |
92 | 92 |
|
93 |
| - if (empty($title)) { |
| 93 | + if (empty($title)) { |
94 | 94 | $error = $lang_module['title_empty'];
|
95 |
| - } elseif (empty($pid) or ! isset($plans[$pid])) { |
| 95 | + } elseif (empty($pid) or !isset($plans[$pid])) { |
96 | 96 | $error = $lang_module['plan_not_selected'];
|
97 |
| - } elseif (! empty($click_url) and ! nv_is_url($click_url)) { |
| 97 | + } elseif (!empty($click_url) and !nv_is_url($click_url)) { |
98 | 98 | $error = $lang_module['click_url_invalid'];
|
99 |
| - } elseif (! is_uploaded_file($_FILES['banner']['tmp_name']) && $array_require_image[0]['require_image'] == 1 ) { |
100 |
| - $error = $lang_module['file_upload_empty']; |
| 99 | + } elseif (!is_uploaded_file($_FILES['banner']['tmp_name']) && $array_require_image[0]['require_image'] == 1) { |
| 100 | + $error = $lang_module['file_upload_empty']; |
101 | 101 | } else {
|
102 |
| - if (empty($publ_date)) { |
| 102 | + if (empty($publ_date)) { |
103 | 103 | $publtime = NV_CURRENTTIME;
|
104 | 104 | } else {
|
105 | 105 | unset($m);
|
|
124 | 124 |
|
125 | 125 | $_weight = 0;
|
126 | 126 | if ($plans_form[$pid] == 'sequential') {
|
127 |
| - $_weight = $db->query('SELECT MAX(weight) FROM ' . NV_BANNERS_GLOBALTABLE. '_rows WHERE pid=' . $pid)->fetchColumn(); |
| 127 | + $_weight = $db->query('SELECT MAX(weight) FROM ' . NV_BANNERS_GLOBALTABLE . '_rows WHERE pid=' . $pid)->fetchColumn(); |
128 | 128 | $_weight = intval($_weight) + 1;
|
129 | 129 | }
|
130 |
| - if (! is_uploaded_file($_FILES['banner']['tmp_name'])){ |
131 |
| - $file_name = 'no_image'; |
| 130 | + if (!is_uploaded_file($_FILES['banner']['tmp_name'])) { |
| 131 | + $file_name = 'no_image'; |
132 | 132 | $file_ext = 'no_image';
|
133 | 133 | $file_mime = 'no_image';
|
134 | 134 | $width = 0;
|
135 | 135 | $height = 0;
|
136 |
| - $_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE. "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES |
| 136 | + $_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE . "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES |
137 | 137 | ( :title, " . $pid . ", " . $clid . ", :file_name, :file_ext, :file_mime,
|
138 | 138 | " . $width . ", " . $height . ", :file_alt, '', :click_url, :target, :bannerhtml, " . NV_CURRENTTIME . ", " . $publtime . ", " . $exptime . ",
|
139 | 139 | 0, 1, " . $_weight . ")";
|
140 | 140 |
|
141 |
| - $data_insert = array(); |
142 |
| - $data_insert['title'] = $title; |
143 |
| - $data_insert['file_name'] = $file_name; |
144 |
| - $data_insert['file_ext'] = $file_ext; |
145 |
| - $data_insert['file_mime'] = $file_mime; |
146 |
| - $data_insert['file_alt'] = $file_alt; |
147 |
| - $data_insert['click_url'] = $click_url; |
148 |
| - $data_insert['target'] = $target; |
149 |
| - $data_insert['bannerhtml'] = $bannerhtml; |
150 |
| - $id = $db->insert_id($_sql, 'id', $data_insert); |
151 |
| - }else{ |
152 |
| - $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); |
153 |
| - $upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false); |
154 |
| - @unlink($_FILES['banner']['tmp_name']); |
155 |
| - |
156 |
| - if (! empty($upload_info['error'])) { |
157 |
| - $error = $upload_info['error']; |
158 |
| - } else { |
159 |
| - @chmod($upload_info['name'], 0644); |
160 |
| - $file_name = $upload_info['basename']; |
161 |
| - $file_ext = $upload_info['ext']; |
162 |
| - $file_mime = $upload_info['mime']; |
163 |
| - $width = $upload_info['img_info'][0]; |
164 |
| - $height = $upload_info['img_info'][1]; |
165 |
| - |
166 |
| - |
167 |
| - $_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE. "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES |
| 141 | + $data_insert = array(); |
| 142 | + $data_insert['title'] = $title; |
| 143 | + $data_insert['file_name'] = $file_name; |
| 144 | + $data_insert['file_ext'] = $file_ext; |
| 145 | + $data_insert['file_mime'] = $file_mime; |
| 146 | + $data_insert['file_alt'] = $file_alt; |
| 147 | + $data_insert['click_url'] = $click_url; |
| 148 | + $data_insert['target'] = $target; |
| 149 | + $data_insert['bannerhtml'] = $bannerhtml; |
| 150 | + $id = $db->insert_id($_sql, 'id', $data_insert); |
| 151 | + } else { |
| 152 | + $upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT); |
| 153 | + $upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false); |
| 154 | + @unlink($_FILES['banner']['tmp_name']); |
| 155 | + |
| 156 | + if (!empty($upload_info['error'])) { |
| 157 | + $error = $upload_info['error']; |
| 158 | + } else { |
| 159 | + @chmod($upload_info['name'], 0644); |
| 160 | + $file_name = $upload_info['basename']; |
| 161 | + $file_ext = $upload_info['ext']; |
| 162 | + $file_mime = $upload_info['mime']; |
| 163 | + $width = $upload_info['img_info'][0]; |
| 164 | + $height = $upload_info['img_info'][1]; |
| 165 | + |
| 166 | + $_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE . "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES |
168 | 167 | ( :title, " . $pid . ", " . $clid . ", :file_name, :file_ext, :file_mime,
|
169 | 168 | " . $width . ", " . $height . ", :file_alt, '', :click_url, :target, :bannerhtml, " . NV_CURRENTTIME . ", " . $publtime . ", " . $exptime . ",
|
170 | 169 | 0, 1, " . $_weight . ")";
|
171 | 170 |
|
172 |
| - $data_insert = array(); |
173 |
| - $data_insert['title'] = $title; |
174 |
| - $data_insert['file_name'] = $file_name; |
175 |
| - $data_insert['file_ext'] = $file_ext; |
176 |
| - $data_insert['file_mime'] = $file_mime; |
177 |
| - $data_insert['file_alt'] = $file_alt; |
178 |
| - $data_insert['click_url'] = $click_url; |
179 |
| - $data_insert['target'] = $target; |
180 |
| - $data_insert['bannerhtml'] = $bannerhtml; |
181 |
| - $id = $db->insert_id($_sql, 'id', $data_insert); |
182 |
| - } |
183 |
| - } |
184 |
| - nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_banner', 'bannerid ' . $id, $admin_info['userid']); |
| 171 | + $data_insert = array(); |
| 172 | + $data_insert['title'] = $title; |
| 173 | + $data_insert['file_name'] = $file_name; |
| 174 | + $data_insert['file_ext'] = $file_ext; |
| 175 | + $data_insert['file_mime'] = $file_mime; |
| 176 | + $data_insert['file_alt'] = $file_alt; |
| 177 | + $data_insert['click_url'] = $click_url; |
| 178 | + $data_insert['target'] = $target; |
| 179 | + $data_insert['bannerhtml'] = $bannerhtml; |
| 180 | + $id = $db->insert_id($_sql, 'id', $data_insert); |
| 181 | + } |
| 182 | + } |
| 183 | + nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_banner', 'bannerid ' . $id, $admin_info['userid']); |
185 | 184 | nv_CreateXML_bannerPlan();
|
186 | 185 | $op2 = ($file_ext == 'swf') ? 'edit_banner' : 'info_banner';
|
187 | 186 | nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op2 . '&id=' . $id);
|
|
202 | 201 | }
|
203 | 202 | }
|
204 | 203 |
|
205 |
| -$contents['info'] = (! empty($error)) ? $error : $lang_module['add_banner_info']; |
206 |
| -$contents['is_error'] = (! empty($error)) ? 1 : 0; |
| 204 | +$contents['info'] = (!empty($error)) ? $error : $lang_module['add_banner_info']; |
| 205 | +$contents['is_error'] = (!empty($error)) ? 1 : 0; |
207 | 206 | $contents['file_allowed_ext'] = implode(', ', $contents['file_allowed_ext']);
|
208 | 207 | $contents['submit'] = $lang_module['add_banner'];
|
209 | 208 | $contents['action'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=add_banner';
|
210 |
| -$contents['title'] = array( $lang_module['title'], 'title', $title, 255 ); |
211 |
| -$contents['plan'] = array( $lang_module['in_plan'], 'pid', $plans, $pid, $row, $require_image ); |
212 |
| -$contents['client'] = array( $lang_module['of_client'], 'clid', $clients, $clid ); |
213 |
| -$contents['upload'] = array( sprintf($lang_module['upload'], $contents['file_allowed_ext']), 'banner' ); |
214 |
| -$contents['file_alt'] = array( $lang_module['file_alt'], 'file_alt', $file_alt, 255 ); |
215 |
| -$contents['click_url'] = array( $lang_module['click_url'], 'click_url', $click_url, 255 ); |
216 |
| -$contents['target'] = array( $lang_module['target'], 'target', $targets, $target ); |
217 |
| -$contents['publ_date'] = array( $lang_module['publ_date'], 'publ_date', $publ_date, 10 ); |
218 |
| -$contents['exp_date'] = array( $lang_module['exp_date'], 'exp_date', $exp_date, 10 ); |
| 209 | +$contents['title'] = array( |
| 210 | + $lang_module['title'], |
| 211 | + 'title', |
| 212 | + $title, |
| 213 | + 255 |
| 214 | +); |
| 215 | +$contents['plan'] = array( |
| 216 | + $lang_module['in_plan'], |
| 217 | + 'pid', |
| 218 | + $plans, |
| 219 | + $pid, |
| 220 | + $row, |
| 221 | + $require_image |
| 222 | +); |
| 223 | +$contents['client'] = array( |
| 224 | + $lang_module['of_client'], |
| 225 | + 'clid', |
| 226 | + $clients, |
| 227 | + $clid |
| 228 | +); |
| 229 | +$contents['upload'] = array( |
| 230 | + sprintf($lang_module['upload'], $contents['file_allowed_ext']), |
| 231 | + 'banner' |
| 232 | +); |
| 233 | +$contents['file_alt'] = array( |
| 234 | + $lang_module['file_alt'], |
| 235 | + 'file_alt', |
| 236 | + $file_alt, |
| 237 | + 255 |
| 238 | +); |
| 239 | +$contents['click_url'] = array( |
| 240 | + $lang_module['click_url'], |
| 241 | + 'click_url', |
| 242 | + $click_url, |
| 243 | + 255 |
| 244 | +); |
| 245 | +$contents['target'] = array( |
| 246 | + $lang_module['target'], |
| 247 | + 'target', |
| 248 | + $targets, |
| 249 | + $target |
| 250 | +); |
| 251 | +$contents['publ_date'] = array( |
| 252 | + $lang_module['publ_date'], |
| 253 | + 'publ_date', |
| 254 | + $publ_date, |
| 255 | + 10 |
| 256 | +); |
| 257 | +$contents['exp_date'] = array( |
| 258 | + $lang_module['exp_date'], |
| 259 | + 'exp_date', |
| 260 | + $exp_date, |
| 261 | + 10 |
| 262 | +); |
219 | 263 | $contents['bannerhtml'] = htmlspecialchars(nv_editor_br2nl($bannerhtml));
|
220 | 264 |
|
221 | 265 | if (defined('NV_EDITOR')) {
|
222 | 266 | require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
|
223 | 267 | }
|
224 | 268 |
|
225 | 269 | if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) {
|
226 |
| - $contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml']); |
| 270 | + $contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml'], '', NV_UPLOADS_DIR . '/' . $module_upload, NV_UPLOADS_DIR . '/' . $module_upload . '/files'); |
227 | 271 | } else {
|
228 | 272 | $contents['bannerhtml'] = '<textarea style="width:100%;height:300px" name="bannerhtml">' . $contents['bannerhtml'] . '</textarea>';
|
229 | 273 | }
|
230 |
| -$contents['bannerhtml'] = array($lang_module['bannerhtml'], $contents['bannerhtml']); |
| 274 | +$contents['bannerhtml'] = array( |
| 275 | + $lang_module['bannerhtml'], |
| 276 | + $contents['bannerhtml'] |
| 277 | +); |
231 | 278 |
|
232 | 279 | include NV_ROOTDIR . '/includes/header.php';
|
233 | 280 | echo nv_admin_theme(nv_add_banner_theme($contents));
|
|
0 commit comments