id = $data["id"]; $this->start = strtotime($data["start"]); $this->end = strtotime($data["end"]); $this->host = $data["host"]; } } function getLastQuizzPeriod() { require_once("./.htconfig.php"); $dblink = getlink(); $result = array(); $userCountPerChan = $dblink->prepare("SELECT * FROM `knackizz_period` ORDER BY `id` DESC LIMIT 1"); $userCountPerChan->execute(); if ($row = $userCountPerChan->fetch(PDO::FETCH_ASSOC)) return new Period($row); return null; } function getCurrentOrLastQuizzPeriod($periodId) { if ($periodId == null) return getLastQuizzPeriod(); require_once("./.htconfig.php"); $dblink = getlink(); $result = array(); $userCountPerChan = $dblink->prepare("SELECT * FROM `knackizz_period` WHERE `id`=:id"); $userCountPerChan->execute([ "id" => $periodId ]); if ($row = $userCountPerChan->fetch(PDO::FETCH_ASSOC)) return new Period($row); return getLastQuizzPeriod(); } function getPreviousQuizzPeriod($periodId) { require_once("./.htconfig.php"); $dblink = getlink(); $result = array(); $userCountPerChan = $dblink->prepare("SELECT * FROM `knackizz_period` WHERE `id` < :id ORDER BY `id` DESC LIMIT 1"); $userCountPerChan->execute([ "id" => $periodId ]); if ($row = $userCountPerChan->fetch(PDO::FETCH_ASSOC)) return new Period($row); return null; } function getNextQuizzPeriod($periodId) { require_once("./.htconfig.php"); $dblink = getlink(); $result = array(); $userCountPerChan = $dblink->prepare("SELECT * FROM `knackizz_period` WHERE `id` > :id ORDER BY `id` DESC LIMIT 1"); $userCountPerChan->execute([ "id" => $periodId ]); if ($row = $userCountPerChan->fetch(PDO::FETCH_ASSOC)) return new Period($row); return null; } function getQuizzScores($periodId) { $result = []; require_once("./.htconfig.php"); $dblink = getlink(); $result = array(); $userCountPerChan = $dblink->prepare("SELECT * FROM `knackizz_scores` WHERE `period_id`=:pid ORDER BY `score` DESC"); $userCountPerChan->execute([ "pid" => $periodId ]); $i = 0; while ($row = $userCountPerChan->fetch(PDO::FETCH_ASSOC)) $result[] = array( "rank" => ++$i, "pseudo" => $row["pseudo"], "score" => $row["score"] ); return $result; } ?>