diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 3048c24be..4fd8018ab 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $ -| $Revision: 1.23 $ -| $Date: 2008-12-30 19:01:09 $ -| $Author: e107steved $ +| $Revision: 1.24 $ +| $Date: 2009-07-07 02:22:57 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -24,746 +24,907 @@ if (!getperms("Z")) exit; } $e_sub_cat = 'plug_manage'; -require_once("auth.php"); -require_once(e_HANDLER.'plugin_class.php'); -require_once(e_HANDLER.'file_class.php'); -$plugin = new e107plugin; - -$tmp = explode('.', e_QUERY); -$action = $tmp[0]; -$id = intval($tmp[1]); define('PLUGIN_SHOW_REFRESH', FALSE); +global $user_pref; -if (isset($_POST['upload'])) -{ - if (!$_POST['ac'] == md5(ADMINPWCHANGE)) - { - exit; - } +require_once("auth.php"); +require_once(e_HANDLER.'plugin_class.php'); +require_once(e_HANDLER.'file_class.php'); +require_once(e_HANDLER."form_handler.php"); - extract($_FILES); - /* check if e_PLUGIN dir is writable ... */ - if(!is_writable(e_PLUGIN)) - { - /* still not writable - spawn error message */ - $ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_39); - } - else - { - /* 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")) - { - $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; - } - - 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); - } - } -} - - -if ($action == 'uninstall') -{ - if(!isset($_POST['uninstall_confirm'])) - { // $id is already an integer - show_uninstall_confirm($id); - exit; - } - - $plug = $plugin->getinfo($id); - $text = ''; - //Uninstall Plugin - if ($plug['plugin_installflag'] == TRUE ) - { - $_path = e_PLUGIN.$plug['plugin_path'].'/'; - if(file_exists($_path.'plugin.xml')) - { - $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($id, 'uninstall', $options); - } - else - { - include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); - - $func = $eplug_folder.'_uninstall'; - if (function_exists($func)) - { - $text .= call_user_func($func); - } - - 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.' '.$mySQLprefix.$result.' - '.EPL_ADLAN_30.'
'; - } - else - { - $text .= EPL_ADLAN_28."
"; - } - } - } - else - { - $text .= EPL_ADLAN_49."
"; - } - - if (is_array($eplug_prefs)) - { - $plugin->manage_prefs('remove', $eplug_prefs); - $text .= EPL_ADLAN_29."
"; - } - - if (is_array($eplug_comment_ids)) - { - $text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."
" : ""; - } - -/* 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); - } - - 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); - } - } - -/* Not used in 0.8 - if (is_array($eplug_sc)) - { - $plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc); - } - - 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' "); - } - - if ($eplug_link) - { - $plugin->manage_link('remove', $eplug_link_url, $eplug_link_name); - } - - if ($eplug_userclass) - { - $plugin->manage_userclass('remove', $eplug_userclass); - } - - $sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$id}' "); - $plugin->manage_search('remove', $eplug_folder); - - $plugin->manage_notify('remove', $eplug_folder); - } - - $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(); - } - } - - if($_POST['delete_files']) - { - include_once(e_HANDLER."file_class.php"); - $fi = new e_file; - $result = $fi->rmtree(e_PLUGIN.$eplug_folder); - $text .= ($result ? "
All files removed from ".e_PLUGIN.$eplug_folder : '
File deletion failed
'.EPL_ADLAN_31.' '.e_PLUGIN.$eplug_folder.' '.EPL_ADLAN_32); - } - else - { - $text .= '
'.EPL_ADLAN_31.' '.e_PLUGIN.$eplug_folder.' '.EPL_ADLAN_32; - } - - $plugin->save_addon_prefs(); - $ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text); - $text = ''; -} - - -if ($action == 'install') -{ - $text = $plugin->install_plugin($id); - if ($text === FALSE) - { // Tidy this up - $ns->tablerender(LAN_INSTALL_FAIL, "Error messages above this line"); - } - else - { - $plugin ->save_addon_prefs(); -// if($eplug_conffile){ $text .= " [".LAN_CONFIGURE."]"; } - $admin_log->log_event('PLUGMAN_01', $id.':'.$eplug_folder, E_LOG_INFORMATIVE, ''); - $ns->tablerender(EPL_ADLAN_33, $text); - } -} - -if ($action == 'upgrade') -{ - $plug = $plugin->getinfo($id); - - $_path = e_PLUGIN.$plug['plugin_path'].'/'; - if(file_exists($_path.'plugin.xml')) - { - $text .= $plugin->manage_plugin_xml($id, 'upgrade'); - } - else - { - include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); - - $func = $eplug_folder.'_upgrade'; - if (function_exists($func)) - { - $text .= call_user_func($func); - } - - if (is_array($upgrade_alter_tables)) - { - $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables); - if (!$result) - { - $text .= EPL_ADLAN_9.'
'; - } - else - { - $text .= EPL_ADLAN_7."
"; - } - } - -/* 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); - } - - if ($eplug_status) - { - $plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder); - } - else - { - $plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder); - } - - if ($eplug_latest) - { - $plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder); - } - else - { - $plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder); - } - - if (is_array($upgrade_add_eplug_sc)) - { - $plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc); - } - - if (is_array($upgrade_remove_eplug_sc)) - { - $plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc); - } - - if (is_array($upgrade_add_eplug_bb)) - { - $plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb); - } - - 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.'
'; - } - - if (is_array($upgrade_remove_prefs)) - { - $plugin->manage_prefs('remove', $upgrade_remove_prefs); - } - - if (is_array($upgrade_add_array_pref)) - { - foreach($upgrade_add_array_pref as $key => $val) - { - $plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val); - } - } - - if (is_array($upgrade_remove_array_pref)) - { - foreach($upgrade_remove_array_pref as $key => $val) - { - $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val); - } - } - - $plugin->manage_search('upgrade', $eplug_folder); - $plugin->manage_notify('upgrade', $eplug_folder); - - $eplug_addons = $plugin -> getAddons($eplug_folder); - - $admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, ''); - $text .= (isset($eplug_upgrade_done)) ? '
'.$eplug_upgrade_done : "
".LAN_UPGRADE_SUCCESSFUL; - $sql->db_Update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='$id' "); - $pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version - save_prefs(); - } - $ns->tablerender(EPL_ADLAN_34, $text); - - $plugin->save_addon_prefs(); -} - - -if ($action == 'refresh') -{ - $plug = $plugin->getinfo($id); - - $_path = e_PLUGIN.$plug['plugin_path'].'/'; - if(file_exists($_path.'plugin.xml')) - { - $text .= $plugin->manage_plugin_xml($id, 'refresh'); - $admin_log->log_event('PLUGMAN_04', $id.':'.$plug['plugin_path'], E_LOG_INFORMATIVE, ''); - } -} - - -// Check for new plugins, create entry in plugin table ... - -$plugin->update_plugins_table(); - -// ---------------------------------------------------------- -// render plugin information ... - -/* plugin upload form */ - -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 = "
-
- - - - - - - - -
".EPL_ADLAN_37." - - - -
- -
-
-
\n"; -} -// Uninstall and Install sorting should be fixed once and for all now ! -$installed = $plugin->getall(1); -$uninstalled = $plugin->getall(0); - -$text .= ""; -$text .= ""; -$text .= render_plugs($installed); -$text .= ""; -$text .= render_plugs($uninstalled); - - -function render_plugs($pluginList) -{ - global $tp, $imode, $plugin; - - if (empty($pluginList)) return ''; - - foreach($pluginList as $plug) - { - $_path = e_PLUGIN.$plug['plugin_path'].'/'; - $plug_vars = false; -// if($plugin->parse_plugin($_path)) - if($plugin->parse_plugin($plug['plugin_path'])) - { - $plug_vars = $plugin->plug_vars; - } - if($plug_vars) - { - - if ($plug_vars['@attributes']['installRequired']) - { - $img = (!$plug['plugin_installflag'] ? "" : ""); - } - else - { - $img = ""; - } - - if ($plug['plugin_version'] != $plug_vars['@attributes']['version'] && $plug['plugin_installflag']) - { - $img = ""; - } - - $icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN : $_path).$plug_vars['administration']['icon']; - $plugin_icon = $plug_vars['administration']['icon'] ? "" : E_32_CAT_PLUG; - - if ($plug_vars['administration']['configFile'] && $plug['plugin_installflag'] == true) - { - $conf_title = LAN_CONFIGURE.' '.$tp->toHtml($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable"); - $plugin_icon = "".$plugin_icon.''; - } - - $plugEmail = varset($plug_vars['author']['@attributes']['email'],''); - $plugAuthor = varset($plug_vars['author']['@attributes']['name'],''); - $plugURL = varset($plug_vars['author']['@attributes']['url'],''); - $text .= " - - - "; - $text .= ""; - $text .= ""; - } - } - return $text; -} - -$text .= "
".EPL_ADLAN_22."
".EPL_ADLAN_23."
- -
- ".$plugin_icon." - - {$img} ".$tp->toHTML($plug['plugin_name'], false, "defs,emotes_off, no_make_clickable")."
".EPL_ADLAN_11." {$plug['plugin_version']} -

