<?php require_once dirname(__FILE__) . '/settings/urls.php'; require_once dirname(__FILE__) . '/settings/config.php'; require_once dirname(__FILE__) . '/include/utils.php'; $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REDIRECT_URL']; session_start(); // find the matched url pattern and execute the function associated with it foreach ($url_patterns as $pattern => $func) { if (preg_match($pattern, $path)) { $func(); exit; } } // send a 404 not found error sr_response_error(404);
/** * Send chat invitation emails. */ function room_invite_email() { global $sr_regex_email; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $failed = array(); if (isset($_POST['emails'])) { $email_list = json_decode(stripslashes($_POST['emails'])); if (count($email_list) > 0) { $content = room_invite_email_content($_POST); foreach ($email_list as $email) { if (preg_match($sr_regex_email, $email)) { if (($r = sr_send_mail($email, $content)) !== null) { $failed[] = array('email' => $email, 'error' => $r); } } else { $failed[] = array('email' => $email, 'error' => 'Invalid email address format'); } } $failed_cnt = count($failed); if ($failed_cnt === 0) { $result['result'] = 0; } else { $result['result'] = 2; if ($failed_cnt == 1) { $result['msg'] = "Failed to send an invitation email to 1 person."; } else { $result['msg'] = "Failed to send invitation emails to {$failed_cnt} people."; } $result['failed'] = $failed; } } else { $result['result'] = 1; $result['msg'] = 'No email address was specified'; } } else { sr_response_error(400); } echo json_encode($result); } else { sr_response_error(404); } }
function main_signout() { $context = array(); if (sr_is_signed_in()) { $context['result'] = 0; $context['msg'] = 'Thank you, ' . $_SESSION['user_name'] . ' :)<br />Please wait...'; sr_signout(); sr_response('views/main/signout.php', $context); } else { sr_response_error(400); } }