From 293f1058543c01ce18993fa708fd9e68cf2cd06d Mon Sep 17 00:00:00 2001 From: Ben Keen Date: Sun, 23 Dec 2018 16:00:52 -0800 Subject: [PATCH] 2.1.4 --- README.md | 1 + code/Module.class.php | 38 ++++----- code/Tables.class.php | 2 +- code/actions.php | 174 +++++++++++++++++++++--------------------- lang/en_us.php | 2 +- 5 files changed, 109 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index 93d0aee..18844e6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ This module replaces the older Database Integrity module. It offers a few simple, quick tests to run on your Form Tools installation: kind of like taking your car to get it serviced. + ### Documentation - [https://docs.formtools.org/modules/system_check/](https://docs.formtools.org/modules/system_check/) diff --git a/code/Module.class.php b/code/Module.class.php index 9dc6f32..7940b4a 100644 --- a/code/Module.class.php +++ b/code/Module.class.php @@ -8,24 +8,24 @@ class Module extends FormToolsModule { - protected $moduleName = "System Check"; - protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation."; - protected $author = "Ben Keen"; - protected $authorEmail = "ben.keen@gmail.com"; - protected $authorLink = "http://formtools.org"; - protected $version = "2.1.3"; - protected $date = "2017-12-20"; - protected $originLanguage = "en_us"; - protected $jsFiles = array("scripts/tests.js"); - protected $cssFiles = array("css/styles.css"); + protected $moduleName = "System Check"; + protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation."; + protected $author = "Ben Keen"; + protected $authorEmail = "ben.keen@gmail.com"; + protected $authorLink = "http://formtools.org"; + protected $version = "2.1.4"; + protected $date = "2018-12-23"; + protected $originLanguage = "en_us"; + protected $jsFiles = array("scripts/tests.js"); + protected $cssFiles = array("css/styles.css"); - protected $nav = array( - "module_name" => array("index.php", false), - "phrase_file_verification" => array("files.php", true), - "phrase_table_verification" => array("tables.php", true), - "phrase_hook_verification" => array("hooks.php", true), - "phrase_orphan_clean_up" => array("orphans.php", true), - "phrase_environment_info" => array("env.php", false), - "word_help" => array("help.php", false) - ); + protected $nav = array( + "module_name" => array("index.php", false), + "phrase_file_verification" => array("files.php", true), + "phrase_table_verification" => array("tables.php", true), + "phrase_hook_verification" => array("hooks.php", true), + "phrase_orphan_clean_up" => array("orphans.php", true), + "phrase_environment_info" => array("env.php", false), + "word_help" => array("help.php", false) + ); } diff --git a/code/Tables.class.php b/code/Tables.class.php index 48b517a..b2e7183 100644 --- a/code/Tables.class.php +++ b/code/Tables.class.php @@ -66,7 +66,7 @@ private static function checkComponentTableColumns($component_info, $table_name) $invalid_columns = array(); // get the actual content of the db table (should be moved to helper) - $db->query("SHOW COLUMNS FROM $table_name"); + $db->query("SHOW COLUMNS FROM `$table_name`"); $db->execute(); $actual_column_info = array(); diff --git a/code/actions.php b/code/actions.php index 748cc57..5f3796d 100644 --- a/code/actions.php +++ b/code/actions.php @@ -25,98 +25,98 @@ // the action to take and the ID of the page where it will be displayed (allows for // multiple calls on same page to load content in unique areas) $request = array_merge($_GET, $_POST); -$action = $request["action"]; +$action = $request["action"]; $settings = Settings::get(); $root_dir = Core::getRootDir(); switch ($action) { - // Stage 1 of the Table Verification test: returns a list of tables to test for a particular component - case "get_component_tables": - $component = $request["component"]; - - // N.B. from 2.1.5 onwards, the Core stores its own DB structure - if ($component == "core") { - require_once("$root_dir/global/misc/config_core.php"); - $tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE)); - } else { - $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID - $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); - $tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"])); - } - echo json_encode(array("tables" => $tables)); - break; - - // Stage 2 of the Table Verification test: verifies the table structure - case "verify_table": - $component = $request["component"]; - if ($component == "core") { - require_once("$root_dir/global/misc/config_core.php"); - $info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]); - $info["table_name"] = $request["table_name"]; - echo json_encode($info); - } else { - $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID - $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); - $info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]); - $info["table_name"] = $request["table_name"]; - echo json_encode($info); - } - break; - - // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks - // in a single step and returns the result - case "verify_module_hooks": - $module_id = $request["module_id"]; - $module_info = Modules::getModule($module_id); - $module_folder = $module_info["module_folder"]; - $module_version = $module_info["version"]; - list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder); - - echo json_encode(array( - "module_id" => $module_id, - "module_folder" => $module_folder, - "module_name" => $module_info["module_name"], - "result" => $result, - "extra" => $extra_info - )); - break; - - case "verify_component_files": - $component = $request["component"]; - - $return_info = array("result" => "pass"); - if ($component == "core") { - $missing_files = Files::checkCoreFiles(); - $return_info["component_type"] = "core"; - $return_info["component_name"] = "Form Tools Core"; - } - if (preg_match("/^module_/", $component)) { - $module_id = preg_replace("/^module_/", "", $component); - $module_info = Modules::getModule($module_id); - $missing_files = Files::checkModuleFiles($module_info["module_folder"]); - $return_info["component_type"] = "module"; - $return_info["component_name"] = $module_info["module_name"]; - } - if (preg_match("/^theme_/", $component)) { - $theme_id = preg_replace("/^theme_/", "", $component); - $theme_info = Themes::getTheme($theme_id); - $missing_files = Files::checkThemeFiles($theme_info["theme_folder"]); - $return_info["component_type"] = "theme"; - $return_info["component_name"] = $theme_info["theme_name"]; - } - if (!empty($missing_files)) { - $return_info["result"] = "fail"; - $return_info["missing_files"] = $missing_files; - } - echo json_encode($return_info); - break; - - case "find_table_orphans": - $remove_orphans = isset($request["remove_orphans"]) ? true : false; - $results = Orphans::findTableOrphans($request["table_name"], $remove_orphans); - echo json_encode($results); - break; + // Stage 1 of the Table Verification test: returns a list of tables to test for a particular component + case "get_component_tables": + $component = $request["component"]; + + // N.B. from 2.1.5 onwards, the Core stores its own DB structure + if ($component == "core") { + require_once("$root_dir/global/misc/config_core.php"); + $tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE)); + } else { + $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID + $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); + $tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"])); + } + echo json_encode(array("tables" => $tables)); + break; + + // Stage 2 of the Table Verification test: verifies the table structure + case "verify_table": + $component = $request["component"]; + if ($component == "core") { + require_once("$root_dir/global/misc/config_core.php"); + $info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]); + $info["table_name"] = $request["table_name"]; + echo json_encode($info); + } else { + $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID + $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); + $info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]); + $info["table_name"] = $request["table_name"]; + echo json_encode($info); + } + break; + + // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks + // in a single step and returns the result + case "verify_module_hooks": + $module_id = $request["module_id"]; + $module_info = Modules::getModule($module_id); + $module_folder = $module_info["module_folder"]; + $module_version = $module_info["version"]; + list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder); + + echo json_encode(array( + "module_id" => $module_id, + "module_folder" => $module_folder, + "module_name" => $module_info["module_name"], + "result" => $result, + "extra" => $extra_info + )); + break; + + case "verify_component_files": + $component = $request["component"]; + + $return_info = array("result" => "pass"); + if ($component == "core") { + $missing_files = Files::checkCoreFiles(); + $return_info["component_type"] = "core"; + $return_info["component_name"] = "Form Tools Core"; + } + if (preg_match("/^module_/", $component)) { + $module_id = preg_replace("/^module_/", "", $component); + $module_info = Modules::getModule($module_id); + $missing_files = Files::checkModuleFiles($module_info["module_folder"]); + $return_info["component_type"] = "module"; + $return_info["component_name"] = $module_info["module_name"]; + } + if (preg_match("/^theme_/", $component)) { + $theme_id = preg_replace("/^theme_/", "", $component); + $theme_info = Themes::getTheme($theme_id); + $missing_files = Files::checkThemeFiles($theme_info["theme_folder"]); + $return_info["component_type"] = "theme"; + $return_info["component_name"] = $theme_info["theme_name"]; + } + if (!empty($missing_files)) { + $return_info["result"] = "fail"; + $return_info["missing_files"] = $missing_files; + } + echo json_encode($return_info); + break; + + case "find_table_orphans": + $remove_orphans = isset($request["remove_orphans"]) ? true : false; + $results = Orphans::findTableOrphans($request["table_name"], $remove_orphans); + echo json_encode($results); + break; } diff --git a/lang/en_us.php b/lang/en_us.php index 64e7813..ff6d599 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -51,7 +51,7 @@ $L["text_help"] = "For more information on this module, please see the help documentation on the Form Tools site."; $L["text_file_check"] = "This examines all compatible components (Core, modules and themes) to confirm that the component's files exist."; $L["text_file_verification_intro"] = "This checks over your Core, modules and themes to confirm that all the necessary files have been uploaded properly. If any are missing, you will need to re-download the appropriate component and upload them to your server."; -$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. If this test finds anything, we'd appreciate it if you report them in the forums!"; +$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. If this test finds anything, we'd appreciate it if you reported it on github!"; $L["text_orphan_desc_short"] = "A housekeeping test to identify and remove old database records and references that are no longer needed and should have been deleted."; $L["text_environment_overview_summary"] = "This section below contains a report of key information about your Form Tools installation and environment, which can be helpful when reporting bugs."; $L["text_ft3_compatibility"] = "Form Tools 3 has slightly difference server requirements than Form Tools 2. This page runs a couple of simple tests to confirm you will be able to run the newer version.";