Completed
Push — master ( 15a86c...ff0242 )
by Michael
03:23
created

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
// $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
ob_start();
28
include "header.php";
29
30 View Code Duplication
if(planet_parse_args($args_num, $args, $args_str)){
31
	$args["article"] = @$args_num[0];
32
	$args["type"] = @$args_str[0];
33
}
34
35
/* Specified Article */
36
$article_id = intval( empty($_GET["article"])?@$args["article"]:$_GET["article"] );
37
/* Specified Category */
38
$category_id = intval( empty($_GET["category"])?@$args["category"]:$_GET["category"] );
39
/* Specified Blog */
40
$blog_id = intval( empty($_GET["blog"])?@$args["blog"]:$_GET["blog"] );
41
/* Specified Bookmar(Favorite) UID */
42
$uid = intval( empty($_GET["uid"])?@$args["uid"]:$_GET["uid"] );
43
44
$type = empty($_GET["type"])?(empty($_GET["op"])?@$args["type"]:$_GET["op"]):$_GET["type"];
45
$type = strtoupper($type);
46
47
$valid_format = array("RSS0.91", "RSS1.0", "RSS2.0", "PIE0.1", "MBOX", "OPML", "ATOM", "ATOM0.3", "HTML", "JS");
48
if($type == "RDF") $type = "RSS1.0";
49
if($type == "RSS") $type = "RSS0.91";
50
if(empty($type) || !in_array($type, $valid_format)){
51
	planet_trackback_response(1, planet_constant("MD_INVALID"));
52
	exit();
53
}
54
55
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]);
56
$blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]);
57
$article_handler =& xoops_getmodulehandler("article", $GLOBALS["moddirname"]);
58
$bookmark_handler =& xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]);
59
60
if(!empty($article_id)) {
61
 	$article_obj =& $article_handler->get($article_id);
62
 	if(!$article_obj->getVar("art_id")){
63
		planet_trackback_response(1, planet_constant("MD_EXPIRED"));
64
		exit();
65
 	}
66
 	$source = "article";
67
}elseif(!empty($blog_id)) {
68
 	$blog_obj =& $blog_handler->get($blog_id);
69
 	if(!$blog_obj->getVar("blog_id")){
70
		planet_trackback_response(1, planet_constant("MD_INVALID"));
71
		exit();
72
 	}
73
	$source = "blog";
74
}elseif(!empty($category_id)) {
75
	$source = "category";
76
 	$category_obj =& $category_handler->get($category_id);
77
 	if(!$category_obj->getVar("cat_id")){
78
		planet_trackback_response(1, planet_constant("MD_INVALID"));
79
		exit();
80
 	}
81
}elseif(!empty($uid)) {
82
	$source = "bookmark";
83
}
84
else $source = "";
85
86
$xml_charset = "UTF-8";
87
include_once XOOPS_ROOT_PATH.'/class/template.php';
88
$tpl = new XoopsTpl();
89
$tpl->xoops_setCaching(2);
90
$tpl->xoops_setCacheTime(3600);
91
$xoopsCachedTemplateId = md5($xoopsModule->getVar("mid").",".$article_id.",".$category_id.",".$blog_id.",".$uid.",".$type);
92
if (!$tpl->is_cached('db:system_dummy.html', $xoopsCachedTemplateId)) {
93
94
$criteria = new CriteriaCompo();
95
$criteria->setLimit($xoopsModuleConfig["articles_perpage"]);
96
$articles_obj = array();
97
switch($source){
98
	case "article":
99
		$pagetitle = planet_constant("MD_ARTICLE");
100
		$rssdesc = planet_constant("MD_XMLDESC_ARTICLE");
101
		
102
		$articles_obj[$article_id] =& $article_obj;
103
		
104
		$xml_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php".URL_DELIMITER."".$article_obj->getVar("art_id");
105
		break;
106
107 View Code Duplication
	case "category":
108
		$pagetitle = planet_constant("MD_CATEGORY");
109
		$rssdesc = sprintf(planet_constant("MD_XMLDESC_CATEGORY"), $category_obj->getVar("cat_title"));
110
111
		$criteria->add(new Criteria("bc.cat_id", $category_id));
112
		$articles_obj =& $article_handler->getByCategory($criteria);
113
		
114
		$xml_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php".URL_DELIMITER."c".$category_id;
115
		break;
116
117 View Code Duplication
	case "blog":
118
		$pagetitle = planet_constant("MD_BLOG");
119
		$rssdesc = sprintf(planet_constant("MD_XMLDESC_BLOG"), $blog_obj->getVar("blog_title"));
120
121
		$criteria->add(new Criteria("blog_id", $blog_id));
122
		$articles_obj =& $article_handler->getAll($criteria);		
123
124
		$xml_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php".URL_DELIMITER."b".$blog_id;
125
		break;
126
127 View Code Duplication
	case "bookmark":
128
		$author_name = XoopsUser::getUnameFromId($uid);
129
		$pagetitle = planet_constant("MD_BOOKMARKS");
130
		$rssdesc = sprintf(planet_constant("MD_XMLDESC_BOOKMARK"), $author_name);
131
132
		$criteria->add(new Criteria("bm.bm_uid", $uid));
133
		$articles_obj =& $article_handler->getByBookmark($criteria);
134
		
135
		$xml_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php".URL_DELIMITER."u".$uid;
136
		
137
		break;
138
139
	default:
140
		$pagetitle = planet_constant("MD_INDEX");
141
		$rssdesc = planet_constant("MD_XMLDESC_INDEX");
142
143
		$articles_obj =& $article_handler->getAll($criteria);
144
145
		$xml_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php";
146
		break;
147
}
148
$items = array();
149
foreach(array_keys($articles_obj) as $id){
150
	$content = $articles_obj[$id]->getVar("art_content");
151
	$content .= "<br />".planet_constant("MD_SOURCE").": ".$articles_obj[$id]->getVar("art_link")." ".$articles_obj[$id]->getVar("art_author");
152
	$items[] = array(
153
		"title" => $articles_obj[$id]->getVar("art_title"),
154
	    "link" => XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php".URL_DELIMITER."".$articles_obj[$id]->getVar("art_id"),
155
	    "description" => $content,
156
	    "descriptionHtmlSyndicated" => true,
157
	    "date" => $articles_obj[$id]->getTime("rss"),
158
	    "source" => XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/",
159
	    "author" => $articles_obj[$id]->getVar("art_author")
160
	    );
161
}
162
unset($articles_obj, $criteria);
163
164
$xml_handler =& xoops_getmodulehandler("xml", $GLOBALS["moddirname"]);
165
$xml = $xml_handler->create($type);
166
$xml->setVar("encoding", $xml_charset);
167
$xml->setVar("title", $xoopsConfig["sitename"]." :: ".$pagetitle, "UTF-8", $xml_charset, true);
168
$xml->setVar("description", $rssdesc, true);
169
$xml->setVar("descriptionHtmlSyndicated", true);
170
$xml->setVar("link", $xml_link);
171
$xml->setVar("syndicationURL", XOOPS_URL."/".xoops_getenv("PHP_SELF"));
172
$xml->setVar("webmaster", checkEmail($xoopsConfig["adminmail"], true));
173
$xml->setVar("editor", checkEmail($xoopsConfig["adminmail"], true));
174
$xml->setVar("category", $xoopsModule->getVar("name"), true);
175
$xml->setVar("generator", $xoopsModule->getInfo("version"));
176
$xml->setVar("language", _LANGCODE);
177
178
$dimention = @getimagesize(XOOPS_ROOT_PATH."/modules/".$GLOBALS["moddirname"]."/".$xoopsModule->getInfo("image"));
179
$image = array(
180
	"width" => $dimention[0],
181
	"height" => $dimention[1],
182
	"title" => $xoopsConfig["sitename"]." :: ".$pagetitle,
183
	"url" => XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/".$xoopsModule->getInfo("image"),
184
	"link" => XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/",
185
	"description" => $rssdesc
186
	);
187
$xml->setImage($image);
188
189
/*
190
$item = array(
191
	"title" => $datatitle,
192
    "link" => $dataurl,
193
    "description" => $datadesc,
194
    "descriptionHtmlSyndicated" => true,
195
    "date" => $datadate,
196
    "source" => $datasource,
197
    "author" => $dataauthor
198
    );
199
*/
200
$xml->addItems($items);
201
202
$dummy_content = $xml_handler->display($xml, XOOPS_CACHE_PATH."/".$GLOBALS["moddirname"].".xml.tmp");
203
204
$tpl->assign_by_ref('dummy_content', $dummy_content);
205
}
206
//$content = ob_get_contents();
207
ob_end_clean();
208
header('Content-Type:text/xml; charset='.$xml_charset);
209
$tpl->display('db:system_dummy.html', $xoopsCachedTemplateId);
210
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

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.

Loading history...