Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config.php';
- require_once 'classes/class.smarty/Smarty.class.php';
- require_once 'classes/class.content.php';
- require_once 'classes/class.gamehandler.php';
- require_once 'classes/facebook.php';
- $Handler = new Handler();
- $NewsData = new stdClass();
- $NewsData->SlideOne = array();
- $NewsData->SlideTwo = array();
- if (isset($_POST['txtUsername']) AND isset($_POST['txtPassword'])) {
- $_POST = $Handler->MySQL('EscapeArray', $_POST);
- $Authenticate = $Handler->AuthenticateUser($_POST['txtUsername'], $_POST['txtPassword'], $_POST['remember'] === 'true');
- if (!$Authenticate) $Handler->plain(json_encode(array('output' => 'failure')));
- $Result = array('output' => 'success',
- 'root' => Configuration::getPublic('RootPath'),
- 'info' => $Handler->UserData->FlashVars,
- 'name' => $Handler->UserData->Name,
- 'Gold' => $Handler->UserData->Gold,
- 'Coins' => $Handler->UserData->Coins,
- 'Kills' => $Handler->UserData->KillCount,
- 'Deaths' => $Handler->UserData->DeathCount);
- $Handler->plain(json_encode(array_merge($Result, $Handler->calculateStats())));
- } else if (isset($_GET['profile'])) {
- if (empty($_GET['profile'])) $Handler->redirectToRoot();
- $_GET = $Handler->MySQL('EscapeArray', $_GET);
- $Profile = $Handler->getUserObjectByName($_GET['profile']);
- if (is_null($Profile)) $Handler->redirectToRoot();
- $Profile->Inventory = $Handler->getUserInventory($Profile->id);
- $FlashVars = $Handler->getUserFlashVars($Profile->id) . $Profile->Inventory['FlashVars'];
- $Stats = $Handler->calculateStats($Profile);
- $Handler->caching = false;
- $Handler->assign("AchievementList", $Handler->getUserAcheivements($Profile));
- $Handler->assign('ExpPercentage', $Stats['ExpPercentage']);
- $Handler->assign('ExpWidth', $Stats['ExpWidth']);
- $Handler->assign('CPPercentage', $Stats['CPPercentage']);
- $Handler->assign('CPWidth', $Stats['CPWidth']);
- $Handler->assign('FlashVariables', $FlashVars);
- $Handler->assign('ProfileData', $Profile);
- } else {
- $Dummy = new stdClass();
- $Dummy->Gold = 0;
- $Dummy->Coins = 0;
- $Dummy->KillCount = 0;
- $Dummy->DeathCount = 0;
- $Handler->assign('ExpPercentage', 0);
- $Handler->assign('ExpWidth', 0);
- $Handler->assign('CPPercentage', 0);
- $Handler->assign('CPWidth', 0);
- $Handler->assign('FlashVariables', null);
- $Handler->assign('ProfileData', $Dummy);
- $Facebook = new Facebook(array(
- 'appId' => Configuration::getPublic('FacebookAppId'),
- 'secret' => Configuration::getPublic('FacebookSecret'),
- ));
- $PageID = Configuration::getPublic('FacebookId');
- $Token = $Facebook->getAccessToken();
- $Data = json_decode(@file_get_contents("https://graph.facebook.com/{$PageID}/posts?access_token={$Token}"), true);
- foreach ($Data['data'] as $Post) {
- if (!array_key_exists('message', $Post) || !array_key_exists('created_time', $Post)) continue;
- if (!array_key_exists('link', $Post)) $Post['link'] = "https://facebook.com/{$Post['id']}";
- if ($Post['type'] == 'status' || $Post['type'] == 'link' || $Post['type'] == 'photo') {
- $Data = new stdClass();
- $Data->Date = strtotime($Post['created_time']);
- $Data->Title = 'Server Update: '. date("jS M, Y", (strtotime($Post['created_time'])));
- $Data->Content = $Post['type'] == 'status' ? $Post['message'] : ($Post['type'] == 'link' ? $Post['name'] : (empty($Post['story']) === false ? $Post['story'] : $Post['message']));
- $Data->Link = $Post['link'];
- if (count($NewsData->SlideOne) < 2) array_push($NewsData->SlideOne, $Data);
- else if (count($NewsData->SlideTwo) < 2) array_push($NewsData->SlideTwo, $Data);
- else break;
- }
- }
- }
- $Handler->assign('NewsData', $NewsData);
- $Handler->assign('Overview', $Handler->fetch("string: {include file='template.overview.html'}"));
- $Handler->assign('Content', $Handler->fetch(isset($_GET['profile']) ? "string: {include file='template.profile.html'}" : "string: {include file='template.homepage.html'}"));
- $Handler->display('template.default.html');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement