function init_smarty() { global $smarty; global $cfg; if (!$smarty) { $smarty = new MySmarty(); $smarty->mySetCache(); } }
public function getContent() { if (LoggedUser::whoIsLogged()) { if (isset($_COOKIE['ref_url'])) { $url = $_COOKIE['ref_url']; $absolute = FALSE; } else { $page = PageActionMap::getPageByTypeAndLanguage('rooms'); $url = PageActionMap::createUrl($page['alias']); $absolute = TRUE; } Utils::redirect($url, $absolute); } if (Utils::post('login')) { MySmarty::assign('username', Utils::post('username')); $validation = LoggedUser::userLogin(); //var_Dump($validation);exit(); if ($validation === TRUE) { Utils::redirect(Utils::getActualUrlWithoutGetParameters(), FALSE); } else { MySmarty::assign('errors', $validation); } } return MySmarty::fetch('login.tpl'); }
protected function run() { if ($this->check == self::OK) { $this->attackingCards = $this->cards; $nextPositionPlayer = $this->findNextPlayerWithHandCards($this->game, $this->actualPlayer, $this->actualPlayer); if ($nextPositionPlayer['id'] != $this->actualPlayer['id']) { foreach ($this->players as $player) { if ($player->getIsAlive()) { if ($player['id'] == $this->actualPlayer['id']) { $this->actualPlayer['phase'] = Player::PHASE_WAITING; $this->actualPlayer->save(); } else { if ($player['id'] == $nextPositionPlayer['id']) { $player['phase'] = Player::PHASE_UNDER_ATTACK; } MySmarty::assign('card', $this->cards[0]); $response = MySmarty::fetch($this->template); $player['command_response'] = $response; $player->save(); } } } $this->game['inter_turn_reason'] = serialize(array('action' => 'poker', 'from' => $this->actualPlayer['id'], 'to' => $nextPositionPlayer['id'], 'thrownCards' => array())); $this->game['inter_turn'] = $nextPositionPlayer['id']; $this->game->save(); } else { // bola by blbost hrat kartu poker ak nikto iny nema karty na ruke } GameUtils::throwCards($this->game, $this->actualPlayer, $this->cards); } }
protected function run() { if ($this->check == self::OK) { // TODO moze sa stat ze hraju uz len dvaja apache kid a utocnik - asi staci ak skontrolujeme ci next pos player != od actual $this->attackingCards = $this->cards; $nextPositionPlayer = $this->getNextPositionPlayer($this->game, $this->actualPlayer); foreach ($this->players as $player) { if ($player->getIsAlive()) { if ($player['id'] == $this->actualPlayer['id']) { $this->actualPlayer['phase'] = Player::PHASE_WAITING; $this->actualPlayer->save(); } else { if ($player['id'] == $nextPositionPlayer['id']) { $player['phase'] = Player::PHASE_UNDER_ATTACK; } MySmarty::assign('card', $this->cards[0]); $response = MySmarty::fetch($this->template); $player['command_response'] = $response; $player->save(); } } } $this->game['inter_turn_reason'] = serialize(array('action' => 'wild_band', 'from' => $this->actualPlayer['id'], 'to' => $nextPositionPlayer['id'], 'cards' => $this->getCardIds())); $this->game['inter_turn'] = $nextPositionPlayer['id']; $this->game->save(); GameUtils::throwCards($this->game, $this->actualPlayer, $this->cards); } }
protected function setup() { $roleRepository = new RoleRepository(TRUE); $roleRepository->addGroupBy('type'); $roles = $roleRepository->getAll(); MySmarty::assign('roles', $roles); }
/** * ページを表示する。 * * @param array(string => string) $value スキンに渡す値。bodyとtitleは必須。 */ function render($value) { $command = array(); foreach (Command::getCommands() as $c) { $html = $c->getbody(); if ($html != '') { $command[substr(get_class($c), 8)] = $html; } } $plugin = array(); foreach (Plugin::getPlugins() as $c) { $html = $c->getbody(); if ($html != '') { $plugin[substr(get_class($c), 7)] = $html; } } $this->smarty->assign('command', $command); $this->smarty->assign('plugin', $plugin); $this->smarty->assign('option', $this->option); $this->smarty->assign('headeroption', $this->headeroption); $this->smarty->assign('theme', $this->theme); $this->smarty->assign($value); header('Content-Type: text/html; charset=UTF-8'); $this->smarty->assign('runningtime', sprintf('%.3f', mtime() - STARTTIME)); $this->smarty->display(SKINFILE); }
protected function setup() { $cardRepository = new CardRepository(TRUE); $cardRepository->setGroupBy('card_base_type'); $cards = $cardRepository->getAll(); MySmarty::assign('cards', $cards); }
protected function run() { if ($this->check == self::OK) { $nextPositionPlayer = GameUtils::getPlayerOnNextPosition($this->game, $this->actualPlayer); foreach ($this->players as $player) { if ($player->getIsAlive()) { if ($player['id'] == $this->actualPlayer['id']) { $this->actualPlayer['phase'] = Player::PHASE_WAITING; if ($this->actualPlayer->getIsBelleStar($this->game)) { $notices = $this->actualPlayer->getNoticeList(); $notices['character_used'] = 1; $this->actualPlayer->setNoticeList($notices); } $this->actualPlayer->save(); } else { if ($player['id'] == $nextPositionPlayer['id']) { $player['phase'] = Player::PHASE_UNDER_ATTACK; } MySmarty::assign('card', $this->cards[0]); $response = MySmarty::fetch($this->template); $player['command_response'] = $response; $player->save(); } } } $this->game['inter_turn_reason'] = serialize(array('action' => 'gatling', 'from' => $this->actualPlayer['id'], 'to' => $nextPositionPlayer['id'])); $this->game['inter_turn'] = $nextPositionPlayer['id']; $this->game->save(); GameUtils::throwCards($this->game, $this->actualPlayer, $this->cards); } }
protected function setup() { $characterRepository = new CharacterRepository(TRUE); $characterRepository->addOrderBy(array('name' => 'ASC')); $characters = $characterRepository->getAll(); MySmarty::assign('characters', $characters); }
protected function setup() { $roleAlias = Utils::get('identifier'); $roleRepository = new RoleRepository(TRUE); $role = $roleRepository->getOneByAlias($roleAlias); MySmarty::assign('role', $role); }
protected function setup() { $pageTypeRepository = new PageTypeRepository(TRUE); $pageType = $pageTypeRepository->getOneByAlias(Utils::get('action')); $pageRepository = new PageRepository(TRUE); $page = $pageRepository->getOneByPageType($pageType['id']); MySmarty::assign('page', $page); }
public static function getInstance() { if (null == self::$instance) { self::$instance = new MySmarty(); return self::$instance; } else { return self::$instance; } }
public function main() { $room = intval($_POST['room']); $game = intval($_POST['game']); $loggedUser = LoggedUser::whoIsLogged(); $lastActivity = Room::getUserLastActivityInRoom($loggedUser['id'], $room); Room::updateUserLastActivity($loggedUser['id'], $room); MySmarty::assign('messages', Chat::getMessages($room, $loggedUser['id'], 0, $game)); echo MySmarty::fetch('message-box.tpl'); }
protected function createResponse() { if ($this->check == self::OK) { // TODO prerobit tak aby to fungovalo aj bez javascriptu, onclick treba nahradit niecim inym, pripadne doplnit tlacitko ktore skryje ten overlay MySmarty::assign('card', $this->cards[0]); $response = MySmarty::fetch($this->template); $this->attackedPlayer['command_response'] = $response; $this->attackedPlayer->save(); } return ''; }
protected function setup() { $characterAlias = Utils::get('identifier'); $characterRepository = new CharacterRepository(TRUE); $character = $characterRepository->getOneByAlias($characterAlias); BangSeo::addTitlePart($character['name']); if ($character->getLocalizedDescription()) { BangSeo::setDescription($character->getLocalizedDescription()); } MySmarty::assign('character', $character); }
function run() { if (method_exists($this, 'init')) { $this->init(); } $C = !isset($_GET['a']) ? 'index' : strtolower($_GET['a']); if (method_exists($this, $C)) { $this->{$C}(); } else { Debug::addmsg('<font color="red">控制器' . ucfirst(strtolower($_GET['m'])) . 'Action中没有' . $C . '这个方法</font>'); } parent::__construct(); }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if ($loggedUser) { MySmarty::assign('loggedUser', $loggedUser); $logoutPage = PageActionMap::getPageByTypeAndLanguage('logout'); MySmarty::assign('logoutPage', $logoutPage); } else { $loginPage = PageActionMap::getPageByTypeAndLanguage('login'); MySmarty::assign('loginPage', $loginPage); } MySmarty::assign('language', Utils::get('language')); }
public function init() { parent::init(); if (!isset($_SESSION["login"])) { $_SESSION["login"] = LOGIN_NULL; } if ($_SESSION["login"] != LOGIN_OK && $_GET["a"] != "login") { $this->login_get(); exit; } if (isset($_SESSION["username"])) { $this->assign("username", $_SESSION["username"]); } }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if ($this->room !== NULL) { Room::addUser($loggedUser['id'], $this->room['id']); $messages = Chat::getMessages($this->room['id'], $loggedUser['id'], 0, $this->game['id']); MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('messages', $messages); MySmarty::assign('users', Room::getUsers($this->room['id'])); MySmarty::assign('emoticonDir', EMOTICONS_DIR); MySmarty::assign('emoticons', Emoticons::getEmoticons()); MySmarty::assign('room', $this->room); } }
protected function setup() { $cardAlias = Utils::get('identifier'); $cardBaseTypeRepository = new CardBaseTypeRepository(TRUE); $cardBaseType = $cardBaseTypeRepository->getOneByAlias($cardAlias); if ($cardBaseType) { $cardRepository = new CardRepository(TRUE); $card = $cardRepository->getOneByCardBaseType($cardBaseType['id']); } BangSeo::addTitlePart($card->getTitle()); if ($card->getDescription()) { BangSeo::setDescription($card->getDescription()); } MySmarty::assign('card', $card); }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if (Utils::post('change_settings')) { // TODO check if password and confirm password match $loggedUser['password'] = md5(Utils::post('password')); $loggedUser['name'] = Utils::post('name'); $loggedUser['surname'] = Utils::post('surname'); $loggedUser['color'] = intval(Utils::post('color')); $loggedUser->save(); } MySmarty::assign('loggedUser', $loggedUser); $colorRepository = new ColorRepository(); $colors = $colorRepository->getAll(); MySmarty::assign('colors', $colors); }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if (Utils::post('create_room') && $loggedUser['admin']) { $params = array('title' => Utils::post('title'), 'alias' => Utils::createAlias(Utils::post('title'), 'room'), 'description' => Utils::post('description')); $room = new Room($params); $room->save(); } $roomRepository = new RoomRepository(); $rooms = $roomRepository->getAll(); $gameRepository = new GameRepository(); $games = $gameRepository->getGamesByRooms(array_keys($rooms)); foreach ($games as $game) { $rooms[$game['room']]['game'] = TRUE; $rooms[$game['room']]['status'] = Localize::getMessage('room_status_' . $game['status']); } MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('rooms', $rooms); }
protected function setup() { $pages = array(); $pageTypeRepository = new PageTypeRepository(TRUE); $hasSelected = FALSE; foreach ($this->pageTypes as $pageTypeAlias) { $page = PageActionMap::getPageByTypeAndLanguage($pageTypeAlias); if ($page) { if ($hasSelected === FALSE) { $pageType = $pageTypeRepository->getOneByAlias($pageTypeAlias); if ($pageType['action'] == $this->actualAction) { $page['sel'] = TRUE; $hasSelected = TRUE; } } $pages[] = $page; } } MySmarty::assign('pages', $pages); }
/** * initialization of Smarty */ protected function init() { if (self::$smarty === NULL) { require_once dirname(__FILE__) . '/../smarty/Smarty/libs/Smarty.class.php'; // vytvorime nove smarty $smarty = new Smarty(); $smarty->template_dir = $GLOBALS['smartyDir']; $templatesC = dirname(__FILE__) . '/../tmp/smarty-dir/templates_c/'; if (!file_exists($templatesC)) { mkdir($templatesC); } // $templatesCache = $templatesC . $GLOBALS['smartyTempCacheDir']; // if (!file_exists($templatesCache)) { // mkdir($templatesCache); // } $smarty->compile_dir = $templatesC; $smarty->cache_dir = dirname(__FILE__) . '/../tmp/smarty-dir/cache/'; $smarty->config_dir = dirname(__FILE__) . '/../tmp/smarty-dir/configs/'; self::$smarty = $smarty; } }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('room', $this->room); if ($this->game) { MySmarty::assign('game', $this->game); MySmarty::assign('gameStartedStatus', Game::GAME_STATUS_STARTED); $playerRepository = new PlayerRepository(); $actualPlayer = $playerRepository->getOneByGameAndUser($this->game['id'], $loggedUser['id']); // phases when we want to make autoreload $refreshGameBox = FALSE; if (in_array($actualPlayer['phase'], array(Player::PHASE_NONE, Player::PHASE_WAITING))) { if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED && $actualPlayer['possible_choices'] != '') { $refreshGameBox = FALSE; } else { $refreshGameBox = TRUE; } } MySmarty::assign('refreshGameBox', $refreshGameBox); // zobrazime len hracovi ktory je na tahu resp. v medzitahu $playerOnMove = $this->game->getPlayerOnMove(); if ($playerOnMove['id'] == $actualPlayer['id'] || $this->game['status'] == Game::GAME_STATUS_INITIALIZED) { MySmarty::assign('response', $actualPlayer['command_response']); } if ($this->game['status'] == Game::GAME_STATUS_CREATED) { if (!GameUtils::checkUserInGame($loggedUser, $this->game)) { MySmarty::assign('joinGameAvailable', TRUE); } elseif ($loggedUser['id'] == $this->game['creator']) { MySmarty::assign('startGameAvailable', Localize::getMessage('start_game')); } } elseif ($this->game['status'] == Game::GAME_STATUS_ENDED) { MySmarty::assign('createGameAvailable', Localize::getMessage('create_game')); MySmarty::assign('refreshGameBox', TRUE); } } else { MySmarty::assign('createGameAvailable', Localize::getMessage('create_game')); MySmarty::assign('refreshGameBox', TRUE); } }
protected function setup() { // cards $cardBaseTypeRepository = new CardBaseTypeRepository(TRUE); $validCardBaseTypes = $cardBaseTypeRepository->getByValid(1); $validCardBaseTypesIdList = array(); foreach ($validCardBaseTypes as $cardBaseType) { $validCardBaseTypesIdList[] = $cardBaseType['id']; } $cardRepository = new CardRepository(TRUE); $cardRepository->setGroupBy('card_base_type'); $cards = $cardRepository->getAll(); $validCards = array(); $notValidCards = array(); foreach ($cards as $card) { if (in_array($card['card_base_type'], $validCardBaseTypesIdList)) { $validCards[] = $card; } else { $notValidCards[] = $card; } } MySmarty::assign('validCards', $validCards); MySmarty::assign('notValidCards', $notValidCards); // characters $characterRepository = new CharacterRepository(TRUE); $characters = $characterRepository->getAll(); $validCharacters = array(); $notValidCharacters = array(); foreach ($characters as $character) { if ($character['valid'] == 1) { $validCharacters[] = $character; } else { $notValidCharacters[] = $character; } } MySmarty::assign('validCharacters', $validCharacters); MySmarty::assign('notValidCharacters', $notValidCharacters); }
protected function createResponse() { if ($this->check == self::OK) { $actualPlayerResponse = ''; foreach ($this->game->getAdditionalField('players') as $player) { $possibleChoices = unserialize($player['possible_choices']); $characterRepository = new CharacterRepository(); $possibleCharacters = $characterRepository->getById($possibleChoices['possible_characters']); MySmarty::assign('possibleCharacters', $possibleCharacters); MySmarty::assign('player', $player); $response = MySmarty::fetch($this->template); $player['command_response'] = $response; $player->save(); if ($player['id'] == $this->actualPlayer['id']) { $actualPlayerResponse = $response; } } return $actualPlayerResponse; } else { return ''; } }
** ** ------------------------------------------------------------------ ** ** This code is part of http://picurls.com - buzziest pics website. ** Read how it was designed at: ** http://catonmat.net/blog/making-of-picurls-popurls-for-pictures-part-one/ ** */ error_reporting(E_ALL); if (!$included_from_index) { header("Location: {$SITE_URL}"); exit; } require_once 'mysmarty.php'; require_once 'system/db.sqlite.php'; $smarty = new MySmarty(); $smarty->assign('tpl_content', 'content-login-register.tpl.html'); $smarty->assign('page_style', 'style-login.css'); if ($_SERVER['REQUEST_METHOD'] != "POST") { $smarty->assign('page_title', 'login into picurls!'); $smarty->assign('page_description', 'Login into picurls, buzziest pics on the net website!'); $smarty->display('index.tpl.html'); exit; } $error = false; if (!isset($_POST['username'])) { $error = "No username was specified!"; } else { if (!isset($_POST['password'])) { $error = "No password was specified!"; } else {
public function render() { $this->addSeo(); $this->setup(); return MySmarty::fetch($this->template); }
<?php require_once '../includes/config.inc'; require_once '../includes/access.inc'; $requestedUrl = isset($_REQUEST['ref']) ? base64_decode(htmlentities($_REQUEST['ref'])) : $BASE_URL . '/dashboard.php'; $submitted = isset($_REQUEST['submitted']); $username = isset($_REQUEST['username']) ? htmlentities($_REQUEST['username']) : false; $password = isset($_REQUEST['password']) ? htmlentities($_REQUEST['password']) : false; $smarty = new MySmarty($SMARTY_CONFIG); if ($submitted) { try { $access = new Access(); if ($access->authenticate($username, $password)) { header("Location: " . $requestedUrl); exit; } else { $smarty->assign('errorMessage', 'Username or Password is incorrect. Please try logging in again.'); } } catch (AccessDeniedException $e) { header('HTTP/1.1 401 Access Denied'); echo "AccessDeniedException: " . $e->getMessage(); } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); echo "Exception: " . $e->getMessage(); } } $smarty->assign('login', 'login'); $smarty->display('login.tpl');