Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bans doesn't show properly #126

Closed
realKitsune opened this issue May 27, 2019 · 3 comments
Closed

Bans doesn't show properly #126

realKitsune opened this issue May 27, 2019 · 3 comments

Comments

@realKitsune
Copy link

Hey guys,

I have a website for my teamspeak, and I've been realizing that (NEW) bans doesn't show up on my web banlist as it did before and I didn't change the code at all, it just started acting like that.

I still have an old ban that I kept that is still shown but news bans doesn't show up.
tl;dr it was an invisible ban used to prevent web banlist to crash when banlist is empty, idk a bug I never resolved

Web version:
http://prntscr.com/nu5cno

Teamspeak version:
http://prntscr.com/nu5e31

As you can see there are a lot of bans that are not on the web part. Is it because of Teamspeak update?
I am on version 3.7.1 now. I don't remember what was the last version that I upgraded to before but I remember I was late to update.

The code should be fine but I still share it, maybe something has to be changed since the new version.

<?php 

if($info_server_bansCount != 0){
  // Table top
  echo '<table class="table table-hover">
  <thead>
    <tr>
      <th scope="col" class="text-primary">#ID</th>
      <th scope="col" class="text-primary">Pseudo</th>
      <th scope="col" class="text-primary">UniqueID</th>
      <th scope="col" class="text-primary">Date</th>
      <th scope="col" class="text-primary">Durée</th>
      <th scope="col" class="text-primary">Banni par</th>
      <th scope="col" class="text-primary">Raison</th>';
      if(in_array($info_user_dbid, $group_allStaff_dbid)):
      	echo '<th scope="col" class="text-primary">Action</th>';
      endif;
      echo'
    </tr>
  </thead> <tbody>';
  if($_GET['e'] == 1){ echo '<tr><td colspan="8" class="text-success"><img src="http://i.kitsune.ovh/images/konsole/valid.png" style="vertical-align: text-top;"> Ban supprimé avec succès, pensez à bannir l\'autre ban associé avec.</span></td></tr>'; }
  foreach($banlist as $ban){
if($ban['banid'] != 403){

$invoker_PermissionLevel = 0;

	if($ban['invokercldbid'] == 1){
		$consoleName = explode('@', $ban['invokername']);
		$ban_invokerName = $consoleName[1];
		$ban_invokerDbid = $consoleName[0];
	}else{
		$ban_invokerName = $ban['invokername'];
		$ban_invokerDbid = $ban['invokercldbid'];
	}

foreach($group_list_moderators as $gU){ if($gU['cldbid'] == $ban_invokerDbid){ $invoker_PermissionLevel = 1;  } }
foreach($group_list_admins as $gU){ if($gU['cldbid'] == $ban_invokerDbid){ $invoker_PermissionLevel = 3;  } }
foreach($group_list_responsables as $gU){ if($gU['cldbid'] == $ban_invokerDbid){ $invoker_PermissionLevel = 5;  } }
foreach($group_list_superAdmins as $gU){ if($gU['cldbid'] == $ban_invokerDbid){ $invoker_PermissionLevel = 6;  } } 



    if($invoker_PermissionLevel == 1){
      $ban_invokerColor = "text-warning";
    }elseif($invoker_PermissionLevel == 3){
      $ban_invokerColor = "text-success";
    }elseif($invoker_PermissionLevel == 5){
      $ban_invokerColor = "text-danger";
    }elseif($invoker_PermissionLevel == 6){
      $ban_invokerColor = "text-danger";
    }else{
      $ban_invokerColor = "text-primary";
    }

    if(empty($ban['reason'])){ $ban_reason = '<span class="text-muted" title="Mais y\'avait surement une bonne raison derrière ;)"><i>Aucune raison renseignée.</i></span>'; }else{ $ban_reason = $ban['reason']; }
    if(empty($ban['name']) && !empty($ban['uid'])){ $client = $ts3_VirtualServer->clientFindDb($ban['uid'], true); $Info = $ts3_VirtualServer->clientinfoDb($client); $ban_name = $Info['client_nickname']; }else{ $ban_name = $ban['name']; }
    if(empty($ban['uid'])){ $ban_uidip = '<span class="text-muted">Ban IP (masqué)</span>'; }else{ $ban_uidip = $ban['uid']; }

    if(!empty($ban['uid']) && !empty($ban['ip'])){ if($user_PermissionLevel >= 2){ $ban_uidip = '<span class="text-warning" title="+BAN IP - '.$ban['ip'].'">'.$ban['uid'].'</span>'; }else{ $ban_uidip = '<span class="text-warning" title="+BAN IP - Même si t\'es un batard on va pas donner ton IP non plus.">'.$ban['uid'].'</span>'; } }

    if(empty($ban['name']) && empty($ban['uid']) && !empty($ban_uidip)){ $ban_name = '<span title="Si #BanID-1" class="text-muted">Voir ban # du dessus</span>'; }else{ }

    if($ban['duration'] < 86400 && time() - $ban['created'] < 86400){ $minus = 3600; $dateFormat1 = 'G\hi'; $dateFormat2 = 'G\h'; 
	}elseif($ban['duration'] == 86400 && time() - $ban['created'] < 86400){ $minus = 3600 + 86400; $dateFormat1 = 'G\hi'; $dateFormat2 = 'j\j G\h'; 
	}else{ $minus = 3600 + 86400; $dateFormat1 = 'j\j G\hi'; $dateFormat2 = 'j\j G\h'; }

	if($ban['duration'] != 0){
		$banLength = date($dateFormat2, $ban['duration'] - $minus); $banExpiration = date('d/m/Y H\hi', $ban['created'] + $ban['duration']);
	}else{
		$banLength = "<span class='text-danger'>Permanent</span>"; $banExpiration = "Dans très longtemps :*";
	}
	if(!empty($ban['ip']) && $user_PermissionLevel >= 2){ $titleUidIP = 'IP: '.$ban['ip']; }elseif(!empty($ban['ip']) && $user_PermissionLevel <= 1){ $titleUidIP = 'Même si t\'es un batard on va pas donner ton IP non plus.'; }else{ $titleUidIP = ''; }


    echo '<tr>';
    echo '<td class="text-muted">#'.$ban['banid'].'</td>';
    echo '<td class="text-primary">'.$ban_name.'</td>';
    echo '<td class="text-secondary" title="'.$titleUidIP.'">'.$ban_uidip.'</td>';
    echo '<td class="text-secondary" title="Expiration: '.$banExpiration.'">'.date("d/m/Y H\hi", $ban['created']).'</td>';
    echo '<td class="text-secondary" title="Temps restant: '.date($dateFormat1, ($ban['created'] + $ban['duration'] - time() - $minus)).'">'.$banLength.'</td>';
    echo '<td class="'.$ban_invokerColor.'">'.$ban_invokerName.'<span class="text-muted">#'.$ban_invokerDbid.'</span></td>';
    echo '<td class="text-secondary">'.$ban_reason.'</td>';
    if(in_array($info_user_dbid, $group_a ) && $invoker_PermissionLevel <= $user_PermissionLevel || $info_user_dbid == $ban['invokercldbid']):
     echo '<td class="text-primary"><a href="http://i.kitsune.ovh/php/actions.php?action=unban&b='.$ban['banid'].'"><button class="btn btn-warning btn-sm" title="Débannir ce pauvre petit canard."><img src="http://i.kitsune.ovh/images/konsole/hammer.gif" style="vertical-align:text-top;"></button></a></td>';
    endif;
    echo '</tr>';

  }

}
}
if($info_server_bansCount == 0){
  echo '<tr>';
  echo '<td colspan=5><span class="text-info">Il n\'y a pas de bans pour le moment, c\'est bien !</span></td>';
  echo '</tr>';
}
  echo '</tbody></table>';
?>

Thanks :))))

@realKitsune
Copy link
Author

Hey,

Anyone has an idea? i'm still on it and found nothing to do

@ronindesign
Copy link
Collaborator

Sorry for the late reply, not sure if you're still dealing with this.

Your code looks ok, I don't see an issue. I see in your web screenshot, a ban with id 403, but your foreach has if($ban['banid'] != 403) so I'm not sure why you see that ban.

I recommend you simplify your code to diagnose where in your code the issue is.
Start by just looping all the bans:

foreach($banlist as $ban){
  echo '<tr><td>'.$ban['banid'].'</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
}

So then you can see if even your $banlist is being populated correctly.

@ronindesign
Copy link
Collaborator

Closing for inactivity. We can reopen if you continue to have trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants