Skip to content

Commit dce3bb5

Browse files
author
Till Brehm
committed
Improved sql queries in VM module.
1 parent 35509d5 commit dce3bb5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

interface/web/vm/openvz_action.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
if($vm_id == 0) die('Invalid VM ID');
1919

2020
$vm = $app->db->queryOneRecord("SELECT server_id, veid FROM openvz_vm WHERE vm_id = $vm_id");
21-
$veid = $vm['veid'];
22-
$server_id = $vm['server_id'];
21+
$veid = $app->functions->intval($vm['veid']);
22+
$server_id = $app->functions->intval($vm['server_id']);
2323

2424
//* Loading classes
2525
$app->uses('tpl');

interface/web/vm/openvz_template_edit.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ class page_action extends tform_actions {
5454
function onAfterInsert() {
5555
global $app, $conf;
5656

57-
$guar_ram = $this->dataRecord['ram']*256;
58-
$burst_ram = $this->dataRecord['ram_burst']*256;
57+
$guar_ram = $app->functions->intval($this->dataRecord['ram']*256);
58+
$burst_ram = $app->functions->intval($this->dataRecord['ram_burst']*256);
5959
$sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id";
6060
$app->db->query($sql);
6161
}
6262

6363
function onAfterUpdate() {
6464
global $app, $conf;
6565

66-
$guar_ram = $this->dataRecord['ram']*256;
67-
$burst_ram = $this->dataRecord['ram_burst']*256;
66+
$guar_ram = $app->functions->intval($this->dataRecord['ram']*256);
67+
$burst_ram = $app->functions->intval($this->dataRecord['ram_burst']*256);
6868
$sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id";
6969
$app->db->query($sql);
7070
}

interface/web/vm/openvz_vm_edit.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ function onShowEnd() {
7373
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
7474

7575
//* Get the limits of the client
76-
$client_group_id = $_SESSION["s"]["user"]["default_group"];
76+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
7777
$client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
7878

7979
//* Fill the template_id field
8080
if($client['limit_openvz_vm_template_id'] == 0) {
8181
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
8282
} else {
83-
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$client['limit_openvz_vm_template_id'].' ORDER BY template_name';
83+
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$app->functions->intval($client['limit_openvz_vm_template_id']).' ORDER BY template_name';
8484
}
8585
$records = $app->db->queryAllRecords($sql);
8686
if(is_array($records)) {
@@ -100,9 +100,9 @@ function onShowEnd() {
100100

101101

102102
//* Fill the client select field
103-
$sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name";
103+
$sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$app->functions->intval($client['client_id'])." ORDER BY sys_group.name";
104104
$records = $app->db->queryAllRecords($sql);
105-
$tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']);
105+
$tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id']));
106106
$client_select = '<option value="'.$tmp['groupid'].'">'.$client['contactname'].'</option>';
107107
//$tmp_data_record = $app->tform->getDataRecord($this->id);
108108
if(is_array($records)) {
@@ -117,7 +117,7 @@ function onShowEnd() {
117117
if($client['limit_openvz_vm_template_id'] == 0) {
118118
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
119119
} else {
120-
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$client['limit_openvz_vm_template_id'].' ORDER BY template_name';
120+
$sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$app->functions->intval($client['limit_openvz_vm_template_id']).' ORDER BY template_name';
121121
}
122122
$records = $app->db->queryAllRecords($sql);
123123
if(is_array($records)) {
@@ -164,7 +164,7 @@ function onShowEnd() {
164164
$vm_server_id = $app->functions->intval($this->dataRecord["server_id"]);
165165
} else {
166166
$tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name LIMIT 0,1');
167-
$vm_server_id = $tmp['server_id'];
167+
$vm_server_id = $app->functions->intval($tmp['server_id']);
168168
}
169169
$sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '".$this->id."') AND server_id = ".$app->functions->intval($vm_server_id)." ORDER BY ip_address";
170170
$ips = $app->db->queryAllRecords($sql);

0 commit comments

Comments
 (0)