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(); } }
public function treat($parameters) { $game = new DreawGame(); if (isset($parameters[2])) { if ($parameters[2] == 'add') { // add issue $tags = array('title' => 'KG-Rating | Add Issue', 'bootstrap' => URL . '/common/libs/bootstrap', 'datables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']); $tp = new DreawTemplateParser('tracker_add', 'application/views/'); $tp->addTags($tags); $tp->parseTemplate(); if (isset($_POST['tracker_add_submit'])) { $game->addIssue($_POST['message_text'], $_POST['category'], $_FILES['ufile'], 0); } } else { // dev tracker $tags = array('title' => 'KG Rating | DevTracker', 'bootstrap' => URL . '/common/libs/bootstrap', 'datables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'perm' => $_SESSION['perm_logged'], 'uid_logged' => $_SESSION['uid_logged']); $tp = new DreawTemplateParser('dev_tracker', 'application/views'); $tp->addTags($tags); $tp->addDBCycleTags(['issues' => $game->getDevTracker()]); $tp->parseTemplate(); } } else { header('Location: /app/'); exit(0); } }
public function treat($parameters) { $game = new DreawGame(); $tags = array('title' => 'KG-Rating | Games', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template'); $tp = new DreawTemplateParser('games', 'public/views/'); $tp->addTags($tags); $tp->addDBCycleTags(['games' => $game->view()]); $tp->parseTemplate(); }
public function logIn($uid, $pass, $token) { if (!empty($uid)) { if (!empty($pass)) { if (!empty($token) && $token == $this->_SESS->getSess('dreaw_token')) { $this->_DB->query('SELECT id, pass, mail, last_logged, perm, verified FROM users WHERE uid = :uid LIMIT 1'); $this->_DB->bind(['uid' => $uid]); $this->_DB->execute(); $user_data = $this->_DB->fetchAll(); if (!empty($user_data)) { if ($user_data[0]['verified'] == 1) { if (password_verify($pass, $user_data[0]['pass'])) { $this->_SESS->setSess(['logged' => true, 'uid_logged' => $uid, 'mail_logged' => $user_data[0]['mail'], 'last_logged' => $user_data[0]['last_logged'], 'perm_logged' => $user_data[0]['perm']]); // update last_logged $this->_DB->query('UPDATE users SET last_logged = :last_logged WHERE id = :id'); $this->_DB->bind(['last_logged' => date('Y-m-d H:i:s'), 'id' => $user_data[0]['id']]); $this->_DB->execute(); // game to redirect $game = new DreawGame(); $games = $game->addedGames($_SESSION['uid_logged']); if (isset($games[1])) { header('Location: /app/myGames/'); exit(0); } elseif (isset($games[0])) { $url = '/app/games/' . $games[0]['code_represent']; header('Location: ' . $url . ''); exit(0); } else { header('Location: /app/gameAdd'); exit(0); } exit(0); } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'Your account is not verified yet.']); } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'Validity of this page has expired. Please reload this page.']); return false; } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } } else { $this->_SESS->setSess(['error' => 'You have entered an invalid login data. Please check your credentials and try again.']); return false; } }
public function treat($parameters) { $game = new DreawGame(); /* AJAX -> changelog */ if (isset($_POST['action']) && $_POST['action'] == 'changelog') { // get newest changelog and return it $data = $game->getNewestChangeLog(); die(json_encode($data)); } /* /AJAX -> changelog */ if (isset($_POST['game_submit'])) { $game->validate($_POST['game_url']); } $tags = array('title' => 'KG-Rating | AddGame', '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('game_add', 'application/views/'); $tp->addTags($tags)->parseTemplate(); }
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) { $game = new DreawGame(); // view $tags = array('title' => 'KG-Rating | ChangeLog', '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']); if ($_SESSION['perm_logged'] == "0") { if (isset($_POST['changelog_add_submit'])) { $game->addChangeLog($_POST['changelog_msg']); } $tp = new DreawTemplateParser('changelog_private', 'application/views'); $tp->addTags($tags); $tp->addDBCycleTags(['logs' => $game->getEveryChangeLog()]); $tp->parseTemplate(); } else { $tp = new DreawTemplateParser('changelog', 'application/views/'); $tp->addTags($tags); $tp->addDBCycleTags(['logs' => $game->getEveryChangeLog()]); $tp->parseTemplate(); } }
public function treat($parameters) { $game = new DreawGame(); if (isset($parameters[2])) { // Are you realy this developer? if ($parameters[2] == $_SESSION['uid_logged']) { // calculate games $games = $game->addedGames($_SESSION['uid_logged']); if (isset($games[0])) { $count_games = count($games); } else { $count_games = '0'; } } else { header('Location: /app/'); } } else { header('Location: /app/'); } // Set new profile image if (isset($_POST['set_profile'])) { if (isset($_FILES['image_field'])) { $game->setProfileImage($_FILES['image_field']); } } // Change profile description if (isset($_POST['action']) && $_POST['action'] == 'change_description') { if (!empty($_POST['text'])) { $game->setDevDescription($_POST['text']); } $data = $game->getDevDescription(); die(json_encode($data)); } // output $tags = array('title' => 'KG-Rating | Profile', 'bootstrap' => URL . '/common/libs/bootstrap', 'datatables' => URL . '/common/libs/dataTables', 'url' => URL, 'url_data' => URL . '/common/libs/template', 'uid_logged' => $_SESSION['uid_logged'], 'mail_logged' => $_SESSION['mail_logged'], 'perm' => $_SESSION['perm_logged'], 'games_number' => $count_games, 'description' => $game->getDevDescription()); $tp = new DreawTemplateParser('profile', 'application/views/'); $tp->addTags($tags); $tp->parseTemplate(); }
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'); } } }