Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. <?php
  2. require_once 'config.php';
  3. require_once 'classes/class.smarty/Smarty.class.php';
  4. require_once 'classes/class.content.php';
  5. require_once 'classes/class.gamehandler.php';
  6. require_once 'classes/facebook.php';
  7.  
  8. $Handler = new Handler();
  9. $NewsData = new stdClass();
  10. $NewsData->SlideOne = array();
  11. $NewsData->SlideTwo = array();
  12.  
  13. if (isset($_POST['txtUsername']) AND isset($_POST['txtPassword'])) {
  14. $_POST = $Handler->MySQL('EscapeArray', $_POST);
  15. $Authenticate = $Handler->AuthenticateUser($_POST['txtUsername'], $_POST['txtPassword'], $_POST['remember'] === 'true');
  16. if (!$Authenticate) $Handler->plain(json_encode(array('output' => 'failure')));
  17. $Result = array('output' => 'success',
  18. 'root' => Configuration::getPublic('RootPath'),
  19. 'info' => $Handler->UserData->FlashVars,
  20. 'name' => $Handler->UserData->Name,
  21. 'Gold' => $Handler->UserData->Gold,
  22. 'Coins' => $Handler->UserData->Coins,
  23. 'Kills' => $Handler->UserData->KillCount,
  24. 'Deaths' => $Handler->UserData->DeathCount);
  25. $Handler->plain(json_encode(array_merge($Result, $Handler->calculateStats())));
  26. } else if (isset($_GET['profile'])) {
  27. if (empty($_GET['profile'])) $Handler->redirectToRoot();
  28. $_GET = $Handler->MySQL('EscapeArray', $_GET);
  29. $Profile = $Handler->getUserObjectByName($_GET['profile']);
  30. if (is_null($Profile)) $Handler->redirectToRoot();
  31. $Profile->Inventory = $Handler->getUserInventory($Profile->id);
  32. $FlashVars = $Handler->getUserFlashVars($Profile->id) . $Profile->Inventory['FlashVars'];
  33. $Stats = $Handler->calculateStats($Profile);
  34.  
  35. $Handler->caching = false;
  36. $Handler->assign("AchievementList", $Handler->getUserAcheivements($Profile));
  37. $Handler->assign('ExpPercentage', $Stats['ExpPercentage']);
  38. $Handler->assign('ExpWidth', $Stats['ExpWidth']);
  39. $Handler->assign('CPPercentage', $Stats['CPPercentage']);
  40. $Handler->assign('CPWidth', $Stats['CPWidth']);
  41. $Handler->assign('FlashVariables', $FlashVars);
  42. $Handler->assign('ProfileData', $Profile);
  43. } else {
  44. $Dummy = new stdClass();
  45. $Dummy->Gold = 0;
  46. $Dummy->Coins = 0;
  47. $Dummy->KillCount = 0;
  48. $Dummy->DeathCount = 0;
  49.  
  50. $Handler->assign('ExpPercentage', 0);
  51. $Handler->assign('ExpWidth', 0);
  52. $Handler->assign('CPPercentage', 0);
  53. $Handler->assign('CPWidth', 0);
  54. $Handler->assign('FlashVariables', null);
  55. $Handler->assign('ProfileData', $Dummy);
  56.  
  57. $Facebook = new Facebook(array(
  58. 'appId' => Configuration::getPublic('FacebookAppId'),
  59. 'secret' => Configuration::getPublic('FacebookSecret'),
  60. ));
  61.  
  62. $PageID = Configuration::getPublic('FacebookId');
  63. $Token = $Facebook->getAccessToken();
  64. $Data = json_decode(@file_get_contents("https://graph.facebook.com/{$PageID}/posts?access_token={$Token}"), true);
  65.  
  66. foreach ($Data['data'] as $Post) {
  67. if (!array_key_exists('message', $Post) || !array_key_exists('created_time', $Post)) continue;
  68. if (!array_key_exists('link', $Post)) $Post['link'] = "https://facebook.com/{$Post['id']}";
  69. if ($Post['type'] == 'status' || $Post['type'] == 'link' || $Post['type'] == 'photo') {
  70. $Data = new stdClass();
  71. $Data->Date = strtotime($Post['created_time']);
  72. $Data->Title = 'Server Update: '. date("jS M, Y", (strtotime($Post['created_time'])));
  73. $Data->Content = $Post['type'] == 'status' ? $Post['message'] : ($Post['type'] == 'link' ? $Post['name'] : (empty($Post['story']) === false ? $Post['story'] : $Post['message']));
  74. $Data->Link = $Post['link'];
  75.  
  76. if (count($NewsData->SlideOne) < 2) array_push($NewsData->SlideOne, $Data);
  77. else if (count($NewsData->SlideTwo) < 2) array_push($NewsData->SlideTwo, $Data);
  78. else break;
  79. }
  80. }
  81. }
  82.  
  83. $Handler->assign('NewsData', $NewsData);
  84. $Handler->assign('Overview', $Handler->fetch("string: {include file='template.overview.html'}"));
  85. $Handler->assign('Content', $Handler->fetch(isset($_GET['profile']) ? "string: {include file='template.profile.html'}" : "string: {include file='template.homepage.html'}"));
  86. $Handler->display('template.default.html');
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement