Beispiel #1
0
<?php

include_once 'secken.class.php';
$app_id = '1234';
$app_key = 'app_key';
$auth_id = 'auth_id';
// Create an API object using your credentials
$secken_api = new secken($app_id, $app_key, $auth_id);
# Step 1 - Get an qrcode for binding
$ret = $secken_api->getBinding();
//$ret = $secken_api->offline_auth('2121','sd');
# Step 2 - Check the returned result
if ($secken_api->getCode() != 200) {
    var_dump($secken_api->getCode(), $secken_api->getMessage());
} else {
    var_dump($ret);
}
<?php

include_once 'secken.class.php';
$app_id = 'IXgdZ1A7CFUej2ytUbVjFJKS5ICiorw4';
$app_key = 'ELD0DNzMYep7m6Uo1v3v';
$secken_api = new secken($app_id, $app_key);
if ($_GET["Action"] == "GetYcAuthQrCode") {
    $ret = $secken_api->getQrCode(3);
    if ($secken_api->getCode() != 200) {
        $arr = array('status' => $secken_api->getCode(), 'description' => $secken_api->getMessage());
        $json = json_encode($arr);
        echo $json;
    } else {
        $json = json_encode($ret);
        echo $json;
    }
    return;
}
if ($_GET["Action"] == "CheckYcAuthResult") {
    $event_id = $_GET["eid"];
    $ret = $secken_api->getResult($event_id);
    if ($secken_api->getCode() != 200) {
        //var_dump($secken_api->getCode(), $secken_api->getMessage());
        $arr = array('status' => $secken_api->getCode(), 'description' => $secken_api->getMessage());
        $json = json_encode($arr);
        echo $json;
    } else {
        $json = json_encode($ret);
        echo $json;
    }
    return;
Beispiel #3
0
$bindhash = isset($_POST['handlekey']) ? trim($_POST['handlekey']) : 'L' . random(4);
//进行绑定请求
if (submitcheck('confirmsubmit')) {
    //查询详细事件信息
    $info = $yangcong->getResult($_POST['event_id']);
    if (!empty($info['uid'])) {
        $bind_info = C::t('#yangcong#yangcong')->getBindInfo($_G['uid'], $info['uid']);
        //如果已经绑定,跳转到解绑页面
        if (!empty($bind_info['uid'])) {
            showmessage($lang['has_bind'], 'home.php?mod=spacecp&ac=plugin&id=yangcong:binding', null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0));
        }
        //更新绑定纪录
        if (!empty($bind_info['uid'])) {
            C::t('#yangcong#yangcong')->updateBindInfo($_G['uid'], $info['uid']);
        } else {
            $data = array();
            $data = array('uid' => $_G['uid'], 'yangcong' => $info['uid']);
            C::t('#yangcong#yangcong')->insertBindInfo($data);
        }
        showmessage($lang['bind_success'], 'home.php?mod=spacecp&ac=plugin&id=yangcong:binding', null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
    } else {
        if ($yangcong->getCode() === 602) {
            showmessage($lang['scan_to_bind'], NULL, null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0));
        } else {
            $code = $yangcong->getCode();
            $error_message = !isset($lang['error_code'][$code]) ? $lang['error_code']['unknow_error'] : $lang['error_code'][$code];
            showmessage($error_message, 'home.php?mod=spacecp&ac=plugin&id=yangcong:binding', null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
        }
    }
}
require_once template('yangcong:bind');
Beispiel #4
0
<?php

if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
require_once 'language.' . currentlang() . '.php';
require_once DISCUZ_ROOT . './source/plugin/yangcong/secken.class.php';
$app_id = $_G['cache']['plugin']['yangcong']['appid'];
$app_key = $_G['cache']['plugin']['yangcong']['appkey'];
$auth_id = $_G['cache']['plugin']['yangcong']['auth_id'];
$yangcong = new secken($app_id, $app_key, $auth_id);
$loginhash = isset($_POST['handlekey']) ? trim($_POST['handlekey']) : 'L' . random(4);
//登陆验证
if (submitcheck('confirmsubmit')) {
    $info = $yangcong->getResult($_POST['event_id']);
    $code = $yangcong->getCode();
    if ($code == 200) {
        $var = C::t('#yangcong#yangcong')->getUid($info['uid']);
        if (!empty($var)) {
            $uid = $var['uid'];
            if ($uid) {
                $member = getuserbyuid($uid, 1);
                dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), 31536000);
                showmessage($lang['login_success'], null, null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
            } else {
                showmessage($lang['login_failed'], null, null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0));
            }
        } else {
            // $auth = authcode($info['uid'], 'ENCODE', $_G['config']['security']['authkey']);
            // dsetcookie('yangconguid', $auth);
            showmessage($lang['unbind'], 'member.php?mod=register', null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
Beispiel #5
0
        $var = $GLOBALS['db']->getRow($sql);
        //如果已经绑定,跳转到解绑页面
        if (!empty($var['uid'])) {
            die(json_encode(array('status' => 0, 'message' => '账号已经绑定', 'url' => 'plugin.php?act=yangcong_bind')));
        }
        //更新绑定纪录
        $table = $GLOBALS['ecs']->table('yangcong');
        if (!empty($var['uid'])) {
            $fields = array('yangcong' => $info['uid']);
            $GLOBALS['db']->autoExecute($table, $fields, 'UPDATE', "uid={$user_id}");
        } else {
            $fields = array('uid' => $user_id, 'yangcong' => $info['uid']);
            $GLOBALS['db']->autoExecute($table, $fields, 'INSERT');
        }
        die(json_encode(array('status' => 1, 'message' => '绑定成功', 'url' => 'plugin.php?act=yangcong_bind')));
    } else {
        die(json_encode(array('status' => 0, 'message' => $yangcong->getMessage())));
    }
} else {
    $sql = "select `yangcong` from %s where `uid` = %d";
    $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id);
    $smarty->assign('bind_info', $GLOBALS['db']->getRow($sql));
    //获取绑定二维码
    $auth = $yangcong->getBinding();
    if ($yangcong->getCode() == 200) {
        $assign = array();
        $assign = array('qrcode_url' => $auth['qrcode_url'], 'message' => $yangcong->getMessage(), 'event_id' => $auth['event_id']);
        $smarty->assign('auth', $assign);
    }
    $smarty->display('template/bind.dwt');
}
Beispiel #6
0
require dirname(__FILE__) . '/load_config.php';
$app_id = $GLOBALS['yangcong']['app_id'];
$app_key = $GLOBALS['yangcong']['app_key'];
$auth_id = $GLOBALS['yangcong']['auth_id'];
$yangcong = new secken($app_id, $app_key, $auth_id);
$user_id = $_SESSION['user_id'];
if (empty($user_id)) {
    show_message('请先登录', 'user.php?act=login', 'user.php?act=login');
}
if (!empty($_POST['event_id'])) {
    $info = $yangcong->getResult($_POST['event_id']);
    if (!empty($info['uid'])) {
        $sql = "DELETE FROM %s WHERE uid=%d AND yangcong='%s'";
        $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id, $info['uid']);
        $GLOBALS['db']->query($sql);
        die(json_encode(array('status' => 1, 'message' => '绑定取消成功', 'url' => 'plugin.php?act=yangcong_bind')));
    } else {
        if ($yangcong->getCode() == 602) {
            die(json_encode(array('status' => 0, 'message' => '请求已推送到您的洋葱App,请打开确认')));
        } else {
            die(json_encode(array('status' => 0, 'message' => $yangcong->getMessage())));
        }
    }
} else {
    $sql = "select * from %s where `uid` = %d";
    $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id);
    $yangcong_info = $GLOBALS['db']->getRow($sql);
    $yangcong_uid = !empty($yangcong_info) ? $yangcong_info['yangcong'] : '';
    $smarty->assign('realtimeAuth', $yangcong->realtimeAuth($yangcong_uid));
    $smarty->display('template/cancel.dwt');
}
Beispiel #7
0
<?php

