

<?php
    if(!defined('panel'))
    	die('Nope.');

    ?>
<?php
    $registered = Config::rows('users');
    $houses = Config::rows('houses');
    $cars = Config::rows('cars');
    $businesses = Config::rows('bizz');

    if(isset($_POST['addninfo']) && Config::getData('users','Admin',$_SESSION['user']) >= 6) {
    	$q = Config::$g_con->prepare('INSERT INTO `updates` (`text`, `byAdmin`, `For`) VALUES (?, ?, ?)');
    	$q->execute(array($_POST['ninfo'],Config::getData('users','name',$_SESSION['user']),1));
    }
    if(isset($_POST['addsupdate']) && Config::getData('users','Admin',$_SESSION['user']) >= 6) {
    	$q = Config::$g_con->prepare('INSERT INTO `updates` (`text`, `byAdmin`, `For`) VALUES (?, ?, ?)');
    	$q->execute(array($_POST['supdate'],Config::getData('users','name',$_SESSION['user']),0));
    }
    ?>
</div>
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
    </script>
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-home home-icon"></i>
            <a href="<?php echo Config::$_PAGE_URL; ?>">Home</a>
        </li>
        <li class="active">Homepage</li>
    </ul>
    <!-- /.breadcrumb -->
    <div class="nav-search" id="nav-search">
        <form method="POST" action="<?php echo Config::$_PAGE_URL; ?>search">
            <span class="input-icon">
            <input type="text" placeholder="Search ..." name="sname" id="username" type="submit" class="nav-search-input" autocomplete="on">
            <i class="ace-icon fa fa-search nav-search-icon"></i>
            </span>
        </form>
    </div>
    <!-- /.nav-search -->
