Completed
Push — master ( b610c1...53db9c )
by Michael
03:25 queued 01:39
created

submit.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package
16
 * @since
17
 * @author         XOOPS Development Team
18
 */
19
20
//defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

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.

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