fork download
  1. <?
  2. function get($var, $val){
  3. $url = parse_url($_SERVER['REQUEST_URI']);
  4. $query = $url['query'];
  5. parse_str($query, $url);
  6. $url["$var"] = $val;
  7. $url = "{$GLOBALS['siteurl']}"."/templates/deals/deals.php"."?".http_build_query($url);
  8. return $url;
  9. }
  10. function filter(){
  11. if(!empty($_GET)){
  12. $url = parse_url($_SERVER['REQUEST_URI']);
  13. $query = $url['query'];
  14. parse_str($query, $url);
  15. $sql = " where ";
  16. $count = count($url);
  17. $i=1;
  18. foreach($url as $key => $val){
  19. if(is_string($val)){
  20. $sql .= "`".$key."`"." LIKE "."'%".$val."%'";
  21. }else{
  22. $sql .= "`".$key."`"."="."'".$val."'";
  23. }
  24.  
  25. if($i<$count){
  26. $sql .= " and ";
  27. }
  28. $i++;
  29. }
  30. return $sql;
  31. }else{
  32. return false;
  33. }
  34. }
  35. ?>
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
<?
function get($var, $val){
$url = parse_url($_SERVER['REQUEST_URI']);
$query = $url['query'];
parse_str($query, $url);
$url["$var"] =  $val;
$url = "{$GLOBALS['siteurl']}"."/templates/deals/deals.php"."?".http_build_query($url);
return $url;
}
function filter(){
    if(!empty($_GET)){
    $url = parse_url($_SERVER['REQUEST_URI']);
    $query = $url['query'];
    parse_str($query, $url);
    $sql = " where ";
    $count = count($url);
    $i=1;
    foreach($url as $key => $val){
    if(is_string($val)){
        $sql .= "`".$key."`"." LIKE "."'%".$val."%'";
    }else{
        $sql .= "`".$key."`"."="."'".$val."'";
    }

        if($i<$count){
            $sql .= " and ";
        }
        $i++;
    }
    return $sql;
    }else{
    return false;
    }
}
?>