API_USER::api_forgot PHP Method

api_forgot() public method

public api_forgot ( )
    function api_forgot()
    {
        $this->app_check("post");
        if (!isset($this->appAllow["user"]["forgot"])) {
            $_arr_return = array("alert" => "x050308");
            $_arr_logTarget[] = array("app_id" => $this->appRequest["app_id"]);
            $_arr_logType = array("user", "forgot");
            $this->log_do($_arr_logTarget, "app", $_arr_return, $_arr_logType);
            $this->obj_api->halt_re($_arr_return);
        }
        $_arr_userSubmit = $this->mdl_user->input_get_by("post");
        if ($_arr_userSubmit["alert"] != "ok") {
            $this->obj_api->halt_re($_arr_userSubmit);
        }
        $_arr_sign = array("act_post" => $GLOBALS["act_post"], $_arr_userSubmit["user_by"] => $_arr_userSubmit["user_str"]);
        if (!$this->obj_sign->sign_check(array_merge($this->appRequest, $_arr_sign), $this->appRequest["signature"])) {
            $_arr_return = array("alert" => "x050403");
            $this->obj_api->halt_re($_arr_return);
        }
        $_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);
        }
        if (!isset($this->appAllow["user"]["global"])) {
            $_arr_belongRow = $this->mdl_belong->mdl_read($_arr_userRow["user_id"], $this->appRequest["app_id"]);
            if ($_arr_belongRow["alert"] != "y070102") {
                $_arr_return = array("alert" => "x050308");
                $this->obj_api->halt_re($_arr_return);
            }
        }
        //file_put_contents(BG_PATH_ROOT . "test.txt", $_str_userPass . "||" . $_str_rand);
        $_arr_returnRow = $this->mdl_verify->mdl_submit($_arr_userRow["user_id"], $_arr_userRow["user_mail"]);
        if ($_arr_returnRow["alert"] != "y120101" && $_arr_returnRow["alert"] != "y120103") {
            $_arr_return = array("alert" => "x010407");
            $this->obj_api->halt_re($_arr_return);
        }
        $_str_verifyUrl = BG_SITE_URL . BG_URL_ROOT . "user/ctl.php?mod=reg&act_get=forgot&verify_id=" . $_arr_returnRow["verify_id"] . "&verify_token=" . $_arr_returnRow["verify_token"];
        $_str_url = "<a href=\"" . $_str_verifyUrl . "\">" . $_str_verifyUrl . "</a>";
        $_str_html = str_ireplace("{verify_url}", $_str_url, $this->obj_api->mail["forgot"]["content"]);
        $_str_html = str_ireplace("{user_name}", $_arr_userRow["user_name"], $_str_html);
        if (fn_mailSend($_arr_userRow["user_mail"], $this->obj_api->mail["forgot"]["subject"], $_str_html)) {
            $_arr_returnRow["alert"] = "y010408";
        } else {
            $_arr_returnRow["alert"] = "x010408";
        }
        $_arr_returnRow["user_id"] = $_arr_userRow["user_id"];
        $_arr_returnRow["user_name"] = $_arr_userRow["user_name"];
        //unset($_arr_returnRow["alert"]);
        $_str_src = fn_jsonEncode($_arr_returnRow, "encode");
        $_str_code = $this->obj_crypt->encrypt($_str_src, $this->appRow["app_key"]);
        $_arr_return = array("code" => $_str_code);
        $_arr_return["alert"] = $_arr_returnRow["alert"];
        $this->obj_api->halt_re($_arr_return);
    }

Usage Example

Beispiel #1
0
     $api_user->api_reg();
     break;
 case "login":
     $api_user->api_login();
     break;
 case "edit":
     $api_user->api_edit();
     break;
 case "mailbox":
     $api_user->api_mailbox();
     break;
 case "nomail":
     $api_user->api_nomail();
     break;
 case "forgot":
     $api_user->api_forgot();
     break;
 case "del":
     $api_user->api_del();
     break;
 default:
     switch ($GLOBALS["act_get"]) {
         case "get":
         case "read":
             $api_user->api_read();
             break;
         case "chkname":
         case "check_name":
             $api_user->api_chkname();
             break;
         case "chkmail":