'.$_SESSION['framework']['basic']['main']['error'][$_GET['eid']]['error']['eid'].'';} $eDataInfo=$_SESSION['framework']['basic']['main']['error'][$_GET['eid']]['data']; } elseif (isset($_SESSION['framework']['pda']['main']['error'][$_GET['eid']]['error']['message'])) { $eData=$_SESSION['framework']['pda']['main']['error'][$_GET['eid']]['error']['eid']; if (empty($eData)){$eData=''.$_SESSION['framework']['pda']['main']['error'][$_GET['eid']]['error']['eid'].'';} $eDataInfo=$_SESSION['framework']['pda']['main']['error'][$_GET['eid']]['data']; } else{unset($eData);} if (isset($eDataInfo)) { if (is_array($eDataInfo)) { foreach($eDataInfo['form'] as $key=>$val) { if (is_array($val)) { $eDataInfo['form'][$key]=Tools::htmlspecialchars_array($val); } else { $eDataInfo['form'][$key]=htmlspecialchars($val); } } } } if(!$_SESSION['user']){session_destroy();} ini_set('session.name',$localCookie); } /******* MESSAGE HANDLER ******/ if(isset($_GET['mid'])) { $if=strtoupper($_COOKIE['sess_suffix']); $localCookie=ini_get('session.name'); define('SESSION_COOKIE_NAME','PHPSESSID'.($if?'_'.$if:'_LOGIN')); ini_set('session.name',SESSION_COOKIE_NAME); session_start(); $mData=$_GET['mid']; if(!$_SESSION['user']){session_destroy();} } else{unset($mData);} if(!defined(SESSION_COOKIE_NAME)){ define('SESSION_COOKIE_NAME','PHPSESSID_LOGIN'); ini_set('session.name',SESSION_COOKIE_NAME); } if (isset($_REQUEST['reason'])) { $reason=htmlspecialchars($_REQUEST['reason']); $isError=true; } if (isset($_REQUEST['msg'])) { $msg=htmlspecialchars($_REQUEST['msg']); $isError=true; } /***********/ /** tool allowing sent data for login in GET **/ if (isset($_GET['postlike'])) { foreach($_GET as $key=>$val) { $_POST[$key]=$val; } } /** **/ /********************** AUTOLOGIN *********************/ $interface=''; if (isset($_COOKIE['lastLogin'])) { $lastLogin=$_COOKIE['lastLogin']; $lastLogin=explode('|',$lastLogin); $language=$lastLogin[0]; $interface=$lastLogin[1]; if (isset($_GET['language'])) { setcookie('lastLogin',$_GET['language'].'|'.$interface,mktime(0,0,0,1,1,2030),'/'); } } else { if (isset($_GET['language'])) { setcookie('lastLogin',$_GET['language'].'|-',mktime(0,0,0,1,1,2030),'/'); } } if ($isError) { setcookie('permanentLogin','',mktime(0,0,0,1,1,2000),'/'); unset($_COOKIE['permanentLogin']); } if (isset($_COOKIE['permanentLogin'])) { $permanentLogin=$_COOKIE['permanentLogin']; if ($interface!='pro' && !isset($_GET['sid']) && !isset($_COOKIE['login_sid'])) { $_POST['to']=$interface; $_POST['direct']=1; $_POST['_n']['p']['main']='win.main.tree'; $_POST['password']=$permanentLogin.'&t='.time(); $_POST['username']=''; $_POST['language']=$language; $_POST['auto_login']=1; $_POST['_c']='auth'; $_POST['_n']['w']='main'; $_POST['_n']['js']=1; $_POST['_a']['login']=1; $_POST['referer']=$self; $encodeCredentials=false; } else { if(!isset($_GET['sid']) && !isset($_COOKIE['login_sid'])) { if(ini_get('session.use_cookies')) { $qs=getClearGet(); $normalLogin=true; session_id(str_replace('i=','',$permanentLogin)); session_start(); //print_r($_SESSION);die(); if (isset($_SESSION['EMAIL'])) { $account = createobject("account"); if(!$account->Open($_SESSION['EMAIL'])){ @session_destroy(); $normalLogin=false; } } else { $normalLogin=false; } if($normalLogin) { setcookie('login_sid',str_replace('i=','',$permanentLogin),mktime(0,0,0,1,1,2030),'/'); header("HTTP/1.0 302 Moved Temporarely"); header("Location: ./".$qs); } else { setcookie('login_sid','',mktime(0,0,0,1,1,2000),'/'); setcookie('permanentLogin','',mktime(0,0,0,1,1,2000),'/'); header("HTTP/1.0 302 Moved Temporarely"); header("Location: ./"); } } else { $qs=getClearGet(array("sid=".str_replace('i=','',$permanentLogin))); header("HTTP/1.0 302 Moved Temporarely"); header("Location: ".$qs); } die(); } else{$forceLogin=true;} } } /**/ /********* NO JS Login part *********/ if (isset($_POST['to'])) { //die($_POST['password'].'|'.$_POST['iw_username']); if ($encodeCredentials) { $_POST['password']=urlencode($_POST['password']); } if ($_POST['to']=='pro') {$goto='basic';} else { if (isset($_POST['amitabletgotobasic']) && (substr_count($_SERVER['HTTP_USER_AGENT'],"Mobile")==0 && substr_count($_SERVER['HTTP_USER_AGENT'],"Android")>0)){$_POST['to']='basic';} /*decide, which interface go to, if no action was selected (no JS available)*/ if ($_POST['to']=='basic' || $_POST['to']=='pda') {$goto=$_POST['to'];} else {$goto='pda'; } /*if PDA, set _n p main to PDA value, to log in correctly*/ if ($goto=='pda'){$_POST['_n']['p']['main']='grid.mail';} /*if BASIC, set _n p main to BASIC value, to log in correctly*/ if ($goto=='basic'){$_POST['_n']['p']['main']='win.main.tree';} if (isset($_POST['auto_login']) && $_POST['auto_login']=='1'){$_POST['auto_login']='1';} } /*save POST data into session to log in after redirect*/ session_start(); if(!$_COOKIE['use_cookies']){$suffix='&PHPSESSID_LOGIN='.session_id();} else{$suffix = '';} $_SESSION['_unilogin']=$_POST; /*redirect onto target location*/ header("HTTP/1.0 302 Moved Temporarely"); header("Location: ./".$goto."/index.html?l".$suffix.'&'.$_SERVER['QUERY_STRING']); die(); } /******************/ /** ////////////////////////////////////////////////////////////////////////////////*/ /** ////////////////////////////////////////////////////////////////////////////////*/ /** ////////////////////////////////////////////////////////////////////////////////*/ // permanent login fix for FRM testing if (isset($_REQUEST['frm'])) { setcookie('permanentLogin','',mktime(0,0,0,1,1,2030),'/'); unset($_COOKIE['permanentLogin']); } /** ******/ slSystem::import( 'application' ); slSystem::import( 'io/router' ); slSystem::import( 'system/session' ); slSystem::import( 'storage/settings' ); slSystem::import( 'tools/debug' ); $request = slRequest::instance(); $session = slSession::instance($request,false); /********* error handler ********/ if (isset($eData)){$_SESSION['error']=$eData;} else{unset($_SESSION['error']);} /******************/ require_once( APP_PATH.'model/settings.php'); $api=new IceWarpAPI(); $url['install']=$api->GetProperty('C_Install_URL'); $version=$api->GetProperty('C_Version'); @$serverData=simplexml_load_file($api->GetProperty('C_ConfigPath')."_webmail/server.xml"); $sets = WebmailSettings::instance($session); $layoutData = $sets->getPublic('layout_settings'); $restrictionsData = $sets->getPublic('restrictions'); $resourcesData = $sets->getPublic('forgot_settings'); $languagesData = $sets->getPublic('languages'); $gSettings = $sets->getPrivate('global_settings'); $domainsData=Storage::getSignupDomains(); $settings['logging_type']=$serverData->item->logging_type; $languagesData=sortLanguages($languagesData); foreach($languagesData as $key=>$val) { //echo print_r($val); $languagesData[$key]['name']=translateLanguage($val['lang'],$val['name']); } if (is_array($languagesData)){$languages=$languagesData;} if (is_array($domainsData)){$domains=$domainsData;} $forgot=false; if (isset($resourcesData['@childnodes']['item'][0]['@childnodes']['forgot'][0]['@value'])){$forgot=$resourcesData['@childnodes']['item'][0]['@childnodes']['forgot'][0]['@value'];} $defaultLanguage=$layoutData['@childnodes']['item'][0]['@childnodes']['language'][0]['@value']; if (empty($defaultLanguage)) {$defaultLanguage='en';} $defaultSkin=$layoutData['@childnodes']['item'][0]['@childnodes']['skin'][0]['@value']; $settings['restrictions']=array(); if (!empty($restrictionsData)) { foreach($restrictionsData['@childnodes']['item'][0]['@childnodes'] as $key=>$val) { $settings['restrictions'][$key]=$val[0]['@value']; } } $settings['restrictions']['forgot']=$forgot; $settings['layout']=array(); if (!empty($layoutData)) { foreach($layoutData['@childnodes']['item'][0]['@childnodes'] as $key=>$val) { $settings['layout'][$key]=$val[0]['@value']; } } $allowed_interfaces['basic']=false; $allowed_interfaces['advanced']=false; $allowed_interfaces['pda']=false; if (isset($layoutData['@childnodes']['item'][0]['@childnodes']['interfaces'][0]['@value']) && !empty($layoutData['@childnodes']['item'][0]['@childnodes']['interfaces'][0]['@value'])) { $aAlowedInterfaces=$layoutData['@childnodes']['item'][0]['@childnodes']['interfaces'][0]['@value']; if (substr_count($aAlowedInterfaces,'a')>0) {$allowed_interfaces['advanced']=true;} if (substr_count($aAlowedInterfaces,'b')>0) {$allowed_interfaces['basic']=true;} if (substr_count($aAlowedInterfaces,'p')>0) {$allowed_interfaces['pda']=true;} } else { $allowed_interfaces['basic']=true; $allowed_interfaces['advanced']=true; $allowed_interfaces['pda']=true; } if (isset($settings['layout']['login_client']) && $settings['layout']['login_client']=='basic') { $interface=$settings['layout']['login_client']; $allowed_interfaces[$settings['layout']['login_client']]=true; } /*** logo ***/ if (trim($settings['layout']['logo'])=='') {$settings['layout']['logo']='logo.png';} if (substr_count($settings['layout']['logo'],'/')==0) { if (file_exists('../client/skins/'.$settings['layout']['skin'].'/images/'.$settings['layout']['logo'])) { $settings['layout']['logo']='client/skins/'.$settings['layout']['skin'].'/images/'.$settings['layout']['logo']; } elseif (file_exists('../client/skins/'.$settings['layout']['skin'].'/images/'.str_replace('.png','.gif',$settings['layout']['logo']))) { $settings['layout']['logo']='client/skins/'.$settings['layout']['skin'].'/images/'.str_replace('.png','.gif',$settings['layout']['logo']); } elseif(file_exists('../client/skins/default/images/'.$settings['layout']['logo'])) { $settings['layout']['logo']='client/skins/default/images/'.$settings['layout']['logo']; } else { $settings['layout']['logo']='client/skins/default/images/'.str_replace('.png','.gif',$settings['layout']['logo']); } } /************/ $settings['main']=(array)$sets; /** ////////////////////////////////////////////////////////////////////////////////*/ /** ////////////////////////////////////////////////////////////////////////////////*/ /** ////////////////////////////////////////////////////////////////////////////////*/ /** Get OS name **/ $OS=l::getOS(); $OSName=$OS['name']; $OSCode=$OS['code']; /** **/ $mdr=l::mobileDeviceRecognition(); $pda=$mdr['pda']; // override to allow show pda login screen if (isset($_GET['pda'])){$pda=true;} $normalLoginException=$mdr['normal_login_exception']; /********/ WebmailIqAuth::checkServerKeys(); $hash = @file_get_contents(WM_CONFIGPATH.'public.key'); /********/ /** languages **/ if (!isset($_COOKIE['lastLogin'])){$language=$defaultLanguage;} if (isset($_GET['language'])) {$language=$_GET['language'];} if (trim($language)==''){$language=$defaultLanguage;} foreach ($languages as $key=>$val) { if ($language==$val['lang']) {$languages[$key]['selected']=true;} } /** */ /***** load language *****/ $file=dirname(__FILE__).'/client/languages/'.$language.'/data.xml'; if (!file_exists($file) || substr_count($file,'//')>0) {$language=$defaultLanguage;} $language_data =(array) simplexml_load_file(dirname(__FILE__).'/client/languages/'.$language.'/data.xml'); foreach($language_data as $key=>$val) { $language_data[$key]=(array)$val; if (is_array($language_data[$key])) { foreach($language_data[$key] as $key2=>$val2) { $language_data[$key][$key2]=(string)$val2; } } } /**********/ /********/ unset($error); if (isset($reason)) { $reason=strtolower($reason); if (isset($language_data['error'][$reason])){$error=$language_data['error'][$reason];} else{$error=$reason;} } elseif ($eData) { $error=$eData; } if (isset($_GET['pwpolicy'])) { $policy['enable'] = $api->GetProperty('C_Accounts_Policies_Pass_Enable'); $policy['minlength'] = $api->GetProperty('C_Accounts_Policies_Pass_MinLength'); $policy['digits'] = $api->GetProperty('C_Accounts_Policies_Pass_Digits'); $policy['alpha'] = $api->GetProperty('C_Accounts_Policies_Pass_Alpha'); $policy['nonalphanum'] = $api->GetProperty('C_Accounts_Policies_Pass_NonAlphaNum'); $policy['useralias'] = $api->GetProperty('C_Accounts_Policies_Pass_UserAlias'); $policy['expiration'] = $api->GetProperty('C_Accounts_Policies_Pass_Expiration'); $policy['expireafter'] = $api->GetProperty('C_Accounts_Policies_Pass_ExpireAfter'); $policy['notification'] = $api->GetProperty('C_Accounts_Policies_Pass_Notification'); $policy['notifybefore'] = $api->GetProperty('C_Accounts_Policies_Pass_NotifyBefore'); $policy['denyexport'] = $api->GetProperty('C_Accounts_Policies_Pass_DenyExport'); $policy['allowadminpass'] = $api->GetProperty('C_Accounts_Policies_Pass_AllowAdminPass'); $policy['encrypt'] = $api->GetProperty('C_Accounts_Policies_Pass_Encrypt'); $policy['uppercase'] = $api->GetProperty('C_Accounts_Policies_Pass_UpperAlpha'); } /* translate message */ if (isset($msg)){$mData=$msg;} if ($mData) { $mData=strtolower($mData); if (isset($language_data['message'][$mData])){$message=$language_data['message'][$mData];} else{$message=$mData;} } /********/ $username=''; if (isset($_COOKIE['lastUsername'])) {$username=$_COOKIE['lastUsername'];} if (isset($_GET['password'])) {$password=$_GET['password'];} if (isset($_GET['username'])) {$username=$_GET['username'];} if (isset($_GET['interface'])) {$interface=$_GET['interface'];} /*****************************************************/ /* fixes */ $settings['logging_type']=(int)$settings['logging_type']; // force logging_type to INT value $language_data['login_screen']['copy']="".$language_data['login_screen']['copy'].' © 1999-'.date('Y').""; // add version info into copyright if ($username=='***') {$username='';} /**/ $get=json_encode($_GET); $qs=getClearGet(); if(is_array($eDataInfo) && is_array($domains) && !empty($domains)) { foreach($domains as $key=>$val) { if ($eDataInfo['form']['signup_domain']==$val['domain']) { $domains[$key]['selected']=true; } } } if (isset($eDataInfo['form']['to'])) {$interface=$eDataInfo['form']['to'];} if (isset($_REQUEST['interface'])){$preselected=$_REQUEST['interface'];}elseif(isset($lastLogin[1])){$preselected=$lastLogin[1];}else{$preselected=false;} // IE <=7 OVERRIDE TO GO TO BASIC EVERYTIME $browserInfo=browser_info(); if (!isset($_REQUEST['interface'])){if (($browserInfo['browser']=='msie' && ($browserInfo['version'])<=7)){$preselected='basic';}} // $recommendedInterface=l::getRecommendedInterface($allowed_interfaces,$settings,$preselected); //$recommendedInterface['second']['js']=false; //$recommendedInterface['second']['nojs']=false; /* echo 'os: '.$OSName.'/'.$OSCode."
"; echo 'doporuceny: '.print_r($recommendedInterface,true)."
"; echo 'cookie: '.$lastLogin[1]."
"; echo 'mdr: '.print_r($mdr,true)."
"; echo 'povoleno: '.print_r($allowed_interfaces,true)."
"; */ //echo "
".print_r($settings,true)."
"; // one line or two line solution? $solution=1; if (!$settings['restrictions']['disable_signup'] || (!$settings['restrictions']['disable_remember'] && $settings['restrictions']['forgot'])) { $solution=2; } // /** ee */ $picker=false; if ($_GET['color']=='picker'){$picker=true;unset($_GET['color']);} /** */ /** Utilities */ $utilities['webdav']=$api->GetProperty('C_WebDAV_URL'); $utilities['ical']=$api->GetProperty('C_InternetCalendar_URL'); $utilities['webcal']=str_replace(array('http://','https://'),array('webcal://','webcals://'),$utilities['ical']); $utilities['freebusy']=$api->GetProperty('C_FreeBusy_URL'); $utilities['webadmin']=$api->GetProperty('C_WebAdmin_URL'); $utilities['bcal']=trim($api->GetProperty('C_Webmail_URL'),'/').'/calendar/'; $utilities['install']=$api->GetProperty('C_Install_URL'); /** */ //print_r($utilities); /* template data set */ $templateData=array( 'utilities'=>$utilities, 'picker'=>$picker, 'solution'=>$solution, 'recomended_interface'=>$recommendedInterface, 'normal_login_exception'=>$normalLoginException, 'filtered_query_string'=>$qs, 'json_get'=>$get, 'get'=>$_GET, 'base'=>$base, 'restrictions'=>$restrictions, 'languages'=>$languages, 'domains'=>$domains, 'OSName'=>$OSName, 'OSCode'=>$OSCode, 'hash'=>$hash, 'settings'=>$settings, 'error'=>$error, 'message'=>$message, 'url'=>$url, 'defaultLanguage'=>$defaultLanguage, 'language'=>$language, 'interface'=>htmlspecialchars($interface), 'lastLogin'=>array( 'language'=>$lastLogin[0], 'interface'=>$lastLogin[1] ), 'permanentLogin'=>$permanentLogin, 'username'=>htmlspecialchars($username), 'password'=>htmlspecialchars($password), 'self'=>$self, 'forceLogin'=>$forceLogin, 'version'=>$version, 'lang'=>$language_data, 'eDataInfo'=>$eDataInfo, 'pwdPolicy'=>$policy, 'time'=>time(), 'allowed_interfaces'=>$allowed_interfaces, 'ctz'=>date('Z'), ); /**/ /** SSO only */ if (!( isset($_REQUEST['sid']) || isset($_COOKIE['login_sid']) || isset($_REQUEST['frm']) || isset($_GET['!']) )) { if(isset($gSettings['@childnodes']['global_settings'][0]['@childnodes']['item'][0]['@childnodes'])) { $gSettings=$gSettings['@childnodes']['global_settings'][0]['@childnodes']['item'][0]['@childnodes']; if (isset($gSettings['sso_only'][0]['@value']) && $gSettings['sso_only'][0]['@value']==1) { header("HTTP/1.0 302 Moved Temporarely"); header("Location: ./sso/"); die(); } } } /** */ /** Licence type */ $templateData['licenseType']=Storage::getLicenseType(); /** */ if(isset($_GET['pro'])){$desktop=true;}else{$desktop=false;} /** ADVANCED LAYOUT - direct login */ if( ( isset($_REQUEST['sid']) || isset($_COOKIE['login_sid']) || isset($_REQUEST['frm']) || isset($_GET['!']) ) && $templateData['licenseType']!='simple' ) { if (isset($_COOKIE['login_sid'])){$templateData['activeSID']=$_COOKIE['login_sid'];} if (isset($_REQUEST['sid'])){$templateData['activeSID']=$_REQUEST['sid'];} $browserInfo=browser_info(); $templateData['strict']=true; if (($browserInfo['browser']=='msie' && $browserInfo['version']<8) || ($browserInfo['browser']=='opera' && $browserInfo['version']<9.8)) { $templateData['strict']=false; } // set PRO as last used interface $lastLanguage='en'; if(isset($_COOKIE['lastLogin'])){$parse=explode('|',$_COOKIE['lastLogin']);$lastLanguage=$parse[0];} setcookie('lastLogin',$lastLanguage.'|pro',mktime(0,0,0,1,1,2030),'/'); echo getTemplate($defaultSkin,'advanced.tpl',$templateData); } /** PDA LOGIN */ elseif ($pda && !$desktop) { echo getTemplate($defaultSkin,'device.tpl',$templateData); } /** **************/ /** Other Login - login page ***************/ else { echo getTemplate($defaultSkin,'desktop.tpl',$templateData); } if(session_id() && !$_SESSION['user']){session_destroy();} /** *******************/ ?>