コード例 #1
0
 public static function sweep()
 {
     $watch_path = LookoutController::watchPath();
     $inactive_users = array();
     $orig_dir = getcwd();
     chdir($watch_path);
     $worked = false;
     $watch_files = glob('*.sess');
     foreach ($watch_files as $file) {
         $file_access_time = fileatime($file);
         $current_time = time();
         $inactive = $current_time - $file_access_time > MAX_INACTIVE_TIME;
         if ($inactive) {
             $userid = explode('.', $file);
             array_push($inactive_users, $userid[0]);
         }
         $worked = true;
     }
     chdir($orig_dir);
     if (sizeof($inactive_users) > 0) {
         LookoutController::deleteInactiveWatch($inactive_users);
         AuthenticationController::autoLogout($inactive_users);
         $worked = true;
     }
     return $worked;
 }
コード例 #2
0
ファイル: phase_lookout.php プロジェクト: ademolaoduguwa/pms
require_once '../_core/global/_require.php';
Crave::requireAll(GLOBAL_VAR);
Crave::requireFiles(UTIL, array('SqlClient', 'JsonResponse', 'CxSessionHandler'));
Crave::requireFiles(MODEL, array('BaseModel', 'UserModel'));
Crave::requireFiles(CONTROLLER, array('LookoutController', 'AuthenticationController'));
if (isset($_REQUEST['intent'])) {
    $intent = $_REQUEST['intent'];
} else {
    echo JsonResponse::error("Intent not set!");
    exit;
}
if ($intent == 'markPresence') {
    $userid = CxSessionHandler::getItem(UserAuthTable::userid);
    if ($userid == NULL) {
        echo JsonResponse::error("User not logged in!");
        exit;
    }
    $inspector = new LookoutController();
    $marked = $inspector->markPresence($userid);
    if ($marked) {
        echo JsonResponse::message(STATUS_OK, "User marked present!");
        exit;
    } else {
        echo JsonResponse::error("Unable to mark user present!");
        exit;
    }
} elseif ($intent == 'sweep') {
    $sweepResult = LookoutController::sweep();
    var_dump($sweepResult);
}