MyBB Community Forums

Full Version: Problem with Moderator log page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There seems to be a problem in 1.8.15 with the Moderator log page under "Tools & Maintenance".
If I open it, it says:
Parse error: syntax error, unexpected T_VARIABLE in /home/xxxxxxxxx/domains/xxxxxx.nl/public_html/oriste/admin/modules/tools/modlog.php on line 286


If I check the mentioned file at line #286 it says:


$table->construct_cell($logitem['profilelink']);
Thats should be OK, isn't it? I checked my backupfile (1.8.14) wich is identical.......

Whats going wrong?
Check the above line of the line you stated whether a semicolon ( ; ) or a close brace is missing at the end ...
(2018-04-15, 06:47 PM)effone Wrote: [ -> ]Check the above line of the line you stated whether a semicolon ( ; ) or a close brace is missing at the end ...

I just checked it, this is exactly what line 286 says (I copy/pastet it)
$table->construct_cell($logitem['profilelink']);

That's what it should say, isn't it?
I said to check one line above. Line 285.
or may be chunk of code upto 285 for better reference...

<?php

$var1 = "wageral"   // semicolon missing here
$var2 = "effone";   // error occurs here

^ thats why ...
I'm sorry, didn't understood what you mean. This is the code from line 1 up to line 300:


<?php
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$page->add_breadcrumb_item($lang->mod_logs, "index.php?module=tools-modlog");

$sub_tabs['mod_logs'] = array(
	'title' => $lang->mod_logs,
	'link' => "index.php?module=tools-modlog",
	'description' => $lang->mod_logs_desc
);
$sub_tabs['prune_mod_logs'] = array(
	'title' => $lang->prune_mod_logs,
	'link' => "index.php?module=tools-modlog&amp;action=prune",
	'description' => $lang->prune_mod_logs_desc
);

$plugins->run_hooks("admin_tools_modlog_begin");

if($mybb->input['action'] == 'prune')
{
	$plugins->run_hooks("admin_tools_modlog_prune");

	if($mybb->request_method == 'post')
	{
		$is_today = false;
		$mybb->input['older_than'] = $mybb->get_input('older_than', MyBB::INPUT_INT);
		if($mybb->input['older_than'] <= 0)
		{
			$is_today = true;
			$mybb->input['older_than'] = 1;
		}
		$where = 'dateline < '.(TIME_NOW-($mybb->input['older_than']*86400));

		// Searching for entries by a particular user
		if($mybb->input['uid'])
		{
			$where .= " AND uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'";
		}

		// Searching for entries in a specific module
		if($mybb->input['fid'] > 0)
		{
			$where .= " AND fid='".$db->escape_string($mybb->input['fid'])."'";
		}
		else
		{
			$mybb->input['fid'] = 0;
		}

		$db->delete_query("moderatorlog", $where);
		$num_deleted = $db->affected_rows();

		$plugins->run_hooks("admin_tools_modlog_prune_commit");

		if(!is_array($forum_cache))
		{
			$forum_cache = cache_forums();
		}

		// Log admin action
		log_admin_action($mybb->input['older_than'], $mybb->input['uid'], $mybb->input['fid'], $num_deleted, $forum_cache[$mybb->input['fid']]['name']);

		$success = $lang->success_pruned_mod_logs;
		if($is_today == true && $num_deleted > 0)
		{
			$success .= ' '.$lang->note_logs_locked;
		}
		elseif($is_today == true && $num_deleted == 0)
		{
			flash_message($lang->note_logs_locked, 'error');
			admin_redirect("index.php?module=tools-modlog");
		}
		flash_message($success, 'success');
		admin_redirect("index.php?module=tools-modlog");
	}
	$page->add_breadcrumb_item($lang->prune_mod_logs, "index.php?module=tools-modlog&amp;action=prune");
	$page->output_header($lang->prune_mod_logs);
	$page->output_nav_tabs($sub_tabs, 'prune_mod_logs');

	// Fetch filter options
	$sortbysel[$mybb->input['sortby']] = 'selected="selected"';
	$ordersel[$mybb->input['order']] = 'selected="selected"';

	$user_options[''] = $lang->all_moderators;
	$user_options['0'] = '----------';

	$query = $db->query("
		SELECT DISTINCT l.uid, u.username
		FROM ".TABLE_PREFIX."moderatorlog l
		LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid)
		ORDER BY u.username ASC
	");
	while($user = $db->fetch_array($query))
	{
		// Deleted Users
		if(!$user['username'])
		{
			$user['username'] = htmlspecialchars_uni($lang->na_deleted);
		}

		$user_options[$user['uid']] = htmlspecialchars_uni($user['username']);
	}

	$form = new Form("index.php?module=tools-modlog&amp;action=prune", "post");
	$form_container = new FormContainer($lang->prune_moderator_logs);
	$form_container->output_row($lang->forum, "", $form->generate_forum_select('fid', $mybb->input['fid'], array('id' => 'fid', 'main_option' => $lang->all_forums)), 'fid');
	$form_container->output_row($lang->forum_moderator, "", $form->generate_select_box('uid', $user_options, $mybb->input['uid'], array('id' => 'uid')), 'uid');
	if(!$mybb->input['older_than'])
	{
		$mybb->input['older_than'] = '30';
	}
	$form_container->output_row($lang->date_range, "", $lang->older_than.$form->generate_numeric_field('older_than', $mybb->input['older_than'], array('id' => 'older_than', 'style' => 'width: 50px', 'min' => 0)).' '.$lang->days, 'older_than');
	$form_container->end();
	$buttons[] = $form->generate_submit_button($lang->prune_moderator_logs);
	$form->output_submit_wrapper($buttons);
	$form->end();

	$page->output_footer();
}

if(!$mybb->input['action'])
{
	$plugins->run_hooks("admin_tools_modlog_start");

	$page->output_header($lang->mod_logs);

	$page->output_nav_tabs($sub_tabs, 'mod_logs');

	$perpage = $mybb->get_input('perpage', MyBB::INPUT_INT);
	if(!$perpage)
	{
		if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
		{
			$mybb->settings['threadsperpage'] = 20;
		}

		$perpage = $mybb->settings['threadsperpage'];
	}

	$where = 'WHERE 1=1';

	// Searching for entries by a particular user
	if($mybb->input['uid'])
	{
		$where .= " AND l.uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'";
	}

	// Searching for entries in a specific forum
	if($mybb->input['fid'] > 0)
	{
		$where .= " AND l.fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'";
	}

	// Order?
	switch($mybb->input['sortby'])
	{
		case "username":
			$sortby = "u.username";
			break;
		case "forum":
			$sortby = "f.name";
			break;
		case "thread":
			$sortby = "t.subject";
			break;
		default:
			$sortby = "l.dateline";
	}
	$order = $mybb->input['order'];
	if($order != "asc")
	{
		$order = "desc";
	}

	$query = $db->query("
		SELECT COUNT(l.dateline) AS count
		FROM ".TABLE_PREFIX."moderatorlog l
		{$where}
	");
	$rescount = $db->fetch_field($query, "count");

	// Figure out if we need to display multiple pages.
	if($mybb->input['page'] != "last")
	{
		$pagecnt = $mybb->get_input('page', MyBB::INPUT_INT);
	}

	$postcount = (int)$rescount;
	$pages = $postcount / $perpage;
	$pages = ceil($pages);

	if($mybb->input['page'] == "last")
	{
		$pagecnt = $pages;
	}

	if($pagecnt > $pages)
	{
		$pagecnt = 1;
	}

	if($pagecnt)
	{
		$start = ($pagecnt-1) * $perpage;
	}
	else
	{
		$start = 0;
		$pagecnt = 1;
	}

	$table = new Table;
	$table->construct_header($lang->username, array('width' => '10%'));
	$table->construct_header($lang->date, array("class" => "align_center", 'width' => '15%'));
	$table->construct_header($lang->action, array("class" => "align_center", 'width' => '35%'));
	$table->construct_header($lang->information, array("class" => "align_center", 'width' => '30%'));
	$table->construct_header($lang->ipaddress, array("class" => "align_center", 'width' => '10%'));

	$query = $db->query("
		SELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject
		FROM ".TABLE_PREFIX."moderatorlog l
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid)
		LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=l.fid)
		LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=l.pid)
		{$where}
		ORDER BY {$sortby} {$order}
		LIMIT {$start}, {$perpage}
	");
	while($logitem = $db->fetch_array($query))
	{
		$information = '';
		$logitem['action'] = htmlspecialchars_uni($logitem['action']);
		$logitem['dateline'] = my_date('relative', $logitem['dateline']);
		$trow = alt_trow();
		if($logitem['username'])
		{
			$username = format_name(htmlspecialchars_uni($logitem['username']), $logitem['usergroup'], $logitem['displaygroup']);
			$logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank");
		}
		else
		{
			$username = $logitem['profilelink'] = $logitem['username'] = htmlspecialchars_uni($lang->na_deleted);
		}
		if($logitem['tsubject'])
		{
			$information = "<strong>{$lang->thread}</strong> <a href=\"../".get_thread_link($logitem['tid'])."\" target=\"_blank\">".htmlspecialchars_uni($logitem['tsubject'])."</a><br />";
		}
		if($logitem['fname'])
		{
			$information .= "<strong>{$lang->forum}</strong> <a href=\"../".get_forum_link($logitem['fid'])."\" target=\"_blank\">".htmlspecialchars_uni($logitem['fname'])."</a><br />";
		}
		if($logitem['psubject'])
		{
			$information .= "<strong>{$lang->post}</strong> <a href=\"../".get_post_link($logitem['pid'])."#pid{$logitem['pid']}\" target=\"_blank\">".htmlspecialchars_uni($logitem['psubject'])."</a>";
		}

		if(!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject'])
		{
			$data = my_unserialize($logitem['data']);
			if($data['uid'])
			{
				$information = "<strong>{$lang->user_info}</strong> <a href=\"../".get_profile_link($data['uid'])."\" target=\"_blank\">".htmlspecialchars_uni($data['username'])."</a>";
			}
			if($data['aid'])
			{
				$information = "<strong>{$lang->announcement}</strong> <a href=\"../".get_announcement_link($data['aid'])."\" target=\"_blank\">".htmlspecialchars_uni($data['subject'])."</a>";
			}
		}

		$plugins->run_hooks("admin_tools_modlog_modlogs_result")

		$table->construct_cell($logitem['profilelink']);
		$table->construct_cell($logitem['dateline'], array("class" => "align_center"));
		$table->construct_cell($logitem['action'], array("class" => "align_center"));
		$table->construct_cell($information);
		$table->construct_cell(my_inet_ntop($db->unescape_binary($logitem['ipaddress'])), array("class" => "align_center"));
		$table->construct_row();
	}

	if($table->num_rows() == 0)
	{
		$table->construct_cell($lang->no_modlogs, array("colspan" => "5"));
		$table->construct_row();
	}

	$table->output($lang->mod_logs);

	// Do we need to construct the pagination?

So I have to put a ";" in line 284 (line 285 is empty) after  
$plugins->run_hooks("admin_tools_modlog_modlogs_result")

So it would look like this:

$plugins->run_hooks("admin_tools_modlog_modlogs_result");
Is that correct?
^ yes. add a semicolon at the end of that code line
(2018-04-16, 03:47 AM).m. Wrote: [ -> ]^ yes. add a semicolon at the end of that code line

Thanks Effone and .M. ; it worked!
Its effone and .m.
We are case sensetive.

Glad your problem solved. Big Grin