Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Simple Speedysnail6 Dashboard
- session_start();
- class config {
- //Database connection. Remember to upload the .sql file too!
- static $DB_SERVER = 'localhost';
- static $DB_NAME = 'yt_dash';
- static $DB_USERNAME = 'root';
- static $DB_PASSWORD = 'chris99';
- //Site URL and location
- static $DOMAIN = "azzura.yt";
- static $SITE_URL = 'http://suite.azzura.yt';
- static $SITE_DIR = '/var/www/suite.azzura.yt/public_html';
- //Branding Info
- static $WEBSITE_NAME = 'Azzura Dashboard';
- static $LOGO_FILE = 'img/logo.jpg';
- static $BETA = true;
- //Email options
- static $SEND_FROM = 'no_reply@azzura.yt';
- //Theme options
- static $MAIN_THEME = 'metro';
- static $THEME_DIR = '/var/www/suite.azzura.yt/public_html/themes/metro';
- static $THEME_URL = 'http://suite.azzura.yt/themes/metro';
- }
- //The main menu items
- $main_menu = array (
- array(
- "Name" => "dashboard",
- "Value" => "Dashboard",
- "URL" => config::$SITE_URL . "/",
- "PageName" => "main",
- "Icon" => "dashboard"
- ),
- array(
- "Name" => "analytics",
- "Value" => "Analytics",
- "URL" => config::$SITE_URL . "/analytics.php",
- "PageName" => "analytics",
- "Icon" => "bar-chart"
- ),
- array(
- "Name" => "request_art",
- "Value" => "Request Art",
- "URL" => config::$SITE_URL . "/request_art.php",
- "PageName" => "request_art",
- "Icon" => "pencil"
- ),
- ,
- array(
- "Name" => "sponsors",
- "Visibility" => "admin",
- "Value" => "Sponsors",
- "PageName" => "sponsors",
- "Icon" => "inbox",
- "Dropdown" => "true",
- "Values" => array(
- array(
- "Name" => "gameservers",
- "Value" => "Game Servers",
- "URL" => config::$SITE_URL . "/gameservers.php",
- "PageName" => "gameservers",
- "Icon" => "hdd"
- ),
- array(
- "Name" => "test2",
- "Value" => "test2",
- "URL" => config::$SITE_URL . "/test2.php",
- "PageName" => "test2",
- "Icon" => "picture"
- )
- )
- ),
- array(
- "Name" => "admin",
- "Visibility" => "admin",
- "Value" => "Admin Zone",
- "URL" => config::$SITE_URL . "/admin.php",
- "PageName" => "admin",
- "Icon" => "lock"
- ),
- array(
- "Name" => "gfx_zone",
- "Visibility" => "gfx_artist",
- "Value" => "GFX Zone",
- "URL" => config::$SITE_URL . "/gfx_zone.php",
- "PageName" => "gfx_zone",
- "Icon" => "picture"
- )
- );
- //Connects to the database
- if(!$dbh = new PDO('mysql:host='. config::$DB_SERVER .';dbname='. config::$DB_NAME .';charset=utf8', config::$DB_USERNAME, config::$DB_PASSWORD)) {
- echo "error";
- }
- require_once (config::$SITE_DIR . '/google_api/autoload.php');
- $client_id = '410161622023-4um9jeb5o9s61n5vtrcvtos0o950f1a2.apps.googleusercontent.com';
- $client_secret = 'cnf9Se5ejYcYqwlKsVw7hsxc';
- $redirect_uri = 'http://suite.azzura.yt/login.php';
- $key = 'AIzaSyC4fVDvh1u5zcUSbZ_h_eTA08wj9-kJnNA';
- $client = new Google_Client();
- $client->setClientId($client_id);
- $client->setClientSecret($client_secret);
- $client->setDeveloperKey($key);
- $client->setApprovalPrompt('force');
- $client->setRedirectUri($redirect_uri);
- $client->addScope("https://www.googleapis.com/auth/youtube");
- $client->addScope("https://www.googleapis.com/auth/yt-analytics.readonly");
- $client->addScope("https://www.googleapis.com/auth/youtubepartner");
- $client->addScope("https://www.googleapis.com/auth/yt-analytics-monetary.readonly");
- $client->setAccessType('offline');
- $yt_service = new Google_Service_YouTube($client);
- $yta_service = new Google_Service_YouTubeAnalytics($client);
- $url = $client->createAuthUrl();
- if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
- $client->setAccessToken($_SESSION['access_token']);
- }
- if ($client->getAccessToken()) {
- class user {
- function user() {
- global $yt_service;
- $data = $yt_service->channels->listChannels('snippet', array('mine' => 'true'));
- $username = $data['modelData']['items'][0]['snippet']['title'];
- $id = $data['modelData']['items'][0]['id'];
- $this->username = $username;
- $this->id = $id;
- global $dbh;
- foreach($dbh->query('SELECT Admin FROM users WHERE Username="'. $username . '"') as $row) {
- if ($row['Admin'] == 1) {
- $this->admin = true;
- $this->gfx_artist = false;
- $this->super_admin = false;
- }
- elseif ($row['Admin'] == 3) {
- $this->admin = true;
- $this->super_admin = true;
- $this->gfx_artist = true;
- }
- elseif ($row['Admin'] == 2) {
- $this->gfx_artist = true;
- $this->super_admin = false;
- $this->admin = false;
- }
- else {
- $this->admin = false;
- $this->super_admin = false;
- $this->gfx_artist = false;
- }
- }
- }
- }
- // create an object
- $user = new user();
- if ($client->isAccessTokenExpired()) {
- foreach($dbh->query('SELECT RefreshToken FROM users WHERE Username="'. $user->username . '"') as $row) {
- $client->refreshToken($row['RefreshToken']);
- $_SESSION['access_token']= $client->getAccessToken();
- }
- }
- }
- function logged_in_only() {
- global $url;
- if(!isset($_SESSION['dash_logged_in'])) {
- header("LOCATION:" .config::$SITE_URL . "/log_in.php");
- }
- if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
- $redirect = config::$SITE_URL . '/unverified.php';
- $_SESSION['verified'] = false;
- header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
- }
- }
- function admin_only() {
- global $url;
- global $user;
- if(!isset($_SESSION['dash_logged_in'])) {
- header("LOCATION: $url");
- }
- if($user->admin == false) {
- header("LOCATION:" . config::$SITE_URL . "?admin=0");
- }
- if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
- $redirect = config::$SITE_URL . '/unverified.php';
- $_SESSION['verified'] = false;
- header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
- }
- }
- function gfx_artist_only() {
- global $url;
- global $user;
- if(!isset($_SESSION['dash_logged_in'])) {
- header("LOCATION: $url");
- }
- if($user->gfx_artist == false) {
- header("LOCATION:" . config::$SITE_URL . "?admin=0");
- }
- if(isset($_SESSION['verified']) and $_SESSION['verified'] == false) {
- $redirect = config::$SITE_URL . '/unverified.php';
- $_SESSION['verified'] = false;
- header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement