Example #1
0
 public function treat($parameters)
 {
     $game = new DreawGame();
     $auth = new DreawAuthorize();
     /*$contest = new DreawContest();
     		$contest->set();*/
     // output
     $tags = array('title' => 'KG-Rating | Homepage', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'uid_logged' => $_SESSION['uid_logged'], 'perm' => $_SESSION['perm_logged'], 'games_number' => count($game->lastAddedGames()));
     // processed?
     if (isset($_GET['action']) && $_GET['action'] == "processed") {
         $game->processedTracker($_GET['id']);
     }
     if ($_SESSION['uid_logged'] == 'JZikes' or $_SESSION['uid_logged'] == 'TBest') {
         //$seo = new DreawSEO('http://www.dreaw.cz');
         //$seo->get();
         $tp = new DreawTemplateParser('homepage_stats', 'application/views');
         $tp->addTags($tags);
         $tp->addDBCycleTags(['last_games' => $game->lastAddedGames(), 'last_developers' => $auth->getDevelopers(5), 'issues' => $game->getAdminTracker()]);
         $tp->parseTemplate();
     } else {
         $tp = new DreawTemplateParser('homepage', 'application/views/');
         $tp->addTags($tags);
         $tp->parseTemplate();
     }
 }
Example #2
0
 public function treat($parameters)
 {
     if (isset($_POST['login_submit'])) {
         $auth = new DreawAuthorize();
         $auth->logIn($_POST['uid'], $_POST['pass'], $_POST['dreaw_token']);
     }
     $tags = array('title' => 'KG-Rating | Login', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template');
     $tp = new DreawTemplateParser('login', 'public/views/');
     $tp->addTags($tags)->parseTemplate();
 }
Example #3
0
 public function treat($parameters)
 {
     if (isset($_POST['register_submit'])) {
         $register = new DreawAuthorize();
         $register->register($_POST['dev'], $_POST['email'], $_POST['pw'], $_POST['verify_pw'], $_POST['dreaw_token']);
         $developer = $_POST['dev'];
         $email = $_POST['email'];
     } else {
         $developer = '';
         $email = '';
     }
     $tags = array('title' => 'KG-Rating | Register', 'url_data' => URL . '/common/libs/template', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'developer_value' => $developer, 'email_value' => $email);
     $tp = new DreawTemplateParser('register', 'public/views');
     $tp->addTags($tags);
     $tp->parseTemplate();
 }
Example #4
0
 public function Treat($parameters)
 {
     $auth = new DreawAuthorize();
     $auth->isAuthorized();
     $parseURL = $this->ParseURL($parameters[0]);
     $repre_names = ['dev-tracker' => 'devTracker', 'secure-img' => 'secureImg'];
     // $parseURL[0] = 'app';
     if ($parseURL[0] != 'app') {
         // Unveliable to get true in this statement -> application error
         $this->redirect('error');
     } elseif (!isset($parseURL[1])) {
         file_exists(BASE_DIR . "application/controllers/HomepageController.php") ? $this->controller = new HomepageController() : $this->redirect('error');
     } else {
         $controller = self::CamelNotation(strtr($parseURL[1], $repre_names)) . 'Controller';
         file_exists(BASE_DIR . "application/controllers/{$controller}.php") ? $this->controller = new $controller() : $this->redirect('error');
     }
     $this->controller->treat($parseURL);
 }
 public function treat($parameters)
 {
     $game = new DreawGame();
     $auth = new DreawAuthorize();
     /* AJAX GET DEVELOPER INFO */
     if (isset($_POST['action']) && $_POST['action'] == 'developer_detail') {
         $tp = new DreawTemplateParser('developer_detail', 'application/views/ajax/templates');
         $tp->addTags(['empty' => false]);
         $tp->addDBCycleTags(['games' => $game->addedGames($_POST['uid'])]);
         $tp->parseTemplate();
         die;
     }
     /* AJAX GET DEVELOPER INFO */
     $tags = array('title' => 'KG-Rating | Developers', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']);
     $tp = new DreawTemplateParser('developers', 'application/views/');
     $tp->addTags($tags);
     $tp->addDBCycleTags(['developers' => $auth->getDevelopers()]);
     $tp->parseTemplate();
 }
 public function treat($parameters)
 {
     if (isset($parameters[2])) {
         // get user id
         $authorized = new DreawAuthorize();
         $user_id = $authorized->getDeveloperId();
         // get path to image
         if ($parameters[2] == 'profile_image') {
             if (isset($parameters[3])) {
                 $user_id = $parameters[3];
             }
             $path = realpath('common/libs/dev_data/' . $user_id . '/images/' . $parameters[2] . '.jpg');
             header('Content-type: image/jpeg');
             if (file_exists($path)) {
                 readfile($path);
                 exit(0);
             } else {
                 readfile('common/libs/template/img/profile_small.jpg');
                 exit(0);
             }
         } else {
             if (isset($parameters[3]) & isset($parameters[4])) {
                 $path = realpath('common/libs/dev_data/' . $parameters[4] . '/tracker/' . $parameters[2] . '.' . $parameters[3]);
                 header('Content-Type: application/octet-stream');
                 header("Content-Transfer-Encoding: Binary");
                 header("Content-disposition: attachment; filename=\"" . basename($path) . "\"");
                 readfile($path);
                 exit(0);
             }
         }
         // end code
         exit(0);
     } else {
         header('Location: /app/');
         exit(0);
     }
 }
Example #7
0
 public function getNewestChangeLog()
 {
     // get users last viewed changelog
     $this->_DB->query("SELECT changelog_viewed FROM users WHERE uid = :uid LIMIT 1");
     $this->_DB->bind(['uid' => $this->_SESS->getSess('uid_logged')]);
     $this->_DB->execute();
     $changelog_viewed = $this->_DB->fetchAll();
     $changelog_viewed = $changelog_viewed[0]['changelog_viewed'];
     // get newest changelog
     $this->_DB->query("SELECT * FROM changelog ORDER BY id DESC LIMIT 1");
     $this->_DB->execute();
     $newest_changelog = $this->_DB->fetchAll();
     if ($newest_changelog[0]['id'] != $changelog_viewed) {
         $data = array('view' => 'true', 'text' => $newest_changelog[0]['text']);
         // update changelog_viewed
         // get user id
         $authorize = new DreawAuthorize();
         $user_id = $authorize->getDeveloperId();
         $this->_DB->query('UPDATE users SET changelog_viewed = :changelog_viewed WHERE id = :id');
         $this->_DB->bind(['changelog_viewed' => $newest_changelog[0]['id'], 'id' => $user_id]);
         $this->_DB->execute();
     } else {
         $data = array('view' => 'false', 'text' => '');
     }
     return $data;
 }
Example #8
0
 public function treat($parameters)
 {
     $auth = new DreawAuthorize();
     $auth->logOut();
 }
Example #9
0
 public function treat($parameters)
 {
     $game = new DreawGame();
     $sess = new DreawSession();
     /* AJAX REQUEST OF ALL GRAPHS */
     if (isset($_POST['graph_data']) && !empty($_POST['graph_data'])) {
         $graph_data = htmlspecialchars($_POST['graph_data'], ENT_QUOTES);
         $game_history = $game->history($parameters[2]);
         $game_history = $game->toGraph($game_history, ['y-data' => $graph_data]);
         die(json_encode($game_history));
     }
     /* /AJAX REQUEST OF ALL GRAPHS */
     /* AJAX REQUEST OF RANGE GRAPHS */
     if (isset($_POST['action']) && $_POST['action'] == 'range_update') {
         $game_history = $game->customHistory($parameters[2], $_POST['from_date'], $_POST['to_date']);
         $gameplays_range = $game->toGraph($game_history, ['y-data' => 'gameplays']);
         $daily_range = $game->toGraph($game_history, ['y-data' => 'daily']);
         $rating_range = $game->toGraph($game_history, ['y-data' => 'rating']);
         die(json_encode([[$gameplays_range], [$daily_range], [$rating_range]]));
     }
     /* /AJAX REQUEST OF RANGE GRAPHS */
     /* AJAX request of get actual game stats */
     if (isset($_POST['get_actual_data'])) {
         $name = htmlspecialchars($_POST['get_actual_data'], ENT_QUOTES);
         die($game->getActualStats($name));
     }
     /* /AJAX request of get actual game stats */
     /* AJAX -> changelog */
     if (isset($_POST['action']) && $_POST['action'] == 'changelog') {
         // get newest changelog and return it
         $data = $game->getNewestChangeLog();
         die(json_encode($data));
     }
     /* /AJAX -> changelog */
     $tags = array('title' => 'KG-Rating | Games', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'date_actual' => date('Y/m/d'), 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']);
     $tags_single = array('title' => 'KG-Rating | SingleGame', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'date_actual' => date('d/m/Y'), 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']);
     if (!isset($parameters[2])) {
         $tp = new DreawTemplateParser('games', 'application/views/');
         $tp->addTags($tags);
         $tp->addDBCycleTags(['games' => $game->view()]);
         $tp->parseTemplate();
     } else {
         if (!empty($parameters[2])) {
             $verify = new DreawAuthorize();
             $isDeveloper = $verify->isDeveloper($parameters[2]);
             $developerName = $sess->getSess('uid_logged');
             if (!$isDeveloper and $developerName != 'JZikes' and $developerName != 'TBest' and $developerName != 'MBezdek') {
                 $session = new DreawSession();
                 $session->setSess(['error' => 'You do not have permissions to see this page!']);
                 header('Location: ../games/');
                 exit(0);
             }
             $single_game = $game->viewSingleGame($parameters[2]);
             if ($single_game['status'] == 1) {
                 $tp = new DreawTemplateParser('game_single', 'application/views/');
                 $tp->addTags($tags_single)->addDBTags($single_game['data'])->addDBCycleTags(['history' => $game->history($parameters[2])])->parseTemplate();
             } else {
                 die('Game has not any history, please wait 1 hour!');
             }
         } else {
             $this->redirect('error');
         }
     }
 }