function index() { $dota = Dota::me(); if (isset($this->args[0])) { $match_id = (int) $this->args[0]; } if (!empty($match_id)) { $steam_ids_array = array(); $match = $dota->get_match_by_id($match_id); foreach ($match['players'] as $key => $player) { if ($player['account_id'] == 4294967295.0) { continue; } $steam_ids_array[$key] = $player['account_id']; } $profiles = $dota->get_user_profiles($steam_ids_array); foreach ($profiles as $key => $profile) { $match['players'][$key]['profile'] = $profile; } $match['tower_radiant'] = decbin(32768 + $match['tower_status_radiant']); $match['tower_dire'] = decbin(32768 + $match['tower_status_dire']); $match['barak_radiant'] = decbin(128 + $match['barracks_status_radiant']); $match['barak_dire'] = decbin(128 + $match['barracks_status_dire']); $this->des->set('spells', $dota->get_spells()); //$this->des->set('arr', $arr['result']); $this->des->set('match', $match); } $this->des->set('dota', $dota); $this->des->display('match'); }
public static function me() { if (is_null(self::$instance)) { self::$instance = new Dota(); } return self::$instance; }
function index() { $dota = Dota::me(); if ($this->user['id']) { $arr['account_id'] = $this->user['steamid']; $arr['matches_requested'] = 5; $history = $dota->get_match_history($arr); $heroes = array(); foreach ($history['matches'] as $match) { foreach ($match['players'] as $player) { if (Dota::me()->MAKE_64_BIT($player['account_id']) == $this->user['steamid']) { $heroes[] = $player['hero_id']; } } } $dota->init_heroes($heroes); $this->des->set('dota', $dota); $this->des->set('history', $history); $this->des->display('index'); } }
public function index() { if ($this->user['id']) { $this->error('Вы уже авторизированы!'); } //Авторизация через логин-пароль--- if (isset($_POST['login'])) { //Закрываем авторизацию по логину-паролю $this->error('Авторизация возможна только через Steam'); $this->des->set('title', 'Авторизация'); try { if ($arr = SiteRead::me()->auth($_POST['login'], $_POST['pas'])) { //Авторизируем пользователя $_SESSION['user_id'] = $arr['id']; //Пишем куки----- if (isset($_POST['remember'])) { setcookie('id', $arr['id'], time() + 3600 * 24 * 30, '/'); setcookie('p', $arr['pas'], time() + 3600 * 24 * 30, '/'); } //-------------- $this->loc($this->back_url); } } catch (Exception $e) { $this->error($e->getMessage(), false); } } //-------------- //Авторизация через OpenID $openid = new LightOpenID(H); if (!$openid->mode) { $openid->identity = 'http://steamcommunity.com/openid'; $this->loc($openid->authUrl()); } elseif ($openid->mode == 'cancel') { echo 'Авторизация отменена'; } else { if (!$openid->validate()) { $this->error('Ошибка авторизации'); } $id = $openid->identity; $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/"; preg_match($ptn, $id, $matches); $_SESSION['steamid'] = $matches[1]; $_SESSION['steam'] = Dota::me()->get_user_profile($_SESSION['steamid']); $_SESSION['user_id'] = SiteWrite::me()->steamRegistrationUser($_SESSION['steamid'], $_SESSION['steam']['personaname']); $this->loc(H); } //$this->des->display('login'); $this->des->display('_auth_form_steam'); }