We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28373
    • 204 Posts
    Hey peeps,

    We added an ip logger for web users signing up, we apply it twice - once for display purposes, and a second time we’ve added it to websignup.inc.php and record the ip addy in $comment

    Create a new snippet, call it
    showIP

    Put this code in it

       $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;
       }
    
    # ........./......... #
    
       $login_ip = $login_ip;
    
       echo "<p>Your IP Address is [<strong>".$login_ip."</strong>]";
       echo "</p>";
    


    Snippet Usage

    [[showIP]]

    On the off chance you have a use for it, you can see it in action here

    http://www.escortsnz.com/index.php?q=5.html

    You can also extract host info from $login_ip - depending on your level of paranoia smiley





      • 6726
      • 7,075 Posts
      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 ?
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l&#39;outil id
        • 28373
        • 204 Posts
        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
          • 6726
          • 7,075 Posts
          Really thanks for this Starbuck grin
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 28373
            • 204 Posts
            Quote from: davidm at May 24, 2006, 04:42 AM

            Really thanks for this Starbuck grin

            Anytime smiley
              • 8471
              • 333 Posts
              Thanks Satrbuck! It is very useful!
                Sorry for my bad English grin