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 | include "header.php"; |
||
28 | |||
29 | if(preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)){ |
||
30 | include XOOPS_ROOT_PATH.'/include/notification_update.php'; |
||
31 | exit(); |
||
32 | } |
||
33 | |||
34 | View Code Duplication | if($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)){ |
|
35 | $args["start"] = @$args_num[0]; |
||
36 | $args["sort"] = @$args_str[0]; |
||
37 | } |
||
38 | |||
39 | /* Start */ |
||
40 | $start = intval( empty($_GET["start"])?@$args["start"]:$_GET["start"] ); |
||
41 | /* Specified Category */ |
||
42 | $category_id = intval( empty($_GET["category"])?@$args["category"]:$_GET["category"] ); |
||
43 | /* Specified Bookmar(Favorite) UID */ |
||
44 | $uid = intval( empty($_GET["uid"])?@$args["uid"]:$_GET["uid"] ); |
||
45 | /* Sort by term */ |
||
46 | $sort = empty($_GET["sort"])?@$args["sort"]:$_GET["sort"]; |
||
47 | /* Display as list */ |
||
48 | $list = intval( empty($_GET["list"])?@$args["list"]:$_GET["list"] ); |
||
49 | /* |
||
50 | // restore $_SERVER['REQUEST_URI'] |
||
51 | if(!empty($REQUEST_URI_parsed)){ |
||
52 | $args_REQUEST_URI = array(); |
||
53 | $_args =array("start", "sort", "uid", "list"); |
||
54 | foreach($_args as $arg){ |
||
55 | if(!empty(${$arg})){ |
||
56 | $args_REQUEST_URI[] = $arg ."=". ${$arg}; |
||
57 | } |
||
58 | } |
||
59 | if(!empty($category_id)){ |
||
60 | $args_REQUEST_URI[] = "category=". $category_id; |
||
61 | } |
||
62 | $_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php". |
||
63 | (empty($args_REQUEST_URI)?"":"?".implode("&",$args_REQUEST_URI)); |
||
64 | } |
||
65 | */ |
||
66 | |||
67 | $xoopsOption["xoops_pagetitle"] = $xoopsModule->getVar("name"). " - " . planet_constant("MD_BLOGS"); |
||
68 | $xoopsOption["template_main"] = planet_getTemplate("blogs"); |
||
69 | include_once( XOOPS_ROOT_PATH . "/header.php" ); |
||
70 | include XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php"; |
||
71 | |||
72 | // Following part will not be executed after cache |
||
73 | $category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]); |
||
74 | $blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
||
75 | |||
76 | $limit = empty($list)? $xoopsModuleConfig["articles_perpage"] : $xoopsModuleConfig["list_perpage"]; |
||
77 | |||
78 | $query_type = ""; |
||
79 | $criteria = new CriteriaCompo(); |
||
80 | $blog_prefix = ""; |
||
81 | /* Specific category */ |
||
82 | View Code Duplication | if($category_id >0){ |
|
83 | $category_obj = $category_handler->get($category_id); |
||
84 | $criteria->add(new Criteria("bc.cat_id", $category_id)); |
||
85 | $uid = 0; |
||
86 | $blog_id = 0; |
||
87 | $category_data = array( "id" => $category_id, "title" => $category_obj->getVar("cat_title") ); |
||
88 | $query_type = "category"; |
||
89 | $blog_prefix = "b."; |
||
90 | } |
||
91 | |||
92 | /* User bookmarks(favorites) */ |
||
93 | View Code Duplication | if($uid >0){ |
|
94 | $criteria->add(new Criteria("bm.bm_uid", $uid)); |
||
95 | $category_id = 0; |
||
96 | $blog_id = 0; |
||
97 | $bookmark_handler =& xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]); |
||
98 | $user_data = array( |
||
99 | "uid" => $uid, |
||
100 | "name" => XoopsUser::getUnameFromID($uid), |
||
101 | "marks" => $bookmark_handler->getCount(new Criteria("bm_uid", $uid)) |
||
102 | ); |
||
103 | $query_type = "bookmark"; |
||
104 | $blog_prefix = "b."; |
||
105 | } |
||
106 | |||
107 | $criteria->add(new Criteria($blog_prefix."blog_status", 0, ">")); |
||
108 | |||
109 | /* Sort */ |
||
110 | $order = "DESC"; |
||
111 | $sort = empty($sort) ? "default" : $sort; |
||
112 | switch($sort){ |
||
113 | case "marks": |
||
114 | $sortby = $blog_prefix."blog_marks"; |
||
115 | break; |
||
116 | case "rating": |
||
117 | $sortby = $blog_prefix."blog_rating"; |
||
118 | break; |
||
119 | case "time": |
||
120 | $sortby = $blog_prefix."blog_time"; |
||
121 | break; |
||
122 | case "default": |
||
123 | default: |
||
124 | $sort = "default"; |
||
125 | $sortby = $blog_prefix."blog_id"; |
||
126 | break; |
||
127 | } |
||
128 | $criteria->setSort($sortby); |
||
129 | $criteria->setOrder($order); |
||
130 | $criteria->setStart($start); |
||
131 | $criteria->setLimit($limit); |
||
132 | |||
133 | $tags = empty($list) ? "" : array($blog_prefix."blog_title", $blog_prefix."blog_time"); |
||
134 | View Code Duplication | switch($query_type){ |
|
135 | case "category": |
||
136 | $blogs_obj =& $blog_handler->getByCategory($criteria, $tags); |
||
137 | $count_blog = $blog_handler->getCountByCategory($criteria); |
||
138 | break; |
||
139 | case "bookmark": |
||
140 | $blogs_obj =& $blog_handler->getByBookmark($criteria, $tags); |
||
141 | $count_blog = $blog_handler->getCountByBookmark($criteria); |
||
142 | break; |
||
143 | default: |
||
144 | $blogs_obj =& $blog_handler->getAll($criteria, $tags); |
||
145 | $count_blog = $blog_handler->getCount($criteria); |
||
146 | break; |
||
147 | } |
||
148 | |||
149 | /* Objects to array */ |
||
150 | $blogs = array(); |
||
151 | foreach (array_keys($blogs_obj) as $id) { |
||
152 | $_blog = array( |
||
153 | "id" => $id, |
||
154 | "title" => $blogs_obj[$id]->getVar("blog_title"), |
||
155 | "time" => $blogs_obj[$id]->getTime() |
||
156 | ); |
||
157 | if(empty($list)){ |
||
158 | $_blog = array_merge($_blog, array( |
||
159 | "image" => $blogs_obj[$id]->getImage(), |
||
160 | "feed" => $blogs_obj[$id]->getVar("blog_feed"), |
||
161 | "link" => $blogs_obj[$id]->getVar("blog_link"), |
||
162 | "desc" => $blogs_obj[$id]->getVar("blog_desc"), |
||
163 | "star" => $blogs_obj[$id]->getStar(), |
||
164 | "rates" => $blogs_obj[$id]->getVar("blog_rates"), |
||
165 | "marks" => $blogs_obj[$id]->getVar("blog_marks") |
||
166 | ) |
||
167 | ); |
||
168 | } |
||
169 | $blogs[] = $_blog; |
||
170 | unset($_blog); |
||
171 | } |
||
172 | unset($blogs_obj); |
||
173 | |||
174 | if ( $count_blog > $limit) { |
||
175 | include(XOOPS_ROOT_PATH."/class/pagenav.php"); |
||
176 | $start_link = array(); |
||
177 | if($sort) $start_link[] = "sort=".$sort; |
||
178 | if($category_id) $start_link[] = "category=".$category_id; |
||
179 | if($list) $start_link[] = "list=".$list; |
||
180 | $nav = new XoopsPageNav($count_blog, $limit, $start, "start", implode("&", $start_link)); |
||
181 | $pagenav = $nav->renderNav(4); |
||
182 | } else { |
||
183 | $pagenav = ""; |
||
184 | } |
||
185 | |||
186 | $xoopsTpl -> assign("xoops_pagetitle", $xoopsOption["xoops_pagetitle"] ); |
||
187 | $xoopsTpl -> assign("link_home", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php\" title=\"".planet_constant("MD_HOME")."\" target=\"_self\">".planet_constant("MD_HOME")."</a>"); |
||
188 | |||
189 | if($category_id || $uid){ |
||
190 | $xoopsTpl -> assign("link_index", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php\" title=\"".planet_constant("MD_INDEX")."\" target=\"_self\">".planet_constant("MD_INDEX")."</a>"); |
||
191 | |||
192 | $link_articles = "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php". |
||
193 | (empty($category_id)?"":"/c".$category_id). |
||
194 | (empty($uid)?"":"/u".$uid). |
||
195 | "\" title=\"".planet_constant("MD_ARTICLES")."\">".planet_constant("MD_ARTICLES")."</a>"; |
||
196 | $xoopsTpl -> assign("link_articles", $link_articles); |
||
197 | } |
||
198 | |||
199 | $link_switch = "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php". |
||
200 | (empty($category_id)?"":"/c".$category_id). |
||
201 | (empty($uid)?"":"/u".$uid). |
||
202 | (empty($list)?"/l1":""). |
||
203 | "\" title=\"".(empty($list)?planet_constant("MD_LISTVIEW"):planet_constant("MD_FULLVIEW"))."\">".(empty($list)?planet_constant("MD_LISTVIEW"):planet_constant("MD_FULLVIEW"))."</a>"; |
||
204 | $xoopsTpl -> assign("link_switch", $link_switch); |
||
205 | |||
206 | View Code Duplication | if(empty($uid) && is_object($xoopsUser)){ |
|
207 | $xoopsTpl -> assign("link_bookmark", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php".URL_DELIMITER."u".$xoopsUser->getVar("uid")."\" title=\"".planet_constant("MD_BOOKMARKS")."\" target=\"_self\">".planet_constant("MD_BOOKMARKS")."</a>"); |
||
208 | } |
||
209 | |||
210 | View Code Duplication | if($xoopsModuleConfig["newblog_submit"]==1 || is_object($xoopsUser)){ |
|
211 | $xoopsTpl -> assign("link_submit", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/action.blog.php\" title=\""._SUBMIT."\" target=\"_blank\">"._SUBMIT."</a>"); |
||
212 | } |
||
213 | |||
214 | $xoopsTpl -> assign("pagetitle", $xoopsModule->getVar("name")."::".planet_constant("MD_BLOGS")); |
||
215 | $xoopsTpl -> assign("category", @$category_data); |
||
216 | $xoopsTpl -> assign("user", @$user_data); |
||
217 | $xoopsTpl -> assign("blogs", $blogs); |
||
218 | $xoopsTpl -> assign("pagenav", $pagenav); |
||
219 | $xoopsTpl -> assign("count_blog", $count_blog); |
||
220 | $xoopsTpl -> assign("is_list", !empty($list)); |
||
221 | |||
222 | $xoopsTpl -> assign("user_level", !is_object($xoopsUser)?0:($xoopsUser->isAdmin()?2:1)); |
||
223 | View Code Duplication | if(empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)){ |
|
224 | }elseif(!$list){ |
||
225 | $xoopsTpl -> assign("canrate", 1); |
||
226 | } |
||
227 | |||
228 | $sort_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php" . URL_DELIMITER; |
||
229 | $vars = array(); |
||
230 | if(!empty($category_id)) $vars[] = "c".$category_id; |
||
231 | if(!empty($uid)) $vars[] = "u".$uid; |
||
232 | if(!empty($list)) $vars[] = "li"; |
||
233 | if(!empty($vars)) $sort_link .= implode("/", $vars)."/"; |
||
234 | $sortlinks = array(); |
||
235 | $valid_sorts = array( "marks" => planet_constant("MD_BOOKMARKS"), "rating" => planet_constant("MD_RATING"), "time" => planet_constant("MD_TIME"), "default" => planet_constant("MD_DEFAULT") ); |
||
236 | View Code Duplication | foreach($valid_sorts as $val => $name){ |
|
237 | if($val == $sort) continue; |
||
238 | $sortlinks[] = "<a href=\"".$sort_link. $val."\">".$name."</a>"; |
||
239 | } |
||
240 | $xoopsTpl -> assign("link_sort", implode(" | ", $sortlinks)); |
||
241 | |||
242 | include_once "footer.php"; |
||
243 | ?> |
||
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.