The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IP-Address in Profile

+3
Ape
SLGray
Eugeo Igvalt
7 posters

Page 2 of 3 Previous  1, 2, 3  Next

Go down

Solved IP-Address in Profile

Post by Eugeo Igvalt December 9th 2014, 5:41 am

First topic message reminder :

Hello. I have been working as Administrator for a forum and They have asked me they want in the Profile area and only Administrators to see it. I need the IP to appear automatically in the text box without me having to fill each text box of each member manually. I have already created the field I just need the IP to be added automatically. is there any CSS, Javascript or Html code to make this a possibility? 

Screenshot of text box: http://prntscr.com/5esvgg


Last edited by Eugeo Ayano on December 16th 2014, 3:56 pm; edited 1 time in total
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down


Solved Re: IP-Address in Profile

Post by FrOsTyXi December 10th 2014, 4:44 am

It;s making me have to fill out the ip at registration any fix? forum link:TPSN
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 10th 2014, 5:23 am

FrOsTyXi wrote:It;s making me have to fill out the ip at registration any fix? forum link:TPSN
Read carefully each line that I wrote in this post: https://help.forumotion.com/t137330-ip-address-in-profile#927788

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 10th 2014, 5:40 am

JScript wrote:
FrOsTyXi wrote:It;s making me have to fill out the ip at registration any fix? forum link:TPSN
Read carefully each line that I wrote in this post: https://help.forumotion.com/t137330-ip-address-in-profile#927788

JS

Yes sir i believe i read it all clearly here is what i have
IP-Address in Profile - Page 2 123410

At registration
IP-Address in Profile - Page 2 Test10

I have it set to Necessarily filled ? [No] as of now due to the issue

Regards
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 10th 2014, 3:49 pm



Last edited by JScript on December 12th 2014, 3:43 am; edited 1 time in total
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 10th 2014, 4:22 pm

Thank you Jscript but i'm still having a issue with having to enter the ip upon registering.

TPSN

Maybe is you have time i can send you my test account for the forum so you can see where my error is.

Note: i followed everything to a Tee but still same issue

also thank you for your coding i find it very useful!

Regards

FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by SLGray December 11th 2014, 1:00 am

Did you do this:
Note: Change this value profile_field_XX_XX ] by the identifier that you found in step above!


IP-Address in Profile - Page 2 Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51576
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 11th 2014, 1:09 am

SLGray wrote:Did you do this:
Note: Change this value profile_field_XX_XX ] by the identifier that you found in step above!

Yes sir i did, profile_field_13_1.

Seems that when people login the ip is being posted in their profile but is i tick Yes to for that profile option no one can register due to the system wants them to type their IP in even though you can see the field to type it in.

Weird i know.

Regards
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Ape December 11th 2014, 4:00 am

i have no problem with the old code that adds the ip address when they make an account but the one that makes the ip address when the member is already a member don't work i get an error if you want the one that the member gets when they make an account then the code is already inplace on the thread


IP-Address in Profile - Page 2 Left1212IP-Address in Profile - Page 2 Center11IP-Address in Profile - Page 2 Right112
IP-Address in Profile - Page 2 Ape_b110
IP-Address in Profile - Page 2 Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19454
Reputation : 2012
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 11th 2014, 4:19 am

APE wrote:i have no problem with the old code that adds the ip address when they make an account but the one that makes the ip address when the member is already a member don't work i get an error if you want the one that the member gets when they make an account then the code is already inplace on the thread


Thank you sir for the info.

Rehards
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 11th 2014, 5:15 pm

Hello everybody!

I did successfully testing in IE, Chrome and Safari, but in firefox the cross-origin request is blocked in the latest versions!!!

I'm trying to work around but this problem is also reported in this link: http://stackoverflow.com/questions/25051759/how-to-solve-cross-origin-request-blocked-error-in-firefox

As soon as possible I will modify the code to be compatible with the new version of Firefox.

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 11th 2014, 5:41 pm

JScript wrote:Hello everybody!

I did successfully testing in IE, Chrome and Safari, but in firefox the cross-origin request is blocked in the latest versions!!!

