Afficher les adresses IP des Utilisateurs

Date 12/08/2010 | Sujet : Programmation, Hack, ...

Bonjour,

Je vous présente un Hack réalisé pour une version 2.4.5 Xoops.

Ces codes permettent de visualiser (seulement les admin) et de géolocaliser les adresse ip de vos membres.


Exécuter la requête suivante sur votre base via l'éditeur mysql

Attention: Nommer le préfixe correspondant au votre.
ALTER TABLE `xoops_users`
ADD `user_ipVARCHAR(100NOT NULL AFTER `user_avatar` ;


Fichier /userinfo.php, vers la ligne 88, après:

$xoopsTpl->assign('user_uid'$thisUser->getVar('uid'));
}

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT 1/3
$xoopsTpl->assign('uname'$thisUser->getVar('uname'));
$user_online = new XoopsUser($thisUser->getVar('uid'));
if (
$user_online->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}
// ADRESSE IP NULLOS FIN 1/3

Vers la ligne 145, après:
$xoopsTpl->assign('user_posts'$thisUser->getVar('posts'));
$xoopsTpl->assign('lang_lastlogin'_US_LASTLOGIN);

Vous ajoutez ceci:
//ADRESSE IP NULLOS DEBUT 2/3
$xoopsTpl->assign('lang_ip'_US_IP);
$xoopsTpl->assign('user_ip'$thisUser->getVar('user_ip'));
//ADRESSE IP NULLOS FIN 2/3

Vers la ligne 178, après:
if (! empty($date)) {
    
$xoopsTpl->assign('user_lastlogin'formatTimestamp($date"m"));
}

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT DE EN LIGNE ET HORS LIGNE 3/3
$user_online = new XoopsUser($thisUser->getVar('uid'));
if (
$user_online->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}
// ADRESSE IP NULLOS FIN EN LIGNE ET HORS LIGNE 3/3


Fichier /register.php, vers la ligne 197, après:

$xoopsMailer =& xoops_getMailer();
                
$xoopsMailer->reset();
                
$xoopsMailer->useMail();

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT
                
$xoopsMailer->setTemplate('newuser.tpl');
                
$xoopsMailer->assign('USERNAME'$uname);
                
$xoopsMailer->assign('USEREMAIL'$email);
                
$xoopsMailer->assign('USER_IP'$user_ip);
                
$xoopsMailer->assign('USEREMAILFROM'$_SERVER['REMOTE_ADDR']);
// ADRESSE IP NULLOS FIN


Fichier /include/checklogin.php, vers la ligne 105, après:

$notification_handler =& xoops_gethandler('notification');
    
$notification_handler->doLoginMaintenance($user->getVar('uid'));

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT
         
$lognom $user->getVar('uname');
         
$addip getenv("REMOTE_ADDR");
    
mysql_query("UPDATE ".$xoopsDB->prefix("users")." SET user_ip='$addip' WHERE uname='$lognom'");
// ADRESSE IP NULLOS FIN


Fichier /kernel/user.php, vers la ligne 65, après:

$this->initVar('user_regdate'XOBJ_DTYPE_INTnullfalse);

Vous ajoutez ceci:
//ADRESSE IP NULLOS 1/2 DEBUT
        
$this->initVar('user_ip'XOBJ_DTYPE_TXTBOXnullfalse100);
//ADRESSE IP NULLOS 2/2 FIN


Vers la ligne 311, après:

function user_avatar($format 'S')
    {
        return 
$this->getVar('user_avatar'$format);
    }

Vous ajoutez ceci:
// ADRESSE IP NULLOS 2/2 DEBUT
    
function user_ip($format="S")
    {
        return 
$this->getVar("user_ip");
    }
// ADRESSE IP NULLOS 2/2 FIN


Fichier /language/french/user.php, ajouter ceci:

// ADRESSE IP NULLOS
define("_US_IP","Dernière IP");


Création du fichier /language/french/mail_template/newuser.tpl et metter ceci:

Bonjour {X_UNAME},

Un nouveau membre vient de s'inscrire sur {SITENAME}.

Inscrit depuis le pc : {USEREMAILFROM} 
Pseudo: {USERNAME}
Surnom(s) : {NAME}
EMail : {USEREMAIL}

----------------------
Sincères salutations
{SITENAME} ({SITEURL})
Le Webmaster : {ADMINMAIL}


Fichier /modules/system/admin/findusers/main.php, vers la ligne 59, après:

$name_tray->addElement($name_text);

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT 1/2
    
$ip_text = new XoopsFormText("""user_ip"3060);
    
$ip_match = new XoopsFormSelectMatchOption("""user_ip_match");
    
$ip_tray = new XoopsFormElementTray(_AM_IP" ");
    
$ip_tray->addElement($ip_match);
    
$ip_tray->addElement($ip_text);
// ADRESSE IP NULLOS DEBUT 1/2


Vers la ligne 194, après:

case XOOPS_MATCH_CONTAIN:
            
$criteria->add(new Criteria('name''%'.$myts->addSlashes(trim($_POST['user_name'])).'%''LIKE'));
            break;
        }
    }

Vous ajoutez ceci:
// ADRESSE IP NULLOS DEBUT 2/2
    
if ( !empty($HTTP_POST_VARS['user_ip']) ) {
        
$match = (!empty($HTTP_POST_VARS['user_ip_match'])) ? intval($HTTP_POST_VARS['user_ip_match']) : XOOPS_MATCH_START;
        switch (
$match) {
        case 
XOOPS_MATCH_START:
            
$criteria->add(new Criteria('user_ip'$myts->addSlashes(trim($HTTP_POST_VARS['user_ip'])).'%''LIKE'));
            break;
        case 
XOOPS_MATCH_END:
            
$criteria->add(new Criteria('user_ip''%'.$myts->addSlashes(trim($HTTP_POST_VARS['user_ip'])).'%''LIKE'));
            break;
        case 
XOOPS_MATCH_EQUAL:
            
$criteria->add(new Criteria('user_ip'$myts->addSlashes(trim($HTTP_POST_VARS['user_ip']))));
            break;
        case 
XOOPS_MATCH_CONTAIN:
            
$criteria->add(new Criteria('user_ip''%'.$myts->addSlashes(trim($HTTP_POST_VARS['user_ip'])).'%''LIKE'));
            break;
        }
    }
// ADRESSE IP NULLOS FIN 2/2


Fichier /modules/system/language/french/admin/findusers.php, ajoutez ceci:

// ADRESSE IP NULLOS
define("_AM_IP","Dernière IP");


Fichier /modules/system/templates/system_userinfo.html, Remplacer ces lignes:

<tr valign="top">
          <
td class="head"><{$lang_lastlogin}></td>
          <
td align="center" class="odd"><{$user_lastlogin}><br />

Par celles-ci:
<!-- ADRESSE IP NULLOS DEBUT -->
<{if 
$user_online == true}>
    <
tr valign="top">
          <
td class="head"><{$lang_lastlogin}></td>
          <
td align="center" class="odd"><{$user_lastlogin}><br />
          <
img src='<{$xoops_url}>/uploads/online.gif' /></td>         
        </
tr>
<{else}>
    <
tr valign="top">
          <
td class="head"><{$lang_lastlogin}></td>
          <
td align="center" class="odd"><{$user_lastlogin}><br />
          <
img src='<{$xoops_url}>/uploads/offline.gif' /></td>
        </
tr>
<{/if}>
<{if 
$xoops_isadmin}>
          <
tr valign="top">
          <
td class="head"><{$lang_ip}></td>
         <
td align="center" class="odd"><a href="http://www.ip-adress.com/ip_tracer/<{$user_ip}>" target="_blank"><{$user_ip}></a></td>
        </
tr>
<{else}>
          <
tr valign="top">
          <
td class="head"><{$lang_ip}></td>
          <
td align="center" class="odd"><a>Visible seulement par le Webmaster</a></td>
        </
tr>
<{/if}>
<!-- 
ADRESSE IP NULLOS FIN -->


Surtout, ne pas oublier de modifier le fichier system_userinfo.html de votre thème par défaut, si vous en avez un personalisé.

Pour conclure, dans le dossier uploads, déposer ces deux fichiers images:

offline.gif


et online.gif


Bien entendu, je laisse nos amis anglophones la charge de l'adaptation des fichiers language.

Je remercie particulièrement Titi "RC78" pour son travail



Cet article provient de Communauté Francophone des Utilisateurs de Xoops
https://www.frxoops.org

L'adresse de cet article est :
https://www.frxoops.org/modules/news/article.php?storyid=1784