Exemple #1
0
<?php 
//Used to fill textbox automatically when wrong invite url has been given
$prevUsername = isset($_GET['disname']) ? $_GET['disname'] : '';
$prevEmail = isset($_GET['email']) ? $_GET['email'] : '';
?>

<div class="wrapper-vertical-centered">

    <?php 
include_once 'fragment/top5leaderboard.php';
?>

    <div class="container">
        <?php 
if (!isset($_GET['invite_url']) || ($apiInfo = fetchUserStatsFromKid($_GET['invite_url'])) == null) {
    ?>
            <section class="middle">
                <h1>Welcome OnePlus Fan</h1>
                <br/>

                <h3>Get your reservation data by filling in your (forum)name, email & kid below.</h3>

                <h3><a href="disclaimer.php">Disclaimer</a>. We would appreciate some feedback on the <a href="https://forums.oneplus.net/threads/how-many-really-want-the-2-hmrwt2.338938/" target="blank">forum</a>.</h3>

                <div class="clear"></div>

                <?php 
    if (isset($_GET['invite_url'])) {
        ?>
                    <h2>Invalid referral invite link. Please try again.</h2>
Exemple #2
0
/**
 * Add a new user in the database.
 * @return true if the user was added, otherwise false.
 */
function addNewUserInDB($username, $email, $invite_url)
{
    if ($connection = connectDB()) {
        if (!checkIfUserExists($connection, $username)) {
            $userStats = fetchUserStatsFromKid($invite_url);
            if (!strContains($userStats, 'error')) {
                $query = "INSERT INTO users(displayname, rank, referrals, email, invite_url) VALUES (?, ?, ?, ?, ?)";
                $stmt = $connection->stmt_init();
                $stmt->prepare($query);
                $stmt->bind_param("siiss", $username, explode(';', $userStats)[0], explode(';', $userStats)[1], $email, $invite_url);
                $stmt->execute();
                $connection->close();
                return true;
            }
        }
        $connection->close();
    }
    return false;
}
            //we stop to avoid multiple task instance being ran at same time.
            exit;
        }
        if (($taskID = isTaskRunning($conn)) == 0) {
            //if no task is running, create a new one.
            $taskID = createTask($conn, count($users));
        }
        if ($taskID != 0) {
            for ($i = getTaskUserCountProgress($conn, $taskID); $i < count($users); $i++) {
                //If time elapsed is more than 15 seconds, rerun the script to bypass PHP timeout
                if (time() - $startTime > 15) {
                    asyncExecuteScript('update_user_stats.php?action=continue');
                    exit('Script continuing on another process.');
                }
                updateTaskProgress($conn, $taskID, $users[$i]['id']);
                $newUserStats = fetchUserStatsFromKid($users[$i]['invite_url']);
                updateUserStats($conn, $users[$i]['username'], explode(';', $newUserStats)[0], explode(';', $newUserStats)[1]);
            }
            setTaskFinished($conn, $taskID, -1);
            exit('Update finished.');
        } else {
            exit('error : Couldn\'t create task in database.');
        }
    }
} else {
    exit('error : Couldn\'t connect to database.');
}
/**
 * The reason why we don't want sorting is because the script calls itself after having updated a few
 * users. This can change the index order.
 *