These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // $Id$ |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // This program is free software; you can redistribute it and/or modify // |
||
5 | // it under the terms of the GNU General Public License as published by // |
||
6 | // the Free Software Foundation; either version 2 of the License, or // |
||
7 | // (at your option) any later version. // |
||
8 | // // |
||
9 | // You may not change or alter any portion of this comment or credits // |
||
10 | // of supporting developers from this source code or any supporting // |
||
11 | // source code which is considered copyrighted (c) material of the // |
||
12 | // original comment or credit authors. // |
||
13 | // // |
||
14 | // This program is distributed in the hope that it will be useful, // |
||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
17 | // GNU General Public License for more details. // |
||
18 | // // |
||
19 | // You should have received a copy of the GNU General Public License // |
||
20 | // along with this program; if not, write to the Free Software // |
||
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
22 | // ------------------------------------------------------------------------ // |
||
23 | // Author: phppp (D.J., [email protected]) // |
||
24 | // URL: http://xoops.org // |
||
25 | // Project: Article Project // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | |||
28 | include "header.php"; |
||
29 | |||
30 | $op = !empty($_POST["op"])?$_POST["op"]:(!empty($_GET["op"])?$_GET["op"]:""); |
||
31 | $blog_id = !empty($_POST["blog"])?$_POST["blog"]:(!empty($_GET["blog"])?$_GET["blog"]:0); |
||
32 | $blog_id = is_array($blog_id)?array_map("intval", $blog_id):intval($blog_id); |
||
33 | |||
34 | if(empty($xoopsModuleConfig["newblog_submit"]) && (!is_object($xoopsUser) || !$xoopsUser->isAdmin())){ |
||
35 | redirect_header("index.php", 2, _NOPERM); |
||
36 | } |
||
37 | |||
38 | if($op=="save" && !empty($_POST["fetch"])){ |
||
39 | $op="edit"; |
||
40 | } |
||
41 | |||
42 | if($op=="save" && !$GLOBALS['xoopsSecurity']->check()){ |
||
43 | redirect_header("javascript:history.go(-1);", 1, planet_constant("MD_INVALID").": security check failed"); |
||
44 | exit(); |
||
45 | } |
||
46 | include XOOPS_ROOT_PATH."/header.php"; |
||
47 | include XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php"; |
||
48 | |||
49 | $blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
||
50 | $category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]); |
||
51 | |||
52 | switch($op){ |
||
53 | /* save a single blog */ |
||
54 | case "save": |
||
55 | |||
56 | if ($blog_id) { |
||
57 | $blog_obj =& $blog_handler->get($blog_id); |
||
58 | if($xoopsUser->isAdmin()){ |
||
59 | $blog_obj->setVar('blog_status', @$_POST["blog_status"]); |
||
60 | } |
||
61 | } else { |
||
62 | if($blog_exists = $blog_handler->getCount(new Criteria("blog_feed", $myts->addSlashes( trim($_POST['blog_feed']) )))){ |
||
63 | redirect_header("index.php", 2, planet_constant("MD_BLOGEXISTS")); |
||
64 | exit(); |
||
65 | } |
||
66 | |||
67 | $blog_obj =& $blog_handler->create(); |
||
68 | $blog_obj->setVar('blog_submitter', is_object($xoopsUser)?$xoopsUser->getVar("uid"):planet_getIP(true)); |
||
69 | |||
70 | switch($xoopsModuleConfig["newblog_submit"]){ |
||
71 | case 2: |
||
72 | if(!is_object($xoopsUser)){ |
||
73 | $status = 0; |
||
74 | }else{ |
||
75 | $status = 1; |
||
76 | } |
||
77 | break; |
||
78 | case 0: |
||
79 | case 3: |
||
80 | $status = 1; |
||
81 | break; |
||
82 | case 1: |
||
83 | default: |
||
84 | if(!is_object($xoopsUser) || !$xoopsUser->isAdmin()){ |
||
85 | $status = 0; |
||
86 | }else{ |
||
87 | $status = 1; |
||
88 | } |
||
89 | break; |
||
90 | } |
||
91 | |||
92 | $blog_obj->setVar('blog_status', $status); |
||
93 | } |
||
94 | |||
95 | $blog_obj->setVar('blog_title', $_POST['blog_title']); |
||
96 | $blog_obj->setVar('blog_desc', $_POST['blog_desc']); |
||
97 | $blog_obj->setVar('blog_image', $_POST['blog_image']); |
||
98 | $blog_obj->setVar('blog_feed', $_POST['blog_feed']); |
||
99 | $blog_obj->setVar('blog_link', $_POST['blog_link']); |
||
100 | $blog_obj->setVar('blog_language', $_POST['blog_language']); |
||
101 | $blog_obj->setVar('blog_charset', $_POST['blog_charset']); |
||
102 | $blog_obj->setVar('blog_trackback', $_POST['blog_trackback']); |
||
103 | if($blog_obj->isNew()){ |
||
104 | $blog_obj->setVar('blog_submitter', is_object($xoopsUser)?$xoopsUser->getVar("uid"):planet_getIP(true)); |
||
105 | } |
||
106 | |||
107 | View Code Duplication | if (!$blog_handler->insert($blog_obj)) { |
|
108 | }elseif(!empty($_POST["categories"])){ |
||
109 | $blog_id = $blog_obj->getVar("blog_id"); |
||
110 | if(in_array(0, $_POST["categories"])) $_POST["categories"] = array(); |
||
111 | $blog_handler->setCategories($blog_id, $_POST["categories"]); |
||
112 | } |
||
113 | $message = planet_constant("MD_DBUPDATED"); |
||
114 | redirect_header("index.php".URL_DELIMITER."b".$blog_id, 2, $message); |
||
115 | exit(); |
||
116 | |||
117 | /* edit a single blog */ |
||
118 | case "edit": |
||
119 | default: |
||
120 | View Code Duplication | if(!empty($_POST["fetch"])){ |
|
121 | $blog_obj =& $blog_handler->fetch($_POST["blog_feed"]); |
||
122 | $blog_obj->setVar("blog_id", $blog_id); |
||
123 | }else{ |
||
124 | $blog_obj =& $blog_handler->get($blog_id); |
||
125 | } |
||
126 | $categories = isset($_POST["categories"])?$_POST["categories"]:array(); |
||
127 | if(in_array("-1", $categories)) $categories = array(); |
||
128 | View Code Duplication | if(empty($categories) && $blog_id>0){ |
|
129 | $crit = new Criteria("bc.blog_id", $blog_id); |
||
130 | $categories = array_keys($category_handler->getByBlog($crit)); |
||
131 | } |
||
132 | if(empty($categories)) $categories = array(0=>_NONE); |
||
133 | |||
134 | echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . "</legend>"; |
||
135 | echo"<br />"; |
||
136 | View Code Duplication | if(empty($blog_id) && $blog_obj->getVar("blog_feed")){ |
|
137 | $criteria = new Criteria("blog_feed", $blog_obj->getVar("blog_feed")); |
||
138 | $blogs_obj =& $blog_handler->getList($criteria); |
||
139 | if(count($blogs_obj)>0){ |
||
140 | echo "<div class=\"errorMsg\">".planet_constant("MD_BLOGEXISTS"); |
||
141 | foreach(array_keys($blogs_obj) as $bid){ |
||
142 | echo "<br /><a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php".URL_DELIMITER."b".$bid."\" target=\"_blank\">".$blogs_obj[$bid]."</a>"; |
||
143 | } |
||
144 | echo "</div>"; |
||
145 | unset($blogs_obj, $criteria); |
||
146 | } |
||
147 | } |
||
148 | include XOOPS_ROOT_PATH."/modules/".$GLOBALS["moddirname"]."/include/form.blog.php"; |
||
149 | echo "</fieldset>"; |
||
150 | break; |
||
151 | } |
||
152 | |||
153 | include XOOPS_ROOT_PATH."/footer.php"; |
||
154 | ?> |
||
0 ignored issues
–
show
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.