4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: __G__ on January 29, 2007, 05:15:21 PM

Title: Register Ip
Post by: __G__ on January 29, 2007, 05:15:21 PM
hi can we record ip of people who registers the account on 4images ?
Title: Re: Register Ip
Post by: CeJay on January 30, 2007, 12:42:37 AM
There use to be a mod for this. I think from The Oracle?

I have not seen it in a while and can not find it.
Title: Re: Register Ip
Post by: trez on February 02, 2007, 06:32:40 PM
Well, just create a new field in your database and use for example

Code: [Select]
 
    $user_ip = $site_sess->user_ip;
    $additional_field_sql .= ", user_ip";
    $additional_value_sql .= ", '$user_ip'";

in your register.php ... of course you have to include it in your adminarea etc, but that wouldnt be difficult ;)
Title: Re: Register Ip
Post by: __G__ on February 02, 2007, 06:44:06 PM
bro i am not really a coder can u gimme instructions step by step please
Title: Re: Register Ip
Post by: trez on February 02, 2007, 06:50:10 PM
use the search for "additional user field", there was a large thread somewhere ... use "user_ip" as your new userfield. After you've done that open your register.php,
and find:

Code: [Select]
  if (!$error) {
    $additional_field_sql = "";
    $additional_value_sql = "";
    if (!empty($additional_user_fields)) {
      $table_fields = $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_field_sql .= ", $key";
          $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }

right after add:

Code: [Select]
    // IP Logging of new user
    $user_ip = $site_sess->user_ip;
    $additional_field_sql .= ", user_ip";
    $additional_value_sql .= ", '$user_ip'";

save it, and you should see the IP in the admin area under "edit user" (if you followed the thread for the add. user field)



Title: Re: Register Ip
Post by: __G__ on February 02, 2007, 09:42:08 PM
bro when i run the run it in php my admin it shows this

Error

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

ERROR: Unknown Punctuation String @ 22
STR: -&
SQL: $user_ip = $site_sess->user_ip

SQL query:

$user_ip = $site_sess->user_ip

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$user_ip = $site_sess->user_ip' at line 1
Title: Re: Register Ip
Post by: Acidgod on February 03, 2007, 09:28:23 AM
Well, just create a new field in your database

Do you have done it bevor?

Quote
$user_ip = $site_sess->user_ip

And this is not for phpmyamdin!!!

Title: Re: Register Ip
Post by: __G__ on February 03, 2007, 09:42:07 AM
how do we do that bro
Title: Re: Register Ip
Post by: Acidgod on February 03, 2007, 10:15:28 AM
Quote
ALTER TABLE `XXXX_users` ADD `user_ip` VARCHAR( 20 ) NOT NULL ;

Use the SQL Snippet (in phpmyadmin) to create a new Field (user_ip) in the User Table (rename XXXX_users)...

Good speed....
Title: Re: Register Ip
Post by: __G__ on February 05, 2007, 09:31:05 AM
i am still lost abt this database thingy :(
Title: Re: Register Ip
Post by: __G__ on February 07, 2007, 07:51:41 AM
 SQL query:

ALTER TABLE `XXXX_users` ADD `user_ip` VARCHAR( 20 ) NOT NULL


.XXXX_users' doesn't exist
Title: Re: Register Ip
Post by: impss on February 07, 2007, 03:41:15 PM
The XXXX is inteded for you to change.

Depending on what you use in your database.

I believe if you did not make any changes to that on install it would be 4Images_users

So then you would run:
Code: [Select]
ALTER TABLE `4Images_users` ADD `user_ip` VARCHAR( 20 ) NOT NULL ;
Title: Re: Register Ip
Post by: __G__ on February 07, 2007, 03:53:36 PM
wow thanks a lot >:D< it worked
Title: Re: Register Ip
Post by: __G__ on February 07, 2007, 04:02:03 PM
i did everything i dont see the ip :( Username    Email    Date of registration    Last activity    Options
   testaccount    lol@lol.com    07.02.2007 06:59    07.02.2007 06:59    

[Edit]  [Delete]    [Permissions]  [User Groups] 
Title: Re: Register Ip
Post by: Foto-Portal on February 08, 2007, 10:24:46 AM
hi erveryone.

its the same problem for me.
i can only see:

Username - Date - Date of registry - last action - options

???

thx for reply
Title: Re: Register Ip
Post by: trez on February 08, 2007, 02:36:33 PM
try

Code: [Select]
echo "<td>".$user_row['user_ip']."</td>\n";

in your admin/users.php

after that line

Code: [Select]
      echo "<td>".format_date($config['date_format']." ".$config['time_format'], $user_row[$user_table_fields['user_lastaction']])."</td>\n";
Title: Re: Register Ip
Post by: impss on February 08, 2007, 03:01:59 PM
Hey Trez,

I'm not a coder so I am not sure what you have above.

I have a feeling what they are missing is this

Open lang/english/main.php
Add this before the closing ?>
Code: [Select]
//-----------------------------------------------------
//--- Registration IP Address----------------------
//-----------------------------------------------------
$lang['registered_ip'] = "Ip Address on Registration";

Open /includes/db_field_definitions.php
Add this before the closing ?>
Code: [Select]
$additional_user_fields['user_ip'] = array($lang['registered_ip'], "text", 0);
Like I said Im still learning, So if this is not the right way to do this , please let me know.
It worked for me tho.
Title: Re: Register Ip
Post by: Loda on February 08, 2007, 04:35:58 PM
@trez: you forgot something..  :wink:
 :arrow: in admin/user find:
Code: [Select]
  if ($countusers['users'] > 0) {
    $sql = "SELECT ".USERS_TABLE.".".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_joindate").get_user_table_field(", ", "user_lastaction")."
replace it with this:
Code: [Select]
  if ($countusers['users'] > 0) {
    $sql = "SELECT ".USERS_TABLE.".".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_joindate").get_user_table_field(", ", "user_lastaction")." , user_ip
:arrow: then find:
Code: [Select]
    echo "<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_email']."</td>\n<td class=\"tableseparator\">".$lang['field_joindate']."</td>\n<td class=\"tableseparator\">".$lang['field_lastaction']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";
and replace it with this:
Code: [Select]
    echo "<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_email']."</td>\n<td class=\"tableseparator\">".$lang['field_joindate']."</td>\n<td class=\"tableseparator\">".$lang['field_lastaction']."</td>\n<td class=\"tableseparator\">".$lang['field_user_ip']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";
and then you go on with your steps...
 :arrow: and then add in your lang/admin.php:
Code: [Select]
$lang['field_user_ip'] = "IP Adress";
Title: Re: Register Ip
Post by: trez on February 08, 2007, 05:05:51 PM
Loda, your're right, i was in a rush ;)
Title: Re: Register Ip
Post by: impss on February 08, 2007, 06:45:36 PM
What i posted works to..

Can you explain if this is not a good way to do this?

Im still trying to learn

thanks
Title: Re: Register Ip
Post by: __G__ on February 08, 2007, 07:34:15 PM
it still don't show ip here r the files i edited