Codice PHP:
<?php
require 'config.php';
if ($link = mysql_connect(HOST, USERNAME, PASSWORD)) {} else {
die("<br><h2 style="text-align:center;color:red">Error while connecting to MySQL database</h2><h3 style="text-align:center;color:red">Check MySQL connection in config.php</h3>");
}
if (mysql_select_db(DB_NAME, $link)) {} else {
die("<br><h2 style="text-align:center;color:red">Error while selecting MySQL database</h2><h3 style="text-align:center;color:red">Check if database exists and user from config.php has access to it</h3>");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo TITLE; ?></title>
<link rel="shortcut icon" type="image/x-icon" href="img/ico.png">
<link rel="stylesheet" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=0.5, width=device-width">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<?php
function calcTime($d1, $d2){
require 'config.php';
$interval = $d2->diff($d1);
if ( $v = $interval->d >= 1 ) return $interval->d.' d';
if ( $v = $interval->h >= 1 ) return $interval->h.' h';
if ( $v = $interval->i >= 1 ) return $interval->i.' min';
return $interval->s.' sec';
}
function getBanOrKick($id, $time, $name, $reason, $by, $end){
require 'config.php';
$addition = "";
if($end != ""){
$addition = '<tr class="hide-'.$id.'" >
<td style="text-align:right;color:#9EFF30;">'.$msgDuration.'</td> <td class="color2">"'.$end.'"</td>
</tr>';
}
echo'
<tr class="name-'.$id.'" style="cursor: pointer;">
<td class="color2" style="text-align:right;width:100px;font-size:20px;">
'.$time.'
</td>
<td>
<span class="reason-entry" >'.$name.'</span>*<i style="font-size:15px;" class="fa fa-mouse-pointer"></i>
</td>
</tr>
<tr class="hide-'.$id.'" >
<td style="text-align:right;color:orange;">'.$msgReason.'</td> <td class="color2">"'.$reason.'"</td>
</tr>';
if(BANNED_BY){
echo '<tr class="hide-'.$id.'" >
<td style="text-align:right;color:#3194CE;">'.$msgBannedBy.'</td> <td class="color2">"'.$by.'"</td>
</tr>';
}
echo $addition.'
<style>
.hide-'.$id.'{
font-size: 0px;
transition-timing-function: ease-out;
-webkit-transition-timing-function: ease-out;
-webkit-transition: 0.5s;
transition: 0.5s;
}
#main .name-'.$id.':hover ~ .hide-'.$id.'{
font-size: 25px;
}
</style>
';
}
?>
<body>
<div class="shadow" id="header">
<span id="title" ><?php echo $msgTitle; ?></span>
<form id="ban-search" method="get" action="search.php">
<span><?php echo $msgSearch; ?> </span><input name="search" type="text" required><i onclick="document.getElementById('ban-search').submit();" class="whiteIco fa fa-search"></i>
</form>
</div>
<br>
<br>
<div id="main">
<table style="width:400px;">
<tr>
<th style="text-align:right;"> <i class="fa fa-lock"></i> </th>
<th style="text-align:left;">
<?php echo $msgLastBans; ?>
</th>
</tr>
<?php
//BAN
$sql="SELECT * FROM PlayerHistory WHERE end='BAN' ORDER BY STR_TO_DATE(`PlayerHistory`.`start`, '%d.%m.%Y-%H:%i:%s') DESC LIMIT ". MAX_ENTRIES;
$result=mysql_query($sql,$link);
if(mysql_num_rows($result)>0) {
for($i=0;$i<mysql_num_rows($result);$i++) {
//07.10.2015-14:25:46
$date = DateTime::createFromFormat('d.m.Y-H:i:s', mysql_result($result,$i,'start'));
getBanOrKick(($i."b"),
$date->format(DATE_FORMAT),
mysql_result($result,$i,'name'),
mysql_result($result,$i,'reason'),
mysql_result($result,$i,'by'), '');
}
}else{
echo '
<tr><td></td><td style="color:#FF6C59; font-size: 25px;">'.$msgNoBans.'</td></tr>
';
}
?>
</table>
<table style="width:400px;">
<tr>
<th style="text-align:right;" > <i class="fa fa-ban"></i> </th>
<th style="text-align:left;">
<?php echo $msgLastKicks; ?>
</th>
</tr>
<?php
//KICK
$sql="SELECT * FROM PlayerHistory WHERE end='KICK' ORDER BY STR_TO_DATE(`PlayerHistory`.`start`, '%d.%m.%Y-%H:%i:%s') DESC LIMIT ".MAX_ENTRIES;
$result=mysql_query($sql,$link);
if(mysql_num_rows($result)>0) {
for($i=0;$i<mysql_num_rows($result);$i++) {
//07.10.2015-14:25:46
$date = DateTime::createFromFormat('d.m.Y-H:i:s', mysql_result($result,$i,'start'));
getBanOrKick(($i."k"),
$date->format(DATE_FORMAT),
mysql_result($result,$i,'name'),
mysql_result($result,$i,'reason'),
mysql_result($result,$i,'by'), '');
}
}else{
echo '
<tr><td></td><td style="color:#FF6C59; font-size: 25px;">'.$msgNoKicks.'</td></tr>
';
}
?>
</table>
<table style="width:400px;">
<tr>
<th style="text-align:right;"> <i class="fa fa-clock-o"></i> </th>
<th style="text-align:left;">
<?php echo $msgLastTempBans; ?>
</th>
</tr>
<?php
//TEMP-BAN
$sql="SELECT * FROM PlayerHistory WHERE end NOT IN ('BAN', 'KICK') ORDER BY STR_TO_DATE(`PlayerHistory`.`start`, '%d.%m.%Y-%H:%i:%s') DESC LIMIT ".MAX_ENTRIES;
$result=mysql_query($sql,$link);
if(mysql_num_rows($result)>0) {
for($i=0;$i<mysql_num_rows($result);$i++) {
//07.10.2015-14:25:46
$date = DateTime::createFromFormat('d.m.Y-H:i:s', mysql_result($result,$i,'start'));
$end = DateTime::createFromFormat('d.m.Y-H:i:s', mysql_result($result,$i,'end'));
getBanOrKick(($i."t"),
$date->format(DATE_FORMAT),
mysql_result($result,$i,'name'),
mysql_result($result,$i,'reason'),
mysql_result($result,$i,'by'),
calcTime($date ,$end));
}
}else{
echo '
<tr><td></td><td style="color:#FF6C59; font-size: 25px;">'.$msgNoTempBans.'</td></tr>
';
}
?>
</table>
</div>
<div id="footer" class="shadow">
<span>Coded by <a href="http://dev.skamps.eu" target="_blank">LeokoTime</a> | © Copyright 2015</span>
</div>
</body>
</html>