/** * @param StatsModel $model * @param string $data * @param int $count * @return \SQLite3Result */ public function insertData(StatsModel $model, $data, $count = 1) { $statement = $this->conn->prepare(sprintf("INSERT INTO `%s` (`date`, `count`, `data`) VALUES (%d, :count, :data);", $model->getEvent(), intval(date('U')))); $statement->bindValue(':data', $data, SQLITE3_TEXT); $statement->bindValue(':count', $count, SQLITE3_INTEGER); return $statement->execute(); }
<?php // get the config require_once 'app/config.php'; // get the stats model require_once 'app/StatsModel.php'; // new up the stats model $StatsModel = new StatsModel(); $stats = $StatsModel->getAll(); // send the responce as JSON header("HTTP/1.1 200 OK"); header("Content-Type:application/json"); header("Access-Control-Allow-Origin: *"); $json_responce = json_encode($stats); echo $json_responce;
public function updateStatistics() { if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { header("Location: http://www.bewelcome.org"); exit(0); } ob_start(); $statsModel = new StatsModel(); echo $statsModel->updateStatistics(); ob_end_clean(); echo "success"; exit(0); }