I'm trying to work around but this problem is also reported in this link: http://stackoverflow.com/questions/25051759/how-to-solve-cross-origin-request-blocked-error-in-firefox

As soon as possible I will modify the code to be compatible with the new version of Firefox.

JS
Thank you for your time JScript! Can't wait for the new code!!
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 12th 2014, 3:42 am

Here is the code that writes the the public IP of a member in the register and then when it is logged in on the forum the IP will be updated!

Note: This code works only when the Advanced profile is activated!
If they wish to work in the normal profile, let me know ok?

Create a new field in the profile as follows:
IP-Address in Profile - Page 2 O0rVRkB

Then go on editing your profile and with the help of the browser console, locate the new field identifier that was created as illustrated below:
IP-Address in Profile - Page 2 1vPCUTq

Use this code with placement in all pages:
Code:

/*******************************************************************************************************
 * Application: Location IP.
 * Description: Shows the user's IP in the profile.
 * Version: RC2 - Beta tester only!
 * Made and Optimizations by JScript - 2014/12/10, 11
 * Copyright (c) 2014 JScript <jscriptbrasil at live dot com>
 * This work is free. You can redistribute it and/or modify it
 * under the terms of the WTFPL, Version 2
********************************************************************************************************
-
Variables that can be changed by the user:
1- profile_field (change the value profile_field_XX_XX by your profile field!)
2- error_msg
3- tTimeOut
4- checkTime
Note: For those variables "tTimeout" and "checkTime" ->
      - to avoid the "Request Limit" the lowest value should be 5 seconds and 10 seconds respectively!
*/
var IPLocation = {
   profile_field: 'profile_field_XX_XX',
   error_msg: "Warning!\n\nAn error occurred while requesting registration, wait 10 seconds and refresh the page to re-register!",
   setLoop: 0,
   lInterval: 10,
   tTimeOut: 10000, // Min is 5 seconds to start check.
   checkTime: 60000, // Min is 30 seconds of interval to check a new IP.
   TID: 0
};

/**
 * jQuery AJAX Cross Origin v1.3 (http://www.ajax-cross-origin.com)
 * jQuery plugin to bypass Same-origin_policy using Google Apps Script.
 * (c) 2014, Writen by Erez Ninio. site: www.dealhotelbook.com
 **/
AJAX_CrossOrigin();

/**
 * Waits for a user registers to record the initial IP!
 **/
if (location.search == "?agreed=true\x26step=2") {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById(IPLocation.profile_field) !== null) {
         jQuery("#" + IPLocation.profile_field).closest("dl").hide();
         clearInterval(IPLocation.setLoop);
         $.ajax({
            type: "GET",
            url: "http://api.ipify.org",
            crossOrigin: true,
            dataType: "text",
            success: function(data) {
               jQuery("#" + IPLocation.profile_field).val(data);
            },
            error: function(data) {
               jQuery("#" + IPLocation.profile_field).val('127.0.0.0');
               // alert("Warning!\n\nAn error occurred while requesting registration, wait 10 seconds and refresh the page to re-register!");
            }
         });
      };
   }, IPLocation.lInterval);
} else {
   jQuery(function() {
      if (!_userdata.session_logged_in) {
         return false;
      }
      /**
       * If you are logged in, writes the current IP in the profile field...
       **/
      setTimeout(function() {
         IPLocation.TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0];
         setInterval(function() {
            $.ajax({
               type: "GET",
               url: "http://api.ipify.org",
               crossOrigin: true,
               dataType: "text",
               success: function(data) {
                  jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                     id: IPLocation.profile_field.substring(17, IPLocation.profile_field.length),
                     user: _userdata.user_id,
                     active: "1",
                     content: '[["' + IPLocation.profile_field + '", "' + data + '"]]',
                     tid: IPLocation.TID
                  }, function(data) {
                     console.log("The IP " + data + " was saved in profile!");
                  }, "json").fail(function() {
                     console.log("Error saving the IP to profile!");
                  });
               },
               error: function(data) {
                  console.log("Error getting public IP!");
               }
            });
         }, IPLocation.checkTime);
      }, IPLocation.tTimeOut);
   });
}

