diff --git a/e107_admin/db.php b/e107_admin/db.php
index bc753f6fc..199ae58b1 100644
--- a/e107_admin/db.php
+++ b/e107_admin/db.php
@@ -149,6 +149,8 @@ class system_tools
{
require_once(e_HANDLER."db_verify_class.php");
$dbv = new db_verify;
+ $dbv->backUrl = e_SELF."?mode=verify_sql";
+ $dbv->verify();
return;
}
diff --git a/e107_handlers/db_verify_class.php b/e107_handlers/db_verify_class.php
index 5e14a34f6..820f5e191 100644
--- a/e107_handlers/db_verify_class.php
+++ b/e107_handlers/db_verify_class.php
@@ -21,13 +21,22 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_db_verify.php');
class db_verify
{
-
+ var $backUrl = "";
var $tables = array();
var $sqlTables = array();
var $sqlLanguageTables = array();
var $results = array();
var $indices = array(); // array(0) - Issue?
+ var $fieldTypes = array('time','timestamp','datetime','year','tinyblob','blob',
+ 'mediumblob','longblob','tinytext','mediumtext','longtext','text','date');
+
+ var $fieldTypeNum = array('bit','tinyint','smallint','mediumint','integer','int','bigint',
+ 'real','double','float','decimal','numeric','varchar','char','binary','varbinary','enum','set');
+
+ /**
+ * Setup
+ */
function __construct()
{
@@ -36,6 +45,8 @@ class db_verify
$mes = e107::getMessage();
$frm = e107::getForm();
+ $this->backUrl = e_SELF;
+
$core_data = file_get_contents(e_ADMIN.'sql/core_sql.php');
$this->tables['core'] = $this->getTables($core_data);
@@ -53,39 +64,73 @@ class db_verify
}
else
{
- $emessage->add($filename.DBVLAN_22, E_MESSAGE_WARNING);
+ $message = str_replace("[x]",$filename,DBVLAN_22);
+ $emessage->add($message, E_MESSAGE_WARNING);
}
}
+ }
+
+
+
+ /**
+ * Main Routine for checking and rendering results.
+ */
+ function verify()
+ {
+
if($_POST['verify_table'])
- {
- foreach($_POST['verify_table'] as $tab)
- {
- $this->compare($tab);
- foreach($this->sqlLanguageTables as $lng=>$lantab)
- {
- $this->compare($tab,$lng);
- }
- }
-
- if(count($this->errors))
- {
- $this->renderResults();
- }
- else
- {
- $mes->add("Tables appear to be okay!",E_MESSAGE_SUCCESS); //TODO LAN
- //$text .= "
".$frm->admin_button('back', DBVLAN_17, 'back')."
";
- $ns->tablerender("Okay",$mes->render().$text);
- }
-
+ {
+ $this->runComparison($_POST['verify_table']);
}
else
{
- $this->runFix();
+ if(isset($_POST['runfix']))
+ {
+ $this->runFix();
+
+ }
+
$this->renderTableSelect();
+ }
+
+ }
+
+
+ function runComparison($fileArray)
+ {
+
+ $ns = e107::getRender();
+ $mes = e107::getMessage();
+ $frm = e107::getForm();
+
+ foreach($fileArray as $tab)
+ {
+ $this->compare($tab);
+ foreach($this->sqlLanguageTables as $lng=>$lantab)
+ {
+ $this->compare($tab,$lng);
+ }
}
+
+ if($cnt = count($this->errors))
+ {
+ $message = str_replace("[x]",$cnt,DBVLAN_26); // Found [x] issues.
+ $mes->add($message, E_MESSAGE_WARNING);
+ $this->renderResults();
+ }
+ else
+ {
+ $mes->add("Tables appear to be okay!",E_MESSAGE_SUCCESS); //TODO LAN
+ $mes->add("".LAN_BACK."", E_MESSAGE_SUCCESS);
+ $debug = "".print_r($this->results,TRUE)."
";
+ $mes->add($debug,E_MESSAGE_DEBUG);
+ //$text .= "".$frm->admin_button('back', DBVLAN_17, 'back')."
";
+ $ns->tablerender("Okay",$mes->render().$text);
+ }
+
+ }
// $this->sqlTables = $this->sqlTableList();
@@ -95,7 +140,7 @@ class db_verify
// print_a($field);
// print_a($match[2]);
// echo "".$sql_data."
";
- }
+
function compare($selection,$language='')
{
@@ -124,14 +169,14 @@ class db_verify
$fileIndexData = $this->getIndex($this->tables[$selection]['data'][$key]);
$sqlIndexData = $this->getIndex($sqlDataArr['data'][0]);
-
+ /*
$debugA = print_r($fileFieldData,TRUE); // Extracted Field Arrays
$debugA .= "Index
";
$debugA .= print_r($fileIndexData,TRUE);
$debugB = print_r($sqlFieldData,TRUE); // Extracted Field Arrays
$debugB .= "Index
";
$debugB .= print_r($sqlIndexData,TRUE);
-
+ */
// $debugA = $this->tables[$selection]['data'][$key]; // Extracted Raw Field Text
// $debugB = $sqlDataArr['data'][0]; // Extracted Raw Field Text
@@ -164,8 +209,8 @@ class db_verify
if(!is_array($sqlFieldData[$field]))
{
- // echo "".$field."
".print_r($info,TRUE)." |
- // - ".print_r($sqlFieldData[$field],TRUE)." |
";
+ // echo "".$field."
".print_r($info,TRUE)." |
+ // - ".print_r($sqlFieldData[$field],TRUE)." |
";
$this->errors[$tbl]['_status'] = 'error'; // table status
$this->results[$tbl][$field]['_status'] = 'missing_field'; // field status
@@ -242,7 +287,7 @@ class db_verify
$text = "
diff --git a/e107_languages/English/admin/lan_db_verify.php b/e107_languages/English/admin/lan_db_verify.php
index 658a6b086..5132935ac 100644
--- a/e107_languages/English/admin/lan_db_verify.php
+++ b/e107_languages/English/admin/lan_db_verify.php
@@ -25,15 +25,15 @@ define("DBVLAN_13", "Table missing!");
define("DBVLAN_14", "Choose table(s) to validate");
define("DBVLAN_15", "Start Verify");
define("DBVLAN_16", "SQL Verification");
-define("DBVLAN_17", "Back");
-define("DBVLAN_18", "tables");
+
define("DBVLAN_19", "Attempt to Fix");
-define("DBVLAN_20", "Attempting to fix tables");
+
define("DBVLAN_21", "Fix Selected Items");
-define("DBVLAN_22", " is not readable");
+define("DBVLAN_22", "[x] is not readable");
define("DBVLAN_23", "Database Utilities");
define("DBVLAN_24", "Please select action.");
define("DBVLAN_25", "Index missing!");
+define("DBVLAN_26", "[x] table(s) have problems.");
// IMPORTANT NOTE: DBLAN has been replaced by DBBLAN in this file since 0.7 due to conflicts with db.php