public function GET__0()
 {
     $settings = new SettingRepository();
     $apkPath = Config::getInstance()->getApkFilePath();
     $alerts = [];
     if (isset($_FILES['apk']) && $_FILES['apk']['error'] == UPLOAD_ERR_OK) {
         Auth::forceLoggingIn();
         $tempPath = $_FILES['apk']["tmp_name"];
         if (move_uploaded_file($tempPath, $apkPath)) {
             $alerts[] = 'Zaktualizowano plik APK';
         }
     }
     if (isset($_POST['version'])) {
         Auth::forceLoggingIn();
         if ($settings->setVersion($_POST['version'])) {
             $alerts[] = 'Zaktualizowano wersję aplikacji';
         }
     }
     $statistics = new StatisticRepository();
     $template = $this->includeTemplate('dashboard/settings');
     $template->alerts = $alerts;
     $template->version = $settings->getVersion();
     $template->statRest = $statistics->getStatistics(StatisticRepository::REST_API, 14);
     $template->statDownload = $statistics->getStatistics(StatisticRepository::DOWNLOAD, 14);
     $template->statHome = $statistics->getStatistics(StatisticRepository::HOME_PAGE, 14);
     if (file_exists($apkPath)) {
         $template->apkMd5 = md5_file($apkPath);
         $template->apkLastModified = filemtime($apkPath);
     }
     $template->render();
 }
 public function GET__0()
 {
     $settings = new SettingRepository();
     $version = $settings->getVersion();
     $statistics = new StatisticRepository();
     $statistics->increaseVisits(StatisticRepository::DOWNLOAD, date('Y-m-d'), $version, '');
     $path = Config::getInstance()->getApkFilePath();
     if (file_exists($path)) {
         header('Content-Type: application/vnd.android.package-archive');
         header('Content-Disposition: attachment; filename="lo1olkusz-app.apk"');
         readfile($path);
     } else {
         header('HTTP/1.0 404 Not Found');
         readfile('html/404.html');
     }
 }
Esempio n. 3
0
 /**
  * @param string $date in format yyyy-mm-dd
  * @param int $lastModified
  * @return News
  */
 public function getNews($date, $lastModified)
 {
     $now = time();
     $replacements = new ReplacementsRepository();
     $luckyNumbers = new LuckyNumberRepository();
     $timetables = new TimetableRepository();
     $bells = new BellsRepository();
     $settings = new SettingRepository();
     $news = new News();
     $news->timestamp = $now;
     $news->replacements = $replacements->getByDateAndLastModified($date, $lastModified);
     $news->luckyNumbers = $luckyNumbers->getByDateAndLastModified($date, $lastModified);
     $news->timetables = $timetables->getByLastModified($lastModified);
     $news->bells = $bells->getByLastModified($lastModified);
     $news->version = (int) $settings->get('version');
     return $news;
 }