Example #1
0
<?php

$action = $_GET['action'];
switch ($action) {
    case 'getcat':
        $toreturn = getAllSubCategories();
        break;
    case 'searchproducts':
        $toreturn = searchProducts($_GET['value']);
        break;
    case 'searchsubcat':
        $toreturn = searchSubCategories($_GET['value']);
        break;
    case 'searchproductcheap':
        $toreturn = searchProductCheap($_GET['value']);
        break;
    case 'searchproductname':
        $toreturn = searchProductName($_GET['value']);
        break;
    case 'getcarts':
        $toreturn = getAllCarts($_GET['value']);
        break;
    case 'getcartcontent':
        $toreturn = getCartContent($_GET['value']);
        break;
    case 'savecarts':
        $toreturn = saveCart($_GET['name'], $_GET['user'], $_GET['value']);
        break;
    default:
        $toreturn = array("status" => 0, "title" => "Forbidden", "msg" => "Forbidden attempt at backend functionallity.");
        break;
Example #2
0
    $page = trim($_GET['page']);
    $flag = 1;
}
/*排序相关*/
if (empty($sort)) {
    if ($project_name == 'milk' || $project_name == 'milkpowder') {
        $sort = 'score';
    } else {
        $sort = 'time';
    }
}
$productsA = $productsB = array();
/*搜索相关*/
$keyWords = trim($_GET["keyword"]);
if (!empty($keyWords)) {
    $keyIds = searchProducts($keyWords);
    $productsA = getProductByIds($keyIds);
}
/*筛选相关*/
$data = showLabels();
if (!empty($labels)) {
    $ids = filterProducts($labels);
    //  echo "id".$ids;
    //print_r($ids);
    $productsB = getProductByIds($ids, $sort);
}
if (!empty($keyWords) && !empty($labels)) {
    foreach ($productsA as $value) {
        foreach ($productsB as $val) {
            if ($value == $val) {
                $products[] = $value;