diff --git a/e107_admin/db.php b/e107_admin/db.php
index 082b5457a..25b061f51 100644
--- a/e107_admin/db.php
+++ b/e107_admin/db.php
@@ -9,8 +9,8 @@
* Administration - Database Utilities
*
* $Source: /cvs_backup/e107_0.8/e107_admin/db.php,v $
- * $Revision: 1.22 $
- * $Date: 2009-08-28 17:56:24 $
+ * $Revision: 1.23 $
+ * $Date: 2009-08-29 15:30:41 $
* $Author: e107coders $
*
*/
@@ -54,13 +54,13 @@ if(isset($_POST['trigger_db_execute']))
}
}
-if(isset($_POST['db_update']))
+if(isset($_POST['db_update']) || $_GET['mode']=='db_update')
{
header("location: ".e_ADMIN."e107_update.php");
exit();
}
-if(isset($_POST['verify_sql']))
+if(isset($_POST['verify_sql']) || $_GET['mode']=='verify_sql')
{
header("location: ".e_ADMIN."db_verify.php");
exit();
@@ -77,247 +77,596 @@ require_once (e_HANDLER."form_handler.php");
$frm = new e_form();
$emessage = &eMessage::getInstance(); //nothing wrong with doing it twice
-if(isset($_POST['importCorePrefsForm']))
-{
- importCorePrefsForm();
-}
+/* No longer needed after XML feature added.
-if(isset($_POST['exportForm']))
-{
- exportXmlForm();
- exit();
-}
-
-
-if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2'])))
-{
- del_pref_val();
-}
-
-if(isset($_POST['pref_editor']) || isset($_POST['delpref']) || isset($_POST['delpref_checked']))
-{
- pref_editor();
- require_once ("footer.php");
- exit();
-}
-
-if(isset($_POST['optimize_sql']))
-{
- optimizesql($mySQLdefaultdb);
-}
-
-if(isset($_POST['sc_override_scan']))
-{
- scan_override();
-}
-
-if(isset($_POST['backup_core']))
+if(isset($_POST['backup_core']) || $_GET['mode']=='backup_core')
{
backup_core();
//message_handler("MESSAGE", DBLAN_1);
$emessage->add(DBLAN_1, E_MESSAGE_SUCCESS);
}
-if(isset($_POST['delplug']))
+*/
+
+
+
+
+
+
+
+
+
+$st = new system_tools;
+
+require_once ("footer.php");
+
+class system_tools
{
- delete_plugin_entry();
-
-}
-
-if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || $_POST['delplug'])
-{
- plugin_viewscan();
- require_once ("footer.php");
- exit();
-}
-
-if(isset($_POST['verify_sql_record']) || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
-{
- verify_sql_record();
- require_once ("footer.php");
- exit();
-}
-
-if(isset($_POST['upload']))
-{
- importCorePrefs();
+ public $_options = array();
+
+
+ function __construct()
+ {
+ global $mySQLdefaultdb;
+
+ $this->_options = array(
+ "db_update" => array('diz'=>DBLAN_15, 'label'=>DBLAN_16),
+ "verify_sql" => array('diz'=>DBLAN_4, 'label'=>DBLAN_5),
+ 'optimize_sql' => array('diz'=>DBLAN_6, 'label'=> DBLAN_7),
+ 'plugin_scan' => array('diz'=>DBLAN_28, 'label'=> DBLAN_29),
+ 'pref_editor' => array('diz'=>DBLAN_19, 'label'=> DBLAN_20),
+ // 'backup_core' => array('diz'=>DBLAN_8, 'label'=> DBLAN_9),
+ 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36),
+ 'importForm' => array('diz'=>DBLAN_59, 'label'=> DBLAN_59),
+ 'exportForm' => array('diz'=>DBLAN_58, 'label'=> DBLAN_58),
+ 'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56)
+ );
+
+ //TODO Merge db_verify.php into db.php
+
+ if(!vartrue($_GET['mode']))
+ {
+ $this->render_options();
+ }
+
+ if(isset($_POST['delplug']))
+ {
+ $this->delete_plugin_entry();
+ }
+
+ if(isset($_POST['upload']))
+ {
+ $this->importCorePrefs();
+ }
+
+ if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2'])))
+ {
+ $this->del_pref_val();
+ }
+
+ if(isset($_POST['verify_sql_record']) || $_GET['mode']=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
+ {
+ // $this->verify_sql_record(); - currently performed in db_verify.php
+ }
+
+ if(isset($_POST['importForm']) || $_GET['mode']=='importForm')
+ {
+ $this->importForm();
+ }
+
+ if(isset($_POST['exportForm']) || $_GET['mode']=='exportForm')
+ {
+ $this->exportXmlForm();
+ }
+
+ if(isset($_POST['optimize_sql']) || $_GET['mode']=='optimize_sql')
+ {
+ $this->optimizesql($mySQLdefaultdb);
+ }
+
+ if(isset($_POST['pref_editor']) || $_GET['mode']=='pref_editor' || isset($_POST['delpref']) || isset($_POST['delpref_checked']))
+ {
+ $this->pref_editor();
+ }
+
+ if(isset($_POST['sc_override_scan']) || $_GET['mode']=='sc_override_scan')
+ {
+ $this->scan_override();
+ }
+
+ if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || $_POST['delplug'] || $_GET['mode']=='plugin_scan')
+ {
+ $this->plugin_viewscan();
+ }
+
+
+
+ }
+
+ /**
+ * Delete selected preferences.
+ * @return
+ */
+ function del_pref_val()
+ {
+ global $pref, $e107cache, $emessage;
+ $del = array_keys($_POST['delpref']);
+ $delpref = $del[0];
+
+ if($delpref)
+ {
+ unset($pref[$delpref]);
+ $deleted_list .= "
".$delpref."";
+ }
+
+ if($_POST['delpref2'])
+ {
+
+ foreach($_POST['delpref2'] as $k => $v)
+ {
+ $deleted_list .= "".$k."";
+ unset($pref[$k]);
+ }
+ }
+
+ save_prefs();
+ $emessage->add(LAN_DELETED."");
+ $e107cache->clear();
+ //$e107->ns->tablerender(LAN_DELETED,$message);
+ }
+
+ private function delete_plugin_entry()
+ {
+ global $sql, $emessage;
+
+ $del = array_keys($_POST['delplug']);
+ if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1"))
+ {
+ $emessage->add(LAN_DELETED, E_MESSAGE_SUCCESS);
+ }
+ else
+ {
+ $emessage->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING);
+ }
+
+ }
+
+
+
+ /**
+ * Render Options
+ * @return
+ */
+ private function render_options()
+ {
+ $frm = e107::getSingleton('e_form');
+
+ $text = "
+
+ ";
+
+ $emessage = eMessage::getInstance();
+ e107::getRender()->tablerender(DBLAN_10, $emessage->render().$text);
+ }
+
+
+ /**
+ * Import XML Form
+ * @return
+ */
+ private function importForm()
+ {
+ // Get largest allowable file upload
+
+ $frm = e107::getSingleton('e_form');
+
+
+ require_once(e_HANDLER.'upload_handler.php');
+ $max_file_size = get_user_max_upload();
+
+ $text = "
+ \n";
+
+ $emessage = eMessage::getInstance();
+ e107::getRender()->tablerender(DBLAN_59, $emessage->render().$text);
+
+ }
+
+ /**
+ * Export XML Dump
+ * @return
+ */
+ private function exportXmlForm()
+ {
+
+ $frm = e107::getSingleton('e_form');
+
+ $text = " ";
+
+
+ e107::getRender()->tablerender("Export Options", $text);
+
+
+ }
+
+ /**
+ * Import XML Dump
+ * @return
+ */
+ private function importCorePrefs()
+ {
+ //TODO - move to own class and make generic.
+ // SecretR - structure changes / improvements proposal
+
+ $xmlArray = e107::getSingleton('xmlClass')->loadXMLfile($_FILES['file_userfile']['tmp_name'][0],'advanced');
+
+ if(vartrue($xmlArray['prefs']['core'])) // Save Core Prefs
+ {
+ foreach ($xmlArray['prefs']['core'] as $val)
+ {
+ $value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
+ // print_a($val['@value']);
+ e107::getConfig()->set($val['@attributes']['name'], $value);
+ }
+
+ e107::getConfig()->save(FALSE);
+ }
+ }
+
+ /**
+ * Optimize SQL
+ * @return
+ */
+ private function optimizesql($mySQLdefaultdb)
+ {
+ // global $emessage;
+ $result = mysql_list_tables($mySQLdefaultdb);
+ while($row = mysql_fetch_row($result))
+ {
+ mysql_query("OPTIMIZE TABLE ".$row[0]);
+ }
+
+ // $emessage->add(DBLAN_11." $mySQLdefaultdb ".DBLAN_12, E_MESSAGE_SUCCESS);
+ e107::getRender()->tablerender(DBLAN_7, DBLAN_11." $mySQLdefaultdb ".DBLAN_12);
+ }
+
+ /**
+ * Preferences Editor
+ * @return
+ */
+ private function pref_editor()
+ {
+ //TODO Add drop-down filter for editing plugin prefs also.
+
+ global $pref, $e107, $emessage, $frm;
+ ksort($pref);
+
+ $text = "
+ \n\n";
+
+ //$text .= "\n";
+ e107::getRender()->tablerender(DBLAN_10.' - '.DBLAN_20, $emessage->render().$text);
+
+ return $text;
+ }
+
+ /**
+ * Preferences Editor
+ * @return
+ */
+ private function scan_override()
+ {
+ global $pref, $emessage;
+
+ require_once(e_HANDLER.'file_class.php');
+ $f = new e_file;
+
+ $scList = '';
+ $fList = $f->get_files(e_FILE.'shortcode/override', '\.sc$');
+ if(count($fList))
+ {
+ $tmp = array();
+ foreach($fList as $file)
+ {
+ $tmp[] = strtoupper(substr($file['fname'], 0, -3));
+ }
+ $scList = implode(',', $tmp);
+ unset($tmp);
+ }
+ $pref['sc_override'] = $scList;
+ save_prefs();
+ // $emessage->add(DBLAN_57.':
'.$pref['sc_override'], E_MESSAGE_SUCCESS);
+ e107::getRender()->tablerender(DBLAN_56, DBLAN_57.':
'.$pref['sc_override']);
+ }
+
+ /**
+ * Plugin Folder Scanner
+ * @return
+ */
+ private function plugin_viewscan()
+ {
+ $error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34);
+ $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
+
+ global $sql, $e107, $emessage, $frm;
+
+ require_once (e_HANDLER."plugin_class.php");
+ $ep = new e107plugin();
+ $ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table.
+ $ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table.
+
+ /* we all are awaiting for PHP5 only support - method chaining...
+ $emessage->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS)
+ ->add("".DBLAN_13."", E_MESSAGE_SUCCESS)
+ ->add(DBLAN_30);
+ */
+
+ $emessage->add(DBLAN_23, E_MESSAGE_SUCCESS);
+ $emessage->add("".DBLAN_13."", E_MESSAGE_SUCCESS);
+ $emessage->add(DBLAN_30);
+
+ $text = "
+
+ ";
+
+ e107::getRender()->tablerender(DBLAN_10.' - '.DBLAN_22, $emessage->render().$text);
+ }
}
-
-
//XXX - what is this for (backup core)?
-
-$text = "
-
- ";
-
-$e107->ns->tablerender(DBLAN_10, $emessage->render().$text);
-
-
-function exportXmlForm()
+function db_adminmenu()
{
+ global $st;
- global $frm;
-
- $text = " ";
-
-
- e107::getRender()->tablerender("Export Options", $text);
-
-
+ foreach($st->_options as $key=>$val)
+ {
+ $var[$key]['text'] = $val['label'];
+ $var[$key]['link'] = e_SELF."?mode=".$key;
+ }
+
+ e_admin_menu(DBLAN_10, $_GET['mode'], $var);
}
+
+
function exportXmlFile()
{
@@ -380,25 +729,7 @@ function exportXmlFile()
exit;
}
-function importCorePrefs()
-{
- //TODO - move to own class and make generic.
- // SecretR - structure changes / improvements proposal
-
- $xmlArray = e107::getSingleton('xmlClass')->loadXMLfile($_FILES['file_userfile']['tmp_name'][0],'advanced');
-
- if(vartrue($xmlArray['prefs']['core'])) // Save Core Prefs
- {
- foreach ($xmlArray['prefs']['core'] as $val)
- {
- $value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
- // print_a($val['@value']);
- e107::getConfig()->set($val['@attributes']['name'], $value);
- }
-
- e107::getConfig()->save(FALSE);
- }
-}
+
function importTables()
{
@@ -406,50 +737,7 @@ function importTables()
}
-function importCorePrefsForm()
-{
- //TODO - Fix Core XML class - array returned is incorrect.
-// importCorePrefs();
-// return;
-
- // Get largest allowable file upload
- $frm = e107::getSingleton('e_form');
-
- require_once(e_HANDLER.'upload_handler.php');
- $max_file_size = get_user_max_upload();
-
- $text = "
- \n";
-
-
- e107::getRender()->tablerender("Import e107 Preferences", $text);
-
-
-}
function table_list()
{
@@ -458,6 +746,7 @@ function table_list()
global $mySQLdefaultdb;
$exclude = array();
+ $exclude[] = "core";
$exclude[] = "rbinary";
$exclude[] = "parser";
$exclude[] = "tmp";
@@ -511,6 +800,7 @@ function table_list()
return $tabs;
}
+/* Still needed?
function backup_core()
{
@@ -522,255 +812,10 @@ function backup_core()
}
}
-function optimizesql($mySQLdefaultdb)
-{
- global $emessage;
- $result = mysql_list_tables($mySQLdefaultdb);
- while($row = mysql_fetch_row($result))
- {
- mysql_query("OPTIMIZE TABLE ".$row[0]);
- }
-
- $emessage->add(DBLAN_11." $mySQLdefaultdb ".DBLAN_12, E_MESSAGE_SUCCESS);
-}
-
-function scan_override()
-{
- global $pref, $emessage;
-
- require_once(e_HANDLER.'file_class.php');
- $f = new e_file;
-
- $scList = '';
- $fList = $f->get_files(e_FILE.'shortcode/override', '\.sc$');
- if(count($fList))
- {
- $tmp = array();
- foreach($fList as $file)
- {
- $tmp[] = strtoupper(substr($file['fname'], 0, -3));
- }
- $scList = implode(',', $tmp);
- unset($tmp);
- }
- $pref['sc_override'] = $scList;
- save_prefs();
- $emessage->add(DBLAN_57.':
'.$pref['sc_override'], E_MESSAGE_SUCCESS);
-}
-
-function plugin_viewscan()
-{
- $error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34);
- $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
-
- global $sql, $e107, $emessage, $frm;
-
- require_once (e_HANDLER."plugin_class.php");
- $ep = new e107plugin();
- $ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table.
- $ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table.
-
- /* we all are awaiting for PHP5 only support - method chaining...
- $emessage->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS)
- ->add("".DBLAN_13."", E_MESSAGE_SUCCESS)
- ->add(DBLAN_30);
- */
-
- $emessage->add(DBLAN_23, E_MESSAGE_SUCCESS);
- $emessage->add("".DBLAN_13."", E_MESSAGE_SUCCESS);
- $emessage->add(DBLAN_30);
-
- $text = "
-
- ";
-
- $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_22, $emessage->render().$text);
-}
-
-function pref_editor()
-{
- global $pref, $e107, $emessage, $frm;
- ksort($pref);
-
- $text = "
-
+*/
- ";
- //$text .= "\n";
- $e107->ns->tablerender(DBLAN_10.' - '.DBLAN_20, $emessage->render().$text);
-
- return $text;
-}
-
-function del_pref_val()
-{
- global $pref, $e107cache, $emessage;
- $del = array_keys($_POST['delpref']);
- $delpref = $del[0];
-
- if($delpref)
- {
- unset($pref[$delpref]);
- $deleted_list .= "".$delpref."";
- }
-
- if($_POST['delpref2'])
- {
-
- foreach($_POST['delpref2'] as $k => $v)
- {
- $deleted_list .= "".$k."";
- unset($pref[$k]);
- }
- }
-
- save_prefs();
- $emessage->add(LAN_DELETED."");
- $e107cache->clear();
- //$e107->ns->tablerender(LAN_DELETED,$message);
-
-
-}
-
-function delete_plugin_entry()
-{
- global $sql, $emessage;
-
- $del = array_keys($_POST['delplug']);
- if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1"))
- {
- $emessage->add(LAN_DELETED, E_MESSAGE_SUCCESS);
- }
- else
- {
- $emessage->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING);
- }
-
-}
-
-function verify_sql_record()
+function verify_sql_record() // deprecated by db_verify.php ( i think).
{
global $emessage, $sql, $sql2, $sql3, $frm, $e107, $tp;
@@ -1179,7 +1224,7 @@ function verify_sql_record()
}
}
-require_once ("footer.php");
+
/**
* Handle page DOM within the page header