pls help for php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cigojlo
Forum Newbie
Posts: 2
Joined: Mon Jul 08, 2013 4:44 am

pls help for php code

Post by cigojlo »

I have ftp php script for forum,im using this script to show bans in forum but i add some code for time of ban,but now in table when i ban some player script print and change time for all banned players,but i just want to print in one row for current player,pls if someone know help me here what i add
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Time/Date:</td>\n";
and this
$date = date("Y-m-d H:i:s");
and this
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
echo $date;
echo "</td>\n";

Code: Select all

<!doctype html>
<head>
<title>Advance Bans List</title>
 <?php
 
$ftp_ip="";
$ftp_user="";
$ftp_pass="";
$ftp_log_path="cstrike/addons/amxmodx/data/advanced_bans.txt";
$temporary_file="bans.tmp";
//END VARS
 
 
 
 
$conn_id = ftp_connect($ftp_ip);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
 
/*
if ((!$conn_id) || (!$login_result)) {
echo "<font color=\"#FF0000\">Could not retrieve ban list.</font>";
exit;
} else {
echo "<font color=\"#00FF00\">Retrieved ban list successfully.</font>\n";
echo "<br />\n";
echo "<br />\n";
}
*/
 
// get the file
$local = fopen($temporary_file, "w");
$result = ftp_fget($conn_id, $local, $ftp_log_path, FTP_ASCII);
 
// close the FTP stream
ftp_close($conn_id);
 
 
$myFile = $temporary_file;
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
 
 
echo "<table border=\"0\" cellpadding=\"3\" style=\"width: 100%;\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Time/Date:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Player name:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Player SteamID/IP:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Reason for ban:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Ban duration:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Time of Unban:</td>\n";
echo "<td style=\"background-color: #333333; color: #FFFFFF; font-size: small;\">Admin name:</td>\n";
echo "</tr>\n";
 
function steam2friend($steam_id){
    $steam_id=strtolower($steam_id);
    if (substr($steam_id,0,7)=='steam_0') {
        $tmp=explode(':',$steam_id);
        if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
            return bcadd((($tmp[2]*2)+$tmp[1]),'76561197960265728');
        }else return false;
        }else{
            return false;
        }
    }
 
 
$file1 = $temporary_file;
$lines = file($file1);
$line_num = -1;
foreach($lines as $linenum => $line){
 $line_num++;
}
while($line_num > -1){
 
$line = $lines[$line_num];
 
list($steamidraw, $nickdurationtimeraw, $reason, $admin, $adminidraw) = explode('" "', $line);
$steamid = str_replace("\"", "", $steamidraw);
list($nick, $durationraw, $time) = explode('"', $nickdurationtimeraw);
 
$duration = str_replace(" ", "", $durationraw);
$adminidraw2 = str_replace("\"", "", $adminidraw);
$adminid = trim($adminidraw2);
$friendid = steam2friend($steamid);
$adminfriendid = steam2friend($adminid);
$date = date("Y-m-d H:i:s");
 
echo "<tr>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
echo $date;
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
echo $nick;
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
//echo $steamid;
echo "<a style=\"color: #0000FF;\" href=\"http://steamcommunity.com/profiles/";
echo $friendid;
echo "\" target=\"_blank\">";
echo $steamid;
echo "</a>";
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
if($reason == "") {
        echo "No reason specified.";
}
else {
        echo $reason;
}
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
if($duration == "0") {
        echo "Permanent";
}
elseif($duration == "1") {
        echo $duration;
        echo " minute";
}
else {
        echo $duration;
        echo " minutes";
}
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
if($time == "Permanent Ban") {
        echo "Never";
}
else {
        echo $time;
}
echo "</td>\n";
 
echo "<td style=\"background-color: #eee; color: #000000; font-size: small;\">";
//echo $admin;
echo "<a style=\"color: #0000FF;\" href=\"http://steamcommunity.com/profiles/";
echo $adminfriendid;
echo "\" target=\"_blank\">";
echo $admin;
echo "</a>";
echo "</td>\n";
 
echo "</tr>\n";
$line_num--;
}
?>
</table>
</body>
</html>
Last edited by requinix on Mon Jul 08, 2013 12:41 pm, edited 1 time in total.
Reason: [php] tags don't work well. please use [syntax=php][/syntax]
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: pls help for php code

Post by Celauran »

Code: Select all

date("Y-m-d H:i:s")
You aren't passing in a time argument, so it's defaulting to just formatting the current time, which you then repeat on every row. If you want to display the time each player was banned, you'll need to record that alongside the other information you're storing, then pass that as a second argument to date().
cigojlo
Forum Newbie
Posts: 2
Joined: Mon Jul 08, 2013 4:44 am

Re: pls help for php code

Post by cigojlo »

thx but i still dont understand,im not good at all in php scripts, can somebody write me code,i write this code alone pls
Post Reply