From 20b851da6fb72eaa7c835c7ceb36627979fcdf31 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sun, 14 Dec 2003 17:18:41 +0000 Subject: [PATCH] intval -> (int), replace gettype() and ereg functions where possible --- phpgwapi/inc/class.accounts_ldap.inc.php | 14 +++---- phpgwapi/inc/class.accounts_shared.inc.php | 14 +++---- phpgwapi/inc/class.accounts_sql.inc.php | 44 +++++++++++----------- phpgwapi/inc/class.interserver.inc.php | 20 +++++----- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 74c011d1d5..f0e971ee24 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -363,7 +363,7 @@ function isin_array($needle,$haystack='') { - if(gettype($haystack) != 'array') + if(!@is_array($haystack)) { return False; } @@ -587,7 +587,7 @@ if (@$allValues[0]['gidnumber'][0]) { - $name_list[$account_lid] = intval($allValues[0]['gidnumber'][0]); + $name_list[$account_lid] = (int)$allValues[0]['gidnumber'][0]; } $sri = ldap_search($this->ds, $this->user_context, "(&(uid=$account_lid)(phpgwaccounttype=u))"); @@ -596,7 +596,7 @@ if (@$allValues[0]['uidnumber'][0]) { - $name_list[$account_lid] = intval($allValues[0]['uidnumber'][0]); + $name_list[$account_lid] = (int)$allValues[0]['uidnumber'][0]; } return $name_list[$account_lid]; @@ -673,7 +673,7 @@ /* * returns nonzero if $account exists in LDAP: 0: nowhere 1: user accounts, 2: group accounts, 3: both - * $account can be an account_id (LDAP: uidnumber) or an account_lid (LDAP: uid) (is determinded by gettype($account) == 'integer') + * $account can be an account_id (LDAP: uidnumber) or an account_lid (LDAP: uid) (is determinded by ettype($account) == 'integer') */ function exists($account) { @@ -936,7 +936,7 @@ { if ($expiredate) { - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } else { @@ -949,14 +949,14 @@ else { $expiredate = time() + $GLOBALS['phpgw_info']['server']['auto_create_expire']; - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } } else { /* expire in 30 days by default */ $expiredate = time() + ( ( 60 * 60 ) * (30 * 24) ); - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } } diff --git a/phpgwapi/inc/class.accounts_shared.inc.php b/phpgwapi/inc/class.accounts_shared.inc.php index 559807690f..6d0afd8bf8 100644 --- a/phpgwapi/inc/class.accounts_shared.inc.php +++ b/phpgwapi/inc/class.accounts_shared.inc.php @@ -161,7 +161,7 @@ for ($idx=0; $idxmemberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups)); } @@ -184,8 +184,8 @@ for ($idx=0; $idxid2name(intval($security_equals[$idx])); - $this->members[] = Array('account_id' => intval($security_equals[$idx]), 'account_name' => $name); + $name = $this->id2name((int)$security_equals[$idx]); + $this->members[] = Array('account_id' => (int)$security_equals[$idx], 'account_name' => $name); } return $this->members; @@ -209,7 +209,7 @@ { $type = 'accounts'; } - $nextid = intval($GLOBALS['phpgw']->common->last_id($type,$min,$max)); + $nextid = (int)$GLOBALS['phpgw']->common->last_id($type,$min,$max); /* Loop until we find a free id */ $free = 0; @@ -219,7 +219,7 @@ //echo '
calling search for id: '.$nextid; if ($this->exists($nextid)) { - $nextid = intval($GLOBALS['phpgw']->common->next_id($type,$min,$max)); + $nextid = (int)$GLOBALS['phpgw']->common->next_id($type,$min,$max); } else { @@ -227,7 +227,7 @@ /* echo '
calling search for lid: '.$account_lid . '(from account_id=' . $nextid . ')'; */ if ($this->exists($account_lid)) { - $nextid = intval($GLOBALS['phpgw']->common->next_id($type,$min,$max)); + $nextid = (int)$GLOBALS['phpgw']->common->next_id($type,$min,$max); } else { @@ -260,7 +260,7 @@ if(isset($_POST['start'])) { - $start = intval($_POST['start']); + $start = (int)$_POST['start']; } else { diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index aeb1e75af4..7a8caa7585 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -65,7 +65,7 @@ ); return $xml_functions; break; - case 'soap': + case 'soap': return $this->soap_functions; break; default: @@ -80,7 +80,7 @@ */ function read_repository() { - $this->db->query('SELECT * FROM phpgw_accounts WHERE account_id=' . intval($this->account_id),__LINE__,__FILE__); + $this->db->query('SELECT * FROM phpgw_accounts WHERE account_id=' . (int)$this->account_id,__LINE__,__FILE__); $this->db->next_record(); $this->data['userid'] = $this->db->f('account_lid'); @@ -106,15 +106,15 @@ */ function save_repository() { - $this->db->query('UPDATE phpgw_accounts SET'. - " account_firstname='" . $this->db->db_addslashes($this->data['firstname']). - "', account_lastname='" . $this->db->db_addslashes($this->data['lastname']). - "', account_status='". $this->db->db_addslashes($this->data['status']). - "', account_expires=" . intval($this->data['expires']). - ($this->data['account_lid']?", account_lid='".$this->db->db_addslashes($this->data['account_lid'])."'":''). - ', person_id='.intval($this->data['person_id']). - ', account_primary_group='.intval($this->data['account_primary_group']). - ' WHERE account_id=' . intval($this->account_id),__LINE__,__FILE__); + $this->db->query('UPDATE phpgw_accounts SET' + . " account_firstname='" . $this->db->db_addslashes($this->data['firstname']) + . "', account_lastname='" . $this->db->db_addslashes($this->data['lastname']) + . "', account_status='". $this->db->db_addslashes($this->data['status']) + . "', account_expires=" . (int)$this->data['expires'] + . ($this->data['account_lid']?", account_lid='".$this->db->db_addslashes($this->data['account_lid'])."'":'') + . ', person_id='.(int)$this->data['person_id'] + . ', account_primary_group='.(int)$this->data['account_primary_group'] + . ' WHERE account_id=' . (int)$this->account_id,__LINE__,__FILE__); } function delete($accountid = '') @@ -124,7 +124,7 @@ /* Do this last since we are depending upon this record to get the account_lid above */ $tables_array = Array('phpgw_accounts'); $this->db->lock($tables_array); - $this->db->query('DELETE FROM phpgw_accounts WHERE account_id=' . intval($account_id),__LINE__,__FILE__); + $this->db->query('DELETE FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__); $this->db->unlock(); } @@ -235,7 +235,7 @@ if($this->db->num_rows()) { $this->db->next_record(); - $name_list[$account_lid] = intval($this->db->f('account_id')); + $name_list[$account_lid] = (int)$this->db->f('account_id'); } else { @@ -258,7 +258,7 @@ return $id_list[$account_id]; } - $this->db->query('SELECT account_lid FROM phpgw_accounts WHERE account_id=' . intval($account_id),__LINE__,__FILE__); + $this->db->query('SELECT account_lid FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__); if($this->db->num_rows()) { $this->db->next_record(); @@ -352,9 +352,9 @@ . "', '" . $this->db->db_addslashes($account_info['account_firstname']) . "','" . $this->db->db_addslashes($account_info['account_lastname']) . "','" . $this->db->db_addslashes($account_info['account_status']) - . "'," . intval($account_info['account_expires']) - . ',' . intval($account_info['person_id']) - . ',' . intval($account_info['account_primary_group']) . ')',__LINE__,__FILE__); + . "'," . (int)$account_info['account_expires'] + . ',' . (int)$account_info['person_id'] + . ',' . (int)$account_info['account_primary_group'] . ')',__LINE__,__FILE__); $accountid = $this->db->get_last_insert_id('phpgw_accounts','account_id'); @@ -371,7 +371,7 @@ { if ($expiredate) { - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } else { @@ -384,14 +384,14 @@ else { $expiredate = time() + $GLOBALS['phpgw_info']['server']['auto_create_expire']; - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } } else { /* expire in 30 days by default */ $expiredate = time() + ( ( 60 * 60 ) * (30 * 24) ); - $expires = mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate)); + $expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate)); } } @@ -447,7 +447,7 @@ function get_account_name($accountid,&$lid,&$fname,&$lname) { static $account_name; - + $account_id = get_account_id($accountid); if(isset($account_name[$account_id])) { @@ -457,7 +457,7 @@ return; } $db = $GLOBALS['phpgw']->db; - $db->query('SELECT account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_id=' . intval($account_id),__LINE__,__FILE__); + $db->query('SELECT account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__); $db->next_record(); $account_name[$account_id]['lid'] = $db->f('account_lid'); $account_name[$account_id]['fname'] = $db->f('account_firstname'); diff --git a/phpgwapi/inc/class.interserver.inc.php b/phpgwapi/inc/class.interserver.inc.php index 40fa8ebe08..d5f3796c4c 100644 --- a/phpgwapi/inc/class.interserver.inc.php +++ b/phpgwapi/inc/class.interserver.inc.php @@ -90,7 +90,7 @@ $this->db = $GLOBALS['phpgw']->db; if($serverid) { - $this->serverid = intval($serverid); + $this->serverid = (int)$serverid; $this->setup(); } } @@ -136,18 +136,18 @@ { preg_match('/^(.*?\/\/.*?)(\/.*)/',$url,$matches); $hostpart = $matches[1]; - $hostpart = ereg_replace('https://','',$hostpart); - $hostpart = ereg_replace('http://','',$hostpart); + $hostpart = str_replace('https://','',$hostpart); + $hostpart = str_replace('http://','',$hostpart); switch($this->mode) { case 'soap': - if(!ereg('soap.php',$matches[2])) + if(!strstr($matches[2],'soap.php')) { $matches[2] .= $this->urlparts['soap']; } break; case 'xmlrpc': - if(!ereg('xmlrpc.php',$matches[2])) + if(!strstr($matches[2],'xmlrpc.php')) { $matches[2] .= $this->urlparts['xmlrpc']; } @@ -397,7 +397,7 @@ { $serverid = $this->serverid; } - $sql = "SELECT * FROM $this->table WHERE server_id=" . intval($serverid); + $sql = "SELECT * FROM $this->table WHERE server_id=" . (int)$serverid; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { @@ -428,13 +428,13 @@ . "server_url='" . $this->server['server_url'] . "'," . "server_mode='" . $this->server['server_mode'] . "'," . "server_security='" . $this->server['server_security'] . "'," - . "trust_level=" . intval($this->server['trust_level']) . "," - . "trust_rel=" . intval($this->server['trust_rel']) . "," + . "trust_level=" . (int)$this->server['trust_level'] . "," + . "trust_rel=" . (int)$this->server['trust_rel'] . "," . "username='" . $this->server['username'] . "'," . "password='" . $this->server['password'] . "'," . "admin_name='" . $this->server['admin_name'] . "'," . "admin_email='" . $this->server['admin_email'] . "' " - . "WHERE server_id=" . intval($serverid); + . "WHERE server_id=" . (int)$serverid; $this->db->query($sql,__LINE__,__FILE__); return True; } @@ -451,7 +451,7 @@ . "trust_level,trust_rel,username,password,admin_name,admin_email) " . "VALUES('" . $server_info['server_name'] . "','" . $server_info['server_url'] . "','" . $server_info['server_mode'] . "','" . $server_info['server_security'] . "'," - . intval($server_info['trust_level']) . "," . intval($server_info['trust_rel']) . ",'" + . (int)$server_info['trust_level'] . "," . (int)$server_info['trust_rel'] . ",'" . $server_info['username'] . "','" . $server_info['password'] . "','" . $server_info['admin_name'] . "','" . $server_info['admin_email'] . "')"; $this->db->query($sql,__LINE__,__FILE__);