Allow users to migrate IP/email bans
This commit is contained in:
parent
a26b25e36c
commit
a9d8d13ebd
40
install/migrateBans.php
Normal file
40
install/migrateBans.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
define('IN_SCRIPT',1);
|
||||||
|
define('HESK_PATH','../');
|
||||||
|
require(HESK_PATH . 'install/install_functions.inc.php');
|
||||||
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
|
||||||
|
$updateSuccess = true;
|
||||||
|
|
||||||
|
hesk_dbConnect();
|
||||||
|
|
||||||
|
// Get the ID of the creator
|
||||||
|
$creator = $_POST['user'];
|
||||||
|
|
||||||
|
// Insert the email bans
|
||||||
|
$emailBanRS = hesk_dbQuery("SELECT `Email` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_emails`");
|
||||||
|
while ($row = hesk_dbFetchAssoc($emailBanRS)) {
|
||||||
|
hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."banned_emails` (`email`, `banned_by`, `dt`)
|
||||||
|
VALUES ('".hesk_dbEscape($row['Email'])."', ".$creator.", NOW())");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the IP bans
|
||||||
|
$ipBanRS = hesk_dbQuery("SELECT `RangeStart`, `RangeEnd` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_ips`");
|
||||||
|
while ($row = hesk_dbFetchAssoc($ipBanRS)) {
|
||||||
|
$ipFrom = long2ip($row['RangeStart']);
|
||||||
|
$ipTo = long2ip($row['RangeEnd']);
|
||||||
|
$ipDisplay = $ipFrom . ' - ' . $ipTo;
|
||||||
|
hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."banned_ips` (`ip_from`, `ip_to`, `ip_display`, `banned_by`, `dt`)
|
||||||
|
VALUES (".$row['RangeStart'].", ".$row['RangeEnd'].", '".$ipDisplay."', ".$creator.", NOW())");
|
||||||
|
}
|
||||||
|
// Migration Complete. Drop Tables.
|
||||||
|
hesk_dbQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_ips`");
|
||||||
|
hesk_dbQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_emails`");
|
||||||
|
|
||||||
|
if ($updateSuccess) {
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h1>Installation / Update complete!</h1>
|
||||||
|
<p>Please delete the <b>install</b> folder for security reasons, and then proceed back to the <a href="../">Help Desk</a></p>
|
||||||
|
|
||||||
|
<?php } ?>
|
@ -4,23 +4,31 @@ define('HESK_PATH','../');
|
|||||||
require(HESK_PATH . 'install/install_functions.inc.php');
|
require(HESK_PATH . 'install/install_functions.inc.php');
|
||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
|
|
||||||
$updateSuccess = true;
|
|
||||||
|
|
||||||
hesk_dbConnect();
|
hesk_dbConnect();
|
||||||
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` DROP COLUMN `note_id`");
|
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."attachments` DROP COLUMN `note_id`");
|
||||||
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` DROP COLUMN `edit_date`");
|
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` DROP COLUMN `edit_date`");
|
||||||
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` DROP COLUMN `number_of_edits`");
|
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` DROP COLUMN `number_of_edits`");
|
||||||
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `default_notify_customer_email`");
|
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` DROP COLUMN `default_notify_customer_email`");
|
||||||
|
|
||||||
//TODO Migrate Mods for HESK Banned IPs / Emails to HESK 2.6.0's tables. Luckily the table names are different, so there won't be a problem when HESK tries to install.
|
$banRS = hesk_dbQuery("SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_emails`
|
||||||
|
UNION ALL SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_ips`");
|
||||||
hesk_dbQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_ips`");
|
if (hesk_dbNumRows($banRS) > 0)
|
||||||
hesk_dbQuery("DROP TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."denied_emails`");
|
{
|
||||||
|
$usersRS = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `active` = '1' ORDER BY `name`");
|
||||||
if ($updateSuccess) {
|
|
||||||
?>
|
?>
|
||||||
|
<h2>Migrating IP / E-mail Bans</h2>
|
||||||
<h1>Installation / Update complete!</h1>
|
<p>Mods for HESK has detected that you have added IP address and/or email bans using Mods for HESK. As part of the upgrade process,
|
||||||
<p>Please delete the <b>install</b> folder for security reasons, and then proceed back to the <a href="../">Help Desk</a></p>
|
Mods for HESK will migrate these bans for you to HESK 2.6.0's IP/email ban feature. Select the user below that will be the "creator" of the bans,
|
||||||
|
then click "Submit".</p>
|
||||||
|
<form action="migrateBans.php" method="post" role="form">
|
||||||
|
<select name="user" id="user">
|
||||||
|
<?php
|
||||||
|
while ($row = hesk_dbFetchAssoc($usersRS))
|
||||||
|
{ ?>
|
||||||
|
<option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option>
|
||||||
|
<?php }
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
<?php } ?>
|
<?php } ?>
|
Loading…
x
Reference in New Issue
Block a user