Chris
26ec6de1e3
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
|
|
class Smart extends Page {
|
|
function setMenu()
|
|
{
|
|
$this->menu_text = 'Smart';
|
|
$this->menu_image = 'fas fa-robot';
|
|
$this->menu_priority = 1;
|
|
}
|
|
|
|
function index()
|
|
{
|
|
$this->set('template', "smart.html.php");
|
|
}
|
|
|
|
function search()
|
|
{
|
|
$db = new SQLite3(ROOT.DS.'../crawler/data.db');
|
|
$q = $_REQUEST['q'];
|
|
$query = "SELECT * FROM results WHERE teilnehmer LIKE '$q'";
|
|
$res = $db->query($query);
|
|
$results = [];
|
|
while($row = $res->fetchArray())
|
|
{
|
|
$row['date'] = $db->querySingle("SELECT date FROM events WHERE id = ".$row['event']);
|
|
$row['event'] = $db->querySingle("SELECT name FROM events WHERE id = ".$row['event']);
|
|
$row['unixtimestamp'] = strtotime($row['date']);
|
|
$row['run'] = $db->querySingle("SELECT name FROM runs WHERE id = ".$row['run']);
|
|
$row['ago'] = printRelativeTime(time(),$row['unixtimestamp']);
|
|
$results[] = $row;
|
|
}
|
|
|
|
//sort results by date
|
|
usort($results, function($a, $b) {
|
|
return $b['unixtimestamp'] <=> $a['unixtimestamp'];
|
|
});
|
|
|
|
$this->set('results', $results);
|
|
$this->set('query', $query);
|
|
$this->set('template', 'search.html.php');
|
|
|
|
}
|
|
|
|
} |