- ".EPL_ADLAN_64." ".$plug['plugin_path']." -
-
-
- - - - - \n"; - - $text .= "
".EPL_ADLAN_12.":{$plugAuthor} "; - if($plugURL) - { - $text .= "  [ ".EPL_WEBSITE." ] "; - } - $text .="
".EPL_ADLAN_14.": ".$tp->toHTML($plug_vars['description'], false, "defs,emotes_off, no_make_clickable")." "; - if ($plug_vars['readme']) - { - $text .= "[ ".$plug_vars['readme']." ]"; - } - - $text .="
".EPL_ADLAN_13.": ".varset($plug_vars['@attributes']['compatibility'],'')." "; - - if ($plug_vars['compliant']) - { - $text .= "  "; - } - $text .="
"; - - if ($plug_vars['@attributes']['installRequired']) - { - if ($plug['plugin_installflag']) - { - $text .= ($plug['plugin_installflag'] ? " " : ""); - if (PLUGIN_SHOW_REFRESH && !varsettrue($plug_vars['plugin_php'])) - { - $text .= "

"; - } - } - else - { - $text .= ""; - } - } - 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 .= "
"; - } - - $text .="
-

- ".EPL_ADLAN_23."   - ".EPL_ADLAN_22."   - ".EPL_ADLAN_24."   - ".EPL_ADLAN_25."
"; - -$ns->tablerender(EPL_ADLAN_16, $text); -// ---------------------------------------------------------- +$plugin = new e107plugin; +$frm = new e_form(); +$pman = new pluginManager; require_once("footer.php"); exit; -function show_uninstall_confirm($id) +class pluginManager{ + + var $plugArray; + var $action; + var $id; + var $frm; + var $fields; + var $fieldpref; + + function pluginManager() + { + 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" => ""), + "plugin_icon" => array("title" => EPL_ADLAN_82, "type"=>"image", "width" => "5%", "thclass" => "center", "url" => ""), + "plugin_name" => array("title" => EPL_ADLAN_10, "type"=>"text", "width" => "30", "thclass" => "", "url" => ""), + "plugin_version" => array("title" => EPL_ADLAN_11, "type"=>"numeric", "width" => "5%", "thclass" => "", "url" => ""), + "plugin_folder" => array("title" => EPL_ADLAN_64, "type"=>"text", "width" => "10%", "thclass" => "", "url" => ""), + "plugin_author" => array("title" => EPL_ADLAN_12, "type"=>"text", "width" => "auto", "thclass" => "", "url" => ""), + "plugin_website" => array("title" => EPL_WEBSITE, "type"=>"url", "width" => "5%", "thclass" => "center", "url" => ""), + "plugin_notes" => array("title" => EPL_ADLAN_83, "type"=>"url", "width" => "5%", "thclass" => "center", "url" => ""), + "plugin_description" => array("title" => EPL_ADLAN_14, "type"=>"text", "width" => "auto", "thclass" => "center", "url" => ""), + "plugin_compatible" => array("title" => EPL_ADLAN_13, "type"=>"text", "width" => "auto", "thclass" => "", "url" => ""), + "plugin_compliant" => array("title" => EPL_ADLAN_81, "type"=>"text", "width" => "5%", "thclass" => "center", "url" => ""), + "options" => array("title" => LAN_OPTIONS, "width" => "15%", "thclass" => "center last", "url" => "") + ); + + if (isset($_POST['upload'])) + { + $this -> pluginProcessUpload(); + } + + if(isset($_POST['submit-e-columns'])) + { + $user_pref['admin_pluginmanager_columns'] = $_POST['e-columns']; + save_prefs('user'); + } + + $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") + { + $this -> pluginRenderList(); + } + + + if($this->action == "uninstall") + { + $this -> pluginUninstall(); + $this -> action = "installed"; + $this -> pluginRenderList(); + } + + if($this->action == "install") + { + $this -> pluginInstall(); + $this -> action = "installed"; + $this -> pluginRenderList(); + } + + if($this->action == "upgrade") + { + $this -> pluginUpgrade(); + $this -> action = "installed"; + $this -> pluginRenderList(); + } + + if($this->action == "refresh") + { + $this -> pluginRefresh(); + } + if($this->action == "upload") + { + $this -> pluginUpload(); + } + } + + + + function pluginUninstall() + { + global $plugin,$ns,$admin_log,$pref,$tp; + + if(!isset($_POST['uninstall_confirm'])) + { // $id is already an integer + $this->pluginConfirmUninstall($this->id); + exit; + } + + $plug = $plugin->getinfo($this->id); + $text = ''; + //Uninstall Plugin + if ($plug['plugin_installflag'] == TRUE ) + { + $_path = e_PLUGIN.$plug['plugin_path'].'/'; + if(file_exists($_path.'plugin.xml')) + { + $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 + { + include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); + + $func = $eplug_folder.'_uninstall'; + if (function_exists($func)) + { + $text .= call_user_func($func); + } + + 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.' '.$mySQLprefix.$result.' - '.EPL_ADLAN_30.'
'; + } + else + { + $text .= EPL_ADLAN_28."
"; + } + } + } + else + { + $text .= EPL_ADLAN_49."
"; + } + + if (is_array($eplug_prefs)) + { + $plugin->manage_prefs('remove', $eplug_prefs); + $text .= EPL_ADLAN_29."
"; + } + + if (is_array($eplug_comment_ids)) + { + $text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."
" : ""; + } + + /* 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); + } + + 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); + } + } + + /* Not used in 0.8 + if (is_array($eplug_sc)) + { + $plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc); + } + + 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' "); + } + + if ($eplug_link) + { + $plugin->manage_link('remove', $eplug_link_url, $eplug_link_name); + } + + if ($eplug_userclass) + { + $plugin->manage_userclass('remove', $eplug_userclass); + } + + $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); + } + + $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(); + } + } + + if($_POST['delete_files']) + { + include_once(e_HANDLER."file_class.php"); + $fi = new e_file; + $result = $fi->rmtree(e_PLUGIN.$eplug_folder); + $text .= ($result ? "
All files removed from ".e_PLUGIN.$eplug_folder : '
File deletion failed
'.EPL_ADLAN_31.' '.e_PLUGIN.$eplug_folder.' '.EPL_ADLAN_32); + } + else + { + $text .= '
'.EPL_ADLAN_31.' '.e_PLUGIN.$eplug_folder.' '.EPL_ADLAN_32; + } + + $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)) + { + exit; + } + + extract($_FILES); + /* check if e_PLUGIN dir is writable ... */ + if(!is_writable(e_PLUGIN)) + { + /* still not writable - spawn error message */ + $ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_39); + } + else + { + /* 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")) + { + $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; + } + + 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); + } + } + } + + +// ----------------------------------------------------------------------------- + + 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"); + } + else + { + $plugin ->save_addon_prefs(); + // if($eplug_conffile){ $text .= " [".LAN_CONFIGURE."]"; } + $admin_log->log_event('PLUGMAN_01', $this->id.':'.$eplug_folder, E_LOG_INFORMATIVE, ''); + $ns->tablerender(EPL_ADLAN_33, $text); + } + + } + + +// ----------------------------------------------------------------------------- + + function pluginUpgrade() + { + global $plugin,$ns,$pref; + + $plug = $plugin->getinfo($this->id); + + $_path = e_PLUGIN.$plug['plugin_path'].'/'; + if(file_exists($_path.'plugin.xml')) + { + $text .= $plugin->manage_plugin_xml($this->id, 'upgrade'); + } + else + { + include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); + + $func = $eplug_folder.'_upgrade'; + if (function_exists($func)) + { + $text .= call_user_func($func); + } + + if (is_array($upgrade_alter_tables)) + { + $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables); + if (!$result) + { + $text .= EPL_ADLAN_9.'
'; + } + else + { + $text .= EPL_ADLAN_7."
"; + } + } + + /* 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); + } + + if ($eplug_status) + { + $plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder); + } + else + { + $plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder); + } + + if ($eplug_latest) + { + $plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder); + } + else + { + $plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder); + } + + if (is_array($upgrade_add_eplug_sc)) + { + $plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc); + } + + if (is_array($upgrade_remove_eplug_sc)) + { + $plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc); + } + + if (is_array($upgrade_add_eplug_bb)) + { + $plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb); + } + + 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.'
'; + } + + if (is_array($upgrade_remove_prefs)) + { + $plugin->manage_prefs('remove', $upgrade_remove_prefs); + } + + if (is_array($upgrade_add_array_pref)) + { + foreach($upgrade_add_array_pref as $key => $val) + { + $plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val); + } + } + + if (is_array($upgrade_remove_array_pref)) + { + foreach($upgrade_remove_array_pref as $key => $val) + { + $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val); + } + } + + $plugin->manage_search('upgrade', $eplug_folder); + $plugin->manage_notify('upgrade', $eplug_folder); + + $eplug_addons = $plugin -> getAddons($eplug_folder); + + $admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, ''); + $text .= (isset($eplug_upgrade_done)) ? '
'.$eplug_upgrade_done : "
".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); + + $plugin->save_addon_prefs(); + + } + + +// ----------------------------------------------------------------------------- + + function pluginRefresh() + { + global $plug; + + $plug = $plugin->getinfo($this->id); + + $_path = e_PLUGIN.$plug['plugin_path'].'/'; + if(file_exists($_path.'plugin.xml')) + { + $text .= $plugin->manage_plugin_xml($this->id, 'refresh'); + $admin_log->log_event('PLUGMAN_04', $this->id.':'.$plug['plugin_path'], E_LOG_INFORMATIVE, ''); + } + + } + +// ----------------------------------------------------------------------------- + + // Check for new plugins, create entry in plugin table ... + function pluginCheck() + { + global $plugin; + $plugin->update_plugins_table(); + } + // ---------------------------------------------------------- + // render plugin information ... + + +// ----------------------------------------------------------------------------- + + + function pluginUpload() + { + global $plugin,$ns,$frm; + + /* plugin upload form */ + + 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 = " +
+ + + + + + + + +
".EPL_ADLAN_37." + + + +
"; + $text .= $frm->admin_button('upload', EPL_ADLAN_38, 'submit', EPL_ADLAN_38); + + $text .= " +
+
+
\n"; + } + + $ns->tablerender(EPL_ADLAN_16, $text); + } + +// ----------------------------------------------------------------------------- + + function pluginRenderList() // Uninstall and Install sorting should be fixed once and for all now ! + { + + global $plugin,$ns,$frm; + + $text .= " +
+
+ ".NWSLAN_4." + + ".$frm->colGroup($this->fields,$this->fieldpref)." + + ".$frm->thead($this->fields,$this->fieldpref)." + + + "; + + 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); + } + + $text .= " + +
+
+
+ "; + + $ns->tablerender(EPL_ADLAN_16." : ".$caption, $text); + } + + +// ----------------------------------------------------------------------------- + + function pluginRenderPlugin($pluginList) + { + global $tp, $imode, $plugin; + + if (empty($pluginList)) return ''; + + foreach($pluginList as $plug) + { + $_path = e_PLUGIN.$plug['plugin_path'].'/'; + $plug_vars = false; + + if($plugin->parse_plugin($plug['plugin_path'])) + { + $plug_vars = $plugin->plug_vars; + } + if($plug_vars) + { + + $icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN : $_path).$plug_vars['administration']['icon']; + $plugin_icon = $plug_vars['administration']['icon'] ? "" : E_32_CAT_PLUG; + + if ($plug_vars['administration']['configFile'] && $plug['plugin_installflag'] == true) + { + $conf_title = LAN_CONFIGURE.' '.$tp->toHtml($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable"); + $plugin_icon = "".$plugin_icon.''; + } + + $plugEmail = varset($plug_vars['author']['@attributes']['email'],''); + $plugAuthor = varset($plug_vars['author']['@attributes']['name'],''); + $plugURL = varset($plug_vars['author']['@attributes']['url'],''); + $plugReadme = ""; + + 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 .= ""; + // $text .= (in_array("plugin_status",$this->fieldpref)) ? "".$img."" : ""; + $text .= (in_array("plugin_icon",$this->fieldpref)) ? "".$plugin_icon."" : ""; + $text .= (in_array("plugin_name",$this->fieldpref)) ? "".$tp->toHTML($plug['plugin_name'], false, "defs,emotes_off, no_make_clickable")."" : ""; + $text .= (in_array("plugin_version",$this->fieldpref)) ? "".$plug['plugin_version']."" : ""; + $text .= (in_array("plugin_folder",$this->fieldpref)) ? "".$plug['plugin_path']."" : ""; + $text .= (in_array("plugin_author",$this->fieldpref)) ? "".$plugAuthor." " : ""; + $text .= (in_array("plugin_website",$this->fieldpref)) ? "".($plugURL ? "" : "")."" : ""; + $text .= (in_array("plugin_notes",$this->fieldpref)) ? "".($plugReadme ? "" : " ")."" : ""; + $text .= (in_array("plugin_description",$this->fieldpref)) ? "".$tp->toHTML($plug_vars['description'], false, "defs,emotes_off, no_make_clickable")."" : ""; + $text .= (in_array("plugin_compatible",$this->fieldpref)) ? "".varset($plug_vars['@attributes']['compatibility'],'')."" : ""; + $text .= (in_array("plugin_compliant",$this->fieldpref)) ? "".(($plug_vars['compliant'] || $plug_vars['@attributes']['xhtmlcompliant']=="true") ? ADMIN_TRUE_ICON : " ")."" : ""; + + + // Plugin options Column -------------- + + $text .= ""; + + if ($plug_vars['@attributes']['installRequired']) + { + if ($plug['plugin_installflag']) + { + $text .= ($plug['plugin_installflag'] ? "".ADMIN_DELETE_ICON."" : "\"".EPL_ADLAN_0."\""); + + // $text .= ($plug['plugin_installflag'] ? "" : ""); + if (PLUGIN_SHOW_REFRESH && !varsettrue($plug_vars['plugin_php'])) + { + $text .= "

