diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php
index c431ec262..9af6bc24f 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.7 $
-| $Date: 2007-05-30 20:35:44 $
-| $Author: e107steved $
+| $Revision: 1.8 $
+| $Date: 2008-01-26 04:47:27 $
+| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -32,17 +32,22 @@ $tmp = explode('.', e_QUERY);
$action = $tmp[0];
$id = intval($tmp[1]);
-if (isset($_POST['upload'])) {
- if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
+if (isset($_POST['upload']))
+{
+ if (!$_POST['ac'] == md5(ADMINPWCHANGE))
+ {
exit;
}
extract($_FILES);
/* check if e_PLUGIN dir is writable ... */
- if(!is_writable(e_PLUGIN)) {
+ if(!is_writable(e_PLUGIN))
+ {
/* still not writable - spawn error message */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_39);
- } else {
+ }
+ else
+ {
/* e_PLUGIN is writable - continue */
$pref['upload_storagetype'] = "1";
require_once(e_HANDLER."upload_handler.php");
@@ -50,18 +55,24 @@ if (isset($_POST['upload'])) {
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
- if(strstr($file_userfile['type'][0], "gzip")) {
+ if(strstr($file_userfile['type'][0], "gzip"))
+ {
$fileType = "tar";
- } else if (strstr($file_userfile['type'][0], "zip")) {
+ }
+ else if (strstr($file_userfile['type'][0], "zip"))
+ {
$fileType = "zip";
- } else {
+ }
+ else
+ {
/* not zip or tar - spawn error message */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_41);
require_once("footer.php");
exit;
}
- if ($fileSize) {
+ if ($fileSize)
+ {
$opref = $pref['upload_storagetype'];
$pref['upload_storagetype'] = 1; /* temporarily set upload type pref to flatfile */
@@ -72,20 +83,27 @@ if (isset($_POST['upload'])) {
/* attempt to unarchive ... */
- if($fileType == "zip") {
+ 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 {
+ }
+ else
+ {
require_once(e_HANDLER."pcltar.lib.php");
$unarc = ($fileList = PclTarExtract($archiveName, e_PLUGIN));
}
- if(!$unarc) {
+ if(!$unarc)
+ {
/* unarc failed ... */
- if($fileType == "zip") {
+ if($fileType == "zip")
+ {
$error = EPL_ADLAN_46." '".$archive -> errorName(TRUE)."'";
- } else {
+ }
+ else
+ {
$error = EPL_ADLAN_47.PclErrorString().", ".EPL_ADLAN_48.intval(PclErrorCode());
}
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_42." ".$archiveName." ".$error);
@@ -98,10 +116,13 @@ if (isset($_POST['upload'])) {
/* get folder name ... */
$folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/")));
- if(file_exists(e_PLUGIN.$folderName."/plugin.php")) {
+ 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 {
+ }
+ else
+ {
/* upload is a menu */
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_45);
}
@@ -124,12 +145,13 @@ if ($action == 'uninstall')
$id = intval($id);
$plug = $plugin->getinfo($id);
//Uninstall Plugin
- if ($plug['plugin_installflag'] == TRUE )
+ if ($plug['plugin_installflag'] == TRUE )
{
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
$func = $eplug_folder.'_uninstall';
- if (function_exists($func)) {
+ if (function_exists($func))
+ {
$text .= call_user_func($func);
}
@@ -153,25 +175,30 @@ if ($action == 'uninstall')
$text .= EPL_ADLAN_49."
";
}
- if (is_array($eplug_prefs)) {
+ if (is_array($eplug_prefs))
+ {
$plugin->manage_prefs('remove', $eplug_prefs);
$text .= EPL_ADLAN_29."
";
}
- if (is_array($eplug_comment_ids)) {
+ if (is_array($eplug_comment_ids))
+ {
$text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."
" : "";
}
- if ($eplug_module) {
+ if ($eplug_module)
+ {
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
- if ($eplug_status) {
+ if ($eplug_status)
+ {
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
- if ($eplug_latest) {
+ if ($eplug_latest)
+ {
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
@@ -195,33 +222,41 @@ if ($action == 'uninstall')
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
- if (is_array($eplug_user_prefs)) {
+ if (is_array($eplug_user_prefs))
+ {
if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
$user_entended = array_values(array_diff($user_entended, array_keys($eplug_user_prefs)));
- if ($user_entended == NULL) {
+ if ($user_entended == NULL)
+ {
$sql->db_Delete("core", "e107_name='user_entended'");
- } else {
+ }
+ else
+ {
$tmp = addslashes(serialize($user_entended));
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
}
- while (list($key, $e_user_pref) = each($eplug_user_prefs)) {
+ while (list($key, $e_user_pref) = each($eplug_user_prefs))
+ {
unset($user_pref[$key]);
}
save_prefs("user");
}
- if ($eplug_menu_name) {
+ if ($eplug_menu_name)
+ {
$sql->db_Delete('menus', "menu_name='$eplug_menu_name' ");
}
- if ($eplug_link) {
+ if ($eplug_link)
+ {
$plugin->manage_link('remove', $eplug_link_url, $eplug_link_name);
}
- if ($eplug_userclass) {
+ if ($eplug_userclass)
+ {
$plugin->manage_userclass('remove', $eplug_userclass);
}
@@ -232,8 +267,8 @@ if ($action == 'uninstall')
$sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$id}' ");
if (isset($pref['plug_installed'][$plug['plugin_path']]))
{
- unset($pref['plug_installed'][$plug['plugin_path']]);
- save_prefs();
+ unset($pref['plug_installed'][$plug['plugin_path']]);
+ save_prefs();
}
@@ -254,44 +289,60 @@ if ($action == 'uninstall')
}
}
-if ($action == 'install') {
+if ($action == 'install')
+{
$plugin->install_plugin(intval($id));
$plugin ->save_addon_prefs();
}
-if ($action == 'upgrade') {
+if ($action == 'upgrade')
+{
$plug = $plugin->getinfo($id);
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
$func = $eplug_folder.'_upgrade';
- if (function_exists($func)) {
+ if (function_exists($func))
+ {
$text .= call_user_func($func);
}
- if (is_array($upgrade_alter_tables)) {
+ if (is_array($upgrade_alter_tables))
+ {
$result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
- if (!$result) {
+ if (!$result)
+ {
$text .= EPL_ADLAN_9.'
';
- } else {
+ }
+ else
+ {
$text .= EPL_ADLAN_7."
";
}
}
- if ($eplug_module) {
+ if ($eplug_module)
+ {
$plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
- } else {
+ }
+ else
+ {
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
- if ($eplug_status) {
+ if ($eplug_status)
+ {
$plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
- } else {
+ }
+ else
+ {
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
- if ($eplug_latest) {
+ if ($eplug_latest)
+ {
$plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder);
- } else {
+ }
+ else
+ {
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
@@ -315,57 +366,68 @@ if ($action == 'upgrade') {
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
- if (is_array($upgrade_add_prefs)) {
+ if (is_array($upgrade_add_prefs))
+ {
$plugin->manage_prefs('add', $upgrade_add_prefs);
$text .= EPL_ADLAN_8.'
';
}
- if (is_array($upgrade_remove_prefs)) {
+ 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);
- }
+ 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);
- }
+ foreach($upgrade_remove_array_pref as $key => $val)
+ {
+ $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
+ }
}
- if (is_array($upgrade_add_user_prefs)) {
+ if (is_array($upgrade_add_user_prefs))
+ {
if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
- while (list($key, $e_user_pref) = each($eplug_user_prefs)) {
+ while (list($key, $e_user_pref) = each($eplug_user_prefs))
+ {
$user_entended[] = $e_user_pref;
}
$tmp = addslashes(serialize($user_entended));
- if ($sql->db_Select("core", " e107_value", " e107_name='user_entended'")) {
+ if ($sql->db_Select("core", " e107_value", " e107_name='user_entended'"))
+ {
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
- } else {
+ }
+ else
+ {
$sql->db_Insert("core", "'user_entended', '$tmp' ");
}
$text .= EPL_ADLAN_8."
";
}
- if (is_array($upgrade_remove_user_prefs)) {
- if (!is_object($sql)){ $sql = new db; }
+ if (is_array($upgrade_remove_user_prefs))
+ {
+ if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
$user_entended = array_values(array_diff($user_entended, $eplug_user_prefs));
- if ($user_entended == NULL) {
+ if ($user_entended == NULL)
+ {
$sql->db_Delete("core", "e107_name='user_entended'");
- } else {
+ }
+ else
+ {
$tmp = addslashes(serialize($user_entended));
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
}
@@ -374,12 +436,12 @@ if ($action == 'upgrade') {
$plugin -> manage_search('upgrade', $eplug_folder);
$plugin -> manage_notify('upgrade', $eplug_folder);
- $eplug_addons = $plugin -> getAddons($eplug_folder);
+ $eplug_addons = $plugin -> getAddons($eplug_folder);
$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();
+ save_prefs();
$ns->tablerender(EPL_ADLAN_34, $text);
$plugin -> save_addon_prefs();
@@ -395,9 +457,12 @@ $plugin->update_plugins_table();
/* plugin upload form */
-if(!is_writable(e_PLUGIN)) {
+if(!is_writable(e_PLUGIN))
+{
$ns->tablerender(EPL_ADLAN_40, EPL_ADLAN_44);
-} else {
+}
+else
+{
$text = "