<?php
if(!defined('panel'))
	die('Nope.');
if(isset($_SESSION['user']) && Config::getData('users','Admin',$_SESSION['user']) >= 4) {
?>
</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">Admin Panel</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>	
<title>Admin Panel - <?php echo Config::$_SITE_NAME; ?></title>
<div class="page-content"><div class="row-fluid"><div class="span12">

<?php
if (isset($_POST['inchide']))
{
		$q = Config::$g_con->prepare('UPDATE `factions` SET `Application` = 0 WHERE `ID` = ?');
		$q->execute(array($_POST['inchideid']));
	echo '<div class="alert alert-danger">Ai inchis aplicatiile cu succes la factiunea <b>'. Config::$factions[$_POST['inchideid']] .'</b>!
	<button type="button" class="close" data-dismiss="alert">
    <i class="icon-remove"></i>
    </button></div>';
	//echo '<meta http-equiv="refresh" content="3;URL=\''.Config::$_PAGE_URL.'leader\'/>';
}
if (isset($_POST['levelmin']))
{
		$q = Config::$g_con->prepare('UPDATE `factions` SET `MinLevel` = ? WHERE `ID` = ?');
		$q->execute(array($_POST['levelmin'],$_POST['factionid']));
	echo '<div class="alert alert-danger">Ai setat levelul minim la <b>'. htmlspecialchars($_POST['levelmin']) .'</b> la factiunea <b>'. Config::$factions[$_POST['factionid']] .'</b>!
	<button type="button" class="close" data-dismiss="alert">
    <i class="icon-remove"></i>
    </button></div>';
	//echo '<meta http-equiv="refresh" content="3;URL=\''.Config::$_PAGE_URL.'leader\'/>';
}
if (isset($_POST['resetcr']))
{
		$q = Config::$g_con->prepare('UPDATE `users` SET `CrPlayers` = 0');
		$q->execute(array());
}
if (isset($_POST['resethelp']))
{
		$q = Config::$g_con->prepare('UPDATE `users` SET `HelpedPlayers` = 0');
		$q->execute(array());
}
if (isset($_POST['resetgift']))
{
		$q = Config::$g_con->prepare('UPDATE `users` SET `GiftTime` = 0');
		$q->execute(array());
}
if (isset($_POST['resetquest']))
{
        $q = Config::$g_con->prepare('UPDATE `users` SET `Misiune` = 0, `Misiune2` = 0, `CerinteMisiune` = 0, `CerinteMisiune2` = 0, `ProgresMisiune2` = 0, `ProgresMisiune` = 0, `MisiuneTerminata` = 0, `MisiuneTerminata2` = 0');
        $q->execute(array());
}
?>
<div class="span8 pull-right">
<h4>Admin Tools</h4>
<a href="#flood" data-toggle="collapse">flood attemps</a>
<div id="flood" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `antiflood` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->time ?><br><span style="color:grey"><?php echo $row->text ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#staff" data-toggle="collapse">staff logs</a>
<div id="staff" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `staff_logs` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->time ?><br><span style="color:grey"><?php echo $row->text ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#deposit" data-toggle="collapse">factions deposit</a>
<div id="deposit" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_deposit` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->time ?><br><span style="color:grey"><?php echo $row->action ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#adm" data-toggle="collapse">admins logs</a>
<div id="adm" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `log_admin` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->time ?><br><span style="color:grey"><?php echo $row->log ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#ticket" data-toggle="collapse">tickets</a>
<div id="ticket" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `tickets` ORDER BY `id` DESC Limit 15');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><a href="http://wster-rpg.cf/panel/ticket/<?php echo $row->id ?>"><?php echo $row->Name ?>'s ticket</a> | Stauts: <?php echo ($row->Status ? "Closed" : "Open"); ?> | <span style="color:grey"><?php echo $row->time ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#panel" data-toggle="collapse">panel logs</a>
<div id="panel" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `panellogs` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->time ?><br><span style="color:grey"><?php echo $row->text ?></span></li>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#newbie" data-toggle="collapse">player questions and answers</a>
<div id="newbie" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `questions` ORDER BY `id` DESC Limit 25');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li>Question: <?php echo $row->Question ?></li>
    <li>Answer: <?php echo $row->Response ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#lspd" data-toggle="collapse">(1) lspd chat</a>
<div id="lspd" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 1 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#fbi" data-toggle="collapse">(2) fbi chat</a>
<div id="fbi" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 2 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#ng" data-toggle="collapse">(3) ng chat</a>
<div id="ng" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 3 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#lat" data-toggle="collapse">(4) los aztecas chat</a>
<div id="lat" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 4 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#gr" data-toggle="collapse">(5) grove street chat</a>
<div id="gr" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 5 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#lvg" data-toggle="collapse">(6) los vagos chat</a>
<div id="lvg" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 6 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#lvpd" data-toggle="collapse">(8) lvpd chat</a>
<div id="lvpd" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 8 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#nr" data-toggle="collapse">(9) news reporters chat</a>
<div id="nr" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 9 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#bls" data-toggle="collapse">(10) ballas chat</a>
<div id="bls" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 10 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#htm" data-toggle="collapse">(11) hitman chat</a>
<div id="htm" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 11 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#si" data-toggle="collapse">(12) school instructors chat</a>
<div id="si" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 12 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#taxi" data-toggle="collapse">(13) taxi chat</a>
<div id="taxi" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 13 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<a href="#para" data-toggle="collapse">(14) paramedic chat</a>
<div id="para" class="collapse">
	<?php
        $q = Config::$g_con->prepare('SELECT * FROM `factions_chat` WHERE `factionid` = 14 ORDER BY `id` DESC Limit 20');
        $q->execute();
        while($row = $q->fetch(PDO::FETCH_OBJ)) {
        ?>
    <li><?php echo $row->text ?></li>
    <br>
    <?php } ?>
</div>
<div class="hr hr8"></div>
<?php if(Config::getData('users','Admin',$_SESSION['user']) >= 5) {	?>
<form method="post">
<button type="submit" name="resethelp" class="btn-yellow">Reseteaza raport helperi</button>
<div class="hr hr8"></div>
<button type="submit" name="resetcr" class="btn-yellow">Reseteaza raport admini</button>
<div class="hr hr8"></div>
<button type="submit" name="resetquest" class="btn-yellow">Reseteaza quest-urile zilnice (doar in baza de date)</button>
<div class="hr hr8"></div>
<button type="submit" name="resetgift" class="btn-yellow">Reseteaza GiftBox</button>
</form> <?php }?>
</div>
<div class="span3 pull-left">
<h4>Faction settings</h4>
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `factions` ORDER BY `ID` ASC'); 
	$q->execute();
	while($row = $q->fetch(PDO::FETCH_OBJ)) {
?>
<li><?php echo $row->Name ?></li>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $row->ID ?>">
	<i class="ace-icon fa fa-angle-down bigger-110" data-icon-hide="ace-icon fa fa-angle-right" data-icon-show="ace-icon fa fa-angle-down"></i>
	&nbsp;&nbsp;seteaza level aplicatii (<?php echo $row->MinLevel ?>)
</a>											
	<div class="collapse" id="collapse<?php echo $row->ID ?>">											
		<form method="post">
				<div class="col-sm-13">
					<input type="text" name="levelmin" placeholder="Introdu levelul minim dorit" class="col-xs-10 col-sm-13" />
					<input name="factionid" type="hidden" value="<?php echo $row->ID ?>">
				</div>
		</form><br />
	</div>
<?php if($row->Application == 1) { ?>
<br />
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne<?php echo $row->ID ?>">
	<i class="ace-icon fa fa-angle-down bigger-110" data-icon-hide="ace-icon fa fa-angle-right" data-icon-show="ace-icon fa fa-angle-down"></i>
	&nbsp;&nbsp;inchide aplicatii
</a>											
	<div class="collapse" id="collapseOne<?php echo $row->ID ?>">
		<form method="post">
			<button name="inchide" class="btn btn-danger">Inchide aplicatii</button>
			<input name="inchideid" type="hidden" value="<?php echo $row->ID ?>">
		</form><br />
	</div>
<?php } ?>
<br /><br />
<?php } } else { echo'<meta http-equiv="refresh" content="0;URL=\''.Config::$_PAGE_URL.'\'/>'; } ?>
</div>
