diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index ae120c984ed8e2ef543b7e6b3e9d70660822b44e..0319f47b3d851110cdae962e7b8058b2cc13acdb 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -1,6 +1,6 @@ diffrec($record_old, $record_new); - $diffrec_full = $tmp['diff_rec']; - $diff_num = $tmp['diff_num']; - unset($tmp); - // Insert the server_id, if the record has a server_id + if($force_update == true) { + //* We force a update even if no record has changed + $diffrec_full = array('new' => $record_new, 'old' => $record_old); + $diff_num = count($record_new); + } else { + //* get the difference record between old and new record + $tmp = $this->diffrec($record_old, $record_new); + $diffrec_full = $tmp['diff_rec']; + $diff_num = $tmp['diff_num']; + unset($tmp); + } + + //* Insert the server_id, if the record has a server_id $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0; if(isset($record_new['server_id'])) $server_id = $record_new['server_id']; if($diff_num > 0) { - //print_r($diff_num); - //print_r($diffrec_full); $diffstr = $app->db->quote(serialize($diffrec_full)); $username = $app->db->quote($_SESSION['s']['user']['username']); $dbidx = $primary_field.':'.$primary_id; @@ -323,11 +328,7 @@ class db { public function datalogUpdate($tablename, $update_data, $index_field, $index_value, $force_update = false) { global $app; - if($force_update == true) { - $old_rec = array(); - } else { - $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - } + $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); if(is_array($update_data)) { $update_data_str = ''; @@ -340,7 +341,7 @@ class db { $this->query("UPDATE $tablename SET $update_data_str WHERE $index_field = '$index_value'"); $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec); + $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update); return true; } diff --git a/interface/web/tools/dns_resync.php b/interface/web/tools/dns_resync.php deleted file mode 100644 index c80735df3e4a909d9a23bab5e0e227fd41977687..0000000000000000000000000000000000000000 --- a/interface/web/tools/dns_resync.php +++ /dev/null @@ -1,84 +0,0 @@ -auth->check_module_permissions('admin'); - -//* This is only allowed for administrators -if(!$app->auth->is_admin()) die('only allowed for administrators.'); - -$app->uses('tpl,validate_dns'); - -$app->tpl->newTemplate('form.tpl.htm'); -$app->tpl->setInclude('content_tpl', 'templates/dns_resync.htm'); -$msg = ''; -$error = ''; - -// Resyncing dns zones -if(isset($_POST['resync']) && $_POST['resync'] == 1) { - $zones = $app->db->queryAllRecords("SELECT id,origin,serial FROM dns_soa WHERE active = 'Y'"); - if(is_array($zones) && !empty($zones)) { - foreach($zones as $zone) { - $records = $app->db->queryAllRecords("SELECT id,serial FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'"); - if(is_array($records)) { - foreach($records as $rec) { - $new_serial = $app->validate_dns->increase_serial($rec["serial"]); - $app->db->datalogUpdate('dns_rr', "serial = '".$new_serial."'", 'id', $rec['id']); - - } - } - $new_serial = $app->validate_dns->increase_serial($zone["serial"]); - $app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone['id']); - $msg .= "Resynced: ".$zone['origin'].'
'; - } - } else { - $error .= "No zones found to sync.
"; - } - -} - -$app->tpl->setVar('msg',$msg); -$app->tpl->setVar('error',$error); - - -//* load language file -/* -$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_mailbox_import.lng'; -include($lng_file); -$app->tpl->setVar($wb); -*/ - -$app->tpl_defaults(); -$app->tpl->pparse(); - - -?> \ No newline at end of file diff --git a/interface/web/tools/lib/lang/en.lng b/interface/web/tools/lib/lang/en.lng index 1dee19df804ea68b1f17fc29b744352c65eb0a67..0122dcd8f2c69c957d5cf86a578eba78f370b211 100644 --- a/interface/web/tools/lib/lang/en.lng +++ b/interface/web/tools/lib/lang/en.lng @@ -4,6 +4,6 @@ $wb['Settings'] = 'Settings'; $wb['ISPConfig Tools'] = 'ISPConfig Tools'; $wb['Password and Language'] = 'Password and Language'; $wb['ispconfig_tools_note'] = 'This module allows you to change the password and language and to start a resync of the DNS records.'; -$wb['Dns Tools'] = 'Dns Tools'; +$wb['Sync Tools'] = 'Sync Tools'; $wb['Resync'] = 'Resync'; ?> \ No newline at end of file diff --git a/interface/web/tools/lib/lang/en_resync.lng b/interface/web/tools/lib/lang/en_resync.lng new file mode 100644 index 0000000000000000000000000000000000000000..ae87bbda5348ae1af049f6b9cf785ac18c77bd46 --- /dev/null +++ b/interface/web/tools/lib/lang/en_resync.lng @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/interface/web/tools/lib/menu.d/dns_resync.menu.php b/interface/web/tools/lib/menu.d/resync.menu.php similarity index 69% rename from interface/web/tools/lib/menu.d/dns_resync.menu.php rename to interface/web/tools/lib/menu.d/resync.menu.php index f6b6ae00a6ccfaef88cd9cb3bc2fd965ccfc2b52..3ef45fb0e7e86c1bebd870c227ca2a0821ba2cde 100644 --- a/interface/web/tools/lib/menu.d/dns_resync.menu.php +++ b/interface/web/tools/lib/menu.d/resync.menu.php @@ -9,10 +9,10 @@ $items = array(); $items[] = array( 'title' => 'Resync', 'target' => 'content', - 'link' => 'tools/dns_resync.php'); + 'link' => 'tools/resync.php'); -$module['nav'][] = array( 'title' => 'DNS Tools', +$module['nav'][] = array( 'title' => 'Sync Tools', 'open' => 1, 'items' => $items); diff --git a/interface/web/tools/lib/module.conf.php b/interface/web/tools/lib/module.conf.php index a88aab0b5e9f87a7b8042a83f9846ce1147b5e52..3190d70557f94b15ffd8379f44c861aa9995cea6 100644 --- a/interface/web/tools/lib/module.conf.php +++ b/interface/web/tools/lib/module.conf.php @@ -29,7 +29,7 @@ if (is_dir($menu_dir)) { if ($dh = opendir($menu_dir)) { //** Go through all files in the menu dir while (($file = readdir($dh)) !== false) { - if($file != '.' && $file != '..' && substr($file,-9,9) == '.menu.php') { + if($file != '.' && $file != '..' && substr($file,-9,9) == '.menu.php' && $file != 'dns_resync.menu.php') { include_once($menu_dir.'/'.$file); } } diff --git a/interface/web/tools/resync.php b/interface/web/tools/resync.php new file mode 100644 index 0000000000000000000000000000000000000000..86ba27dfa98eb1ddc28d3d426ebfd83a983e0f78 --- /dev/null +++ b/interface/web/tools/resync.php @@ -0,0 +1,166 @@ +auth->check_module_permissions('admin'); + +//* This is only allowed for administrators +if(!$app->auth->is_admin()) die('only allowed for administrators.'); + +$app->uses('tpl,validate_dns'); + +$app->tpl->newTemplate('form.tpl.htm'); +$app->tpl->setInclude('content_tpl', 'templates/resync.htm'); +$msg = ''; +$error = ''; + +//* load language file +$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_resync.lng'; +include($lng_file); +$app->tpl->setVar($wb); + +//* Resyncing websites +if(isset($_POST['resync_sites']) && $_POST['resync_sites'] == 1) { + $db_table = 'web_domain'; + $index_field = 'domain_id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced Website: ".$rec['domain'].'
'; + } + } +} + +//* Resyncing ftp +if(isset($_POST['resync_ftp']) && $_POST['resync_ftp'] == 1) { + $db_table = 'ftp_user'; + $index_field = 'ftp_user_id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced FTP user: ".$rec['username'].'
'; + } + } +} + +//* Resyncing shell +if(isset($_POST['resync_shell']) && $_POST['resync_shell'] == 1) { + $db_table = 'shell_user'; + $index_field = 'shell_user_id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced Shell user: ".$rec['username'].'
'; + } + } +} + +//* Resyncing Cronjobs +if(isset($_POST['resync_cron']) && $_POST['resync_cron'] == 1) { + $db_table = 'cron'; + $index_field = 'id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced Cron: ".$rec['id'].'
'; + } + } +} + +//* Resyncing Databases +if(isset($_POST['resync_db']) && $_POST['resync_db'] == 1) { + $db_table = 'web_database'; + $index_field = 'database_id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced Database: ".$rec['database_name'].'
'; + } + } +} + +//* Resyncing Mailboxes +if(isset($_POST['resync_mailbox']) && $_POST['resync_mailbox'] == 1) { + $db_table = 'mail_user'; + $index_field = 'mailuser_id'; + $sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; + $records = $app->db->queryAllRecords($sql); + if(is_array($records)) { + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $msg .= "Resynced Mailbox: ".$rec['email'].'
'; + } + } +} + + +//* Resyncing dns zones +if(isset($_POST['resync_dns']) && $_POST['resync_dns'] == 1) { + $zones = $app->db->queryAllRecords("SELECT id,origin,serial FROM dns_soa WHERE active = 'Y'"); + if(is_array($zones) && !empty($zones)) { + foreach($zones as $zone) { + $records = $app->db->queryAllRecords("SELECT id,serial FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'"); + if(is_array($records)) { + foreach($records as $rec) { + $new_serial = $app->validate_dns->increase_serial($rec["serial"]); + $app->db->datalogUpdate('dns_rr', "serial = '".$new_serial."'", 'id', $rec['id']); + + } + } + $new_serial = $app->validate_dns->increase_serial($zone["serial"]); + $app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone['id']); + $msg .= "Resynced DNS zone: ".$zone['origin'].'
'; + } + } else { + $error .= "No zones found to sync.
"; + } + +} + +$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('error',$error); + +$app->tpl_defaults(); +$app->tpl->pparse(); + + +?> \ No newline at end of file diff --git a/interface/web/tools/templates/dns_resync.htm b/interface/web/tools/templates/dns_resync.htm deleted file mode 100644 index 372206af970caefdb22abb86e0e0606c98783790..0000000000000000000000000000000000000000 --- a/interface/web/tools/templates/dns_resync.htm +++ /dev/null @@ -1,31 +0,0 @@ -

DNS Resync

-

- -
- -
-
DNS Resync -
-

Resync DNS Records

-
- -
-
-
- - -

-
- -

ERROR

-
- - - -
- - -
-
- -
diff --git a/interface/web/tools/templates/resync.htm b/interface/web/tools/templates/resync.htm new file mode 100644 index 0000000000000000000000000000000000000000..196fb7e0de78f08ae7118e4d82a2aaf94be0b1c8 --- /dev/null +++ b/interface/web/tools/templates/resync.htm @@ -0,0 +1,67 @@ +

{tmpl_var name="head_txt"}

+

+ +
+ +
+
{tmpl_var name="legend_txt"} +
+

{tmpl_var name="resync_sites_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_ftp_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_shell_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_cron_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_db_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_mailbox_txt"}

+
+ +
+
+
+

{tmpl_var name="resync_dns_txt"}

+
+ +
+
+
+ + +

+
+ +

ERROR

+
+ + + +
+ + +
+
+ +