redirect('protected.php'); } /*-------------------------------------------------- Handle submitting the login form via AJAX ---------------------------------------------------*/ try { if (!empty($_POST) && isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { // Output a JSON header header('Content-type: application/json'); // Is the email address valid? if (!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { throw new Exception('Please enter a valid email.'); } // This will throw an exception if the person is above // the allowed login attempt limits (see functions.php for more): rate_limit($_SERVER['REMOTE_ADDR']); // Record this login attempt rate_limit_tick($_SERVER['REMOTE_ADDR'], $_POST['email']); // Send the message to the user $message = ''; $email = $_POST['email']; $subject = 'Your Login Link'; if (!User::exists($email)) { $subject = "Thank You For Registering!"; $message = "Thank you for registering at our site!\n\n"; } // Attempt to login or register the person $user = User::loginOrRegister($_POST['email']); $message .= "You can login from this URL:\n"; $message .= get_page_url() . "?tkn=" . $user->generateToken() . "\n\n"; $message .= "The link is going expire automatically after 10 minutes.";
$fyr_values = get_all_variables(); set_up_variables($fyr_values); // Various display and used fields, global variables $stash = array(); $stash['time'] = msg_get_time(); msg_check_error($stash['time']); $stash['date'] = strftime('%A %e %B %Y', $stash['time']); if (!isset($fyr_values['who']) || $fyr_values['who'] == "all" && !isset($fyr_values['type'])) { back_to_who(); } # Determine if this is a message to be sent to a group of representatives $stash['group_msg'] = false; if ($fyr_values['who'] == 'all') { $stash['group_msg'] = true; } rate_limit($fyr_values); // For a group mail, get a group_id for transaction with the fax queue now // and generate message ids later if ($stash['group_msg']) { if (array_key_exists('fyr_grpid', $fyr_values)) { $grpid = $fyr_values['fyr_grpid']; } else { $grpid = msg_create_group(); msg_check_error($grpid); $fyr_values['fyr_grpid'] = $grpid; } } else { $grpid = null; // Message id for transaction with fax queue if (array_key_exists('fyr_msgid', $fyr_values)) { $msgid = $fyr_values['fyr_msgid'];