Esempio n. 1
0
    $whiteLists = (include __DIR__ . '/whiteList.php');
    $whiteLists = $request->getMethod() == 'GET' ? $whiteLists['get'] : $whiteLists['post'];
    $inWhiteList = 0;
    foreach ($whiteLists as $whiteList) {
        $path = $request->getPathInfo();
        if (preg_match($whiteList, $request->getPathInfo())) {
            $inWhiteList = 1;
            break;
        }
    }
    $token = $request->headers->get('Auth-Token', '');
    if (!$inWhiteList && empty($token)) {
        throw createNotFoundException("AuthToken is not exist.");
    }
    $userService = ServiceKernel::instance()->createService('User.UserService');
    $token = $userService->getToken('mobile_login', $token);
    if (!$inWhiteList && empty($token['userId'])) {
        throw createAccessDeniedException("AuthToken is invalid.");
    }
    $user = $userService->getUser($token['userId']);
    // $user = $userService->getUser(1);
    if (!$inWhiteList && empty($user)) {
        throw createNotFoundException("Auth user is not found.");
    }
    setCurrentUser($user);
});
$app->error(function (\Exception $e, $code) {
    return array('code' => $code, 'message' => $e->getMessage());
});
include __DIR__ . '/config/routing.php';
$app->run();
Esempio n. 2
0
            			 echo "nok";
            			 //Login failed, so check remote site.
            			 $rpc = new RPC;
            			 $Frontend = new FrontEnd;
            			 $loginOK = $rpc->CheckLogin($login,$Frontend->encryptPassword($password));
            			 if($loginOK)
            			 {
            				//Oops we must be out of date, update the users table!
            				$rpc->GetUsers();
            				$loginOK = checkLogin($login,$password);
            				startSession($loginOK->id,$loginOK->username);
            				//header( 'Location: intranet.php' ) ;
            				}
            				else
            				{
            				echo "nok";
            				}**/
        }
        if ($displayError) {
            global $master;
            $master->AddWarning("Incorrect username or password.");
        }
    }
}
//Logout
if (isset($_GET["user-session-logout"])) {
    $lanid = getCurrentLID();
    session_unset();
    setCurrentLID($lanid);
    setCurrentUser(0);
}
Esempio n. 3
0
<?php

include_once 'core.php';
include 'skins/' . Config::$theme . '/setup.php';
include_once 'integration/integration.php';
//Pull through user ID
$frontend = new FrontEnd();
setCurrentUser($frontend->getUserId());
startSession(getCurrentUID(), $frontend->getName(getCurrentUID()));
//Check user is in db and run checks.
$frontend->pullUserInfo(getCurrentUID());
$frontend->checkGroups(getCurrentUID(), getCurrentLID());
$frontend->disconnect();
$page = new Lan_pages();
$page->name = GETSafe('page');
$page->find();
if ($page->fetch()) {
    $file = 'modules/' . $page->module . '/' . $page->file . '.php';
    if (file_exists($file)) {
        include $file;
        $master->RenderPage($page->module . '.' . $page->file . '.htm');
    } else {
        $master->AddError("The file for this page does not exist!");
    }
} else {
    $master->AddError("Unknown page!");
}
if ($master->HasFatalError()) {
    $master->RenderPage('error.htm');
}
$master->RenderSite('master.integration.htm');
Esempio n. 4
0
function startSession($id, $username)
{
    setCurrentUser($id);
    $_SESSION['username'] = $username;
    // Store User IP
    $user = new Lan_users();
    if (0 != $user->get($id)) {
        $user->ip = $_SERVER['REMOTE_ADDR'];
        $_SESSION['steamprofile'] = $user->steamprofile;
        $_SESSION['profilepic'] = $user->smallavatar;
        $user->update();
    }
    SetupGroups();
}