API_SYNC::api_logout PHP Method

api_logout() public method

public api_logout ( )
    function api_logout()
    {
        $this->app_check();
        $_arr_userSubmit = $this->mdl_user->input_get_by("post");
        if ($_arr_userSubmit["alert"] != "ok") {
            $this->obj_api->halt_re($_arr_userSubmit);
        }
        $_arr_userRow = $this->mdl_user->mdl_read($_arr_userSubmit["user_str"], $_arr_userSubmit["user_by"]);
        if ($_arr_userRow["alert"] != "y010102") {
            $this->obj_api->halt_re($_arr_userRow);
        }
        if ($_arr_userRow["user_status"] == "disable") {
            $_arr_return = array("alert" => "x010401");
            $this->obj_api->halt_re($_arr_return);
        }
        unset($_arr_userRow["user_pass"], $_arr_userRow["user_mail"], $_arr_userRow["user_nick"], $_arr_userRow["user_note"], $_arr_userRow["user_rand"], $_arr_userRow["user_status"], $_arr_userRow["user_time"], $_arr_userRow["user_time_login"], $_arr_userRow["user_ip"]);
        $_arr_code = $_arr_userRow;
        $_arr_urlRows = array();
        foreach ($this->appRows as $_key => $_value) {
            $_tm_time = time();
            $_arr_code["app_id"] = $_value["app_id"];
            $_arr_code["app_key"] = $_value["app_key"];
            //unset($_arr_code["alert"]);
            $_str_src = fn_jsonEncode($_arr_code, "encode");
            $_str_code = $this->obj_crypt->encrypt($_str_src, $_value["app_key"]);
            if (stristr($_value["app_url_sync"], "?")) {
                $_str_conn = "&";
            } else {
                $_str_conn = "?";
            }
            $_str_url = $_value["app_url_sync"] . $_str_conn . "mod=sync";
            $_arr_data = array("act_get" => "logout", "app_id" => $_value["app_id"], "app_key" => $_value["app_key"], "time" => $_tm_time, "code" => $_str_code);
            $_arr_data["signature"] = $this->obj_sign->sign_make($_arr_data);
            $_arr_urlRows[] = urlencode($_str_url . "&" . http_build_query($_arr_data));
        }
        $_arr_return = array("alert" => "y100402", "urlRows" => $_arr_urlRows);
        $this->obj_api->halt_re($_arr_return);
    }

Usage Example

Example #1
0
<?php

/*-----------------------------------------------------------------

!!!!警告!!!!
以下为系统文件,请勿修改

-----------------------------------------------------------------*/
//不能非法包含或直接执行
if (!defined("IN_BAIGO")) {
    exit("Access Denied");
}
include_once BG_PATH_INC . "common_api.inc.php";
//验证是否已登录
include_once BG_PATH_CONTROL_API . "sync.class.php";
//载入商家控制器
$api_sync = new API_SYNC();
//初始化商家
switch ($GLOBALS["act_get"]) {
    case "login":
        $api_sync->api_login();
        break;
    case "logout":
        $api_sync->api_logout();
        break;
}