Beispiel #1
0
/**
 * Try and make an action log entry into a proper link.
 *
 * @param  ID_TEXT		Action type
 * @param  string			First parameter
 * @param  string			Second parameter
 * @param  tempcode		First parameter (cropped)
 * @param  tempcode		Second parameter (cropped)
 * @return ?array			Pair: first parameter as possible link, second parameter as possible link (NULL: could not construct a nice link)
 */
function actionlog_linkage($type, $a, $b, $_a, $_b)
{
    $type_str = do_lang($type, $a, $b, NULL, NULL, false);
    if (is_null($type_str)) {
        $type_str = $type;
    }
    // TODO: This will be replaced later with a more thorough system
    if ($type == 'EDIT_TEMPLATES' && strpos($a, ',') === false) {
        if ($b == '') {
            $b = 'default';
        }
        $tmp_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $b, 'f0file' => $a), get_module_zone('admin_themes'));
        $a = basename($a, '.tpl');
        $_a = tpl_crop_text_mouse_over($a, 14);
        $_a = hyperlink($tmp_url, $_a, false, false, $type_str);
        return array($_a, $_b);
    }
    if ($type == 'EDIT_CSS') {
        if ($b == '') {
            $b = 'global.css';
        }
        $tmp_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $a, 'file' => $b), get_module_zone('admin_themes'));
        $b = basename($b, '.css');
        $_b = hyperlink($tmp_url, $_b, false, false, $type_str);
        return array($_a, $_b);
    }
    if ($type == 'COMCODE_PAGE_EDIT') {
        $tmp_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $b . ':' . $a), get_module_zone('cms_comcode_pages'));
        $_a = hyperlink($tmp_url, $_a, false, false, $type_str);
        return array($_a, $_b);
    }
    if ($type == 'ADD_CATALOGUE_ENTRY' || $type == 'EDIT_CATALOGUE_ENTRY') {
        $tmp_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $a), get_module_zone('catalogues'));
        $_b = hyperlink($tmp_url, $b == '' ? $_a : $_b, false, false, $type_str);
        return array($_a, $_b);
    }
    if (($type == 'ADD_CATALOGUE_CATEGORY' || $type == 'EDIT_CATALOGUE_CATEGORY') && $b != '') {
        $tmp_url = build_url(array('page' => 'catalogues', 'type' => 'misc', 'id' => !is_numeric($a) ? $b : $a), get_module_zone('catalogues'));
        $_b = hyperlink($tmp_url, $_b, false, false, $type_str);
        return array($_a, $_b);
    }
    return NULL;
    // Could not get a match
}
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_all_lang();
     require_css('adminzone');
     require_code('actionlog');
     $start = get_param_integer('sa_start', 0);
     $max = get_param_integer('sa_max', 10);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sa_sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sa_sort';
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B')), $sortables, 'sa_sort', $sortable . ' ' . $sort_order);
     $max_rows = $max;
     //Don't want to encourage pagination (there's a better module they can go to) $GLOBALS['SITE_DB']->query_value('adminlogs','COUNT(*)');
     $rows = $GLOBALS['SITE_DB']->query_select('adminlogs', array('the_type', 'param_a', 'param_b', 'the_user', 'ip', 'date_and_time'), NULL, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['the_user']);
         if (is_null($username)) {
             $username = do_lang('UNKNOWN');
         }
         $date = get_timezoned_date($myrow['date_and_time']);
         if (!is_null($myrow['param_a'])) {
             $a = $myrow['param_a'];
         } else {
             $a = '';
         }
         if (!is_null($myrow['param_b'])) {
             $b = $myrow['param_b'];
         } else {
             $b = '';
         }
         require_code('templates_interfaces');
         $_a = tpl_crop_text_mouse_over($a, 8);
         $_b = tpl_crop_text_mouse_over($b, 15);
         $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
         if (is_null($type_str)) {
             $type_str = $myrow['the_type'];
         }
         $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
         if (!is_null($test)) {
             list($_a, $_b) = $test;
         }
         $ip = tpl_crop_text_mouse_over($myrow['ip'], 12);
         $fields->attach(results_entry(array(escape_html($username), escape_html($date), $type_str, $_a, $_b)));
     }
     return results_table(do_lang_tempcode('ACTIONS'), $start, 'sa_start', $max, 'sa_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sa_sort', new ocp_tempcode(), NULL, NULL, 5);
 }
Beispiel #3
0
 /**
  * The UI to show a results table of moderation actions for a moderator.
  *
  * @return tempcode		The UI
  */
 function choose_action()
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('VIEW_ACTION_LOGS'))));
     breadcrumb_set_self(do_lang_tempcode('RESULTS'));
     $title = get_page_title('VIEW_ACTION_LOGS');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     $id = get_param_integer('id', -1);
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     require_code('templates_results_table');
     $field_titles = array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B'));
     if (addon_installed('securitylogging')) {
         $field_titles[] = do_lang_tempcode('_BANNED');
     }
     $fields_title = results_field_title($field_titles, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $filter_to_type = get_param('to_type', '');
     $filter_param_a = get_param('param_a', '');
     $filter_param_b = get_param('param_b', '');
     $max_rows = 0;
     // Pull up our rows: forum
     if (get_forum_type() == 'ocf') {
         // Possible filter (called up by URL)
         $where = '1=1';
         if ($filter_to_type != '') {
             $where .= ' AND ' . db_string_equal_to('l_the_type', $filter_to_type);
         }
         if ($filter_param_a != '') {
             $where .= ' AND l_param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
         }
         if ($filter_param_b != '') {
             $where .= ' AND l_param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
         }
         if ($id != -1) {
             $where .= ' AND l_by=' . strval($id);
         }
         // Fetch
         $rows1 = $GLOBALS['FORUM_DB']->query('SELECT l_reason,id,l_by AS the_user,l_date_and_time AS date_and_time,l_the_type AS the_type,l_param_a AS param_a,l_param_b AS param_b FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
         $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where);
     } else {
         $rows1 = array();
     }
     // Possible filter (called up by URL)
     $where = '1=1';
     if ($filter_to_type != '') {
         $where .= ' AND ' . db_string_equal_to('the_type', $filter_to_type);
     }
     if ($filter_param_a != '') {
         $where .= ' AND param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
     }
     if ($filter_param_b != '') {
         $where .= ' AND param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
     }
     if ($id != -1) {
         $where .= ' AND the_user='******'SITE_DB']->query('SELECT id,the_user,date_and_time,the_type,param_a,param_b,ip FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
     $max_rows += $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where);
     $rows = array_merge($rows1, $rows2);
     require_code('actionlog');
     $fields = new ocp_tempcode();
     $pos = 0;
     while (count($rows) != 0 && $pos - $start < $max) {
         $best = 0;
         // Initialise type to integer
         $_best = 0;
         // Initialise type to integer
         $best = NULL;
         $_best = NULL;
         foreach ($rows as $x => $row) {
             if (is_null($best) || $row['date_and_time'] < $_best && $sortable == 'date_and_time' && $sort_order == 'ASC' || $row['date_and_time'] > $_best && $sortable == 'date_and_time' && $sort_order == 'DESC' || intval($row['the_type']) < $_best && $sortable == 'the_type' && $sort_order == 'ASC' || intval($row['the_type']) > $_best && $sortable == 'the_type' && $sort_order == 'DESC') {
                 $best = $x;
                 if ($sortable == 'date_and_time') {
                     $_best = $row['date_and_time'];
                 }
                 if ($sortable == 'the_type') {
                     $_best = $row['the_type'];
                 }
             }
         }
         if ($pos >= $start) {
             $myrow = $rows[$best];
             $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['the_user']);
             $mode = array_key_exists('l_reason', $myrow) ? 'ocf' : 'ocp';
             $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $myrow['id'], 'mode' => $mode), '_SELF');
             $mode_nice = $mode == 'ocp' ? 'ocPortal' : 'OCF';
             $date = hyperlink($url, get_timezoned_date($myrow['date_and_time']), false, true, $mode_nice . '/' . $row['the_type'] . '/' . strval($myrow['id']), NULL, NULL, NULL, '_top');
             if (!is_null($myrow['param_a'])) {
                 $a = $myrow['param_a'];
             } else {
                 $a = '';
             }
             if (!is_null($myrow['param_b'])) {
                 $b = $myrow['param_b'];
             } else {
                 $b = '';
             }
             require_code('templates_interfaces');
             $_a = tpl_crop_text_mouse_over($a, 8);
             $_b = tpl_crop_text_mouse_over($b, 15);
             $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
             if (is_null($type_str)) {
                 $type_str = $myrow['the_type'];
             }
             $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
             if (!is_null($test)) {
                 list($_a, $_b) = $test;
             }
             $result_entry = array($username, $date, $type_str, $_a, $_b);
             if (addon_installed('securitylogging')) {
                 $banned_test_1 = array_key_exists('ip', $myrow) ? $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip', 'ip', array('ip' => $myrow['ip'])) : NULL;
                 $banned_test_2 = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member', 'the_member', array('the_member' => $myrow['the_user']));
                 $banned_test_3 = $GLOBALS['FORUM_DRIVER']->is_banned($myrow['the_user']);
                 $banned = is_null($banned_test_1) && is_null($banned_test_2) && !$banned_test_3 ? do_lang_tempcode('NO') : do_lang_tempcode('YES');
                 $result_entry[] = $banned;
             }
             $fields->attach(results_entry($result_entry, true));
         }
         unset($rows[$best]);
         $pos++;
     }
     $table = results_table(do_lang_tempcode('ACTIONS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('ACTION_LOGS_SCREEN', array('_GUID' => 'd75c813e372c3ca8d1204609e54c9d65', 'TABLE' => $table, 'TITLE' => $title));
 }
        $from_name = '(Deleted)';
    }
    $to_name = $GLOBALS['FORUM_DRIVER']->get_username($gift['gift_to']);
    if (is_null($to_name)) {
        $from_name = '(Deleted)';
    }
    $from_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $gift['gift_from']), get_module_zone('points'));
    $to_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $gift['gift_to']), get_module_zone('points'));
    $reason = $gift['text_original'];
    if (is_null($from_name)) {
        continue;
    }
    if (is_null($to_name)) {
        continue;
    }
    if ($amount <= 0) {
        continue;
    }
    $from_link = hyperlink($from_url, $from_name, false, true);
    $to_link = hyperlink($to_url, $to_name, false, true);
    echo '<tr>';
    //	echo '<td>'.$from_link->evaluate().'</td>';
    echo '<td>' . $to_link->evaluate() . '</td>';
    echo '<td>' . escape_html(integer_format($amount)) . '</td>';
    if (trim($reason) != '') {
        $blah = tpl_crop_text_mouse_over($reason . ($gift['anonymous'] == 0 ? ' (' . $from_name . ')' : ' (Anonymous)'), 5);
        echo '<td>' . $blah->evaluate() . '</td>';
    }
    echo '</tr>';
}
echo '</table></div>';