Quote from: davidm at May 23, 2006, 06:59 PM
Cool snippet, Starbuck !
The ShowIP/display part is nice enough, but adding this to websignup, that’s even cooler !
Just one thing (remember I am no coder) : how do you implement this last bit ?
Hi David
Locate this file
assets/snippets/weblogin/websignup.inc.php
Change this code
// save user attributes
$blocked=1;
$sql = "INSERT INTO ".$modx->getFullTableName("web_user_attributes")." (internalKey, fullname, email, phone, state, country, blocked)
VALUES($key, '$fullname', '$email', '$phone', '$state', '$country', '$blocked');";
$rs = $modx->db->query($sql);
if(!$rs){
$output = webLoginAlert("An error occured while attempting to save the user's attributes.").$tpl;
return;
}
to this
// save user attributes
$blocked=1;
$a = getenv("HTTP_X_FORWARDED_FOR");
$b = getenv("REMOTE_ADDR");
if ($a <> "") {
### [ip proxied] ###
$posn=0;
do {
$posn++; # increment $POSN.
if ($a{$posn} == ',') { # if inside the $A string, at the $POSN character -- there is a "," character
break; # .. exit the do/while loop.
}
} while ($posn < strlen($a)); # do until the end of the $A string has been reached.
$login_ip = substr($a,0,$posn); # $LOGIN_IP = from 0 to $POSN characters of $A string
# $A = "nigger", [0=>4] === {nigg}
} else {
### [ip standard] ###
$login_ip = $b;
}
# ........./......... #
$comment = $login_ip;
$sql = "INSERT INTO ".$modx->getFullTableName("web_user_attributes")." (internalKey, fullname, email, phone, state, country, blocked, comment)
VALUES($key, '$fullname', '$email', '$phone', '$state', '$country', '$blocked', '$comment');";
$rs = $modx->db->query($sql);
if(!$rs){
$output = webLoginAlert("An error occured while attempting to save the user's attributes.").$tpl;
return;
}
$blocked is a hack I added earlier which automatically blocks any new web users until admin approves (unblocks) them
-Starbuck