Exemple #1
0
// Keep users logged in for a month... TODO: This doesn't work??
$SESSION_LIFETIME = 60 * 60 * 24 * 30;
session_set_cookie_params($SESSION_LIFETIME);
ini_set('session.gc_maxlifetime', $SESSION_LIFETIME);
// Start session... we'll need it
session_start();
require_once "common.php";
// Open a persistent connection to the database
$DB = new DB();
// If the user is logged in, update last activity.
// They could be a leader or a regular member.
$MEMBER = Member::Current();
$LEADER = null;
$WARD = null;
if ($MEMBER) {
    $MEMBER->UpdateLastActivity();
} else {
    $LEADER = StakeLeader::Current();
    if ($LEADER) {
        $LEADER->UpdateLastActivity();
    }
}
if ($MEMBER) {
    $WARD = Ward::Load($MEMBER->WardID);
} else {
    if ($LEADER) {
        $WARD = Ward::Load($_SESSION['wardID']);
    }
}
$USER = $MEMBER ? $MEMBER : $LEADER;
define('IS_MOBILE', isMobile());
Exemple #2
0
function errorHandler($level, $errorMsg, $file, $line)
{
    // Don't handle it if the error was suppressed (maybe with @) (or error reporting is off)
    if (!error_reporting()) {
        return true;
    }
    $errorType;
    if ($level == E_USER_ERROR) {
        $errorType = "Error";
    } else {
        if ($level == E_USER_WARNING) {
            $errorType = "Warning";
        } else {
            if ($level == E_USER_NOTICE) {
                $errorType = "Notice";
            } else {
                $errorType = "Unknown";
            }
        }
    }
    $alertSubject = $errorType . ": " . $errorMsg;
    $alertBody = "FILE: {$file}\r\nLINE: {$line}\r\nPROBLEM: {$errorType}: {$errorMsg}\r\n";
    // See if there's a logged-in user
    $user = Member::Current();
    if (!$user) {
        $user = StakeLeader::Current();
    }
    if ($user) {
        $alertBody .= "Currently logged-in user:\r\n" . print_r($user, true);
    }
    $alertBody .= "\r\n\r\n--\r\nAutomatically generated by the PHP error handling subsystem for debugging purposes.";
    $mail = new Mailer();
    $mail->FromAndReplyTo(ERR_HANDLE_FROM_NAME, EMAIL_BLACKHOLE);
    $mail->Subject($alertSubject);
    $mail->Body($alertBody);
    $mail->To(WEBMASTER_NAME, WEBMASTER_EMAIL);
    $mail->Send();
    // Write this to the server's internal log file...
    error_log("{$errorType}: {$errorMsg} in {$file} on line {$line}\n", LOG_TYPE, LOG_FILE);
    // Don't execute PHP's internal error handler
    return true;
}