/**
 * If the member go on editing your profile and it is not a staff member, the IP field is removed!
 **/
if (location.pathname.indexOf('/profile') == 0) {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById(IPLocation.profile_field) !== null) {
         if (_userdata.user_level == 0) {
            jQuery("#" + IPLocation.profile_field).closest("dl").remove();
         }
         clearInterval(IPLocation.setLoop);
      };
   }, IPLocation.lInterval);
}

/**
 * If the member is viewing your profile and ->
 **/
if (location.pathname.indexOf('/u') == 0) {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById('profile-advanced-right') !== null) {
         if (!_userdata.session_logged_in) {
            return false;
         }
         var forbid = jQuery('#field_id' + IPLocation.profile_field.substring(17, IPLocation.profile_field.length));
         if (forbid.length) {
            forbid.attr('id', 'forbid');
            /**
             * <- it is not a staff member, the IP field will be removed!
             **/
            if (_userdata.user_level == 0) {
               forbid.remove();
            }
         }
         /**
          *       Since we do not have access to the template of the advanced profile,
          * then we have to modify the identifiers so we can intercept them in order
          * to avoid that members can modify the IP field!
          **/
         var oTarget = jQuery('[id^=field_id]'),
            iLen = oTarget.length,
            index = 0;
         for (; index < iLen; index++) {
            var oThis = jQuery(oTarget[index]);
            oThis.attr('id', 'JS_' + oThis.attr('id'));
            IPLocation.profile_field
         };
         clearInterval(IPLocation.setLoop);
         $('[id^=JS_field_id]').each(function() {
            if ($(this).find('.field_editable').is('span, div')) {
               $(this).hover(function() {
                  if ($(this).find('.field_editable.invisible').is('span, div')) {
                     $(this).find('.field_editable').prev().addClass('ajax-profil_hover').parent().addClass('ajax-profil_parent').append('<div class="ajax-profil_edit"><img src="http://2img.net/i/fa/invision/../edit.png" /></div>');
                     $(this).find('.ajax-profil_edit').attr({
                        alt: "{L_FIELD_EDIT_VALUE}",
                        title: "{L_FIELD_EDIT_VALUE}"
                     }).click(function() {
                        $(this).prev().prev().removeClass('ajax-profil_hover').addClass('invisible').next().removeClass('invisible').append('<img src="http://2img.net/i/fa/invision/../valid.png" class="ajax-profil_valid" />').find('input,select');
                        $(this).prev().find('.ajax-profil_valid').attr({
                           alt: "{L_VALIDATE}",
                           title: "{L_VALIDATE}"
                        }).click(function() {
                           var content = new Array();
                           $(this).parent().find('[name]').each(function() {
                              var type_special = $(this).is('input[type=radio],input[type=checkbox]');
                              if ((type_special && $(this).is(':checked')) || !type_special) {
                                 content.push(new Array($(this).attr('name'), $(this).attr('value')));
                              }
                           });
                           var id_name = $(this).parents('[id^=JS_field_id]').attr('id');
                           var id = id_name.substring(11, id_name.length);
                           // console.log('id_name: ' + id_name + '\n' + 'id: ' + id);
                           $.post(
                              "/ajax_profile.forum?jsoncallback=?", {
                                 id: id,
                                 user: _userdata.user_id,
                                 active: "1",
                                 content: $.toJSON(content),
                                 tid: jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0];
                              },
                              function(data) {
                                 $.each(data, function(i, item) {
                                    $('[id=JS_field_id' + i + ']').find('.field_uneditable').html(item).end().find('.ajax-profil_valid').remove().end().find('.field_editable').addClass('invisible').end().find('.field_uneditable').removeClass('invisible');
                                 });
                              },
                              "json"
                           );
                        });
                        $(this).remove();
                     });
                  }
               }, function() {
                  if ($(this).find('.field_editable.invisible').is('span, div')) {
                     $(this).find('.field_editable').prev().removeClass('ajax-profil_hover');
                     $(this).find('.ajax-profil_edit').remove();
                  }
               });
            }
         });

      };
   }, 50);
}

