conoscete uno scritp che fa visualizzare l'ip del atuale utente?? mi serve per bannare degli utenti che non si colportano in modo adeguato. insomma ho trovato lo script per bannare nel quale ce anche lo script che cerco solo che non riesco ad estrapolarlo facendolo funzionare in una tabella, per farvi capire il tutto un po meglio vi passo il materiale sperando in una maggiore riuscita.
ecco lo script dv devo estrapolare la parte del IP
Codice PHP:
<?php
session_start();
$domain = GetHostByName($REMOTE_ADDR); // GET YOUR IP ADDRESS
include "inc.php"; // INCLUDE THIS FILE FOR PASSWORD
// IF LOG OUT IS REQUESTED THEN THE SESSION WILL UNSET BELOW
if ($action == 'logout') {
session_unset();
echo "Logged out !!";
exit();
}
// CHECK TO SEE IF YOUR LOGGED IN
if ($_POST['Login'] == 'Login') {
if ($pass != $password) {$msg = "You must type in the correct password";}
if ($pass == $password)
{$_SESSION['logged'] = 'true';
$action = '';}
}
if (!$_SESSION['logged'] == 'true') {
echo $_SESSION['logged'];
echo "<link href='IPstyle.css' rel='stylesheet' type='text/css'>
<div align='center'>
PHP - AGTC IP Ban v1.0a </p>
<table width='50%' border='0'>
<tr>
<th scope='col'><form action='' method='post' name='form1'>
<div align='center'>Enter The Admin Password
<input name='pass' type='password' size='30' maxlength='30'>
<input name='Login' type='submit' value='Login'>
</div>
</form> </th>
</tr>
</table></div>";
}
// THIS IS WHERE WE CHECK BEFORE WE WRITE NEW BANNED IP TO FILE ip.txt
if($_SESSION['logged']) {
if (isset($_POST['Submit'])) {
$addip = $_POST['ipadd'];
$filename = 'ip.txt';
$content = "$addip\n";
// DOES IT EXIST, IF SO PREPARE TO APPEND
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// WRITE $content TO $ip.txt
if (fwrite($handle, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
$msg = "Success, wrote $content to IP ban database";
fclose($handle);
} else {
$msg = "The file $filename is not writable";
}
}
?>
<link href="IPstyle.css" rel="stylesheet" type="text/css">
<div align="center">
PHP - AGTC IP Ban v1.0a </p>
Your IP address is <?php echo $domain; ?> </p>
<table width="50%" border="0">
<tr>
<th scope="col"><form action="" method="post" name="form1">
<div align="center">Enter the IP address you wish to ban
<input name="ipadd" type="text" size="30" maxlength="30">
<input name="Submit" type="submit" value="Submit">
</div>
</form> </th>
</tr>
</table>
[url="?action=logout"]LOG OUT [/url]</p>
<?php echo $msg; ?></p>
</div>
<div align="center">
</p>
<table width="30%" border="0" cellspacing="2" cellpadding="2">
<tr><th><span class="style1">List of banned IP's</span></th>
</tr>
<?php $theFile = file_get_contents('ip.txt');
$lines = array();
$lines = explode("\n", $theFile);
$lineCount = count($lines);
for ($i = 0; $i < $lineCount; $i++){ ?>
<tr> <th scope="col"><div align="left"><span class="style1"><?php echo $lines[$i];}?>
</span></div></th>
</tr>
</table>
</p>
</div>
<?php } echo "<center>$copyright</center>"; ?>
per farmi spiegare ora devo inserirlo in quasta tabella:
Codice PHP:
<table width="664" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="22" bgcolor="#000000"><div align="center">[url="<?php"]><font color="#FFFFFF">Username</font>[/url]</div></td>
<td width="196" valign="top" bgcolor="#333333"><div align="center"><a href=<?php
echo "\"admin.php?begin=$begin&sortby=mailadres&direction=";
if ($sortby == "mailadres" && $direction=="ASC"){echo "DESC\"";}
else {echo "ASC\"";}
?>>Autorità</div></td>
<td width="143" valign="top" bgcolor="#000000"><div align="center"><a href=<?php
echo "\"admin.php?begin=$begin&sortby=actnum&direction=";
if ($sortby == "actnum" && $direction=="ASC"){echo "DESC\"";}
else {echo "ASC\"";}
?>><font color="#FFFFFF">Ultimo login</font></div></td>
<td width="146" valign="top" bgcolor="#333333"><div align="center"><font color="#FFFFFF">Data
di registrazione</font></div></td>
</tr>
<?PHP
// set the color switcher to zero
$bgcolorswithcer = 0;
// make an query to retrieve al members
$query = "Select * from ".$DBprefix."signup ORDER BY '$sortby' $direction LIMIT $begin, 50 ";
$result = mysql_query($query);
// use a while loop to print al the results
while($row = mysql_fetch_array($result)){
?>
<tr>
<td height="18" bgcolor="<?PHP
// a simple script to change the value of the bgcolor atribuut of the TD tag.
if ($bgcolorswithcer == 0) {
echo "#000099";
}
else
{
echo "#000066";
} ?>"><div align="center"><font color="#FFFFFF">
<?PHP
// print the usename retrieved from the database
echo htmlspecialchars($row["username"],ENT_QUOTES); ?>
</font></div></td>
<td valign="top" bgcolor="<?PHP if ($bgcolorswithcer == 0) {
echo "#003399";
}
else
{
echo "#003366";
} ?>"><div align="center"><font color="#FFFFFF">
<?PHP
//echo if the user is an admin.
if ($row["userlevel"] < 0) {echo "ADMIN";}
else{echo $row["userlevel"];}?>
</font></div></td>
<td valign="top" bgcolor="<?PHP if ($bgcolorswithcer == 0) {
echo "#000099";
}
else
{
echo "#000066";
} ?>"> <div align="center"><font color="#FFFFFF">
<?PHP
//echo the date of the last login
echo $row["lastlogin"]; ?>
</font></div></td>
<td valign="top" bgcolor="<?PHP if ($bgcolorswithcer == 0) {
echo "#003399";
$bgcolorswithcer = 1;
}
else
{
echo "#003366";
$bgcolorswithcer = 0;
} ?>"><div align="center">
<?PHP
//echo the date the user signed up
echo $row["signupdate"]; ?>
</div></td>
</tr>
<tr>
<td height="0"></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php
// and very important end the while loop
}
?>
</table>
</body>
</html>
so che sembra una cosa lunghissima ma alla fine forse anzi almeno spero si potra spiegare in poche parole