X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fmodules%2Fadmin%2Fwhat-extensions.php;h=b159ab3d45f43775a758dbb2e9a5253accba9776;hb=49248176a5638be80b148ef55d0dc8c334522bf3;hp=b761a95fff528e21504e2cf30f9dfe134021032e;hpb=3e077cc4c838b433c321a21ced20f02f023f3b80;p=mailer.git diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index b761a95fff..b159ab3d45 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -10,7 +10,12 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Erweiterungen-Management * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2008 by Roland Haeder * * For more information visit: http://www.mxchange.org * @@ -32,433 +37,335 @@ ************************************************************************/ // Some security stuff... -if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; +if ((!defined('__SECURITY')) || (!IS_ADMIN())) { + $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); } // Add description as navigation point -ADD_DESCR("admin", basename(__FILE__)); - -global $cacheInstance, $cacheArray, $cacheMode; +ADD_DESCR('admin', __FILE__); // Normally we want the overview of all registered extensions -$do = "overview"; -$SEL = "0"; -if (!empty($_POST['sel'])) $SEL = SELECTION_COUNT($_POST['sel']); +$do = 'overview'; +$SEL = 0; + +// Are some extensions submitted? +if (REQUEST_ISSET_POST('sel')) { + // Then count all + $SEL = countPostSelection(); +} // END - if -if (!empty($_GET['reg_ext'])) { +if (REQUEST_ISSET_GET('reg_ext')) { // We are about to register a new extension - $do = "register"; $id = $_GET['reg_ext']; + $do = 'register'; $ext_id = bigintval(REQUEST_GET('reg_ext')); // The ID comes from task management and it is - of course - *not* the extension's name! -} elseif ((isset($_POST['change'])) && ($SEL > 0) && (!IS_DEMO())) { +} elseif ((REQUEST_ISSET_POST('change')) && ($SEL > 0) && (!IS_DEMO())) { // De-/activate extensions - foreach ($_POST['sel'] as $id=>$active) { + foreach (REQUEST_POST('sel') as $ext_id => $active) { // Shall we keep the extension always active? - if ((isset($cacheArray['active_extensions'][GET_EXT_NAME($id)])) && ($cacheArray['active_extensions'][GET_EXT_NAME($id)] == 'Y') && ($active == 'N')) { + if ((isset($GLOBALS['cache_array']['active_extensions'][GET_EXT_NAME($ext_id)])) && ($GLOBALS['cache_array']['active_extensions'][GET_EXT_NAME($ext_id)] == 'Y') && ($active == 'N')) { // Keep this extension active! } else { // De/activate extension - $ACT = 'N'; $EXT_LOAD_MODE = "deactivate"; - if ($active == 'N') { $ACT = 'Y'; $EXT_LOAD_MODE = "activate"; } - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='".$ACT."' WHERE id=%d AND ext_active='%s' LIMIT 1", - array(bigintval($id), $active), __FILE__, __LINE__); + $ACT = 'N'; $EXT_LOAD_MODE = 'deactivate'; + if ($active == 'N') { $ACT = 'Y'; $EXT_LOAD_MODE = 'activate'; } + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET `ext_active`='".$ACT."' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1", + array(bigintval($ext_id), $active), __FILE__, __LINE__); // Run embeded SQL commands - EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE); + EXTENSION_RUN_SQLS($ext_id, $EXT_LOAD_MODE); } } -} elseif (((isset($_POST['edit'])) || (isset($_POST['modify']))) && ($SEL > 0) && (!IS_DEMO())) { +} elseif (((REQUEST_ISSET_POST('edit')) || (REQUEST_ISSET_POST(('modify')))) && ($SEL > 0) && (!IS_DEMO())) { // Change settings like CSS file load - if (isset($_POST['modify'])) { + if (REQUEST_ISSET_POST(('modify'))) { // Change entries - $cacheInstance_UPDATE = "0"; - foreach ($_POST['sel'] as $id=>$sel) { + $cache_update = 0; + foreach (REQUEST_POST('sel') as $ext_id => $sel) { // Secure ID - $id = bigintval($id); + $ext_id = bigintval($ext_id); // Change this extension? if ($sel == 1) { + // Load mode is modify + $EXT_LOAD_MODE = 'modify'; + + // Get entry for 'active' + $active = REQUEST_POST('active', $ext_id); + // Update extension's record - $active = $_POST['active'][$id]; - if (GET_EXT_VERSION("sql_patches") >= "0.0.6") { + if (GET_EXT_VERSION('sql_patches') >= '0.0.6') { // Update also CSS column when extensions sql_patches is newer or exact v0.0.6 - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_has_css='%s', ext_active='%s' WHERE id=%d LIMIT 1", - array($_POST['css'][$id], $active, $id), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET ext_has_css='%s', `ext_active`='%s' WHERE `id`=%s LIMIT 1", + array(REQUEST_POST('css', $ext_id), $active, $ext_id), __FILE__, __LINE__); } else { // When extension is older than v0.0.6 there is no column for the CSS information - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='%s' WHERE id=%d LIMIT 1", - array($active, $id), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_extensions` SET `ext_active`='%s' WHERE `id`=%s LIMIT 1", + array($active, $ext_id), __FILE__, __LINE__); } // Run SQLs on activation / deactivation switch ($active) { - case 'Y': $EXT_LOAD_MODE = "activate"; break; - case 'N': $EXT_LOAD_MODE = "deactivate"; break; + case 'Y': $EXT_LOAD_MODE = 'activate'; break; + case 'N': $EXT_LOAD_MODE = 'deactivate'; break; } // Run embeded SQL commands - EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE); + EXTENSION_RUN_SQLS($ext_id, $EXT_LOAD_MODE); } } // Extensions changed - OUTPUT_HTML("
"); - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_EXT_CHANGED); - OUTPUT_HTML("
"); + LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_EXT_CHANGED')); } else { // Edit selected entries - $SW = "2"; $OUT = ""; - foreach ($_POST['sel'] as $id=>$sel) { + $SW = 2; $OUT = ''; + foreach (REQUEST_POST('sel') as $ext_id => $sel) { // Edit this extension? if (($sel == 'Y') || ($sel == 'N')) { // Load required data - if (GET_EXT_VERSION("sql_patches") >= "0.0.6") { - $result = SQL_QUERY_ESC("SELECT ext_name, ext_has_css, ext_active FROM "._MYSQL_PREFIX."_extensions WHERE id=%d LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); + if (GET_EXT_VERSION('sql_patches') >= '0.0.6') { + $result = SQL_QUERY_ESC("SELECT ext_name, ext_has_css, ext_active FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1", + array(bigintval($ext_id)), __FILE__, __LINE__); list($name, $css, $active) = SQL_FETCHROW($result); SQL_FREERESULT($result); } else { - $result = SQL_QUERY_ESC("SELECT ext_name, ext_active FROM "._MYSQL_PREFIX."_extensions WHERE id=%d LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT ext_name, ext_active FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1", + array(bigintval($ext_id)), __FILE__, __LINE__); list($name, $active) = SQL_FETCHROW($result); SQL_FREERESULT($result); - $css = "X"; + $css = 'X'; } // Output row - $CSS = "---"; - if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = ADD_SELECTION("yn", $css, "css", $id); + $cssSelection = '---'; + if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = ADD_SELECTION('yn', $css, 'css', $ext_id); // Prepare data for the row template $content = array( 'sw' => $SW, - 'id' => $id, + 'id' => $ext_id, 'name' => $name, - 'active' => ADD_SELECTION("yn", $active, "active", $id), - 'css' => $CSS, + 'active' => ADD_SELECTION('yn', $active, 'active', $ext_id), + 'css' => $cssSelection, ); // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_extensions_edit_row", true, $content); + $OUT .= LOAD_TEMPLATE('admin_extensions_edit_row', true, $content); $SW = 3 - $SW; } - } + } // END - foreach + + // @TODO Rewrite this constant define('__EXTENSIONS_ROWS', $OUT); // Load template - LOAD_TEMPLATE("admin_extensions_edit"); - $do = "edit"; + LOAD_TEMPLATE('admin_extensions_edit'); + $do = 'edit'; } -} elseif ((isset($_POST['delete'])) && ($SEL > 0) && (!IS_DEMO())) { +} elseif ((REQUEST_ISSET_POST('delete')) && ($SEL > 0) && (!IS_DEMO())) { // List extensions and when verbose is enabled SQL statements which will be executed - $SW = 2; $OUT = ""; - foreach ($_POST['sel'] as $id=>$sel) { - $VERBOSE_OUT = ""; $SQLs = array(); - // Load extension's data - $result = SQL_QUERY_ESC("SELECT ext_name, ext_version FROM "._MYSQL_PREFIX."_extensions WHERE id=%d LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - list($ext_name, $ext_ver) = SQL_FETCHROW($result); - - // Free the result - SQL_FREERESULT($result); + $OUT = ''; $SW = 2; + foreach (REQUEST_POST('sel') as $ext_id => $sel) { + // Init variables + $VERBOSE_OUT = ''; + INIT_SQLS(); - if ($_CONFIG['verbose_sql']) { - // Load SQL commands in remove mode - $EXT_LOAD_MODE = "remove"; - $file = sprintf(PATH."inc/extensions/ext-%s.php", $ext_name); - include($file); + // Secure id number + $ext_id = bigintval($ext_id); - // Generate extra table with loaded SQL commands - $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE($SQLs); - } + // Get extension name + $ext_name = GET_EXT_NAME($ext_id); + + if (getConfig('verbose_sql') == 'Y') { + // Load SQL commands in remove mode + if (LOAD_EXTENSION($ext_name, 'remove', '', true)) { + // Generate extra table with loaded SQL commands + $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE(); + } // END - if + } // END - if // Prepare data for the row template $content = array( 'sw' => $SW, - 'id' => $id, + 'id' => $ext_id, 'ext_name' => $ext_name, - 'ext_ver' => $ext_ver, + 'ext_ver' => GET_EXT_VERSION($ext_name), 'verbose' => $VERBOSE_OUT ); // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_extensions_delete_row", true, $content); + $OUT .= LOAD_TEMPLATE('admin_extensions_delete_row', true, $content); $SW = 3 - $SW; - } + } // END - foreach define('__EXTENSIONS_ROWS', $OUT); // Load template - LOAD_TEMPLATE("admin_extensions_delete"); - $do = "delete"; -} elseif ((isset($_POST['remove'])) && ($SEL > 0) && (!IS_DEMO())) { + LOAD_TEMPLATE('admin_extensions_delete'); + $do = 'delete'; +} elseif ((REQUEST_ISSET_POST('remove')) && ($SEL > 0) && (!IS_DEMO())) { // Remove extensions from DB (you have to delete all files manually!) - $cacheInstance_UPDATE = "0"; - foreach ($_POST['sel'] as $id=>$active) { + $cache_update = 0; + foreach (REQUEST_POST('sel') as $ext_id => $active) { // Secure ID number - $id = bigintval($id); + $ext_id = bigintval($ext_id); // Is this extension selected? if ($active == 1) { // Run embeded SQL commands - EXTENSION_RUN_SQLS($id, "remove"); - - // Delete this extension (remember to remove it from your server *before* you click on welcome! - $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE id=%d LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - } - } -} elseif (!empty($_GET['do']) && (!IS_DEMO())) { + EXTENSION_RUN_SQLS($ext_id, 'remove'); + } // END - if + } // END - foreach +} elseif ((REQUEST_ISSET_GET('do')) && (!IS_DEMO())) { // Other things to do - $do = SQL_ESCAPE(strip_tags($_GET['do'])); -} elseif (!empty($_GET['do'])) { + $do = SQL_ESCAPE(strip_tags(REQUEST_GET('do'))); +} elseif (REQUEST_ISSET_GET('do')) { // Demo mode active! - $do = "demo"; + $do = 'demo'; } // Shall we display active/inactive extensions? -$where = ""; -if (!empty($_GET['active'])) { - $where = sprintf("WHERE ext_active = '%s'", SQL_ESCAPE(strip_tags($_GET['active']))); -} +$where = ''; +if (REQUEST_ISSET_GET(('active'))) { + $where = sprintf("WHERE `ext_active`='%s'", SQL_ESCAPE(strip_tags(REQUEST_GET('active')))); +} // END - if // Case selection switch ($do) { -case "overview": // List all registered extensions - if (GET_EXT_VERSION("sql_patches") >= "0.0.6") { - // Load extension data with CSS informations - $result = SQL_QUERY("SELECT id, ext_name, ext_lang_file, ext_active, ext_has_css, ext_version - FROM "._MYSQL_PREFIX."_extensions - ".$where." - ORDER BY ext_name", __FILE__, __LINE__); - } else { - // Load extension data without CSS informations - $result = SQL_QUERY("SELECT id, ext_name, ext_lang_file, ext_active, id, ext_version - FROM "._MYSQL_PREFIX."_extensions - ".$where." - ORDER BY ext_name", __FILE__, __LINE__); - } - - // Are there some entries? - if (SQL_NUMROWS($result) > 0) { - // Extensions are registered - $SW = 2; $OUT = ""; - while (list($id, $name, $lang, $active, $css, $ver) = SQL_FETCHROW($result)) { - $CSS = "---"; - if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = TRANSLATE_YESNO($css); - - // Prepare data for the row template - $content = array( - 'sw' => $SW, - 'id' => $id, - 'name' => $name, - 'active' => TRANSLATE_YESNO($active), - 'act_val' => $active, - 'lang' => $lang, - 'css' => $CSS, - 'ver' => $ver, - ); - - // Load row template and switch color - $OUT .= LOAD_TEMPLATE("admin_extensions_row", true, $content); - $SW = 3 - $SW; + case 'overview': // List all registered extensions + if (GET_EXT_VERSION('sql_patches') >= '0.0.6') { + // Load extension data with CSS informations + $result = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_active, ext_has_css AS ext_css, ext_version +FROM `{!_MYSQL_PREFIX!}_extensions` +".$where." +ORDER BY ext_name", __FILE__, __LINE__); + } else { + // Load extension data without CSS informations + $result = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_active, id, ext_version +FROM `{!_MYSQL_PREFIX!}_extensions` +".$where." +ORDER BY ext_name", __FILE__, __LINE__); } - // Free memory - SQL_FREERESULT($result); + // Are there some entries? + if (SQL_NUMROWS($result) > 0) { + // Extensions are registered + $OUT = ''; $SW = 2; + while ($content = SQL_FETCHARRAY($result)) { + // Prepare CSS selection output + $cssSelection = '---'; + if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = translateYesNo($content['ext_css']); - // Remember rows in constant for the template - define('__EXT_ROWS', $OUT); + // Prepare data for the row template + $content = array( + 'sw' => $SW, + 'id' => $content['ext_id'], + 'name' => $content['ext_name'], + 'active' => translateYesNo($content['ext_active']), + 'act_val' => $content['ext_active'], + 'css' => $cssSelection, + 'ver' => $content['ext_version'], + ); - // Load template - LOAD_TEMPLATE("admin_extensions"); - } else { - // No extensions are registered - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_EXTENSION_REGISTERED.""); - } - // Link for checking for new or updated extensions - OUTPUT_HTML("