"; + } + } + else + { + // $text .= ""; + // $text .= ""; + $text .= "\"".EPL_ADLAN_0."\""; + } + } + 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 .= "
"; + $text .= "\"".EPL_UPGRADE."\""; + } + + $text .=""; + $text .= ""; + + } + } + return $text; + } + + +// ----------------------------------------------------------------------------- + + + + function pluginConfirmUninstall() + { + global $plugin, $tp, $ns; + $plug = $plugin->getinfo($this->id); + + if ($plug['plugin_installflag'] == true ) + { + if($plugin->parse_plugin($plug['plugin_path'])) + { + $plug_vars = $plugin->plug_vars; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + $userclasses = ''; + $eufields = ''; + if (isset($plug_vars['userclass'])) + { + if (isset($plug_vars['userclass']['@attributes'])) + { + $plug_vars['userclass'][0]['@attributes'] = $plug_vars['userclass']['@attributes']; + unset($plug_vars['userclass']['@attributes']); + } + $spacer = ''; + foreach ($plug_vars['userclass'] as $uc) + { + $userclasses .= $spacer.$uc['@attributes']['name'].' - '.$uc['@attributes']['description']; + $spacer = '
'; + } + } + 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 = '
'; + } + } + + if(is_writable(e_PLUGIN.$plug['plugin_path'])) + { + $del_text = " + + "; + } + else + { + $del_text = " + ".EPL_ADLAN_53." + + "; + } + + $text = " +
+ + + + + + + + + + + + + + + + "; + + if ($userclasses) + { + $text .= " + + + "; + } + + if ($eufields) + { + $text .= " + + + "; + } + + $text .=" + + + + + + +
".EPL_ADLAN_54." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable")."
".EPL_ADLAN_55."".LAN_YES."
+ ".EPL_ADLAN_57."
".EPL_ADLAN_58."
+
+ +
+ ".EPL_ADLAN_78."
".$userclasses."
".EPL_ADLAN_79."
+
+ +
+ ".EPL_ADLAN_80."
".$eufields."
".EPL_ADLAN_79."
+
+ +
".EPL_ADLAN_59."
".EPL_ADLAN_60."
{$del_text}
  
