Exemplo n.º 1
0
//date in this format : MMDDYYYY
//======================= Start MySQL connection ======================
require_once "_connections/connection_start.php";
require_once "_includes/_functions/mysql_functions.php";
require_once "_includes/_functions/process_input_functions.php";
// query for the url set
$url_set = get_server_value("url_set");
//======================= Greeting by name =======================
if (isset($_SESSION["cust_name_first"])) {
    echo "Hello, " . clean_input($_SESSION["cust_name_first"] . " : ");
}
//======================= Querying server status =======================
$serverQuery = 'SELECT * ';
$serverQuery .= 'FROM server_status';
$serverResult = mysqli_query($connection, $serverQuery);
checkQuery($serverResult);
while ($status = mysqli_fetch_assoc($serverResult)) {
    $server_online_ordering_available = $status["online_ordering_available"];
    $server_wait_time = $status["wait_time"];
    $server_registration = $status["registration"];
    $server_login = $status["login"];
}
$restaurant_closed = 0;
if ($server_online_ordering_available == 0) {
    echo 'We\'re sorry, online ordering is temporarily seized by the management team';
    $restaurant_closed = 2;
} else {
    //======================= Querying server status and show warnings =======================
    if ($server_wait_time > 20) {
        $server_warning = '<strong> Warning! The current wait time is ' . $server_wait_time . ' minutes! : </strong>';
    } else {
Exemplo n.º 2
0
function check_cust_suspension($cust_email)
{
    global $connection;
    $customerQuery = 'SELECT `customers`.`suspension` ';
    $customerQuery .= 'FROM customers ';
    $customerQuery .= 'WHERE `customers`.`email` = "' . $cust_email . '";';
    $customerResult = mysqli_query($connection, $customerQuery);
    checkQuery($customerResult);
    while ($result = mysqli_fetch_assoc($customerResult)) {
        $suspension = $result["suspension"];
    }
    if ($suspension == 1) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 3
0
 if ($food_sub_option_set == 1) {
     $firstOption = 2;
     echo '<div class="optionContainer1"><label>Choose meat: <select name="option_1">';
     $meatQuery = 'SELECT ch_000,ch_025,ch_030,ch_075,ch_170,pk_000,bf_000,bf_100,co_200,sh_100,sh_200,sh_345,sh_370,se_200,se_400,se_470,ve_000,st_000,ft_000,eg_000,nm_000,cc_000,cp_000,cb_100,cs_000 ';
     $meatQuery .= 'FROM food ';
     $meatQuery .= 'WHERE (`food`.`food_id` = "' . $food_id . '");';
     $meatResult = mysqli_query($connection, $meatQuery);
     checkQuery($meatResult);
     $meat_option = mysqli_fetch_assoc($meatResult);
     foreach ($meat_option as $meat_code => $applicable) {
         if ($applicable == 1) {
             $meatNameQuery = 'SELECT * ';
             $meatNameQuery .= 'FROM option_1 ';
             $meatNameQuery .= 'WHERE (`option_1`.`option_code` = "' . $meat_code . '");';
             $meatInfoResult = mysqli_query($connection, $meatNameQuery);
             checkQuery($meatInfoResult);
             while ($meat_info = mysqli_fetch_assoc($meatInfoResult)) {
                 $meat_name = $meat_info["option_name_en"];
                 $meat_price = $meat_info["option_price"];
                 $meat_available = $meat_info["option_available"];
             }
             if ($meat_available == 1) {
                 echo '<option value="' . $meat_code . '">' . $meat_name;
                 if ($meat_price != 0) {
                     echo ' $' . $meat_price;
                 }
                 echo '</option>';
             }
             // end if meat available
         }
         //end if meat applicable
Exemplo n.º 4
0
Arquivo: SQLite.php Projeto: mmr/b1n
 /**
  * Executes a sql query and return its result.
  * @param $query the query.
  * @return a multidimensional array with all the data requested.
  */
 public function query($query)
 {
     checkQuery($query);
     #$result = sqlite_unbuffered_query($query, $this->link);
     $result = sqlite_query($query, $this->link);
     if (!$result) {
         throw new Exception("Query Failed: '{$query}'");
     }
     $num = sqlite_num_rows($result);
     if ($num > 0) {
         for ($i = 0; $i < $num; $i++) {
             $rows[$i] = sqlite_fetch_array($result, SQLITE_ASSOC);
         }
         return $rows;
     } else {
         return sqlite_last_insert_rowid($this->link);
     }
 }
Exemplo n.º 5
0
/**
 * Attempts to guess the user's locale based on a string sample
 *
 * @param string $phrase_string used to make guess
 * @param string $locale_tag language tag to use if can't guess -- if not
 *     provided uses current locale's value
 * @param int threshold number of chars to guess a particular encoding
 * @return string IANA language tag of the guessed locale
 */
function guessLocaleFromString($phrase_string, $locale_tag = NULL)
{
    $query_string = $phrase_string;
    $locale_tag = $locale_tag == NULL ? getLocaleTag() : $locale_tag;
    $sub = PUNCT . "|[0-9]|\\s";
    $phrase_string = preg_replace('/' . $sub . '/u', "", $phrase_string);
    $phrase_string = mb_convert_encoding($phrase_string, "UTF-32", "UTF-8");
    $len = strlen($phrase_string);
    $guess['zh-CN'] = 0;
    $guess['ru'] = 0;
    $guess['he'] = 0;
    $guess['ar'] = 0;
    $guess['th'] = 0;
    $guess['ja'] = 0;
    $guess['ko'] = 0;
    $guess[$locale_tag] = 0;
    for ($i = 0; $i < $len; $i += 4) {
        $start = ord($phrase_string[$i + 2]);
        $next = ord($phrase_string[$i + 3]);
        if ($start >= 78 && $start <= 159) {
            $guess['zh-CN'] += 4;
        } else {
            if ($start == 4 || $start == 5 && $next < 48) {
                $guess['ru']++;
            } else {
                if ($start == 5 && $next >= 144) {
                    $guess['he'] += 2;
                } else {
                    if ($start >= 6 && $start <= 7) {
                        $guess['ar'] += 2;
                    } else {
                        if ($start == 14 && $next < 128) {
                            $guess['th'] += 2;
                        } else {
                            if ($start >= 48 && $start <= 49) {
                                $guess['ja'] += 3;
                            } else {
                                if ($start == 17 || $start >= 172 && $start < 215) {
                                    $guess['ko'] += 2;
                                } else {
                                    if ($start == 0 && $next < 128) {
                                        $guess[$locale_tag]++;
                                        // assume ascii is from $locale_tag
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $num_points = $len / 4 - 1;
    //there will be a lead and tail space
    $max = $guess[$locale_tag];
    if ($num_points >= 0) {
        foreach ($guess as $tag => $cnt) {
            if ($cnt >= $num_points && $cnt > $max) {
                $locale_tag = $tag;
                $max = $cnt;
                break;
            }
        }
    }
    if ($locale_tag == 'en-US') {
        $locale_tag = checkQuery($query_string);
    }
    return $locale_tag;
}
Exemplo n.º 6
0
    // Delay between connections
    if (is_numeric($dbc) || $dbc != "" || !empty($dbc)) {
    } else {
        // error
        echo "   [!]  ERROR: Delay between connections is invalid. Default is 0.5 seconds. \n";
        exit(0);
    }
} else {
    // display help
    displayHelp();
    exit(0);
}
// parse target url return a parsed array
$target_url = parseUrl($target_url);
// check if query empty or not empty
$request_url = checkQuery($target_url);
if ($k == "y") {
    // check if server supports keep-alive make sure its a parsed target url
    $keepAlive = keepAlive($target_url);
    // Switch to check results if server keeps alive
    switch ($keepAlive) {
        case "NO:KEEP-ALIVE":
            $mpc = 1;
            break;
        case "KEEP-ALIVE":
            $mpc = 100;
            break;
    }
}
// send out payloads and connection
sendphpstress($target_url, $request_url, $mr, $mpc, $dbr, $dbc);
if (!is_string($LastUser['name'])) {
    fail('ORDERBY_RETURNING_WRONG_DATA_TYPE_STRING');
}
# rawQuery() Checks
// No bound parameteres
$FirstTwoUsers = $Database->rawQuery('SELECT * FROM users WHERE id <= 2');
checkQuery('SELECT * FROM users WHERE id <= 2', 'RAWQUERY_QUERY_MISMATCH');
if (!is_array($FirstTwoUsers)) {
    fail('RAWQUERY_RETURNING_WRONG_DATA');
}
if (count($FirstTwoUsers) !== 2) {
    fail('RAWQUERY_RETURNING_WRONG_DATA');
}
// Bound parameteres
$FirstTwoUsers = $Database->rawQuery('SELECT * FROM users WHERE id <= ?', array(2));
checkQuery('SELECT * FROM users WHERE id <= 2', 'RAWQUERY_QUERY_MISMATCH');
if (!is_array($FirstTwoUsers)) {
    fail('RAWQUERY_RETURNING_WRONG_DATA');
}
if (count($FirstTwoUsers) !== 2) {
    fail('RAWQUERY_RETURNING_WRONG_DATA');
}
# getLastError Check
$Insert = @$Database->insert('users', array('id' => '1', 'name' => 'Sam'));
if ($Insert !== false) {
    fail('INSERT_DUPE_PRIMARY_KEY_NOT_RECOGNIZED');
}
if (strpos($Database->getLastError(), 'duplicate key value violates unique constraint') === false) {
    fail('INSERT_DUPE_PRIMARY_KEY_WRONG_ERROR_MSG');
}
# count() Checks