/*
 jQuery AJAX Cross Origin v1.3 (http://www.ajax-cross-origin.com)
 jQuery plugin to bypass Same-origin_policy using Google Apps Script.

 references:
 http://en.wikipedia.org/wiki/Same-origin_policy
 http://www.google.com/script/start/

 (c) 2014, Writen by Erez Ninio. site: www.dealhotelbook.com

 Licensed under the Creative Commons Attribution 3.0 Unported License.
 For details, see http://creativecommons.org/licenses/by/3.0/.
*/
function AJAX_CrossOrigin() {
   if (typeof proxyJsonp === 'undefined') {
      var proxyJsonp = "https://script.google.com/macros/s/AKfycbwmqG55tt2d2FcT_WQ3WjCSKmtyFpkOcdprSITn45-4UgVJnzp9/exec";
      jQuery.ajaxOrig = jQuery.ajax;
      jQuery.ajax = function(a, b) {
         function d(a) {
            a = encodeURI(a).replace(/&/g, "%26");
            return proxyJsonp + "?url=" + a + "&callback=?"
         }
         var c = "object" === typeof a ? a : b || {};
         c.url = c.url || ("string" === typeof a ? a : "");
         var c = jQuery.ajaxSetup({}, c),
            e = function(a, c) {
               var b = document.createElement("a");
               b.href = a;
               return c.crossOrigin && "http" == a.substr(0, 4).toLowerCase() && "localhost" != b.hostname && "127.0.0.1" != b.hostname && b.hostname != window.location.hostname
            }(c.url, c);
         c.proxy && 0 < c.proxy.length && (proxyJsonp = c.proxy, "object" === typeof a ?
            a.crossDomain = !0 : "object" === typeof b && (b.crossDomain = !0));
         e && ("object" === typeof a ? a.url && (a.url = d(a.url), a.charset && (a.url += "&charset=" + a.charset), a.dataType = "json") : "string" === typeof a && "object" === typeof b && (a = d(a), b.charset && (a += "&charset=" + b.charset), b.dataType = "json"));
         return jQuery.ajaxOrig.apply(this, arguments)
      };
      jQuery.ajax.prototype = new jQuery.ajaxOrig;
      jQuery.ajax.prototype.constructor = jQuery.ajax;
   }
}
Note: Change this value profile_field_XX_XX ] by the identifier that you found in step above!

Result:
IP-Address in Profile - Page 2 VmaFcO9

