Exemplo n.º 1
0
function initGlobalVariables()
{
    global $users, $usersInRestaurants, $dapulseApiKey, $numOfResults, $usersTimeInRest, $invited, $replies, $orders, $testCount;
    if (!$dapulseApiKey) {
        $dapulseApiKey = 'c83b648d198b0a081b71c612c871470d';
    }
    if (!$numOfResults) {
        $numOfResults = 2000;
    }
    if (!($users = getGlobalVar('users'))) {
        $users = createUsersIndex();
        setGlobalVar('users', $users);
    }
    if (!($usersInRestaurants = getGlobalVar('usersInRestaurants'))) {
        $usersInRestaurants = [];
        setGlobalVar('usersInRestaurants', $usersInRestaurants);
    }
    if (!($usersTimeInRest = getGlobalVar('usersTimeInRest'))) {
        $usersTimeInRest = [];
        setGlobalVar('usersTimeInRest', $usersTimeInRest);
    }
    if (!$invited) {
        $invited = [];
        setGlobalVar('invites', $invited);
    }
    if (!$replies) {
        $replies = [];
        setGlobalVar('replies', $replies);
    }
    if (!$orders) {
        $orders = [];
        setGlobalVar('orders', $orders);
    }
    if (!$testCount) {
        $testCount = 0;
        setGlobalVar('testCount', $testCount);
    }
}
Exemplo n.º 2
0
function updateMinMaxWifiSignals($signal, $group, $conn)
{
    $wifi_sig_low = getGlobalVar("wifi_sig_low", $group, $conn);
    $wifi_sig_high = getGlobalVar("wifi_sig_high", $group, $conn);
    //if it is less than min, update the min
    if ($signal < $wifi_sig_low) {
        //update the min
        setGlobalVar("wifi_sig_low", $group, $signal, $conn);
        return "low";
    }
    //elseif it is more than the max
    if ($signal > $wifi_sig_high) {
        //update the max
        setGlobalVar("wifi_sig_high", $group, $signal, $conn);
        return "high";
    }
    $difference = abs($wifi_sig_high - $wifi_sig_low);
    $difference_slots = $difference / 3;
    if ($signal <= $wifi_sig_low + $difference_slots) {
        return "low";
    }
    if ($signal >= $wifi_sig_low + $difference_slots && $signal < $wifi_sig_low + 2 * $difference_slots) {
        return "med";
    }
    if ($signal >= $wifi_sig_low + 2 * $difference_slots) {
        return "high";
    } else {
        //is not in any region. so just say "low";
        return "med";
    }
}