<?php
    ob_start();
    	if(!defined('panel'))
    	die('Nope.');
    ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta charset="utf-8" />
        <!--<title><?php echo Config::$_SITE_NAME; ?> - User Panel</title>-->
        <meta name="description" content="overview &amp; stats" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <!-- bootstrap & fontawesome -->
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/bootstrap.min.css" />
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/bootstrap-responsive.min.css" />
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/font-awesome.min.css" />
        <!-- page specific plugin styles -->
        <!-- text fonts -->
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />
        <!-- ace styles -->
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
        <!--[if lte IE 9]>
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/ace-part2.min.css" class="ace-main-stylesheet" />
        <![endif]-->
        <!--[if lte IE 9]>
        <link rel="stylesheet" href="<?php echo Config::$_PAGE_URL; ?>assets/css/ace-ie.min.css" />
        <![endif]-->
        <!-- inline styles related to this page -->
        <!-- ace settings handler -->
        <script src="<?php echo Config::$_PAGE_URL; ?>assets/js/ace-extra.min.js"></script>
        <!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->
        <!--[if lte IE 8]>
        <script src="<?php echo Config::$_PAGE_URL; ?>assets/js/html5shiv.min.js"></script>
        <script src="<?php echo Config::$_PAGE_URL; ?>assets/js/respond.min.js"></script>
        <![endif]-->
    </head>
    <body class="no-skin">
        <div id="navbar" class="navbar navbar-default" style="background: 
            <?php if(Config::$_SITE_COLOR == 1) { ?>
            #e14d4d;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 2) { ?>
            #429b3d;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 3) { ?>
            #62a8d1;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 4) { ?>
            #b94de1;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 5) { ?>
            #e14da6;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 6) { ?>
            #5f5f5f;
            <?php } ?>
            <?php if(Config::$_SITE_COLOR == 7) { ?>
            #000000;
            <?php } ?>
            ">
            <!-- COLOR CHOOSED -->
            <script type="text/javascript">
                try{ace.settings.check('navbar' , 'fixed')}catch(e){}
            </script>
            <div class="navbar-container" id="navbar-container">
                <button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
                <span class="sr-only">Toggle sidebar</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                </button>
                <div class="navbar-header pull-left">
                    <a href="<?php echo Config::$_PAGE_URL; ?>" class="navbar-brand">
                    <font color="red">
                    <small>
                    <i class="fa fa-rocket"></i></font>
                    <?php echo Config::$_SITE_NAME; ?>
                    </small>
                    </a>
                </div>
                <div class="navbar-buttons navbar-header pull-right" role="navigation">
                    <ul class="nav ace-nav">
                        <?php 
                            if(isset($_SESSION['user'])) {
                            ?>
                        <?php 
                            if(isset(Config::$_url[1])) $user = (int)Config::$_url[1];
                            else $user = $_SESSION['user'];
                            $q = Config::$g_con->prepare('SELECT * FROM `users` WHERE `id` = ?');
                            $q->execute(array($user));
                            $data = $q->fetch(PDO::FETCH_OBJ);
                            
                            ?>
                        <li class="purple">
                            <?php
                                $id = Config::getData('users','id',$_SESSION['user']);
                                $q = Config::$g_con->prepare('SELECT * FROM `emails` WHERE `playerid` = ? AND `EmailRead` = 1');
                                $q->execute(array($id));
                                if($q->rowCount()!=0) {
                                ?>	
                            <script>
                                function myFunction() {
                                    var str = document.getElementById("demo").innerHTML; 
                                    var res = str.replace("<?php  echo $q->rowCount();?>", "0<?php $q = Config::$g_con->prepare("UPDATE emails SET EmailRead = 0 WHERE playerid = ?"); $q->execute(array(Config::getData("users","id",$_SESSION['user'])));?>");
                                    document.getElementById("demo").innerHTML = res;
                                }
                            </script>								
                            <a data-toggle="dropdown" onclick="myFunction()" class="dropdown-toggle" href="#">
                            <i class="ace-icon fa fa-bell icon-animated-bell"></i>
                            <span class='badge badge-important' id='demo'><?php  echo $q->rowCount();?></span>
                            </a>						
                            <?php } else { ?>
                            <?php 
                                $id = Config::getData('users','id',$_SESSION['user']);
                                $q = Config::$g_con->prepare('SELECT * FROM `emails` WHERE `playerid` = ?');
                                $q->execute(array($id));											
                                 ?>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <i class="ace-icon fa fa-bell menu-icon fa fa-animated-bell"></i>					
                            <span class="badge badge-grey">0</span>
                            </a>											
                            <?php  } ?>
                            <ul class="dropdown-menu-right dropdown-navbar navbar-pink dropdown-menu dropdown-caret dropdown-close">
                                <!--<li class="dropdown-header">						
                                    <i class="ace-icon fa fa-exclamation-triangle"></i>
                                    <?php // echo $q->rowCount();?> Notifications
                                    </li>-->
                                <?php 
                                    $q = Config::$g_con->prepare('SELECT * FROM `emails` WHERE `playerid` = ? ORDER BY `id` DESC LIMIT 5'); 
                                    $row = $q->execute(array($id)); while($row = $q->fetch(PDO::FETCH_OBJ)) {
                                    ?>		
                                <li class="dropdown-content">
                                    <ul class="dropdown-menu dropdown-navbar navbar-pink">
                                        <li>
                                            <?php if(!$row->LinkPanel == "") { ?>
                                            <a href="<?php echo Config::$_PAGE_URL; ?><?php echo $row->LinkPanel; ?>">
                                            <?php } else { ?>
                                            <a href="<?php echo Config::$_PAGE_URL; ?>notifications">
                                                <?php } ?>
                                                <div class="clearfix">
                                                    <span class="pull-left">
                                                    <i class="btn btn-xs no-hover btn-grey fa fa-comment"></i>
                                                    <?php  echo $row->Message; ?>
                                                    </span>
                                                </div>
                                            </a>
                                        </li>
                                    </ul>
                                </li>
                                <?php  } ?>
                                <li class="dropdown-footer">
                                    <a href="<?php echo Config::$_PAGE_URL; ?>notifications">
                                    See all notifications
                                    <i class="ace-icon fa fa-arrow-right"></i>
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li style="background: <?php if(Config::$_SITE_COLOR == 1) { ?>
                            #e14d4d;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 2) { ?>
                            #429b3d;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 3) { ?>
                            #62a8d1;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 4) { ?>
                            #b94de1;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 5) { ?>
                            #e14da6;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 6) { ?>
                            #5f5f5f;
                            <?php } ?>
							<?php if(Config::$_SITE_COLOR == 7) { ?>
				            #000000;
				            <?php } ?>
				            ">
                            <a data-toggle="dropdown" href="#" class="dropdown-toggle" style="background:#000000">
                            <img class="nav-user-photo" src="<?php echo Config::$_PAGE_URL; ?>assets/images/avatars/<?php echo Config::getData('users','Model',$_SESSION['user']); ?>.png" astyle="height: 34px;" alt="Avatar" />
                            <span class="user-info">
                            <small>Welcome,</small>
                            <?php echo Config::getData('users','name',$_SESSION['user']); ?>
                            </span>
                            <i class="ace-icon fa fa-caret-down"></i>
                            </a>
                            <ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                                <li>
                                    <a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$_SESSION['user']); ?>">
                                    <i class="ace-icon fa fa-user"></i>
                                    Profilul meu
                                    </a>
                                </li>
                                <li>
                                    <a href="<?php echo Config::$_PAGE_URL; ?>changemail">
                                    <i class="ace-icon fa fa-envelope"></i>
                                    Schimba email
                                    </a>
                                </li>
                                <li>
                                    <a href="<?php echo Config::$_PAGE_URL; ?>mycomplaints">
                                    <i class="ace-icon fa fa-legal"></i>
                                    Reclamatii create de mine
                                    </a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a href="<?php echo Config::$_PAGE_URL; ?>logout">
                                    <i class="ace-icon fa fa-power-off"></i>
                                    Deconectare
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <?php } else { ?>
                        <li style="background: <?php if(Config::$_SITE_COLOR == 1) { ?>
                            #e14d4d;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 2) { ?>
                            #429b3d;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 3) { ?>
                            #62a8d1;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 4) { ?>
                            #b94de1;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 5) { ?>
                            #e14da6;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 6) { ?>
                            #5f5f5f;
                            <?php } ?>
                            <?php if(Config::$_SITE_COLOR == 7) { ?>
				            #000000;
				            <?php } ?>
				            ">
                            <a href="<?php echo Config::$_PAGE_URL; ?>login" style="background: <?php if(Config::$_SITE_COLOR == 1) { ?>
                                #e14d4d;
                                <?php } ?>
                                <?php if(Config::$_SITE_COLOR == 2) { ?>
                                #429b3d;
                                <?php } ?>
                                <?php if(Config::$_SITE_COLOR == 3) { ?>
                                #62a8d1;
                                <?php } ?>
                                <?php if(Config::$_SITE_COLOR == 4) { ?>
                                #b94de1;
                                <?php } ?>
                                <?php if(Config::$_SITE_COLOR == 5) { ?>
                                #e14da6;
                                <?php } ?>
                                <?php if(Config::$_SITE_COLOR == 6) { ?>
                                #5f5f5f;
                                <?php } ?>
								<?php if(Config::$_SITE_COLOR == 7) { ?>
					            #000000;
					            <?php } ?>
					            ">Login</a>
                        </li>
                        <?php } ?>
                    </ul>
                </div>
            </div>
            <!-- /.navbar-container -->
        </div>
        <div class="main-container" id="main-container">
        <script type="text/javascript">
            try{ace.settings.check('main-container' , 'fixed')}catch(e){}
        </script>
        <div id="sidebar" class="sidebar                  responsive">
        <script type="text/javascript">
            try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
        </script>
        <?php
            $q = Config::$g_con->prepare('SELECT `Status` FROM `users` WHERE `Admin` > 0 OR `Helper` > 0');
            $q->execute();
            $online_ = 0; $online = 0; $ponline = 0;
            while($row = $q->fetch()) if($row['Status']) $online_++;
            $staff_online = $online_ . ' / ' . $q->rowCount();
            $q = Config::$g_con->prepare('SELECT * FROM `users` WHERE `Status` = 1');
            $q->execute();
            while($row = $q->fetch()) if($row['Status']) $ponline++;
            $online = $ponline ;
            // $server = @new Server(Config::$_IP);
            // $online = @$server->get('users') . ' / ' . @$server->get('maxplayers');
            ?>
        <ul class="nav nav-list">
            <li<?php echo Config::isActive(''); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>">
                <i class="menu-icon icon-dashboard blue"></i>
                <span class="menu-text"> Home </span>
                </a>
                <b class="arrow"></b>
            </li>
            <?php if(isset($_SESSION['user']) && Config::getData('users','Admin',$_SESSION['user']) >= 4) { ?>
            <li<?php echo Config::isActive('adminpanel'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>adminpanel">
                <i class="menu-icon fa fa-sitemap orange"></i>
                <span class="menu-text"> Admin Panel </span>
                </a>
            </li>
            <?php } if(isset($_SESSION['user']) && Config::getData('users','Leader',$_SESSION['user']) != 0) { ?>
            <li<?php echo Config::isActive('leader'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>leader">
                <i class="menu-icon fa fa-angle-double-right orange"></i>
                <span class="menu-text"> Leader Panel </span>
                </a>
            </li>
            <?php }
                if(isset($_SESSION['user'])) { ?>
            <li<?php if(!isset(Config::$_url[1])) echo Config::isActive('profile'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>profile/<?php echo Config::getData('users','id',$_SESSION['user']); ?>">
                <i class="menu-icon icon-smile green"></i>
                <span class="menu-text"> Profilul meu </span>
                </a>
            </li>
            <?php
                }
                ?>
            <li<?php echo Config::isActive('online'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>online">
                <i class="menu-icon fa fa-user red"></i>
                <?php
					$qs = Config::$g_con->prepare("SELECT * FROM `users` WHERE `Status` > 0");
					$qs->execute();
					$total2 = $qs->rowCount();
				?>
                <span class="menu-text"> Playeri conectati </span>
                </a>
            </li>
            <li<?php echo Config::isActive('staff'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>staff">
                <i class="menu-icon fa fa-android orange"></i>
                <span class="menu-text"> Staff 
                <span class="badge badge-yellow"><?php echo $staff_online; ?></span></span>
                </a>
            </li>
            <li<?php if(Config::$_url[0] === 'profile/' && isset(Config::$_url[1])) echo ' class="active"'; echo Config::isActive('search'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>search">
                <i class="menu-icon fa fa-search blue"></i>
                <span class="menu-text"> Cauta un jucator </span>
                </a>
            </li>
            <li<?php if(Config::$_url[0] === 'profile/' && isset(Config::$_url[1])) echo ' class="active"'; echo Config::isActive('faq'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>faq">
                <i class="menu-icon fa fa-question purple"></i>
                <span class="menu-text"> F.A.Q </span>
                </a>
            </li>
            <?php 
                $q = Config::$g_con->prepare("SELECT * FROM `complaints` WHERE `status` = 0 AND `factionid` = 0");
                $q->execute();
                ?>
            <li<?php echo Config::isActive(array('complaints','complaint','createcomplaint')); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>complaints">
                <i class="menu-icon fa fa-legal red"></i>
                <span class="menu-text"> Reclamatii </span>
                <span class="badge badge-yellow"><?php echo $q->rowCount() ?></span>
                </a>
            </li>
            <li<?php echo Config::isActive(array('tickets','ticket','ticketpay','ticketgeneral')); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>tickets">
                <i class="menu-icon fa fa-ticket red"></i>
                <span class="menu-text"> Tichete ajutor </span>
                </a>
            </li>
            <?php 
                $q = Config::$g_con->prepare("SELECT * FROM `unban_requests` WHERE `status` = 0");
                $q->execute();
                ?>
            <li<?php if(Config::$_url[0] === 'unban' && isset(Config::$_url[1])) echo ' class="active"'; echo Config::isActive('unban'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>unban">
                <i class="menu-icon fa fa-tasks red"></i>
                <span class="menu-text"> Cereri debanare 
                <span class="badge badge-yellow"><?php echo $q->rowCount(); ?></span></span>
                </a>
            </li>
            <li<?php echo Config::isActive('banlist'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>banlist">
                <i class="menu-icon icon-frown black"></i>
                <span class="menu-text"> Ban-uri </span>
                </a>
            </li>
            <li<?php echo Config::isActive(array('premium','paysafecard')); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>premium">
                <i class="menu-icon fa fa-certificate red"></i>
                <span class="menu-text"> Premium </span>
                </a>
            </li>
            <?php 
                $qf = Config::$g_con->prepare("SELECT * FROM `factions` WHERE `MinLevel` > 0");
                $qf->execute();
                ?>		
            <li<?php echo Config::isActive(array('factionslist','members','skins','logs','viewapplication','apply','wipemfactions','applications')); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>factionslist">
                <i class="menu-icon fa fa-group blue"></i>
                <span class="menu-text"> Factiuni </span>
                <span class="badge badge-yellow"><?php echo $qf->rowCount(); ?></span>
                </a>
            </li>
            <li<?php echo Config::isActive('clan'); ?>>
                <a href="<?php echo Config::$_PAGE_URL; ?>clan">
                <i class="menu-icon fa fa-sitemap blue"></i>
                <span class="menu-text"> Clanuri </span>
                </a>
            </li>
            <li<?php echo Config::isActive(array('top','vehicles','houses','businesses','war','wars','jobs','ptop','racetop')); ?>>
                <a href="#" class="dropdown-toggle">
                <i class="menu-icon fa fa-signal red"></i>
                <span class="menu-text"> Statistici </span>
                <b class="arrow menu-icon fa fa-angle-down"></b>
                </a>
                <ul class="submenu">
                    <li<?php echo Config::isActive('top'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>top">
                        <i class="fa fa-globe red"></i>
                        <span class="menu-text"> Top Jucatori </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('houses'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>houses">
                        <i class="fa fa-home red"></i>
                        <span class="menu-text"> Case </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('businesses'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>businesses">
                        <i class="fa fa-beer red"></i>
                        <span class="menu-text"> Afaceri </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('vehicles'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>vehicles">
                        <i class="fa fa-truck red"></i>
                        <span class="menu-text"> Vehicule Personale </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive(array('war','wars')); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>wars">
                        <i class="fa fa-fire red"></i>
                        <span class="menu-text"> War-uri </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('jobs'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>jobs">
                        <i class="icon-legal red"></i>
                        <span class="menu-text"> Job-uri </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('ptop'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>ptop">
                        <i class="fa fa-gamepad red"></i>
                        <span class="menu-text"> PaintBall </span>
                        </a>
                    </li>
                    <li<?php echo Config::isActive('racetop'); ?>>
                        <a href="<?php echo Config::$_PAGE_URL; ?>racetop">
                        <i class="fa fa-flag-checkered red"></i>
                        <span class="menu-text"> Race Arena </span>
                        </a>
                    </li>
                </ul>
            </li>
        </ul>
        <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
            <i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
        </div>
        <script type="text/javascript">
            try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
        </script>