+
+ "; + $ns->tablerender(EPL_ADLAN_63." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable"), $text); + require_once(e_ADMIN."footer.php"); + exit; + } + + +} // end of Class. + + + +function plugin_adminmenu() { - global $plugin, $tp, $ns; - $plug = $plugin->getinfo($id); + // $e107 = &e107::getInstance(); - if ($plug['plugin_installflag'] == true ) - { - if($plugin->parse_plugin($plug['plugin_path'])) - { - $plug_vars = $plugin->plug_vars; - } - else - { - return FALSE; - } - } - else - { - return FALSE; - } - $userclasses = ''; - $eufields = ''; - if (isset($plug_vars['userclass'])) - { - if (isset($plug_vars['userclass']['@attributes'])) - { - $plug_vars['userclass'][0]['@attributes'] = $plug_vars['userclass']['@attributes']; - unset($plug_vars['userclass']['@attributes']); - } - $spacer = ''; - foreach ($plug_vars['userclass'] as $uc) - { - $userclasses .= $spacer.$uc['@attributes']['name'].' - '.$uc['@attributes']['description']; - $spacer = '
'; - } - } - 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 = '
'; - } - } + $var['installed']['text'] = EPL_ADLAN_22; + $var['installed']['link'] = e_SELF; - if(is_writable(e_PLUGIN.$plug['plugin_path'])) - { - $del_text = " - - "; - } - else - { - $del_text = " - ".EPL_ADLAN_53." - - "; - } + $var['avail']['text'] = EPL_ADLAN_23; + $var['avail']['link'] = e_SELF."?avail"; - $text = " -
- - - - - - - - - - - - - - - - "; - - if ($userclasses) - { - $text .= " - - - "; - } +/* $var['choose']['text'] = TPVLAN_51; + $var['choose']['link'] = e_SELF."?choose";*/ - if ($eufields) - { - $text .= " - - - "; - } + $var['upload']['text'] = EPL_ADLAN_38; + $var['upload']['link'] = e_SELF."?upload"; - $text .=" - - - - - - -
".EPL_ADLAN_54." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable")."
".EPL_ADLAN_55."".LAN_YES."
- ".EPL_ADLAN_57."
".EPL_ADLAN_58."
-
- -
- ".EPL_ADLAN_78."
".$userclasses."
".EPL_ADLAN_79."
-
- -
- ".EPL_ADLAN_80."
".$eufields."
".EPL_ADLAN_79."
-
- -
".EPL_ADLAN_59."
".EPL_ADLAN_60."
{$del_text}
  
