1) Добавить столбец в базу SQL через PHP myADMin ALTER TABLE `jos_users` ADD `registerIp` VARCHAR( 15 ) NOT NULL AFTER `gid` ;
*****************************************************************************
2)libraries/joomla/database/table/user.php/**
* The login name
*
* @var string
*/
var $username = null;
// -- Добавить код --> var $registerIp = null;
//-- ************ -->...
*****************************************************************************
3)Добавление скрытого поля в регистрациюcomponents/com_user/views/register/tmpl/default.php
...
<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" method="post" id="josForm" name="josForm" class="form-validate">
<?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>"><?php echo $this->escape($this->params->get('page_title')); ?></div>
<?php endif; ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
<tr>
<td width="30%" height="40">
<label id="namemsg" for="name">
<?php echo JText::_( 'Name' ); ?>:
</label>
</td>
<td>
<input type="text" name="name" id="name" size="40" value="<?php echo $this->escape($this->user->get( 'name' ));?>" class="inputbox required" maxlength="50" /> *
</td>
</tr>
<!-- Добавить код --> <input type="hidden" name="registerIp" id="registerIp" size="40" value="<?PHP print($_SERVER['REMOTE_ADDR']); ?>" class="inputbox required" maxlength="15" />
<!-- ************ --><tr>
...
*****************************************************************************
4)Админка, добавление столбца RegisterIpadministrator/components/com_users/views/users/tmpl/default.php
<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php JHTML::_('behavior.tooltip'); ?>
<?php
JToolBarHelper::title( JText::_( 'User Manager' ), 'user.png' );
JToolBarHelper::custom( 'logout', 'cancel.png', 'cancel_f2.png', 'Logout' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
JToolBarHelper::help( 'screen.users' );
?>
<form action="index.php?option=com_users" method="post" name="adminForm">
<table>
<tr>
<td width="100%">
<?php echo JText::_( 'Filter' ); ?>:
<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($this->lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_type').value='0';this.form.getElementById('filter_logged').value='0';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
</td>
<td nowrap="nowrap">
<?php echo $this->lists['type'];?>
<?php echo $this->lists['logged'];?>
</td>
</tr>
</table>
<table class="adminlist" cellpadding="1">
<thead>
<tr>
<th width="2%" class="title">
<?php echo JText::_( 'NUM' ); ?>
</th>
<th width="3%" class="title">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
</th>
<th class="title">
<?php echo JHTML::_('grid.sort', 'Name', 'a.name', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="15%" class="title" >
<?php echo JHTML::_('grid.sort', 'Username', 'a.username', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="5%" class="title" nowrap="nowrap">
<?php echo JText::_( 'Logged In' ); ?>
</th>
<th width="5%" class="title" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'Enabled', 'a.block', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="15%" class="title">
<?php echo JHTML::_('grid.sort', 'Group', 'groupname', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="15%" class="title">
<?php echo JHTML::_('grid.sort', 'E-Mail', 'a.email', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="10%" class="title">
<?php echo JHTML::_('grid.sort', 'Last Visit', 'a.lastvisitDate', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<!-- Добавить код --> <th width="11%" class="title" >
<?php echo JHTML::_('grid.sort', 'RegisterIp', 'a.registerIp', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<!-- ************ --> <th width="1%" class="title" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'ID', 'a.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="10">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
{
$row =& $this->items[$i];
$img = $row->block ? 'publish_x.png' : 'tick.png';
$task = $row->block ? 'unblock' : 'block';
$alt = $row->block ? JText::_( 'Enabled' ) : JText::_( 'Blocked' );
$link = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->id. '';
if ($row->lastvisitDate == "0000-00-00 00:00:00") {
$lvisit = JText::_( 'Never' );
} else {
$lvisit = JHTML::_('date', $row->lastvisitDate, '%Y-%m-%d %H:%M:%S');
}
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $i+1+$this->pagination->limitstart;?>
</td>
<td>
<?php echo JHTML::_('grid.id', $i, $row->id ); ?>
</td>
<td>
<a href="<?php echo $link; ?>">
<?php echo $row->name; ?></a>
</td>
<td>
<?php echo $row->username; ?>
</td>
<td align="center">
<?php echo $row->loggedin ? '<img src="images/tick.png" width="16" height="16" border="0" alt="" />': ''; ?>
</td>
<td align="center">
<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')">
<img src="images/<?php echo $img;?>" width="16" height="16" border="0" alt="<?php echo $alt; ?>" /></a>
</td>
<td>
<?php echo JText::_( $row->groupname ); ?>
</td>
<td>
<a href="mailto:<?php echo $row->email; ?>">
<?php echo $row->email; ?></a>
</td>
<td nowrap="nowrap">
<?php echo $lvisit; ?>
</td>
<!-- Добавить код --> <td>
<?php echo $row->registerIp; ?>
</td>
<!-- ************ --> <td>
<?php echo $row->id; ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</tbody>
</table>
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
*********************************************************************
5)Чтоб пользователи не меняли IP самиcomponents/com_user/controller.php
// we don't want users to edit certain fields so we will unset them
unset($post['gid']);
unset($post['block']);
unset($post['usertype']);
unset($post['registerDate']);
unset($post['activation']);
// -- Добавить код --> unset($post['registerIp']);
// -- ************ -->*************************************************************************************************************
*************************************************************************************************************
*************************************************************************************************************
Блокировка регистрации по IP если нужно\libraries\joomla\database\table\use.php
...
// check for existing username
$query = 'SELECT id'
. ' FROM #__users '
. ' WHERE username = ' . $this->_db->Quote($this->username)
. ' AND id != '. (int) $this->id;
;
$this->_db->setQuery( $query );
$xid = intval( $this->_db->loadResult() );
if ($xid && $xid != intval( $this->id )) {
$this->setError( JText::_('WARNREG_INUSE'));
return false;
}
//-- Добавить код --> //проверка если такой Ip
$query = 'SELECT id'
. ' FROM #__users '
. ' WHERE registerIp = ' . $this->_db->Quote($this->registerIp)
. ' AND id != '. (int) $this->id;
;
$this->_db->setQuery( $query );
$xid = intval( $this->_db->loadResult() );
if ($xid && $xid != intval( $this->id )) {
$this->setError( JText::_('WARNREG_REGISTERIP'));
return false;
}
// -- ************ --> // check for existing email
...
*****************************************************************************************
Добовляем оповещение\language\ru-RU\ru-RU.ini
WARNREG_REGISTERIP=Этот IP адрес уже используется другим пользователем.
\language\en-GB\en-GB.ini
WARNREG_REGISTERIP=This IP address is used by another user.
