/** * api_signature function. * * @access public * @return void */ function api_signature() { $this->app_check("get"); if (!isset($this->appAllow["signature"]["signature"])) { $_arr_return = array("alert" => "x050312"); $this->log_do($_arr_return, "signature"); $this->obj_api->halt_re($_arr_return); } $_arr_time = validateStr(fn_get("time"), 1, 0); switch ($_arr_time["status"]) { case "too_short": $_arr_return = array("alert" => "x090201"); $this->obj_api->halt_re($_arr_return); break; case "ok": $_tm_time = $_arr_time["str"]; break; } $_arr_random = validateStr(fn_get("random"), 1, 0); switch ($_arr_random["status"]) { case "too_short": $_arr_return = array("alert" => "x090202"); $this->obj_api->halt_re($_arr_return); break; case "ok": $_str_rand = $_arr_random["str"]; break; } $_str_sign = fn_baigoSignMk($_tm_time, $_str_rand); $_arr_return = array("signature" => $_str_sign, "alert" => "y050404"); $this->obj_api->halt_re($_arr_return); }
function fn_baigoSignChk($tm_time, $str_rand, $str_sign) { $_str_temp = fn_baigoSignMk($tm_time, $str_rand); if ($_str_temp == $str_sign) { return true; } else { return false; } }
/** * ajax_notice function. * * @access public * @return void */ function ajax_notice() { $_num_appId = fn_getSafe(fn_post("app_id_notice"), "int", 0); if ($_num_appId == 0) { $this->obj_ajax->halt_alert("x050203"); } if (!isset($this->adminLogged["admin_allow"]["app"]["browse"])) { $this->obj_ajax->halt_alert("x050301"); } $_arr_appRow = $this->mdl_app->mdl_read($_num_appId); if ($_arr_appRow["alert"] != "y050102") { $this->obj_ajax->halt_alert($_arr_appRow["alert"]); } $_tm_time = time(); $_str_rand = fn_rand(); $_str_sign = fn_baigoSignMk($_tm_time, $_str_rand); $_str_echo = fn_rand(); $_arr_data = array("act_get" => "test", "time" => $_tm_time, "random" => $_str_rand, "signature" => $_str_sign, "echostr" => $_str_echo, "app_id" => $_arr_appRow["app_id"], "app_key" => $_arr_appRow["app_key"]); if (stristr($_arr_appRow["app_notice"], "?")) { $_str_conn = "&"; } else { $_str_conn = "?"; } $_arr_notice = fn_http($_arr_appRow["app_notice"] . $_str_conn . "mod=notice", $_arr_data, "get"); //print_r($_arr_notice); //exit; if ($_arr_notice["ret"] == $_str_echo) { $_str_alert = "y050401"; } else { $_str_alert = "x050401"; $_arr_targets[] = array("app_id" => $_num_appId); $_str_targets = json_encode($_arr_targets); $_str_notice = htmlentities($_arr_notice["ret"], ENT_QUOTES, "UTF-8"); //exit($_str_notice); $this->mdl_log->mdl_submit($_str_targets, "app", $this->log["app"]["noticeTest"], $_str_notice, "admin", $this->adminLogged["admin_id"]); //exit("test"); } $this->obj_ajax->halt_alert($_str_alert); }
function api_logout() { $this->app_check("get"); if (!isset($this->appAllow["user"]["login"])) { $_arr_return = array("alert" => "x050306"); $_arr_logTarget[] = array("app_id" => $this->appGet["app_id"]); $_arr_logType = array("user", "get"); $this->log_do($_arr_logTarget, "app", $_arr_return, $_arr_logType); $this->obj_sync->halt_re($_arr_return); } $_arr_userId = validateStr($this->appGet["user_id"], 1, 0, "str", "int"); switch ($_arr_userId["status"]) { case "too_short": $_arr_return = array("alert" => "x010217"); $this->obj_sync->halt_re($_arr_return); break; case "format_err": $_arr_return = array("alert" => "x010218"); $this->obj_sync->halt_re($_arr_return); break; case "ok": $_num_userId = $_arr_userId["str"]; break; } $_arr_userRow = $this->mdl_user->mdl_read($_num_userId); if ($_arr_userRow["alert"] != "y010102") { $this->obj_sync->halt_re($_arr_userRow); } if ($_arr_userRow["user_status"] != "enable") { $_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"]); $_str_key = fn_rand(6); $_arr_code = $_arr_userRow; $_str_sync = ""; foreach ($this->appRows as $_key => $_value) { $_tm_time = time(); $_str_rand = fn_rand(); $_str_sign = fn_baigoSignMk($_tm_time, $_str_rand); $_arr_code["app_id"] = $_value["app_id"]; $_arr_code["app_key"] = $_value["app_key"]; $_str_code = $this->obj_sync->sync_encode($_arr_code, $_str_key); if (stristr($_value["app_notice"], "?")) { $_str_conn = "&"; } else { $_str_conn = "?"; } $_str_url = $_value["app_notice"] . $_str_conn . "act_get=logout&time=" . $_tm_time . "&random=" . $_str_rand . "&signature=" . $_str_sign . "&code=" . $_str_code . "&key=" . $_str_key; $_str_sync .= "<script type=\"text/javascript\" src=\"" . $_str_url . "\"></script>"; } $_arr_return = array("alert" => "y100402", "html" => base64_encode($_str_sync)); exit(fn_jsonEncode($_arr_return, "no")); }
function api_logout() { $this->app_check("get"); if (!isset($this->appRow["app_allow"]["user"]["login"])) { $_arr_return = array("alert" => "x050306"); $_arr_logTarget[] = array("app_id" => $this->appRequest["app_id"]); $_arr_logType = array("user", "get"); $this->log_do($_arr_logTarget, "app", $_arr_return, $_arr_logType); $this->obj_sync->halt_re($_arr_return); } $_arr_userId = validateStr($this->appRequest["user_id"], 1, 0, "str", "int"); switch ($_arr_userId["status"]) { case "too_short": $_arr_return = array("alert" => "x010217"); $this->obj_sync->halt_re($_arr_return); break; case "format_err": $_arr_return = array("alert" => "x010218"); $this->obj_sync->halt_re($_arr_return); break; case "ok": $_num_userId = $_arr_userId["str"]; break; } $_arr_userRow = $this->mdl_user->mdl_read($_num_userId); if ($_arr_userRow["alert"] != "y010102") { $this->obj_sync->halt_re($_arr_userRow); } if ($_arr_userRow["user_status"] != "enable") { $_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"]); $_str_key = fn_rand(6); $_arr_code = $_arr_userRow; $_arr_urlRows = array(); foreach ($this->appRows as $_key => $_value) { $_tm_time = time(); $_str_rand = fn_rand(); $_str_sign = fn_baigoSignMk($_tm_time, $_str_rand); $_arr_code["app_id"] = $_value["app_id"]; $_arr_code["app_key"] = $_value["app_key"]; $_str_code = $this->obj_sync->sync_encode($_arr_code, $_str_key); if (stristr($_value["app_notice"], "?")) { $_str_conn = "&"; } else { $_str_conn = "?"; } $_str_url = $_value["app_notice"] . $_str_conn . "mod=sync"; $_arr_data = array("act_get" => "logout", "time" => $_tm_time, "random" => $_str_rand, "signature" => $_str_sign, "code" => $_str_code, "key" => $_str_key); $_arr_urlRows[] = urlencode($_str_url . "&" . http_build_query($_arr_data)); } $_arr_return = array("alert" => "y100402", "urlRows" => $_arr_urlRows); $this->obj_sync->halt_re($_arr_return); }
/** 通知 * api_notice function. * * @access public * @param mixed $arr_data * @param mixed $arr_appRows * @return void */ function api_notice($arr_data, $arr_appRows, $method = "post") { foreach ($arr_appRows as $_key => $_value) { $_tm_time = time(); $_str_rand = fn_rand(); $_str_sign = fn_baigoSignMk($_tm_time, $_str_rand); $_arr_query = array("time" => $_tm_time, "random" => $_str_rand, "signature" => $_str_sign, "app_id" => $_value["app_id"], "app_key" => $_value["app_key"]); $_arr_data = array_merge($arr_data, $_arr_query); if (stristr($_value["app_notice"], "?")) { $_str_conn = "&"; } else { $_str_conn = "?"; } $_arr_return[$_key] = fn_http($_value["app_notice"] . $_str_conn . "mod=notice", $_arr_data, $method); } return $_arr_return; }