1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Request;
13:
14: 15: 16: 17: 18: 19: 20: 21:
22:
23: include __DIR__ . '/mainfile.php';
24:
25: $xoops = Xoops::getInstance();
26: $xoops->isAdminSide = true;
27: include_once $xoops->path('include/cp_functions.php');
28:
29: $xbc = \XoopsBaseConfig::getInstance();
30:
31: 32: 33:
34: if ($xoops->isUser()) {
35: if (!$xoops->user->isAdmin(-1)) {
36: $xoops->redirect('index.php', 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
37: exit();
38: }
39: } else {
40: $xoops->redirect('index.php', 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
41: exit();
42: }
43:
44: $xoops->header();
45:
46: 47: 48:
49: if ($xoops->getConfig('admin_warnings_enable')) {
50: $error_msg = array();
51:
52: $install_dir = $xoops->path('install');
53: if (is_dir($install_dir)) {
54: $error_msg[] = sprintf(XoopsLocale::EF_DIRECTORY_EXISTS, $install_dir);
55: }
56:
57: $mainfile = $xoops->path('www/mainfile.php');
58: if (is_writable($mainfile)) {
59: $error_msg[] = sprintf(XoopsLocale::EF_FILE_IS_WRITABLE, $mainfile);
60: }
61:
62: $cache_path = $xoops->path('var/caches');
63: if (!is_writable($cache_path)) {
64: $error_msg[] = sprintf(XoopsLocale::EF_FOLDER_NOT_WRITABLE, $cache_path);
65: }
66: $upload_path = $xoops->path('uploads');
67: if (!is_writable($upload_path)) {
68: $error_msg[] = sprintf(XoopsLocale::EF_FOLDER_NOT_WRITABLE, $upload_path);
69: }
70: $compile_path = $xbc->get('smarty-compile');
71: if (!is_writable($compile_path)) {
72: $error_msg[] = sprintf(XoopsLocale::EF_FOLDER_NOT_WRITABLE, $compile_path);
73: }
74:
75:
76: $xoops_path = $xbc->get('lib-path');
77: $xoops_root_path = $xbc->get('root-path');
78: if (strpos($xoops_path, $xoops_root_path) !== false || strpos($xoops_path, $_SERVER['DOCUMENT_ROOT']) !== false) {
79: $error_msg[] = sprintf(XoopsLocale::EF_FOLDER_IS_INSIDE_DOCUMENT_ROOT, $xoops_path);
80: }
81:
82: $var_path = $xoops->path('var');
83: if (strpos($var_path, $xoops_root_path) !== false || strpos($var_path, $_SERVER['DOCUMENT_ROOT']) !== false) {
84: $error_msg[] = sprintf(XoopsLocale::EF_FOLDER_IS_INSIDE_DOCUMENT_ROOT, $var_path);
85: }
86: $xoops->tpl()->assign('error_msg', $error_msg);
87: }
88:
89: $xoopsorgnews = Request::getString('xoopsorgnews', null, 'GET');
90: if (!empty($xoopsorgnews)) {
91:
92: $myts = \Xoops\Core\Text\Sanitizer::getInstance();
93: $rssurl = array();
94: $rssurl[] = 'http://sourceforge.net/export/rss2_projnews.php?group_id=41586&rss_fulltext=1';
95: $rssurl[] = 'http://www.xoops.org/backend.php';
96: $rssurl = array_unique(array_merge($rssurl, XoopsLocale::getAdminRssUrls()));
97: $rssfile = 'admin/rss/adminnews-' . $xoops->getConfig('locale');
98:
99: $items = $xoops->cache()->cacheRead($rssfile, 'buildRssFeedCache', 24*60*60, $rssurl);
100:
101: if ($items != '') {
102: $ret = '<table class="outer width100">';
103: foreach (array_keys($items) as $i) {
104: $ret .= '<tr class="head"><td><a href="' . htmlspecialchars($items[$i]['link']) . '" rel="external">';
105: $ret .= htmlspecialchars($items[$i]['title']) . '</a> (' . htmlspecialchars($items[$i]['pubdate']) . ')</td></tr>';
106: if ($items[$i]['description'] != "") {
107: $ret .= '<tr><td class="odd">' . $items[$i]['description'];
108: if (!empty($items[$i]['guid'])) {
109: $ret .= ' <a href="' . htmlspecialchars($items[$i]['guid']) . '" rel="external" title="">' . XoopsLocale::MORE . '</a>';
110: }
111: $ret .= '</td></tr>';
112: } else {
113: if ($items[$i]['guid'] != "") {
114: $ret .= '<tr><td class="even aligntop"></td><td colspan="2" class="odd"><a href="' . htmlspecialchars($items[$i]['guid']) . '" rel="external">' . _MORE . '</a></td></tr>';
115: }
116: }
117: }
118: $ret .= '</table>';
119: echo $ret;
120: }
121: }
122: $xoops->footer();
123:
124: function buildRssFeedCache($rssurl)
125: {
126: $snoopy = new Snoopy();
127: $cnt = 0;
128: foreach ($rssurl as $url) {
129: if ($snoopy->fetch($url)) {
130: $rssdata = $snoopy->results;
131: $rss2parser = new XoopsXmlRss2Parser($rssdata);
132: if (false != $rss2parser->parse()) {
133: $_items = $rss2parser->getItems();
134: $count = count($_items);
135: for ($i = 0; $i < $count; $i++) {
136:
137:
138: $items[(string)(strtotime($_items[$i]['pubdate'])) . "-" . (string)(++$cnt)] = $_items[$i];
139: }
140: } else {
141: echo $rss2parser->getErrors();
142: }
143: }
144: }
145: krsort($items);
146: return $items;
147: }
148: