Beispiel #1
0
<?php

require_once 'jabberauth.php';
$config = array('dbuser' => 'dbusr', 'dbpass' => 'dbpwd', 'dbhost' => 'localhost', 'dbname' => 'jabber');
$jauth = new JabberAuth($config);
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'register':
            if ($jauth->register()) {
                $msg = SUCCESS_REGISTER;
                $jauth->clear_session();
            } else {
                $jauth->clear_session();
                $_SESSION['formdata']['username'] = $_POST['username'];
                $_SESSION['formdata']['email'] = $_POST['email'];
            }
            break;
        case 'recover_password':
            if ($jauth->recover_password()) {
                $msg = SUCCESS_RECOVER;
                $jauth->clear_session();
            }
            break;
        case 'reset_password':
            if ($jauth->set_password(FALSE, $_POST['username'], $_POST['password'])) {
                $msg = SUCCESS_PASSWORD;
                $jauth->clear_session();
            } else {
                die(ERROR_RESET_PASSWORD);
            }
            break;