Skip to content

Commit 7b26eae

Browse files
author
Marius Cramer
committed
Merge branch 'master' into 'master'
Master See merge request !222
2 parents eb1177f + 458ad7c commit 7b26eae

File tree

8 files changed

+72
-2
lines changed

8 files changed

+72
-2
lines changed

install/sql/incremental/upd_dev_collection.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,5 @@ CREATE TABLE `server_ip_map` (
166166
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
167167

168168
ALTER TABLE `web_domain` ADD COLUMN `rewrite_to_https` ENUM('y','n') NOT NULL DEFAULT 'n' AFTER `seo_redirect`;
169+
170+
ALTER TABLE openvz_ip ADD COLUMN `additional` VARCHAR(255) NOT NULL DEFAULT 'n';

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ CREATE TABLE IF NOT EXISTS `openvz_ip` (
10041004
`ip_address` varchar(39) DEFAULT NULL,
10051005
`vm_id` int(11) NOT NULL DEFAULT '0',
10061006
`reserved` varchar(255) NOT NULL DEFAULT 'n',
1007+
`additional` varchar(255) NOT NULL DEFAULT 'n',
10071008
PRIMARY KEY (`ip_address_id`)
10081009
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
10091010

install/tpl/master_cf_amavis10025.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
-o strict_rfc821_envelopes=yes
1313
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
1414
-o smtp_send_xforward_command=yes
15+
-o disable_dns_lookups=yes
1516

install/tpl/master_cf_amavis10027.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
-o smtp_send_xforward_command=yes
1515
-o milter_default_action=accept
1616
-o milter_macro_daemon_name=ORIGINATING
17+
-o disable_dns_lookups=yes
1718

interface/lib/plugins/vm_openvz_plugin.inc.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ function openvz_vm_insert($event_name, $page_form) {
6060
// Set the IP address
6161
$app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
6262

63+
// Set additional IPs
64+
if (isset($this->dataRecord['additional_ip'])) {
65+
$app->db->query("UPDATE openvz_ip SET vm_id = 0, additional = 'n' WHERE vm_id = ? AND additional='y'", $this->id);
66+
foreach ($this->dataRecord['additional_ip'] as $idx => $rec) {
67+
$app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'y' WHERE ip_address = ?", $this->id, $rec);
68+
}
69+
}
70+
6371
// Create the OpenVZ config file and store it in config field
6472
$this->makeOpenVZConfig();
6573

@@ -95,8 +103,16 @@ function openvz_vm_update($event_name, $page_form) {
95103

96104
// Set the IP address
97105
if(isset($this->dataRecord['ip_address'])) {
98-
$app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = ?", $this->id);
99-
$app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
106+
$app->db->query("UPDATE openvz_ip SET vm_id = 0 WHERE vm_id = ? AND additional='n'", $this->id);
107+
$app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'n' WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']);
108+
}
109+
110+
// Set additional IPs
111+
if (isset($this->dataRecord['additional_ip'])) {
112+
$app->db->query("UPDATE openvz_ip SET vm_id = 0, additional = 'n' WHERE (vm_id = ? AND additional='y')", $this->id);
113+
foreach ($this->dataRecord['additional_ip'] as $idx => $rec) {
114+
$app->db->query("UPDATE openvz_ip SET vm_id = ?, additional = 'y' WHERE ip_address = ?", $this->id, $rec);
115+
}
100116
}
101117

102118
// Create the OpenVZ config file and store it in config field
@@ -195,6 +211,17 @@ private function makeOpenVZConfig() {
195211
$hostname = str_replace('{VEID}', $vm['veid'], $vm['hostname']);
196212

197213
$tpl->setVar('hostname', $hostname);
214+
215+
$additional_ips = $app->db->queryAllRecords("SELECT * FROM openvz_ip WHERE vm_id = ?",$this->id);
216+
if (isset($additional_ips)) {
217+
$vm['ip_address']='';
218+
foreach ($additional_ips as $ip) {
219+
$vm['ip_address'] .= " ".$ip['ip_address'];
220+
}
221+
$vm['ip_address'] = substr($vm['ip_address'],1);
222+
}
223+
$tpl->setVar('ip_address', $vm['ip_address']);
224+
198225
$tpl->setVar('ip_address', $vm['ip_address']);
199226
$tpl->setVar('nameserver', $vm['nameserver']);
200227
$tpl->setVar('capability', $vm['capability']);

interface/web/vm/form/openvz_vm.tform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@
327327
//#################################
328328
)
329329
);
330+
331+
$form["tabs"]['additional_ip'] = array (
332+
'title' => "Additional IP",
333+
'width' => 100,
334+
'template' => "templates/openvz_vm_additional_ip_edit.htm",
335+
);
330336
}
331337

332338

interface/web/vm/openvz_vm_edit.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ function onShowEnd() {
178178
$app->tpl->setVar("ip_address", $ip_select);
179179
unset($tmp);
180180
unset($ips);
181+
182+
//* Additional IPs
183+
$sql="SELECT * FROM openvz_ip WHERE reserved = 'n' AND ((vm_id = ? AND additional='y') OR vm_id = 0) AND server_id = ?";
184+
$additional_ips = $app->db->queryAllRecords($sql, $this->id, $vm_server_id);
185+
foreach ($additional_ips as $idx => $rec) {
186+
$temp .= "<input type='hidden' id='id".$idx."' name='additional_ip[".$idx."]' name='additional_ip[".$idx."]' value='0'>";
187+
$used = @($rec['additional']=='y')?'CHECKED':'';
188+
$temp .= "<input type='checkbox' value='".$rec['ip_address']."' id='id".$idx."' name='additional_ip[".$idx."]' ".$used."> ".$rec['ip_address']."<br>";
189+
}
190+
$app->tpl->setVar("additional_ip", $temp);
191+
unset($used);
192+
unset($temp);
193+
unset($additional_ips);
181194

182195
if($this->id > 0) {
183196
//* we are editing a existing record
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class='page-header'></div>
2+
<p><tmpl_var name="list_desc_txt"></p>
3+
4+
<legend>Additional IPs</legend>
5+
6+
<div class="form-group">
7+
<div class="col-sm-3">
8+
{tmpl_var name='additional_ip'}
9+
</div>
10+
</div>
11+
12+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
13+
14+
<div class="clear"><div class="right">
15+
<button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="vm/openvz_vm_edit.php">{tmpl_var name='btn_save_txt'}</button>
16+
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="vm/openvz_vm_list.php">{tmpl_var name='btn_cancel_txt'}</button>
17+
</div></div>
18+
19+

0 commit comments

Comments
 (0)