mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 11:33:41 +02:00
dev21w43d-a
This commit is contained in:
parent
65632140d8
commit
180bc0b0d9
1 changed files with 20 additions and 2 deletions
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
class Search extends Database {
|
class Search extends Database {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->query = $query;
|
parent::__construct("search");
|
||||||
|
|
||||||
|
$this->query = $this->real_escape_string($query);
|
||||||
|
|
||||||
$mime_type = $_SERVER["HTTP_CONTENT_TYPE"] ? $_SERVER["HTTP_CONTENT_TYPE"] : $_GET["f"];
|
$mime_type = $_SERVER["HTTP_CONTENT_TYPE"] ? $_SERVER["HTTP_CONTENT_TYPE"] : $_GET["f"];
|
||||||
switch($mime_type) {
|
switch($mime_type) {
|
||||||
|
@ -22,6 +24,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function get_results() {
|
||||||
|
$sql = "SELECT id,template,content FROM `search` WHERE `content` LIKE '%{$this->query}%'";
|
||||||
|
$query = $this->query($sql);
|
||||||
|
if(!$query->num_rows()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $query->fetch_assoc();
|
||||||
|
}
|
||||||
|
|
||||||
private function get_html_template($name) {
|
private function get_html_template($name) {
|
||||||
$path = dirname(__FILE__,1)."/templates/${name}.html";
|
$path = dirname(__FILE__,1)."/templates/${name}.html";
|
||||||
if(!is_file($path)) {
|
if(!is_file($path)) {
|
||||||
|
@ -38,11 +49,18 @@
|
||||||
$this->get_html_template("card_default"),
|
$this->get_html_template("card_default"),
|
||||||
$this->get_html_template("result_about")
|
$this->get_html_template("result_about")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
header("Content-Type: text/html");
|
||||||
echo implode("",$results);
|
echo implode("",$results);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_json() {
|
private function get_json() {
|
||||||
|
$data = [
|
||||||
|
"results" => []
|
||||||
|
];
|
||||||
|
$json = json_encode($data);
|
||||||
|
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
echo "{}";
|
echo $json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue