formating the file authentication.php to PSR2

This commit is contained in:
Fernando Ontiveros
2012-07-04 19:01:31 -04:00
parent 4ee129b3b6
commit 9f6cb2f812

View File

@@ -24,7 +24,6 @@
*/
try {
if (!$RBAC->singleSignOn) {
if (!isset($_POST['form']) ) {
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error');
@@ -53,7 +52,7 @@ try {
case -2:
$errLabel = 'ID_WRONG_PASS';
if(isset($_SESSION['__AUTH_ERROR__'])){
if (isset($_SESSION['__AUTH_ERROR__'])) {
G::SendMessageText($_SESSION['__AUTH_ERROR__'], "warning");
unset($_SESSION['__AUTH_ERROR__']);
}
@@ -64,7 +63,7 @@ try {
$user = new Users;
$aUser = $user->loadByUsernameInArray($usr);
switch($aUser['USR_STATUS']){
switch ($aUser['USR_STATUS']) {
case 'VACATION':
$errLabel = 'ID_USER_ONVACATION';
break;
@@ -88,9 +87,10 @@ try {
$errLabel = 'ID_USER_NOT_REGISTERED';
}
if ( !isset($uid) || $uid < 0 ) {
if(isset($_SESSION['FAILED_LOGINS']))
if (!isset($uid) || $uid < 0) {
if (isset($_SESSION['FAILED_LOGINS'])) {
$_SESSION['FAILED_LOGINS']++;
}
if (!defined('PPP_FAILED_LOGINS')) {
define('PPP_FAILED_LOGINS', 0);
}
@@ -116,14 +116,12 @@ try {
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$d = serialize(array('u'=>$usr, 'p'=>$pwd, 'm'=>G::LoadTranslation($errLabel)));
$loginUrl = '../home/login?d='.base64_encode($d);
}
else {
} else {
G::SendTemporalMessage($errLabel, "warning");
if (substr(SYS_SKIN, 0, 2) !== 'ux') {
$loginUrl = 'login';
}
else {
} else {
$loginUrl = '../main/login';
}
}
@@ -131,19 +129,21 @@ try {
G::header("location: $loginUrl");
die;
}
if(!isset( $_SESSION['WORKSPACE'] ) ) $_SESSION['WORKSPACE'] = SYS_SYS;
if (!isset( $_SESSION['WORKSPACE'] ) ) {
$_SESSION['WORKSPACE'] = SYS_SYS;
}
//Execute the SSO Script from plugin
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_LOGIN ) ) {
if ($oPluginRegistry->existsTrigger ( PM_LOGIN )) {
$lSession="";
$loginInfo = new loginInfo ($usr, $pwd, $lSession );
$oPluginRegistry->executeTriggers ( PM_LOGIN , $loginInfo );
}
$_SESSION['USER_LOGGED'] = $uid;
$_SESSION['USR_USERNAME'] = $usr;
}
else {
} else {
$uid = $RBAC->userObj->fields['USR_UID'];
$usr = $RBAC->userObj->fields['USR_USERNAME'];
$_SESSION['USER_LOGGED'] = $uid;
@@ -167,10 +167,11 @@ try {
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
$res = $RBAC->userCanAccess('PM_LOGIN');
if ($res != 1 ) {
if ($res == -2)
if ($res == -2) {
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
else
} else {
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_PAGE', "error");
}
G::header ("location: login.html");
die;
}
@@ -179,12 +180,10 @@ try {
if ($frm['USER_LANG'] != '') {
$lang = $frm['USER_LANG'];
}
}
else {
} else {
if (defined('SYS_LANG')) {
$lang = SYS_LANG;
}
else {
} else {
$lang = 'en';
}
}
@@ -203,22 +202,21 @@ try {
$weblog->create($aLog);
/**end log**/
//************** background processes, here we are putting some back office routines **********
//************** background processes, here we are putting some back office routines **********
$oServerConf->setWsInfo(SYS_SYS,$oServerConf->getWorkspaceInfo(SYS_SYS) );
//**** defining and saving server info, this file has the values of the global array $_SERVER ****
//this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line
//**** defining and saving server info, this file has the values of the global array $_SERVER ****
//this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line
$_CSERVER = $_SERVER;
unset($_CSERVER['REQUEST_TIME']);
unset($_CSERVER['REMOTE_PORT']);
$cput = serialize($_CSERVER);
if( !is_file(PATH_DATA_SITE . PATH_SEP . '.server_info') ){
if (!is_file(PATH_DATA_SITE . PATH_SEP . '.server_info')) {
file_put_contents(PATH_DATA_SITE . PATH_SEP . '.server_info', $cput);
}
else {
} else {
$c = file_get_contents(PATH_DATA_SITE . PATH_SEP . '.server_info');
if(md5($c) != md5($cput)){
if (md5($c) != md5($cput)) {
file_put_contents(PATH_DATA_SITE . PATH_SEP . '.server_info', $cput);
}
}
@@ -230,12 +228,10 @@ try {
// getting default user location
if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') {
$sLocation = $_REQUEST['form']['URL'];
}
else {
} else {
if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') {
$sLocation = $_REQUEST['u'];
}
else {
} else {
$sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang);
}
}
@@ -290,11 +286,11 @@ try {
G::RenderPage('publish', 'extJs');
//G::header('Location: ' . $sLocation);
die;
}
catch ( Exception $e ) {
} catch ( Exception $e ) {
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish' );
die;
}