The code now includes:
jQuery AJAX Cross Origin v1.3 (http://www.ajax-cross-origin.com)
jQuery plugin to bypass Same-origin_policy using Google Apps Script.
(c) 2014, Writen by Erez Ninio. site: www.dealhotelbook.com


JS


Last edited by JScript on December 12th 2014, 3:51 am; edited 1 time in total
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 12th 2014, 3:47 am

Thank you JScript!!
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 12th 2014, 5:16 am

Strange. I created an account using this new code. after I made the account I went and saw that yeah the IP did register but it wasnt my ip. Yes I used a proxy VPN, my IP was supposed to be from Brazil but the IP it registered put it me in California. Google HQ. Found that strange.
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by SLGray December 12th 2014, 5:42 am

That will be an issue if someone uses a proxy, because when they register the IP address will be different each time they log into the forum.


IP-Address in Profile - Page 2 Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51576
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 12th 2014, 5:43 am

Just tested it out by no using any proxy now I got my own IP-address registered. SUCCESS! Big thanks to @JScript
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by SLGray December 12th 2014, 5:51 am

Well that is great for you, but some people will not be able to stop using proxies, because some Internet providers use proxies.


IP-Address in Profile - Page 2 Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51576
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 12th 2014, 5:53 am

I did not know that actually. Thanks for that info.
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by SLGray December 12th 2014, 5:58 am

My provider uses proxies.  I know this because every time I unplug the modem and plug it back in, I have a different IP address.


IP-Address in Profile - Page 2 Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51576
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 12th 2014, 6:03 am

but are external IP's supposed to be static or do they change eventually because sometimes during the week I have an IP then the another day I have another IP but still gives the same location.
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 12th 2014, 4:04 pm

Hello!

There is a limit of requests to obtain the IP in this case I recommend the following:
Code:

 tTimeout: 60000, // 1 minute to start check.
 checkTime: 1800000 // 30 minutes to re check
 

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 12th 2014, 4:11 pm

Thank you again JScript i've added this in place!
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 12th 2014, 5:58 pm

Added. Thanks a lot!!
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 12th 2014, 7:30 pm

Reporting a small issue, every member is sending back the error ip 127.0.0.0
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 12th 2014, 7:42 pm

FrOsTyXi wrote:Reporting a small issue, every member is sending back the error ip 127.0.0.0
I also realized this friend, so I'm looking for other ways or another proxy that is limitless because Google has limits daily ...

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by FrOsTyXi December 12th 2014, 7:54 pm

JScript wrote:
FrOsTyXi wrote:Reporting a small issue, every member is sending back the error ip 127.0.0.0
I also realized this friend, so I'm looking for other ways or another proxy that is limitless because Google has limits daily ...

JS

Ah ok thank you JScript i knew you would have a answer for the issue i await your fix!!
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 13th 2014, 2:27 am

I'm getting that to with my users. Just noticed it.
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by JScript December 13th 2014, 8:16 pm

Finally a version that did not fail in any of the tests that I did!

Here is the code that writes the the public IP of a member in the register and then when it is logged in on the forum the IP will be updated!

Note: This code works only when the Advanced profile is activated!
If they wish to work in the normal profile, let me know ok?

Create a new field in the profile as follows:
IP-Address in Profile - Page 2 O0rVRkB

Then go on editing your profile and with the help of the browser console, locate the new field identifier that was created as illustrated below:
IP-Address in Profile - Page 2 1vPCUTq

Use this code with placement in all pages:
Code:

/*******************************************************************************************************
 * Application: Location IP.
 * Description: Shows the user's IP in the profile.
 * Version: RC2 - Beta tester only!
 * Made and Optimizations by JScript - 2014/12/10, 11, 13
 * Copyright (c) 2014 JScript <jscriptbrasil at live dot com>
 * This work is free. You can redistribute it and/or modify it
 * under the terms of the WTFPL, Version 2
********************************************************************************************************
-
Variables that can be changed by the user:
1- profile_field (change the value profile_field_XX_XX by your profile field!)
2- error_msg
3- tTimeOut
4- checkTime
Note: For those variables "tTimeout" and "checkTime" ->
      - to avoid the "Request Limit" the lowest value should be 5 seconds and 10 seconds respectively!
*/
var IPLocation = {
   profile_field: 'profile_field_XX_XX',
   error_msg: "Warning!\n\nAn error occurred while requesting registration, wait 10 seconds and refresh the page to re-register!",
   setLoop: 0,
   lInterval: 10,
   tTimeOut: 10000, // Min is 10 seconds to start check.
   checkTime: 300000, // Min is 5 minutes of interval to check a new IP.
   TID: 0
};

/**
 * jQuery.ajaxCORS - Cross Domain Ajax - Version: RC1
 * Using: query.yahooapis.com, based on James Padolsey
 * Made and Optimizations by JScript - 2014/12/13
 **/
jQuery.ajaxCORS = (function(_cors) {
   var protocol = location.protocol,
      hostname = location.hostname,
      patt = RegExp(protocol + '//' + hostname),
      YQL = 'http' + (/^https/.test(protocol) ? 's' : '') + '://query.yahooapis.com/v1/public/yql?callback=?',
      query = 'select * from html where url="{URL}" and xpath="*"';

   function isExternal(url) {
      return !patt.test(url) && /:\/\//.test(url);
   }
   return function(Obj) {
      var url = Obj.url;

      if (/get/i.test(Obj.type) && !/json/i.test(Obj.dataType) && isExternal(url)) {
         // Manipulate options so that JSONP-x request is made to YQL
         Obj.url = YQL;
         Obj.dataType = 'json';
         Obj.data = {
            q: query.replace(
               '{URL}',
               url + (Obj.data ?
                  (/\?/.test(url) ? '&' : '?') + jQuery.param(Obj.data) : '')
            ),
            format: 'xml'
         };
         // Since it's a JSONP request, then complete === success
         if (!Obj.success && Obj.complete) {
            Obj.success = Obj.complete;
            delete Obj.complete;
         }
         Obj.success = (function(_success) {
            return function(data) {
               if (_success) {
                  // Fake XHR callback.
                  _success.call(this, {
                     responseText: (data.results[0] || '')
                        // YQL screws with tag <script>, then get rid of them...
                        .replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
                  }, 'success');
               }
            };
         })(Obj.success);
      }
      return _cors.apply(this, arguments);
   };
})(jQuery.ajax);

/**
 * Waits for a user registers to record the initial IP!
 **/
if (location.search == "?agreed=true\x26step=2") {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById(IPLocation.profile_field) !== null) {
         jQuery("#" + IPLocation.profile_field).closest("dl").hide();
         clearInterval(IPLocation.setLoop);
         $.ajax({
            type: "GET",
            // url: 'http://www.whatsmyip.net/',
            url: 'http://wtfismyip.com/json',
            dataType: "json",
            success: function(data) {
               // var ip = jQuery(data.responseText).find('h1:first input').val(); // ->http://www.whatsmyip.net/
               var ip = data.YourFuckingIPAddress; // ->http://wtfismyip.com/
               jQuery("#" + IPLocation.profile_field).val(ip);
            },
            error: function(data) {
               // console.log(data);
               jQuery("#" + IPLocation.profile_field).val('127.0.0.0');
               alert("Warning!\n\nAn error occurred while requesting registration, wait 10 seconds and refresh the page to re-register!");
            }
         });
      };
   }, IPLocation.lInterval);
} else {
   jQuery(function() {
      if (!_userdata.session_logged_in) {
         return false;
      }
      /**
       * If you are logged in, writes the current IP in the profile field...
       **/
      setTimeout(function() {
         _SaveIPInProfile();
         setInterval(function() {
            _SaveIPInProfile();
         }, IPLocation.checkTime);
      }, IPLocation.tTimeOut);

      function _SaveIPInProfile() {
         IPLocation.TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0];
         $.ajax({
            type: "GET",
            // url: 'http://www.whatsmyip.net/',
            url: 'http://wtfismyip.com/json',
            dataType: "json",
            success: function(data) {
               // var ip = jQuery(data.responseText).find('h1:first input').val(); // ->http://www.whatsmyip.net/
               var ip = data.YourFuckingIPAddress; // ->http://wtfismyip.com/
               jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                  id: IPLocation.profile_field.substring(17, IPLocation.profile_field.length),
                  user: _userdata.user_id,
                  active: "1",
                  content: '[["' + IPLocation.profile_field + '", "' + ip + '"]]',
                  tid: IPLocation.TID
               }, function(data) {
                  console.log("The IP was saved in profile!");
               }, "json").fail(function() {
                  console.log("Error saving the IP to profile!");
               });
            },
            error: function(data) {
               console.log("Error getting public IP!");
            }
         });
      };
   });
}

