intval -> (int), replace gettype() and ereg functions where possible

This commit is contained in:
Miles Lott 2003-12-14 17:18:41 +00:00
parent 4f612cbbde
commit 20b851da6f
4 changed files with 46 additions and 46 deletions

View File

@ -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));
}
}

View File

@ -161,7 +161,7 @@
for ($idx=0; $idx<count($security_equals); $idx++)
{
$groups = intval($security_equals[$idx]);
$groups = (int)$security_equals[$idx];
$this->memberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups));
}
@ -184,8 +184,8 @@
for ($idx=0; $idx<count($security_equals); $idx++)
{
$name = $this->id2name(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 '<br>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 '<br>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
{

View File

@ -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');

View File

@ -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__);