2023-11-26 10:30:00 +01:00
|
|
|
<?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'];
|
2023-11-26 10:39:08 +01:00
|
|
|
$query = "SELECT * FROM results WHERE teilnehmer LIKE '$q'";
|
|
|
|
$res = $db->query($query);
|
2023-11-26 10:30:00 +01:00
|
|
|
$results = [];
|
|
|
|
while($row = $res->fetchArray())
|
|
|
|
{
|
2023-11-26 10:52:43 +01:00
|
|
|
$row['date'] = $db->querySingle("SELECT date FROM events WHERE id = ".$row['event']);
|
2023-11-26 11:01:19 +01:00
|
|
|
$row['event'] = $db->querySingle("SELECT name FROM events WHERE id = ".$row['event']);
|
2023-11-26 10:52:43 +01:00
|
|
|
$row['unixtimestamp'] = strtotime($row['date']);
|
|
|
|
$row['run'] = $db->querySingle("SELECT name FROM runs WHERE id = ".$row['run']);
|
2023-11-26 11:01:19 +01:00
|
|
|
$row['ago'] = printRelativeTime(time(),$row['unixtimestamp']);
|
2023-11-26 10:30:00 +01:00
|
|
|
$results[] = $row;
|
|
|
|
}
|
|
|
|
|
2023-11-26 10:52:43 +01:00
|
|
|
//sort results by date
|
|
|
|
usort($results, function($a, $b) {
|
2023-11-26 11:01:19 +01:00
|
|
|
return $b['unixtimestamp'] <=> $a['unixtimestamp'];
|
2023-11-26 10:52:43 +01:00
|
|
|
});
|
|
|
|
|
2023-11-26 10:30:00 +01:00
|
|
|
$this->set('results', $results);
|
2023-11-26 10:39:08 +01:00
|
|
|
$this->set('query', $query);
|
2023-11-26 10:30:00 +01:00
|
|
|
$this->set('template', 'search.html.php');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|