</div>
<div class="page-content">
<div class="row-fluid">
<div class="span12">
<div class="span8">
    <title><?php echo Config::$_SITE_NAME; ?> - User Panel</title>
    <?php
        if(isset($_SESSION['user'])) {
        	$q = Config::$g_con->prepare("SELECT * FROM `bans` WHERE `PlayerName`=:name AND `Active` = 1");
        	$q->execute(array(":name" => Config::getData('users', 'name', $_SESSION['user'])));
        	while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>   
        <div class="alert alert-danger">
            <b>Contul tau este banat!</b><br/><br/>
            Banat de: <b><?php echo $row->AdminName ?></b> pe data de <b><?php echo $row->BanTimeDate ?></b>, motivul banului: <b><?php echo $row->Reason ?></b>.<br/>
            <?php if($row->Days == 0) { ?>Contul este banat permanent, ban-ul nu va expira.<?php } else {?>Ban-ul expira la <?php echo $row->Days ?> zile de la data pe care ai fost banat, insa trebuie sa incerci sa te conectezi pe joc. <?php } ?>
            Poti plati puncte premium pentru unban, mai jos vei avea variantele de calculare a platii:</br>
            <u>ban temporar</u>
            <li>pentru ban temporar plata unban-ului se face in functie de numarul de zile. (Metoda de calculare: <b>5 puncte premium * numarul de zile + 10 puncte premium</b>)</li>
            <br>
            <u>ban permanent</u>
            <li>pentru ban permanent plata unban-ului este de 100 puncte premium, se poate achizitiona doar daca in motivul banului nu se regasesc motivele "Reclama", "Flood", "Tentativa Flood" sau "Cheats". Tu ai <b><?php echo $data->PremiumPoints ?> puncte premium</b>.</li><br/>
            Daca ai suficiente puncte premium pentru a-ti plati banul, poti deschide o cerere unban <a href='<?php echo Config::$_PAGE_URL; ?>unban'><font color="blue">aici</font></a>.
            <br><br>Daca consideri ca ai fost sanctionat in mod gresit, poti crea o cerere de unban <a href='<?php echo Config::$_PAGE_URL; ?>unban'><font color="blue">aici</font></a><br>Daca ai folosit cheat-uri, nu te obosi sa faci cerere de unban. Cheaterii nu sunt debanati.<br>De asemenea, nu te obosi sa zici ca a fost altcineva pe contul tau. Tu trebuie sa ai grija de contul tau si tu esti responsabil de ceea ce se intampla cu contul tau.<br><br>Daca ai fost banat pentru autoclicker, asta inseamna ca ai folosit un program pentru a te tine online in joc sau ai pus un obiect pe o tasta pentru a face caracterul sa mearga in fata in joc. Majoritatea playerilor care fac cerere de unban pentru autoclicker nu sunt debanati.<br/><br/>
        </div>
        <?php } }
            if(isset($_SESSION['user']) && Config::getData('users','Email',$_SESSION['user']) == "email@yahoo.com") {	?>
        <div class="alert alert-block alert-info">
            <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
            </button>
            <p>
                <strong>
                <i class="icon-frown"></i>
                Seteaz&#259; adresa de Email
                <br>
                </strong>
                Nu ai o adres&#259; de email setat&#259; pe contul t&#259;u.<br>Setarea unei adrese de email te ajut&#259; &#238;n cazul &#238;n care &#238;&#355;i e spart contul.<br>F&#259;r&#259; o adres&#259; de email setat&#259;, nu &#238;&#355;i vei putea recupera contul dac&#259; acesta este spart.<br>Click pe butonul de mai jos pentru a seta o adres&#259; de email!
            </p>
            <p><a class="btn btn-sm btn-success" href="changemail">Seteaz&#259; adresa de Email</a></p>
        </div>
        <?php } ?>
    <div class="infobox-container">
        <?php
            $q = Config::$g_con->prepare("SELECT * FROM `users` WHERE `Status` > 0");
            $q->execute();
            ?>
        <div class="infobox infobox-blue">
            <div class="infobox-icon">
                <i class="fa fa-gamepad red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo $q->RowCount() ?></span>
                <div class="infobox-content"><a href="<?php echo Config::$_PAGE_URL; ?>online">jucatori conectati</a></div>
            </div>
        </div>
        <?php
            $q = Config::$g_con->prepare("SELECT * FROM `users` WHERE `OnlineToday` = 1");
            $q->execute();
            ?>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-info-circle red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo number_format($q->RowCount(),0,',',',') ?></span>
                <div class="infobox-content">conectati astazi</div>
            </div>
        </div>
        <?php
            $qlw = Config::$g_con->prepare("SELECT * FROM `users` WHERE `OnlineLastWeek` = 1");
            $qlw->execute();
            ?>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-info red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo number_format($qlw->RowCount(),0,',',',') ?></span>
                <div class="infobox-content">conectati sapt. trecuta</div>
            </div>
        </div>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-users red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo number_format($registered,0,',',',') ?></span>
                <div class="infobox-content">jucatori inregistrati</div>
            </div>
        </div>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-truck red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo number_format($cars,0,',',',') ?></span>
                <div class="infobox-content">vehicule personale</div>
            </div>
        </div>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-home red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo $houses; ?></span>
                <div class="infobox-content">case</div>
            </div>
        </div>
        <div class="infobox infobox-blue"">
            <div class="infobox-icon">
                <i class="fa fa-beer red" style="font-size:36px"></i>
            </div>
            <div class="infobox-data">
                <span class="infobox-data-number"><?php echo $businesses; ?></span>
                <div class="infobox-content">afaceri</div>
            </div>
        </div>
    </div>
    <br />
   	<?php if(isset($_SESSION['user']) && Config::getData('users','Admin',$_SESSION['user']) >= 1) {
        $q = Config::$g_con->prepare('SELECT * FROM `complaints` WHERE `playername` = ? AND `status` = 0');
        $q->execute(array($data->name));
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <h4 class="blue">
        <i class="icon-legal"></i>
        Complaints against you
    </h4>
    <table class="table table-striped table-condensed table-hover">
        <thead>
            <tr>
                <th>Title</th>
                <th><i class="fa fa-clock-o"></i> Date</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            <?php
                $q = Config::$g_con->prepare('SELECT * FROM `complaints` WHERE `playername` = ? AND `status` = 0 ORDER BY `id` DESC');
                $q->execute(array($data->name));
                while($row = $q->fetch(PDO::FETCH_OBJ)) {
                	if($row->reasoncomplaint == 1) {
                		$reason = "Factiune";
                	} else if($row->reasoncomplaint == 2) {
                		$reason = "DM";
                	} else if($row->reasoncomplaint == 3) {
                		$reason = "Jigniri, injurii, limbaj vulgar";
                	} else if($row->reasoncomplaint == 4) {
                		$reason = "Inselatorie";
                	} else if($row->reasoncomplaint == 5) {
                		$reason = "Altceva (abuz, comportament non RP)";
                	} else if($row->reasoncomplaint == 6) {
                		$reason = "Abuz admin/helper";
                	} else if($row->reasoncomplaint == 7) {
                		$reason = "Greseli ca lider";
                	}
                	echo
                	"<tr>
                		<td><a href='". Config::$_PAGE_URL ."complaint/". $row->id ."'>{$row->playername} - ". $reason ."</a></td>
                		<td>{$row->time}</td>
                		<td>" . ($row->status ? "Closed" : "Open") . "</td>
                	</tr>";
                }
                ?>
        </tbody>
    </table>
    <?php } ?>
    <div class="row-fluid">
        <div class="span6">
            <div class="widget-box ">
                <div class="widget-header widget-header-flat" style="background-color:#000000">
                    <h5>
                        <i class="icon-legal red"></i><font color="white"> Status reclamatii </font>
                    </h5>
                </div>
                <div class="widget-body"">
                    <div class="widget-main">
                        <div class="clearfix">
                            <div class="box-body box box-solid">
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `complaints` WHERE `status` = 0 AND `reasoncomplaint` = 3");
                                    $q->execute();	?>
                                <p>Reclamatii normale: <a href="<?php echo Config::$_PAGE_URL; ?>complaints"><?php echo $q->rowCount(); ?></a></p>
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `complaints` WHERE `status` = 0 AND `reasoncomplaint` = 4");
                                    $q->execute();	?>
                                <p>Reclamatii inselatorii: <a href="<?php echo Config::$_PAGE_URL; ?>complaints"><?php echo $q->rowCount(); ?></a></p>
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `complaints` WHERE `status` = 0 AND `reasoncomplaint` = 7");
                                    $q->execute();	?>
                                <p>Reclamatii lideri: <a href="<?php echo Config::$_PAGE_URL; ?>complaints"><?php echo $q->rowCount(); ?></a></p>
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `complaints` WHERE `status` = 0 AND `reasoncomplaint` = 6");
                                    $q->execute();	?>
                                <p>Reclamatii staff: <a href="<?php echo Config::$_PAGE_URL; ?>complaints"><?php echo $q->rowCount(); ?></a></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="span6">
            <div class="widget-box ">
                <div class="widget-header widget-header-flat" style="background-color:#000000">
                    <h5>
                        <i class="icon-ticket red"></i><font color="white"> Status tickete </font>
                    </h5>
                </div>
                <div class="widget-body"">
                    <div class="widget-main">
                        <div class="clearfix">
                            <div class="box-body box box-solid">
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `tickets` WHERE `status` = 0 AND `type` = 0");
                                    $q->execute();	?>
                                <p>General: <a href="<?php echo Config::$_PAGE_URL; ?>tickets"><?php echo $q->rowCount(); ?></a></p>
                                <?php
                                    $q = Config::$g_con->prepare("SELECT * FROM `tickets` WHERE `status` = 0 AND `type` = 1");
                                    $q->execute();	?>
                                <p>Donatii: <a href="<?php echo Config::$_PAGE_URL; ?>tickets"><?php echo $q->rowCount(); ?></a></p>
                                <hr />
                                <?php if(Config::getData('users','Admin',$_SESSION['user']) >= 6) {
                                    $q = Config::$g_con->prepare("SELECT * FROM `donations` WHERE `donateStatus` = 0");
                                    $q->execute();	?>
                                <p>Donatii in asteptare: <a href="<?php echo Config::$_PAGE_URL; ?>donations"><?php echo $q->rowCount(); ?></a></p>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>
    <div class="widget-box ">
        <div class="widget-header widget-header-flat" style="background-color:#000000">
            <h5>
                <i class="icon-rss red"></i><font color="white"> Ultimele actiuni </font>
            </h5>
        </div>
        <div class="widget-body"">
            <div class="widget-main no-padding">
                <div class="dialogs">
                    <?php
                        $q = Config::$g_con->prepare('SELECT * FROM `faction_logs` ORDER BY `id` DESC Limit 10');
                        $q->execute();
                        while($row = $q->fetch(PDO::FETCH_OBJ)) {

                        $value = $row->Text;
                        $tokens = explode(" ", $value);
                        //echo str_replace($tokens[0],"<a href='".Config::$_PAGE_URL."profile/".Config::getID('users','name',$tokens[0])."'>".$tokens[0]."</a>",$row->Text);

                        	$qr = Config::$g_con->prepare('SELECT `Model` FROM `users` WHERE `name` = ?');
                        	$qr->execute(array($tokens[0]));
                        ?>
                    <div class="itemdiv dialogdiv">
                        <div class="user">
                            <img src="<?php echo Config::$_PAGE_URL; ?>assets/images/avatars/<?php echo Config::getID("users","Model",$tokens[0]); ?>.png"/>
                        </div>
                        <div class="body" style="background-color:#FFFFFF">
                            <div class="time">
                                <i class="icon-time"></i>
                                <span class="green">
                                <?php echo $row->time; ?>
                                </span>
                            </div>
                            <div class="text">
                                <p>
                                    <?php
                                        echo str_replace($tokens[0],"<a href='".Config::$_PAGE_URL."profile/".Config::getID('users','id',$tokens[0])."'>".$tokens[0]."</a>",$row->Text);
                                        ?>
                            </div>
                        </div>
                    </div>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="col-sm-4">
    <div class="widget-box">
        <div class="widget-header widget-header-flat" style="background-color:#000000">
            <h5>
                <i class="fa fa-tags red"></i><font color="white"> Staff logs</font>
            </h5>
        </div>
        <div class="widget-body"">
            <div class="widget-main">
                <br />
                <div class="clearfix">
                    <?php
                        $q = Config::$g_con->prepare('SELECT * FROM `staff_logs` ORDER BY `ID` DESC Limit 10');
                        $q->execute();
                        while($row = $q->fetch(PDO::FETCH_OBJ)) {
                        ?>
                    <ul>
                    <li><?php echo $row->text ?></li></ul>
                    <?php } ?>
                </div>
            </div>
            <!--/widget-main-->
        </div>
        <!--/widget-body-->
    </div>
    <br />
    <div class="widget-box">
        <div class="widget-header widget-header-flat" style="background-color:#000000">
            <h5>
                <i class="fa fa-bell red"></i><font color="white"> Informatii server</font>
            </h5>
        </div>
        <div class="widget-body"">
            <div class="widget-main">
                <div class="clearfix">
                    <br />
                    <?php
                        $q = Config::$g_con->prepare('SELECT * FROM `updates` WHERE `For` = 1 ORDER BY `id` DESC Limit 1');
                        $q->execute();
                        while($row = $q->fetch(PDO::FETCH_OBJ)) {
                        ?>
                    <div class="box-body box box-solid">
                        <?php if(isset($_SESSION['user'])&& Config::getData('users','Admin',$_SESSION['user']) >= 6) { ?>
                        <form action="" method="POST">
                            <textarea name="ninfo" class="span12" rows="15"><?php echo $row->text ?></textarea>
                            <input type="submit" name="addninfo" value="Modifica" class="btn btn-success"/>
                        </form>
                        <?php } else { ?>
                        <?php echo $row->text ?>
                        <?php } ?>
                        <br><br>
                        Edited by <a href="http://wster-rpg.cf/panel/profile/<?php echo Config::getID('users','id',$row->byAdmin); ?>"><?php echo $row->byAdmin ?></a>, <span style="color:grey"><?php echo $row->time ?> </span>
                    </div>
                    <?php } ?>
                </div>
            </div>
            <!--/widget-main-->
        </div>
        <!--/widget-body-->
    </div>
    <br />
    <div class="widget-box">
        <div class="widget-header widget-header-flat" style="background-color:#000000">
            <h5>
                <i class="fa fa-gift red"></i><font color="white"> GiftBox Logs </font>
            </h5>
        </div>
        <div class="widget-body"">
            <div class="widget-main">
                <br />
                <div class="clearfix">
                    <?php
                        $q = Config::$g_con->prepare('SELECT * FROM `giftbox_logs` ORDER BY `ID` DESC Limit 5');
                        $q->execute();
                        while($row = $q->fetch(PDO::FETCH_OBJ)) {
                        ?>
                    <ul>
                    <li><?php echo $row->text ?></li></ul>
                    <?php } ?>
                </div>
            </div>
            <!--/widget-main-->
        </div>
        <!--/widget-body-->
    </div>
    <br />
    <div class="widget-box">
        <div class="widget-header widget-header-flat" style="background-color:#000000">
            <h5>
                <i class="fa fa-upload red"></i><font color="white"> Server updates </font>
            </h5>
        </div>
        <div class="widget-body"">
            <div class="widget-main">
                <div class="clearfix">
                    <br />
                    <?php
                        $q = Config::$g_con->prepare('SELECT * FROM `updates` WHERE `For` = 0 ORDER BY `id` DESC Limit 1');
                        $q->execute();
                        while($row = $q->fetch(PDO::FETCH_OBJ)) {
                        ?>
                    <div class="box-body box box-solid">
                        <?php if(isset($_SESSION['user'])&& Config::getData('users','Admin',$_SESSION['user']) >= 6) { ?>
                        <form action="" method="POST">
                            <textarea name="supdate" class="span12" rows="15"><?php echo $row->text ?></textarea>
                            <input type="submit" name="addsupdate" value="Modifica" class="btn btn-success"/>
                        </form>
                        <?php } else { ?>
                        <?php echo $row->text ?>
                        <?php } ?>
                        <br><br>
                        Edited by <a href="http://wster-rpg.cf/panel/profile/<?php echo Config::getID('users','id',$row->byAdmin); ?>"><?php echo $row->byAdmin ?></a>, <span style="color:grey"><?php echo $row->time ?> </span>
                    </div>
                    <?php } ?>
                </div>
            </div>
            <!--/widget-main-->
        </div>
        <!--/widget-body-->
    </div>
</div>