require dirname(__FILE__) . '/secken.class.php';
require dirname(__FILE__) . '/load_config.php';
$app_id = $GLOBALS['yangcong']['app_id'];
$app_key = $GLOBALS['yangcong']['app_key'];
$auth_id = $GLOBALS['yangcong']['auth_id'];
$yangcong = new secken($app_id, $app_key, $auth_id);
$user_id = $_SESSION['user_id'];
if ($user_id) {
    show_message('已经登录,正在跳转中...', 'user.php', 'user.php');
}
//登陆验证
if (!empty($_POST['event_id'])) {
    $info = $yangcong->getResult($_POST['event_id']);
    $code = $yangcong->getCode();
    if ($code == 200) {
        $sql = "select `uid` from  %s where `yangcong` =  '%s'";
        $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $info['uid']);
        $var = $GLOBALS['db']->getRow($sql, array($info['uid']));
        if (!empty($var)) {
            $uid = $var['uid'];
            if ($uid) {
                //直接登录
                $sql = "select `user_name` from %s where `user_id`=%d";
                $sql = sprintf($sql, $GLOBALS['ecs']->table('users'), $uid);
                $user_info = $GLOBALS['db']->getRow($sql);
                $GLOBALS['user']->set_session($user_info['user_name']);
                $GLOBALS['user']->set_cookie($user_info['user_name']);
                update_user_info();
                recalculate_price();