-
- "; - $ns->tablerender(EPL_ADLAN_63." ".$tp->toHtml($plug_vars['name'], "", "defs,emotes_off, no_make_clickable"), $text); - require_once(e_ADMIN."footer.php"); - exit; + $selected = (e_QUERY) ? e_QUERY : "installed"; + + + e_admin_menu(ADLAN_98, $selected, $var); } ?> \ No newline at end of file diff --git a/e107_languages/English/admin/lan_plugin.php b/e107_languages/English/admin/lan_plugin.php index a33be0640..a79ad3e36 100644 --- a/e107_languages/English/admin/lan_plugin.php +++ b/e107_languages/English/admin/lan_plugin.php @@ -4,9 +4,9 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_plugin.php,v $ -| $Revision: 1.8 $ -| $Date: 2008-12-30 19:01:17 $ -| $Author: e107steved $ +| $Revision: 1.9 $ +| $Date: 2009-07-07 02:22:57 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ define("EPL_ADLAN_0", "Install"); @@ -84,7 +84,7 @@ define("EPL_ADLAN_60", "e107 will attempt to remove all plugin related files."); // define("EPL_ADLAN_61", "Confirm uninstall"); // duplicated. can be deleted. define("EPL_ADLAN_62", "Cancel uninstall"); define("EPL_ADLAN_63", "Uninstall:"); -define("EPL_ADLAN_64", "Folder:"); +define("EPL_ADLAN_64", "Folder"); define ('EPL_ADLAN_70','Required plugin not installed: '); define ('EPL_ADLAN_71','Newer plugin version required: '); @@ -97,9 +97,9 @@ define ('EPL_ADLAN_77','Cannot find plugin.xml'); define ('EPL_ADLAN_78','Delete User Classes created by plugin:'); define ('EPL_ADLAN_79','Only delete these if you have not used them for other purposes.'); define ('EPL_ADLAN_80','Delete extended user fields created by plugin:'); -define ('EPL_ADLAN_81',''); -define ('EPL_ADLAN_82',''); -define ('EPL_ADLAN_83',''); +define ('EPL_ADLAN_81','Xhtml'); +define ('EPL_ADLAN_82','Icon'); +define ('EPL_ADLAN_83','Notes'); define ('EPL_ADLAN_84',''); define ('EPL_ADLAN_85',''); diff --git a/e107_plugins/forum/plugin.xml b/e107_plugins/forum/plugin.xml index 7b765e764..34337974b 100755 --- a/e107_plugins/forum/plugin.xml +++ b/e107_plugins/forum/plugin.xml @@ -1,6 +1,6 @@ - - + + This plugin is a fully featured Forum system forum