Just some silly formating

This commit is contained in:
jengo 2001-02-12 19:21:45 +00:00
parent 4602e18fe1
commit 401d02fe7d

View File

@ -56,9 +56,12 @@
{
global $REMOTE_ADDR, $HTTP_X_FORWARDED_FOR;
if ($HTTP_X_FORWARDED_FOR) {
if ($HTTP_X_FORWARDED_FOR)
{
return $HTTP_X_FORWARDED_FOR;
} else {
}
else
{
return $REMOTE_ADDR;
}
}
@ -83,7 +86,8 @@
$db->next_record();
// This is going to be replace with the session_flag field
if ($db->f('session_info') == '' || $db->f('session_info') == 'NULL') {
if ($db->f('session_info') == '' || $db->f('session_info') == 'NULL')
{
/* $this->account_lid = $db->f('session_lid');
$phpgw_info['user']['sessionid'] = $this->sessionid;
$phpgw_info['user']['session_ip'] = $db->f('session_ip');
@ -99,9 +103,12 @@
$login_array = explode('@', $db->f('session_lid'));
$this->account_lid = $login_array[0];
if ($login_array[1]!='') {
if ($login_array[1] != '')
{
$this->account_domain = $login_array[1];
} else {
}
else
{
$this->account_domain = $phpgw_info['server']['default_domain'];
}
@ -114,12 +121,15 @@
$this->update_dla();
$this->account_id = $phpgw->accounts->name2id($this->account_lid);
if ($phpgw_info['server']['cache_phpgw_info']) {
if ($phpgw_info['server']['cache_phpgw_info'])
{
$t = $this->appsession('phpgw_info_cache','phpgwapi');
$phpgw_info['server'] = $t['server'];
$phpgw_info['user'] = $t['user'];
$phpgw_info['hooks'] = $t['hooks'];
} else {
}
else
{
$this->read_repositories();
$phpgw_info['user'] = $this->user;
$phpgw_info['hooks'] = $this->hooks;
@ -128,11 +138,13 @@
$phpgw_info['user']['session_ip'] = $db->f('session_ip');
$phpgw_info['user']['passwd'] = $this->appsession('password','phpgwapi');
if ($userid_array[1] != $phpgw_info['user']['domain']) {
if ($userid_array[1] != $phpgw_info['user']['domain'])
{
return False;
}
if (PHP_OS != 'Windows' && (! $phpgw_info['user']['session_ip'] || $phpgw_info['user']['session_ip'] != $this->getuser_ip())){
if (PHP_OS != 'Windows' && (! $phpgw_info['user']['session_ip'] || $phpgw_info['user']['session_ip'] != $this->getuser_ip()))
{
return False;
}
@ -141,9 +153,12 @@
$phpgw->preferences->preferences($this->account_id);
$phpgw->applications->applications($this->account_id);
if (! $this->account_lid ) {
if (! $this->account_lid)
{
return False;
} else {
}
else
{
return True;
}
}
@ -153,7 +168,8 @@
{
global $phpgw_info, $phpgw;
if (!isset($phpgw_info['server']['cron_apps']) || ! $phpgw_info['server']['cron_apps']) {
if (!isset($phpgw_info['server']['cron_apps']) || ! $phpgw_info['server']['cron_apps'])
{
$phpgw->db->query("delete from phpgw_sessions where session_dla <= '" . (time() - 7200)
. "'",__LINE__,__FILE__);
}
@ -162,30 +178,39 @@
function create($login,$passwd)
{
global $phpgw_info, $phpgw;
$this->login = $login;
$this->clean_sessions();
$login_array = explode('@', $login);
$this->account_lid = $login_array[0];
$now = time();
if ($login_array[1]!='') {
if ($login_array[1] != '')
{
$this->account_domain = $login_array[1];
} else {
}
else
{
$this->account_domain = $phpgw_info['server']['default_domain'];
}
if ($phpgw_info['server']['global_denied_users'][$this->account_lid]) {
if ($phpgw_info['server']['global_denied_users'][$this->account_lid])
{
return False;
}
if (! $phpgw->auth->authenticate($this->account_lid, $passwd)) {
if (! $phpgw->auth->authenticate($this->account_lid, $passwd))
{
return False;
exit;
}
if (!$phpgw->accounts->exists($this->account_lid) && $phpgw_info['server']['auto_create_acct'] == True) {
if (!$phpgw->accounts->exists($this->account_lid) && $phpgw_info['server']['auto_create_acct'] == True)
{
$this->account_id = $phpgw->accounts->auto_add($this->account_lid, $passwd);
} else {
}
else
{
$this->account_id = $phpgw->accounts->name2id($this->account_lid);
}
$phpgw->accounts->account_id = $this->account_id;
@ -199,14 +224,18 @@
$cryptovars[1] = $phpgw->common->iv;
$phpgw->crypto = CreateObject('phpgwapi.crypto', $cryptovars);
if ($phpgw_info['server']['usecookies']) {
if ($phpgw_info['server']['usecookies'])
{
Setcookie('sessionid',$this->sessionid);
Setcookie('kp3',$this->kp3);
Setcookie('domain',$this->account_domain);
Setcookie('last_domain',$this->account_domain,$now+1209600);
if ($this->account_domain == $phpgw_info['server']['default_domain']) {
if ($this->account_domain == $phpgw_info['server']['default_domain'])
{
Setcookie('last_loginid', $this->account_lid ,$now+1209600); // For 2 weeks
} else {
}
else
{
Setcookie('last_loginid', $login ,$now+1209600); // For 2 weeks
}
unset ($phpgw_info['server']['default_domain']); // we kill this for security reasons
@ -215,7 +244,8 @@
$this->read_repositories();
$phpgw_info['user'] = $this->user;
$phpgw_info['hooks'] = $this->hooks;
if ($phpgw_info['server']['cache_phpgw_info']) {
if ($phpgw_info['server']['cache_phpgw_info'])
{
$this->appsession('phpgw_info_cache','phpgwapi',$phpgw_info);
}
@ -227,8 +257,7 @@
. $now . "','" . $now . "','".$info_string."')",__LINE__,__FILE__);
$phpgw->db->query("insert into phpgw_access_log values ('" . $this->sessionid . "','"
. "$login','" . $this->getuser_ip() . "','" . $now
. "','') ",__LINE__,__FILE__);
. "$login','" . $this->getuser_ip() . "','$now','') ",__LINE__,__FILE__);
$phpgw->auth->update_lastlogin($this->account_id,$this->getuser_ip());
@ -256,10 +285,12 @@
. $phpgw_info['user']['sessionid'] . "'",__LINE__,__FILE__);
$phpgw->db->query("update phpgw_access_log set lo='" . time() . "' where sessionid='"
. $phpgw_info['user']['sessionid'] . "'",__LINE__,__FILE__);
if ($phpgw_info['server']['usecookies']) {
if ($phpgw_info['server']['usecookies'])
{
Setcookie('sessionid');
Setcookie('kp3');
if ($phpgw_info['multiable_domains']) {
if ($phpgw_info['multiable_domains'])
{
Setcookie('domain');
}
}
@ -304,21 +335,23 @@
$phpgw_info_temp['user']['kp3'] = '';
$phpgw_info_temp['flags'] = array();
if ($phpgw_info['server']['cache_phpgw_info']) {
if ($phpgw_info['server']['cache_phpgw_info'])
{
$this->appsession('phpgw_info_cache','phpgwapi',$phpgw_info_temp);
}
}
function appsession($location = "default", $appname = "", $data = "##NOTHING##")
function appsession($location = 'default', $appname = '', $data = '##NOTHING##')
{
global $phpgw_info, $phpgw;
if (! $appname) {
if (! $appname)
{
$appname = $phpgw_info['flags']['currentapp'];
}
/* This allows the user to put "" as the value. */
if ($data == "##NOTHING##") {
if ($data == '##NOTHING##') {
$query = 'select content from phpgw_app_sessions where'
.' sessionid = "'.$this->sessionid.'" and loginid = "'.$this->account_id.'"'
.' and app = "'.$appname.'" and location = "'.$location.'"';
@ -326,7 +359,7 @@
$phpgw->db->query($query,__LINE__,__FILE__);
$phpgw->db->next_record();
$data = $phpgw->db->f("content");
$data = $phpgw->db->f('content');
#$data = $phpgw->common->decrypt($data);
return $data;
} else {
@ -369,7 +402,7 @@
{
global $$key;
$$key = $value;
$this->variableNames[$key]="registered";
$this->variableNames[$key] = 'registered';
#print "restored: ".$key.", $value<br>";
}
}
@ -422,23 +455,28 @@
}
}
/*************************************************************************\
* Function to handle session support via url or cookies *
\*************************************************************************/
function link($url = '', $extravars = '')
{
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
/* Fix problems when PHP_SELF if used as the param */
if ($url == $PHP_SELF){ $url = ''; }
if ($url == $PHP_SELF)
{
$url = '';
}
if (! $kp3) { $kp3 = $phpgw_info['user']['kp3']; }
if (! $kp3)
{
$kp3 = $phpgw_info['user']['kp3'];
}
// Explicit hack to work around problems with php running as CGI on windows
// please let us know if this doesn't work for you!
if (! $url && (PHP_OS == 'Windows' || PHP_OS == 'OS/2' || PHP_OS == 'WIN32' || PHP_OS == 'WIN16')) {
if (! $url && (PHP_OS == 'Windows' || PHP_OS == 'OS/2' || PHP_OS == 'WIN32' || PHP_OS == 'WIN16'))
{
$exe = strpos($PHP_SELF,'php.exe');
if ($exe != false) {
$exe += 7; // strlen('php.exe')
@ -447,7 +485,8 @@
$url .= substr($PHP_SELF,$exe,strlen($PHP_SELF)-$exe);
}
}
if (! $url) {
if (! $url)
{
$url_root = split ('/', $phpgw_info['server']['webserver_url']);
/* Some hosting providers have their paths screwy.
If the value from $PHP_SELF is not what you expect, you can use this to patch it
@ -458,31 +497,48 @@
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2] . $patched_php_self;
}
if (isset($phpgw_info['server']['usecookies']) &&
$phpgw_info['server']['usecookies']) {
if ($extravars) { $url .= "?$extravars"; }
} else {
$url .= "?sessionid=" . $phpgw_info['user']['sessionid'];
$url .= "&kp3=" . $kp3;
$url .= "&domain=" . $phpgw_info['user']['domain'];
if (isset($phpgw_info['server']['usecookies']) && $phpgw_info['server']['usecookies'])
{
if ($extravars)
{
$url .= '?' . $extravars;
}
}
else
{
$url .= '?sessionid=' . $phpgw_info['user']['sessionid'];
$url .= '&kp3=' . $kp3;
$url .= '&domain=' . $phpgw_info['user']['domain'];
// This doesn't belong in the API.
// Its up to the app to pass this value. (jengo)
// Putting it into the app requires a massive number of updates in email app.
// Until that happens this needs to stay here (seek3r)
if ($phpgw_info['flags']['newsmode']) { $url .= "&newsmode=on"; }
if ($extravars) { $url .= "&$extravars"; }
if ($phpgw_info['flags']['newsmode'])
{
$url .= '&newsmode=on';
}
if ($extravars)
{
$url .= "&$extravars";
}
}
$url = str_replace('/?', '/index.php?', $url);
$webserver_url_count = strlen($phpgw_info['server']['webserver_url']);
$slash_check = strtolower(substr($url ,0,1));
if(substr($url ,0,$webserver_url_count) != $phpgw_info['server']['webserver_url']) {
if (substr($url ,0,$webserver_url_count) != $phpgw_info['server']['webserver_url'])
{
$app = $phpgw_info['flags']['currentapp'];
if($slash_check == '/') {
if ($slash_check == '/')
{
$url = $phpgw_info['server']['webserver_url'] . $url;
} elseif ($app == 'home' || $app == 'logout' || $app == 'login'){
}
elseif ($app == 'home' || $app == 'logout' || $app == 'login')
{
$url = $phpgw_info['server']['webserver_url'].'/'.$url;
}else{
}
else
{
$url = $phpgw_info['server']['webserver_url'].'/'.$app.'/'.$url;
}
}