<?php
if(!isset($_GET['check']) || empty($_GET['check'])) die;
$admin=$_GET['check'];

$sumfingIncl=true;
require '../config.thing.php';

$user = is_user_fakeid($admin);
if($user->isadmin != 1) die(_("Not admin!"));

$set = get_adm_opts();
include 'translate.php';
// Set timezone
date_default_timezone_set($set->timezone);

$users = get_all_users($admin);

?>

<div>
	<h3><?php echo _("Users");?></h3>
    <small><?php echo _("For search, hit F3 and enter your criteria");?></small>
</div>
<table class="table table-bordered table-condensed table-hover">
  <thead>
    <tr>
      <th><?php echo _("#");?></th>
      <th><?php echo _("Name");?></th>
      <th><?php echo _("Email");?></th>
      <th><?php echo _("Joined");?></th>
      <th><?php echo _("Birthday");?></th>
      <th><?php echo _("Status");?></th>
      <th><?php echo _("Options");?></th>
    </tr>
  </thead>
  <tbody>
  <?php foreach($users as $u) { 
  $user = explode("|",$u);
  $rowclass = ($user[5] == 'n') ? '' : 'class="error"';
  ?>
    <tr <?php echo $rowclass;?>>
      <td><?php echo $user[0];?></td>
      <td> <a href="https://facebook.com/<?php echo $user[6];?>" target="_blank"><?php echo $user[1];?></a> </td>
      <td><?php echo $user[2];?></td>
      <td><?php echo $user[3];?></td>
      <td><?php echo $user[4];?></td>
      <td>
	  	<?php 
			if($user[5] == 'n')
			echo _("Active");
			else
			echo _("Banned");
		?>
      </td>
      <td><button type="button" rel="<?php echo $user[6];?>" class="btn btn-mini usermng" ><?php echo _("Manage");?></button></td>
    </tr>
  <?php }?>
  </tbody>
</table>
<script> 
$(document).ready(function() {
	$('.usermng').click(function() {
		manageuser($(this).attr('rel'),'<?php echo $admin;?>');
	});
});
function manageuser(user,adminhsh) {
	var w=800;
	var h=500;
	var pageURL = 'incl/mnguser.php?check='+adminhsh+'&usr='+user;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, "_blank", 'toolbar=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>