XOOPS  2.6.0
admin.php
Go to the documentation of this file.
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 
13 
23 include __DIR__ . '/mainfile.php';
24 
26 $xoops->isAdminSide = true;
27 include_once $xoops->path('include/cp_functions.php');
28 
30 
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 // ###### Output warn messages for security ######
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  // ###### Output warn messages for correct functionality ######
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  //www fits inside www_private, lets add a trailing slash to make sure it doesn't
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  // Multiple feeds
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 .= '&nbsp;&nbsp;<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  $_items[$i]['title'] = XoopsLocale::convert_encoding($_items[$i]['title'], XoopsLocale::getCharset(), 'UTF-8');
137  $_items[$i]['description'] = XoopsLocale::convert_encoding($_items[$i]['description'], XoopsLocale::getCharset(), 'UTF-8');
138  $items[strval(strtotime($_items[$i]['pubdate'])) . "-" . strval(++$cnt)] = $_items[$i];
139  }
140  } else {
141  echo $rss2parser->getErrors();
142  }
143  }
144  }
145  krsort($items);
146  return $items;
147 }
if($xoops->getConfig('admin_warnings_enable')) $xoopsorgnews
Definition: admin.php:89
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
$_SERVER['REQUEST_URI']
const EF_DIRECTORY_EXISTS
Definition: en_US.php:232
if(!function_exists('xoopseditor_get_rootpath')) $mainfile
exit
Definition: browse.php:104
buildRssFeedCache($rssurl)
Definition: admin.php:124
const EF_FOLDER_NOT_WRITABLE
Definition: en_US.php:253
$xoops
Definition: admin.php:25
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
Definition: config.php:7
static convert_encoding($text, $to= 'utf-8', $from= '')
Definition: Abstract.php:235
const EF_FILE_IS_WRITABLE
Definition: en_US.php:242
const E_NO_ACCESS_PERMISSION
Definition: en_US.php:351
static getAdminRssUrls()
Definition: Abstract.php:124
$url
Definition: register.php:72
$xbc
Definition: admin.php:29
$myts
Definition: edituser.php:38
static getInstance($config= '')
const EF_FOLDER_IS_INSIDE_DOCUMENT_ROOT
Definition: en_US.php:251