示例#1
0
文件: wsd.php 项目: rotoballer/emily
function wsd_render_main()
{
    if (1 == 0) {
        delete_option('WSD-TARGETID');
        delete_option("WSD-COOKIE");
        delete_option("WSD-USER");
        return;
    }
    //-- GET
    $rm = strtoupper($_SERVER['REQUEST_METHOD']);
    if ('GET' == $rm) {
        $targetid = get_option("WSD-TARGETID");
        if ($targetid !== false) {
            wsd_render_target_status();
            return;
        }
        $u = get_option('WSD-USER');
        if (false === $u) {
            wsd_render_new_user();
            return;
        } else {
            wsd_render_user_login();
            return;
        }
    }
    //-- POST
    if (isset($_POST['wsd-new-user'])) {
        wsd_process_new_user_form();
        return;
    }
    if (isset($_POST['wsd-login'])) {
        wsd_process_login();
        return;
    }
    if (isset($_POST['wsd_update_target_id'])) {
        wsd_process_add_target_id();
        return;
    }
    $hello = wsd_jsonRPC(WSD_URL_RPC, "cPlugin.hello", wsd_site_url());
    if ($hello == null) {
        // update sept 20
        wsd_render_new_user();
        return;
    }
    if ($hello == 'registered') {
        wsd_render_add_target_id();
        return;
    } elseif ($hello == 'new') {
        //$user = get_option("WSD-USER"); if($user === FALSE)
        wsd_render_new_user();
        //else wsd_render_user_login();
    } else {
        wsd_render_error(__("Invalid server response. Please try again in a few minutes!"));
        return;
    }
}
示例#2
0
function wsd_process_login()
{
    $email = isset($_POST['wsd_login_form_email']) ? $_POST['wsd_login_form_email'] : null;
    $password = isset($_POST['wsd_login_form_password']) ? $password = $_POST['wsd_login_form_password'] : null;
    if (empty($email)) {
        wsd_render_user_login('Email address is required.');
        return;
    }
    if (empty($password)) {
        wsd_render_user_login('Password is required.');
        return;
    }
    // $password is received as MD5 hash
    $login = wsd_jsonRPC(WSD_URL_RPC, "cUser.login", array($email, $password));
    if ($login == NULL) {
        wsd_render_user_login('Invalid login');
        return;
    }
    $user = get_option("WSD-USER");
    if ($user === False) {
        add_option("WSD-USER", $email);
    } else {
        update_option("WSD-USER", $email);
    }
    wsd_add_or_process_target();
}