These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000-2016 XOOPS.org // |
||
6 | // <http://xoops.org/> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | |||
28 | //defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
||
0 ignored issues
–
show
|
|||
29 | if (!defined('XOOPS_ROOT_PATH')) { |
||
30 | include __DIR__ . '/../../mainfile.php'; |
||
31 | } |
||
32 | include_once __DIR__ . '/header.php'; |
||
33 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
34 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; |
||
35 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
||
36 | include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
37 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
38 | include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; |
||
39 | View Code Duplication | if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
40 | include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/admin.php'; |
||
41 | } else { |
||
42 | include_once XOOPS_ROOT_PATH . '/modules/news/language/english/admin.php'; |
||
43 | } |
||
44 | $myts = MyTextSanitizer::getInstance(); |
||
45 | $module_id = $xoopsModule->getVar('mid'); |
||
46 | $storyid = 0; |
||
47 | |||
48 | if (is_object($xoopsUser)) { |
||
49 | $groups = $xoopsUser->getGroups(); |
||
50 | } else { |
||
51 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
52 | } |
||
53 | |||
54 | $gperm_handler = xoops_getHandler('groupperm'); |
||
55 | |||
56 | if (isset($_POST['topic_id'])) { |
||
57 | $perm_itemid = (int)$_POST['topic_id']; |
||
58 | } else { |
||
59 | $perm_itemid = 0; |
||
60 | } |
||
61 | //If no access |
||
62 | View Code Duplication | if (!$gperm_handler->checkRight('news_submit', $perm_itemid, $groups, $module_id)) { |
|
63 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
64 | } |
||
65 | $op = 'form'; |
||
66 | |||
67 | //If approve privileges |
||
68 | $approveprivilege = 0; |
||
69 | if (is_object($xoopsUser) && $gperm_handler->checkRight('news_approve', $perm_itemid, $groups, $module_id)) { |
||
70 | $approveprivilege = 1; |
||
71 | } |
||
72 | |||
73 | if (isset($_POST['preview'])) { |
||
74 | $op = 'preview'; |
||
75 | } elseif (isset($_POST['post'])) { |
||
76 | $op = 'post'; |
||
77 | } elseif (isset($_GET['op']) && isset($_GET['storyid'])) { |
||
78 | // Verify that the user can edit or delete an article |
||
79 | if ($_GET['op'] === 'edit' || $_GET['op'] === 'delete') { |
||
80 | if ($xoopsModuleConfig['authoredit'] == 1) { |
||
81 | $tmpstory = new NewsStory((int)$_GET['storyid']); |
||
82 | if (is_object($xoopsUser) && $xoopsUser->getVar('uid') != $tmpstory->uid() && !news_is_admin_group()) { |
||
83 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
84 | } |
||
85 | } else { // Users can't edit their articles |
||
86 | if (!news_is_admin_group()) { |
||
87 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | |||
92 | if ($approveprivilege && $_GET['op'] === 'edit') { |
||
93 | $op = 'edit'; |
||
94 | $storyid = (int)$_GET['storyid']; |
||
95 | } elseif ($approveprivilege && $_GET['op'] === 'delete') { |
||
96 | $op = 'delete'; |
||
97 | $storyid = (int)$_GET['storyid']; |
||
98 | } else { |
||
99 | if (news_getmoduleoption('authoredit') && is_object($xoopsUser) && isset($_GET['storyid']) |
||
100 | && ($_GET['op'] === 'edit' |
||
101 | || $_POST['op'] === 'preview' |
||
102 | || $_POST['op'] === 'post') |
||
103 | ) { |
||
104 | $storyid = 0; |
||
105 | $storyid = isset($_GET['storyid']) ? (int)$_GET['storyid'] : (int)$_POST['storyid']; |
||
106 | if (!empty($storyid)) { |
||
107 | $tmpstory = new NewsStory($storyid); |
||
108 | if ($tmpstory->uid() == $xoopsUser->getVar('uid')) { |
||
109 | $op = isset($_GET['op']) ? $_GET['op'] : $_POST['post']; |
||
110 | unset($tmpstory); |
||
111 | $approveprivilege = 1; |
||
112 | View Code Duplication | } else { |
|
113 | unset($tmpstory); |
||
114 | if (!news_is_admin_group()) { |
||
115 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
116 | } else { |
||
117 | $approveprivilege = 1; |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | View Code Duplication | } else { |
|
122 | if (!news_is_admin_group()) { |
||
123 | unset($tmpstory); |
||
124 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
125 | } else { |
||
126 | $approveprivilege = 1; |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | |||
132 | switch ($op) { |
||
133 | case 'edit': |
||
134 | if (!$approveprivilege) { |
||
135 | redirect_header(XOOPS_URL . '/modules/news/index.php', 0, _NOPERM); |
||
136 | |||
137 | break; |
||
138 | } |
||
139 | //if ($storyid==0 && isset($_POST['storyid'])) { |
||
140 | //$storyid=(int)($_POST['storyid']); |
||
141 | //} |
||
142 | $story = new NewsStory($storyid); |
||
143 | View Code Duplication | if (!$gperm_handler->checkRight('news_view', $story->topicid(), $groups, $module_id)) { |
|
144 | redirect_header(XOOPS_URL . '/modules/news/index.php', 0, _NOPERM); |
||
145 | } |
||
146 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
||
147 | echo '<h4>' . _AM_EDITARTICLE . '</h4>'; |
||
148 | $title = $story->title('Edit'); |
||
149 | $subtitle = $story->subtitle('Edit'); |
||
150 | $hometext = $story->hometext('Edit'); |
||
151 | $bodytext = $story->bodytext('Edit'); |
||
152 | $nohtml = $story->nohtml(); |
||
153 | $nosmiley = $story->nosmiley(); |
||
154 | $description = $story->description(); |
||
155 | $keywords = $story->keywords(); |
||
156 | $ihome = $story->ihome(); |
||
157 | $newsauthor = $story->uid(); |
||
158 | $topicid = $story->topicid(); |
||
159 | $notifypub = $story->notifypub(); |
||
160 | $picture = $story->picture(); |
||
161 | $pictureinfo = $story->pictureinfo; |
||
162 | $approve = 0; |
||
163 | $published = $story->published(); |
||
164 | if (isset($published) && $published > 0) { |
||
165 | $approve = 1; |
||
166 | } |
||
167 | if ($story->published() != 0) { |
||
168 | $published = $story->published(); |
||
169 | } |
||
170 | if ($story->expired() != 0) { |
||
171 | $expired = $story->expired(); |
||
172 | } else { |
||
173 | $expired = 0; |
||
174 | } |
||
175 | $type = $story->type(); |
||
176 | $topicdisplay = $story->topicdisplay(); |
||
177 | $topicalign = $story->topicalign(false); |
||
178 | if (!news_is_admin_group()) { |
||
179 | include_once XOOPS_ROOT_PATH . '/modules/news/include/storyform.inc.php'; |
||
180 | } else { |
||
181 | include_once XOOPS_ROOT_PATH . '/modules/news/include/storyform.original.php'; |
||
182 | } |
||
183 | echo '</td></tr></table>'; |
||
184 | break; |
||
185 | |||
186 | case 'preview': |
||
187 | $topic_id = (int)$_POST['topic_id']; |
||
188 | $xt = new NewsTopic($topic_id); |
||
189 | View Code Duplication | if (isset($_GET['storyid'])) { |
|
190 | $storyid = (int)$_GET['storyid']; |
||
191 | } else { |
||
192 | if (isset($_POST['storyid'])) { |
||
193 | $storyid = (int)$_POST['storyid']; |
||
194 | } else { |
||
195 | $storyid = 0; |
||
196 | } |
||
197 | } |
||
198 | |||
199 | if (!empty($storyid)) { |
||
200 | $story = new NewsStory($storyid); |
||
201 | $published = $story->published(); |
||
202 | $expired = $story->expired(); |
||
203 | } else { |
||
204 | $story = new NewsStory(); |
||
205 | $published = isset($_POST['publish_date']) ? $_POST['publish_date'] : 0; |
||
206 | View Code Duplication | if (!empty($published) && isset($_POST['autodate']) && (int)($_POST['autodate'] == 1)) { |
|
207 | $published = strtotime($published['date']) + $published['time']; |
||
208 | } else { |
||
209 | $published = 0; |
||
210 | } |
||
211 | $expired = isset($_POST['expiry_date']) ? $_POST['expiry_date'] : 0; |
||
212 | View Code Duplication | if (!empty($expired) && isset($_POST['autoexpdate']) && (int)($_POST['autoexpdate'] == 1)) { |
|
213 | $expired = strtotime($expired['date']) + $expired['time']; |
||
214 | } else { |
||
215 | $expired = 0; |
||
216 | } |
||
217 | } |
||
218 | $topicid = $topic_id; |
||
219 | if (isset($_POST['topicdisplay'])) { |
||
220 | $topicdisplay = (int)$_POST['topicdisplay']; |
||
221 | } else { |
||
222 | $topicdisplay = 1; |
||
223 | } |
||
224 | |||
225 | $approve = isset($_POST['approve']) ? (int)$_POST['approve'] : 0; |
||
226 | $topicalign = 'R'; |
||
227 | if (isset($_POST['topicalign'])) { |
||
228 | $topicalign = $_POST['topicalign']; |
||
229 | } |
||
230 | $story->setTitle($_POST['title']); |
||
231 | $story->setSubtitle($_POST['subtitle']); |
||
232 | $story->setHometext($_POST['hometext']); |
||
233 | if ($approveprivilege) { |
||
234 | $story->setTopicdisplay($topicdisplay); |
||
235 | $story->setTopicalign($topicalign); |
||
236 | $story->setBodytext($_POST['bodytext']); |
||
237 | if (news_getmoduleoption('metadata')) { |
||
238 | $story->setKeywords($_POST['keywords']); |
||
239 | $story->setDescription($_POST['description']); |
||
240 | $story->setIhome((int)$_POST['ihome']); |
||
241 | } |
||
242 | } else { |
||
243 | $noname = isset($_POST['noname']) ? (int)$_POST['noname'] : 0; |
||
244 | } |
||
245 | |||
246 | if ($approveprivilege || (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid()))) { |
||
247 | if (isset($_POST['author'])) { |
||
248 | $story->setUid((int)$_POST['author']); |
||
249 | } |
||
250 | } |
||
251 | |||
252 | $notifypub = isset($_POST['notifypub']) ? (int)$_POST['notifypub'] : 0; |
||
253 | $nosmiley = isset($_POST['nosmiley']) ? (int)$_POST['nosmiley'] : 0; |
||
254 | if (isset($nosmiley) && ($nosmiley == 0 || $nosmiley == 1)) { |
||
255 | $story->setNosmiley($nosmiley); |
||
256 | } else { |
||
257 | $nosmiley = 0; |
||
258 | } |
||
259 | if ($approveprivilege) { |
||
260 | $nohtml = isset($_POST['nohtml']) ? (int)$_POST['nohtml'] : 0; |
||
261 | $story->setNohtml($nohtml); |
||
262 | if (!isset($_POST['approve'])) { |
||
263 | $approve = 0; |
||
264 | } |
||
265 | } else { |
||
266 | $story->setNohtml = 1; |
||
267 | } |
||
268 | |||
269 | $title = $story->title('InForm'); |
||
270 | $subtitle = $story->subtitle('InForm'); |
||
271 | $hometext = $story->hometext('InForm'); |
||
272 | if ($approveprivilege) { |
||
273 | $bodytext = $story->bodytext('InForm'); |
||
274 | $ihome = $story->ihome(); |
||
275 | $description = $story->description('E'); |
||
276 | $keywords = $story->keywords('E'); |
||
277 | } |
||
278 | $pictureinfo = $story->pictureinfo('InForm'); |
||
279 | |||
280 | //Display post preview |
||
281 | $newsauthor = $story->uid(); |
||
282 | $p_title = $story->title('Preview'); |
||
283 | $p_hometext = $story->hometext('Preview'); |
||
284 | if ($approveprivilege) { |
||
285 | $p_bodytext = $story->bodytext('Preview'); |
||
286 | $p_hometext .= '<br><br>' . $p_bodytext; |
||
287 | } |
||
288 | $topicalign2 = isset($story->topicalign) ? 'align="' . $story->topicalign() . '"' : ''; |
||
289 | $p_hometext = (($xt->topic_imgurl() !== '') && $topicdisplay) ? '<img src="'.XOOPS_URL . '/uploads/news/image/' . $xt->topic_imgurl() . '" ' . $topicalign2 . ' alt="" />' . $p_hometext : $p_hometext; |
||
290 | themecenterposts($p_title, $p_hometext); |
||
291 | |||
292 | //Display post edit form |
||
293 | $returnside = (int)$_POST['returnside']; |
||
294 | include_once XOOPS_ROOT_PATH . '/modules/news/include/storyform.inc.php'; |
||
295 | break; |
||
296 | |||
297 | case 'post': |
||
298 | $nohtml_db = isset($_POST['nohtml']) ? $_POST['nohtml'] : 1; |
||
299 | if (is_object($xoopsUser)) { |
||
300 | $uid = $xoopsUser->getVar('uid'); |
||
301 | if ($approveprivilege) { |
||
302 | $nohtml_db = empty($_POST['nohtml']) ? 0 : 1; |
||
303 | } |
||
304 | if (isset($_POST['author']) && ($approveprivilege || $xoopsUser->isAdmin($xoopsModule->mid()))) { |
||
305 | $uid = (int)$_POST['author']; |
||
306 | } |
||
307 | } else { |
||
308 | $uid = 0; |
||
309 | } |
||
310 | |||
311 | View Code Duplication | if (isset($_GET['storyid'])) { |
|
312 | $storyid = (int)$_GET['storyid']; |
||
313 | } else { |
||
314 | if (isset($_POST['storyid'])) { |
||
315 | $storyid = (int)$_POST['storyid']; |
||
316 | } else { |
||
317 | $storyid = 0; |
||
318 | } |
||
319 | } |
||
320 | |||
321 | if (empty($storyid)) { |
||
322 | $story = new NewsStory(); |
||
323 | $editmode = false; |
||
324 | } else { |
||
325 | $story = new NewsStory($storyid); |
||
326 | $editmode = true; |
||
327 | } |
||
328 | $story->setUid($uid); |
||
329 | $story->setTitle($_POST['title']); |
||
330 | $story->setSubtitle($_POST['subtitle']); |
||
331 | $story->setHometext($_POST['hometext']); |
||
332 | $story->setTopicId((int)$_POST['topic_id']); |
||
333 | $story->setHostname(xoops_getenv('REMOTE_ADDR')); |
||
334 | $story->setNohtml($nohtml_db); |
||
335 | $nosmiley = isset($_POST['nosmiley']) ? (int)$_POST['nosmiley'] : 0; |
||
336 | $story->setNosmiley($nosmiley); |
||
337 | $notifypub = isset($_POST['notifypub']) ? (int)$_POST['notifypub'] : 0; |
||
338 | $story->setNotifyPub($notifypub); |
||
339 | $story->setType($_POST['type']); |
||
340 | |||
341 | if (!empty($_POST['autodate']) && $approveprivilege) { |
||
342 | $publish_date = $_POST['publish_date']; |
||
343 | $pubdate = strtotime($publish_date['date']) + $publish_date['time']; |
||
344 | //$offset = $xoopsUser -> timezone() - $xoopsConfig['server_TZ']; |
||
345 | //$pubdate = $pubdate - ( $offset * 3600 ); |
||
346 | $story->setPublished($pubdate); |
||
347 | } |
||
348 | if (!empty($_POST['autoexpdate']) && $approveprivilege) { |
||
349 | $expiry_date = $_POST['expiry_date']; |
||
350 | $expiry_date = strtotime($expiry_date['date']) + $expiry_date['time']; |
||
351 | $offset = $xoopsUser->timezone() - $xoopsConfig['server_TZ']; |
||
352 | $expiry_date = $expiry_date - ($offset * 3600); |
||
353 | $story->setExpired($expiry_date); |
||
354 | } else { |
||
355 | $story->setExpired(0); |
||
356 | } |
||
357 | |||
358 | if ($approveprivilege) { |
||
359 | if (news_getmoduleoption('metadata')) { |
||
360 | $story->setDescription($_POST['description']); |
||
361 | $story->setKeywords($_POST['keywords']); |
||
362 | } |
||
363 | $story->setTopicdisplay($_POST['topicdisplay']); // Display Topic Image ? (Yes or No) |
||
364 | $story->setTopicalign($_POST['topicalign']); // Topic Align, 'Right' or 'Left' |
||
365 | $story->setIhome($_POST['ihome']); // Publish in home ? (Yes or No) |
||
366 | if (isset($_POST['bodytext'])) { |
||
367 | $story->setBodytext($_POST['bodytext']); |
||
368 | } else { |
||
369 | $story->setBodytext(' '); |
||
370 | } |
||
371 | $approve = isset($_POST['approve']) ? (int)$_POST['approve'] : 0; |
||
372 | |||
373 | if (!$story->published() && $approve) { |
||
374 | $story->setPublished(time()); |
||
375 | } |
||
376 | if (!$story->expired()) { |
||
377 | $story->setExpired(0); |
||
378 | } |
||
379 | |||
380 | if (!$approve) { |
||
381 | $story->setPublished(0); |
||
382 | } |
||
383 | } elseif ($xoopsModuleConfig['autoapprove'] == 1 && !$approveprivilege) { |
||
384 | if (empty($storyid)) { |
||
385 | $approve = 1; |
||
386 | } else { |
||
387 | $approve = isset($_POST['approve']) ? (int)$_POST['approve'] : 0; |
||
388 | } |
||
389 | if ($approve) { |
||
390 | $story->setPublished(time()); |
||
391 | } else { |
||
392 | $story->setPublished(0); |
||
393 | } |
||
394 | $story->setExpired(0); |
||
395 | $story->setTopicalign('R'); |
||
396 | } else { |
||
397 | $approve = 0; |
||
398 | } |
||
399 | $story->setApproved($approve); |
||
400 | |||
401 | if ($approve) { |
||
402 | news_updateCache(); |
||
403 | } |
||
404 | |||
405 | // Increment author's posts count (only if it's a new article) |
||
406 | // First case, it's not an anonyous, the story is approved and it's a new story |
||
407 | if ($uid && $approve && empty($storyid)) { |
||
408 | $tmpuser = new xoopsUser($uid); |
||
409 | $member_handler = xoops_getHandler('member'); |
||
410 | $member_handler->updateUserByField($tmpuser, 'posts', $tmpuser->getVar('posts') + 1); |
||
411 | } |
||
412 | |||
413 | // Second case, it's not an anonymous, the story is NOT approved and it's NOT a new story (typical when someone is approving a submited story) |
||
414 | if (is_object($xoopsUser) && $approve && !empty($storyid)) { |
||
415 | $storytemp = new NewsStory($storyid); |
||
416 | if (!$storytemp->published() && $storytemp->uid() > 0) { // the article has been submited but not approved |
||
417 | $tmpuser = new xoopsUser($storytemp->uid()); |
||
418 | $member_handler = xoops_getHandler('member'); |
||
419 | $member_handler->updateUserByField($tmpuser, 'posts', $tmpuser->getVar('posts') + 1); |
||
420 | } |
||
421 | unset($storytemp); |
||
422 | } |
||
423 | |||
424 | $allowupload = false; |
||
425 | View Code Duplication | switch ($xoopsModuleConfig['uploadgroups']) { |
|
426 | case 1: //Submitters and Approvers |
||
427 | $allowupload = true; |
||
428 | break; |
||
429 | case 2: //Approvers only |
||
430 | $allowupload = $approveprivilege ? true : false; |
||
431 | break; |
||
432 | case 3: //Upload Disabled |
||
433 | $allowupload = false; |
||
434 | break; |
||
435 | } |
||
436 | |||
437 | if ($allowupload && isset($_POST['deleteimage']) && (int)$_POST['deleteimage'] == 1) { |
||
438 | $currentPicture = $story->picture(); |
||
439 | if (xoops_trim($currentPicture) !== '') { |
||
440 | $currentPicture = XOOPS_ROOT_PATH . '/uploads/news/image/' . xoops_trim($story->picture()); |
||
441 | if (is_file($currentPicture) && file_exists($currentPicture)) { |
||
442 | if (!unlink($currentPicture)) { |
||
443 | trigger_error('Error, impossible to delete the picture attached to this article'); |
||
444 | } |
||
445 | } |
||
446 | } |
||
447 | $story->setPicture(''); |
||
448 | $story->setPictureinfo(''); |
||
449 | } |
||
450 | |||
451 | if ($allowupload) { // L'image |
||
452 | if (isset($_POST['xoops_upload_file'])) { |
||
453 | $fldname = $_FILES[$_POST['xoops_upload_file'][1]]; |
||
454 | $fldname = $fldname['name']; |
||
455 | if (xoops_trim($fldname !== '')) { |
||
456 | $sfiles = new sFiles(); |
||
457 | $destname = $sfiles->createUploadName(XOOPS_ROOT_PATH . '/uploads/news/image', $fldname); |
||
458 | $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); |
||
459 | $uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/uploads/news/image', $permittedtypes, |
||
460 | $xoopsModuleConfig['maxuploadsize']); |
||
461 | $uploader->setTargetFileName($destname); |
||
462 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
||
463 | if ($uploader->upload()) { |
||
464 | $fullPictureName = XOOPS_ROOT_PATH . '/uploads/news/image/' . basename($destname); |
||
465 | $newName = XOOPS_ROOT_PATH . '/uploads/news/image/redim_' . basename($destname); |
||
466 | news_resizePicture($fullPictureName, $newName, $xoopsModuleConfig['maxwidth'], $xoopsModuleConfig['maxheight']); |
||
467 | if (file_exists($newName)) { |
||
468 | @unlink($fullPictureName); |
||
469 | rename($newName, $fullPictureName); |
||
470 | } |
||
471 | $story->setPicture(basename($destname)); |
||
472 | } else { |
||
473 | echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); |
||
474 | } |
||
475 | } else { |
||
476 | echo $uploader->getErrors(); |
||
477 | } |
||
478 | } |
||
479 | $story->setPictureinfo($_POST['pictureinfo']); |
||
480 | } |
||
481 | } |
||
482 | $destname = ''; |
||
483 | |||
484 | $result = $story->store(); |
||
485 | if ($result) { |
||
486 | if (xoops_isActiveModule('tag') && news_getmoduleoption('tags')) { |
||
487 | $tag_handler = xoops_getModuleHandler('tag', 'tag'); |
||
488 | $tag_handler->updateByItem($_POST['item_tag'], $story->storyid(), $xoopsModule->getVar('dirname'), 0); |
||
489 | } |
||
490 | |||
491 | if (!$editmode) { |
||
492 | // Notification |
||
493 | // TODO: modifier afin qu'en cas de pr�publication, la notification ne se fasse pas |
||
494 | $notification_handler = xoops_getHandler('notification'); |
||
495 | $tags = array(); |
||
496 | $tags['STORY_NAME'] = $story->title(); |
||
497 | $tags['STORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/article.php?storyid=' . $story->storyid(); |
||
498 | // If notify checkbox is set, add subscription for approve |
||
499 | if ($notifypub && $approve) { |
||
500 | include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
501 | $notification_handler->subscribe('story', $story->storyid(), 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE, |
||
502 | $xoopsModule->getVar('mid'), $story->uid()); |
||
503 | } |
||
504 | |||
505 | if ($approve == 1) { |
||
506 | $notification_handler->triggerEvent('global', 0, 'new_story', $tags); |
||
507 | $notification_handler->triggerEvent('story', $story->storyid(), 'approve', $tags); |
||
508 | // Added by Lankford on 2007/3/23 |
||
509 | $notification_handler->triggerEvent('category', $story->topicid(), 'new_story', $tags); |
||
510 | } else { |
||
511 | $tags['WAITINGSTORIES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=newarticle'; |
||
512 | $notification_handler->triggerEvent('global', 0, 'story_submit', $tags); |
||
513 | } |
||
514 | } |
||
515 | |||
516 | if ($allowupload) { |
||
517 | // Manage upload(s) |
||
518 | if (isset($_POST['delupload']) && count($_POST['delupload']) > 0) { |
||
519 | foreach ($_POST['delupload'] as $onefile) { |
||
520 | $sfiles = new sFiles($onefile); |
||
521 | $sfiles->delete(); |
||
522 | } |
||
523 | } |
||
524 | |||
525 | if (isset($_POST['xoops_upload_file'])) { |
||
526 | $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; |
||
527 | $fldname = $fldname['name']; |
||
528 | if (xoops_trim($fldname !== '')) { |
||
529 | $sfiles = new sFiles(); |
||
530 | $destname = $sfiles->createUploadName(XOOPS_UPLOAD_PATH, $fldname); |
||
531 | /** |
||
532 | * You can attach files to your news |
||
533 | */ |
||
534 | $permittedtypes = explode("\n", str_replace("\r", '', news_getmoduleoption('mimetypes'))); |
||
535 | array_walk($permittedtypes, 'trim'); |
||
536 | $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); |
||
537 | $uploader->setTargetFileName($destname); |
||
538 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||
539 | if ($uploader->upload()) { |
||
540 | $sfiles->setFileRealName($uploader->getMediaName()); |
||
541 | $sfiles->setStoryid($story->storyid()); |
||
542 | $sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH . '/' . $uploader->getMediaName())); |
||
543 | $sfiles->setDownloadname($destname); |
||
544 | if (!$sfiles->store()) { |
||
545 | echo _AM_UPLOAD_DBERROR_SAVE; |
||
546 | } |
||
547 | } else { |
||
548 | echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); |
||
549 | } |
||
550 | } else { |
||
551 | echo $uploader->getErrors(); |
||
552 | } |
||
553 | } |
||
554 | } |
||
555 | } |
||
556 | } else { |
||
557 | echo _ERRORS; |
||
558 | } |
||
559 | $returnside = isset($_POST['returnside']) ? (int)$_POST['returnside'] : 0; |
||
560 | if (!$returnside) { |
||
561 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_THANKS); |
||
562 | } else { |
||
563 | redirect_header(XOOPS_URL . '/modules/news/admin/index.php?op=newarticle', 2, _NW_THANKS); |
||
564 | } |
||
565 | break; |
||
566 | |||
567 | case 'form': |
||
568 | $xt = new NewsTopic(); |
||
569 | $title = ''; |
||
570 | $subtitle = ''; |
||
571 | $hometext = ''; |
||
572 | $noname = 0; |
||
573 | $nohtml = 0; |
||
574 | $nosmiley = 0; |
||
575 | $notifypub = 1; |
||
576 | $topicid = 0; |
||
577 | if ($approveprivilege) { |
||
578 | $description = ''; |
||
579 | $keywords = ''; |
||
580 | $topicdisplay = 0; |
||
581 | $topicalign = 'R'; |
||
582 | $ihome = 0; |
||
583 | $bodytext = ''; |
||
584 | $approve = 0; |
||
585 | $autodate = ''; |
||
586 | $expired = 0; |
||
587 | $published = 0; |
||
588 | } |
||
589 | if ($xoopsModuleConfig['autoapprove'] == 1) { |
||
590 | $approve = 1; |
||
591 | } |
||
592 | include_once XOOPS_ROOT_PATH . '/modules/news/include/storyform.inc.php'; |
||
593 | break; |
||
594 | } |
||
595 | include_once XOOPS_ROOT_PATH . '/footer.php'; |
||
596 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.