1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00
php-e107/e107_admin/plugin.php

940 lines
29 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <EFBFBD>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
2009-07-07 02:43:14 +00:00
| $Revision: 1.25 $
| $Date: 2009-07-07 02:43:14 $
2009-07-07 02:22:57 +00:00
| $Author: e107coders $
2006-12-02 04:36:16 +00:00
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
if (!getperms("Z"))
{
2006-12-02 04:36:16 +00:00
header("location:".e_BASE."index.php");
exit;
}
$e_sub_cat = 'plug_manage';
2009-07-07 02:22:57 +00:00
define('PLUGIN_SHOW_REFRESH', FALSE);
global $user_pref;
2006-12-02 04:36:16 +00:00
require_once("auth.php");
require_once(e_HANDLER.'plugin_class.php');
require_once(e_HANDLER.'file_class.php');
2009-07-07 02:22:57 +00:00
require_once(e_HANDLER."form_handler.php");
2006-12-02 04:36:16 +00:00
$plugin = new e107plugin;
2009-07-07 02:22:57 +00:00
$frm = new e_form();
$pman = new pluginManager;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
require_once("footer.php");
exit;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
class pluginManager{
2009-07-07 02:22:57 +00:00
var $plugArray;
var $action;
var $id;
var $frm;
var $fields;
var $fieldpref;
2009-07-07 02:22:57 +00:00
function pluginManager()
{
2009-07-07 02:22:57 +00:00
global $user_pref,$admin_log;
$tmp = explode('.', e_QUERY);
$this -> action = $tmp[0];
$this -> id = intval($tmp[1]);
$this-> fields = array(
// "plugin_status" => array("title" => "Status", "type"=>"image", "width" => "5%", "thclass" => "center", "url" => ""),
2009-07-07 02:43:14 +00:00
"plugin_icon" => array("title" => EPL_ADLAN_82, "type"=>"image", "width" => "5%", "thclass" => "middle center", "url" => ""),
"plugin_name" => array("title" => EPL_ADLAN_10, "type"=>"text", "width" => "30", "thclass" => "middle", "url" => ""),
"plugin_version" => array("title" => EPL_ADLAN_11, "type"=>"numeric", "width" => "5%", "thclass" => "middle", "url" => ""),
"plugin_folder" => array("title" => EPL_ADLAN_64, "type"=>"text", "width" => "10%", "thclass" => "middle", "url" => ""),
"plugin_author" => array("title" => EPL_ADLAN_12, "type"=>"text", "width" => "auto", "thclass" => "middle", "url" => ""),
"plugin_website" => array("title" => EPL_WEBSITE, "type"=>"url", "width" => "5%", "thclass" => "middle center", "url" => ""),
"plugin_notes" => array("title" => EPL_ADLAN_83, "type"=>"url", "width" => "5%", "thclass" => "middle center", "url" => ""),
"plugin_description" => array("title" => EPL_ADLAN_14, "type"=>"text", "width" => "auto", "thclass" => "middle center", "url" => ""),
"plugin_compatible" => array("title" => EPL_ADLAN_13, "type"=>"text", "width" => "auto", "thclass" => "middle", "url" => ""),
"plugin_compliant" => array("title" => EPL_ADLAN_81, "type"=>"text", "width" => "5%", "thclass" => "middle center", "url" => ""),
"options" => array("title" => LAN_OPTIONS, "width" => "15%", "thclass" => "middle center last", "url" => "")
2009-07-07 02:22:57 +00:00
);
if (isset($_POST['upload']))
{
$this -> pluginProcessUpload();
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if(isset($_POST['submit-e-columns']))
{
2009-07-07 02:22:57 +00:00
$user_pref['admin_pluginmanager_columns'] = $_POST['e-columns'];
save_prefs('user');
}
2009-07-07 02:22:57 +00:00
$this -> fieldpref = (is_array($user_pref['admin_pluginmanager_columns'])) ? $user_pref['admin_pluginmanager_columns'] : array("plugin_icon","plugin_name","plugin_version","plugin_description","plugin_author","plugin_website","plugin_notes");
if($this->action == "" || $this->action == "installed" || $this->action == "avail")
{
2009-07-07 02:22:57 +00:00
$this -> pluginRenderList();
}
if($this->action == "uninstall")
{
$this -> pluginUninstall();
$this -> action = "installed";
$this -> pluginRenderList();
}
2009-07-07 02:22:57 +00:00
if($this->action == "install")
{
2009-07-07 02:22:57 +00:00
$this -> pluginInstall();
$this -> action = "installed";
$this -> pluginRenderList();
}
if($this->action == "upgrade")
{
$this -> pluginUpgrade();
$this -> action = "installed";
$this -> pluginRenderList();
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
if($this->action == "refresh")
{
$this -> pluginRefresh();
}
if($this->action == "upload")
{
2009-07-07 02:22:57 +00:00
$this -> pluginUpload();
}
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginUninstall()
{
global $plugin,$ns,$admin_log,$pref,$tp;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if(!isset($_POST['uninstall_confirm']))
{ // $id is already an integer
$this->pluginConfirmUninstall($this->id);
exit;
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
$plug = $plugin->getinfo($this->id);
$text = '';
//Uninstall Plugin
if ($plug['plugin_installflag'] == TRUE )
{
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml'))
{
2009-07-07 02:22:57 +00:00
$options = array(
'del_tables' => varset($_POST['delete_tables'],FALSE),
'del_userclasses' => varset($_POST['delete_userclasses'],FALSE),
'del_extended' => varset($_POST['delete_xfields'],FALSE)
);
$text .= $plugin->manage_plugin_xml($this->id, 'uninstall', $options);
}
else
{
2009-07-07 02:22:57 +00:00
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$func = $eplug_folder.'_uninstall';
if (function_exists($func))
{
$text .= call_user_func($func);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if($_POST['delete_tables'])
{
if (is_array($eplug_table_names))
{
$result = $plugin->manage_tables('remove', $eplug_table_names);
if ($result !== TRUE)
{
$text .= EPL_ADLAN_27.' <b>'.$mySQLprefix.$result.'</b> - '.EPL_ADLAN_30.'<br />';
}
else
{
$text .= EPL_ADLAN_28."<br />";
}
}
}
else
{
$text .= EPL_ADLAN_49."<br />";
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($eplug_prefs))
{
$plugin->manage_prefs('remove', $eplug_prefs);
$text .= EPL_ADLAN_29."<br />";
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($eplug_comment_ids))
{
$text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
/* Not used in 0.8
if ($eplug_module)
{
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
if ($eplug_status)
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
*/
if (is_array($eplug_array_pref))
{
foreach($eplug_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
}
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
/* Not used in 0.8
if (is_array($eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
*/
if ($eplug_menu_name)
{
$sql->db_Delete('menus', "menu_name='$eplug_menu_name' ");
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if ($eplug_link)
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$plugin->manage_link('remove', $eplug_link_url, $eplug_link_name);
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
if ($eplug_userclass)
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$plugin->manage_userclass('remove', $eplug_userclass);
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
$sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$this->id}' ");
$plugin->manage_search('remove', $eplug_folder);
$plugin->manage_notify('remove', $eplug_folder);
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$admin_log->log_event('PLUGMAN_03', $plug['plugin_path'], E_LOG_INFORMATIVE, '');
if (isset($pref['plug_installed'][$plug['plugin_path']]))
{
unset($pref['plug_installed'][$plug['plugin_path']]);
save_prefs();
}
2008-02-02 22:04:18 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if($_POST['delete_files'])
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
include_once(e_HANDLER."file_class.php");
$fi = new e_file;
$result = $fi->rmtree(e_PLUGIN.$eplug_folder);
$text .= ($result ? "<br />All files removed from ".e_PLUGIN.$eplug_folder : '<br />File deletion failed<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
else
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
$plugin->save_addon_prefs();
$ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text);
$text = '';
}
function pluginProcessUpload()
{
global $ns;
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
exit;
2008-02-02 22:04:18 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
extract($_FILES);
/* check if e_PLUGIN dir is writable ... */
if(!is_writable(e_PLUGIN))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
/* still not writable - spawn error message */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_39);
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
else
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
/* e_PLUGIN is writable - continue */
$pref['upload_storagetype'] = "1";
require_once(e_HANDLER."upload_handler.php");
$fileName = $file_userfile['name'][0];
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
if(strstr($file_userfile['type'][0], "gzip"))
2006-12-02 04:36:16 +00:00
{
2009-07-07 02:22:57 +00:00
$fileType = "tar";
}
else if (strstr($file_userfile['type'][0], "zip"))
{
$fileType = "zip";
}
else
{
/* not zip or tar - spawn error message */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_41);
require_once("footer.php");
exit;
2006-12-02 04:36:16 +00:00
}
2008-10-11 11:55:18 +00:00
2009-07-07 02:22:57 +00:00
if ($fileSize)
{
$opref = $pref['upload_storagetype'];
$pref['upload_storagetype'] = 1; /* temporarily set upload type pref to flatfile */
$uploaded = file_upload(e_PLUGIN);
$pref['upload_storagetype'] = $opref;
$archiveName = $uploaded[0]['name'];
/* attempt to unarchive ... */
if($fileType == "zip")
{
require_once(e_HANDLER."pclzip.lib.php");
$archive = new PclZip(e_PLUGIN.$archiveName);
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0666));
}
else
{
require_once(e_HANDLER."pcltar.lib.php");
$unarc = ($fileList = PclTarExtract($archiveName, e_PLUGIN));
}
if(!$unarc)
{
/* unarc failed ... */
if($fileType == "zip")
{
$error = EPL_ADLAN_46." '".$archive -> errorName(TRUE)."'";
}
else
{
$error = EPL_ADLAN_47.PclErrorString().", ".EPL_ADLAN_48.intval(PclErrorCode());
}
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_42." ".$archiveName." ".$error);
require_once("footer.php");
exit;
}
/* ok it looks like the unarc succeeded - continue */
/* get folder name ... */
$folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/")));
if(file_exists(e_PLUGIN.$folderName."/plugin.php") || file_exists(e_PLUGIN.$folderName."/plugin.xml"))
{
/* upload is a plugin */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_43);
}
else
{
/* upload is a menu */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_45);
}
/* attempt to delete uploaded archive */
@unlink(e_PLUGIN.$archiveName);
}
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
function pluginInstall()
{
global $ns,$plugin,$admin_log;
$text = $plugin->install_plugin($this->id);
if ($text === FALSE)
{ // Tidy this up
$ns->tablerender(LAN_INSTALL_FAIL, "Error messages above this line");
}
2009-07-07 02:22:57 +00:00
else
{
2009-07-07 02:22:57 +00:00
$plugin ->save_addon_prefs();
// if($eplug_conffile){ $text .= "&nbsp;<a href='".e_PLUGIN."$eplug_folder/$eplug_conffile'>[".LAN_CONFIGURE."]</a>"; }
$admin_log->log_event('PLUGMAN_01', $this->id.':'.$eplug_folder, E_LOG_INFORMATIVE, '');
$ns->tablerender(EPL_ADLAN_33, $text);
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
}
// -----------------------------------------------------------------------------
function pluginUpgrade()
{
global $plugin,$ns,$pref;
$plug = $plugin->getinfo($this->id);
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml'))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$text .= $plugin->manage_plugin_xml($this->id, 'upgrade');
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
else
{
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$func = $eplug_folder.'_upgrade';
if (function_exists($func))
{
$text .= call_user_func($func);
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_alter_tables))
{
$result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
if (!$result)
{
$text .= EPL_ADLAN_9.'<br />';
}
else
{
$text .= EPL_ADLAN_7."<br />";
}
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
/* Not used in 0.8
if ($eplug_module)
{
$plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ($eplug_status)
{
$plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
2009-07-07 02:22:57 +00:00
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_add_eplug_sc))
{
$plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_remove_eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_add_eplug_bb))
{
$plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_remove_eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
*/
if (is_array($upgrade_add_prefs))
{
$plugin->manage_prefs('add', $upgrade_add_prefs);
$text .= EPL_ADLAN_8.'<br />';
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_remove_prefs))
{
$plugin->manage_prefs('remove', $upgrade_remove_prefs);
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_add_array_pref))
{
foreach($upgrade_add_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
}
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if (is_array($upgrade_remove_array_pref))
{
foreach($upgrade_remove_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
}
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$plugin->manage_search('upgrade', $eplug_folder);
$plugin->manage_notify('upgrade', $eplug_folder);
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$eplug_addons = $plugin -> getAddons($eplug_folder);
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, '');
$text .= (isset($eplug_upgrade_done)) ? '<br />'.$eplug_upgrade_done : "<br />".LAN_UPGRADE_SUCCESSFUL;
$sql->db_Update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='$this->id' ");
$pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version
save_prefs();
}
$ns->tablerender(EPL_ADLAN_34, $text);
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$plugin->save_addon_prefs();
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
function pluginRefresh()
{
global $plug;
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$plug = $plugin->getinfo($this->id);
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml'))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$text .= $plugin->manage_plugin_xml($this->id, 'refresh');
$admin_log->log_event('PLUGMAN_04', $this->id.':'.$plug['plugin_path'], E_LOG_INFORMATIVE, '');
2008-02-02 22:04:18 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
// Check for new plugins, create entry in plugin table ...
function pluginCheck()
{
global $plugin;
$plugin->update_plugins_table();
}
// ----------------------------------------------------------
// render plugin information ...
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginUpload()
{
2009-07-07 02:22:57 +00:00
global $plugin,$ns,$frm;
2009-07-07 02:22:57 +00:00
/* plugin upload form */
2009-07-07 02:22:57 +00:00
if(!is_writable(e_PLUGIN))
{
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_44);
}
else
{
// Get largest allowable file upload
require_once(e_HANDLER.'upload_handler.php');
$max_file_size = get_user_max_upload();
$text = "
<form enctype='multipart/form-data' method='post' action='".e_SELF."'>
<table class='adminlist' cellpadding='0' cellspacing='0'>
<tr>
<td style='width: 50%;'>".EPL_ADLAN_37."</td>
<td style='width: 50%;'>
<input type='hidden' name='MAX_FILE_SIZE' value='{$max_file_size}' />
<input type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
<input class='tbox' type='file' name='file_userfile[]' size='50' />
</td>
</tr>
<tr>
<td colspan='2' class='center buttons-bar'>";
$text .= $frm->admin_button('upload', EPL_ADLAN_38, 'submit', EPL_ADLAN_38);
$text .= "
</td>
</tr>
</table>
</form>
<br />\n";
}
$ns->tablerender(EPL_ADLAN_16, $text);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginRenderList() // Uninstall and Install sorting should be fixed once and for all now !
{
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
global $plugin,$ns,$frm;
$text .= "
<form action='".e_SELF."?".e_QUERY."' id='pluginmanager_list' method='post'>
<fieldset id='core-newspost-list'>
<legend class='e-hideme'>".NWSLAN_4."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='".count($this->fieldpref)."'>".$frm->colGroup($this->fields,$this->fieldpref)."</colgroup>
<thead>
<tr>".$frm->thead($this->fields,$this->fieldpref)."</tr>
</thead>
<tbody>
";
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if($this->action == "" || $this->action == "installed")
{
$installed = $plugin->getall(1);
$caption = EPL_ADLAN_22;
$text .= $this->pluginRenderPlugin($installed);
}
if($this->action == "avail")
{
$uninstalled = $plugin->getall(0);
$caption = EPL_ADLAN_23;
$text .= $this->pluginRenderPlugin($uninstalled);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$text .= "
</tbody>
</table>
</fieldset>
</form>
";
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$ns->tablerender(EPL_ADLAN_16." : ".$caption, $text);
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2008-04-05 07:58:30 +00:00
2009-07-07 02:22:57 +00:00
function pluginRenderPlugin($pluginList)
{
2009-07-07 02:22:57 +00:00
global $tp, $imode, $plugin;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if (empty($pluginList)) return '';
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
foreach($pluginList as $plug)
{
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN.$plug['plugin_path'].'/';
$plug_vars = false;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if($plugin->parse_plugin($plug['plugin_path']))
{
$plug_vars = $plugin->plug_vars;
}
if($plug_vars)
{
2009-07-07 02:22:57 +00:00
$icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN : $_path).$plug_vars['administration']['icon'];
$plugin_icon = $plug_vars['administration']['icon'] ? "<img src='{$icon_src}' alt='' style='border:0px;vertical-align: bottom; width: 32px; height: 32px' />" : E_32_CAT_PLUG;
2009-07-07 02:43:14 +00:00
$conf_file = "#";
$conf_title = "";
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ($plug_vars['administration']['configFile'] && $plug['plugin_installflag'] == true)
{
2009-07-07 02:43:14 +00:00
$conf_file = e_PLUGIN.$plug['plugin_path'].'/'.$plug_vars['administration']['configFile'];
2009-07-07 02:22:57 +00:00
$conf_title = LAN_CONFIGURE.' '.$tp->toHtml($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable");
2009-07-07 02:43:14 +00:00
$plugin_icon = "<a title='{$conf_title}' href='{$conf_file}' >".$plugin_icon.'</a>';
2009-07-07 02:22:57 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$plugEmail = varset($plug_vars['author']['@attributes']['email'],'');
$plugAuthor = varset($plug_vars['author']['@attributes']['name'],'');
$plugURL = varset($plug_vars['author']['@attributes']['url'],'');
$plugReadme = "";
2009-07-07 02:43:14 +00:00
if($plug['plugin_installflag'])
{
$plugName = "<a title='{$conf_title}' href='{$conf_file}' >".$tp->toHTML($plug['plugin_name'], false, "defs,emotes_off, no_make_clickable")."</a>";
}
else
{
$plugName = $tp->toHTML($plug['plugin_name'], false, "defs,emotes_off, no_make_clickable");
}
2009-07-07 02:22:57 +00:00
if($plug_vars['readme']) // 0.7 plugin.php
{
$plugReadme = $plug_vars['readme'];
}
if($plug_vars['readMe']) // 0.8 plugin.xml
{
$plugReadme = $plug_vars['readMe'];
}
$text .= "<tr>";
// $text .= (in_array("plugin_status",$this->fieldpref)) ? "<td class='center'>".$img."</td>" : "";
$text .= (in_array("plugin_icon",$this->fieldpref)) ? "<td class='center middle'>".$plugin_icon."</td>" : "";
2009-07-07 02:43:14 +00:00
$text .= (in_array("plugin_name",$this->fieldpref)) ? "<td class='middle'>".$plugName."</td>" : "";
2009-07-07 02:22:57 +00:00
$text .= (in_array("plugin_version",$this->fieldpref)) ? "<td class='middle'>".$plug['plugin_version']."</td>" : "";
$text .= (in_array("plugin_folder",$this->fieldpref)) ? "<td class='middle'>".$plug['plugin_path']."</td>" : "";
$text .= (in_array("plugin_author",$this->fieldpref)) ? "<td class='middle'><a href='mailto:".$plugEmail."' title='".$plugEmail."'>".$plugAuthor."</a>&nbsp;</td>" : "";
$text .= (in_array("plugin_website",$this->fieldpref)) ? "<td class='center middle'>".($plugURL ? "<a href='{$plugURL}' title='{$plugURL}' ><img src='".e_IMAGE_ABS."admin_images/forums_16.png' alt='' style='border:0px' /></a>" : "")."</td>" : "";
$text .= (in_array("plugin_notes",$this->fieldpref)) ? "<td class='center middle'>".($plugReadme ? "<a href='".e_PLUGIN.$plug['plugin_path']."/".$plugReadme."' title='".$plugReadme."'><img src='".e_IMAGE_ABS."admin_images/info_16.png' alt='' style='border:0px' /></a>" : "&nbsp;")."</td>" : "";
$text .= (in_array("plugin_description",$this->fieldpref)) ? "<td class='middle'>".$tp->toHTML($plug_vars['description'], false, "defs,emotes_off, no_make_clickable")."</td>" : "";
$text .= (in_array("plugin_compatible",$this->fieldpref)) ? "<td class='center middle'>".varset($plug_vars['@attributes']['compatibility'],'')."</td>" : "";
$text .= (in_array("plugin_compliant",$this->fieldpref)) ? "<td class='center middle'>".(($plug_vars['compliant'] || $plug_vars['@attributes']['xhtmlcompliant']=="true") ? ADMIN_TRUE_ICON : "&nbsp;")."</td>" : "";
// Plugin options Column --------------
$text .= "<td class='center middle'>";
if ($plug_vars['@attributes']['installRequired'])
{
if ($plug['plugin_installflag'])
{
$text .= ($plug['plugin_installflag'] ? "<a href=\"".e_SELF."?uninstall.{$plug['plugin_id']}'\" title='".EPL_ADLAN_1."' >".ADMIN_DELETE_ICON."</a>" : "<a href=\"".e_SELF."?install.{$plug['plugin_id']}\" title='".EPL_ADLAN_0."' ><img class='middle' src='".e_IMAGE_ABS."admin_images/plugins_16.png' alt=\"".EPL_ADLAN_0."\" style='border:0px' /></a>");
// $text .= ($plug['plugin_installflag'] ? "<button type='button' class='delete' value='".EPL_ADLAN_1."' onclick=\"location.href='".e_SELF."?uninstall.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_1."</span></button>" : "<button type='button' class='update' value='".EPL_ADLAN_0."' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>");
if (PLUGIN_SHOW_REFRESH && !varsettrue($plug_vars['plugin_php']))
{
$text .= "<br /><br /><input type='button' class='button' onclick=\"location.href='".e_SELF."?refresh.{$plug['plugin_id']}'\" title='".'Refresh plugin settings'."' value='".'Refresh plugin settings'."' /> ";
}
}
else
{
// $text .= "<input type='button' class='button' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />";
// $text .= "<button type='button' class='update' value='".EPL_ADLAN_0."' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>";
$text .= "<a href=\"".e_SELF."?install.{$plug['plugin_id']}\" title='".EPL_ADLAN_0."' ><img class='middle' src='".e_IMAGE_ABS."admin_images/plugins_16.png' alt=\"".EPL_ADLAN_0."\" style='border:0px' /></a>";
}
}
else
{
if ($plug_vars['menuName'])
{
$text .= EPL_NOINSTALL.str_replace("..", "", e_PLUGIN.$plug['plugin_path'])."/ ".EPL_DIRECTORY;
}
else
{
$text .= EPL_NOINSTALL_1.str_replace("..", "", e_PLUGIN.$plug['plugin_path'])."/ ".EPL_DIRECTORY;
if($plug['plugin_installflag'] == false)
{
global $sql;
$sql->db_Delete('plugin', "plugin_installflag=0 AND (plugin_path='{$plug['plugin_path']}' OR plugin_path='{$plug['plugin_path']}/' ) ");
}
}
}
if ($plug['plugin_version'] != $plug_vars['@attributes']['version'] && $plug['plugin_installflag'])
{
// $text .= "<br /><input type='button' class='button' onclick=\"location.href='".e_SELF."?upgrade.{$plug['plugin_id']}'\" title='".EPL_UPGRADE." to v".$plug_vars['@attributes']['version']."' value='".EPL_UPGRADE."' />";
$text .= "<a href='".e_SELF."?upgrade.{$plug['plugin_id']}' title=\"".EPL_UPGRADE." to v".$plug_vars['@attributes']['version']."\" ><img class='middle' src='".e_IMAGE_ABS."admin_images/up_16.png' alt=\"".EPL_UPGRADE."\" style='border:0px' /></a>";
}
$text .="</td>";
$text .= "</tr>";
}
}
2009-07-07 02:22:57 +00:00
return $text;
}
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginConfirmUninstall()
{
global $plugin, $tp, $ns;
$plug = $plugin->getinfo($this->id);
if ($plug['plugin_installflag'] == true )
{
2009-07-07 02:22:57 +00:00
if($plugin->parse_plugin($plug['plugin_path']))
{
2009-07-07 02:22:57 +00:00
$plug_vars = $plugin->plug_vars;
}
else
{
2009-07-07 02:22:57 +00:00
return FALSE;
}
}
else
{
2009-07-07 02:22:57 +00:00
return FALSE;
}
$userclasses = '';
$eufields = '';
if (isset($plug_vars['userclass']))
{
if (isset($plug_vars['userclass']['@attributes']))
{
2009-07-07 02:22:57 +00:00
$plug_vars['userclass'][0]['@attributes'] = $plug_vars['userclass']['@attributes'];
unset($plug_vars['userclass']['@attributes']);
}
2009-07-07 02:22:57 +00:00
$spacer = '';
foreach ($plug_vars['userclass'] as $uc)
{
2009-07-07 02:22:57 +00:00
$userclasses .= $spacer.$uc['@attributes']['name'].' - '.$uc['@attributes']['description'];
$spacer = '<br />';
}
}
if (isset($plug_vars['extendedField']))
{
if (isset($plug_vars['extendedField']['@attributes']))
{
$plug_vars['extendedField'][0]['@attributes'] = $plug_vars['extendedField']['@attributes'];
unset($plug_vars['extendedField']['@attributes']);
}
$spacer = '';
foreach ($plug_vars['extendedField'] as $eu)
{
$eufields .= $spacer.'plugin_'.$plug_vars['folder'].'_'.$eu['@attributes']['name'];
$spacer = '<br />';
}
}
2009-07-07 02:22:57 +00:00
if(is_writable(e_PLUGIN.$plug['plugin_path']))
{
$del_text = "
<select class='tbox' name='delete_files'>
<option value='0'>".LAN_NO."</option>
<option value='1'>".LAN_YES."</option>
</select>
";
}
else
{
$del_text = "
".EPL_ADLAN_53."
<input type='hidden' name='delete_files' value='0' />
";
}
2009-07-07 02:22:57 +00:00
$text = "
<form action='".e_SELF."?".e_QUERY."' method='post'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<colgroup>
<col style='width:75%' />
<col style='width:25%' />
</colgroup>
<tr>
<td colspan='2' class='forumheader'>".EPL_ADLAN_54." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable")."</td>
</tr>
<tr>
<td class='forumheader3'>".EPL_ADLAN_55."</td>
<td class='forumheader3'>".LAN_YES."</td>
</tr>
<tr>
<td class='forumheader3'>
".EPL_ADLAN_57."<div class='smalltext'>".EPL_ADLAN_58."</div>
</td>
<td class='forumheader3'>
<select class='tbox' name='delete_tables'>
<option value='1'>".LAN_YES."</option>
<option value='0'>".LAN_NO."</option>
</select>
</td>
</tr>";
if ($userclasses)
{
$text .= " <tr>
<td class='forumheader3'>
".EPL_ADLAN_78."<div class='indent'>".$userclasses."</div><div class='smalltext'>".EPL_ADLAN_79."</div>
</td>
<td class='forumheader3'>
<select class='tbox' name='delete_userclasses'>
<option value='1'>".LAN_YES."</option>
<option value='0'>".LAN_NO."</option>
</select>
</td>
</tr>";
}
if ($eufields)
{
$text .= " <tr>
<td class='forumheader3'>
".EPL_ADLAN_80."<div class='indent'>".$eufields."</div><div class='smalltext'>".EPL_ADLAN_79."</div>
</td>
<td class='forumheader3'>
<select class='tbox' name='delete_xfields'>
<option value='1'>".LAN_YES."</option>
<option value='0'>".LAN_NO."</option>
</select>
</td>
</tr>";
}
$text .="<tr>
<td class='forumheader3'>".EPL_ADLAN_59."<div class='smalltext'>".EPL_ADLAN_60."</div></td>
<td class='forumheader3'>{$del_text}</td>
</tr>
<tr>
<td colspan='2' class='forumheader' style='text-align:center'><input class='button' type='submit' name='uninstall_confirm' value=\"".EPL_ADLAN_3."\" />&nbsp;&nbsp;<input class='button' type='submit' name='uninstall_cancel' value='".EPL_ADLAN_62."' onclick=\"location.href='".e_SELF."'; return false;\"/></td>
</tr>
</table>
</form>
";
$ns->tablerender(EPL_ADLAN_63." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable"), $text);
require_once(e_ADMIN."footer.php");
exit;
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
} // end of Class.
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function plugin_adminmenu()
2006-12-02 04:36:16 +00:00
{
2009-07-07 02:22:57 +00:00
// $e107 = &e107::getInstance();
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$var['installed']['text'] = EPL_ADLAN_22;
$var['installed']['link'] = e_SELF;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$var['avail']['text'] = EPL_ADLAN_23;
$var['avail']['link'] = e_SELF."?avail";
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
/* $var['choose']['text'] = TPVLAN_51;
$var['choose']['link'] = e_SELF."?choose";*/
2009-07-07 02:22:57 +00:00
$var['upload']['text'] = EPL_ADLAN_38;
$var['upload']['link'] = e_SELF."?upload";
2009-07-07 02:22:57 +00:00
$selected = (e_QUERY) ? e_QUERY : "installed";
e_admin_menu(ADLAN_98, $selected, $var);
2006-12-02 04:36:16 +00:00
}
?>