-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
45 lines (36 loc) · 1.43 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php session_start();
require "admin/config.php";
require "functions.php";
if(!isset($_SESSION["visitor"]) && !isset($_SESSION["admin"]))
{
header("Location: login.php");
}
$conection = conection_to_database($db_config);
if(!$conection)
{
header("Location: error.php");
}
$error = "";
if(isset($_GET["socio_filterBy"]) && $_GET["socio_filterBy"] == "name" && !empty($_GET["name"]))
{
$name = clean_string($_GET["name"]);
$begin = get_page() > 1 ? get_page() * $page_config["torrents_per_page"] - $page_config["torrents_per_page"] : 0;
$torrents_per_page = $page_config["torrents_per_page"];
$statement = $conection->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM socios WHERE name LIKE :name LIMIT $begin, $torrents_per_page");
$statement->execute(array("name" => "%$name%" ));
$socios = $statement->fetchAll();
}
else if(isset($_GET["socio_filterBy"]) && $_GET["socio_filterBy"] == "activity")
{
$begin = get_page() > 1 ? get_page() * $page_config["torrents_per_page"] - $page_config["torrents_per_page"] : 0;
$torrents_per_page = $page_config["torrents_per_page"];
$statement = $conection->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM socios WHERE activity = :activity LIMIT $begin, $torrents_per_page");
$statement->execute(array("activity" => clean_string($_GET["activity_type"])));
$socios = $statement->fetchAll();
}
else
{
header("Location: index.php");
}
require "view/search.view.php"
?>