/**
 * If the member go on editing your profile and it is not a staff member, the IP field is removed!
 **/
if (location.pathname.indexOf('/profile') == 0) {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById(IPLocation.profile_field) !== null) {
         if (_userdata.user_level == 0) {
            jQuery("#" + IPLocation.profile_field).closest("dl").remove();
         }
         clearInterval(IPLocation.setLoop);
      };
   }, IPLocation.lInterval);
}

/**
 * If the member is viewing your profile and ->
 **/
if (location.pathname.indexOf('/u') == 0) {
   IPLocation.setLoop = setInterval(function() {
      if (document.getElementById('profile-advanced-right') !== null) {
         if (!_userdata.session_logged_in) {
            return false;
         }
         var forbid = jQuery('#field_id' + IPLocation.profile_field.substring(17, IPLocation.profile_field.length));
         if (forbid.length) {
            forbid.attr('id', 'forbid');
            /**
             * <- it is not a staff member, the IP field will be removed!
             **/
            if (_userdata.user_level == 0) {
               forbid.remove();
            }
         }
         /**
          *       Since we do not have access to the template of the advanced profile,
          * then we have to modify the identifiers so we can intercept them in order
          * to avoid that members can modify the IP field!
          **/
         var oTarget = jQuery('[id^=field_id]'),
            iLen = oTarget.length,
            index = 0;
         for (; index < iLen; index++) {
            var oThis = jQuery(oTarget[index]);
            oThis.attr('id', 'JS_' + oThis.attr('id'));
            IPLocation.profile_field
         };
         clearInterval(IPLocation.setLoop);
         $('[id^=JS_field_id]').each(function() {
            if ($(this).find('.field_editable').is('span, div')) {
               $(this).hover(function() {
                  if ($(this).find('.field_editable.invisible').is('span, div')) {
                     $(this).find('.field_editable').prev().addClass('ajax-profil_hover').parent().addClass('ajax-profil_parent').append('<div class="ajax-profil_edit"><img src="http://2img.net/i/fa/invision/../edit.png" /></div>');
                     $(this).find('.ajax-profil_edit').attr({
                        alt: "{L_FIELD_EDIT_VALUE}",
                        title: "{L_FIELD_EDIT_VALUE}"
                     }).click(function() {
                        $(this).prev().prev().removeClass('ajax-profil_hover').addClass('invisible').next().removeClass('invisible').append('<img src="http://2img.net/i/fa/invision/../valid.png" class="ajax-profil_valid" />').find('input,select');
                        $(this).prev().find('.ajax-profil_valid').attr({
                           alt: "{L_VALIDATE}",
                           title: "{L_VALIDATE}"
                        }).click(function() {
                           var content = new Array();
                           $(this).parent().find('[name]').each(function() {
                              var type_special = $(this).is('input[type=radio],input[type=checkbox]');
                              if ((type_special && $(this).is(':checked')) || !type_special) {
                                 content.push(new Array($(this).attr('name'), $(this).attr('value')));
                              }
                           });
                           var id_name = $(this).parents('[id^=JS_field_id]').attr('id');
                           var id = id_name.substring(11, id_name.length);
                           // console.log('id_name: ' + id_name + '\n' + 'id: ' + id);
                           $.post(
                              "/ajax_profile.forum?jsoncallback=?", {
                                 id: id,
                                 user: _userdata.user_id,
                                 active: "1",
                                 content: $.toJSON(content),
                                 tid: jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0];
                              },
                              function(data) {
                                 $.each(data, function(i, item) {
                                    $('[id=JS_field_id' + i + ']').find('.field_uneditable').html(item).end().find('.ajax-profil_valid').remove().end().find('.field_editable').addClass('invisible').end().find('.field_uneditable').removeClass('invisible');
                                 });
                              },
                              "json"
                           );
                        });
                        $(this).remove();
                     });
                  }
               }, function() {
                  if ($(this).find('.field_editable.invisible').is('span, div')) {
                     $(this).find('.field_editable').prev().removeClass('ajax-profil_hover');
                     $(this).find('.ajax-profil_edit').remove();
                  }
               });
            }
         });

      };
   }, 50);
}
Note: Change this value profile_field_XX_XX ] by the identifier that you found in step above!

Result:
IP-Address in Profile - Page 2 VmaFcO9

Restrictions?
Now we no longer have time constraint to obtain the IP!

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 13th 2014, 11:04 pm

It's working for me. I created an account and the ip that came out is my own. no errors or 127.0.0.1 till now.
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Solved Re: IP-Address in Profile

Post by Eugeo Igvalt December 13th 2014, 11:30 pm

Wait I take it back now I'm getting an IPV6 rather than V4
Eugeo Igvalt
Eugeo Igvalt
Forumember

Male Posts : 289
Reputation : 17
Language : EN, SPA
Location : Puerto Rico

http://www.NewbForums.com

Back to top Go down

Page 2 of 3 Previous  1, 2, 3  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum