Skip to content

Commit 65ea2ec

Browse files
author
mcramer
committed
Fixed/Implemented: replaced intval() by $app->functions->intval() in all interface functions due to big number problem in intval()
1 parent 3064f83 commit 65ea2ec

File tree

110 files changed

+596
-512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+596
-512
lines changed

interface/lib/app.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public function __construct() {
8181
if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language'];
8282
}
8383

84-
$this->uses('auth,plugin,functions');
84+
$this->uses('functions'); // we need this before all others!
85+
$this->uses('auth,plugin');
8586
}
8687

8788
public function __destruct() {
@@ -119,7 +120,7 @@ public function log($msg, $priority = 0) {
119120
if($priority >= $this->_conf['log_priority']) {
120121
// $server_id = $conf["server_id"];
121122
$server_id = 0;
122-
$priority = intval($priority);
123+
$priority = $this->functions->intval($priority);
123124
$tstamp = time();
124125
$msg = $this->db->quote('[INTERFACE]: '.$msg);
125126
$this->db->query("INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ($server_id,0,$priority,$tstamp,'$msg')");

interface/lib/classes/aps_guicontroller.inc.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function createPackageInstance($settings, $packageid)
210210

211211
//* Get server config of the web server
212212
$this->app->uses("getconf");
213-
$web_config = $this->app->getconf->get_server_config(intval($websrv["server_id"]),'web');
213+
$web_config = $this->app->getconf->get_server_config($app->functions->intval($websrv["server_id"]),'web');
214214

215215
//* Set mysql mode to php-fcgi and enable suexec in website on apache servers
216216
if($web_config['server_type'] == 'apache') {
@@ -239,7 +239,7 @@ public function createPackageInstance($settings, $packageid)
239239
$client = $app->db->queryOneRecord("SELECT default_dbserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$websrv['sys_groupid']);
240240
if(is_array($client) && $client['default_dbserver'] > 0 && $client['default_dbserver'] != $websrv['server_id']) {
241241
$mysql_db_server_id = $client['default_dbserver'];
242-
$dbserver_config = $web_config = $app->getconf->get_server_config(intval($mysql_db_server_id),'server');
242+
$dbserver_config = $web_config = $app->getconf->get_server_config($app->functions->intval($mysql_db_server_id),'server');
243243
$mysql_db_host = $dbserver_config['ip_address'];
244244
$mysql_db_remote_access = 'y';
245245
$mysql_db_remote_ips = $dbserver_config['ip_address'];
@@ -322,7 +322,7 @@ public function deleteInstance($instanceid)
322322
if($tmp['database_id'] > 0) $this->db->datalogDelete('web_database', 'database_id', $tmp['database_id']);
323323

324324
$database_user = $tmp['database_user_id'];
325-
$tmp = $this->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . intval($database_user) . "' OR `database_ro_user_id` = '" . intval($database_user) . "'");
325+
$tmp = $this->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . $app->functions->intval($database_user) . "' OR `database_ro_user_id` = '" . $app->functions->intval($database_user) . "'");
326326
if($tmp['cnt'] < 1) $this->db->datalogDelete('web_database_user', 'database_user_id', $database_user);
327327

328328
$this->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_REMOVE, 'id', $instanceid);
@@ -449,6 +449,8 @@ public function getPackageSettings($id)
449449
*/
450450
public function validateInstallerInput($postinput, $pkg_details, $domains, $settings = array())
451451
{
452+
global $app;
453+
452454
$ret = array();
453455
$input = array();
454456
$error = array();
@@ -566,12 +568,12 @@ public function validateInstallerInput($postinput, $pkg_details, $domains, $sett
566568
{
567569
if($setting['SettingType'] == 'string' || $setting['SettingType'] == 'password')
568570
{
569-
if(intval($setting['SettingMinLength']) != 0
570-
&& strlen($postinput[$setting_id]) < intval($setting['SettingMinLength']))
571+
if($app->functions->intval($setting['SettingMinLength'], true) != 0
572+
&& strlen($postinput[$setting_id]) < $app->functions->intval($setting['SettingMinLength'], true))
571573
$temp_errstr = sprintf($this->app->lng('error_short_value_for'), $setting['setting_name']);
572574

573-
if(intval($setting['SettingMaxLength']) != 0
574-
&& strlen($postinput[$setting_id]) > intval($setting['SettingMaxLength']))
575+
if($app->functions->intval($setting['SettingMaxLength'], true) != 0
576+
&& strlen($postinput[$setting_id]) > $app->functions->intval($setting['SettingMaxLength'], true))
575577
$temp_errstr = sprintf($this->app->lng('error_long_value_for'), $setting['setting_name']);
576578

577579
if(isset($setting['SettingRegex'])

interface/lib/classes/auth.inc.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function is_admin() {
4747
public function has_clients($userid) {
4848
global $app, $conf;
4949

50-
$userid = intval($userid);
50+
$userid = $app->functions->intval($userid);
5151
$client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
5252
if($client['limit_client'] > 0) {
5353
return true;
@@ -60,8 +60,8 @@ public function has_clients($userid) {
6060
public function add_group_to_user($userid,$groupid) {
6161
global $app;
6262

63-
$userid = intval($userid);
64-
$groupid = intval($groupid);
63+
$userid = $app->functions->intval($userid);
64+
$groupid = $app->functions->intval($groupid);
6565

6666
if($userid > 0 && $groupid > 0) {
6767
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
@@ -98,8 +98,8 @@ public function get_client_limit($userid, $limitname)
9898
public function remove_group_from_user($userid,$groupid) {
9999
global $app;
100100

101-
$userid = intval($userid);
102-
$groupid = intval($groupid);
101+
$userid = $app->functions->intval($userid);
102+
$groupid = $app->functions->intval($groupid);
103103

104104
if($userid > 0 && $groupid > 0) {
105105
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");

interface/lib/classes/client_templates.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function apply_client_templates($clientId) {
1515
/*
1616
* Get the master-template for the client
1717
*/
18-
$sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . intval($clientId);
18+
$sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId);
1919
$record = $app->db->queryOneRecord($sql);
2020
$masterTemplateId = $record['template_master'];
2121
$additionalTemplateStr = $record['template_additional'];
@@ -24,7 +24,7 @@ function apply_client_templates($clientId) {
2424
* if the master-Template is custom there is NO changing
2525
*/
2626
if ($masterTemplateId > 0){
27-
$sql = "SELECT * FROM client_template WHERE template_id = " . intval($masterTemplateId);
27+
$sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($masterTemplateId);
2828
$limits = $app->db->queryOneRecord($sql);
2929
} else {
3030
// if there is no master template it makes NO SENSE adding sub templates.
@@ -40,7 +40,7 @@ function apply_client_templates($clientId) {
4040
$addTpl = explode('/', $additionalTemplateStr);
4141
foreach ($addTpl as $item){
4242
if (trim($item) != ''){
43-
$sql = "SELECT * FROM client_template WHERE template_id = " . intval($item);
43+
$sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($item);
4444
$addLimits = $app->db->queryOneRecord($sql);
4545
/* maybe the template is deleted in the meantime */
4646
if (is_array($addLimits)){
@@ -115,7 +115,7 @@ function apply_client_templates($clientId) {
115115
}
116116
}
117117
if($update != '') {
118-
$sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . intval($clientId);
118+
$sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . $app->functions->intval($clientId);
119119
$app->db->query($sql);
120120
}
121121
}

interface/lib/classes/form.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function loadFormDef($file) {
140140
* @return record
141141
*/
142142
function decode($record) {
143+
global $app;
143144
if(is_array($record)) {
144145
foreach($record as $key => $val) {
145146
switch ($this->tableDef[$key]['datatype']) {
@@ -154,7 +155,7 @@ function decode($record) {
154155
break;
155156

156157
case 'INTEGER':
157-
$new_record[$key] = intval($val);
158+
$new_record[$key] = $app->functions->intval($val);
158159
break;
159160

160161
case 'DOUBLE':
@@ -306,7 +307,7 @@ function encode($record) {
306307
}
307308
break;
308309
case 'INTEGER':
309-
$new_record[$key] = intval($val);
310+
$new_record[$key] = $app->functions->intval($val);
310311
break;
311312
case 'DOUBLE':
312313
$new_record[$key] = $app->db->quote($val);

interface/lib/classes/functions.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,15 @@ public function suggest_ips($type = 'IPv4'){
299299
return $result_array;
300300
}
301301

302-
302+
public function intval($string, $force_numeric = false) {
303+
if(intval($string) == 2147483647) {
304+
if($force_numeric == true) return floatval($string);
305+
elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2];
306+
else return 0;
307+
} else {
308+
return intval($string);
309+
}
310+
}
303311

304312
}
305313

interface/lib/classes/getconf.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function get_server_config($server_id, $section = '') {
3737

3838
if(!isset($this->config[$server_id])) {
3939
$app->uses('ini_parser');
40-
$server_id = intval($server_id);
40+
$server_id = $app->functions->intval($server_id);
4141
$server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
4242
$this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
4343
}

interface/lib/classes/listform.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ public function getPagingSQL($sql_where = '1')
194194
global $app, $conf;
195195

196196
//* Add Global Limit from selectbox
197-
if(!empty($_POST['search_limit']) AND intval($_POST['search_limit'])){
198-
$_SESSION['search']['limit'] = intval($_POST['search_limit']);
197+
if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit'])){
198+
$_SESSION['search']['limit'] = $app->functions->intval($_POST['search_limit']);
199199
}
200200

201201
//* Get Config variables
202202
$list_name = $this->listDef['name'];
203203
$search_prefix = $this->listDef['search_prefix'];
204-
$records_per_page = (empty($_SESSION['search']['limit']) ? intval($this->listDef['records_per_page']) : intval($_SESSION['search']['limit'])) ;
204+
$records_per_page = (empty($_SESSION['search']['limit']) ? $app->functions->intval($this->listDef['records_per_page']) : $app->functions->intval($_SESSION['search']['limit'])) ;
205205
$table = $this->listDef['table'];
206206

207207
//* set PAGE to zero, if in session not set
@@ -210,14 +210,14 @@ public function getPagingSQL($sql_where = '1')
210210
}
211211

212212
//* set PAGE to worth request variable "PAGE" - ? setze page auf wert der request variablen "page"
213-
if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = intval($_REQUEST["page"]);
213+
if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $app->functions->intval($_REQUEST["page"]);
214214

215215
//* PAGE to 0 set, if look for themselves ? page auf 0 setzen, wenn suche sich ge�ndert hat.
216216
if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0;
217217

218-
$sql_von = intval($_SESSION['search'][$list_name]['page'] * $records_per_page);
218+
$sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page);
219219
$record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where");
220-
$pages = intval(($record_count['anzahl'] - 1) / $records_per_page);
220+
$pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page);
221221

222222

223223
$vars['list_file'] = $_SESSION['s']['module']['name'].'/'.$this->listDef['file'];
@@ -331,7 +331,7 @@ public function decode($record)
331331
break;
332332

333333
case 'INTEGER':
334-
$record[$key] = intval($record[$key]);
334+
$record[$key] = $app->functions->intval($record[$key]);
335335
break;
336336

337337
case 'DOUBLE':
@@ -387,7 +387,7 @@ public function encode($record)
387387
break;
388388

389389
case 'INTEGER':
390-
$record[$key] = intval($record[$key]);
390+
$record[$key] = $app->functions->intval($record[$key]);
391391
break;
392392

393393
case 'DOUBLE':

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function onShow() {
5353
$error = '';
5454

5555
if(isset($_GET['backup_action'])) {
56-
$backup_id = intval($_GET['backup_id']);
56+
$backup_id = $app->functions->intval($_GET['backup_id']);
5757

5858
if($_GET['backup_action'] == 'download' && $backup_id > 0) {
5959
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";

0 commit comments

Comments
 (0)