Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Open sidebar
isp
ISPConfig 3
Commits
d02193c1
Commit
d02193c1
authored
Apr 23, 2012
by
tbrehm
Browse files
Implemented: FS#2187 - Add a config resync toll for websites, ftp users, shell users and mailboxes.
parent
0cf0ee8e
Changes
8
Hide whitespace changes
Inline
Side-by-side
interface/lib/classes/db_mysql.inc.php
View file @
d02193c1
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
Copyright (c) 2007
-2012
, Till Brehm, projektfarm Gmbh
, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
...
...
@@ -257,29 +257,34 @@ class db {
}
//** Function to fill the datalog with a full differential record.
public
function
datalogSave
(
$db_table
,
$action
,
$primary_field
,
$primary_id
,
$record_old
,
$record_new
)
{
public
function
datalogSave
(
$db_table
,
$action
,
$primary_field
,
$primary_id
,
$record_old
,
$record_new
,
$force_update
=
false
)
{
global
$app
,
$conf
;
// Insert backticks only for incomplete table names.
//
*
Insert backticks only for incomplete table names.
if
(
stristr
(
$db_table
,
'.'
))
{
$escape
=
''
;
}
else
{
$escape
=
'`'
;
}
$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
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
;
}
...
...
interface/web/tools/lib/lang/en.lng
View file @
d02193c1
...
...
@@ -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
interface/web/tools/lib/lang/en_resync.lng
0 → 100644
View file @
d02193c1
<?php
$wb
[
'head_txt'
]
=
'Resync Tool'
;
$wb
[
'legend_txt'
]
=
'Resync'
;
$wb
[
'resync_sites_txt'
]
=
'Resync Websites'
;
$wb
[
'resync_ftp_txt'
]
=
'Resync FTP users'
;
$wb
[
'resync_shell_txt'
]
=
'Resync shell users'
;
$wb
[
'resync_cron_txt'
]
=
'Resync cronjobs'
;
$wb
[
'resync_db_txt'
]
=
'Resync database config'
;
$wb
[
'resync_mailbox_txt'
]
=
'Resync Mailboxes'
;
$wb
[
'resync_dns_txt'
]
=
'Resync DNS records'
;
$wb
[
'btn_start_txt'
]
=
'Start'
;
$wb
[
'btn_cancel_txt'
]
=
'Cancel'
;
?>
\ No newline at end of file
interface/web/tools/lib/menu.d/
dns_
resync.menu.php
→
interface/web/tools/lib/menu.d/resync.menu.php
View file @
d02193c1
...
...
@@ -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
);
...
...
interface/web/tools/lib/module.conf.php
View file @
d02193c1
...
...
@@ -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
);
}
}
...
...
interface/web/tools/
dns_
resync.php
→
interface/web/tools/resync.php
View file @
d02193c1
<?php
/*
Copyright (c) 20
08
, Till Brehm, projektfarm Gmbh
Copyright (c) 20
12
, Till Brehm, projektfarm Gmbh
, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
...
...
@@ -39,12 +39,102 @@ 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'
);
$app
->
tpl
->
setInclude
(
'content_tpl'
,
'templates/resync.htm'
);
$msg
=
''
;
$error
=
''
;
// Resyncing dns zones
if
(
isset
(
$_POST
[
'resync'
])
&&
$_POST
[
'resync'
]
==
1
)
{
//* 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'
]
.
'<br />'
;
}
}
}
//* 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'
]
.
'<br />'
;
}
}
}
//* 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'
]
.
'<br />'
;
}
}
}
//* 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'
]
.
'<br />'
;
}
}
}
//* 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'
]
.
'<br />'
;
}
}
}
//* 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'
]
.
'<br />'
;
}
}
}
//* 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
)
{
...
...
@@ -58,7 +148,7 @@ if(isset($_POST['resync']) && $_POST['resync'] == 1) {
}
$new_serial
=
$app
->
validate_dns
->
increase_serial
(
$zone
[
"serial"
]);
$app
->
db
->
datalogUpdate
(
'dns_soa'
,
"serial = '"
.
$new_serial
.
"'"
,
'id'
,
$zone
[
'id'
]);
$msg
.
=
"Resynced: "
.
$zone
[
'origin'
]
.
'<br />'
;
$msg
.
=
"Resynced
DNS zone
: "
.
$zone
[
'origin'
]
.
'<br />'
;
}
}
else
{
$error
.
=
"No zones found to sync.<br />"
;
...
...
@@ -69,14 +159,6 @@ if(isset($_POST['resync']) && $_POST['resync'] == 1) {
$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
();
...
...
interface/web/tools/templates/dns_resync.htm
deleted
100644 → 0
View file @
0cf0ee8e
<h2>
DNS Resync
</h2>
<p><tmpl_var
name=
"list_desc_txt"
></p>
<div
class=
"panel panel_language_import"
>
<div
class=
"pnl_formsarea"
>
<fieldset
class=
"inlineLabels"
><legend>
DNS Resync
</legend>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
Resync DNS Records
</p>
<div
class=
"multiField"
>
<input
id=
"resync"
type=
"checkbox"
value=
"1"
name=
"resync"
checked
/>
</div>
</div>
</fieldset>
<tmpl_if
name=
"msg"
>
<div
id=
"OKMsg"
><p><tmpl_var
name=
"msg"
></p></div>
</tmpl_if>
<tmpl_if
name=
"error"
>
<div
id=
"errorMsg"
><h3>
ERROR
</h3><ol><tmpl_var
name=
"error"
></ol></div>
</tmpl_if>
<input
type=
"hidden"
name=
"id"
value=
"{tmpl_var name='id'}"
>
<div
class=
"buttonHolder buttons"
>
<button
class=
"positive iconstxt icoPositive"
type=
"button"
value=
"Import"
onClick=
"submitForm('pageForm','tools/dns_resync.php');"
><span>
Start
</span></button>
<button
class=
"negative iconstxt icoNegative"
type=
"button"
value=
"Cancel"
onClick=
"loadContent('tools/index.php');"
><span>
Cancel
</span></button>
</div>
</div>
</div>
interface/web/tools/templates/resync.htm
0 → 100644
View file @
d02193c1
<h2>
{tmpl_var name="head_txt"}
</h2>
<p><tmpl_var
name=
"list_desc_txt"
></p>
<div
class=
"panel panel_language_import"
>
<div
class=
"pnl_formsarea"
>
<fieldset
class=
"inlineLabels"
><legend>
{tmpl_var name="legend_txt"}
</legend>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_sites_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_sites"
type=
"checkbox"
value=
"1"
name=
"resync_sites"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_ftp_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_ftp"
type=
"checkbox"
value=
"1"
name=
"resync_ftp"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_shell_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_shell"
type=
"checkbox"
value=
"1"
name=
"resync_shell"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_cron_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_cron"
type=
"checkbox"
value=
"1"
name=
"resync_cron"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_db_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_db"
type=
"checkbox"
value=
"1"
name=
"resync_db"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_mailbox_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_mailbox"
type=
"checkbox"
value=
"1"
name=
"resync_mailbox"
/>
</div>
</div>
<div
class=
"ctrlHolder"
>
<p
class=
"label"
>
{tmpl_var name="resync_dns_txt"}
</p>
<div
class=
"multiField"
>
<input
id=
"resync_dns"
type=
"checkbox"
value=
"1"
name=
"resync_dns"
/>
</div>
</div>
</fieldset>
<tmpl_if
name=
"msg"
>
<div
id=
"OKMsg"
><p><tmpl_var
name=
"msg"
></p></div>
</tmpl_if>
<tmpl_if
name=
"error"
>
<div
id=
"errorMsg"
><h3>
ERROR
</h3><ol><tmpl_var
name=
"error"
></ol></div>
</tmpl_if>
<input
type=
"hidden"
name=
"id"
value=
"{tmpl_var name='id'}"
>
<div
class=
"buttonHolder buttons"
>
<button
class=
"positive iconstxt icoPositive"
type=
"button"
value=
"Import"
onClick=
"submitForm('pageForm','tools/resync.php');"
><span>
{tmpl_var name="btn_start_txt"}
</span></button>
<button
class=
"negative iconstxt icoNegative"
type=
"button"
value=
"Cancel"
onClick=
"loadContent('tools/index.php');"
><span>
{tmpl_var name="btn_cancel_txt"}
</span></button>
</div>
</div>
</div>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment