Esempio n. 1
0
function ActivateCoupon($user, $code)
{
    global $GlobalUni, $db_prefix;
    if (MDBConnect()) {
        $id = CheckCoupon($code);
        if ($id) {
            $coupon = LoadCoupon($id);
            $query = "UPDATE coupons SET used=1, user_uni='" . $GlobalUni['num'] . "', user_id='" . $user['player_id'] . "', user_name='" . $user['oname'] . "' WHERE id = {$id}";
            // погасить купон
            MDBQuery($query);
            $query = "UPDATE " . $db_prefix . "users SET dm = dm + " . $coupon['amount'] . " WHERE player_id = " . $user['player_id'];
            // добавить пользователю платной ТМ.
            dbquery($query);
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Esempio n. 2
0
}
$GlobalUser['aktplanet'] = GetSelectedPlanet($GlobalUser['player_id']);
$now = time();
UpdateQueue($now);
$aktplanet = GetPlanet($GlobalUser['aktplanet']);
$aktplanet = ProdResources($aktplanet, $aktplanet['lastpeek'], $now);
UpdatePlanetActivity($aktplanet['planet_id']);
UpdateLastClick($GlobalUser['player_id']);
$session = $_GET['session'];
$ShowActivateDlg = false;
$CouponError = "";
if (method() === "POST") {
    $code = $_POST['couponcode'];
    SecurityCheck('/[\\-0-9A-Z]{24}/', $code, "Манипулирование кодом купона");
    if ($_POST['action'] === "check") {
        $id = CheckCoupon($code);
        if ($id) {
            $ShowActivateDlg = true;
            $coupon = LoadCoupon($id);
        } else {
            $CouponError = "Неверный код или купон уже погашен";
        }
        //Код более не действителен.
        //Неверный код
    } else {
        if ($_POST['action'] === "activate") {
            ActivateCoupon($GlobalUser, $code);
            MyGoto("micropayment");
        }
    }
}
} else {
    if (isset($_GET["no"]) && $_GET["no"] == "2") {
        // to check if user exits in the user table.
        CheckUserSignup($_GET["name"], $_GET["email"]);
    } else {
        if (isset($_GET["no"]) && $_GET["no"] == "3") {
            // to check if user exits in the Register table.
            CheckUserRegistrationAndVerification($_GET["name"], $_GET["email"]);
        } else {
            if (isset($_GET["no"]) && $_GET["no"] == "4") {
                // to check if user exits in the Register table for logging in functionality.
                CheckUserRegistrationAndVerification($_GET["name"], $_GET["email"]);
            } else {
                if (isset($_GET["no"]) && $_GET["no"] == "5") {
                    // to check if the coupon code exists in the database table or not!
                    CheckCoupon($_GET["code"]);
                } else {
                    if (isset($_POST["no"]) && $_POST["no"] == "6") {
                        // to insert/update the userEmail and userName in the Register table.
                        UserRegister($_POST["signemail"], $_POST["signname"], $_POST["signpwd"]);
                    } else {
                        if (isset($_GET["no"]) && $_GET["no"] == "7") {
                            // for authentication of password from the Resgiter table during login.
                            AuthenticateUser($_GET["email"], $_GET["pwd"]);
                        } else {
                            if (isset($_GET["no"]) && $_GET["no"] == "8") {
                                // for adding the user to Users table for invite requests.
                                AddToInvites($_GET["email"], $_GET["name"], "1", $_GET["pwd"]);
                                // 1 is for indicating that the user has requested the invite himself.
                            }
                        }