PageRenderTime 66ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/e107_core/shortcodes/batch/admin_shortcodes.php

https://github.com/CasperGemini/e107
PHP | 1770 lines | 1336 code | 287 blank | 147 comment | 219 complexity | f40c55ab35281465359aae6813d421a6 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
  4. *
  5. * Admin shortcode batch - class
  6. */
  7. /**
  8. * @package e107
  9. * @subpackage shortcodes
  10. *
  11. * Shortcodes for admin items
  12. */
  13. if (!defined('e107_INIT')) { exit; }
  14. class admin_shortcodes
  15. {
  16. function cronUpdateRender($parm,$cacheData)
  17. {
  18. $mes = e107::getMessage();
  19. if($cacheData == 'up-to-date')
  20. {
  21. return '';
  22. }
  23. $installUrl = "#"; // TODO
  24. if($parm=='alert')
  25. {
  26. $text = 'A new update is ready to install! Click to unzip and install v'.$cacheData.'</a>.
  27. <a class="btn btn-success" href="'.$installUrl.'">Install</a>';
  28. $mes->addInfo($text);
  29. return; // $mes->render();
  30. }
  31. if($parm=='icon')
  32. {
  33. return '<ul class="nav pill">
  34. <li class="dropdown">
  35. <a class="dropdown-toggle" title="Messages" role="button" data-toggle="dropdown" href="#">
  36. '.E_16_E107.' <b class="caret"></b>
  37. </a>
  38. <ul class="dropdown-menu" role="menu">
  39. <li class="nav-header">Update Available</li>
  40. <li><a href="'.$installUrl.'">e107 v'.$cacheData.'</a></li>
  41. </ul>
  42. </li>
  43. </ul>
  44. ';
  45. }
  46. }
  47. // {ADMIN_COREUPDATE}
  48. function sc_admin_coreupdate($parm='')
  49. {
  50. $che = e107::getCache();
  51. $mes = e107::getMessage();
  52. $che->setMD5(e_LANGUAGE);
  53. $cacheData = $che->retrieve("releasecheck",3600, TRUE); // 2.0.1 | 'up-to-date' | false ;
  54. $cacheData = 2.1; // XXX Remove to test for real.
  55. return false; // XXX Remove to test for real.
  56. if($cacheData)
  57. {
  58. return $this->cronUpdateRender($parm, $cacheData);
  59. }
  60. require_once(e_HANDLER."cron_class.php");
  61. $cron = new _system_cron();
  62. if($result = $cron->checkCoreUpdate())
  63. {
  64. return $this->cronUpdateRender($parm, $cacheData);
  65. }
  66. }
  67. function sc_admin_credits()
  68. {
  69. if (!ADMIN) { return ''; }
  70. return "
  71. <div style='text-align: center'>
  72. <input class='btn btn-default button' type='button' onclick=\"javascript: window.open('".e_ADMIN_ABS."credits.php', 'myWindow', 'status = 1, height = 400, width = 300, resizable = 0')\" value='".LAN_CREDITS."' />
  73. </div>";
  74. }
  75. function sc_admin_docs()
  76. {
  77. if (!ADMIN) { return ''; }
  78. global $ns;
  79. $i=1;
  80. if (!$handle=opendir(e_DOCS.e_LANGUAGE.'/'))
  81. {
  82. $handle=opendir(e_DOCS.'English/');
  83. }
  84. while ($file = readdir($handle))
  85. {
  86. if($file != '.' && $file != '..' && $file != 'CVS')
  87. {
  88. $helplist[$i] = $file;
  89. $i++;
  90. }
  91. }
  92. closedir($handle);
  93. unset($e107_var);
  94. foreach ($helplist as $key => $value)
  95. {
  96. $e107_var['x'.$key]['text'] = str_replace('_', ' ', $value);
  97. $e107_var['x'.$key]['link'] = e_ADMIN.'docs.php?'.$key;
  98. }
  99. $text = show_admin_menu(FOOTLAN_14, $act, $e107_var, FALSE, TRUE, TRUE);
  100. return $ns -> tablerender(FOOTLAN_14,$text, array('id' => 'admin_docs', 'style' => 'button_menu'), TRUE);
  101. }
  102. function sc_admin_help()
  103. {
  104. if (!ADMIN) { return ''; }
  105. $ns = e107::getRender();
  106. $pref = e107::getPref();
  107. if(function_exists('e_help') && ($tmp = e_help())) // new in v2.x for non-admin-ui admin pages.
  108. {
  109. return $ns->tablerender($tmp['caption'],$tmp['text'],'e_help',true);
  110. }
  111. $helpfile = '';
  112. if(strpos(e_SELF, e_ADMIN_ABS) !== FALSE)
  113. {
  114. if (is_readable(e_LANGUAGEDIR.e_LANGUAGE.'/admin/help/'.e_PAGE))
  115. {
  116. $helpfile = e_LANGUAGEDIR.e_LANGUAGE.'/admin/help/'.e_PAGE;
  117. }
  118. elseif (is_readable(e_LANGUAGEDIR.'English/admin/help/'.e_PAGE))
  119. {
  120. $helpfile = e_LANGUAGEDIR.'English/admin/help/'.e_PAGE;
  121. }
  122. }
  123. else
  124. {
  125. $plugpath = getcwd().'/help.php'; // deprecated file. For backwards compat. only.
  126. $eplugpath = getcwd().'/e_help.php';
  127. if(is_readable($eplugpath))
  128. {
  129. $helpfile = $eplugpath;
  130. }
  131. elseif(is_readable($plugpath))
  132. {
  133. $helpfile = $plugpath;
  134. }
  135. }
  136. if (!$helpfile) { return ''; }
  137. ob_start();
  138. include_once($helpfile);
  139. $help_text = ob_get_contents();
  140. ob_end_clean();
  141. return $help_text;
  142. }
  143. function sc_admin_icon()
  144. {
  145. $tp = e107::getParser();
  146. if (ADMIN)
  147. {
  148. global $e_sub_cat, $e_icon_array, $PLUGINS_DIRECTORY;
  149. $e_icon_array = e107::getNav()->getIconArray();
  150. if (e_CURRENT_PLUGIN)
  151. {
  152. $eplug_icon = '';
  153. $eplug_folder = e_CURRENT_PLUGIN.'/';
  154. if (is_readable(e_PLUGIN_DIR.'plugin.xml'))
  155. {
  156. $xml = e107::getXml();
  157. /**
  158. * @todo: folder and administration are deprecated. What replaces them?
  159. * XXX removed folder (as not needed), admininstration[icon] should be replaced with 'icon' only (root xml var), looking in adminlinks for icons isn't that easy
  160. */
  161. $xml->filter = array('folder' => FALSE, 'administration' => FALSE); // Just need one variable
  162. $readFile = $xml->loadXMLfile(e_PLUGIN_DIR.'plugin.xml', 'advanced', true);
  163. // TODO - the better way to go - simple!
  164. //$eplug_icon = $readFile['icon'];
  165. if(isset($readFile['adminLinks']['link']) && is_array($readFile['adminLinks']['link']))
  166. {
  167. foreach ($readFile['adminLinks']['link'] as $data)
  168. {
  169. if(isset($data['@attributes']['primary']) && $data['@attributes']['primary'] && vartrue($data['@attributes']['icon']))
  170. {
  171. $eplug_icon = $data['@attributes']['icon'];
  172. break;
  173. }
  174. }
  175. }
  176. }
  177. elseif (is_readable('plugin.php'))
  178. {
  179. include('plugin.php');
  180. }
  181. else
  182. {
  183. $icon = $tp->toGlyph('e-cat_plugins-32');
  184. return $icon;
  185. }
  186. $icon = ($eplug_icon && file_exists(e_PLUGIN.$eplug_folder.$eplug_icon)) ? "<img src='".e_PLUGIN_ABS.$eplug_folder.$eplug_icon."' alt='' class='icon S32' />" : E_32_CAT_PLUG;
  187. }
  188. else
  189. {
  190. $icon = varset($e_icon_array[$e_sub_cat]);
  191. }
  192. return $icon;
  193. }
  194. else
  195. {
  196. return E_32_LOGOUT;
  197. }
  198. }
  199. function sc_admin_lang($parm)
  200. {
  201. if (!ADMIN || !e107::getPref('multilanguage')) { return ''; }
  202. $e107 = e107::getInstance();
  203. $sql = e107::getDb();
  204. $pref = e107::getPref();
  205. $ns = e107::getRender();
  206. e107::plugLan('user_menu', '', true);
  207. $params = array();
  208. parse_str($parm, $params);
  209. $lanlist = explode(',',e_LANLIST);
  210. sort($lanlist);
  211. $text = '';
  212. foreach($lanlist as $langval)
  213. {
  214. if (getperms($langval))
  215. {
  216. $lanperms[] = $langval;
  217. }
  218. }
  219. $slng = e107::getLanguage();
  220. if(!getperms($sql->mySQLlanguage) && $lanperms)
  221. {
  222. $slng->set($lanperms[0]);
  223. if ($pref['user_tracking'] == "session" && $pref['multilanguage_subdomain'])
  224. {
  225. e107::getRedirect()->redirect($slng->subdomainUrl($lanperms[0]));
  226. }
  227. /*$sql->mySQLlanguage = ($lanperms[0] != $pref['sitelanguage']) ? $lanperms[0] : "";
  228. if ($pref['user_tracking'] == "session")
  229. {
  230. $_SESSION['e107language_'.$pref['cookie_name']] = $lanperms[0];
  231. if($pref['multilanguage_subdomain']){
  232. header("Location:".$slng->subdomainUrl($lanperms[0]));
  233. }
  234. }
  235. else
  236. {
  237. setcookie('e107language_'.$pref['cookie_name'], $lanperms[0], time() + 86400, '/');
  238. $_COOKIE['e107language_'.$pref['cookie_name']]= $lanperms[0];
  239. }*/
  240. }
  241. if(varset($GLOBALS['mySQLtablelist']))
  242. {
  243. foreach($GLOBALS['mySQLtablelist'] as $tabs)
  244. {
  245. $clang = strtolower($sql->mySQLlanguage);
  246. if(strpos($tabs,"lan_".$clang) && $clang !="")
  247. {
  248. $aff[] = str_replace(MPREFIX."lan_".$clang."_","",$tabs);
  249. }
  250. }
  251. }
  252. $text .= "
  253. <div>
  254. ";
  255. if(isset($aff))
  256. {
  257. $text .= $sql->mySQLlanguage;
  258. $text .= " (".$slng->convert($sql->mySQLlanguage).")
  259. : <span class='btn btn-default button' style='cursor: pointer;' onclick='expandit(\"lan_tables\");'><a style='text-decoration:none' title='' href=\"javascript:void(0);\" >&nbsp;&nbsp;".count($aff)." ".UTHEME_MENU_L3."&nbsp;&nbsp;</a></span><br />
  260. <span style='display:none' id='lan_tables'>
  261. ";
  262. $text .= implode('<br />', $aff);
  263. $text .= '</span>';
  264. }
  265. elseif($sql->mySQLlanguage && ($sql->mySQLlanguage != $pref['sitelanguage']))
  266. {
  267. $text .= $sql->mySQLlanguage;
  268. $text .= ' ('.$slng->convert($sql->mySQLlanguage).'): '.LAN_INACTIVE;
  269. }
  270. else
  271. {
  272. $text .= $pref['sitelanguage'];
  273. }
  274. $text .= "<br /><br /></div>";
  275. $select = '';
  276. if(isset($pref['multilanguage_subdomain']) && $pref['multilanguage_subdomain'])
  277. {
  278. // TODO - JS independent
  279. $select .= "
  280. <select class='tbox' name='lang_select' id='sitelanguage' onchange=\"location.href=this.options[selectedIndex].value\">";
  281. foreach($lanperms as $lng)
  282. {
  283. $selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : "";
  284. $urlval = $slng->subdomainUrl($lng);
  285. $select .= "<option value='".$urlval."'{$selected}>$lng</option>\n";
  286. }
  287. $select .= "</select>";
  288. }
  289. /*elseif(isset($params['nobutton']))
  290. {
  291. $select .= "
  292. <form method='post' action='".e_SELF.(e_QUERY ? '?'.e_QUERY : '')."'>
  293. <div>
  294. <select name='sitelanguage' id='sitelanguage' class='tbox' onchange=\"location.href=this.options[selectedIndex].value\">";
  295. foreach($lanperms as $lng)
  296. {
  297. $langval = e_SELF.'?['.$slng->convert($lng).']'.e_QUERY;
  298. $selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : "";
  299. $select .= "<option value='".$langval."'{$selected}>$lng</option>\n";
  300. }
  301. $select .= "</select>
  302. </div>
  303. </form>
  304. ";
  305. }*/
  306. else
  307. {
  308. $select .= "
  309. <form method='post' action='".e_SELF.(e_QUERY ? '?'.e_QUERY : '')."'>
  310. <div>
  311. <select name='sitelanguage' id='sitelanguage' class='tbox' onchange='this.form.submit()'>";
  312. foreach($lanperms as $lng)
  313. {
  314. // FIXME - language detection is a mess - db handler, mysql handler, session handler and language handler + constants invlolved
  315. // Too complex, doesn't work!!! SIMPLIFY!!!
  316. //$langval = ($lng == $pref['sitelanguage'] && $lng == 'English') ? "" : $lng;
  317. //$selected = ($lng == $sql->mySQLlanguage || ($lng == $pref['sitelanguage'] && !$sql->mySQLlanguage)) ? " selected='selected'" : "";
  318. //$select .= "<option value='".$langval."'{$selected}>$lng</option>\n";
  319. $selected = ($lng == e_LANGUAGE) ? " selected='selected'" : "";
  320. $select .= "<option value='".$lng."'{$selected}>$lng</option>\n";
  321. }
  322. $select .= "</select> ".(!isset($params['nobutton']) ? "<button class='update e-hide-if-js' type='submit' name='setlanguage' value='no-value'><span>".UTHEME_MENU_L1."</span></button>" : '')."
  323. ".e107::getForm()->hidden('setlanguage', '1')."
  324. </div>
  325. </form>
  326. ";
  327. }
  328. if(isset($params['nomenu'])) { return $select; }
  329. if($select) { $text .= "<div class='center'>{$select}</div>"; }
  330. return $ns->tablerender(UTHEME_MENU_L2, $text, '', true);
  331. }
  332. function sc_admin_latest($parm)
  333. {
  334. if($parm == 'infopanel' && e_PAGE != 'admin.php')
  335. {
  336. return;
  337. }
  338. if (ADMIN) {
  339. if (!function_exists('admin_latest')) //XXX Is this still necessary?
  340. {
  341. function admin_latest($parm='')
  342. {
  343. $sql = e107::getDb();
  344. $ns = e107::getRender();
  345. $pref = e107::getPref();
  346. $mes = e107::getMessage();
  347. $active_uploads = $sql->count('upload', '(*)', 'WHERE upload_active = 0');
  348. $submitted_news = $sql->count('submitnews', '(*)', 'WHERE submitnews_auth = 0');
  349. $comments_pending = $sql->count("comments", "(*)", "WHERE comment_blocked = 2 ");
  350. // $text = "<div class='left'><div style='padding-bottom: 2px;'>".E_16_NEWS.($submitted_news ? " <a href='".e_ADMIN."newspost.php?mode=sub&amp;action=list'>".ADLAN_LAT_2.": $submitted_news</a>" : ' '.ADLAN_LAT_2.': 0').'</div>';
  351. // $text .= "<div style='padding-bottom: 2px;'>".E_16_COMMENT. " <a href='".e_ADMIN_ABS."comment.php?searchquery=&filter_options=comment_blocked__2'>".ADLAN_LAT_9.": $comments_pending</a></div>";
  352. // $text .= "<div style='padding-bottom: 2px;'>".E_16_UPLOADS." <a href='".e_ADMIN."upload.php'>".ADLAN_LAT_7.": $active_uploads</a></div>";
  353. $oldconfigs = array();
  354. $oldconfigs['e-news'][0] = array('icon'=>E_16_NEWS, 'title'=>ADLAN_LAT_2, 'url'=> e_ADMIN."newspost.php?mode=sub&amp;action=list", 'total'=>$submitted_news);
  355. $oldconfigs['e-comment'][0] = array('icon'=>E_16_COMMENT, 'title'=>ADLAN_LAT_9, 'url'=> e_ADMIN_ABS."comment.php?searchquery=&filter_options=comment_blocked__2", 'total'=>$comments_pending);
  356. $oldconfigs['e-upload'][0] = array('icon'=>E_16_UPLOADS, 'title'=>ADLAN_LAT_7, 'url'=> e_ADMIN."upload.php", 'total'=>$active_uploads);
  357. $messageTypes = array('Broken Download', 'Dev Team Message');
  358. $queryString = '';
  359. foreach($messageTypes as $types)
  360. {
  361. $queryString .= " gen_type='$types' OR";
  362. }
  363. $queryString = substr($queryString, 0, -3);
  364. if($amount = $sql->select('generic', '*', $queryString))
  365. {
  366. // $text .= "<br /><b><a href='".e_ADMIN_ABS."message.php'>".ADLAN_LAT_8." [".$amount."]</a></b>";
  367. $oldconfigs['e-generic'][0] = array('icon'=>E_16_NOTIFY, 'title'=>ADLAN_LAT_8, 'url'=> e_ADMIN_ABS."message.php", 'total'=>$amount);
  368. }
  369. if(vartrue($pref['e_latest_list']))
  370. {
  371. foreach($pref['e_latest_list'] as $val)
  372. {
  373. $text = "";
  374. if (is_readable(e_PLUGIN.$val.'/e_latest.php'))
  375. {
  376. include_once(e_PLUGIN.$val.'/e_latest.php');
  377. if(!class_exists($val."_latest"))
  378. {
  379. $mes->addDebug("<strong>".$val ."</strong> using deprecated e_latest method");
  380. $oldconfigs[$val] = admin_shortcodes::legacyToConfig($text);
  381. }
  382. }
  383. }
  384. }
  385. $configs = e107::getAddonConfig('e_latest');
  386. $allconfigs = array_merge($oldconfigs,$configs);
  387. $allconfigs = multiarray_sort($allconfigs,'title'); //XXX FIXME - not sorting correctly.
  388. $text = "<ul id='e-latest' class='unstyled'>";
  389. foreach($allconfigs as $k=>$v)
  390. {
  391. foreach($v as $val)
  392. {
  393. $class = admin_shortcodes::getBadge($val['total']);
  394. $link = "<a href='".$val['url']."'>".str_replace(":"," ",$val['title'])." <span class='".$class."'>".$val['total']."</span></a>";
  395. $text .= "<li class='clearfix'>".$val['icon']." ".$link."</li>\n";
  396. }
  397. }
  398. $text .= "</ul>";
  399. // $text .= "</div>";
  400. return ($parm != 'norender') ? $ns -> tablerender(ADLAN_LAT_1, $text, '', TRUE) : $text;
  401. }
  402. }
  403. if ($parm == 'request')
  404. {
  405. if (function_exists('latest_request'))
  406. {
  407. if (latest_request())
  408. {
  409. return admin_latest($parm);
  410. }
  411. }
  412. }
  413. else
  414. {
  415. return admin_latest($parm);
  416. }
  417. }
  418. }
  419. function sc_admin_log($parm)
  420. {
  421. if (getperms('0'))
  422. {
  423. if (!function_exists('admin_log'))
  424. {
  425. function admin_log()
  426. {
  427. global $sql, $ns;
  428. $text = E_16_ADMINLOG." <a style='cursor: pointer' onclick=\"expandit('adminlog')\">".ADLAN_116."</a>\n";
  429. if (e_QUERY == 'logall')
  430. {
  431. $text .= "<div id='adminlog'>";
  432. $cnt = $sql -> db_Select('admin_log', '*', "ORDER BY `dblog_datestamp` DESC", 'no_where');
  433. }
  434. else
  435. {
  436. $text .= "<div style='display: none;' id='adminlog'>";
  437. $cnt = $sql -> db_Select('admin_log', '*', 'ORDER BY `dblog_datestamp` DESC LIMIT 0,10', 'no_where');
  438. }
  439. $text .= ($cnt) ? '<ul>' : '';
  440. $gen = e107::getDateConvert();
  441. while ($row = $sql -> db_Fetch())
  442. {
  443. $datestamp = $gen->convert_date($row['dblog_datestamp'], 'short');
  444. $text .= "<li>{$datestamp} - {$row['dblog_title']}</li>";
  445. }
  446. $text .= ($cnt ? '</ul>' : '');
  447. $text .= "[ <a href='".e_ADMIN_ABS."admin_log.php?adminlog'>".ADLAN_117."</a> ]";
  448. $text .= "<br />[ <a href='".e_ADMIN_ABS."admin_log.php?config'>".ADLAN_118."</a> ]";
  449. // $text .= "<br />[ <a href='".e_ADMIN."admin_log.php?purge' onclick=\"return jsconfirm('".LAN_CONFIRMDEL."')\">".ADLAN_118."</a> ]\n";
  450. $text .= "</div>";
  451. return $ns -> tablerender(ADLAN_135, $text, '', TRUE);
  452. }
  453. }
  454. if ($parm == 'request')
  455. {
  456. if (function_exists('log_request'))
  457. {
  458. if (log_request())
  459. {
  460. return admin_log();
  461. }
  462. }
  463. }
  464. else
  465. {
  466. return admin_log();
  467. }
  468. }
  469. }
  470. function sc_admin_logged($parm='')
  471. {
  472. if (ADMIN)
  473. {
  474. $str = str_replace('.', '', ADMINPERMS);
  475. if (ADMINPERMS == '0')
  476. {
  477. return '<b>'.ADLAN_48.':</b> '.ADMINNAME.' ('.ADLAN_49.') '.( defined('e_DBLANGUAGE') ? '<b>'.LAN_head_5.'</b>: '.e_DBLANGUAGE : '' );
  478. }
  479. else
  480. {
  481. return '<b>'.ADLAN_48.':</b> '.ADMINNAME.' '.( defined('e_DBLANGUAGE') ? '<b>'.LAN_head_5.'</b>: '.e_DBLANGUAGE : '' );
  482. }
  483. }
  484. else
  485. {
  486. return ADLAN_51.' ...';
  487. }
  488. }
  489. function sc_admin_logo($parm)
  490. {
  491. parse_str($parm);
  492. if (isset($file) && $file && is_readable($file))
  493. {
  494. $logo = $file;
  495. $path = $file;
  496. }
  497. else if (is_readable(THEME.'images/e_adminlogo.png'))
  498. {
  499. $logo = THEME_ABS.'images/e_adminlogo.png';
  500. $path = THEME.'images/e_adminlogo.png';
  501. }
  502. else
  503. {
  504. $logo = e_IMAGE_ABS.'adminlogo.png';
  505. $path = e_IMAGE.'adminlogo.png';
  506. }
  507. $dimensions = getimagesize($path);
  508. $image = "<img class='logo admin_logo' src='".$logo."' style='width: ".$dimensions[0]."px; height: ".$dimensions[1]."px' alt='".ADLAN_153."' />\n";
  509. if (isset($link) && $link)
  510. {
  511. if ($link == 'index')
  512. {
  513. $image = "<a href='".e_ADMIN_ABS."index.php'>".$image.'</a>';
  514. }
  515. else
  516. {
  517. $image = "<a href='".$link."'>".$image.'</a>';
  518. }
  519. }
  520. return $image;
  521. }
  522. function sc_admin_menu($parm)
  523. {
  524. if (!ADMIN)
  525. {
  526. return '';
  527. }
  528. global $ns, $pref;
  529. // SecretR: NEW v0.8
  530. $tmp = e107::getAdminUI();
  531. if($tmp)
  532. {
  533. ob_start();
  534. // FIXME - renderMenu(), respectively e_adm/in_menu() should return, not output content!
  535. $tmp->renderMenu();
  536. $ret = ob_get_contents();
  537. ob_end_clean();
  538. return $ret;
  539. }
  540. unset($tmp);
  541. // Obsolete
  542. ob_start();
  543. //Show upper_right menu if the function exists
  544. $tmp = explode('.',e_PAGE);
  545. $adminmenu_parms = "";
  546. $adminmenu_func = $tmp[0].'_adminmenu';
  547. if(function_exists($adminmenu_func))
  548. {
  549. if (!$parm)
  550. {
  551. call_user_func($adminmenu_func,$adminmenu_parms); // ? not sure why there's an adminmenu_parms;
  552. }
  553. else
  554. {
  555. ob_end_clean();
  556. return 'pre';
  557. }
  558. }
  559. $plugindir = (str_replace('/','',str_replace('..', '', e_PLUGIN)).'/');
  560. $plugpath = e_PLUGIN.str_replace(basename(e_SELF),'',str_replace('/'.$plugindir,'','/'.strstr(e_SELF,$plugindir))).'admin_menu.php';
  561. if(file_exists($plugpath))
  562. {
  563. if (!$parm)
  564. {
  565. @require_once($plugpath);
  566. }
  567. else
  568. {
  569. ob_end_clean();
  570. return 'pre';
  571. }
  572. }
  573. $ret = ob_get_contents();
  574. ob_end_clean();
  575. return $ret;
  576. }
  577. // FIXME - make it work
  578. function sc_admin_pm($parm)
  579. {
  580. if(!e107::isInstalled('pm')) return;
  581. $sql = e107::getDb();
  582. $tp = e107::getParser();
  583. $count = $sql->count('private_msg','(*)','WHERE pm_read = 0 AND pm_to='.USERID);
  584. if ($count >0)
  585. {
  586. $countDisp = ' <span class="label label-info">'.$count.'</span> ' ;
  587. }
  588. else
  589. {
  590. $countDisp = '';
  591. }
  592. $inboxUrl = e_PLUGIN.'pm/admin_config.php?'.'searchquery=&amp;iframe=1&amp;filter_options=bool__pm_to__'.USERID;
  593. $outboxUrl = e_PLUGIN.'pm/admin_config.php?'.'searchquery=&amp;iframe=1&amp;filter_options=bool__pm_from__'.USERID;
  594. $composeUrl = e_PLUGIN.'pm/admin_config.php?'.'mode=main&amp;iframe=1&amp;action=create';
  595. $text = '<ul class="nav nav-pills">
  596. <li class="dropdown">
  597. <a class="dropdown-toggle" title="Messages" role="button" data-toggle="dropdown" href="#" >
  598. '.$tp->toGlyph('fa-envelope').$countDisp.'<b class="caret"></b>
  599. </a>
  600. <ul class="dropdown-menu" role="menu" >
  601. <li class="nav-header">Private Messages</li>
  602. <li><a class="e-modal" data-cache="false" data-modal-caption="Inbox" data-target="#uiModal" href="'.$inboxUrl.'" >Inbox</a></li>
  603. <li><a class="e-modal" data-cache="false" data-modal-caption="Outbox" data-target="#uiModal" href="'.$outboxUrl.'">Outbox</a></li>
  604. <li><a class="e-modal" data-cache="false" data-modal-caption="Compose" data-target="#uiModal" href="'.$composeUrl.'">Compose</a></li>
  605. </ul>
  606. </li>
  607. </ul>
  608. ';
  609. return $text;
  610. // e107_plugins/pm/pm.php
  611. $text = '
  612. <li class="dropdown">
  613. <a class="dropdown-toggle" title="Messages" role="button" data-toggle="dropdown" href="#" >
  614. <i class="icon-envelope icon-white active"></i> 3 <b class="caret"></b>
  615. </a>
  616. <div id="dropdown" class="dropdown-menu pull-right e-noclick" style="padding:10px;width:300px">
  617. <ul class="nav-list">
  618. <li class="nav-header">Unread Messages</li>
  619. <li><a href="#">Incoming Message Number 1</a></li>
  620. <li><a href="#">Incoming Message Number 2</a></li>
  621. <li><a href="#">Incoming Message Number 3</a></li>
  622. <li class="divider"></li>
  623. </ul>
  624. <textarea class="e-tip input-block-level" title="Example Only"></textarea>
  625. <button class="dropdown-toggle btn btn-primary">Send</button>
  626. </div>
  627. </li>
  628. ';
  629. return $text;
  630. }
  631. function sc_admin_msg($parm)
  632. {
  633. if (ADMIN)
  634. {
  635. global $ns;
  636. ob_start();
  637. if(!FILE_UPLOADS)
  638. {
  639. echo message_handler('ADMIN_MESSAGE', LAN_head_2, __LINE__, __FILE__);
  640. }
  641. /*
  642. if(OPEN_BASEDIR){
  643. echo message_handler('ADMIN_MESSAGE', LAN_head_3, __LINE__, __FILE__);
  644. }
  645. */
  646. $message_text = ob_get_contents();
  647. ob_end_clean();
  648. return $message_text;
  649. }
  650. }
  651. function sc_admin_nav($parm)
  652. {
  653. if (ADMIN)
  654. {
  655. global $ns, $pref, $array_functions, $tp;
  656. $e107_var = array();
  657. if (strstr(e_SELF, '/admin.php'))
  658. {
  659. $active_page = 'x';
  660. }
  661. else
  662. {
  663. $active_page = time();
  664. }
  665. $e107_var['x']['text'] = ADLAN_52;
  666. $e107_var['x']['link'] = e_ADMIN_ABS.'admin.php';
  667. $e107_var['y']['text'] = ADLAN_53;
  668. $e107_var['y']['link'] = e_HTTP."index.php";
  669. //$text .= show_admin_menu("",$active_page,$e107_var);
  670. $e107_var['afuncs']['text'] = ADLAN_93;
  671. $e107_var['afuncs']['link'] = '';
  672. /* SUBLINKS */
  673. $tmp = array();
  674. foreach ($array_functions as $links_key => $links_value)
  675. {
  676. $tmp[$links_key]['text'] = $links_value[1];
  677. $tmp[$links_key]['link'] = $links_value[0];
  678. }
  679. $e107_var['afuncs']['sub'] = $tmp;
  680. /* SUBLINKS END */
  681. // Plugin links menu
  682. $xml = e107::getXml();
  683. $xml->filter = array('@attributes' => FALSE, 'administration' => FALSE); // .. and they're all going to need the same filter
  684. $nav_sql = new db;
  685. if ($nav_sql -> db_Select('plugin', '*', 'plugin_installflag=1'))
  686. {
  687. $tmp = array();
  688. $e107_var['plugm']['text'] = ADLAN_95;
  689. $e107_var['plugm']['link'] = '';
  690. /* SUBLINKS */
  691. //Link Plugin Manager
  692. $tmp['plugm']['text'] = '<strong>'.ADLAN_98.'</strong>';
  693. $tmp['plugm']['link'] = e_ADMIN.'plugin.php';
  694. $tmp['plugm']['perm'] = 'P';
  695. while($rowplug = $nav_sql -> db_Fetch())
  696. {
  697. $plugin_id = $rowplug['plugin_id'];
  698. $plugin_path = $rowplug['plugin_path'];
  699. if (is_readable(e_PLUGIN.$plugin_path.'/plugin.xml'))
  700. {
  701. $readFile = $xml->loadXMLfile(e_PLUGIN.$plugin_path.'/plugin.xml', true, true);
  702. e107::loadLanFiles($plugin_path, 'admin');
  703. $eplug_caption = $tp->toHTML($readFile['@attributes']['name'], FALSE, 'defs, emotes_off');
  704. $eplug_conffile = $readFile['administration']['configFile'];
  705. }
  706. elseif (is_readable(e_PLUGIN.$plugin_path.'/plugin.php'))
  707. {
  708. include(e_PLUGIN.$plugin_path.'/plugin.php');
  709. }
  710. // Links Plugins
  711. if ($eplug_conffile)
  712. {
  713. $tmp['plug_'.$plugin_id]['text'] = $eplug_caption;
  714. $tmp['plug_'.$plugin_id]['link'] = e_PLUGIN.$plugin_path.'/'.$eplug_conffile;
  715. $tmp['plug_'.$plugin_id]['perm'] = 'P'.$plugin_id;
  716. }
  717. unset($eplug_conffile, $eplug_name, $eplug_caption);
  718. }
  719. $e107_var['plugm']['sub'] = $tmp;
  720. $e107_var['plugm']['sort'] = true;
  721. /* SUBLINKS END */
  722. //$text .= show_admin_menu(ADLAN_95, time(), $e107_var, FALSE, TRUE, TRUE);
  723. unset($tmp);
  724. }
  725. $e107_var['lout']['text']=ADLAN_46;
  726. $e107_var['lout']['link']=e_ADMIN_ABS.'admin.php?logout';
  727. $text = e_admin_menu('', '', $e107_var);
  728. return $ns->tablerender(LAN_head_1, $text, array('id' => 'admin_nav', 'style' => 'button_menu'), TRUE);
  729. }
  730. }
  731. function sc_admin_plugins($parm)
  732. {
  733. if (ADMIN)
  734. {
  735. global $e107_plug, $ns, $pref;
  736. if ($pref['admin_alerts_ok'] == 1)
  737. {
  738. ob_start();
  739. $text = "";
  740. $i = 0;
  741. if (strstr(e_SELF, '/admin.php'))
  742. {
  743. global $sql;
  744. if ($sql -> db_Select('plugin', '*', 'plugin_installflag=1'))
  745. {
  746. while($rowplug = $sql -> db_Fetch())
  747. {
  748. extract($rowplug);
  749. if(varset($rowplug[1]))
  750. {
  751. $e107_plug[$rowplug[1]] = varset($rowplug[3]);
  752. }
  753. }
  754. }
  755. }
  756. if (is_array($e107_plug))
  757. {
  758. foreach(array_keys($e107_plug) as $xplug)
  759. {
  760. if (file_exists(e_PLUGIN.$e107_plug[$xplug].'/admin_info.php'))
  761. {
  762. if ($pref['admin_alerts_uniquemenu'] == 1)
  763. {
  764. $text .= '<b>'.$xplug.'</b><br />';
  765. }
  766. else
  767. {
  768. $text = '';
  769. }
  770. require_once(e_PLUGIN.$e107_plug[$xplug].'/admin_info.php');
  771. $text .= '<br />';
  772. if ($pref['admin_alerts_uniquemenu'] != 1)
  773. {
  774. $caption = $xplug;
  775. $ns->tablerender($caption, $text);
  776. }
  777. else
  778. {
  779. $text .= "<br />";
  780. }
  781. $i++;
  782. }
  783. }
  784. }
  785. $caption = LAN_head_6;
  786. if ($i>0 && $pref['admin_alerts_uniquemenu'] == 1)
  787. {
  788. $ns -> tablerender($caption, $text);
  789. }
  790. $plug_text = ob_get_contents();
  791. ob_end_clean();
  792. return $plug_text;
  793. }
  794. }
  795. }
  796. function sc_admin_preset($parm)
  797. {
  798. //DEPRECATED
  799. }
  800. function sc_admin_pword()
  801. {
  802. global $pref;
  803. if (ADMIN && ADMINPERMS == '0')
  804. {
  805. global $ns;
  806. if ($pref['adminpwordchange'] && ((ADMINPWCHANGE+2592000) < time()))
  807. {
  808. $text = "<div style='mediumtext; text-align:center'>".ADLAN_102." <a href='".e_ADMIN."updateadmin.php'>".ADLAN_103.'</a></div>';
  809. return $ns -> tablerender(ADLAN_104, $text, '', true);
  810. }
  811. }
  812. }
  813. function sc_admin_sel_lan()
  814. {
  815. global $pref;
  816. if (ADMIN && $pref['multilanguage'])
  817. {
  818. $language = ($pref['sitelanguage'] == e_LANGUAGE) ? ADLAN_133 : e_LANGUAGE;
  819. return ' <strong>'.ADLAN_132.'</strong> '.$language;
  820. }
  821. }
  822. function sc_admin_siteinfo($parm='')
  823. {
  824. if($parm == 'creditsonly' && e_PAGE != "credits.php" && e_PAGE != "phpinfo.php")
  825. {
  826. return;
  827. }
  828. if (ADMIN)
  829. {
  830. global $ns, $pref, $themename, $themeversion, $themeauthor, $themedate, $themeinfo, $mySQLdefaultdb;
  831. if (file_exists(e_ADMIN.'ver.php'))
  832. {
  833. include(e_ADMIN.'ver.php');
  834. }
  835. if($parm == "version")
  836. {
  837. return $e107info['e107_version'];
  838. }
  839. $obj = e107::getDateConvert();
  840. $install_date = $obj->convert_date($pref['install_date'], 'long');
  841. if(is_readable(THEME."theme.xml"))
  842. {
  843. $xml = e107::getXml();
  844. $data = $xml->loadXMLfile(THEME."theme.xml",true);
  845. $themename = $data['@attributes']['name'];
  846. $themeversion = $data['@attributes']['version'];
  847. $themedate = $data['@attributes']['date'];
  848. $themeauthor = $data['author']['@attributes']['name'];
  849. }
  850. $text = "<b>".FOOTLAN_1."</b>
  851. <br />".
  852. SITENAME."
  853. <br /><br />
  854. <b>".FOOTLAN_2."</b>
  855. <br />
  856. <a href=\"mailto:".SITEADMINEMAIL."\">".SITEADMIN."</a>
  857. <br />
  858. <br />
  859. <b>e107</b>
  860. <br />
  861. ".FOOTLAN_3." ".$e107info['e107_version']."
  862. <br /><br />
  863. <b>".FOOTLAN_20."</b>
  864. <br />
  865. [".e_SECURITY_LEVEL."] ".defset('LAN_SECURITYL_'.e_SECURITY_LEVEL, 'n/a')."
  866. <br /><br />
  867. <b>".FOOTLAN_18."</b>
  868. <br />".$pref['sitetheme']."<br /><br />
  869. <b>".FOOTLAN_5."</b>
  870. <br />
  871. ".$themename." v".$themeversion." ".($themeauthor ? FOOTLAN_6.' '.$themeauthor : '')." ".($themedate ? "(".$themedate.")" : "");
  872. $text .= $themeinfo ? "<br />".FOOTLAN_7.": ".$themeinfo : '';
  873. $text .= "<br /><br />
  874. <b>".FOOTLAN_8."</b>
  875. <br />
  876. ".$install_date."
  877. <br /><br />
  878. <b>".FOOTLAN_9."</b>
  879. <br />".
  880. preg_replace("/PHP.*/i", "", $_SERVER['SERVER_SOFTWARE'])."<br />(".FOOTLAN_10.": ".$_SERVER['SERVER_NAME'].")
  881. <br /><br />
  882. <b>".FOOTLAN_11."</b>
  883. <br />
  884. ".phpversion()."
  885. <br /><br />
  886. <b>".FOOTLAN_12."</b>
  887. <br />
  888. ".e107::getDB()->mySqlServerInfo.
  889. "<br />
  890. ".FOOTLAN_16.": ".$mySQLdefaultdb."
  891. <br /><br />
  892. <b>".FOOTLAN_17."</b>
  893. <br />utf-8
  894. <br /><br />
  895. <b>".FOOTLAN_19."</b>
  896. <br />
  897. ".date('r').
  898. "<br />";
  899. return $ns->tablerender(FOOTLAN_13, $text, '', TRUE);
  900. }
  901. }
  902. function sc_admin_status($parm)
  903. {
  904. if($parm == 'infopanel' && e_PAGE != 'admin.php')
  905. {
  906. return;
  907. }
  908. if (getperms('0') || getperms('4'))
  909. {
  910. if (!function_exists('admin_status')) //XXX Discuss.. do we still need to embed this function within the shortcode?
  911. {
  912. function admin_status($parm='')
  913. {
  914. $mes = e107::getMessage();
  915. $sql = e107::getDb();
  916. $ns = e107::getRender();
  917. $pref = e107::getPref();
  918. $members = $sql->count('user');
  919. $unverified = $sql->count('user', '(*)', 'WHERE user_ban=2');
  920. $banned = $sql->count('user', '(*)', 'WHERE user_ban=1');
  921. $comments = $sql->count('comments');
  922. /*
  923. $unver = ($unverified ? " <a href='".e_ADMIN."users.php?searchquery=&amp;filter_options=user_ban__2&amp;filter=unverified'> ".ADLAN_111.": {$unverified}</a>" : ADLAN_111);
  924. $lban = ($banned) ? "<a href='".e_ADMIN_ABS."users.php??searchquery=&filter_options=user_ban__1&filter=banned'>".ADLAN_112. ": ".$banned."</a>" : ADLAN_112.":";
  925. $lcomment = ($comments) ? "<a href='".e_ADMIN_ABS."comment.php'>".ADLAN_114.": ".$comments."</a>" : ADLAN_114;
  926. $text = "
  927. <div class='left'>
  928. <div style='padding-bottom: 2px;'>". E_16_USER." <a href='".e_ADMIN_ABS."users.php?filter=0'>".ADLAN_110.": ".$members."</a></div>
  929. <div style='padding-bottom: 2px;'>".E_16_USER." {$unver}</div>
  930. <div style='padding-bottom: 2px;'>".E_16_BANLIST." ".$lban."</div>
  931. <div style='padding-bottom: 2px;'>".E_16_COMMENT." ".$lcomment."</div>\n\n";
  932. */
  933. // for BC only.
  934. $oldconfigs['e-user'][0] = array('icon'=>E_16_USER, 'title'=>ADLAN_110, 'url'=> e_ADMIN_ABS."users.php?filter=0", 'total'=>$members);
  935. $oldconfigs['e-user'][1] = array('icon'=>E_16_USER, 'title'=>ADLAN_111, 'url'=> e_ADMIN."users.php?searchquery=&amp;filter_options=user_ban__2&amp;filter=unverified", 'total'=>$unverified);
  936. $oldconfigs['e-user'][2] = array('icon'=>E_16_BANLIST, 'title'=>ADLAN_112, 'url'=> e_ADMIN."users.php?searchquery=&filter_options=user_ban__1&filter=banned", 'total'=>$banned);
  937. $oldconfigs['e-comments'][0] = array('icon'=>E_16_COMMENT, 'title'=>ADLAN_114, 'url'=> e_ADMIN_ABS."comment.php", 'total'=>$comments);
  938. if($flo = $sql->count('generic', '(*)', "WHERE gen_type='failed_login'"))
  939. {
  940. //$text .= "\n\t\t\t\t\t<div style='padding-bottom: 2px;'>".E_16_FAILEDLOGIN." <a href='".e_ADMIN_ABS."fla.php'>".ADLAN_146.": $flo</a></div>";
  941. $oldconfigs['e-failed'][0] = array('icon'=>E_16_FAILEDLOGIN, 'title'=>ADLAN_146, 'url'=>e_ADMIN_ABS."fla.php", 'total'=>$flo);
  942. }
  943. if(vartrue($pref['e_status_list']))
  944. {
  945. foreach($pref['e_status_list'] as $val)
  946. {
  947. $text = "";
  948. if (is_readable(e_PLUGIN.$val.'/e_status.php'))
  949. {
  950. include_once(e_PLUGIN.$val.'/e_status.php');
  951. if(!class_exists($val."_status"))
  952. {
  953. $mes->addDebug("<strong>".$val ."</strong> using deprecated e_status method. See the chatbox plugin folder for a working example of the new one. ");
  954. }
  955. $oldconfigs[$val] = admin_shortcodes::legacyToConfig($text);
  956. }
  957. }
  958. }
  959. // New in v2.x
  960. $configs = e107::getAddonConfig('e_status');
  961. if(!is_array($configs))
  962. {
  963. $configs = array();
  964. }
  965. $allconfigs = array_merge($oldconfigs,$configs);
  966. $allconfigs = multiarray_sort($allconfigs,'title'); //XXX FIXME - not sorting correctly.
  967. $text = "<ul id='e-status' class='unstyled'>";
  968. foreach($allconfigs as $k=>$v)
  969. {
  970. foreach($v as $val)
  971. {
  972. $class = admin_shortcodes::getBadge($val['total']);
  973. $link = "<a href='".$val['url']."'>".str_replace(":"," ",$val['title'])." <span class='".$class."'>".$val['total']."</span></a>";
  974. $text .= "<li>".$val['icon']." ".$link."</li>\n";
  975. }
  976. }
  977. $text .= "</ul>";
  978. if($parm == 'list')
  979. {
  980. // $text = str_replace("<div style='padding-bottom: 2px;'>","<li>",$text);;
  981. }
  982. // $text .= "\n\t\t\t\t\t</div>";
  983. return ($parm != 'norender') ? $ns -> tablerender(LAN_STATUS, $text, '', TRUE) : $text;
  984. }
  985. }
  986. if ($parm == 'request')
  987. {
  988. if (function_exists('status_request'))
  989. {
  990. if (status_request())
  991. {
  992. return admin_status($parm);
  993. }
  994. }
  995. }
  996. else
  997. {
  998. return admin_status($parm);
  999. }
  1000. }
  1001. }
  1002. function getBadge($total, $type = 'latest')
  1003. {
  1004. /*
  1005. * <span class="badge">1</span>
  1006. Success 2 <span class="badge badge-success">2</span>
  1007. Warning 4 <span class="badge badge-warning">4</span>
  1008. Important 6 <span class="badge badge-important">6</span>
  1009. Info 8 <span class="badge badge-info">8</span>
  1010. Inverse 10 <span class="badge badge-inverse">10</span>
  1011. */
  1012. $class = 'badge ';
  1013. if($total > 100 && $type == 'latest')
  1014. {
  1015. $class .= 'badge-important';
  1016. }
  1017. elseif($total > 50 && $type == 'latest')
  1018. {
  1019. $class .= 'badge-warning';
  1020. }
  1021. elseif($total > 0)
  1022. {
  1023. $class .= 'badge-info';
  1024. }
  1025. return $class;
  1026. }
  1027. /**
  1028. * Attempt to Convert Old $text string into new array format (e_status and e_latest)
  1029. */
  1030. function legacyToConfig($text)
  1031. {
  1032. $var = array();
  1033. preg_match_all('/(<img[^>]*>)[\s]*<a[^>]href=(\'|")([^\'"]*)(\'|")>([^<]*)<\/a>[: ]*([\d]*)/is',$text, $match);
  1034. foreach($match[5] as $k=>$m)
  1035. {
  1036. $var[$k]['icon'] = $match[1][$k];
  1037. $var[$k]['title'] = $match[5][$k];
  1038. $var[$k]['url'] = $match[3][$k];
  1039. $var[$k]['total'] = $match[6][$k];
  1040. }
  1041. return $var;
  1042. }
  1043. function sc_admin_update()
  1044. {
  1045. if (!ADMIN) { return ''; }
  1046. global $e107cache,$ns, $pref;
  1047. if (!varset($pref['check_updates'], FALSE)) { return ''; }
  1048. if (is_readable(e_ADMIN.'ver.php'))
  1049. {
  1050. include(e_ADMIN.'ver.php');
  1051. }
  1052. $feed = "http://sourceforge.net/export/rss2_projfiles.php?group_id=63748&rss_limit=5";
  1053. $e107cache->CachePageMD5 = md5($e107info['e107_version']);
  1054. if($cacheData = $e107cache->retrieve('updatecheck', 3600, TRUE))
  1055. {
  1056. return $ns -> tablerender(LAN_NEWVERSION, $cacheData);
  1057. }
  1058. // Don't check for updates if running locally (comment out the next line to allow check - but
  1059. // remember it can cause delays/errors if its not possible to access the Internet
  1060. if ((strpos(e_SELF,'localhost') !== FALSE) || (strpos(e_SELF,'127.0.0.1') !== FALSE)) { return ''; }
  1061. $xml = e107::getXml();
  1062. require_once(e_HANDLER."magpie_rss.php");
  1063. $ftext = '';
  1064. if($rawData = $xml -> getRemoteFile($feed))
  1065. {
  1066. $rss = new MagpieRSS( $rawData );
  1067. list($cur_version,$tag) = explode(" ",$e107info['e107_version']);
  1068. $c = 0;
  1069. foreach($rss->items as $val)
  1070. {
  1071. $search = array((strstr($val['title'], '(')), 'e107', 'released', ' v');
  1072. $version = trim(str_replace($search, '', $val['title']));
  1073. if(version_compare($version,$cur_version)==1)
  1074. {
  1075. $ftext = "<a rel='external' href='".$val['link']."' >e107 v".$version."</a><br />\n";
  1076. break;
  1077. }
  1078. $c++;
  1079. }
  1080. }
  1081. else
  1082. { // Error getting data
  1083. $ftext = ADLAN_154;
  1084. }
  1085. $e107cache->set('updatecheck', $ftext, TRUE);
  1086. if($ftext)
  1087. {
  1088. return $ns -> tablerender(LAN_NEWVERSION, $ftext);
  1089. }
  1090. }
  1091. // Does actually the same than ADMIN_SEL_LAN
  1092. function sc_admin_userlan()
  1093. {
  1094. /*
  1095. if (isset($_COOKIE['userlan']) && $_COOKIE['userlan'])
  1096. {
  1097. return ' <b>Language:</b> '.$_COOKIE['userlan'];
  1098. }
  1099. */
  1100. }
  1101. /**
  1102. * New Admin Navigation Routine.
  1103. */
  1104. function sc_admin_navigation($parm)
  1105. {
  1106. if (!ADMIN) return '';
  1107. // global $admin_cat, $array_functions, $array_sub_functions, $pref;
  1108. $pref = e107::getPref();
  1109. $admin_cat = e107::getNav()->adminCats();
  1110. $array_functions = e107::getNav()->adminLinks('legacy');
  1111. $array_sub_functions = e107::getNav()->adminLinks('sub');
  1112. $tp = e107::getParser();
  1113. $e107 = e107::getInstance();
  1114. $sql = e107::getDb('sqlp');
  1115. parse_str($parm, $parms);
  1116. $tmpl = strtoupper(varset($parms['tmpl'], 'E_ADMIN_NAVIGATION'));
  1117. global $$tmpl;
  1118. if($parm == 'home' || $parm == 'logout' || $parm == 'language' || $parm == 'pm')
  1119. {
  1120. $menu_vars = $this->getOtherNav($parm);
  1121. return e107::getNav()->admin('', '', $menu_vars, $$tmpl, FALSE, FALSE);
  1122. }
  1123. // MAIN LINK
  1124. if($parm != 'no-main')
  1125. {
  1126. $menu_vars = array();
  1127. $menu_vars['adminhome']['text'] = ADLAN_151;
  1128. $menu_vars['adminhome']['link'] = e_ADMIN_ABS.'admin.php';
  1129. $menu_vars['adminhome']['image'] = "<img src='".E_16_NAV_MAIN."' alt='".ADLAN_151."' class='icon S16' />";
  1130. $menu_vars['adminhome']['image_src'] = ADLAN_151;
  1131. $menu_vars['adminhome']['perm'] = '';
  1132. }
  1133. //ALL OTHER ROOT LINKS - temporary data transformation - data structure will be changed in the future and this block will be removed
  1134. foreach($admin_cat['id'] as $i => $cat)
  1135. {
  1136. $id = $admin_cat['id'][$i];
  1137. $menu_vars[$id]['text'] = $admin_cat['title'][$i];
  1138. $menu_vars[$id]['description'] = $admin_cat['title'][$i];
  1139. $menu_vars[$id]['link'] = '#';
  1140. $menu_vars[$id]['image'] = "<img src='".$admin_cat['img'][$i]."' alt='".$admin_cat['title'][$i]."' class='icon S16' />";
  1141. $menu_vars[$id]['image_large'] = "<img src='".$admin_cat['lrg_img'][$i]."' alt='".$admin_cat['title'][$i]."' class='icon S32' />";
  1142. $menu_vars[$id]['image_src'] = $admin_cat['img'][$i];
  1143. $menu_vars[$id]['image_large_src'] = $admin_cat['lrg_img'][$i];
  1144. // FIX - 'perm' should not be set or navigation->admin() will be broken (bad permissions) for non main administrators
  1145. //$menu_vars[$id]['perm'] = '';
  1146. $menu_vars[$id]['sort'] = $admin_cat['sort'][$i];
  1147. }
  1148. //CORE SUBLINKS
  1149. foreach ($array_functions as $key => $subitem)
  1150. {
  1151. $catid = $admin_cat['id'][$subitem[4]];
  1152. $tmp = array();
  1153. $tmp['text'] = $subitem[1];
  1154. $tmp['description'] = $subitem[2];
  1155. $tmp['link'] = $subitem[0];
  1156. $tmp['image'] = $subitem[5];
  1157. $tmp['image_large'] = $subitem[6];
  1158. $tmp['image_src'] = '';
  1159. $tmp['image_large_src'] = '';
  1160. $tmp['perm'] = $subitem[3];
  1161. $tmp['sub_class'] = '';
  1162. $tmp['sort'] = false;
  1163. if(vartrue($pref['admin_slidedown_subs']) && vartrue($array_sub_functions[$key]))
  1164. {
  1165. $tmp['sub_class'] = 'sub';
  1166. foreach ($array_sub_functions[$key] as $subkey => $subsubitem)
  1167. {
  1168. $subid = $key.'_'.$subkey;
  1169. $tmp['sub'][$subid]['text'] = $subsubitem[1];
  1170. $tmp['sub'][$subid]['description'] = $subsubitem[2];
  1171. $tmp['sub'][$subid]['link'] = $subsubitem[0];
  1172. $tmp['sub'][$subid]['image'] = $subsubitem[5];
  1173. $tmp['sub'][$subid]['image_large'] = $subsubitem[6];
  1174. $tmp['sub'][$subid]['image_src'] = '';
  1175. $tmp['sub'][$subid]['image_large_src'] = '';
  1176. $tmp['sub'][$subid]['perm'] = $subsubitem[3];
  1177. }
  1178. }
  1179. if($tmp) $menu_vars[$catid]['sub'][$key] = $tmp;
  1180. }
  1181. //PLUGINS
  1182. require_once(e_HANDLER.'plugin_class.php');
  1183. $plug = new e107plugin;
  1184. $tmp = array();
  1185. if($sql->db_Select("plugin", "*", "plugin_installflag =1 ORDER BY plugin_path"))
  1186. {
  1187. while($row = $sql->db_Fetch())
  1188. {
  1189. if($plug->parse_plugin($row['plugin_path']))
  1190. {
  1191. $plug_vars = $plug->plug_vars;
  1192. if($row['plugin_path']=='calendar_menu')
  1193. {
  1194. // print_a($plug_vars);
  1195. }
  1196. // moved to boot.php
  1197. // e107::loadLanFiles($row['plugin_path'], 'admin');
  1198. if(varset($plug_vars['adminLinks']['link']))
  1199. {
  1200. if($row['plugin_category'] == 'menu' || !vartrue($plug_vars['adminLinks']['link'][0]['@attributes']['url']))
  1201. {
  1202. continue;
  1203. }
  1204. $plugpath = varset($plug_vars['plugin_php']) ? e_PLUGIN_ABS : e_PLUGIN_ABS.$row['plugin_path'].'/';
  1205. $icon_src = varset($plug_vars['administration']['iconSmall']) ? $plugpath.$plug_vars['administration']['iconSmall'] : '';
  1206. $icon_src_lrg = varset($plug_vars['administration']['icon']) ? $plugpath.$plug_vars['administration']['iconSmall'] : '';
  1207. $id = 'plugnav-'.$row['plugin_path'];
  1208. $tmp[$id]['text'] = e107::getParser()->toHTML($plug_vars['@attributes']['name'], FALSE, "LINKTEXT");
  1209. $tmp[$id]['description'] = vartrue($plug_vars['description']['@value']);
  1210. $tmp[$id]['link'] = e_PLUGIN_ABS.$row['plugin_path'].'/'.$plug_vars['administration']['configFile'];
  1211. $tmp[$id]['image'] = $icon_src ? "<img src='{$icon_src}' alt=\"".varset($tmp[$id]['text'])."\" class='icon S16' />" : E_16_PLUGIN;
  1212. $tmp[$id]['image_large'] = $icon_src_lrg ? "<img src='{$icon_src_lrg}' alt=\"".varset($tmp[$id]['text'])."\" class='icon S32' />" : $icon_src_lrg;
  1213. $tmp[$id]['image_src'] = $icon_src;
  1214. $tmp[$id]['image_large_src'] = $icon_src_lrg;
  1215. $tmp[$id]['perm'] = 'P'.$row['plugin_id'];
  1216. $tmp[$id]['sub_class'] = '';
  1217. $tmp[$id]['sort'] = 2;
  1218. $tmp[$id]['category'] = $row['plugin_category'];
  1219. if($pref['admin_slidedown_subs'] && vartrue($plug_vars['adminLinks']['link']) )
  1220. {
  1221. $tmp[$id]['sub_class'] = 'sub';
  1222. $tmp[$id]['sort'] = false;
  1223. foreach ($plug_vars['adminLinks']['link'] as $subkey => $plugsub)
  1224. {
  1225. $subid = $id.'-'.$subkey;
  1226. $predef_icons = array('add', 'manage', 'settings');
  1227. $title = vartrue($plugsub['@value']);
  1228. $plugsub = $plugsub['@attributes'];
  1229. if(varset($plugsub['primary'])=='true') // remove primary links.
  1230. {
  1231. continue;
  1232. }
  1233. $icon_src = in_array($plugsub['icon'], $predef_icons) ? e_IMAGE_ABS."admin_images/{$plugsub['icon']}_16.png" : ( $plugsub['icon'] ? $plugpath.$plugsub['icon'] : '');
  1234. $tmp[$id]['sub'][$subid]['text'] = e107::getParser()->toHTML($title, FALSE, 'LINKTEXT');
  1235. $tmp[$id]['sub'][$subid]['description'] = (vartrue($plug_vars['description']['@value'])) ? e107::getParser()->toHTML($plug_vars['description']['@value']) : "";
  1236. $tmp[$id]['sub'][$subid]['link'] = e_PLUGIN_ABS.$row['plugin_path'].'/'.$plugsub['url'];
  1237. $tmp[$id]['sub'][$subid]['image'] = $icon_src ? "<img src='{$icon_src}' alt=\"".varset($tmp[$id]['sub'][$subid]['text'])."\" class='icon S16' />" : "";
  1238. $tmp[$id]['sub'][$subid]['image_large'] = '';
  1239. $tmp[$id]['sub'][$subid]['image_src'] = $icon_src;
  1240. $tmp[$id]['sub'][$subid]['image_large_src'] = '';
  1241. $tmp[$id]['sub'][$subid]['perm'] = varset($plugsub['perm']) ? $plugsub['perm'] : 'P'.$row['plugin_id'];
  1242. $tmp[$id]['sub'][$subid]['sub_class'] = '';
  1243. }
  1244. }
  1245. }
  1246. }
  1247. }
  1248. $menu_vars['plugMenu']['sub'] = multiarray_sort($tmp, 'text');
  1249. }
  1250. // ---------------- Cameron's Bit ---------------------------------
  1251. if(!varsettrue($pref['admin_separate_plugins']))
  1252. {
  1253. // Convert Plugin Categories to Core Categories.
  1254. $convert = array(
  1255. 'settings' => array(1,'setMenu'),
  1256. 'users' => array(2,'userMenu'),
  1257. 'content' => array(3,'contMenu'),
  1258. 'tools' => array(4,'toolMenu'),
  1259. 'manage' => array(6,'managMenu'),
  1260. 'misc' => array(7,'miscMenu'),
  1261. 'help' => array(20,'helpMenu')
  1262. );
  1263. foreach($tmp as $pg)
  1264. {
  1265. $id = $convert[$pg['category']][1];
  1266. $menu_vars[$id]['sub'][] = $pg;
  1267. }
  1268. unset($menu_vars['plugMenu']);
  1269. // Clean up - remove empty main sections
  1270. foreach ($menu_vars as $_m => $_d)
  1271. {
  1272. if(!isset($_d['sub']) || empty($_d['sub']))
  1273. {
  1274. unset($menu_vars[$_m]);
  1275. }
  1276. }
  1277. }
  1278. // ------------------------------------------------------------------
  1279. //added option to disable leave/logout (ll) - more flexibility for theme developers
  1280. if(!varsettrue($parms['disable_ll']))
  1281. {
  1282. // $menu_vars += $this->getOtherNav('home');
  1283. }
  1284. // print_a($menu_vars);
  1285. return e107::getNav()->admin('', e_PAGE, $menu_vars, $$tmpl, FALSE, FALSE);
  1286. //return e_admin_men/u('', e_PAGE, $menu_vars, $$tmpl, FALSE, FALSE);
  1287. }
  1288. function getOtherNav($type)
  1289. {
  1290. $tp = e107::getParser();
  1291. $frm = e107::getForm();
  1292. if($type == 'home')
  1293. {
  1294. $menu_vars['home']['text'] = ""; // ADLAN_53;
  1295. $menu_vars['home']['link'] = e_HTTP.'index.php';
  1296. $menu_vars['home']['image'] = $tp->toGlyph('fa-home'); // "<i class='fa fa-home'></i>" ; // "<img src='".E_16_NAV_LEAV."' alt='".ADLAN_151."' class='icon S16' />";
  1297. $menu_vars['home']['image_src'] = ADLAN_151;
  1298. $menu_vars['home']['sort'] = 1;
  1299. $menu_vars['home']['sub_class'] = 'sub';
  1300. // Sub Links for 'home'.
  1301. require_once(e_HANDLER."sitelinks_class.php");
  1302. $slinks = new sitelinks;
  1303. $slinks->getlinks(1);
  1304. $tmp = array();
  1305. $c= 0;
  1306. foreach($slinks->eLinkList['head_menu'] as $k=>$lk)
  1307. {
  1308. $subid = 'home_'.$k;
  1309. $subid = $c;
  1310. $link = (substr($lk['link_url'],0,1)!="/" && substr($lk['link_url'],0,3)!="{e_" && substr($lk['link_url'],0,4)!='http') ? "{e_BASE}".$lk['link_url'] : $lk['link_url'];
  1311. $tmp[$c]['text'] = $tp->toHtml($lk['link_name'],'','defs');
  1312. $tmp[$c]['description'] = $tp->toHtml($lk['link_description'],'','defs');
  1313. $tmp[$c]['link'] = $tp->replaceConstants($link,'full');
  1314. $tmp[$c]['image'] = vartrue($lk['link_button']) ? "<img class='icon S16' src='".$tp->replaceConstants($lk['link_button'])."' alt='".$tp->toAttribute($lk['link_description'],'','defs')."' />": "" ;
  1315. $tmp[$c]['image_large'] = '';
  1316. $tmp[$c]['image_src'] = vartrue($lk['link_button']);
  1317. $tmp[$c]['image_large_src'] = '';
  1318. // $tmp[$c]['perm'] = '';
  1319. $c++;
  1320. }
  1321. $menu_vars['home']['sub'] = $tmp;
  1322. // --------------------
  1323. }
  1324. elseif($type == 'logout')
  1325. {
  1326. $tmp = array();
  1327. $tmp[1]['text'] = ADLAN_CL_1;
  1328. $tmp[1]['description'] = ADLAN_151;
  1329. $tmp[1]['link'] = e_BASE.'usersettings.php';
  1330. $tmp[1]['image'] = "<i class='S16 e-settings-16'></i>"; // "<img src='".E_16_CAT_SETT."' alt='".ADLAN_151."' class='icon S16' />";
  1331. $tmp[1]['image_large'] = '';
  1332. $tmp[1]['image_src'] = '';
  1333. $tmp[1]['image_large_src'] = '';
  1334. $tmp[2]['text'] = "Personalize"; // TODO - generic LAN in lan_admin.php
  1335. $tmp[2]['description'] = "Customize administration panels";
  1336. $tmp[2]['link'] = e_ADMIN.'admin.php?mode=customize';
  1337. $tmp[2]['image'] = "<i class='S16 e-admins-16'></i>"; //E_16_ADMIN; // "<img src='".E_16_NAV_ADMIN."' alt='".ADLAN_151."' class='icon S16' />";
  1338. $tmp[2]['image_large'] = '';
  1339. $tmp[2]['image_src'] = '';
  1340. $tmp[2]['image_large_src'] = '';
  1341. // $tmp[2]['perm'] = '';
  1342. $tmp[3]['text'] = ADLAN_46;
  1343. $tmp[3]['description'] = ADLAN_151;
  1344. $tmp[3]['link'] = e_ADMIN_ABS.'admin.php?logout';
  1345. $tmp[3]['image'] = "<i class='S16 e-logout-16'></i>"; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />";
  1346. $tmp[3]['image_large'] = '';
  1347. $tmp[3]['image_src'] = '';
  1348. $tmp[3]['image_large_src'] = '';
  1349. $tmp[4]['text'] = ADLAN_46;
  1350. $tmp[4]['description'] = ADLAN_151;
  1351. $tmp[4]['link'] = e_ADMIN_ABS.'admin.php?logout';
  1352. $tmp[4]['image'] = "";
  1353. $tmp[4]['image_large'] = '';
  1354. $tmp[4]['image_src'] = '';
  1355. $tmp[4]['image_large_src'] = '';
  1356. $tmp[4]['link_class'] = 'divider';
  1357. $tmp[5]['text'] = "e107 Website";
  1358. $tmp[5]['description'] = '';
  1359. $tmp[5]['link'] = 'http://e107.org';
  1360. $tmp[5]['image'] = E_16_E107;
  1361. $tmp[5]['image_large'] = '';
  1362. $tmp[5]['image_src'] = '';
  1363. $tmp[5]['image_large_src'] = '';
  1364. $tmp[5]['link_class'] = '';
  1365. $tmp[6]['text'] = "e107 on Twitter";
  1366. $tmp[6]['description'] = '';
  1367. $tmp[6]['link'] = 'http://twitter.com/e107';
  1368. $tmp[6]['image'] = E_16_TWITTER; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />";
  1369. $tmp[6]['image_large'] = '';
  1370. $tmp[6]['image_src'] = '';
  1371. $tmp[6]['image_large_src'] = '';
  1372. $tmp[6]['link_class'] = '';
  1373. $tmp[7]['text'] = "e107 on Facebook";
  1374. $tmp[7]['description'] = '';
  1375. $tmp[7]['link'] = 'https://www.facebook.com/e107CMS';
  1376. $tmp[7]['image'] = E_16_FACEBOOK; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />";
  1377. $tmp[7]['image_large'] = '';
  1378. $tmp[7]['image_src'] = '';
  1379. $tmp[7]['image_large_src'] = '';
  1380. $tmp[7]['link_class'] = '';
  1381. $tmp[8]['text'] = "e107 on Github";
  1382. $tmp[8]['description'] = '';
  1383. $tmp[8]['link'] = 'https://github.com/e107inc';
  1384. $tmp[8]['image'] = E_16_GITHUB; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />";
  1385. $tmp[8]['image_large'] = '';
  1386. $tmp[8]['image_src'] = '';
  1387. $tmp[8]['image_large_src'] = '';
  1388. $tmp[8]['link_class'] = '';
  1389. $menu_vars['logout']['text'] = ADMINNAME; // ""; // ADMINNAME;
  1390. $menu_vars['logout']['link'] = '#';
  1391. $menu_vars['logout']['image'] = $tp->toGlyph('fa-user'); // "<i class='icon-user'></i>"; // "<img src='".E_16_NAV_LGOT."' alt='".ADLAN_151."' class='icon S16' />";
  1392. $menu_vars['logout']['image_src'] = ADLAN_46;
  1393. $menu_vars['logout']['sub'] = $tmp;
  1394. }
  1395. if($type == 'language')
  1396. {
  1397. $slng = e107::getLanguage();
  1398. $languages = $slng->installed();//array('English','French');
  1399. $multiDoms = array();
  1400. if($langSubs = explode("\n", e10

Large files files are truncated, but you can click here to view the full file