Exemplo n.º 1
0
function room_invite_email_content($request)
{
    global $sr_default_chat_name;
    $content = array();
    $room_link = $_SERVER['HTTP_REFERER'];
    if (($user_name = sr_user_first_name()) === null) {
        if (($user_name = sr_user_name()) === null) {
            $user_name = $_SESSION['chat_name'];
        }
    }
    if ($user_name != $sr_default_chat_name) {
        $content['subject'] = $user_name . ' is inviting you to join the Sunrise video conference room';
        $content['body'] = 'Hi,<br/><br/>' . $user_name . ' is waiting for you in the Sunrise video conference room.<br/>Click the link below to join.<br/><br/><a href="' . $room_link . '">' . $room_link . '</a>';
        if (!$request['is_open']) {
            $content['body'] .= '<br/>Password: '******'password'];
        }
        $content['body'] .= '<br/><br/>Best,<br/><br/>Sunrise VC';
    } else {
        $content['subject'] = 'You were invited to join the Sunrise video conference room';
        $content['body'] = 'Hi,<br/><br/>You were invited to join the Sunrise video conference room.<br/>Click the link below to join.<br/><br/><a href="' . $room_link . '">' . $room_link . '</a>';
        if (!$request['is_open']) {
            $content['body'] .= '<br/>Password: '******'password'];
        }
        $content['body'] .= '<br/><br/>Best,<br/><br/>Sunrise VC';
    }
    return $content;
}
Exemplo n.º 2
0
function main_profile()
{
    if (!sr_is_signed_in()) {
        sr_response_error(400);
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if ($_POST['which'] == 'basic') {
            global $sr_regex_name;
            global $sr_regex_email;
            $user = new User();
            $context = array();
            if (!preg_match($sr_regex_email, $_POST['profile_email'])) {
                $context['result'] = 2;
                $context['msg'] = 'Please enter a valid email address';
            } else {
                if (!preg_match($sr_regex_name, $_POST['first_name'])) {
                    $context['result'] = 3;
                    $context['msg'] = 'Name should consist of only alphabets (uppercase or lowercase).';
                } else {
                    if (!preg_match($sr_regex_name, $_POST['last_name'])) {
                        $context['result'] = 4;
                        $context['msg'] = 'Name should consist of only alphabets (uppercase or lowercase).';
                    } else {
                        try {
                            $db = sr_pdo();
                            $user = $user->get($db, sr_user_id());
                            $user->first_name = ucfirst($_POST['first_name']);
                            $user->last_name = ucfirst($_POST['last_name']);
                            $user->email = strtolower($_POST['profile_email']);
                            $user->save($db);
                            $context['result'] = 1;
                            $context['msg'] = 'Successfully updated';
                            sr_set_user_first_name($user->first_name);
                            sr_set_user_last_name($user->last_name);
                            sr_set_user_name($user->first_name . ' ' . $user->last_name);
                            sr_set_user_email($user->email);
                        } catch (PDOException $e) {
                            $context['result'] = 99;
                            $context['msg'] = 'Failed to save. Please try it again.';
                        }
                    }
                }
            }
            $context['which'] = 'basic';
            $context['first_name'] = sr_user_first_name();
            $context['last_name'] = sr_user_last_name();
            $context['email'] = sr_user_email();
            $context['is_authorized'] = sr_is_authorized();
            $context['is_admin'] = sr_is_admin();
            sr_response('views/main/profile.php', $context);
        } else {
            if ($_POST['which'] == 'password') {
                global $sr_regex_password;
                $user = new User();
                $context = array();
                if (!preg_match($sr_regex_password, $_POST['old_password'])) {
                    $context['result'] = 5;
                    $context['msg'] = 'Please enter a valid password.<br />Password should be alphanumeric.';
                } else {
                    if (!preg_match($sr_regex_password, $_POST['new_password'])) {
                        $context['result'] = 6;
                        $context['msg'] = 'Please enter a valid password.<br />Password should be alphanumeric.';
                    } else {
                        if ($_POST['new_password'] != $_POST['repeat_password']) {
                            $context['result'] = 7;
                            $context['msg'] = 'Please repeat your password.';
                        } else {
                            try {
                                $db = sr_pdo();
                                $user = $user->get($db, sr_user_id());
                                if ($user->password != md5($_POST['old_password'])) {
                                    $context['result'] = 8;
                                    $context['msg'] = 'Please check your old password.';
                                } else {
                                    $user->password = md5($_POST['new_password']);
                                    $user->save($db);
                                    $context['result'] = 1;
                                    $context['msg'] = 'Successfully updated';
                                }
                            } catch (PDOException $e) {
                                $context['result'] = 99;
                                $context['msg'] = 'Failed to save. Please try it again.';
                            }
                        }
                    }
                }
                $context['which'] = 'password';
                $context['first_name'] = sr_user_first_name();
                $context['last_name'] = sr_user_last_name();
                $context['email'] = sr_user_email();
                $context['is_authorized'] = sr_is_authorized();
                $context['is_admin'] = sr_is_admin();
                sr_response('views/main/profile.php', $context);
            } else {
                $user = new User();
                $result = array();
                try {
                    $db = sr_pdo();
                    $user = $user->get($db, sr_user_id());
                    $user->delete($db);
                    sr_signout();
                    echo json_encode($result);
                } catch (PDOException $e) {
                }
            }
        }
    } else {
        // Show profile view
        $context = array('which' => 'basic', 'first_name' => sr_user_first_name(), 'last_name' => sr_user_last_name(), 'email' => sr_user_email(), 'is_authorized' => sr_is_authorized(), 'is_admin' => sr_is_admin());
        sr_response('views/main/profile.php', $context);
    }
}