1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Support plugin.xml in most of the areas which currently read plugin.php; clear system cache in theme manager when saving theme prefs; bug fix in upload_handler XML file read; add filter option to XML class; remove some historic code from admin.php

This commit is contained in:
e107steved
2008-08-25 10:46:46 +00:00
parent d2da01b8db
commit 670b4964a7
11 changed files with 268 additions and 225 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/admin.php,v $
| $Revision: 1.2 $
| $Date: 2007-01-06 23:10:31 $
| $Revision: 1.3 $
| $Date: 2008-08-25 10:46:30 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -20,17 +20,22 @@ require_once('../class2.php');
$e_sub_cat = 'main';
require_once('auth.php');
require_once(e_HANDLER.'admin_handler.php');
require_once(e_HANDLER.'upload_handler.php');
if (!isset($pref['adminstyle'])) $pref['adminstyle'] = 'classis'; // Shouldn't be needed - but just in case
// --- check for htmlarea.
if (is_dir(e_ADMIN.'htmlarea') || is_dir(e_HANDLER.'htmlarea')) {
if (is_dir(e_ADMIN.'htmlarea') || is_dir(e_HANDLER.'htmlarea'))
{
$text = ADLAN_ERR_2."<br /><br />
<div style='text-align:center'>".$HANDLERS_DIRECTORY."htmlarea/<br />".$ADMIN_DIRECTORY."htmlarea/</div>";
$ns -> tablerender(ADLAN_ERR_1, $text);
}
// check for old modules.
if(getperms('0') && isset($pref['modules']) && $pref['modules'] && $sql->db_Field("plugin",5) == "plugin_addons"){
if(getperms('0') && isset($pref['modules']) && $pref['modules'] && $sql->db_Field("plugin",5) == "plugin_addons")
{
$mods=explode(",", $pref['modules']);
$thef = "e_module.php";
foreach ($mods as $mod)
@@ -57,109 +62,88 @@ if(getperms('0') && isset($pref['modules']) && $pref['modules'] && $sql->db_Fiel
}
// check for file-types;
if (is_readable(e_ADMIN.'filetypes.php')) {
$a_types = strtolower(trim(file_get_contents(e_ADMIN.'filetypes.php')));
} else {
$a_types = 'zip, gz, jpg, png, gif';
$allowed_types = get_filetypes(); // Get allowed types according to filetypes.xml or filetypes.php
if (count($allowed_types) == 0)
{
echo "Setting default filetypes<br />";
$allowed_types = array('zip' => 1, 'gz' => 1, 'jpg' => 1, 'png' => 1, 'gif' => 1);
}
$a_types = explode(',', $a_types);
foreach ($a_types as $f_type) {
$allowed_types[] = '.'.trim(str_replace('.', '', $f_type));
}
//echo "Allowed filetypes = ".implode(', ',array_keys($allowed_types)).'<br />';
// avatar check.
$public = array(e_FILE.'public', e_FILE.'public/avatars');
foreach ($public as $dir) {
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (is_dir($dir."/".$file) == FALSE && $file != '.' && $file != '..' && $file != '/' && $file != 'CVS' && $file != 'avatars' && $file != 'Thumbs.db' && $file !=".htaccess" && $file !="php.ini") {
$fext = substr(strrchr($file, "."), 0);
if (!in_array(strtolower($fext), $allowed_types) ) {
if ($file == 'index.html' || $file == "null.txt") {
if (filesize($dir.'/'.$file)) {
foreach ($public as $dir)
{
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (is_dir($dir."/".$file) == FALSE && $file != '.' && $file != '..' && $file != '/' && $file != 'CVS' && $file != 'avatars' && $file != 'Thumbs.db' && $file !=".htaccess" && $file !="php.ini")
{
$fext = substr(strrchr($file, "."), 1);
if (!array_key_exists(strtolower($fext),$allowed_types) )
{
if ($file == 'index.html' || $file == "null.txt")
{
if (filesize($dir.'/'.$file))
{
$potential[] = str_replace('../', '', $dir).'/'.$file;
}
} else {
}
else
{
$potential[] = str_replace('../', '', $dir).'/'.$file;
}
}
}
}
closedir($dh);
closedir($dh);
}
}
}
if (isset($potential)) {
if (isset($potential))
{
$text = ADLAN_ERR_3."<br /><br />";
foreach ($potential as $p_file) {
foreach ($potential as $p_file)
{
$text .= $p_file.'<br />';
}
$ns -> tablerender(ADLAN_ERR_1, $text);
}
// update users using old layout names to their new names
$update_prefs = FALSE;
if (!$pref['adminstyle'] || $pref['adminstyle'] == 'default') {
$pref['adminstyle'] = 'compact';
$update_prefs = true;
}
if ($pref['adminstyle'] == 'adminb') {
$pref['adminstyle'] = 'cascade';
$update_prefs = true;
}
if ($pref['adminstyle'] == 'admin_etalkers') {
$pref['adminstyle'] = 'categories';
$update_prefs = true;
}
if ($pref['adminstyle'] == 'admin_combo') {
$pref['adminstyle'] = 'combo';
$update_prefs = true;
}
if ($pref['adminstyle'] == 'admin_classis') {
$pref['adminstyle'] = 'classis';
$update_prefs = true;
}
// temporary code to switch users using admin_jayya to jayya
if ($pref['admintheme'] == 'admin_jayya') {
$pref['admintheme'] = 'jayya';
$update_prefs = true;
}
if ($pref['sitetheme'] == 'admin_jayya') {
$pref['sitetheme'] = 'jayya';
$update_prefs = true;
}
// ---------------------------------------------------------
if ($update_prefs == true) {
save_prefs();
}
// auto db update
if ('0' == ADMINPERMS) {
if ('0' == ADMINPERMS)
{
require_once(e_ADMIN.'update_routines.php');
update_check();
}
// end auto db update
if (e_QUERY == 'purge' && getperms('0')) {
/*
if (e_QUERY == 'purge' && getperms('0'))
{
$admin_log->purge_log_events(false);
}
*/
$td = 1;
if(!defined("ADLINK_COLS")){
if(!defined("ADLINK_COLS"))
{
define("ADLINK_COLS",5);
}
function render_links($link, $title, $description, $perms, $icon = FALSE, $mode = FALSE) {
function render_links($link, $title, $description, $perms, $icon = FALSE, $mode = FALSE)
{
global $td,$tp;
$text = '';
if (getperms($perms)) {
@@ -194,7 +178,9 @@ function render_links($link, $title, $description, $perms, $icon = FALSE, $mode
return $text;
}
function render_clean() {
function render_clean()
{
global $td;
while ($td <= ADLINK_COLS) {
$text .= "<td class='td' style='width:20%;'></td>";
@@ -207,9 +193,11 @@ function render_clean() {
$newarray = asortbyindex($array_functions, 1);
require_once(e_ADMIN.'includes/'.$pref['adminstyle'].'.php');
function admin_info() {
function admin_info()
{
global $tp;
$width = (getperms('0')) ? "33%" : "50%";
@@ -237,7 +225,8 @@ function admin_info() {
return $tp->parseTemplate($ADMIN_INFO_TEMPLATE);
}
function status_request() {
function status_request()
{
global $pref;
if ($pref['adminstyle'] == 'classis' || $pref['adminstyle'] == 'cascade' || $pref['adminstyle'] == 'beginner') {
return TRUE;
@@ -246,7 +235,9 @@ function status_request() {
}
}
function latest_request() {
function latest_request()
{
global $pref;
if ($pref['adminstyle'] == 'classis' || $pref['adminstyle'] == 'cascade' || $pref['adminstyle'] == 'beginner') {
return TRUE;
@@ -255,7 +246,8 @@ function latest_request() {
}
}
function log_request() {
function log_request()
{
global $pref;
if ($pref['adminstyle'] == 'classis' || $pref['adminstyle'] == 'cascade'|| $pref['adminstyle'] == 'beginner') {
return TRUE;
@@ -264,6 +256,70 @@ function log_request() {
}
}
// Function renders all the plugin links according to the required icon size and layout style
// - common to the various admin layouts.
function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb')
{
global $sql, $tp;
$text = render_links(e_ADMIN."plugin.php", ADLAN_98, ADLAN_99, "Z", $iconSize, $linkStyle);
require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass; // We're going to have some plugins with plugin.xml files, surely? So create XML object now
$xml->filter = array('name' => FALSE,'description'=>FALSE,'administration' => FALSE); // .. and they're all going to need the same filter
if ($sql->db_Select("plugin", "*", "plugin_installflag=1"))
{
while ($row = $sql->db_Fetch())
{
extract($row); // plugin_id int(10) unsigned NOT NULL auto_increment,
// plugin_name varchar(100) NOT NULL default '',
// plugin_version varchar(10) NOT NULL default '',
// plugin_path varchar(100) NOT NULL default '',
// plugin_installflag tinyint(1) unsigned NOT NULL default '0',
// plugin_addons text NOT NULL,
if (is_readable(e_PLUGIN.$plugin_path."/plugin.xml"))
{
$readFile = $xml->loadXMLfile(e_PLUGIN.$plugin_path.'/plugin.xml', true, true);
include_lan_admin($plugin_path);
$eplug_name = $tp->toHTML($readFile['name'],FALSE,"defs, emotes_off");
$eplug_conffile = $readFile['administration']['configFile'];
$eplug_icon_small = $plugin_path.'/'.$readFile['administration']['iconSmall'];
$eplug_icon = $plugin_path.'/'.$readFile['administration']['icon'];
$eplug_caption = $tp->toHTML($readFile['description'],FALSE,"defs, emotes_off");
}
elseif (is_readable(e_PLUGIN.$plugin_path."/plugin.php"))
{
include(e_PLUGIN.$plugin_path."/plugin.php");
}
if ($eplug_conffile)
{
$eplug_name = $tp->toHTML($eplug_name,FALSE,"defs, emotes_off");
if ($iconSize == E_16_PLUGMANAGER)
{
$plugin_icon = $eplug_icon_small ? "<img src='".e_PLUGIN.$eplug_icon_small."' alt='' style='border:0px; vertical-align:bottom; width: 16px; height: 16px' />" : E_16_PLUGIN;
}
else
{
$plugin_icon = $eplug_icon ? "<img src='".e_PLUGIN.$eplug_icon."' alt='' style='border:0px; vertical-align:bottom; width: 32px; height: 32px' />" : E_32_PLUGIN;
}
$plugin_array[ucfirst($eplug_name)] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".$plugin_id, 'icon' => $plugin_icon);
}
unset($eplug_conffile, $eplug_name, $eplug_caption, $eplug_icon_small);
}
}
ksort($plugin_array, SORT_STRING);
foreach ($plugin_array as $plug_key => $plug_value)
{
$text .= render_links($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $plug_value['icon'], $linkStyle);
}
return $text;
}
require_once("footer.php");
?>