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 run()
 {
     Database::init(Config::getInstance()->getDatabaseConfig());
     $url = self::URL;
     $dom = SimpleHtmlDom::fromUrl($url);
     if ($dom === false) {
         echo "cannot get {$url}\n";
         return;
     }
     $this->updateLuckyNumbers($dom);
     $this->updateReplacements($dom);
     echo "done\n";
 }
 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');
     }
 }
 public function DELETE_logs_0()
 {
     if (!Auth::isAuthenticated()) {
         Json::unauthorized();
     }
     $path = Config::getInstance()->getLogsPath();
     if (file_exists($path)) {
         unlink($path);
     }
     Json::OK(['message' => 'Deleted']);
 }
Beispiel #5
0
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL | E_STRICT);
require 'autoloader.php';
require 'config.php';
use pjanczyk\lo1olkusz\Auth;
use pjanczyk\lo1olkusz\Database;
use pjanczyk\lo1olkusz\Router;
use pjanczyk\lo1olkusz\Config;
date_default_timezone_set('Europe/Warsaw');
session_start();
Database::init(Config::getInstance()->getDatabaseConfig());
Auth::$disableSSL = true;
Auth::init();
$route = ['' => 'HomeController', 'contact' => 'ContactController', 'download' => 'DownloadController', 'dashboard' => ['' => 'Dashboard\\HomeController', 'login' => 'Dashboard\\LoginController', 'replacements' => 'Dashboard\\ReplacementController', 'lucky-numbers' => 'Dashboard\\LuckyNumberController', 'settings' => 'Dashboard\\SettingController', 'timetables' => 'Dashboard\\TimetableController', 'cron' => 'Dashboard\\CronController'], 'api' => 'ApiController'];
$path = isset($_GET['p']) ? $_GET['p'] : '';
Router::newInstance()->setNamespace('pjanczyk\\lo1olkusz\\Controller\\')->setControllerMap($route)->setErrorCallback(function () {
    header('HTTP/1.0 404 Not Found');
    include '404.html';
    exit;
})->route($path);