Example #1
0
require 'mvg_db.inc.php';
$geoServerStatus = true;
$link = mysql_connect(dbHost, dbUser, dbPassword) or die('Could not connect: ' . mysql_error());
mysql_select_db(dbName) or die('Database does not exist');
$start = isset($_POST['start']) ? intval($_POST['start']) : 0;
$limit = isset($_POST['limit']) ? intval($_POST['limit']) : 10;
if ($start < 0) {
    $start = 0;
}
if ($end < $start) {
    $end = $start;
}
$sort = isset($_POST['sort']) ? format_mysql($_POST['sort']) : 'start';
$dir = isset($_POST['dir']) ? strtoupper($_POST['dir']) == 'ASC' ? 'ASC' : 'DESC' : 'DESC';
$cb = isset($_REQUEST['callback']) ? preg_replace('/[^\\w]/i', '-', $_REQUEST['callback']) : NULL;
$filterWhere = getFilterCondition($_POST['filter']);
// Set the end time for old flights which haven't received a stop
$query = "SELECT id, end " . "FROM flight " . "WHERE end IS NULL ";
$result = mysql_query($query) or die('Query error: ' . mysql_error());
if (mysql_num_rows($result)) {
    while ($flight = mysql_fetch_object($result)) {
        $query = "SELECT time, DATEDIFF(CURDATE(), time) AS delta " . "FROM point WHERE flightId={$flight->id} " . "HAVING delta > 1 " . "ORDER BY time DESC limit 0,1";
        $result2 = mysql_query($query) or die('Query error: ' . mysql_error());
        if (mysql_num_rows($result2) == 1) {
            $point = mysql_fetch_object($result2);
            $query = "UPDATE flight SET end='{$point->time}' WHERE id = {$flight->id}";
            mysql_query($query) or die('Query error: ' . mysql_error());
        }
    }
}
// Get the total number of flights
Example #2
0
/**
 * filterProducts function
 * this funciton is to filter the products from the conditions specified by user, like category, brand, price range of products and outputs the json object for the product.
 * The funciton can be called from ajax method using action command 'product_filter'
 * @return void
 * @author Ankit Balyan - sf.ankit@gmail.com
 **/
function filterProducts()
{
    global $wpdb;
    $table = "rw_products";
    $user_id = isLogin();
    $where = getFilterCondition($_POST);
    $results = array();
    if (!isArvindUSer()) {
        $sql = "SELECT \n\t\t\t\t    product.*, images.image_url\n\t\t\t\tFROM\n\t\t\t\t    rw_products AS product\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_images AS images ON product.product_id = images.product_id\n\t\t\t\t        AND images.thumnail_ind = 1\n\t\t\t\tLEFT OUTER JOIN\n                \trw_brand_user_map AS user_brand ON user_brand.user_id = {$user_id}\n                LEFT OUTER JOIN\n                \trw_brands AS brand ON brand.brand_id = user_brand.brand_id\n                OR brand.brand_parent_id = user_brand.brand_id\n\t            where\n\t                (product.brand_id = brand.brand_id\n\t            or\n\t                product.brand_id = brand.brand_parent_id)\n\t\t\t\tand {$where}";
    } else {
        $sql = "SELECT \n\t\t\t\t    product.*, images.image_url\n\t\t\t\tFROM\n\t\t\t\t    rw_products AS product\n\t\t\t\t        LEFT OUTER JOIN\n\t\t\t\t    rw_images AS images ON product.product_id = images.product_id\n\t\t\t\t        AND images.thumnail_ind = 1\n\t\t\t\t    where {$where}";
    }
    extract($_POST);
    if (isset($selecteBrandBox) && count($selecteBrandBox)) {
        $results['categories'] = getCategories(null, $selecteBrandBox);
    }
    $sql .= " GROUP BY product.product_id";
    $sql .= " LIMIT 0,100";
    $results['catelog'] = $wpdb->get_results($sql);
    //json_encode($results);
    header('Content-Type: application/json');
    wp_send_json($results);
}