Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. <?php
  2. //Simple Speedysnail6 Dashboard
  3. session_start();
  4.  
  5. class config {
  6.  
  7. //Database connection. Remember to upload the .sql file too!
  8. static $DB_SERVER = 'localhost';
  9. static $DB_NAME = 'yt_dash';
  10. static $DB_USERNAME = 'root';
  11. static $DB_PASSWORD = 'chris99';
  12.  
  13. //Site URL and location
  14. static $DOMAIN = "azzura.yt";
  15. static $SITE_URL = 'http://suite.azzura.yt';
  16. static $SITE_DIR = '/var/www/suite.azzura.yt/public_html';
  17.  
  18. //Branding Info
  19. static $WEBSITE_NAME = 'Azzura Dashboard';
  20. static $LOGO_FILE = 'img/logo.jpg';
  21. static $BETA = true;
  22.  
  23. //Email options
  24. static $SEND_FROM = 'no_reply@azzura.yt';
  25.  
  26. //Theme options
  27. static $MAIN_THEME = 'metro';
  28. static $THEME_DIR = '/var/www/suite.azzura.yt/public_html/themes/metro';
  29. static $THEME_URL = 'http://suite.azzura.yt/themes/metro';
  30.  
  31. }
  32.  
  33. //The main menu items
  34. $main_menu = array (
  35. array(
  36. "Name" => "dashboard",
  37. "Value" => "Dashboard",
  38. "URL" => config::$SITE_URL . "/",
  39. "PageName" => "main",
  40. "Icon" => "dashboard"
  41. ),
  42. array(
  43. "Name" => "analytics",
  44. "Value" => "Analytics",
  45. "URL" => config::$SITE_URL . "/analytics.php",
  46. "PageName" => "analytics",
  47. "Icon" => "bar-chart"
  48. ),
  49. array(
  50. "Name" => "request_art",
  51. "Value" => "Request Art",
  52. "URL" => config::$SITE_URL . "/request_art.php",
  53. "PageName" => "request_art",
  54. "Icon" => "pencil"
  55. ),
  56. ,
  57. array(
  58. "Name" => "sponsors",
  59. "Visibility" => "admin",
  60. "Value" => "Sponsors",
  61. "PageName" => "sponsors",
  62. "Icon" => "inbox",
  63. "Dropdown" => "true",
  64. "Values" => array(
  65. array(
  66. "Name" => "gameservers",
  67. "Value" => "Game Servers",
  68. "URL" => config::$SITE_URL . "/gameservers.php",
  69. "PageName" => "gameservers",
  70. "Icon" => "hdd"
  71. ),
  72. array(
  73. "Name" => "test2",
  74. "Value" => "test2",
  75. "URL" => config::$SITE_URL . "/test2.php",
  76. "PageName" => "test2",
  77. "Icon" => "picture"
  78. )
  79. )
  80. ),
  81. array(
  82. "Name" => "admin",
  83. "Visibility" => "admin",
  84. "Value" => "Admin Zone",
  85. "URL" => config::$SITE_URL . "/admin.php",
  86. "PageName" => "admin",
  87. "Icon" => "lock"
  88. ),
  89. array(
  90. "Name" => "gfx_zone",
  91. "Visibility" => "gfx_artist",
  92. "Value" => "GFX Zone",
  93. "URL" => config::$SITE_URL . "/gfx_zone.php",
  94. "PageName" => "gfx_zone",
  95. "Icon" => "picture"
  96. )
  97. );
  98.  
  99.  
  100. //Connects to the database
  101. if(!$dbh = new PDO('mysql:host='. config::$DB_SERVER .';dbname='. config::$DB_NAME .';charset=utf8', config::$DB_USERNAME, config::$DB_PASSWORD)) {
  102. echo "error";
  103. }
  104.  
  105. require_once (config::$SITE_DIR . '/google_api/autoload.php');
  106.  
  107.  
  108. $client_id = '410161622023-4um9jeb5o9s61n5vtrcvtos0o950f1a2.apps.googleusercontent.com';
  109. $client_secret = 'cnf9Se5ejYcYqwlKsVw7hsxc';
  110. $redirect_uri = 'http://suite.azzura.yt/login.php';
  111. $key = 'AIzaSyC4fVDvh1u5zcUSbZ_h_eTA08wj9-kJnNA';
  112.  
  113. $client = new Google_Client();
  114. $client->setClientId($client_id);
  115. $client->setClientSecret($client_secret);
  116. $client->setDeveloperKey($key);
  117. $client->setApprovalPrompt('force');
  118. $client->setRedirectUri($redirect_uri);
  119. $client->addScope("https://www.googleapis.com/auth/youtube");
  120. $client->addScope("https://www.googleapis.com/auth/yt-analytics.readonly");
  121. $client->addScope("https://www.googleapis.com/auth/youtubepartner");
  122. $client->addScope("https://www.googleapis.com/auth/yt-analytics-monetary.readonly");
  123. $client->setAccessType('offline');
  124.  
  125. $yt_service = new Google_Service_YouTube($client);
  126. $yta_service = new Google_Service_YouTubeAnalytics($client);
  127. $url = $client->createAuthUrl();
  128.  
  129. if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  130. $client->setAccessToken($_SESSION['access_token']);
  131. }
  132.  
  133. if ($client->getAccessToken()) {
  134. class user {
  135. function user() {
  136. global $yt_service;
  137. $data = $yt_service->channels->listChannels('snippet', array('mine' => 'true'));
  138. $username = $data['modelData']['items'][0]['snippet']['title'];
  139. $id = $data['modelData']['items'][0]['id'];
  140. $this->username = $username;
  141. $this->id = $id;
  142. global $dbh;
  143. foreach($dbh->query('SELECT Admin FROM users WHERE Username="'. $username . '"') as $row) {
  144. if ($row['Admin'] == 1) {
  145. $this->admin = true;
  146. $this->gfx_artist = false;
  147. $this->super_admin = false;
  148. }
  149. elseif ($row['Admin'] == 3) {
  150. $this->admin = true;
  151. $this->super_admin = true;
  152. $this->gfx_artist = true;
  153. }
  154. elseif ($row['Admin'] == 2) {
  155. $this->gfx_artist = true;
  156. $this->super_admin = false;
  157. $this->admin = false;
  158. }
  159. else {
  160. $this->admin = false;
  161. $this->super_admin = false;
  162. $this->gfx_artist = false;
  163. }
  164. }
  165. }
  166. }
  167.  
  168. // create an object
  169. $user = new user();
  170.  
  171. if ($client->isAccessTokenExpired()) {
  172. foreach($dbh->query('SELECT RefreshToken FROM users WHERE Username="'. $user->username . '"') as $row) {
  173. $client->refreshToken($row['RefreshToken']);
  174. $_SESSION['access_token']= $client->getAccessToken();
  175. }
  176. }
  177. }
  178.  
  179. function logged_in_only() {
  180. global $url;
  181. if(!isset($_SESSION['dash_logged_in'])) {
  182. header("LOCATION:" .config::$SITE_URL . "/log_in.php");
  183. }
  184. if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
  185. $redirect = config::$SITE_URL . '/unverified.php';
  186. $_SESSION['verified'] = false;
  187. header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
  188. }
  189. }
  190.  
  191. function admin_only() {
  192. global $url;
  193. global $user;
  194. if(!isset($_SESSION['dash_logged_in'])) {
  195. header("LOCATION: $url");
  196. }
  197. if($user->admin == false) {
  198. header("LOCATION:" . config::$SITE_URL . "?admin=0");
  199. }
  200. if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
  201. $redirect = config::$SITE_URL . '/unverified.php';
  202. $_SESSION['verified'] = false;
  203. header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
  204. }
  205. }
  206.  
  207. function gfx_artist_only() {
  208. global $url;
  209. global $user;
  210. if(!isset($_SESSION['dash_logged_in'])) {
  211. header("LOCATION: $url");
  212. }
  213. if($user->gfx_artist == false) {
  214. header("LOCATION:" . config::$SITE_URL . "?admin=0");
  215. }
  216. if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
  217. $redirect = config::$SITE_URL . '/unverified.php';
  218. $_SESSION['verified'] = false;
  219. header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
  220. }
  221. }
  222.  
  223. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement