Volledige versie bekijken : IP Adress laten verschijnen



Sativa
17 March 2007, 00:12
Om dit alles te kunnen uitleggen moet ik jullie ff mijn site tonen...

Link: www.0317clan.tk (http://www.0317clan.tk)

Als je op de homepage bent, zie je rechts een loginsysteem.

Ik zou graag het IP adress laten verschijnen van degene die ingelogt is onder zijn naam (in dit geval sativa).

Kunnen jullie me de goeie php code ervoor geven?

GuntherS
17 March 2007, 00:21
Ik heb dit gevonden:

$ip=@$REMOTE_ADDR;
echo "IP Address= $ip";

EDIT: Het wordt verkeerd weergegeven hier op het forum.
Hier is de link en daar staat het: KLIK (http://www.plus2net.com/php_tutorial/php_ip.php)

Booster
17 March 2007, 00:53
Gebruik de server variable


echo $_SERVER['REMOTE_ADDR'];
?>

Je moet dan gewoon een veld 'ip' bijmaken in je tabel 'online' en daar de IP's opslaan. Ze weergeven is easy.

Sativa
17 March 2007, 11:42
Ik wil dit vlak onder Acount/ LogOut hebben te staan:


-=[Login]=-

Welcome, Sativa

Acount / LogOut

Your IP = xx.xx.xx.xx


=====================================

Ik heb de code tussen de php code van het loginsysteem proberen weven maar dan gaf ie een error op de site...
Test van het scriptje: http://sof2mp.so.funpic.de/test.php


$ip = getenv(REMOTE_ADDR);

print "Your IP Address is ".$ip;

=====================================

Login.php:


<?php
// -------------------------------------------------------------------------//
// Nuked-KlaN - PHP Portal //
// http://www.nuked-klan.org //
// -------------------------------------------------------------------------//
// This program is free software. you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License. //
// -------------------------------------------------------------------------//
if (eregi("block_login.php", $_SERVER['PHP_SELF']))
{
die ("You cannot open this page directly");
}
//------------------------Traduction------------------------------
global $language;

if($language == "french")
{
define("_CONNECT","Connectés");
define("_RECORD","Record");
define("_YESDAY","Hier");
define("_TODAYC","Aujourd'hui");
define("_HIDDEN","Cacher");
define("_AFFCONNECT","Afficher les connectés dans");
}
else
{
define("_CONNECT","Connected");
define("_RECORD","Record");
define("_YESDAY","Yesterday");
define("_TODAYC","Today");
define("_HIDDEN","Hidden");
define("_AFFCONNECT","Post the connected in");
}
//-----------------------------Fin--------------------------------

function affich_block_login($blok)
{
global $user, $nuked;

list($login, $messpv, $members, $online,$connect, $aff) = explode('|', $blok['content']);
$blok['content'] = "";

$c = 0;
if($login != "off")
{
if (!$user)
{
$blok['content'] = "<form action=\"index.php?file=User&amp;nuked_nude=index&amp;op=login\" method=\"post\">\n"
. "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\">\n"
. "<tr><td>" . _NICK . " :</td><td><input type=\"text\" name=\"pseudo\" size=\"10\" maxlength=\"250\" /></td></tr>\n"
. "<tr><td>" . _PASSWORD . " :</td><td><input type=\"password\" name=\"pass\" size=\"10\" maxlength=\"15\" /></td></tr>\n"
. "<tr><td colspan=\"2\"><input type=\"checkbox\" class=\"checkbox\" name=\"remember_me\" value=\"ok\" checked=\"checked\" />&nbsp;" . _SAVE . "</td></tr>\n"
. "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"login\" /></td></tr>\n"
. "<tr><td colspan=\"2\"><a href=\"index.php?file=User&amp;op=reg_screen\">" . _REGISTER . "</a><br />\n"
. "<a href=\"index.php?file=User&amp;op=oubli_pass\">" . _FORGETPASS . "</a> ?</td></tr></table></form>\n";
}
else
{
$blok['content'] = "<div style=\"text-align: center;\">" . _WELCOME . ", <b>" . $user[2] . "</b><br /><br />\n"
. "<a href=\"index.php?file=User\">" . _ACCOUNT . "</a> / <a href=\"index.php?file=User&amp;nuked_nude=index&amp;op=logout\">" . _LOGOUT . "</a></div>\n";
}
$c++;
}

if($messpv != "off" && $user[0] != "")
{
if ($c > 0) $blok['content'] .= "<hr style=\"height: 1px;\" />\n";

$sql2 = mysql_query("SELECT mid FROM " . USERBOX_TABLE . " WHERE user_for = '" . $user[0] . "' AND status = 1");
$nb_mess_lu = mysql_num_rows($sql2);

$blok['content'] .= "&nbsp;<img src=\"images/message.gif\" alt=\"\" />&nbsp;<span style=\"text-decoration: underline\"><b>" . _MESSPV . "</b></span><br />\n";

if ($user[5] > 0)
{
$blok['content'] .= "&nbsp;<b><big>·</big></b>&nbsp;" . _NOTREAD . " : <a href=\"index.php?file=Userbox\"><b>" . $user[5] . "</b></a>\n";
}
else
{
$blok['content'] .= "&nbsp;<b><big>·</big></b>&nbsp;" . _NOTREAD . " : <b>" . $user[5] . "</b>\n";
}

if ($nb_mess_lu > 0)
{
$blok['content'] .= "<br />&nbsp;<b><big>·</big></b>&nbsp;" . _READ . " : <a href=\"index.php?file=Userbox\"><b>" . $nb_mess_lu . "</b></a>\n";
}
else
{
$blok['content'] .= "<br />&nbsp;<b><big>·</big></b>&nbsp;" . _READ . " : <b>" . $nb_mess_lu . "</b>\n";
}

$c++;
}

if ($members != "off")
{
if ($c > 0) $blok['content'] .= "<hr style=\"height: 1px;\" />\n";

$blok['content'] .= "&nbsp;<img src=\"images/memberslist.gif\" alt=\"\" />&nbsp;<span style=\"text-decoration: underline\"><b>" . _MEMBERS . "</b></span><br />\n";

$sql_users = mysql_query("SELECT id FROM " . USER_TABLE . " WHERE niveau < 3");
$nb_users = mysql_num_rows($sql_users);

$sql_admin = mysql_query("SELECT id FROM " . USER_TABLE . " WHERE niveau > 2");
$nb_admin = mysql_num_rows($sql_admin);

$sql_lastmember = mysql_query("SELECT pseudo FROM " . USER_TABLE . " ORDER BY date DESC LIMIT 0, 1");
list($lastmember) = mysql_fetch_array($sql_lastmember);
$lastmember = stripslashes($lastmember);

$blok['content'] .= "&nbsp;<b><big>·</big></b>&nbsp;" . _ADMINS . " : <b>" . $nb_admin . "</b><br />&nbsp;<b><big>·</big></b>&nbsp;" . _MEMBERS . " :"
. "&nbsp;<b>" . $nb_users . "</b> [<a href=\"index.php?file=Members\">" . _LIST . "</a>]<br />\n"
. "&nbsp;<b><big>·</big></b>&nbsp;" . _LASTMEMBER . " : <a href=\"index.php?file=Members&amp;op=detail&amp;autor=" . urlencode($lastmember) . "\"><b>" . $lastmember . "</b></a>\n";

$c++;
}

if ($online != "off")
{
if ($c > 0) $blok['content'] .= "<hr style=\"height: 1px;\" />\n";

$blok['content'] .= "&nbsp;<img src=\"images/online.gif\" alt=\"\" />&nbsp;<span style=\"text-decoration: underline\"><b>" . _WHOISONLINE . "</b></span><br />\n";

$nb = nbvisiteur();

if ($nb[1] > 0)
{
$sql4 = mysql_query("SELECT username FROM " . NBCONNECTE_TABLE . " WHERE type BETWEEN 1 AND 2 ORDER BY date");
while (list($nom) = mysql_fetch_array($sql4))
{
$user_online .= "&nbsp;<b><big>·</big></b>&nbsp;<b>" . $nom . "</b><br />";
}

$user_list = "&nbsp;[<a href=\"#\" onmouseover=\"AffBulle('&nbsp;&nbsp;" . _WHOISONLINE . "', '" . htmlentities(addslashes($user_online), ENT_NOQUOTES) . "', 150)\" onmouseout=\"HideBulle()\">" . _LIST . "</a>]";
}
else
{
$user_list = "";
}

if ($nb[2] > 0)
{
$sql5 = mysql_query("SELECT username FROM " . NBCONNECTE_TABLE . " WHERE type > 2 ORDER BY date");
while (list($name) = mysql_fetch_array($sql5))
{
$admin_online .= "&nbsp;<b><big>·</big></b>&nbsp;<b>" . $name . "</b><br />";
}

$admin_list = "&nbsp;[<a href=\"#\" onmouseover=\"AffBulle('&nbsp;&nbsp;" . _WHOISONLINE . "', '" . htmlentities(addslashes($admin_online), ENT_NOQUOTES) . "', 150)\" onmouseout=\"HideBulle()\">" . _LIST . "</a>]";
}
else
{
$admin_list = "";
}

$blok['content'] .= "&nbsp;<b><big>·</big></b>&nbsp;" . _VISITOR;
if ($nb[0] > 1) $blok['content'] .= "s";
$blok['content'] .= " : <b>" . $nb[0] . "</b><br />&nbsp;<b><big>·</big></b>&nbsp;" . _MEMBER;
if ($nb[1] > 1) $blok['content'] .= "s";
$blok['content'] .= " : <b>" . $nb[1] . "</b>" . $user_list . "<br />&nbsp;<b><big>·</big></b>&nbsp;" . _ADMIN;
if ($nb[2] > 1) $blok['content'] .= "s";
$blok['content'] .= " : <b>" . $nb[2] . "</b>" . $admin_list . "<br />\n";

$c++;
}


//ajout par makia pour afficher le nombres de connect/jour http://www.genese-graph.com/
if ($connect != "off")
{
if ($c > 0) $blok['content'] .= "<hr style=\"height: 1px;\" />\n";

$nom = $user[2];

if ($_SERVER['HTTP_CLIENT_IP'])
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if ($_SERVER['HTTP_X_FORWARDED_FOR'])
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}

if ($nom == "") $nom = "visiteur";

$sql = mysql_query("SELECT temps, record FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom = ''");
list($temps, $record) = mysql_fetch_row($sql);

if(time() >= $temps)
{
$sql3 = mysql_query("SELECT * FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom != ''");
$con_hier = mysql_num_rows($sql3);

$temps = $temps + (3600*24);

$sql2 = mysql_query("DELETE FROM ". $nuked['prefix'] ."_nbconnect_jour");

if ($con_hier > $record)
{
$sql1 = mysql_query("INSERT INTO ". $nuked['prefix'] ."_nbconnect_jour VALUES ('','','". $temps ."','". $con_hier ."','". $con_hier ."','')");
}
else
{
$sql1 = mysql_query("INSERT INTO ". $nuked['prefix'] ."_nbconnect_jour VALUES ('','','". $temps ."','". $con_hier ."','". $record ."','')");
}

$sql = mysql_query("INSERT INTO ". $nuked['prefix'] ."_nbconnect_jour VALUES ('','". $nom ."','','','','". $ip ."')");
}

if( $nom != "visiteur")
{
$sql = mysql_query("SELECT nom,ip FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom='". $nom ."' OR ip='". $ip ."'");
$count = mysql_num_rows($sql);
list($visiteur,$Vist_ip) = mysql_fetch_row($sql);

if($count == 1)
{
if($Vist_ip == $ip && $nom != $visiteur)
{
$sql = mysql_query("UPDATE ". $nuked['prefix'] ."_nbconnect_jour SET nom = '". $nom ."' WHERE ip = '". $ip ."'");
}
if($Vist_ip != $ip && $nom == $visiteur)
{
$sql = mysql_query("UPDATE ". $nuked['prefix'] ."_nbconnect_jour SET ip = '". $ip ."' WHERE nom = '". $nom ."'");
}
}
}
else
{
$sql = mysql_query("SELECT nom FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE ip = '". $ip ."'");
list($visiteur) = mysql_fetch_row($sql);
$count = mysql_num_rows($sql);

if($visiteur == "visiteur")
{
$sql = mysql_query("UPDATE ". $nuked['prefix'] ."_nbconnect_jour SET nom = '". $nom ."' WHERE ip = '". $ip ."'");
}
}

if($count == 0)
{
$sql = mysql_query("INSERT INTO ". $nuked['prefix'] ."_nbconnect_jour VALUES ('','". $nom ."','". $temps ."','','','". $ip ."')");
}

$blok[content] .= "&nbsp;<img src=\"images/memberslist.gif\" alt=\"\" />&nbsp;<span style=\"text-decoration: underline\"><b>" . _CONNECT . "</b></span><br />";

$sql = mysql_query("SELECT hier, record FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom = ''");
list($con_hier, $record) = mysql_fetch_row($sql);

$blok[content].= "&nbsp;<b><big>·</big></b>&nbsp;". _RECORD ." : <b>". $record ."</b>\n"
. "<br />&nbsp;<b><big>·</big></b>&nbsp;". _YESDAY ." : <b>". $con_hier ."</b><br />\n";

$sql = mysql_query("SELECT * FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom != ''");
$today = mysql_num_rows($sql);


$blok[content] .= "&nbsp;<b><big>·</big></b>&nbsp;"._TODAYC ." : <b>". $today ."</b>";

$sql = mysql_query("SELECT nom FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom != '' AND nom != 'visiteur'");
while(list($nom_vist) = mysql_fetch_row($sql))
{
$list_vist .= "&nbsp;-&nbsp;". $nom_vist ."<br />";
}

$sql = mysql_query("SELECT nom FROM ". $nuked['prefix'] ."_nbconnect_jour WHERE nom = 'visiteur'");
$visite = mysql_num_rows($sql);

if($visite > 0)
{
if($visite > 1)$s = "s";
$list_vist .= "&nbsp;-&nbsp;". $visite ."&nbsp;visiteur". $s;
}

if($aff == "div")
{
echo "<script type=\"text/javascript\">\n"
. "<!--\n"
. "function cacherDiv(id,div)\n"
. "{\n"
. " if(document.getElementById(id).style.visibility == 'hidden')\n"
. " {\n"
. " document.getElementById(id).style.visibility = 'visible';\n"
. " document.getElementById(id).style.position = 'relative';\n"
. " document.getElementById(id).style.width = '100%';\n"
. " document.getElementById(div).innerHTML = '". _HIDDEN ."';\n"
. " }\n"
. " else\n"
. " {\n"
. " document.getElementById(id).style.visibility = 'hidden';\n"
. " document.getElementById(id).style.position = 'absolute';\n"
. " document.getElementById(id).style.width = '';\n"
. " document.getElementById(div).innerHTML = '". _LIST ."';\n"
. " }\n"
. "}\n"
. "// -->\n"
. "</script>\n";

$blok[content] .= "&nbsp;[<a href=\"javascript:cacherDiv('listVist', 'cacherSpan');\"><span id=\"cacherSpan\">". _LIST ."</span></a>]\n";
}
else
{
$blok[content] .= "&nbsp;[<a href=\"#\" onmouseover=\"AffBulle('&nbsp;&nbsp;" . _CONNECT . "', '" . htmlentities(addslashes($list_vist), ENT_NOQUOTES) . "', 120)\" onmouseout=\"HideBulle()\">" . _LIST . "</a>]";
}

$blok[content] .= "<br/><div id=\"listVist\" style=\"visibility:hidden;position:absolute;\">". $list_vist ."</div>\n";

$c++;
}
//fin de l'ajout http://www.genese-graph.com/
return $blok;
}

function edit_block_login($bid)
{
global $nuked, $language;

$sql = mysql_query("SELECT active, position, titre, module, content, type, nivo, page FROM " . BLOCK_TABLE . " WHERE bid = '" . $bid . "'");
list($active, $position, $titre, $modul, $content, $type, $nivo, $pages) = mysql_fetch_array($sql);
$titre = stripslashes($titre);
$titre = htmlentities($titre);
list($login, $messpv, $members, $online, $connect, $aff) = explode('|', $content);

if ($active == 1) $checked1 = "selected=\"selected\"";
else if ($active == 2) $checked2 = "selected=\"selected\"";
else $checked0 = "selected=\"selected\"";

if ($login == "off") $checked3 = "selected=\"selected\""; else $checked3 = "";
if ($messpv == "off") $checked4 = "selected=\"selected\""; else $checked4 = "";
if ($members == "off") $checked5 = "selected=\"selected\""; else $checked5 = "";
if ($online == "off") $checked6 = "selected=\"selected\""; else $checked6 = "";
if ($connect == "off") $checked7 = "selected=\"selected\""; else $checked7 = "";
if ($aff == "div") $checked8 = "checked=\"checked\""; else $checked9 = "checked=\"checked\"";

echo "<a href=\"#\" onclick=\"javascript:window.open('help/" . $language . "/block.html','Help','toolbar=0,location=0,directori es=0,status=0,scrollbars=1,resizable=0,copyhistory =0,menuBar=0,width=350,height=300');return(false)\">\n"
. "<img style=\"border: 0;\" src=\"help/help.gif\" alt=\"\" title=\"" . _HELP . "\" /></a><div style=\"text-align: center;\"><h3>" . _ADMINBLOCK . "</h3></div>\n"
. "<form method=\"post\" action=\"index.php?file=Admin&amp;page=block&amp;op=modif_block\">\n"
. "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n"
. "<tr><td><b>" . _TITLE . "</b></td><td><b>" . _BLOCK . "</b></td><td><b>" . _POSITION . "</b></td><td><b>" . _LEVEL . "</b></td></tr>\n"
. "<tr><td align=\"center\"><input type=\"text\" name=\"titre\" size=\"40\" value=\"" . $titre . "\" /></td>\n"
. "<td align=\"center\"><select name=\"active\">\n"
. "<option value=\"1\" " . $checked1 . ">" . _LEFT . "</option>\n"
. "<option value=\"2\" " . $checked2 . ">" . _RIGHT . "</option>\n"
. "<option value=\"0\" " . $checked0 . ">" . _OFF . "</option></select></td>\n"
. "<td align=\"center\"><input type=\"text\" name=\"position\" size=\"2\" value=\"" . $position . "\" /></td>\n"
. "<td align=\"center\"><select name=\"nivo\"><option>" . $nivo . "</option>\n"
. "<option>0</option>\n"
. "<option>1</option>\n"
. "<option>2</option>\n"
. "<option>3</option>\n"
. "<option>4</option>\n"
. "<option>5</option>\n"
. "<option>6</option>\n"
. "<option>7</option>\n"
. "<option>8</option>\n"
. "<option>9</option></select></td></tr>\n"
. "<tr><td colspan=\"4\">" . _LOGIN . " : <select name=\"login\">\n"
. "<option value=\"on\">" . _YES . "</option>\n"
. "<option value=\"off\" " . $checked3 . ">" . _NO . "</option></select>\n"
. "&nbsp;" . _MESSPV . " : <select name=\"messpv\">\n"
. "<option value=\"on\">" . _YES . "</option>\n"
. "<option value=\"off\" " . $checked4 . ">" . _NO . "</option></select>\n"
. "</td></tr><tr><td colspan=\"4\">" . _MEMBERS . " : <select name=\"members\">\n"
. "<option value=\"on\">" . _YES . "</option>\n"
. "<option value=\"off\" " . $checked5 . ">" . _NO . "</option></select>\n"
. "&nbsp;" . _WHOISONLINE . " : <select name=\"online\">\n"
. "<option value=\"on\">" . _YES . "</option>\n"
. "<option value=\"off\" " . $checked6 . ">" . _NO . "</option></select><br />"
. "". _CONNECT ." : <select name=\"connect\">\n"
. "<option value=\"on\">" . _YES . "</option>\n"
. "<option value=\"off\" " . $checked7 . ">" . _NO . "</option></select><br />\n"
. "". _AFFCONNECT ." : <input type=\"radio\" name=\"aff\" value=\"div\" ". $checked8 ." /> Div\n"
. "<input type=\"radio\" name=\"aff\" value=\"bulle\" ". $checked9 ." /> Infobulle</td></tr><tr><td colspan=\"4\">&nbsp;</td></tr>\n"
. "<tr><td colspan=\"4\" align=\"center\"><b>" . _PAGESELECT . " :</b></td></tr><tr><td colspan=\"4\">&nbsp;</td></tr>\n"
. "<tr><td colspan=\"4\" align=\"center\"><select name=\"pages[]\" size=\"8\" multiple=\"multiple\">\n";

select_mod2($pages);

echo "</select></td></tr><tr><td colspan=\"4\" align=\"center\"><br />\n"
. "<input type=\"hidden\" name=\"type\" value=\"" . $type . "\" />\n"
. "<input type=\"hidden\" name=\"bid\" value=\"" . $bid . "\" />\n"
. "<input type=\"submit\" name=\"send\" value=\"" . _MODIFBLOCK . "\" />\n"
. "</td></tr></table>"
. "<div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Admin&amp;page=block\"><b>" . _BACK . "</b></a> ]</div></form><br />\n";

}

function modif_advanced_login($data)
{
$data['content'] = $data['login'] . "|" . $data['messpv'] . "|" . $data['members'] . "|" . $data['online'] ."|". $data['connect'] ."|". $data['aff'];
return $data;
}

?>

=====================================

Wie kan me er een beetje mee helpen? Alvast bedankt!

Spoorzoeker
19 March 2007, 09:29
Kun je me duidelijk maken wat het nut is van het tonen van mijn ipadres ?.

djeetn
19 March 2007, 19:46
euhm, mss heeft het voor jou niet veel nut, mss wel voor de admin van de site, maar ondertussen weet je da ook weeral hé

(wrm druk ik toch altijd op die bedank knop in plaats van quote?)

Edit (Jelle): bedankje verwijderd :p

Jelle
21 March 2007, 11:57
Dan zoek je dat toch gewoon in je code en plaats je het er bij? Heel moeilijk te vinden is het niet en het is bovendien de beste manier om PHP te leren: zelf wat knoeien met code tot het werkt :)


$blok['content'] = "<div style=\"text-align: center;\">" . _WELCOME . ", <b>" . $user[2] . "</b><br /><br />\n"
. "<a href=\"index.php?file=User\">" . _ACCOUNT . "</a> / <a href=\"index.php?file=User&amp;nuked_nude=index&amp;op=logout\">" . _LOGOUT . "</a></div>\n";
Vervang je door

$blok['content'] = "<div style=\"text-align: center;\">" . _WELCOME . ", <b>" . $user[2] . "</b><br /><br />\n"
. "<a href=\"index.php?file=User\">" . _ACCOUNT . "</a> / <a href=\"index.php?file=User&amp;nuked_nude=index&amp;op=logout\">" . _LOGOUT . "</a><br />Your IP = " . $_SERVER['REMOTE_ADDR'] . "</div>\n";
Dat zou het normaal gezien moeten doen.