$filter->_date_max = CMbDT::dateTime($filter->date);
$filter->_date_min = CMbDT::dateTime("-1 week", $filter->date);
$filter->user_id = CValue::get("user_id");
$filter->ip_address = CValue::get("ip_address", "255.255.255.255");
$order_col = CValue::getOrSession("order_col", "date_max");
$order_way = CValue::getOrSession("order_way", "DESC");
$order_way_alt = $order_way == "ASC" ? "DESC" : "ASC";
$user = new CMediusers();
$listUsers = $user->loadUsers();
$where = array("ip_address IS NOT NULL AND ip_address != ''");
$where[] = "date >= '{$filter->_date_min}'";
$where[] = "date <= '{$filter->_date_max}'";
$where[] = "user_id " . CSQLDataSource::prepareIn(array_keys($listUsers), $filter->user_id);
$order = "{$order_col} {$order_way}";
$group = "ip_address";
$total_list_count = $filter->countMultipleList($where, $order, $group, null, array("ip_address", "MAX(date) AS date_max, GROUP_CONCAT(DISTINCT user_id SEPARATOR '|') AS user_list"));
foreach ($total_list_count as $key => $_log) {
    if (inet_ntop($_log["ip_address"]) != inet_ntop($_log["ip_address"] & inet_pton($filter->ip_address))) {
        unset($total_list_count[$key]);
    }
}
$total_list = array_slice($total_list_count, $start, 30);
foreach ($total_list as &$_log) {
    $_log["ip"] = inet_ntop($_log["ip_address"]);
    $_log["ip_explode"] = explode(".", $_log["ip"]);
    $list_users = explode("|", $_log["user_list"]);
    $_log["users"] = array();
    foreach ($list_users as $_user_id) {
        if (isset($listUsers[$_user_id])) {
            $_log["users"][$_user_id] = $listUsers[$_user_id];
        }
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
$user_id = CValue::get("user_id");
$date = CValue::get("date");
$object_class = CValue::get("object_class");
$fields = CValue::get("fields");
$user_log = new CUserLog();
$where = array("object_class" => "= '{$object_class}'");
if ($user_id) {
    $where["user_id"] = " = '{$user_id}'";
}
if ($date) {
    $where["date"] = ">= '{$date}'";
}
$where["type"] = "= 'store'";
if ($fields) {
    $whereField = array();
    foreach ($fields as $_field) {
        $whereField[] = "\r\n      fields LIKE '{$_field} %' OR \r\n      fields LIKE '% {$_field} %' OR \r\n      fields LIKE '% {$_field}' OR \r\n      fields LIKE '{$_field}'";
    }
    $where[] = implode(" OR ", $whereField);
}
$count = count($user_log->countMultipleList($where, "date ASC", "object_id"));
echo $count;
CApp::rip();