Example #1
0
/**
 * Generates comments display for a given item
 *
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param bool $force_admin Enforces user to be administrator of comments for this item.
 *	E.g. to moderate his wall even if he is not a moderator
 * @return string Rendered HTML output for comments
 * @global CotDB $db
 */
function cot_comments_display($ext_name, $code, $cat = '', $force_admin = false)
{
    global $db, $db_com, $db_users, $cfg, $usr, $L, $sys, $R, $env, $pg, $cot_extrafields, $cache, $structure;
    // Check permissions and enablement
    list($auth_read, $auth_write, $auth_admin) = cot_auth('plug', 'comments');
    if ($auth_read && $auth_write && $force_admin) {
        $auth_admin = true;
        $_SESSION['cot_comments_force_admin'][$ext_name][$code] = true;
    }
    $enabled = cot_comments_enabled($ext_name, $cat, $code);
    if (!$auth_read || !$enabled && !$auth_admin) {
        return '';
    }
    $comments_join_columns = $comments_join_tables = $comments_join_where = '';
    // Get the URL and parameters
    $link_area = $env['ext'];
    $link_params = $_GET;
    if (defined('COT_PLUG')) {
        $link_area = 'plug';
        $link_params['e'] = $env['ext'];
    }
    if (isset($_GET['rwr'])) {
        unset($link_params['rwr'], $link_params['e']);
    }
    $cot_com_back = array($link_area, $link_params);
    $_SESSION['cot_com_back'][$ext_name][$cat][$code] = $cot_com_back;
    $d_var = 'dcm';
    list($pg, $d, $durl) = cot_import_pagenav($d_var, $cfg['plugin']['comments']['maxcommentsperpage']);
    $d = empty($d) ? 0 : (int) $d;
    if ($auth_write && $enabled) {
        require_once cot_incfile('forms');
    }
    $t = new XTemplate(cot_tplfile('comments', 'plug'));
    /* == Hook == */
    foreach (cot_getextplugins('comments.main') as $pl) {
        include $pl;
    }
    /* ===== */
    $editor = cot::$cfg['plugin']['comments']['markup'] ? 'input_textarea_minieditor' : '';
    $t->assign(array('COMMENTS_CODE' => $code, 'COMMENTS_FORM_SEND' => cot_url('plug', "e=comments&a=send&area={$ext_name}&cat={$cat}&item={$code}"), 'COMMENTS_FORM_AUTHOR' => $usr['id'] > 0 ? $usr['name'] : cot_inputbox('text', 'rname'), 'COMMENTS_FORM_AUTHORID' => $usr['id'], 'COMMENTS_FORM_TEXT' => $auth_write && $enabled ? cot_textarea('rtext', $rtext, 7, 120, '', $editor) . cot_inputbox('hidden', 'cb', base64_encode(serialize($cot_com_back))) : '', 'COMMENTS_DISPLAY' => $cfg['plugin']['comments']['expand_comments'] ? '' : 'none'));
    if ($auth_write && $enabled) {
        // Extra fields
        if (!empty(cot::$extrafields[cot::$db->com])) {
            foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                $uname = strtoupper($exfld['field_name']);
                $exfld_val = cot_build_extrafields('rcomments' . $exfld['field_name'], $exfld, $rcomments[$exfld['field_name']]);
                $exfld_title = cot_extrafield_title($exfld, 'comments_');
                $t->assign(array('COMMENTS_FORM_' . $uname => $exfld_val, 'COMMENTS_FORM_' . $uname . '_TITLE' => $exfld_title, 'COMMENTS_FORM_EXTRAFLD' => $exfld_val, 'COMMENTS_FORM_EXTRAFLD_TITLE' => $exfld_title));
                $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.EXTRAFLD');
            }
        }
        $allowed_time = cot_build_timegap($sys['now'] - $cfg['plugin']['comments']['time'] * 60, $sys['now']);
        $com_hint = cot_rc('com_edithint', array('time' => $allowed_time));
        /* == Hook == */
        foreach (cot_getextplugins('comments.newcomment.tags') as $pl) {
            include $pl;
        }
        /* ===== */
        $usr['id'] == 0 && $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.GUEST');
        if ($usr['id'] == 0 && cot_check_messages() && $cache) {
            if ($ext_name == 'page' && $cfg['cache_page']) {
                $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$cat]['path']));
                $cfg['cache_page'] = false;
            }
        }
        cot_display_messages($t, 'COMMENTS.COMMENTS_NEWCOMMENT');
        $t->assign('COMMENTS_FORM_HINT', $com_hint);
        $t->parse('COMMENTS.COMMENTS_NEWCOMMENT');
    } else {
        $warning = $enabled ? $L['com_regonly'] : $L['com_closed'];
        $t->assign('COMMENTS_CLOSED', $warning);
        $t->parse('COMMENTS.COMMENTS_CLOSED');
    }
    $order = $cfg['plugin']['comments']['order'] == 'Chronological' ? 'ASC' : 'DESC';
    $comments_order = "com_id {$order}";
    /* == Hook == */
    foreach (cot_getextplugins('comments.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT c.*, u.* {$comments_join_columns}\n\t\tFROM {$db_com} AS c LEFT JOIN {$db_users} AS u ON u.user_id = c.com_authorid {$comments_join_tables}\n\t\tWHERE com_area = ? AND com_code = ? {$comments_join_where} ORDER BY {$comments_order} LIMIT ?, ?", array($ext_name, $code, (int) $d, (int) $cfg['plugin']['comments']['maxcommentsperpage']));
    if ($sql->rowCount() > 0 && $enabled) {
        $i = $d;
        $kk = 0;
        $totalitems = cot_comments_count($ext_name, $code);
        /* === Hook - Part1 : Set === */
        $extp = cot_getextplugins('comments.loop');
        /* ===== */
        foreach ($sql->fetchAll() as $row) {
            $i++;
            $kk++;
            $com_admin = $auth_admin ? cot_rc('comments_code_admin', array('ipsearch' => cot_build_ipsearch($row['com_authorip']), 'delete_url' => cot_confirm_url(cot_url('plug', 'e=comments&a=delete&cat=' . $cat . '&id=' . $row['com_id'] . '&' . cot_xg()), 'comments', 'comments_confirm_delete'))) : '';
            $com_text = cot_parse($row['com_text'], $cfg['plugin']['comments']['markup']);
            $time_limit = $sys['now'] < $row['com_date'] + $cfg['plugin']['comments']['time'] * 60 ? TRUE : FALSE;
            $usr['isowner_com'] = $time_limit && ($usr['id'] > 0 && $row['com_authorid'] == $usr['id'] || $usr['id'] == 0 && !empty($_SESSION['cot_comments_edit'][$row['com_id']]) && $usr['ip'] == $row['com_authorip']);
            $com_gup = $sys['now'] - ($row['com_date'] + $cfg['plugin']['comments']['time'] * 60);
            $allowed_time = $usr['isowner_com'] && !$usr['isadmin'] ? ' - ' . cot_build_timegap($sys['now'] + $com_gup, $sys['now']) . $L['plu_comgup'] : '';
            $com_edit = $auth_admin || $usr['isowner_com'] ? cot_rc('comments_code_edit', array('edit_url' => cot_url('plug', 'e=comments&m=edit&cat=' . $cat . '&id=' . $row['com_id']), 'allowed_time' => $allowed_time)) : '';
            if ($row['com_area'] == 'page') {
                if ($usr['id'] == 0 && $usr['isowner_com'] && $cfg['cache_page']) {
                    $cfg['cache_page'] = $cfg['cache_index'] = false;
                }
            }
            $t->assign(array('COMMENTS_ROW_ID' => $row['com_id'], 'COMMENTS_ROW_ORDER' => $cfg['plugin']['comments']['order'] == 'Recent' ? $totalitems - $i + 1 : $i, 'COMMENTS_ROW_URL' => cot_url($link_area, $link_params, '#c' . $row['com_id']), 'COMMENTS_ROW_AUTHOR' => cot_build_user($row['com_authorid'], htmlspecialchars($row['com_author'])), 'COMMENTS_ROW_AUTHORID' => $row['com_authorid'], 'COMMENTS_ROW_TEXT' => $com_text, 'COMMENTS_ROW_DATE' => cot_date('datetime_medium', $row['com_date']), 'COMMENTS_ROW_DATE_STAMP' => $row['com_date'], 'COMMENTS_ROW_ADMIN' => $com_admin, 'COMMENTS_ROW_EDIT' => $com_edit, 'COMMENTS_ROW_ODDEVEN' => cot_build_oddeven($kk), 'COMMENTS_ROW_NUM' => $kk));
            // Extrafields
            if (!empty(cot::$extrafields[cot::$db->com])) {
                foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                    $tag = mb_strtoupper($exfld['field_name']);
                    $exfld_title = cot_extrafield_title($exfld, 'comments_');
                    $t->assign(array('COMMENTS_ROW_' . $tag . '_TITLE' => $exfld_title, 'COMMENTS_ROW_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'COMMENTS_ROW_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
                }
            }
            $t->assign(cot_generate_usertags($row, 'COMMENTS_ROW_AUTHOR_', htmlspecialchars($row['com_author'])));
            /* === Hook - Part2 : Include === */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('COMMENTS.COMMENTS_ROW');
        }
        $pagenav = cot_pagenav($link_area, $link_params, $d, $totalitems, $cfg['plugin']['comments']['maxcommentsperpage'], $d_var, '#comments', $cfg['jquery'] && $cfg['ajax_enabled'], 'comments', 'plug', "e=comments&area={$ext_name}&cat={$cat}&item={$code}");
        $t->assign(array('COMMENTS_PAGES_INFO' => cot_rc('comments_code_pages_info', array('totalitems' => $totalitems, 'onpage' => $i - $d)), 'COMMENTS_PAGES_TOTALITEMS' => $totalitems, 'COMMENTS_PAGES_PAGESPREV' => $pagenav['prev'], 'COMMENTS_PAGES_PAGNAV' => $pagenav['main'], 'COMMENTS_PAGES_PAGESNEXT' => $pagenav['next']));
        $t->parse('COMMENTS.PAGNAVIGATOR');
    } elseif (!$sql->rowCount() && $enabled) {
        $t->assign(array('COMMENTS_EMPTYTEXT' => $L['com_nocommentsyet']));
        $t->parse('COMMENTS.COMMENTS_EMPTY');
    }
    /* == Hook == */
    foreach (cot_getextplugins('comments.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('COMMENTS');
    $res_display = $t->text('COMMENTS');
    return $res_display;
}
Example #2
0
/* ===== */
$fp_num = 0;
foreach ($sql_forums->fetchAll() as $row) {
    $row['user_text'] = $cfg['forums']['cat_' . $s]['allowusertext'] ? $row['user_text'] : '';
    $fp_num++;
    $rowquote_url = $usr['id'] > 0 ? cot_url('forums', 'm=posts&s=' . $s . '&q=' . $q . '&quote=' . $row['fp_id'] . '&d=' . $durl . '&n=last', '#np') : '';
    $rowquote = $usr['id'] > 0 ? cot_rc('forums_rowquote', array('url' => $rowquote_url)) : '';
    $rowedit_url = ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) && $usr['id'] > 0 ? cot_url('forums', 'm=editpost&s=' . $s . '&q=' . $q . '&p=' . $row['fp_id'] . '&d=' . $durl . '&' . cot_xg()) : '';
    $rowedit = ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) && $usr['id'] > 0 ? cot_rc('forums_rowedit', array('url' => $rowedit_url)) : '';
    $rowdelete_url = $usr['id'] > 0 && ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) ? cot_confirm_url(cot_url('forums', 'm=posts&a=delete&' . cot_xg() . '&s=' . $s . '&q=' . $q . '&p=' . $row['fp_id'] . '&d=' . $durl), 'forums', 'forums_confirm_delete_post') : '';
    $rowdelete = $usr['id'] > 0 && ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600) && $fp_num > 1) ? cot_rc('forums_rowdelete', array('url' => $rowdelete_url)) : '';
    if (!empty($row['fp_updater'])) {
        $row['fp_updatedby'] = sprintf($L['forums_updatedby'], htmlspecialchars($row['fp_updater']), cot_date('datetime_medium', $row['fp_updated']), cot_build_timegap($row['fp_updated'], $sys['now']));
    }
    $t->assign(cot_generate_usertags($row, 'FORUMS_POSTS_ROW_USER'));
    $t->assign(array('FORUMS_POSTS_ROW_ID' => $row['fp_id'], 'FORUMS_POSTS_ROW_POSTID' => 'post_' . $row['fp_id'], 'FORUMS_POSTS_ROW_IDURL' => cot_url('forums', 'm=posts&id=' . $row['fp_id']), 'FORUMS_POSTS_ROW_URL' => cot_url('forums', 'm=posts&q=' . $row['fp_topicid'] . '&d=' . $durl, "#" . $row['fp_id']), 'FORUMS_POSTS_ROW_CREATION' => cot_date('datetime_medium', $row['fp_creation']), 'FORUMS_POSTS_ROW_CREATION_STAMP' => $row['fp_creation'], 'FORUMS_POSTS_ROW_UPDATED' => cot_date('datetime_medium', $row['fp_updated']), 'FORUMS_POSTS_ROW_UPDATED_STAMP' => $row['fp_updated'], 'FORUMS_POSTS_ROW_UPDATER' => htmlspecialchars($row['fp_updater']), 'FORUMS_POSTS_ROW_UPDATEDBY' => $row['fp_updatedby'], 'FORUMS_POSTS_ROW_TEXT' => cot_parse($row['fp_text'], $cfg['forums']['markup'] && $cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_POSTS_ROW_ANCHORLINK' => cot_rc('forums_code_post_anchor', array('id' => $row['fp_id'])), 'FORUMS_POSTS_ROW_POSTERNAME' => cot_build_user($row['fp_posterid'], htmlspecialchars($row['fp_postername'])), 'FORUMS_POSTS_ROW_POSTERID' => $row['fp_posterid'], 'FORUMS_POSTS_ROW_POSTERIP' => $usr['isadmin'] ? cot_build_ipsearch($row['fp_posterip']) : '', 'FORUMS_POSTS_ROW_DELETE' => $rowdelete, 'FORUMS_POSTS_ROW_DELETE_URL' => $rowdelete_url, 'FORUMS_POSTS_ROW_EDIT' => $rowedit, 'FORUMS_POSTS_ROW_EDIT_URL' => $rowedit_url, 'FORUMS_POSTS_ROW_QUOTE' => $rowquote, 'FORUMS_POSTS_ROW_QUOTE_URL' => $rowquote_url, 'FORUMS_POSTS_ROW_BOTTOM' => (empty($id) ? $d + $fp_num : $id) == $totalposts ? $R['forums_code_bottom'] : ($usr['id'] > 0 && $n == 'unread' && $row['fp_creation'] > $usr['lastvisit'] ? $R['forums_code_unread'] : ''), 'FORUMS_POSTS_ROW_ODDEVEN' => cot_build_oddeven($fp_num), 'FORUMS_POSTS_ROW_NUM' => $fp_num, 'FORUMS_POSTS_ROW_ORDER' => empty($id) ? $d + $fp_num : $id));
    foreach ($cot_extrafields[$db_forum_posts] as $exfld) {
        $tag = mb_strtoupper($exfld['field_name']);
        $t->assign(array('FORUMS_POSTS_ROW_' . $tag . '_TITLE' => isset($L['forums_posts_' . $exfld['field_name'] . '_title']) ? $L['forums_posts_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'FORUMS_POSTS_ROW_' . $tag => cot_build_extrafields_data('forums', $exfld, $row['fp_' . $exfld['field_name']], $cfg['forums']['markup'] && $cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_POSTS_ROW_' . $tag . '_VALUE' => $row['fp_' . $exfld['field_name']]));
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.FORUMS_POSTS_ROW');
}
$lastpage = $d + $cfg['forums']['maxpostsperpage'] < $totalposts ? FALSE : TRUE;
$pagenav = cot_pagenav('forums', "m=posts&q={$q}", $d, $totalposts, $cfg['forums']['maxpostsperpage']);
$jumpbox[cot_url('forums')] = $L['Forums'];
foreach ($structure['forums'] as $key => $val) {
Example #3
0
$title_params = array('EDIT' => $L['Edit'], 'NAME' => $urr['user_name']);
$out['subtitle'] = cot_title('{EDIT} - {NAME}', $title_params);
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('users', 'edit', $usr['maingrp']), 'module');
/* === Hook === */
foreach (cot_getextplugins('users.edit.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
require_once cot_incfile('forms');
$protected = $sys['protecttopadmin'] ? array('disabled' => 'disabled') : array();
$editor_class = $cfg['users']['usertextimg'] ? 'minieditor' : '';
$delete_pfs = cot_module_active('pfs') ? cot_checkbox(false, 'ruserdelpfs', $L['PFS']) : '';
$t->assign(array('USERS_EDIT_TITLE' => cot_breadcrumbs(array(array(cot_url('users'), $L['Users']), array(cot_url('users', 'm=details&id=' . $urr['user_id'] . '&u=' . $urr['user_name']), $urr['user_name']), array(cot_url('users', 'm=edit&id=' . $urr['user_id']), $L['Edit'])), $cfg['homebreadcrumb']), 'USERS_EDIT_DETAILSLINK' => cot_url('users', 'm=details&id=' . $urr['user_id']), 'USERS_EDIT_EDITLINK' => cot_url('users', 'm=edit&id=' . $urr['user_id']), 'USERS_EDIT_SUBTITLE' => $L['useed_subtitle'], 'USERS_EDIT_SEND' => cot_url('users', 'm=edit&a=update&' . cot_xg() . '&id=' . $urr['user_id']), 'USERS_EDIT_ID' => $urr['user_id'], 'USERS_EDIT_NAME' => cot_inputbox('text', 'rusername', $urr['user_name'], array('size' => 32, 'maxlength' => 100) + $protected), 'USERS_EDIT_ACTIVE' => $user_form_active, 'USERS_EDIT_BANNED' => $user_form_banned, 'USERS_EDIT_THEME' => cot_inputbox('text', 'rusertheme', $urr['user_theme'], array('size' => 32, 'maxlength' => 32)), 'USERS_EDIT_LANG' => cot_inputbox('text', 'ruserlang', $urr['user_lang'], array('size' => 32, 'maxlength' => 32)), 'USERS_EDIT_NEWPASS' => cot_inputbox('password', 'rusernewpass', '', array('size' => 12, 'maxlength' => 32, 'autocomplete' => 'off') + $protected), 'USERS_EDIT_MAINGRP' => cot_build_group($urr['user_maingrp']), 'USERS_EDIT_GROUPS' => cot_build_groupsms($urr['user_id'], $usr['isadmin'], $urr['user_maingrp']), 'USERS_EDIT_COUNTRY' => cot_selectbox_countries($urr['user_country'], 'rusercountry'), 'USERS_EDIT_EMAIL' => cot_inputbox('text', 'ruseremail', $urr['user_email'], array('size' => 32, 'maxlength' => 64)), 'USERS_EDIT_HIDEEMAIL' => cot_radiobox($urr['user_hideemail'], 'ruserhideemail', array(1, 0), array($L['Yes'], $L['No'])), 'USERS_EDIT_TEXT' => cot_textarea('rusertext', $urr['user_text'], 4, 56, array('class' => $editor_class)), 'USERS_EDIT_GENDER' => cot_selectbox_gender($urr['user_gender'], 'rusergender'), 'USERS_EDIT_BIRTHDATE' => cot_selectbox_date(cot_date2stamp($urr['user_birthdate']), 'short', 'ruserbirthdate', cot_date('Y', $sys['now']), cot_date('Y', $sys['now']) - 100, false), 'USERS_EDIT_TIMEZONE' => cot_selectbox_timezone($urr['user_timezone'], 'rusertimezone'), 'USERS_EDIT_REGDATE' => cot_date('datetime_medium', $urr['user_regdate']), 'USERS_EDIT_REGDATE_STAMP' => $urr['user_regdate'], 'USERS_EDIT_LASTLOG' => cot_date('datetime_medium', $urr['user_lastlog']), 'USERS_EDIT_LASTLOG_STAMP' => $urr['user_lastlog'], 'USERS_EDIT_LOGCOUNT' => $urr['user_logcount'], 'USERS_EDIT_LASTIP' => cot_build_ipsearch($urr['user_lastip']), 'USERS_EDIT_DELETE' => $sys['user_istopadmin'] ? cot_radiobox(0, 'ruserdelete', array(1, 0), array($L['Yes'], $L['No'])) . $delete_pfs : $L['na']));
// Extra fields
foreach ($cot_extrafields[$db_users] as $exfld) {
    $tag = strtoupper($exfld['field_name']);
    $t->assign(array('USERS_EDIT_' . $tag => cot_build_extrafields('ruser' . $exfld['field_name'], $exfld, $urr['user_' . $exfld['field_name']]), 'USERS_EDIT_' . $tag . '_TITLE' => isset($L['user_' . $exfld['field_name'] . '_title']) ? $L['user_' . $exfld['field_name'] . '_title'] : $exfld['field_description']));
}
// Error and message reporting
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('users.edit.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse('MAIN');
$t->out('MAIN');
require_once $cfg['system_dir'] . '/footer.php';
Example #4
0
    $ipmask1 = $userip[0] . "." . $userip[1] . "." . $userip[2] . "." . $userip[3];
    $ipmask2 = $userip[0] . "." . $userip[1] . "." . $userip[2];
    $ipmask3 = $userip[0] . "." . $userip[1];
    $res_host = @gethostbyaddr($id);
    $res_dns = $res_host == $id ? 'Unknown' : $res_host;
    $sql = $db->query("SELECT user_id, user_name, user_lastip FROM {$db_users} WHERE user_lastip='{$ipmask1}' ");
    $totalmatches1 = $sql->rowCount();
    while ($row = $sql->fetch()) {
        $t->assign(array('IPSEARCH_USER_IPMASK1' => cot_build_user($row['user_id'], htmlspecialchars($row['user_name'])), 'IPSEARCH_USER_LASTIP_IPMASK1' => cot_build_ipsearch($row['user_lastip'])));
        $t->parse('MAIN.IPSEARCH_RESULTS.IPSEARCH_IPMASK1');
    }
    $sql->closeCursor();
    $sql = $db->query("SELECT user_id, user_name, user_lastip FROM {$db_users} WHERE user_lastip LIKE '{$ipmask2}.%' ");
    $totalmatches2 = $sql->rowCount();
    while ($row = $sql->fetch()) {
        $t->assign(array('IPSEARCH_USER_IPMASK2' => cot_build_user($row['user_id'], htmlspecialchars($row['user_name'])), 'IPSEARCH_USER_LASTIP_IPMASK2' => cot_build_ipsearch($row['user_lastip'])));
        $t->parse('MAIN.IPSEARCH_RESULTS.IPSEARCH_IPMASK2');
    }
    $sql->closeCursor();
    $sql = $db->query("SELECT user_id, user_name, user_lastip FROM {$db_users} WHERE user_lastip LIKE '{$ipmask3}.%.%' ");
    $totalmatches3 = $sql->rowCount();
    while ($row = $sql->fetch()) {
        $t->assign(array('IPSEARCH_USER_IPMASK3' => cot_build_user($row['user_id'], htmlspecialchars($row['user_name'])), 'IPSEARCH_USER_LASTIP_IPMASK3' => cot_build_ipsearch($row['user_lastip'])));
        $t->parse('MAIN.IPSEARCH_RESULTS.IPSEARCH_IPMASK3');
    }
    $sql->closeCursor();
    $t->assign(array('IPSEARCH_RES_DNS' => $res_dns, 'IPSEARCH_TOTALMATCHES1' => $totalmatches1, 'IPSEARCH_IPMASK1' => $ipmask1, 'IPSEARCH_TOTALMATCHES2' => $totalmatches2, 'IPSEARCH_IPMASK2' => $ipmask2, 'IPSEARCH_TOTALMATCHES3' => $totalmatches3, 'IPSEARCH_IPMASK3' => $ipmask3));
    $t->parse('MAIN.IPSEARCH_RESULTS');
}
$t->parse('MAIN');
$plugin_body .= $t->text('MAIN');