inital commit
This commit is contained in:
748
webroot/forum/admin/modules/config/attachment_types.php
Normal file
748
webroot/forum/admin/modules/config/attachment_types.php
Normal file
@@ -0,0 +1,748 @@
|
||||
<?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->attachment_types, "index.php?module=config-attachment_types");
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_attachment_types_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['mimetype']) && !trim($mybb->input['extension']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_mime_type;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['extension']) && !trim($mybb->input['mimetype']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_extension;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if($mybb->input['mimetype'] == "images/attachtypes/")
|
||||
{
|
||||
$mybb->input['mimetype'] = '';
|
||||
}
|
||||
|
||||
if(substr($mybb->input['extension'], 0, 1) == '.')
|
||||
{
|
||||
$mybb->input['extension'] = substr($mybb->input['extension'], 1);
|
||||
}
|
||||
|
||||
foreach(array('groups', 'forums') as $key)
|
||||
{
|
||||
if($mybb->input[$key] == 'all')
|
||||
{
|
||||
$mybb->input[$key] = -1;
|
||||
}
|
||||
elseif($mybb->input[$key] == 'custom')
|
||||
{
|
||||
if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
|
||||
{
|
||||
foreach($mybb->input['select'][$key] as &$val)
|
||||
{
|
||||
$val = (int)$val;
|
||||
}
|
||||
unset($val);
|
||||
|
||||
$mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$maxsize = $mybb->get_input('maxsize', MyBB::INPUT_INT);
|
||||
|
||||
if($maxsize == 0)
|
||||
{
|
||||
$maxsize = "";
|
||||
}
|
||||
|
||||
$new_type = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"mimetype" => $db->escape_string($mybb->input['mimetype']),
|
||||
"extension" => $db->escape_string($mybb->input['extension']),
|
||||
"maxsize" => $maxsize,
|
||||
"icon" => $db->escape_string($mybb->input['icon']),
|
||||
'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
'groups' => $db->escape_string($mybb->get_input('groups')),
|
||||
'forums' => $db->escape_string($mybb->get_input('forums')),
|
||||
'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$atid = $db->insert_query("attachtypes", $new_type);
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_add_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($atid, $mybb->input['extension']);
|
||||
|
||||
$cache->update_attachtypes();
|
||||
|
||||
flash_message($lang->success_attachment_type_created, 'success');
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_attachment_type);
|
||||
$page->output_header($lang->attachment_types." - ".$lang->add_new_attachment_type);
|
||||
|
||||
$sub_tabs['attachment_types'] = array(
|
||||
'title' => $lang->attachment_types,
|
||||
'link' => "index.php?module=config-attachment_types"
|
||||
);
|
||||
|
||||
$sub_tabs['add_attachment_type'] = array(
|
||||
'title' => $lang->add_new_attachment_type,
|
||||
'link' => "index.php?module=config-attachment_types&action=add",
|
||||
'description' => $lang->add_attachment_type_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_attachment_type');
|
||||
|
||||
$form = new Form("index.php?module=config-attachment_types&action=add", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
switch($mybb->input['groups'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['groups'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['groups'] = implode(',', (array)$mybb->input['select']['groups']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['groups'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($mybb->input['forums'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['forums'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['forums'] = implode(',', (array)$mybb->input['select']['forums']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['forums'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['maxsize'] = '1024';
|
||||
$mybb->input['icon'] = "images/attachtypes/";
|
||||
}
|
||||
|
||||
if(empty($mybb->input['groups']))
|
||||
{
|
||||
$mybb->input['groups'] = '';
|
||||
}
|
||||
|
||||
if(empty($mybb->input['forums']))
|
||||
{
|
||||
$mybb->input['forums'] = '';
|
||||
}
|
||||
|
||||
// PHP settings
|
||||
$upload_max_filesize = @ini_get('upload_max_filesize');
|
||||
$post_max_size = @ini_get('post_max_size');
|
||||
$limit_string = '';
|
||||
if($upload_max_filesize || $post_max_size)
|
||||
{
|
||||
$limit_string = '<br /><br />'.$lang->limit_intro;
|
||||
if($upload_max_filesize)
|
||||
{
|
||||
$limit_string .= '<br />'.$lang->sprintf($lang->limit_upload_max_filesize, $upload_max_filesize);
|
||||
}
|
||||
if($post_max_size)
|
||||
{
|
||||
$limit_string .= '<br />'.$lang->sprintf($lang->limit_post_max_size, $post_max_size);
|
||||
}
|
||||
}
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['groups'] != '' && $mybb->input['groups'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('groups'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['groups'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['groups'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$groups_select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"all\" {$group_checked['all']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"custom\" {$group_checked['custom']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"groups_forums_groups_custom\" class=\"groups_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[groups][]', $selected_values, array('id' => 'groups', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"none\" {$group_checked['none']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('groups');
|
||||
</script>";
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['forums'] != '' && $mybb->input['forums'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('forums'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$forum_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['forums'] == -1)
|
||||
{
|
||||
$forum_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['forums'] != '')
|
||||
{
|
||||
$forum_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
$forums_select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"all\" {$forum_checked['all']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"custom\" {$forum_checked['custom']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"forums_forums_groups_custom\" class=\"forums_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->forums_colon}</small></td>
|
||||
<td>".$form->generate_forum_select('select[forums][]', $selected_values, array('id' => 'forums', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"none\" {$forum_checked['none']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('forums');
|
||||
</script>";
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_attachment_type);
|
||||
$form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->file_extension." <em>*</em>", $lang->file_extension_desc, $form->generate_text_box('extension', $mybb->input['extension'], array('id' => 'extension')), 'extension');
|
||||
$form_container->output_row($lang->mime_type." <em>*</em>", $lang->mime_type_desc, $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype');
|
||||
$form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->input['maxsize'], array('id' => 'maxsize', 'min' => 0)), 'maxsize');
|
||||
$form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->input['icon'], array('id' => 'icon')), 'icon');
|
||||
$form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->input['enabled']), 'enabled');
|
||||
$form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups'));
|
||||
$form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums'));
|
||||
$form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->input['avatarfile']), 'avatarfile');
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_attachment_type);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("attachtypes", "*", "atid='".$mybb->get_input('atid', MyBB::INPUT_INT)."'");
|
||||
$attachment_type = $db->fetch_array($query);
|
||||
|
||||
if(!$attachment_type['atid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_attachment_type, 'error');
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['mimetype']) && !trim($mybb->input['extension']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_mime_type;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['extension']) && !trim($mybb->input['mimetype']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_extension;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if($mybb->input['mimetype'] == "images/attachtypes/")
|
||||
{
|
||||
$mybb->input['mimetype'] = '';
|
||||
}
|
||||
|
||||
if(substr($mybb->input['extension'], 0, 1) == '.')
|
||||
{
|
||||
$mybb->input['extension'] = substr($mybb->input['extension'], 1);
|
||||
}
|
||||
|
||||
foreach(array('groups', 'forums') as $key)
|
||||
{
|
||||
if($mybb->input[$key] == 'all')
|
||||
{
|
||||
$mybb->input[$key] = -1;
|
||||
}
|
||||
elseif($mybb->input[$key] == 'custom')
|
||||
{
|
||||
if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
|
||||
{
|
||||
foreach($mybb->input['select'][$key] as &$val)
|
||||
{
|
||||
$val = (int)$val;
|
||||
}
|
||||
unset($val);
|
||||
|
||||
$mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$updated_type = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"mimetype" => $db->escape_string($mybb->input['mimetype']),
|
||||
"extension" => $db->escape_string($mybb->input['extension']),
|
||||
"maxsize" => $mybb->get_input('maxsize', MyBB::INPUT_INT),
|
||||
"icon" => $db->escape_string($mybb->input['icon']),
|
||||
'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
'groups' => $db->escape_string($mybb->get_input('groups')),
|
||||
'forums' => $db->escape_string($mybb->get_input('forums')),
|
||||
'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_edit_commit");
|
||||
|
||||
$db->update_query("attachtypes", $updated_type, "atid='{$attachment_type['atid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($attachment_type['atid'], $mybb->input['extension']);
|
||||
|
||||
$cache->update_attachtypes();
|
||||
|
||||
flash_message($lang->success_attachment_type_updated, 'success');
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_attachment_type);
|
||||
$page->output_header($lang->attachment_types." - ".$lang->edit_attachment_type);
|
||||
|
||||
$sub_tabs['edit_attachment_type'] = array(
|
||||
'title' => $lang->edit_attachment_type,
|
||||
'link' => "index.php?module=config-attachment_types&action=edit&atid={$attachment_type['atid']}",
|
||||
'description' => $lang->edit_attachment_type_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_attachment_type');
|
||||
|
||||
$form = new Form("index.php?module=config-attachment_types&action=edit&atid={$attachment_type['atid']}", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
switch($mybb->input['groups'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['groups'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['groups'] = implode(',', (array)$mybb->input['select']['groups']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['groups'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($mybb->input['forums'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['forums'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['forums'] = implode(',', (array)$mybb->input['select']['forums']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['forums'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $attachment_type);
|
||||
}
|
||||
|
||||
if(empty($mybb->input['groups']))
|
||||
{
|
||||
$mybb->input['groups'] = '';
|
||||
}
|
||||
|
||||
if(empty($mybb->input['forums']))
|
||||
{
|
||||
$mybb->input['forums'] = '';
|
||||
}
|
||||
|
||||
// PHP settings
|
||||
$upload_max_filesize = @ini_get('upload_max_filesize');
|
||||
$post_max_size = @ini_get('post_max_size');
|
||||
$limit_string = '';
|
||||
if($upload_max_filesize || $post_max_size)
|
||||
{
|
||||
$limit_string = '<br /><br />'.$lang->limit_intro;
|
||||
if($upload_max_filesize)
|
||||
{
|
||||
$limit_string .= '<br />'.$lang->sprintf($lang->limit_upload_max_filesize, $upload_max_filesize);
|
||||
}
|
||||
if($post_max_size)
|
||||
{
|
||||
$limit_string .= '<br />'.$lang->sprintf($lang->limit_post_max_size, $post_max_size);
|
||||
}
|
||||
}
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['groups'] != '' && $mybb->input['groups'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('groups'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['groups'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['groups'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$groups_select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"all\" {$group_checked['all']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"custom\" {$group_checked['custom']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"groups_forums_groups_custom\" class=\"groups_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[groups][]', $selected_values, array('id' => 'groups', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"none\" {$group_checked['none']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('groups');
|
||||
</script>";
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['forums'] != '' && $mybb->input['forums'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('forums'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$forum_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['forums'] == -1)
|
||||
{
|
||||
$forum_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['forums'] != '')
|
||||
{
|
||||
$forum_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
$forums_select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"all\" {$forum_checked['all']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"custom\" {$forum_checked['custom']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"forums_forums_groups_custom\" class=\"forums_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->forums_colon}</small></td>
|
||||
<td>".$form->generate_forum_select('select[forums][]', $selected_values, array('id' => 'forums', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"none\" {$forum_checked['none']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('forums');
|
||||
</script>";
|
||||
|
||||
$form_container = new FormContainer($lang->edit_attachment_type);
|
||||
$form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->file_extension." <em>*</em>", $lang->file_extension_desc, $form->generate_text_box('extension', $mybb->input['extension'], array('id' => 'extension')), 'extension');
|
||||
$form_container->output_row($lang->mime_type." <em>*</em>", $lang->mime_type_desc, $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype');
|
||||
$form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->input['maxsize'], array('id' => 'maxsize', 'min' => 0)), 'maxsize');
|
||||
$form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->input['icon'], array('id' => 'icon')), 'icon');
|
||||
$form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->input['enabled']), 'enabled');
|
||||
$form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups'));
|
||||
$form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums'));
|
||||
$form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->input['avatarfile']), 'avatarfile');
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_attachment_type);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("attachtypes", "*", "atid='".$mybb->get_input('atid', MyBB::INPUT_INT)."'");
|
||||
$attachment_type = $db->fetch_array($query);
|
||||
|
||||
if(!$attachment_type['atid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_attachment_type, 'error');
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("attachtypes", "atid='{$attachment_type['atid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_delete_commit");
|
||||
|
||||
$cache->update_attachtypes();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($attachment_type['atid'], $attachment_type['extension']);
|
||||
|
||||
flash_message($lang->success_attachment_type_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-attachment_types");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-attachment_types&action=delete&atid={$attachment_type['atid']}", $lang->confirm_attachment_type_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == 'toggle_status')
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect('index.php?module=config-attachment_types');
|
||||
}
|
||||
|
||||
$atid = $mybb->get_input('atid', MyBB::INPUT_INT);
|
||||
|
||||
$query = $db->simple_select('attachtypes', '*', "atid='{$atid}'");
|
||||
$attachment_type = $db->fetch_array($query);
|
||||
|
||||
if(!$attachment_type['atid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_mycode, 'error');
|
||||
admin_redirect('index.php?module=config-attachment_types');
|
||||
}
|
||||
|
||||
$plugins->run_hooks('admin_config_attachment_types_toggle_status');
|
||||
|
||||
$update_array = array('enabled' => 1);
|
||||
$phrase = $lang->success_activated_attachment_type;
|
||||
if($attachment_type['enabled'] == 1)
|
||||
{
|
||||
$update_array['enabled'] = 0;
|
||||
$phrase = $lang->success_activated_attachment_type;
|
||||
}
|
||||
|
||||
$plugins->run_hooks('admin_config_attachment_types_toggle_status_commit');
|
||||
|
||||
$db->update_query('attachtypes', $update_array, "atid='{$atid}'");
|
||||
|
||||
$cache->update_attachtypes();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($atid, $attachment_type['extension'], $update_array['enabled']);
|
||||
|
||||
flash_message($phrase, 'success');
|
||||
admin_redirect('index.php?module=config-attachment_types');
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->attachment_types);
|
||||
|
||||
$sub_tabs['attachment_types'] = array(
|
||||
'title' => $lang->attachment_types,
|
||||
'link' => "index.php?module=config-attachment_types",
|
||||
'description' => $lang->attachment_types_desc
|
||||
);
|
||||
$sub_tabs['add_attachment_type'] = array(
|
||||
'title' => $lang->add_new_attachment_type,
|
||||
'link' => "index.php?module=config-attachment_types&action=add",
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_attachment_types_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'attachment_types');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->extension, array("colspan" => 2));
|
||||
$table->construct_header($lang->mime_type);
|
||||
$table->construct_header($lang->alt_enabled, array('class' => 'align_center'));
|
||||
$table->construct_header($lang->maximum_size, array("class" => "align_center"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center"));
|
||||
|
||||
$query = $db->simple_select("attachtypes", "*", "", array('order_by' => 'extension'));
|
||||
while($attachment_type = $db->fetch_array($query))
|
||||
{
|
||||
// Just show default icons in ACP
|
||||
$attachment_type['icon'] = htmlspecialchars_uni(str_replace("{theme}", "images", $attachment_type['icon']));
|
||||
if(my_validate_url($attachment_type['icon'], true))
|
||||
{
|
||||
$image = $attachment_type['icon'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = "../".$attachment_type['icon'];
|
||||
}
|
||||
|
||||
if(!$attachment_type['icon'] || $attachment_type['icon'] == "images/attachtypes/")
|
||||
{
|
||||
$attachment_type['icon'] = " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attachment_type['name'] = htmlspecialchars_uni($attachment_type['name']);
|
||||
$attachment_type['icon'] = "<img src=\"{$image}\" title=\"{$attachment_type['name']}\" alt=\"\" />";
|
||||
}
|
||||
|
||||
if($attachment_type['enabled'])
|
||||
{
|
||||
$phrase = $lang->disable;
|
||||
$icon = "on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$phrase = $lang->enable;
|
||||
$icon = "off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}";
|
||||
}
|
||||
|
||||
$attachment_type['extension'] = htmlspecialchars_uni($attachment_type['extension']);
|
||||
|
||||
$table->construct_cell($attachment_type['icon'], array("width" => 1));
|
||||
$table->construct_cell("<strong>.{$attachment_type['extension']}</strong>");
|
||||
$table->construct_cell(htmlspecialchars_uni($attachment_type['mimetype']));
|
||||
$table->construct_cell("<img src=\"styles/{$page->style}/images/icons/bullet_{$icon}\" style=\"vertical-align: middle;\" />", array("class" => "align_center"));
|
||||
$table->construct_cell(get_friendly_size(($attachment_type['maxsize']*1024)), array("class" => "align_center"));
|
||||
|
||||
$popup = new PopupMenu("attachment_type_{$attachment_type['atid']}", $lang->options);
|
||||
$popup->add_item($lang->edit, "index.php?module=config-attachment_types&action=edit&atid={$attachment_type['atid']}");
|
||||
$popup->add_item($phrase, "index.php?module=config-attachment_types&action=toggle_status&atid={$attachment_type['atid']}&my_post_key={$mybb->post_code}");
|
||||
$popup->add_item($lang->delete, "index.php?module=config-attachment_types&action=delete&atid={$attachment_type['atid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_attachment_type_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array('class' => 'align_center'));
|
||||
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_attachment_types, array('colspan' => 6));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->attachment_types);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
301
webroot/forum/admin/modules/config/badwords.php
Normal file
301
webroot/forum/admin/modules/config/badwords.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?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->bad_words, "index.php?module=config-badwords");
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_begin");
|
||||
|
||||
if($mybb->input['action'] == "add" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_badwords_add");
|
||||
|
||||
if(!trim($mybb->input['badword']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_bad_word;
|
||||
}
|
||||
|
||||
if(strlen(trim($mybb->input['badword'])) > 100)
|
||||
{
|
||||
$errors[] = $lang->bad_word_max;
|
||||
}
|
||||
|
||||
if(strlen($mybb->input['replacement']) > 100)
|
||||
{
|
||||
$errors[] = $lang->replacement_word_max;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$query = $db->simple_select("badwords", "bid", "badword = '".$db->escape_string($mybb->input['badword'])."'");
|
||||
|
||||
if($db->num_rows($query))
|
||||
{
|
||||
$errors[] = $lang->error_bad_word_filtered;
|
||||
}
|
||||
}
|
||||
|
||||
$badword = trim($mybb->input['badword']);
|
||||
|
||||
if($mybb->get_input('regex', MyBB::INPUT_INT))
|
||||
{
|
||||
// Check validity of defined regular expression
|
||||
if((@preg_match('#'.$badword.'#is', null) === false))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_regex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_object($parser))
|
||||
{
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
}
|
||||
|
||||
$badword = $parser->generate_regex($badword);
|
||||
}
|
||||
|
||||
// Don't allow certain badword replacements to be added if it would cause an infinite recursive loop.
|
||||
if(@preg_match('#'.$badword.'#is', $mybb->input['replacement']))
|
||||
{
|
||||
$errors[] = $lang->error_replacement_word_invalid;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_badword = array(
|
||||
"badword" => $db->escape_string($mybb->input['badword']),
|
||||
"regex" => $mybb->get_input('regex', MyBB::INPUT_INT),
|
||||
"replacement" => $db->escape_string($mybb->input['replacement'])
|
||||
);
|
||||
|
||||
$bid = $db->insert_query("badwords", $new_badword);
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_add_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($bid, $mybb->input['badword']);
|
||||
|
||||
$cache->update_badwords();
|
||||
flash_message($lang->success_added_bad_word, 'success');
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['action'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'");
|
||||
$badword = $db->fetch_array($query);
|
||||
|
||||
// Does the bad word not exist?
|
||||
if(!$badword['bid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_bid, 'error');
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the bad word
|
||||
$db->delete_query("badwords", "bid='{$badword['bid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($badword['bid'], $badword['badword']);
|
||||
|
||||
$cache->update_badwords();
|
||||
|
||||
flash_message($lang->success_deleted_bad_word, 'success');
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-badwords&action=delete&bid={$badword['bid']}", $lang->confirm_bad_word_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("badwords", "*", "bid='".$mybb->get_input('bid', MyBB::INPUT_INT)."'");
|
||||
$badword = $db->fetch_array($query);
|
||||
|
||||
// Does the bad word not exist?
|
||||
if(!$badword['bid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_bid, 'error');
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['badword']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_bad_word;
|
||||
}
|
||||
|
||||
if(strlen(trim($mybb->input['badword'])) > 100)
|
||||
{
|
||||
$errors[] = $lang->bad_word_max;
|
||||
}
|
||||
|
||||
if(strlen($mybb->input['replacement']) > 100)
|
||||
{
|
||||
$errors[] = $lang->replacement_word_max;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_badword = array(
|
||||
"badword" => $db->escape_string($mybb->input['badword']),
|
||||
"regex" => $mybb->get_input('regex', MyBB::INPUT_INT),
|
||||
"replacement" => $db->escape_string($mybb->input['replacement'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_edit_commit");
|
||||
|
||||
$db->update_query("badwords", $updated_badword, "bid='{$badword['bid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($badword['bid'], $mybb->input['badword']);
|
||||
|
||||
$cache->update_badwords();
|
||||
|
||||
flash_message($lang->success_updated_bad_word, 'success');
|
||||
admin_redirect("index.php?module=config-badwords");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_bad_word);
|
||||
$page->output_header($lang->bad_words." - ".$lang->edit_bad_word);
|
||||
|
||||
$sub_tabs['editbadword'] = array(
|
||||
'title' => $lang->edit_bad_word,
|
||||
'description' => $lang->edit_bad_word_desc,
|
||||
'link' => "index.php?module=config-badwords"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "editbadword");
|
||||
|
||||
$form = new Form("index.php?module=config-badwords&action=edit&bid={$badword['bid']}", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
$badword_data = $mybb->input;
|
||||
}
|
||||
else
|
||||
{
|
||||
$badword_data = $badword;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_bad_word);
|
||||
$form_container->output_row($lang->bad_word." <em>*</em>", $lang->bad_word_desc, $form->generate_text_box('badword', $badword_data['badword'], array('id' => 'badword')), 'badword');
|
||||
$form_container->output_row($lang->replacement, $lang->replacement_desc, $form->generate_text_box('replacement', $badword_data['replacement'], array('id' => 'replacement')), 'replacement');
|
||||
$form_container->output_row($lang->regex, $lang->regex_desc, $form->generate_yes_no_radio('regex', (int)$badword_data['regex'], array('id' => 'regex')), 'regex');
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->save_bad_word);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->bad_words);
|
||||
|
||||
$sub_tabs['badwords'] = array(
|
||||
'title' => $lang->bad_word_filters,
|
||||
'description' => $lang->bad_word_filters_desc,
|
||||
'link' => "index.php?module=config-badwords"
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_badwords_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "badwords");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->bad_word);
|
||||
$table->construct_header($lang->replacement, array("width" => "50%"));
|
||||
$table->construct_header($lang->regex, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150, "colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("badwords", "*", "", array("order_by" => "badword", "order_dir" => "asc"));
|
||||
while($badword = $db->fetch_array($query))
|
||||
{
|
||||
$badword['badword'] = htmlspecialchars_uni($badword['badword']);
|
||||
$badword['replacement'] = htmlspecialchars_uni($badword['replacement']);
|
||||
if(!$badword['replacement'])
|
||||
{
|
||||
$badword['replacement'] = '*****';
|
||||
}
|
||||
|
||||
$regex = $lang->no;
|
||||
if($badword['regex'])
|
||||
{
|
||||
$regex = $lang->yes;
|
||||
}
|
||||
|
||||
$table->construct_cell($badword['badword']);
|
||||
$table->construct_cell($badword['replacement']);
|
||||
$table->construct_cell($regex, array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-badwords&action=edit&bid={$badword['bid']}\">{$lang->edit}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-badwords&action=delete&bid={$badword['bid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_bad_word_deletion}');\">{$lang->delete}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_bad_words, array("colspan" => 4));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->bad_word_filters);
|
||||
|
||||
$form = new Form("index.php?module=config-badwords&action=add", "post", "add");
|
||||
|
||||
$form_container = new FormContainer($lang->add_bad_word);
|
||||
$form_container->output_row($lang->bad_word." <em>*</em>", $lang->bad_word_desc, $form->generate_text_box('badword', $mybb->input['badword'], array('id' => 'badword')), 'badword');
|
||||
$form_container->output_row($lang->replacement, $lang->replacement_desc, $form->generate_text_box('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement');
|
||||
$form_container->output_row($lang->regex, $lang->regex_desc, $form->generate_yes_no_radio('regex', !$mybb->get_input('regex'), array('id' => 'regex')), 'regex');
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->save_bad_word);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
296
webroot/forum/admin/modules/config/banning.php
Normal file
296
webroot/forum/admin/modules/config/banning.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?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->banning, "index.php?module=config-banning");
|
||||
|
||||
$plugins->run_hooks("admin_config_banning_begin");
|
||||
|
||||
if($mybb->input['action'] == "add" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_banning_add");
|
||||
|
||||
if(!trim($mybb->input['filter']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_ban_input;
|
||||
}
|
||||
|
||||
$query = $db->simple_select("banfilters", "fid", "filter = '".$db->escape_string($mybb->input['filter'])."' AND type = '".$mybb->get_input('type', MyBB::INPUT_INT)."'");
|
||||
if($db->num_rows($query))
|
||||
{
|
||||
$errors[] = $lang->error_filter_already_banned;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_filter = array(
|
||||
"filter" => $db->escape_string($mybb->input['filter']),
|
||||
"type" => $mybb->get_input('type', MyBB::INPUT_INT),
|
||||
"dateline" => TIME_NOW
|
||||
);
|
||||
$fid = $db->insert_query("banfilters", $new_filter);
|
||||
|
||||
$plugins->run_hooks("admin_config_banning_add_commit");
|
||||
|
||||
if($mybb->input['type'] == 1)
|
||||
{
|
||||
$cache->update_bannedips();
|
||||
}
|
||||
else if($mybb->input['type'] == 3)
|
||||
{
|
||||
$cache->update_bannedemails();
|
||||
}
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($fid, $mybb->input['filter'], (int)$mybb->input['type']);
|
||||
|
||||
if($mybb->input['type'] == 1)
|
||||
{
|
||||
flash_message($lang->success_ip_banned, 'success');
|
||||
admin_redirect("index.php?module=config-banning");
|
||||
}
|
||||
else if($mybb->input['type'] == 2)
|
||||
{
|
||||
flash_message($lang->success_username_disallowed, 'success');
|
||||
admin_redirect("index.php?module=config-banning&type=usernames");
|
||||
}
|
||||
else if($mybb->input['type'] == 3)
|
||||
{
|
||||
flash_message($lang->success_email_disallowed, 'success');
|
||||
admin_redirect("index.php?module=config-banning&type=emails");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($mybb->input['type'] == 1)
|
||||
{
|
||||
$mybb->input['type'] = "ips";
|
||||
}
|
||||
else if($mybb->input['type'] == 2)
|
||||
{
|
||||
$mybb->input['type'] = "usernames";
|
||||
}
|
||||
else if($mybb->input['type'] == 3)
|
||||
{
|
||||
$mybb->input['type'] = "emails";
|
||||
}
|
||||
$mybb->input['action'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("banfilters", "*", "fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'");
|
||||
$filter = $db->fetch_array($query);
|
||||
|
||||
// Does the filter not exist?
|
||||
if(!$filter['fid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_filter, 'error');
|
||||
admin_redirect("index.php?module=config-banning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_banning_delete");
|
||||
|
||||
if($filter['type'] == 3)
|
||||
{
|
||||
$type = "emails";
|
||||
}
|
||||
else if($filter['type'] == 2)
|
||||
{
|
||||
$type = "usernames";
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = "ips";
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-banning&type={$type}");
|
||||
}
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the ban filter
|
||||
$db->delete_query("banfilters", "fid='{$filter['fid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_banning_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($filter['fid'], $filter['filter'], (int)$filter['type']);
|
||||
|
||||
// Banned IP? Rebuild banned IP cache
|
||||
if($filter['type'] == 1)
|
||||
{
|
||||
$cache->update_bannedips();
|
||||
}
|
||||
else if($filter['type'] == 3)
|
||||
{
|
||||
$cache->update_bannedemails();
|
||||
}
|
||||
|
||||
flash_message($lang->success_ban_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-banning&type={$type}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-banning&action=delete&fid={$filter['fid']}", $lang->confirm_ban_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_banning_start");
|
||||
|
||||
switch($mybb->input['type'])
|
||||
{
|
||||
case "emails":
|
||||
$type = "3";
|
||||
$title = $lang->disallowed_email_addresses;
|
||||
break;
|
||||
case "usernames":
|
||||
$type = "2";
|
||||
$title = $lang->disallowed_usernames;
|
||||
break;
|
||||
default:
|
||||
$type = "1";
|
||||
$title = $lang->banned_ip_addresses;
|
||||
$mybb->input['type'] = "ips";
|
||||
}
|
||||
|
||||
$page->output_header($title);
|
||||
|
||||
$sub_tabs['ips'] = array(
|
||||
'title' => $lang->banned_ips,
|
||||
'link' => "index.php?module=config-banning",
|
||||
'description' => $lang->banned_ips_desc
|
||||
);
|
||||
|
||||
$sub_tabs['users'] = array(
|
||||
'title' => $lang->banned_accounts,
|
||||
'link' => "index.php?module=user-banning"
|
||||
);
|
||||
|
||||
$sub_tabs['usernames'] = array(
|
||||
'title' => $lang->disallowed_usernames,
|
||||
'link' => "index.php?module=config-banning&type=usernames",
|
||||
'description' => $lang->disallowed_usernames_desc
|
||||
);
|
||||
|
||||
$sub_tabs['emails'] = array(
|
||||
'title' => $lang->disallowed_email_addresses,
|
||||
'link' => "index.php?module=config-banning&type=emails",
|
||||
'description' => $lang->disallowed_email_addresses_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, $mybb->input['type']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-banning&action=add", "post", "add");
|
||||
|
||||
if($mybb->input['type'] == "usernames")
|
||||
{
|
||||
$form_container = new FormContainer($lang->add_disallowed_username);
|
||||
$form_container->output_row($lang->username." <em>*</em>", $lang->username_desc, $form->generate_text_box('filter', $mybb->input['filter'], array('id' => 'filter')), 'filter');
|
||||
$buttons[] = $form->generate_submit_button($lang->disallow_username);
|
||||
}
|
||||
else if($mybb->input['type'] == "emails")
|
||||
{
|
||||
$form_container = new FormContainer($lang->add_disallowed_email_address);
|
||||
$form_container->output_row($lang->email_address." <em>*</em>", $lang->email_address_desc, $form->generate_text_box('filter', $mybb->input['filter'], array('id' => 'filter')), 'filter');
|
||||
$buttons[] = $form->generate_submit_button($lang->disallow_email_address);
|
||||
}
|
||||
else
|
||||
{
|
||||
$form_container = new FormContainer($lang->ban_an_ip_address);
|
||||
$form_container->output_row($lang->ip_address." <em>*</em>", $lang->ip_address_desc, $form->generate_text_box('filter', $mybb->input['filter'], array('id' => 'filter')), 'filter');
|
||||
$buttons[] = $form->generate_submit_button($lang->ban_ip_address);
|
||||
}
|
||||
|
||||
$form_container->end();
|
||||
echo $form->generate_hidden_field("type", $type);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<br />';
|
||||
|
||||
$table = new Table;
|
||||
if($mybb->input['type'] == "usernames")
|
||||
{
|
||||
$table->construct_header($lang->username);
|
||||
$table->construct_header($lang->date_disallowed, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->last_attempted_use, array("class" => "align_center", "width" => 200));
|
||||
}
|
||||
else if($mybb->input['type'] == "emails")
|
||||
{
|
||||
$table->construct_header($lang->email_address);
|
||||
$table->construct_header($lang->date_disallowed, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->last_attempted_use, array("class" => "align_center", "width" => 200));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_header($lang->ip_address);
|
||||
$table->construct_header($lang->ban_date, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->last_access, array("class" => "align_center", "width" => 200));
|
||||
}
|
||||
$table->construct_header($lang->controls, array("width" => 1));
|
||||
|
||||
$query = $db->simple_select("banfilters", "*", "type='{$type}'", array("order_by" => "filter", "order_dir" => "asc"));
|
||||
while($filter = $db->fetch_array($query))
|
||||
{
|
||||
$filter['filter'] = htmlspecialchars_uni($filter['filter']);
|
||||
|
||||
if($filter['lastuse'] > 0)
|
||||
{
|
||||
$last_use = my_date('relative', $filter['lastuse']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_use = $lang->never;
|
||||
}
|
||||
|
||||
if($filter['dateline'] > 0)
|
||||
{
|
||||
$date = my_date('relative', $filter['dateline']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = $lang->na;
|
||||
}
|
||||
|
||||
$table->construct_cell($filter['filter']);
|
||||
$table->construct_cell($date, array("class" => "align_center"));
|
||||
$table->construct_cell($last_use, array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-banning&action=delete&fid={$filter['fid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_ban_deletion}');\"><img src=\"styles/{$page->style}/images/icons/delete.png\" title=\"{$lang->delete}\" alt=\"{$lang->delete}\" /></a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_bans, array("colspan" => 4));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($title);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
479
webroot/forum/admin/modules/config/calendars.php
Normal file
479
webroot/forum/admin/modules/config/calendars.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?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->calendars, "index.php?module=config-calendars");
|
||||
|
||||
if($mybb->input['action'] == "add" || $mybb->input['action'] == "permissions" || !$mybb->input['action'])
|
||||
{
|
||||
$sub_tabs['manage_calendars'] = array(
|
||||
'title' => $lang->manage_calendars,
|
||||
'link' => "index.php?module=config-calendars",
|
||||
'description' => $lang->manage_calendars_desc
|
||||
);
|
||||
$sub_tabs['add_calendar'] = array(
|
||||
'title' => $lang->add_calendar,
|
||||
'link' => "index.php?module=config-calendars&action=add",
|
||||
'description' => $lang->add_calendar_desc
|
||||
);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_calendars_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_calendars_add_commit");
|
||||
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['disporder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_order;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$calendar = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"startofweek" => $mybb->get_input('startofweek', MyBB::INPUT_INT),
|
||||
"eventlimit" => $mybb->get_input('eventlimit', MyBB::INPUT_INT),
|
||||
"showbirthdays" => $mybb->get_input('showbirthdays', MyBB::INPUT_INT),
|
||||
"moderation" => $mybb->get_input('moderation', MyBB::INPUT_INT),
|
||||
"allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
|
||||
"allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_add_commit_start");
|
||||
|
||||
$cid = $db->insert_query("calendars", $calendar);
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_add_commit_end");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($cid, $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_calendar_created, 'success');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, array(
|
||||
"allowhtml" => 0,
|
||||
"eventlimit" => 4,
|
||||
"disporder" => 1,
|
||||
"moderation" => 0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_calendar);
|
||||
$page->output_header($lang->calendars." - ".$lang->add_calendar);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_calendar');
|
||||
$form = new Form("index.php?module=config-calendars&action=add", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_calendar);
|
||||
$form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->display_order, $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$select_list = array($lang->sunday, $lang->monday, $lang->tuesday, $lang->wednesday, $lang->thursday, $lang->friday, $lang->saturday);
|
||||
$form_container->output_row($lang->week_start, $lang->week_start_desc, $form->generate_select_box('startofweek', $select_list, $mybb->input['startofweek'], array('id' => 'startofweek')), 'startofweek');
|
||||
$form_container->output_row($lang->event_limit, $lang->event_limit_desc, $form->generate_numeric_field('eventlimit', $mybb->input['eventlimit'], array('id' => 'eventlimit', 'min' => 0)), 'eventlimit');
|
||||
$form_container->output_row($lang->show_birthdays, $lang->show_birthdays_desc, $form->generate_yes_no_radio('showbirthdays', $mybb->input['showbirthdays'], true));
|
||||
$form_container->output_row($lang->moderate_events, $lang->moderate_events_desc, $form->generate_yes_no_radio('moderation', $mybb->input['moderation'], true));
|
||||
$form_container->output_row($lang->allow_html, "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml']));
|
||||
$form_container->output_row($lang->allow_mycode, "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode']));
|
||||
$form_container->output_row($lang->allow_img, "", $form->generate_yes_no_radio('allowimgcode', $mybb->input['allowimgcode']));
|
||||
$form_container->output_row($lang->allow_video, "", $form->generate_yes_no_radio('allowvideocode', $mybb->input['allowvideocode']));
|
||||
$form_container->output_row($lang->allow_smilies, "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_calendar);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "permissions")
|
||||
{
|
||||
$usergroups = array();
|
||||
|
||||
$query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$calendar = $db->fetch_array($query);
|
||||
|
||||
// Does the calendar not exist?
|
||||
if(!$calendar['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_calendar, 'error');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_permissions");
|
||||
|
||||
$query = $db->simple_select("usergroups", "*", "", array("order" => "name"));
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$usergroups[$usergroup['gid']] = $usergroup;
|
||||
}
|
||||
|
||||
$query = $db->simple_select("calendarpermissions", "*", "cid='{$calendar['cid']}'");
|
||||
while($existing = $db->fetch_array($query))
|
||||
{
|
||||
$existing_permissions[$existing['gid']] = $existing;
|
||||
}
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
foreach(array_keys($usergroups) as $group_id)
|
||||
{
|
||||
$permissions = $mybb->input['permissions'][$group_id];
|
||||
$db->delete_query("calendarpermissions", "cid='{$calendar['cid']}' AND gid='".(int)$group_id."'");
|
||||
|
||||
if(!$mybb->input['default_permissions'][$group_id])
|
||||
{
|
||||
foreach(array('canviewcalendar','canaddevents','canbypasseventmod','canmoderateevents') as $calendar_permission)
|
||||
{
|
||||
if($permissions[$calendar_permission] == 1)
|
||||
{
|
||||
$permissions_array[$calendar_permission] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$permissions_array[$calendar_permission] = 0;
|
||||
}
|
||||
}
|
||||
$permissions_array['gid'] = (int)$group_id;
|
||||
$permissions_array['cid'] = $calendar['cid'];
|
||||
$db->insert_query("calendarpermissions", $permissions_array);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_permissions_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($calendar['cid'], $calendar['name']);
|
||||
|
||||
flash_message($lang->success_calendar_permissions_updated, 'success');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
$calendar['name'] = htmlspecialchars_uni($calendar['name']);
|
||||
$page->add_breadcrumb_item($calendar['name'], "index.php?module=config-calendars&action=edit&cid={$calendar['cid']}");
|
||||
$page->add_breadcrumb_item($lang->permissions);
|
||||
$page->output_header($lang->calendars." - ".$lang->edit_permissions);
|
||||
|
||||
$form = new Form("index.php?module=config-calendars&action=permissions", "post");
|
||||
echo $form->generate_hidden_field("cid", $calendar['cid']);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->permissions_group);
|
||||
$table->construct_header($lang->permissions_view, array("class" => "align_center", "width" => "10%"));
|
||||
$table->construct_header($lang->permissions_post_events, array("class" => "align_center", "width" => "10%"));
|
||||
$table->construct_header($lang->permissions_bypass_moderation, array("class" => "align_center", "width" => "10%"));
|
||||
$table->construct_header($lang->permissions_moderator, array("class" => "align_center", "width" => "10%"));
|
||||
$table->construct_header($lang->permissions_all, array("class" => "align_center", "width" => "10%"));
|
||||
|
||||
foreach($usergroups as $usergroup)
|
||||
{
|
||||
if($existing_permissions[$usergroup['gid']])
|
||||
{
|
||||
$perms = $existing_permissions[$usergroup['gid']];
|
||||
$default_checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$perms = $usergroup;
|
||||
$default_checked = true;
|
||||
}
|
||||
$perm_check = $all_check = "";
|
||||
$all_checked = true;
|
||||
foreach(array('canviewcalendar','canaddevents','canbypasseventmod','canmoderateevents') as $calendar_permission)
|
||||
{
|
||||
if($usergroup[$calendar_permission] == 1)
|
||||
{
|
||||
$value = "this.checked";
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = "false";
|
||||
}
|
||||
if($perms[$calendar_permission] != 1)
|
||||
{
|
||||
$all_checked = false;
|
||||
}
|
||||
if($perms[$calendar_permission] == 1)
|
||||
{
|
||||
$perms_checked[$calendar_permission] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$perms_checked[$calendar_permission] = 0;
|
||||
}
|
||||
$all_check .= "\$('#permissions_{$usergroup['gid']}_{$calendar_permission}').prop('checked', this.checked);\n";
|
||||
$perm_check .= "\$('#permissions_{$usergroup['gid']}_{$calendar_permission}').prop('checked', $value);\n";
|
||||
}
|
||||
$default_click = "if(\$(this).is(':checked')) { $perm_check }";
|
||||
$reset_default = "if(!\$(this).is(':checked')) { \$('#permissions_{$usergroup['gid']}_all').prop('checked', false); }\n";
|
||||
$usergroup['title'] = htmlspecialchars_uni($usergroup['title']);
|
||||
$table->construct_cell("<strong>{$usergroup['title']}</strong><br /><small style=\"vertical-align: middle;\">".$form->generate_check_box("default_permissions[{$usergroup['gid']}];", 1, "", array("id" => "default_permissions_{$usergroup['gid']}", "checked" => $default_checked, "onclick" => $default_click))." <label for=\"default_permissions_{$usergroup['gid']}\">{$lang->permissions_use_group_default}</label></small>");
|
||||
$table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canviewcalendar]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canviewcalendar", "checked" => $perms_checked['canviewcalendar'], "onclick" => $reset_default)), array('class' => 'align_center'));
|
||||
$table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canaddevents]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canaddevents", "checked" => $perms_checked['canaddevents'], "onclick" => $reset_default)), array('class' => 'align_center'));
|
||||
$table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canbypasseventmod]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canbypasseventmod", "checked" => $perms_checked['canbypasseventmod'], "onclick" => $reset_default)), array('class' => 'align_center'));
|
||||
$table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canmoderateevents]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canmoderateevents", "checked" => $perms_checked['canmoderateevents'], "onclick" => $reset_default)), array('class' => 'align_center'));
|
||||
$table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][all]", 1, "", array("id" => "permissions_{$usergroup['gid']}_all", "checked" => $all_checked, "onclick" => $all_check)), array('class' => 'align_center'));
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output("{$lang->calendar_permissions_for} {$calendar['name']}");
|
||||
|
||||
if(!$no_results)
|
||||
{
|
||||
$buttons[] = $form->generate_submit_button($lang->save_permissions);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
}
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$calendar = $db->fetch_array($query);
|
||||
|
||||
// Does the calendar not exist?
|
||||
if(!$calendar['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_calendar, 'error');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['disporder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_order;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_calendar = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"startofweek" => $mybb->get_input('startofweek', MyBB::INPUT_INT),
|
||||
"eventlimit" => $mybb->get_input('eventlimit', MyBB::INPUT_INT),
|
||||
"showbirthdays" => $mybb->get_input('showbirthdays', MyBB::INPUT_INT),
|
||||
"moderation" => $mybb->get_input('moderation', MyBB::INPUT_INT),
|
||||
"allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
|
||||
"allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_edit_commit");
|
||||
|
||||
$db->update_query("calendars", $updated_calendar, "cid='{$calendar['cid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($calendar['cid'], $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_calendar_updated, 'success');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_calendar);
|
||||
$page->output_header($lang->calendars." - ".$lang->edit_calendar);
|
||||
|
||||
$sub_tabs['edit_calendar'] = array(
|
||||
'title' => $lang->edit_calendar,
|
||||
'link' => "index.php?module=config-calendars&action=edit",
|
||||
'description' => $lang->edit_calendar_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_calendar');
|
||||
$form = new Form("index.php?module=config-calendars&action=edit", "post");
|
||||
|
||||
echo $form->generate_hidden_field("cid", $calendar['cid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = $calendar;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_calendar);
|
||||
$form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$select_list = array($lang->sunday, $lang->monday, $lang->tuesday, $lang->wednesday, $lang->thursday, $lang->friday, $lang->saturday);
|
||||
$form_container->output_row($lang->week_start, $lang->week_start_desc, $form->generate_select_box('startofweek', $select_list, $mybb->input['startofweek'], array('id' => 'startofweek')), 'startofweek');
|
||||
$form_container->output_row($lang->event_limit, $lang->event_limit_desc, $form->generate_numeric_field('eventlimit', $mybb->input['eventlimit'], array('id' => 'eventlimit', 'min' => 0)), 'eventlimit');
|
||||
$form_container->output_row($lang->show_birthdays, $lang->show_birthdays_desc, $form->generate_yes_no_radio('showbirthdays', $mybb->input['showbirthdays'], true));
|
||||
$form_container->output_row($lang->moderate_events, $lang->moderate_events_desc, $form->generate_yes_no_radio('moderation', $mybb->input['moderation'], true));
|
||||
$form_container->output_row($lang->allow_html, "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml']));
|
||||
$form_container->output_row($lang->allow_mycode, "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode']));
|
||||
$form_container->output_row($lang->allow_img, "", $form->generate_yes_no_radio('allowimgcode', $mybb->input['allowimgcode']));
|
||||
$form_container->output_row($lang->allow_video, "", $form->generate_yes_no_radio('allowvideocode', $mybb->input['allowvideocode']));
|
||||
$form_container->output_row($lang->allow_smilies, "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_calendar);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$calendar = $db->fetch_array($query);
|
||||
|
||||
// Does the calendar not exist?
|
||||
if(!$calendar['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_calendar, 'error');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_delete");
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the calendar
|
||||
$db->delete_query("calendars", "cid='{$calendar['cid']}'");
|
||||
$db->delete_query("calendarpermissions", "cid='{$calendar['cid']}'");
|
||||
$db->delete_query("events", "cid='{$calendar['cid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($calendar['cid'], $calendar['name']);
|
||||
|
||||
flash_message($lang->success_calendar_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-calendars&action=delete&cid={$calendar['cid']}", $lang->confirm_calendar_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "update_order" && $mybb->request_method == "post")
|
||||
{
|
||||
if(!is_array($mybb->input['disporder']))
|
||||
{
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_update_order");
|
||||
|
||||
foreach($mybb->input['disporder'] as $cid => $order)
|
||||
{
|
||||
$update_query = array(
|
||||
"disporder" => (int)$order
|
||||
);
|
||||
$db->update_query("calendars", $update_query, "cid='".(int)$cid."'");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_calendars_update_order_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
flash_message($lang->success_calendar_orders_updated, 'success');
|
||||
admin_redirect("index.php?module=config-calendars");
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->manage_calendars);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_calendars');
|
||||
|
||||
$form = new Form("index.php?module=config-calendars&action=update_order", "post");
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->calendar);
|
||||
$table->construct_header($lang->order, array('width' => '5%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3, "width" => 300));
|
||||
|
||||
$query = $db->simple_select("calendars", "*", "", array('order_by' => 'disporder'));
|
||||
while($calendar = $db->fetch_array($query))
|
||||
{
|
||||
$calendar['name'] = htmlspecialchars_uni($calendar['name']);
|
||||
$table->construct_cell("<a href=\"index.php?module=config-calendars&action=edit&cid={$calendar['cid']}\"><strong>{$calendar['name']}</strong></a>");
|
||||
$table->construct_cell($form->generate_numeric_field("disporder[{$calendar['cid']}]", $calendar['disporder'], array('id' => 'disporder', 'style' => 'width: 80%', 'class' => 'align_center', 'min' => 0)));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-calendars&action=edit&cid={$calendar['cid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-calendars&action=permissions&cid={$calendar['cid']}\">{$lang->permissions}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-calendars&action=delete&cid={$calendar['cid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_calendar_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_calendars, array('colspan' => 5));
|
||||
$table->construct_row();
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
$table->output($lang->manage_calendars);
|
||||
|
||||
if(!$no_results)
|
||||
{
|
||||
$buttons[] = $form->generate_submit_button($lang->save_calendar_orders);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
}
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
624
webroot/forum/admin/modules/config/help_documents.php
Normal file
624
webroot/forum/admin/modules/config/help_documents.php
Normal file
@@ -0,0 +1,624 @@
|
||||
<?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->help_documents, "index.php?module=config-help_documents");
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_begin");
|
||||
|
||||
// Add something
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_help_documents_add");
|
||||
|
||||
// Add section
|
||||
if($mybb->input['type'] == "section")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_help_documents_add_section");
|
||||
|
||||
// Do add?
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(empty($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_name;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_description;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['enabled']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_enabled;
|
||||
}
|
||||
|
||||
if($mybb->input['enabled'] != 1)
|
||||
{
|
||||
$mybb->input['enabled'] = 0;
|
||||
}
|
||||
|
||||
if(!is_array($errors))
|
||||
{
|
||||
$sql_array = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"usetranslation" => $mybb->get_input('usetranslation', MyBB::INPUT_INT),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$sid = $db->insert_query("helpsections", $sql_array);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_add_section_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($sid, $mybb->input['name'], 'section');
|
||||
|
||||
flash_message($lang->success_help_section_added, 'success');
|
||||
admin_redirect('index.php?module=config-help_documents');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_section);
|
||||
$page->output_header($lang->help_documents." - ".$lang->add_new_section);
|
||||
|
||||
$sub_tabs['manage_help_documents'] = array(
|
||||
'title' => $lang->manage_help_documents,
|
||||
'link' => "index.php?module=config-help_documents"
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_document'] = array(
|
||||
'title' => $lang->add_new_document,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=document"
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_section'] = array(
|
||||
'title' => $lang->add_new_section,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=section",
|
||||
'description' => $lang->add_new_section_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_help_section');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("helpsections", "MAX(disporder) as maxdisp");
|
||||
$mybb->input['disporder'] = $db->fetch_field($query, "maxdisp")+1;
|
||||
$mybb->input['enabled'] = 1;
|
||||
$mybb->input['usetranslation'] = 1;
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-help_documents&action=add&type=section", "post", "add");
|
||||
echo $form->generate_hidden_field("usetranslation", $mybb->input['usetranslation']);
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_section);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio('enabled', $mybb->input['enabled']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_section);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
}
|
||||
|
||||
// Add page
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_config_help_documents_add_page");
|
||||
|
||||
// Do add?
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(empty($mybb->input['sid']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_sid;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_name;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_description;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['document']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_document;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['enabled']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_enabled;
|
||||
}
|
||||
|
||||
if($mybb->input['enabled'] != 1)
|
||||
{
|
||||
$mybb->input['enabled'] = 0;
|
||||
}
|
||||
|
||||
if(!is_array($errors))
|
||||
{
|
||||
$sql_array = array(
|
||||
"sid" => $mybb->get_input('sid', MyBB::INPUT_INT),
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"document" => $db->escape_string($mybb->input['document']),
|
||||
"usetranslation" => $mybb->get_input('usetranslation', MyBB::INPUT_INT),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$hid = $db->insert_query("helpdocs", $sql_array);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_add_page_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($hid, $mybb->input['name'], 'document');
|
||||
|
||||
flash_message($lang->success_help_document_added, 'success');
|
||||
admin_redirect('index.php?module=config-help_documents');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_document);
|
||||
$page->output_header($lang->help_documents." - ".$lang->add_new_document);
|
||||
|
||||
$sub_tabs['manage_help_documents'] = array(
|
||||
'title' => $lang->manage_help_documents,
|
||||
'link' => "index.php?module=config-help_documents"
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_document'] = array(
|
||||
'title' => $lang->add_new_document,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=document",
|
||||
'description' => $lang->add_new_document_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_section'] = array(
|
||||
'title' => $lang->add_new_section,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=section"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_help_document');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the largest existing display order
|
||||
$query = $db->simple_select("helpdocs", "MAX(disporder) as maxdisp");
|
||||
$mybb->input['disporder'] = $db->fetch_field($query, "maxdisp")+1;
|
||||
$mybb->input['enabled'] = 1;
|
||||
$mybb->input['usetranslation'] = 1;
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-help_documents&action=add&type=document", "post", "add");
|
||||
echo $form->generate_hidden_field("usetranslation", $mybb->input['usetranslation']);
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_document);
|
||||
$query = $db->simple_select("helpsections", "sid, name");
|
||||
|
||||
$sections = array();
|
||||
while($section = $db->fetch_array($query))
|
||||
{
|
||||
$sections[$section['sid']] = $section['name'];
|
||||
}
|
||||
$form_container->output_row($lang->section." <em>*</em>", "", $form->generate_select_box("sid", $sections, $mybb->input['sid'], array('id' => 'sid')), 'sid');
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->document." <em>*</em>", "", $form->generate_text_area('document', $mybb->input['document'], array('id' => 'document')), 'document');
|
||||
$form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio('enabled', $mybb->input['enabled']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_document);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
// Edit something
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_help_documents_edit");
|
||||
|
||||
// Edit a section
|
||||
if($mybb->input['sid'] && !$mybb->input['hid'])
|
||||
{
|
||||
$query = $db->simple_select("helpsections", "*", "sid = '".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
|
||||
$section = $db->fetch_array($query);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_edit_section");
|
||||
|
||||
// Do edit?
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$sid = $mybb->get_input('sid', MyBB::INPUT_INT);
|
||||
|
||||
if(empty($sid))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_sid;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_name;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_description;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['enabled']))
|
||||
{
|
||||
$errors[] = $lang->error_section_missing_enabled;
|
||||
}
|
||||
|
||||
if($mybb->input['enabled'] != 1)
|
||||
{
|
||||
$mybb->input['enabled'] = 0;
|
||||
}
|
||||
|
||||
if(!is_array($errors))
|
||||
{
|
||||
$sql_array = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"usetranslation" => $mybb->get_input('usetranslation', MyBB::INPUT_INT),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_edit_section_commit");
|
||||
|
||||
$db->update_query("helpsections", $sql_array, "sid = '{$sid}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($sid, $mybb->input['name'], 'section');
|
||||
|
||||
flash_message($lang->success_help_section_updated, 'success');
|
||||
admin_redirect('index.php?module=config-help_documents');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_section);
|
||||
$page->output_header($lang->help_documents." - ".$lang->edit_section);
|
||||
|
||||
|
||||
$sub_tabs['edit_help_section'] = array(
|
||||
'title' => $lang->edit_section,
|
||||
'link' => "index.php?module=config-help_documents&action=edit&sid=".$section['sid'],
|
||||
'description' => $lang->edit_section_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_help_section');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['sid'] = $section['sid'];
|
||||
$mybb->input['name'] = $section['name'];
|
||||
$mybb->input['description'] = $section['description'];
|
||||
$mybb->input['disporder'] = $section['disporder'];
|
||||
$mybb->input['enabled'] = $section['enabled'];
|
||||
$mybb->input['usetranslation'] = $section['usetranslation'];
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-help_documents&action=edit", "post", "edit");
|
||||
|
||||
echo $form->generate_hidden_field("sid", $section['sid']);
|
||||
echo $form->generate_hidden_field("usetranslation", $mybb->input['usetranslation']);
|
||||
|
||||
$form_container = new FormContainer($lang->edit_section." ({$lang->id} ".$section['sid'].")");
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio('enabled', $mybb->input['enabled']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->edit_section);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
}
|
||||
|
||||
// Edit document
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_config_help_documents_edit_page");
|
||||
|
||||
// Do edit?
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$hid = $mybb->get_input('hid', MyBB::INPUT_INT);
|
||||
|
||||
if(empty($hid))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_sid;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_name;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_description;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['document']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_document;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['enabled']))
|
||||
{
|
||||
$errors[] = $lang->error_document_missing_enabled;
|
||||
}
|
||||
|
||||
if($mybb->input['enabled'] != 1)
|
||||
{
|
||||
$mybb->input['enabled'] = 0;
|
||||
}
|
||||
|
||||
if(!is_array($errors))
|
||||
{
|
||||
$sql_array = array(
|
||||
"sid" => $mybb->get_input('sid', MyBB::INPUT_INT),
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"document" => $db->escape_string($mybb->input['document']),
|
||||
"usetranslation" => $mybb->get_input('usetranslation', MyBB::INPUT_INT),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_edit_page_commit");
|
||||
|
||||
$db->update_query("helpdocs", $sql_array, "hid = '{$hid}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($hid, $mybb->input['name'], 'document');
|
||||
|
||||
flash_message($lang->success_help_document_updated, 'success');
|
||||
admin_redirect('index.php?module=config-help_documents');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_document);
|
||||
$page->output_header($lang->help_documents." - ".$lang->edit_document);
|
||||
|
||||
|
||||
$sub_tabs['edit_help_document'] = array(
|
||||
'title' => $lang->edit_document,
|
||||
'link' => "index.php?module=config-help_documents&action=edit&hid=".$hid,
|
||||
'description' => $lang->edit_document_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_help_document');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("helpdocs", "*", "hid = '".$mybb->get_input('hid', MyBB::INPUT_INT)."'");
|
||||
$doc = $db->fetch_array($query);
|
||||
$mybb->input['hid'] = $doc['hid'];
|
||||
$mybb->input['sid'] = $doc['sid'];
|
||||
$mybb->input['name'] = $doc['name'];
|
||||
$mybb->input['description'] = $doc['description'];
|
||||
$mybb->input['document'] = $doc['document'];
|
||||
$mybb->input['disporder'] = $doc['disporder'];
|
||||
$mybb->input['enabled'] = $doc['enabled'];
|
||||
$mybb->input['usetranslation'] = $doc['usetranslation'];
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-help_documents&action=edit", "post", "edit");
|
||||
|
||||
echo $form->generate_hidden_field("hid", $doc['hid']);
|
||||
echo $form->generate_hidden_field("usetranslation", $mybb->input['usetranslation']);
|
||||
|
||||
$form_container = new FormContainer($lang->edit_document." ({$lang->id} ".$doc['hid'].")");
|
||||
|
||||
$sections = array();
|
||||
$query = $db->simple_select("helpsections", "sid, name");
|
||||
while($section = $db->fetch_array($query))
|
||||
{
|
||||
$sections[$section['sid']] = $section['name'];
|
||||
}
|
||||
$form_container->output_row($lang->section." <em>*</em>", "", $form->generate_select_box("sid", $sections, $mybb->input['sid']), 'sid');
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->document." <em>*</em>", "", $form->generate_text_area('document', $mybb->input['document'], array('id' => 'document')), 'document');
|
||||
$form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio('enabled', $mybb->input['enabled']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->edit_document);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
// Delete something
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-help_documents");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_delete");
|
||||
|
||||
// Do delete something?
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete section
|
||||
if(isset($mybb->input['sid']))
|
||||
{
|
||||
$sid = $mybb->get_input('sid', MyBB::INPUT_INT);
|
||||
|
||||
$query = $db->simple_select("helpsections", "*", "sid='{$sid}'");
|
||||
$section = $db->fetch_array($query);
|
||||
|
||||
// Invalid section?
|
||||
if(!$section['sid'])
|
||||
{
|
||||
flash_message($lang->error_missing_section_id, 'error');
|
||||
admin_redirect("index.php?module=config-help_documents");
|
||||
}
|
||||
|
||||
// Delete section and its documents
|
||||
$db->delete_query("helpsections", "sid = '{$section['sid']}'", 1);
|
||||
$db->delete_query("helpdocs", "sid = '{$section['sid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_delete_section_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($section['sid'], $section['name'], 'section');
|
||||
|
||||
flash_message($lang->success_section_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-help_documents");
|
||||
}
|
||||
|
||||
// Delete document
|
||||
else
|
||||
{
|
||||
$hid = $mybb->get_input('hid', MyBB::INPUT_INT);
|
||||
|
||||
$query = $db->simple_select("helpdocs", "*", "hid='{$hid}'");
|
||||
$doc = $db->fetch_array($query);
|
||||
|
||||
// Invalid document?
|
||||
if(!$doc['hid'])
|
||||
{
|
||||
flash_message($lang->error_missing_hid, 'error');
|
||||
admin_redirect("index.php?module=config-help_documents");
|
||||
}
|
||||
|
||||
$db->delete_query("helpdocs", "hid = '{$doc['hid']}'", 1);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_delete_page_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($doc['hid'], $doc['name'], 'document');
|
||||
|
||||
flash_message($lang->success_document_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-help_documents");
|
||||
}
|
||||
}
|
||||
// Show form for deletion
|
||||
else
|
||||
{
|
||||
// Section
|
||||
if(isset($mybb->input['sid']))
|
||||
{
|
||||
$sid = $mybb->get_input('sid', MyBB::INPUT_INT);
|
||||
$page->output_confirm_action("index.php?module=config-help_documents&action=delete&sid={$sid}", $lang->confirm_section_deletion);
|
||||
}
|
||||
// Document
|
||||
else
|
||||
{
|
||||
$hid = $mybb->get_input('hid', MyBB::INPUT_INT);
|
||||
$page->output_confirm_action("index.php?module=config-help_documents&action=delete&hid={$hid}", $lang->confirm_document_deletion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List document and sections
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->help_documents);
|
||||
|
||||
$sub_tabs['manage_help_documents'] = array(
|
||||
'title' => $lang->manage_help_documents,
|
||||
'link' => "index.php?module=config-help_documents",
|
||||
'description'=> $lang->manage_help_documents_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_document'] = array(
|
||||
'title' => $lang->add_new_document,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=document"
|
||||
);
|
||||
|
||||
$sub_tabs['add_help_section'] = array(
|
||||
'title' => $lang->add_new_section,
|
||||
'link' => "index.php?module=config-help_documents&action=add&type=section"
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_help_documents_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_help_documents');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->section_document);
|
||||
$table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2, "width" => "150"));
|
||||
|
||||
$query = $db->simple_select("helpsections", "*", "", array('order_by' => "disporder"));
|
||||
while($section = $db->fetch_array($query))
|
||||
{
|
||||
$table->construct_cell("<div><strong><a href=\"index.php?module=config-help_documents&action=edit&sid={$section['sid']}\">{$section['name']}</a></strong><br /><small>{$section['description']}</small></div>");
|
||||
$table->construct_cell("<a href=\"index.php?module=config-help_documents&action=edit&sid={$section['sid']}\">{$lang->edit}</a>", array("class" => "align_center", "width" => '60'));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-help_documents&action=delete&sid={$section['sid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_section_deletion}')\">{$lang->delete}</a>", array("class" => "align_center", "width" => '90'));
|
||||
$table->construct_row();
|
||||
|
||||
$query2 = $db->simple_select("helpdocs", "*", "sid='{$section['sid']}'", array('order_by' => "disporder"));
|
||||
while($doc = $db->fetch_array($query2))
|
||||
{
|
||||
$table->construct_cell("<div style=\"padding-left: 40px;\"><div><strong><a href=\"index.php?module=config-help_documents&action=edit&hid={$doc['hid']}\">{$doc['name']}</a></strong><br /><small>{$doc['description']}</small></div></div>");
|
||||
$table->construct_cell("<a href=\"index.php?module=config-help_documents&action=edit&hid={$doc['hid']}\">{$lang->edit}</a>", array("class" => "align_center", "width" => '60'));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-help_documents&action=delete&hid={$doc['hid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_document_deletion}')\">{$lang->delete}</a>", array("class" => "align_center", "width" => '90'));
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
// No documents message
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_help_documents, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->help_documents);
|
||||
$page->output_footer();
|
||||
}
|
||||
8
webroot/forum/admin/modules/config/index.html
Normal file
8
webroot/forum/admin/modules/config/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1075
webroot/forum/admin/modules/config/languages.php
Normal file
1075
webroot/forum/admin/modules/config/languages.php
Normal file
File diff suppressed because it is too large
Load Diff
2362
webroot/forum/admin/modules/config/mod_tools.php
Normal file
2362
webroot/forum/admin/modules/config/mod_tools.php
Normal file
File diff suppressed because it is too large
Load Diff
128
webroot/forum/admin/modules/config/module_meta.php
Normal file
128
webroot/forum/admin/modules/config/module_meta.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function config_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "settings", "title" => $lang->bbsettings, "link" => "index.php?module=config-settings");
|
||||
$sub_menu['20'] = array("id" => "banning", "title" => $lang->banning, "link" => "index.php?module=config-banning");
|
||||
$sub_menu['30'] = array("id" => "profile_fields", "title" => $lang->custom_profile_fields, "link" => "index.php?module=config-profile_fields");
|
||||
$sub_menu['40'] = array("id" => "smilies", "title" => $lang->smilies, "link" => "index.php?module=config-smilies");
|
||||
$sub_menu['50'] = array("id" => "badwords", "title" => $lang->word_filters, "link" => "index.php?module=config-badwords");
|
||||
$sub_menu['60'] = array("id" => "mycode", "title" => $lang->mycode, "link" => "index.php?module=config-mycode");
|
||||
$sub_menu['70'] = array("id" => "languages", "title" => $lang->languages, "link" => "index.php?module=config-languages");
|
||||
$sub_menu['80'] = array("id" => "post_icons", "title" => $lang->post_icons, "link" => "index.php?module=config-post_icons");
|
||||
$sub_menu['90'] = array("id" => "help_documents", "title" => $lang->help_documents, "link" => "index.php?module=config-help_documents");
|
||||
$sub_menu['100'] = array("id" => "plugins", "title" => $lang->plugins, "link" => "index.php?module=config-plugins");
|
||||
$sub_menu['110'] = array("id" => "attachment_types", "title" => $lang->attachment_types, "link" => "index.php?module=config-attachment_types");
|
||||
$sub_menu['120'] = array("id" => "mod_tools", "title" => $lang->moderator_tools, "link" => "index.php?module=config-mod_tools");
|
||||
$sub_menu['130'] = array("id" => "spiders", "title" => $lang->spiders_bots, "link" => "index.php?module=config-spiders");
|
||||
$sub_menu['140'] = array("id" => "calendars", "title" => $lang->calendars, "link" => "index.php?module=config-calendars");
|
||||
$sub_menu['150'] = array("id" => "warning", "title" => $lang->warning_system, "link" => "index.php?module=config-warning");
|
||||
$sub_menu['160'] = array("id" => "thread_prefixes", "title" => $lang->thread_prefixes, "link" => "index.php?module=config-thread_prefixes");
|
||||
$sub_menu['170'] = array("id" => "questions", "title" => $lang->security_questions, "link" => "index.php?module=config-questions");
|
||||
$sub_menu['180'] = array("id" => "report_reasons", "title" => $lang->report_reasons, "link" => "index.php?module=config-report_reasons");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_config_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->configuration, "config", "index.php?module=config", 10, $sub_menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function config_action_handler($action)
|
||||
{
|
||||
global $page, $plugins;
|
||||
|
||||
$page->active_module = "config";
|
||||
|
||||
$actions = array(
|
||||
'plugins' => array('active' => 'plugins', 'file' => 'plugins.php'),
|
||||
'smilies' => array('active' => 'smilies', 'file' => 'smilies.php'),
|
||||
'banning' => array('active' => 'banning', 'file' => 'banning.php'),
|
||||
'badwords' => array('active' => 'badwords', 'file' => 'badwords.php'),
|
||||
'profile_fields' => array('active' => 'profile_fields', 'file' => 'profile_fields.php'),
|
||||
'spiders' => array('active' => 'spiders', 'file' => 'spiders.php'),
|
||||
'attachment_types' => array('active' => 'attachment_types', 'file' => 'attachment_types.php'),
|
||||
'languages' => array('active' => 'languages', 'file' => 'languages.php'),
|
||||
'post_icons' => array('active' => 'post_icons', 'file' => 'post_icons.php'),
|
||||
'help_documents' => array('active' => 'help_documents', 'file' => 'help_documents.php'),
|
||||
'calendars' => array('active' => 'calendars', 'file' => 'calendars.php'),
|
||||
'warning' => array('active' => 'warning', 'file' => 'warning.php'),
|
||||
'mod_tools' => array('active' => 'mod_tools', 'file' => 'mod_tools.php'),
|
||||
'mycode' => array('active' => 'mycode', 'file' => 'mycode.php'),
|
||||
'settings' => array('active' => 'settings', 'file' => 'settings.php'),
|
||||
'thread_prefixes' => array('active' => 'thread_prefixes', 'file' => 'thread_prefixes.php'),
|
||||
'questions' => array('active' => 'questions', 'file' => 'questions.php'),
|
||||
'report_reasons' => array('active' => 'report_reasons', 'file' => 'report_reasons.php')
|
||||
);
|
||||
|
||||
$actions = $plugins->run_hooks("admin_config_action_handler", $actions);
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = "settings";
|
||||
return "settings.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function config_admin_permissions()
|
||||
{
|
||||
global $lang, $plugins;
|
||||
|
||||
$admin_permissions = array(
|
||||
"settings" => $lang->can_manage_settings,
|
||||
"banning" => $lang->can_manage_banned_accounts,
|
||||
"profile_fields" => $lang->can_manage_custom_profile_fields,
|
||||
"smilies" => $lang->can_manage_smilies,
|
||||
"badwords" => $lang->can_manage_bad_words,
|
||||
"mycode" => $lang->can_manage_custom_mycode,
|
||||
"languages" => $lang->can_manage_language_packs,
|
||||
"post_icons" => $lang->can_manage_post_icons,
|
||||
"help_documents" => $lang->can_manage_help_documents,
|
||||
"plugins" => $lang->can_manage_plugins,
|
||||
"attachment_types" => $lang->can_manage_attachment_types,
|
||||
"spiders" => $lang->can_manage_spiders_bots,
|
||||
"calendars" => $lang->can_manage_calendars,
|
||||
"warning" => $lang->can_manage_warning_system,
|
||||
"mod_tools" => $lang->can_manage_mod_tools,
|
||||
"thread_prefixes" => $lang->can_manage_thread_prefixes,
|
||||
"questions" => $lang->can_manage_security_questions,
|
||||
"report_reasons" => $lang->can_manage_report_reasons
|
||||
);
|
||||
|
||||
$admin_permissions = $plugins->run_hooks("admin_config_permissions", $admin_permissions);
|
||||
|
||||
return array("name" => $lang->configuration, "permissions" => $admin_permissions, "disporder" => 10);
|
||||
}
|
||||
488
webroot/forum/admin/modules/config/mycode.php
Normal file
488
webroot/forum/admin/modules/config/mycode.php
Normal file
@@ -0,0 +1,488 @@
|
||||
<?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->mycode, "index.php?module=config-mycode");
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_begin");
|
||||
|
||||
if($mybb->input['action'] == "toggle_status")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$mycode = $db->fetch_array($query);
|
||||
|
||||
if(!$mycode['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_mycode, 'error');
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_toggle_status");
|
||||
|
||||
if($mycode['active'] == 1)
|
||||
{
|
||||
$new_status = 0;
|
||||
$phrase = $lang->success_deactivated_mycode;
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_status = 1;
|
||||
$phrase = $lang->success_activated_mycode;
|
||||
}
|
||||
$mycode_update = array(
|
||||
'active' => $new_status,
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_toggle_status_commit");
|
||||
|
||||
$db->update_query("mycode", $mycode_update, "cid='{$mycode['cid']}'");
|
||||
|
||||
$cache->update_mycode();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mycode['cid'], $mycode['title'], $new_status);
|
||||
|
||||
flash_message($phrase, 'success');
|
||||
admin_redirect('index.php?module=config-mycode');
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "xmlhttp_test_mycode" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_mycode_xmlhttp_test_mycode_start");
|
||||
|
||||
// Send no cache headers
|
||||
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-type: text/html");
|
||||
|
||||
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_xmlhttp_test_mycode_end");
|
||||
|
||||
echo $sandbox['actual'];
|
||||
exit;
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_mycode_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['regex']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_regex;
|
||||
}
|
||||
|
||||
$regex = str_replace("\x0", "", $mybb->input['regex']);
|
||||
|
||||
if(check_existing_regex($regex))
|
||||
{
|
||||
$errors[] = $lang->error_regex_already_available;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['replacement']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_replacement;
|
||||
}
|
||||
|
||||
if($mybb->input['test'])
|
||||
{
|
||||
$errors[] = $lang->changes_not_saved;
|
||||
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_mycode = array(
|
||||
'title' => $db->escape_string($mybb->input['title']),
|
||||
'description' => $db->escape_string($mybb->input['description']),
|
||||
'regex' => $db->escape_string($regex),
|
||||
'replacement' => $db->escape_string($mybb->input['replacement']),
|
||||
'active' => $mybb->get_input('active', MyBB::INPUT_INT),
|
||||
'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$cid = $db->insert_query("mycode", $new_mycode);
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_add_commit");
|
||||
|
||||
$cache->update_mycode();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($cid, $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_added_mycode, 'success');
|
||||
admin_redirect('index.php?module=config-mycode');
|
||||
}
|
||||
}
|
||||
|
||||
$sub_tabs['mycode'] = array(
|
||||
'title' => $lang->mycode,
|
||||
'link' => "index.php?module=config-mycode",
|
||||
'description' => $lang->mycode_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_new_mycode'] = array(
|
||||
'title' => $lang->add_new_mycode,
|
||||
'link' => "index.php?module=config-mycode&action=add",
|
||||
'description' => $lang->add_new_mycode_desc
|
||||
);
|
||||
|
||||
$page->extra_header .= "
|
||||
<script type=\"text/javascript\">
|
||||
var my_post_key = '".$mybb->post_code."';
|
||||
lang.mycode_sandbox_test_error = \"{$lang->mycode_sandbox_test_error}\";
|
||||
</script>";
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_mycode);
|
||||
$page->output_header($lang->custom_mycode." - ".$lang->add_new_mycode);
|
||||
$page->output_nav_tabs($sub_tabs, 'add_new_mycode');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['active'] = 1;
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-mycode&action=add", "post", "add");
|
||||
$form_container = new FormContainer($lang->add_mycode);
|
||||
$form_container->output_row($lang->title." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_description, '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->regular_expression." <em>*</em>", $lang->regular_expression_desc.'<br /><strong>'.$lang->example.'</strong> \[b\](.*?)\[/b\]', $form->generate_text_area('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex');
|
||||
$form_container->output_row($lang->replacement." <em>*</em>", $lang->replacement_desc.'<br /><strong>'.$lang->example.'</strong> <strong>$1</strong>', $form->generate_text_area('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", '', $form->generate_yes_no_radio('active', $mybb->input['active']));
|
||||
$form_container->output_row($lang->parse_order, $lang->parse_order_desc, $form->generate_numeric_field('parseorder', $mybb->input['parseorder'], array('id' => 'parseorder', 'min' => 0)), 'parseorder');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_mycode);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
// Sandbox
|
||||
echo "<br />\n";
|
||||
$form_container = new FormContainer($lang->sandbox);
|
||||
$form_container->output_row($lang->sandbox_desc);
|
||||
$form_container->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->input['test_value'], array('id' => 'test_value'))."<br />".$form->generate_submit_button($lang->test, array('id' => 'test', 'name' => 'test')), 'test_value');
|
||||
$form_container->output_row($lang->result_html, $lang->result_html_desc, $form->generate_text_area('result_html', $sandbox['html'], array('id' => 'result_html', 'disabled' => 1)), 'result_html');
|
||||
$form_container->output_row($lang->result_actual, $lang->result_actual_desc, "<div id=\"result_actual\">{$sandbox['actual']}</div>");
|
||||
$form_container->end();
|
||||
echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
|
||||
echo '<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
$(function(){
|
||||
new MyCodeSandbox("./index.php?module=config-mycode&action=xmlhttp_test_mycode", $("#test"), $("#regex"), $("#replacement"), $("#test_value"), $("#result_html"), $("#result_actual"));
|
||||
});
|
||||
//]]>
|
||||
</script>';
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$mycode = $db->fetch_array($query);
|
||||
|
||||
if(!$mycode['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_mycode, 'error');
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['regex']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_regex;
|
||||
}
|
||||
|
||||
$regex = str_replace("\x0", "", $mybb->input['regex']);
|
||||
|
||||
if(check_existing_regex($regex, $mycode))
|
||||
{
|
||||
$errors[] = $lang->error_regex_already_available;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['replacement']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_replacement;
|
||||
}
|
||||
|
||||
if($mybb->input['test'])
|
||||
{
|
||||
$errors[] = $lang->changes_not_saved;
|
||||
$sandbox = test_regex($mybb->input['regex'], $mybb->input['replacement'], $mybb->input['test_value']);
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_mycode = array(
|
||||
'title' => $db->escape_string($mybb->input['title']),
|
||||
'description' => $db->escape_string($mybb->input['description']),
|
||||
'regex' => $db->escape_string($regex),
|
||||
'replacement' => $db->escape_string($mybb->input['replacement']),
|
||||
'active' => $mybb->get_input('active', MyBB::INPUT_INT),
|
||||
'parseorder' => $mybb->get_input('parseorder', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_edit_commit");
|
||||
|
||||
$db->update_query("mycode", $updated_mycode, "cid='{$mycode['cid']}'");
|
||||
|
||||
$cache->update_mycode();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mycode['cid'], $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_updated_mycode, 'success');
|
||||
admin_redirect('index.php?module=config-mycode');
|
||||
}
|
||||
}
|
||||
|
||||
$sub_tabs['edit_mycode'] = array(
|
||||
'title' => $lang->edit_mycode,
|
||||
'link' => "index.php?module=config-mycode&action=edit",
|
||||
'description' => $lang->edit_mycode_desc
|
||||
);
|
||||
|
||||
$page->extra_header .= "
|
||||
<script type=\"text/javascript\">
|
||||
var my_post_key = '".$mybb->post_code."';
|
||||
lang.mycode_sandbox_test_error = \"{$lang->mycode_sandbox_test_error}\";
|
||||
</script>";
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_mycode);
|
||||
$page->output_header($lang->custom_mycode." - ".$lang->edit_mycode);
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_mycode');
|
||||
|
||||
$form = new Form("index.php?module=config-mycode&action=edit", "post", "edit");
|
||||
echo $form->generate_hidden_field('cid', $mycode['cid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $mycode);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_mycode);
|
||||
$form_container->output_row($lang->title." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_description, '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$form_container->output_row($lang->regular_expression." <em>*</em>", $lang->regular_expression_desc.'<br /><strong>'.$lang->example.'</strong> \[b\](.*?)\[/b\]', $form->generate_text_area('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex');
|
||||
$form_container->output_row($lang->replacement." <em>*</em>", $lang->replacement_desc.'<br /><strong>'.$lang->example.'</strong> <strong>$1</strong>', $form->generate_text_area('replacement', $mybb->input['replacement'], array('id' => 'replacement')), 'replacement');
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", '', $form->generate_yes_no_radio('active', $mybb->input['active']));
|
||||
$form_container->output_row($lang->parse_order, $lang->parse_order_desc, $form->generate_numeric_field('parseorder', $mybb->input['parseorder'], array('id' => 'parseorder', 'min' => 0)), 'parseorder');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_mycode);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
// Sandbox
|
||||
echo "<br />\n";
|
||||
$form_container = new FormContainer($lang->sandbox);
|
||||
$form_container->output_row($lang->sandbox_desc);
|
||||
$form_container->output_row($lang->test_value, $lang->test_value_desc, $form->generate_text_area('test_value', $mybb->input['test_value'], array('id' => 'test_value'))."<br />".$form->generate_submit_button($lang->test, array('id' => 'test', 'name' => 'test')), 'test_value');
|
||||
$form_container->output_row($lang->result_html, $lang->result_html_desc, $form->generate_text_area('result_html', $sandbox['html'], array('id' => 'result_html', 'disabled' => 1)), 'result_html');
|
||||
$form_container->output_row($lang->result_actual, $lang->result_actual_desc, "<div id=\"result_actual\">{$sandbox['actual']}</div>");
|
||||
$form_container->end();
|
||||
echo '<script type="text/javascript" src="./jscripts/mycode_sandbox.js"></script>';
|
||||
echo '<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
//<![CDATA[
|
||||
new MyCodeSandbox("./index.php?module=config-mycode&action=xmlhttp_test_mycode", $("#test"), $("#regex"), $("#replacement"), $("#test_value"), $("#result_html"), $("#result_actual"));
|
||||
});
|
||||
//]]>
|
||||
</script>';
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("mycode", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'");
|
||||
$mycode = $db->fetch_array($query);
|
||||
|
||||
if(!$mycode['cid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_mycode, 'error');
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_delete");
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("mycode", "cid='{$mycode['cid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_mycode_delete_commit");
|
||||
|
||||
$cache->update_mycode();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mycode['cid'], $mycode['title']);
|
||||
|
||||
flash_message($lang->success_deleted_mycode, 'success');
|
||||
admin_redirect("index.php?module=config-mycode");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-mycode&action=delete&cid={$mycode['cid']}", $lang->confirm_mycode_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_mycode_start");
|
||||
|
||||
$page->output_header($lang->custom_mycode);
|
||||
|
||||
$sub_tabs['mycode'] = array(
|
||||
'title' => $lang->mycode,
|
||||
'link' => "index.php?module=config-mycode",
|
||||
'description' => $lang->mycode_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_new_mycode'] = array(
|
||||
'title' => $lang->add_new_mycode,
|
||||
'link' => "index.php?module=config-mycode&action=add"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'mycode');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->title);
|
||||
$table->construct_header($lang->controls, array('class' => 'align_center', 'width' => 150));
|
||||
|
||||
$query = $db->simple_select("mycode", "*", "", array('order_by' => 'parseorder'));
|
||||
while($mycode = $db->fetch_array($query))
|
||||
{
|
||||
if($mycode['active'] == 1)
|
||||
{
|
||||
$phrase = $lang->deactivate_mycode;
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$phrase = $lang->activate_mycode;
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
if($mycode['description'])
|
||||
{
|
||||
$mycode['description'] = "<small>".htmlspecialchars_uni($mycode['description'])."</small>";
|
||||
}
|
||||
|
||||
$table->construct_cell("<div>{$icon}<strong><a href=\"index.php?module=config-mycode&action=edit&cid={$mycode['cid']}\">".htmlspecialchars_uni($mycode['title'])."</a></strong><br />{$mycode['description']}</div>");
|
||||
|
||||
$popup = new PopupMenu("mycode_{$mycode['cid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_mycode, "index.php?module=config-mycode&action=edit&cid={$mycode['cid']}");
|
||||
$popup->add_item($phrase, "index.php?module=config-mycode&action=toggle_status&cid={$mycode['cid']}&my_post_key={$mybb->post_code}");
|
||||
$popup->add_item($lang->delete_mycode, "index.php?module=config-mycode&action=delete&cid={$mycode['cid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_mycode_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array('class' => 'align_center'));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_mycode, array('colspan' => 2));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->custom_mycode);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $regex
|
||||
* @param string $replacement
|
||||
* @param string $test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function test_regex($regex, $replacement, $test)
|
||||
{
|
||||
$array = array();
|
||||
$array['actual'] = @preg_replace("#".str_replace("\x0", "", $regex)."#si", $replacement, $test);
|
||||
$array['html'] = htmlspecialchars_uni($array['actual']);
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a regex is already available
|
||||
*
|
||||
* @param string $regex The regex to check
|
||||
* @param array $current The currently edited MyCode
|
||||
*
|
||||
* @return bool True if already available, false otherwise
|
||||
*/
|
||||
function check_existing_regex($regex='', $current=array())
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if(!empty($current) && $current['regex'] == $regex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$mycodes = $cache->read('mycode');
|
||||
|
||||
foreach($mycodes as $mycode)
|
||||
{
|
||||
if($mycode['regex'] == $regex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
715
webroot/forum/admin/modules/config/plugins.php
Normal file
715
webroot/forum/admin/modules/config/plugins.php
Normal file
@@ -0,0 +1,715 @@
|
||||
<?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->plugins, "index.php?module=config-plugins");
|
||||
|
||||
$plugins->run_hooks("admin_config_plugins_begin");
|
||||
|
||||
if($mybb->input['action'] == "browse")
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->browse_plugins);
|
||||
|
||||
$page->output_header($lang->browse_plugins);
|
||||
|
||||
$sub_tabs['plugins'] = array(
|
||||
'title' => $lang->plugins,
|
||||
'link' => "index.php?module=config-plugins",
|
||||
'description' => $lang->plugins_desc
|
||||
);
|
||||
$sub_tabs['update_plugins'] = array(
|
||||
'title' => $lang->plugin_updates,
|
||||
'link' => "index.php?module=config-plugins&action=check",
|
||||
'description' => $lang->plugin_updates_desc
|
||||
);
|
||||
|
||||
$sub_tabs['browse_plugins'] = array(
|
||||
'title' => $lang->browse_plugins,
|
||||
'link' => "index.php?module=config-plugins&action=browse",
|
||||
'description' => $lang->browse_plugins_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'browse_plugins');
|
||||
|
||||
// Process search requests
|
||||
require_once MYBB_ROOT."inc/class_xml.php";
|
||||
|
||||
$keywords = "";
|
||||
if($mybb->input['keywords'])
|
||||
{
|
||||
$keywords = "&keywords=".urlencode($mybb->input['keywords']);
|
||||
}
|
||||
|
||||
if($mybb->input['page'])
|
||||
{
|
||||
$url_page = "&page=".$mybb->get_input('page', MyBB::INPUT_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$url_page = "";
|
||||
}
|
||||
|
||||
// Gets the major version code. i.e. 1410 -> 1400 or 121 -> 1200
|
||||
$major_version_code = round($mybb->version_code/100, 0)*100;
|
||||
// Convert to mods site version codes
|
||||
$search_version = ($major_version_code/100).'x';
|
||||
|
||||
$contents = fetch_remote_file("https://community.mybb.com/xmlbrowse.php?type=plugins&version={$search_version}{$keywords}{$url_page}", $post_data);
|
||||
|
||||
if(!$contents)
|
||||
{
|
||||
$page->output_inline_error($lang->error_communication_problem);
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->plugin);
|
||||
$table->construct_header($lang->latest_version, array("class" => "align_center", 'width' => 125));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", 'width' => 125));
|
||||
|
||||
$parser = new XMLParser($contents);
|
||||
$tree = $parser->get_tree();
|
||||
|
||||
if(!is_array($tree) || !isset($tree['results']))
|
||||
{
|
||||
$page->output_inline_error($lang->error_communication_problem);
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!empty($tree['results']['result']))
|
||||
{
|
||||
if(array_key_exists("tag", $tree['results']['result']))
|
||||
{
|
||||
$only_plugin = $tree['results']['result'];
|
||||
unset($tree['results']['result']);
|
||||
$tree['results']['result'][0] = $only_plugin;
|
||||
}
|
||||
|
||||
require_once MYBB_ROOT . '/inc/class_parser.php';
|
||||
$post_parser = new postParser();
|
||||
|
||||
foreach($tree['results']['result'] as $result)
|
||||
{
|
||||
$result['name']['value'] = htmlspecialchars_uni($result['name']['value']);
|
||||
$result['description']['value'] = htmlspecialchars_uni($result['description']['value']);
|
||||
$result['author']['value'] = $post_parser->parse_message($result['author']['value'], array(
|
||||
'allow_html' => true
|
||||
)
|
||||
);
|
||||
$result['version']['value'] = htmlspecialchars_uni($result['version']['value']);
|
||||
$result['download_url']['value'] = htmlspecialchars_uni(html_entity_decode($result['download_url']['value']));
|
||||
|
||||
$table->construct_cell("<strong>{$result['name']['value']}</strong><br /><small>{$result['description']['value']}</small><br /><i><small>{$lang->created_by} {$result['author']['value']}</small></i>");
|
||||
$table->construct_cell($result['version']['value'], array("class" => "align_center"));
|
||||
$table->construct_cell("<strong><a href=\"https://community.mybb.com/{$result['download_url']['value']}\" target=\"_blank\" rel=\"noopener\">{$lang->download}</a></strong>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->error_no_results_found, array("colspan" => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$search = new Form("index.php?module=config-plugins&action=browse", 'post', 'search_form');
|
||||
echo "<div style=\"padding-bottom: 3px; margin-top: -9px; text-align: right;\">";
|
||||
if($mybb->input['keywords'])
|
||||
{
|
||||
$default_class = '';
|
||||
$value = htmlspecialchars_uni($mybb->input['keywords']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$default_class = "search_default";
|
||||
$value = $lang->search_for_plugins;
|
||||
}
|
||||
echo $search->generate_text_box('keywords', $value, array('id' => 'search_keywords', 'class' => "{$default_class} field150 field_small"))."\n";
|
||||
echo "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />\n";
|
||||
echo "<script type=\"text/javascript\">
|
||||
var form = $(\"#search_form\");
|
||||
form.on('submit', function()
|
||||
{
|
||||
var search = $(\"#search_keywords\");
|
||||
if(search.val() == '' || search.val() == '{$lang->search_for_plugins}')
|
||||
{
|
||||
search.trigger('focus');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
var search = $(\"#search_keywords\");
|
||||
search.on('focus', function()
|
||||
{
|
||||
var searched_focus = $(this);
|
||||
if(searched_focus.val() == '{$lang->search_for_plugins}')
|
||||
{
|
||||
searched_focus.removeClass(\"search_default\");
|
||||
searched_focus.val(\"\");
|
||||
}
|
||||
}).on('blur', function()
|
||||
{
|
||||
var searched_blur = $(this);
|
||||
if(searched_blur.val() == \"\")
|
||||
{
|
||||
searched_blur.addClass('search_default');
|
||||
searched_blur.val('{$lang->search_for_plugins}');
|
||||
}
|
||||
});
|
||||
|
||||
// fix the styling used if we have a different default value
|
||||
if(search.val() != '{$lang->search_for_plugins}')
|
||||
{
|
||||
search.removeClass('search_default');
|
||||
}
|
||||
</script>\n";
|
||||
echo "</div>\n";
|
||||
echo $search->end();
|
||||
|
||||
// Recommended plugins = Default; Otherwise search results & pagination
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$table->output("<span style=\"float: right;\"><small><a href=\"https://community.mybb.com/mods.php?action=browse&category=plugins\" target=\"_blank\" rel=\"noopener\">{$lang->browse_all_plugins}</a></small></span>".$lang->sprintf($lang->browse_results_for_mybb, $mybb->version));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output("<span style=\"float: right;\"><small><a href=\"https://community.mybb.com/mods.php?action=browse&category=plugins\" target=\"_blank\" rel=\"noopener\">{$lang->browse_all_plugins}</a></small></span>".$lang->sprintf($lang->recommended_plugins_for_mybb, $mybb->version));
|
||||
}
|
||||
|
||||
echo "<br />".draw_admin_pagination($mybb->input['page'], 15, $tree['results']['attributes']['total'], "index.php?module=config-plugins&action=browse{$keywords}&page={page}");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "check")
|
||||
{
|
||||
$plugins_list = get_plugins_list();
|
||||
|
||||
$plugins->run_hooks("admin_config_plugins_check");
|
||||
|
||||
$info = array();
|
||||
|
||||
if($plugins_list)
|
||||
{
|
||||
$active_hooks = $plugins->hooks;
|
||||
foreach($plugins_list as $plugin_file)
|
||||
{
|
||||
require_once MYBB_ROOT."inc/plugins/".$plugin_file;
|
||||
$codename = str_replace(".php", "", $plugin_file);
|
||||
$infofunc = $codename."_info";
|
||||
if(!function_exists($infofunc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$plugininfo = $infofunc();
|
||||
$plugininfo['guid'] = trim($plugininfo['guid']);
|
||||
$plugininfo['codename'] = trim($plugininfo['codename']);
|
||||
|
||||
if($plugininfo['codename'] != "")
|
||||
{
|
||||
$info[] = $plugininfo['codename'];
|
||||
$names[$plugininfo['codename']] = array('name' => $plugininfo['name'], 'version' => $plugininfo['version']);
|
||||
}
|
||||
elseif($plugininfo['guid'] != "")
|
||||
{
|
||||
$info[] = $plugininfo['guid'];
|
||||
$names[$plugininfo['guid']] = array('name' => $plugininfo['name'], 'version' => $plugininfo['version']);
|
||||
}
|
||||
}
|
||||
$plugins->hooks = $active_hooks;
|
||||
}
|
||||
|
||||
if(empty($info))
|
||||
{
|
||||
flash_message($lang->error_vcheck_no_supported_plugins, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
$url = "https://community.mybb.com/version_check.php?";
|
||||
$url .= http_build_query(array("info" => $info))."&";
|
||||
require_once MYBB_ROOT."inc/class_xml.php";
|
||||
$contents = fetch_remote_file($url);
|
||||
|
||||
if(!$contents)
|
||||
{
|
||||
flash_message($lang->error_vcheck_communications_problem, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
$contents = trim($contents);
|
||||
|
||||
$parser = new XMLParser($contents);
|
||||
$tree = $parser->get_tree();
|
||||
|
||||
if(!is_array($tree) || !isset($tree['plugins']))
|
||||
{
|
||||
flash_message($lang->error_communication_problem, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
if(array_key_exists('error', $tree['plugins']))
|
||||
{
|
||||
switch($tree['plugins'][0]['error'])
|
||||
{
|
||||
case "1":
|
||||
$error_msg = $lang->error_no_input;
|
||||
break;
|
||||
case "2":
|
||||
$error_msg = $lang->error_no_pids;
|
||||
break;
|
||||
default:
|
||||
$error_msg = "";
|
||||
}
|
||||
flash_message($lang->error_communication_problem.$error_msg, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->plugin);
|
||||
$table->construct_header($lang->your_version, array("class" => "align_center", 'width' => 125));
|
||||
$table->construct_header($lang->latest_version, array("class" => "align_center", 'width' => 125));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", 'width' => 125));
|
||||
|
||||
if(!is_array($tree['plugins']['plugin']))
|
||||
{
|
||||
flash_message($lang->success_plugins_up_to_date, 'success');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
if(array_key_exists("tag", $tree['plugins']['plugin']))
|
||||
{
|
||||
$only_plugin = $tree['plugins']['plugin'];
|
||||
unset($tree['plugins']['plugin']);
|
||||
$tree['plugins']['plugin'][0] = $only_plugin;
|
||||
}
|
||||
|
||||
foreach($tree['plugins']['plugin'] as $plugin)
|
||||
{
|
||||
$compare_by = array_key_exists("codename", $plugin['attributes']) ? "codename" : "guid";
|
||||
$is_vulnerable = array_key_exists("vulnerable", $plugin) ? true : false;
|
||||
|
||||
if(version_compare($names[$plugin['attributes'][$compare_by]]['version'], $plugin['version']['value'], "<"))
|
||||
{
|
||||
$plugin['download_url']['value'] = htmlspecialchars_uni($plugin['download_url']['value']);
|
||||
$plugin['vulnerable']['value'] = htmlspecialchars_uni($plugin['vulnerable']['value']);
|
||||
$plugin['version']['value'] = htmlspecialchars_uni($plugin['version']['value']);
|
||||
|
||||
if($is_vulnerable)
|
||||
{
|
||||
$table->construct_cell("<div class=\"error\" id=\"flash_message\">
|
||||
{$lang->error_vcheck_vulnerable} {$names[$plugin['attributes'][$compare_by]]['name']}
|
||||
</div>
|
||||
<p> <b>{$lang->error_vcheck_vulnerable_notes}</b> <br /><br /> {$plugin['vulnerable']['value']}</p>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong>{$names[$plugin['attributes'][$compare_by]]['name']}</strong>");
|
||||
}
|
||||
$table->construct_cell("{$names[$plugin['attributes'][$compare_by]]['version']}", array("class" => "align_center"));
|
||||
$table->construct_cell("<strong><span style=\"color: #C00\">{$plugin['version']['value']}</span></strong>", array("class" => "align_center"));
|
||||
if($is_vulnerable)
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins\"><b>{$lang->deactivate}</b></a>", array("class" => "align_center", "width" => 150));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong><a href=\"https://community.mybb.com/{$plugin['download_url']['value']}\" target=\"_blank\" rel=\"noopener\">{$lang->download}</a></strong>", array("class" => "align_center"));
|
||||
}
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
flash_message($lang->success_plugins_up_to_date, 'success');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->plugin_updates);
|
||||
|
||||
$page->output_header($lang->plugin_updates);
|
||||
|
||||
$sub_tabs['plugins'] = array(
|
||||
'title' => $lang->plugins,
|
||||
'link' => "index.php?module=config-plugins",
|
||||
);
|
||||
|
||||
$sub_tabs['update_plugins'] = array(
|
||||
'title' => $lang->plugin_updates,
|
||||
'link' => "index.php?module=config-plugins&action=check",
|
||||
'description' => $lang->plugin_updates_desc
|
||||
);
|
||||
|
||||
$sub_tabs['browse_plugins'] = array(
|
||||
'title' => $lang->browse_plugins,
|
||||
'link' => "index.php?module=config-plugins&action=browse",
|
||||
'description' => $lang->browse_plugins_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'update_plugins');
|
||||
|
||||
$table->output($lang->plugin_updates);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
// Activates or deactivates a specific plugin
|
||||
if($mybb->input['action'] == "activate" || $mybb->input['action'] == "deactivate")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "activate")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_plugins_activate");
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_config_plugins_deactivate");
|
||||
}
|
||||
|
||||
$codename = $mybb->input['plugin'];
|
||||
$codename = str_replace(array(".", "/", "\\"), "", $codename);
|
||||
$file = basename($codename.".php");
|
||||
|
||||
// Check if the file exists and throw an error if it doesn't
|
||||
if(!file_exists(MYBB_ROOT."inc/plugins/$file"))
|
||||
{
|
||||
flash_message($lang->error_invalid_plugin, 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
$plugins_cache = $cache->read("plugins");
|
||||
$active_plugins = $plugins_cache['active'];
|
||||
|
||||
require_once MYBB_ROOT."inc/plugins/$file";
|
||||
|
||||
$installed_func = "{$codename}_is_installed";
|
||||
$installed = true;
|
||||
if(function_exists($installed_func) && $installed_func() != true)
|
||||
{
|
||||
$installed = false;
|
||||
}
|
||||
|
||||
$install_uninstall = false;
|
||||
|
||||
if($mybb->input['action'] == "activate")
|
||||
{
|
||||
$message = $lang->success_plugin_activated;
|
||||
|
||||
// Plugin is compatible with this version?
|
||||
if($plugins->is_compatible($codename) == false)
|
||||
{
|
||||
flash_message($lang->sprintf($lang->plugin_incompatible, $mybb->version), 'error');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
// If not installed and there is a custom installation function
|
||||
if($installed == false && function_exists("{$codename}_install"))
|
||||
{
|
||||
call_user_func("{$codename}_install");
|
||||
$message = $lang->success_plugin_installed;
|
||||
$install_uninstall = true;
|
||||
}
|
||||
|
||||
if(function_exists("{$codename}_activate"))
|
||||
{
|
||||
call_user_func("{$codename}_activate");
|
||||
}
|
||||
|
||||
$active_plugins[$codename] = $codename;
|
||||
$executed[] = 'activate';
|
||||
}
|
||||
else if($mybb->input['action'] == "deactivate")
|
||||
{
|
||||
$message = $lang->success_plugin_deactivated;
|
||||
|
||||
if(function_exists("{$codename}_deactivate"))
|
||||
{
|
||||
call_user_func("{$codename}_deactivate");
|
||||
}
|
||||
|
||||
if($mybb->input['uninstall'] == 1 && function_exists("{$codename}_uninstall"))
|
||||
{
|
||||
call_user_func("{$codename}_uninstall");
|
||||
$message = $lang->success_plugin_uninstalled;
|
||||
$install_uninstall = true;
|
||||
}
|
||||
|
||||
unset($active_plugins[$codename]);
|
||||
}
|
||||
|
||||
// Update plugin cache
|
||||
$plugins_cache['active'] = $active_plugins;
|
||||
$cache->update("plugins", $plugins_cache);
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($codename, $install_uninstall);
|
||||
|
||||
if($mybb->input['action'] == "activate")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_plugins_activate_commit");
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_config_plugins_deactivate_commit");
|
||||
}
|
||||
|
||||
flash_message($message, 'success');
|
||||
admin_redirect("index.php?module=config-plugins");
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->plugins);
|
||||
|
||||
$sub_tabs['plugins'] = array(
|
||||
'title' => $lang->plugins,
|
||||
'link' => "index.php?module=config-plugins",
|
||||
'description' => $lang->plugins_desc
|
||||
);
|
||||
$sub_tabs['update_plugins'] = array(
|
||||
'title' => $lang->plugin_updates,
|
||||
'link' => "index.php?module=config-plugins&action=check",
|
||||
'description' => $lang->plugin_updates_desc
|
||||
);
|
||||
|
||||
$sub_tabs['browse_plugins'] = array(
|
||||
'title' => $lang->browse_plugins,
|
||||
'link' => "index.php?module=config-plugins&action=browse",
|
||||
'description' => $lang->browse_plugins_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'plugins');
|
||||
|
||||
// Let's make things easier for our user - show them active
|
||||
// and inactive plugins in different lists
|
||||
$plugins_cache = $cache->read("plugins");
|
||||
$active_plugins = $plugins_cache['active'];
|
||||
|
||||
$plugins_list = get_plugins_list();
|
||||
|
||||
$plugins->run_hooks("admin_config_plugins_plugin_list");
|
||||
|
||||
if(!empty($plugins_list))
|
||||
{
|
||||
$a_plugins = $i_plugins = array();
|
||||
|
||||
foreach($plugins_list as $plugin_file)
|
||||
{
|
||||
require_once MYBB_ROOT."inc/plugins/".$plugin_file;
|
||||
$codename = str_replace(".php", "", $plugin_file);
|
||||
$infofunc = $codename."_info";
|
||||
|
||||
if(!function_exists($infofunc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugininfo = $infofunc();
|
||||
$plugininfo['codename'] = $codename;
|
||||
|
||||
if($active_plugins[$codename])
|
||||
{
|
||||
// This is an active plugin
|
||||
$plugininfo['is_active'] = 1;
|
||||
|
||||
$a_plugins[] = $plugininfo;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Either installed and not active or completely inactive
|
||||
$i_plugins[] = $plugininfo;
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->plugin);
|
||||
$table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
|
||||
|
||||
if(empty($a_plugins))
|
||||
{
|
||||
$table->construct_cell($lang->no_active_plugins, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
else
|
||||
{
|
||||
build_plugin_list($a_plugins);
|
||||
}
|
||||
|
||||
$table->output($lang->active_plugin);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->plugin);
|
||||
$table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
|
||||
|
||||
if(empty($i_plugins))
|
||||
{
|
||||
$table->construct_cell($lang->no_inactive_plugins, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
else
|
||||
{
|
||||
build_plugin_list($i_plugins);
|
||||
}
|
||||
|
||||
$table->output($lang->inactive_plugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No plugins
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->plugin);
|
||||
$table->construct_header($lang->controls, array("colspan" => 2, "class" => "align_center", "width" => 300));
|
||||
|
||||
$table->construct_cell($lang->no_plugins, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->plugins);
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function get_plugins_list()
|
||||
{
|
||||
// Get a list of the plugin files which exist in the plugins directory
|
||||
$dir = @opendir(MYBB_ROOT."inc/plugins/");
|
||||
if($dir)
|
||||
{
|
||||
while($file = readdir($dir))
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
if($ext == "php")
|
||||
{
|
||||
$plugins_list[] = $file;
|
||||
}
|
||||
}
|
||||
@sort($plugins_list);
|
||||
}
|
||||
@closedir($dir);
|
||||
|
||||
return $plugins_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $plugin_list
|
||||
*/
|
||||
function build_plugin_list($plugin_list)
|
||||
{
|
||||
global $lang, $mybb, $plugins, $table;
|
||||
|
||||
foreach($plugin_list as $plugininfo)
|
||||
{
|
||||
if($plugininfo['website'])
|
||||
{
|
||||
$plugininfo['name'] = "<a href=\"".$plugininfo['website']."\">".$plugininfo['name']."</a>";
|
||||
}
|
||||
|
||||
if($plugininfo['authorsite'])
|
||||
{
|
||||
$plugininfo['author'] = "<a href=\"".$plugininfo['authorsite']."\">".$plugininfo['author']."</a>";
|
||||
}
|
||||
|
||||
if($plugins->is_compatible($plugininfo['codename']) == false)
|
||||
{
|
||||
$compatibility_warning = "<span style=\"color: red;\">".$lang->sprintf($lang->plugin_incompatible, $mybb->version)."</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$compatibility_warning = "";
|
||||
}
|
||||
|
||||
$installed_func = "{$plugininfo['codename']}_is_installed";
|
||||
$install_func = "{$plugininfo['codename']}_install";
|
||||
$uninstall_func = "{$plugininfo['codename']}_uninstall";
|
||||
|
||||
$installed = true;
|
||||
$install_button = false;
|
||||
$uninstall_button = false;
|
||||
|
||||
if(function_exists($installed_func) && $installed_func() != true)
|
||||
{
|
||||
$installed = false;
|
||||
}
|
||||
|
||||
if(function_exists($install_func))
|
||||
{
|
||||
$install_button = true;
|
||||
}
|
||||
|
||||
if(function_exists($uninstall_func))
|
||||
{
|
||||
$uninstall_button = true;
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong>{$plugininfo['name']}</strong> ({$plugininfo['version']})<br /><small>{$plugininfo['description']}</small><br /><i><small>{$lang->created_by} {$plugininfo['author']}</small></i>");
|
||||
|
||||
// Plugin is not installed at all
|
||||
if($installed == false)
|
||||
{
|
||||
if($compatibility_warning)
|
||||
{
|
||||
$table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins&action=activate&plugin={$plugininfo['codename']}&my_post_key={$mybb->post_code}\">{$lang->install_and_activate}</a>", array("class" => "align_center", "colspan" => 2));
|
||||
}
|
||||
}
|
||||
// Plugin is activated and installed
|
||||
else if($plugininfo['is_active'])
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins&action=deactivate&plugin={$plugininfo['codename']}&my_post_key={$mybb->post_code}\">{$lang->deactivate}</a>", array("class" => "align_center", "width" => 150));
|
||||
if($uninstall_button)
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins&action=deactivate&uninstall=1&plugin={$plugininfo['codename']}&my_post_key={$mybb->post_code}\">{$lang->uninstall}</a>", array("class" => "align_center", "width" => 150));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell(" ", array("class" => "align_center", "width" => 150));
|
||||
}
|
||||
}
|
||||
// Plugin is installed but not active
|
||||
else if($installed == true)
|
||||
{
|
||||
if($compatibility_warning && !$uninstall_button)
|
||||
{
|
||||
$table->construct_cell("{$compatibility_warning}", array("class" => "align_center", "colspan" => 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins&action=activate&plugin={$plugininfo['codename']}&my_post_key={$mybb->post_code}\">{$lang->activate}</a>", array("class" => "align_center", "width" => 150));
|
||||
if($uninstall_button)
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-plugins&action=deactivate&uninstall=1&plugin={$plugininfo['codename']}&my_post_key={$mybb->post_code}\">{$lang->uninstall}</a>", array("class" => "align_center", "width" => 150));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell(" ", array("class" => "align_center", "width" => 150));
|
||||
}
|
||||
}
|
||||
}
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
505
webroot/forum/admin/modules/config/post_icons.php
Normal file
505
webroot/forum/admin/modules/config/post_icons.php
Normal file
@@ -0,0 +1,505 @@
|
||||
<?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->post_icons, "index.php?module=config-post_icons");
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_post_icons_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['path']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_icon = array(
|
||||
'name' => $db->escape_string($mybb->input['name']),
|
||||
'path' => $db->escape_string($mybb->input['path'])
|
||||
);
|
||||
|
||||
$iid = $db->insert_query("icons", $new_icon);
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_add_commit");
|
||||
|
||||
$cache->update_posticons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($iid, $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_post_icon_added, 'success');
|
||||
admin_redirect('index.php?module=config-post_icons');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_post_icon);
|
||||
$page->output_header($lang->post_icons." - ".$lang->add_post_icon);
|
||||
|
||||
$sub_tabs['manage_icons'] = array(
|
||||
'title' => $lang->manage_post_icons,
|
||||
'link' => "index.php?module=config-post_icons"
|
||||
);
|
||||
|
||||
$sub_tabs['add_icon'] = array(
|
||||
'title' => $lang->add_post_icon,
|
||||
'link' => "index.php?module=config-post_icons&action=add",
|
||||
'description' => $lang->add_post_icon_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_multiple'] = array(
|
||||
'title' => $lang->add_multiple_post_icons,
|
||||
'link' => "index.php?module=config-post_icons&action=add_multiple"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_icon');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['path'] = 'images/icons/';
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-post_icons&action=add", "post", "add");
|
||||
$form_container = new FormContainer($lang->add_post_icon);
|
||||
$form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('path', $mybb->input['path'], array('id' => 'path')), 'path');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_post_icon);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "add_multiple")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_post_icons_add_multiple");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if($mybb->input['step'] == 1)
|
||||
{
|
||||
if(!trim($mybb->input['pathfolder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path_multiple;
|
||||
}
|
||||
|
||||
$path = $mybb->input['pathfolder'];
|
||||
$dir = @opendir(MYBB_ROOT.$path);
|
||||
if(!$dir)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_path;
|
||||
}
|
||||
|
||||
if(substr($path, -1, 1) !== "/")
|
||||
{
|
||||
$path .= "/";
|
||||
}
|
||||
|
||||
$query = $db->simple_select("icons");
|
||||
|
||||
$aicons = array();
|
||||
while($icon = $db->fetch_array($query))
|
||||
{
|
||||
$aicons[$icon['path']] = 1;
|
||||
}
|
||||
|
||||
$icons = array();
|
||||
if(!$errors)
|
||||
{
|
||||
while($file = readdir($dir))
|
||||
{
|
||||
if($file != ".." && $file != ".")
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
if($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "bmp")
|
||||
{
|
||||
if(!$aicons[$path.$file])
|
||||
{
|
||||
$icons[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
if(count($icons) == 0)
|
||||
{
|
||||
$errors[] = $lang->error_no_images;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for errors again (from above statement)!
|
||||
if(!$errors)
|
||||
{
|
||||
// We have no errors so let's proceed!
|
||||
$page->add_breadcrumb_item($lang->add_multiple_post_icons);
|
||||
$page->output_header($lang->post_icons." - ".$lang->add_multiple_post_icons);
|
||||
|
||||
$sub_tabs['manage_icons'] = array(
|
||||
'title' => $lang->manage_post_icons,
|
||||
'link' => "index.php?module=config-post_icons"
|
||||
);
|
||||
|
||||
$sub_tabs['add_icon'] = array(
|
||||
'title' => $lang->add_post_icon,
|
||||
'link' => "index.php?module=config-post_icons&action=add"
|
||||
);
|
||||
|
||||
$sub_tabs['add_multiple'] = array(
|
||||
'title' => $lang->add_multiple_post_icons,
|
||||
'link' => "index.php?module=config-post_icons&action=add_multiple",
|
||||
'description' => $lang->add_multiple_post_icons_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_multiple');
|
||||
|
||||
$form = new Form("index.php?module=config-post_icons&action=add_multiple", "post", "add_multiple");
|
||||
echo $form->generate_hidden_field("step", "2");
|
||||
echo $form->generate_hidden_field("pathfolder", $path);
|
||||
|
||||
$form_container = new FormContainer($lang->add_multiple_post_icons);
|
||||
$form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '10%'));
|
||||
$form_container->output_row_header($lang->name);
|
||||
$form_container->output_row_header($lang->add, array("class" => "align_center", 'width' => '5%'));
|
||||
|
||||
foreach($icons as $key => $file)
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
$find = str_replace(".".$ext, "", $file);
|
||||
$name = ucfirst($find);
|
||||
|
||||
$form_container->output_cell("<img src=\"../".$path.$file."\" alt=\"\" /><br /><small>{$file}</small>", array("class" => "align_center", "width" => 1));
|
||||
$form_container->output_cell($form->generate_text_box("name[{$file}]", $name, array('id' => 'name', 'style' => 'width: 98%')));
|
||||
$form_container->output_cell($form->generate_check_box("include[{$file}]", 1, "", array('checked' => 1)), array("class" => "align_center"));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
if($form_container->num_rows() == 0)
|
||||
{
|
||||
flash_message($lang->error_no_images, 'error');
|
||||
admin_redirect("index.php?module=config-post_icons&action=add_multiple");
|
||||
}
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_post_icons);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $mybb->input['pathfolder'];
|
||||
reset($mybb->input['include']);
|
||||
$name = $mybb->input['name'];
|
||||
|
||||
if(empty($mybb->input['include']))
|
||||
{
|
||||
flash_message($lang->error_none_included, 'error');
|
||||
admin_redirect("index.php?module=config-post_icons&action=add_multiple");
|
||||
}
|
||||
|
||||
foreach($mybb->input['include'] as $image => $insert)
|
||||
{
|
||||
if($insert)
|
||||
{
|
||||
$new_icon = array(
|
||||
'name' => $db->escape_string($name[$image]),
|
||||
'path' => $db->escape_string($path.$image)
|
||||
);
|
||||
|
||||
$db->insert_query("icons", $new_icon);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_add_multiple_commit");
|
||||
|
||||
$cache->update_posticons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
flash_message($lang->success_post_icons_added, 'success');
|
||||
admin_redirect("index.php?module=config-post_icons");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_multiple_post_icons);
|
||||
$page->output_header($lang->post_icons." - ".$lang->add_multiple_post_icons);
|
||||
|
||||
$sub_tabs['manage_icons'] = array(
|
||||
'title' => $lang->manage_post_icons,
|
||||
'link' => "index.php?module=config-post_icons"
|
||||
);
|
||||
|
||||
$sub_tabs['add_icon'] = array(
|
||||
'title' => $lang->add_post_icon,
|
||||
'link' => "index.php?module=config-post_icons&action=add"
|
||||
);
|
||||
|
||||
$sub_tabs['add_multiple'] = array(
|
||||
'title' => $lang->add_multiple_post_icons,
|
||||
'link' => "index.php?module=config-post_icons&action=add_multiple",
|
||||
'description' => $lang->add_multiple_post_icons_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_multiple');
|
||||
|
||||
$form = new Form("index.php?module=config-post_icons&action=add_multiple", "post", "add_multiple");
|
||||
echo $form->generate_hidden_field("step", "1");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_multiple_post_icons);
|
||||
$form_container->output_row($lang->path_to_images." <em>*</em>", $lang->path_to_images_desc, $form->generate_text_box('pathfolder', $mybb->input['pathfolder'], array('id' => 'pathfolder')), 'pathfolder');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->show_post_icons);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("icons", "*", "iid='".$mybb->get_input('iid', MyBB::INPUT_INT)."'");
|
||||
$icon = $db->fetch_array($query);
|
||||
|
||||
if(!$icon['iid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_post_icon, 'error');
|
||||
admin_redirect("index.php?module=config-post_icons");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['path']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_icon = array(
|
||||
'name' => $db->escape_string($mybb->input['name']),
|
||||
'path' => $db->escape_string($mybb->input['path'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_edit_commit");
|
||||
|
||||
$db->update_query("icons", $updated_icon, "iid='{$icon['iid']}'");
|
||||
|
||||
$cache->update_posticons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($icon['iid'], $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_post_icon_updated, 'success');
|
||||
admin_redirect('index.php?module=config-post_icons');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_post_icon);
|
||||
$page->output_header($lang->post_icons." - ".$lang->edit_post_icon);
|
||||
|
||||
$sub_tabs['edit_icon'] = array(
|
||||
'title' => $lang->edit_post_icon,
|
||||
'link' => "index.php?module=config-post_icons",
|
||||
'description' => $lang->edit_post_icon_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_icon');
|
||||
|
||||
$form = new Form("index.php?module=config-post_icons&action=edit", "post", "edit");
|
||||
echo $form->generate_hidden_field("iid", $icon['iid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $icon);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_post_icon);
|
||||
$form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('path', $mybb->input['path'], array('id' => 'path')), 'path');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_post_icon);
|
||||
$buttons[] = $form->generate_reset_button($lang->reset);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("icons", "*", "iid='".$mybb->get_input('iid', MyBB::INPUT_INT)."'");
|
||||
$icon = $db->fetch_array($query);
|
||||
|
||||
if(!$icon['iid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_post_icon, 'error');
|
||||
admin_redirect("index.php?module=config-post_icons");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-post_icons");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("icons", "iid='{$icon['iid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_post_icons_delete_commit");
|
||||
|
||||
$cache->update_posticons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($icon['iid'], $icon['name']);
|
||||
|
||||
flash_message($lang->success_post_icon_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-post_icons");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-post_icons&action=delete&iid={$icon['iid']}", $lang->confirm_post_icon_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_post_icons_start");
|
||||
|
||||
$page->output_header($lang->post_icons);
|
||||
|
||||
$sub_tabs['manage_icons'] = array(
|
||||
'title' => $lang->manage_post_icons,
|
||||
'link' => "index.php?module=config-post_icons",
|
||||
'description' => $lang->manage_post_icons_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_icon'] = array(
|
||||
'title' => $lang->add_post_icon,
|
||||
'link' => "index.php?module=config-post_icons&action=add"
|
||||
);
|
||||
|
||||
$sub_tabs['add_multiple'] = array(
|
||||
'title' => $lang->add_multiple_post_icons,
|
||||
'link' => "index.php?module=config-post_icons&action=add_multiple"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_icons');
|
||||
|
||||
$query = $db->simple_select("icons", "COUNT(iid) AS icons");
|
||||
$total_rows = $db->fetch_field($query, "icons");
|
||||
|
||||
$pagenum = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
if($pagenum)
|
||||
{
|
||||
$start = ($pagenum - 1) * 20;
|
||||
$pages = ceil($total_rows / 20);
|
||||
if($pagenum > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$pagenum = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$pagenum = 1;
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->image, array('class' => "align_center", 'width' => 1));
|
||||
$table->construct_header($lang->name, array('width' => "70%"));
|
||||
$table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
|
||||
|
||||
$query = $db->simple_select("icons", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'name'));
|
||||
while($icon = $db->fetch_array($query))
|
||||
{
|
||||
$icon['path'] = str_replace("{theme}", "images", $icon['path']);
|
||||
if(my_validate_url($icon['path'], true))
|
||||
{
|
||||
$image = $icon['path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = "../".$icon['path'];
|
||||
}
|
||||
|
||||
$table->construct_cell("<img src=\"".htmlspecialchars_uni($image)."\" alt=\"\" />", array("class" => "align_center"));
|
||||
$table->construct_cell(htmlspecialchars_uni($icon['name']));
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=config-post_icons&action=edit&iid={$icon['iid']}\">{$lang->edit}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-post_icons&action=delete&iid={$icon['iid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_post_icon_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_post_icons, array('colspan' => 4));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->manage_post_icons);
|
||||
|
||||
echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-post_icons&page={page}");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
795
webroot/forum/admin/modules/config/profile_fields.php
Normal file
795
webroot/forum/admin/modules/config/profile_fields.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?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->custom_profile_fields, "index.php?module=config-profile_fields");
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_profile_fields_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_description;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['fieldtype']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_fieldtype;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$type = $mybb->input['fieldtype'];
|
||||
$options = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['options']));
|
||||
if($type != "text" && $type != "textarea")
|
||||
{
|
||||
$thing = "$type\n$options";
|
||||
}
|
||||
else
|
||||
{
|
||||
$thing = $type;
|
||||
}
|
||||
|
||||
foreach(array('viewableby', 'editableby') as $key)
|
||||
{
|
||||
if($mybb->input[$key] == 'all')
|
||||
{
|
||||
$mybb->input[$key] = -1;
|
||||
}
|
||||
elseif($mybb->input[$key] == 'custom')
|
||||
{
|
||||
if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
|
||||
{
|
||||
foreach($mybb->input['select'][$key] as &$val)
|
||||
{
|
||||
$val = (int)$val;
|
||||
}
|
||||
unset($val);
|
||||
|
||||
$mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$new_profile_field = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"type" => $db->escape_string($thing),
|
||||
"regex" => $db->escape_string($mybb->input['regex']),
|
||||
"length" => $mybb->get_input('length', MyBB::INPUT_INT),
|
||||
"maxlength" => $mybb->get_input('maxlength', MyBB::INPUT_INT),
|
||||
"required" => $mybb->get_input('required', MyBB::INPUT_INT),
|
||||
"registration" => $mybb->get_input('registration', MyBB::INPUT_INT),
|
||||
"profile" => $mybb->get_input('profile', MyBB::INPUT_INT),
|
||||
"viewableby" => $db->escape_string($mybb->input['viewableby']),
|
||||
"editableby" => $db->escape_string($mybb->input['editableby']),
|
||||
"postbit" => $mybb->get_input('postbit', MyBB::INPUT_INT),
|
||||
"postnum" => $mybb->get_input('postnum', MyBB::INPUT_INT),
|
||||
"allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT),
|
||||
"allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
|
||||
"allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$fid = $db->insert_query("profilefields", $new_profile_field);
|
||||
|
||||
$db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields ADD fid{$fid} TEXT");
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_add_commit");
|
||||
|
||||
$cache->update_profilefields();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($fid, $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_profile_field_added, 'success');
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_profile_field);
|
||||
$page->output_header($lang->custom_profile_fields." - ".$lang->add_new_profile_field);
|
||||
|
||||
$sub_tabs['custom_profile_fields'] = array(
|
||||
'title' => $lang->custom_profile_fields,
|
||||
'link' => "index.php?module=config-profile_fields"
|
||||
);
|
||||
|
||||
$sub_tabs['add_profile_field'] = array(
|
||||
'title' => $lang->add_new_profile_field,
|
||||
'link' => "index.php?module=config-profile_fields&action=add",
|
||||
'description' => $lang->add_new_profile_field_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_profile_field');
|
||||
$form = new Form("index.php?module=config-profile_fields&action=add", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
switch($mybb->input['viewableby'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['viewableby'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['viewableby'] = implode(',', (array)$mybb->input['select']['viewableby']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['viewableby'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($mybb->input['editableby'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['editableby'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['editableby'] = implode(',', (array)$mybb->input['select']['editableby']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['editableby'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['fieldtype'] = 'textbox';
|
||||
$mybb->input['required'] = 0;
|
||||
$mybb->input['registration'] = 0;
|
||||
$mybb->input['editable'] = 1;
|
||||
$mybb->input['hidden'] = 0;
|
||||
$mybb->input['postbit'] = 0;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['viewableby']))
|
||||
{
|
||||
$mybb->input['viewableby'] = '';
|
||||
}
|
||||
|
||||
if(empty($mybb->input['editableby']))
|
||||
{
|
||||
$mybb->input['editableby'] = '';
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_profile_field);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$select_list = array(
|
||||
"text" => $lang->text,
|
||||
"textarea" => $lang->textarea,
|
||||
"select" => $lang->select,
|
||||
"multiselect" => $lang->multiselect,
|
||||
"radio" => $lang->radio,
|
||||
"checkbox" => $lang->checkbox
|
||||
);
|
||||
$form_container->output_row($lang->field_type." <em>*</em>", $lang->field_type_desc, $form->generate_select_box('fieldtype', $select_list, $mybb->input['fieldtype'], array('id' => 'fieldtype')), 'fieldtype');
|
||||
$form_container->output_row($lang->field_regex, $lang->field_regex_desc, $form->generate_text_box('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex', array(), array('id' => 'row_regex'));
|
||||
$form_container->output_row($lang->maximum_length, $lang->maximum_length_desc, $form->generate_numeric_field('maxlength', $mybb->input['maxlength'], array('id' => 'maxlength', 'min' => 0)), 'maxlength', array(), array('id' => 'row_maxlength'));
|
||||
$form_container->output_row($lang->field_length, $lang->field_length_desc, $form->generate_numeric_field('length', $mybb->input['length'], array('id' => 'length', 'min' => 0)), 'length', array(), array('id' => 'row_fieldlength'));
|
||||
$form_container->output_row($lang->selectable_options, $lang->selectable_options_desc, $form->generate_text_area('options', $mybb->input['options'], array('id' => 'options')), 'options', array(), array('id' => 'row_options'));
|
||||
$form_container->output_row($lang->min_posts_enabled, $lang->min_posts_enabled_desc, $form->generate_numeric_field('postnum', $mybb->input['postnum'], array('id' => 'postnum', 'min' => 0)), 'postnum');
|
||||
$form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->required." <em>*</em>", $lang->required_desc, $form->generate_yes_no_radio('required', $mybb->input['required']));
|
||||
$form_container->output_row($lang->show_on_registration." <em>*</em>", $lang->show_on_registration_desc, $form->generate_yes_no_radio('registration', $mybb->input['registration']));
|
||||
$form_container->output_row($lang->display_on_profile." <em>*</em>", $lang->display_on_profile_desc, $form->generate_yes_no_radio('profile', $mybb->input['profile']));
|
||||
$form_container->output_row($lang->display_on_postbit." <em>*</em>", $lang->display_on_postbit_desc, $form->generate_yes_no_radio('postbit', $mybb->input['postbit']));
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['viewableby'] != '' && $mybb->input['viewableby'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('viewableby'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['viewableby'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['viewableby'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"all\" {$group_checked['all']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"custom\" {$group_checked['custom']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"viewableby_forums_groups_custom\" class=\"viewableby_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[viewableby][]', $selected_values, array('id' => 'viewableby', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"none\" {$group_checked['none']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('viewableby');
|
||||
</script>";
|
||||
$form_container->output_row($lang->viewableby, $lang->viewableby_desc, $select_code, '', array(), array('id' => 'row_viewableby'));
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['editableby'] != '' && $mybb->input['editableby'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('editableby'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['editableby'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['editableby'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"all\" {$group_checked['all']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"custom\" {$group_checked['custom']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"editableby_forums_groups_custom\" class=\"editableby_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[editableby][]', $selected_values, array('id' => 'editableby', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"none\" {$group_checked['none']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('editableby');
|
||||
</script>";
|
||||
$form_container->output_row($lang->editableby, $lang->editableby_desc, $select_code, '', array(), array('id' => 'row_editableby'));
|
||||
|
||||
$parser_options = array(
|
||||
$form->generate_check_box('allowhtml', 1, $lang->parse_allowhtml, array('checked' => $mybb->input['allowhtml'], 'id' => 'allowhtml')),
|
||||
$form->generate_check_box('allowmycode', 1, $lang->parse_allowmycode, array('checked' => $mybb->input['allowmycode'], 'id' => 'allowmycode')),
|
||||
$form->generate_check_box('allowsmilies', 1, $lang->parse_allowsmilies, array('checked' => $mybb->input['allowsmilies'], 'id' => 'allowsmilies')),
|
||||
$form->generate_check_box('allowimgcode', 1, $lang->parse_allowimgcode, array('checked' => $mybb->input['allowimgcode'], 'id' => 'allowimgcode')),
|
||||
$form->generate_check_box('allowvideocode', 1, $lang->parse_allowvideocode, array('checked' => $mybb->input['allowvideocode'], 'id' => 'allowvideocode'))
|
||||
);
|
||||
$form_container->output_row($lang->parser_options, '', implode('<br />', $parser_options), '', array(), array('id' => 'row_parser_options'));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_profile_field);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
new Peeker($("#fieldtype"), $("#row_maxlength, #row_regex, #row_parser_options"), /text|textarea/, false);
|
||||
new Peeker($("#fieldtype"), $("#row_fieldlength"), /select|multiselect/, false);
|
||||
new Peeker($("#fieldtype"), $("#row_options"), /select|radio|checkbox/, false);
|
||||
// Add a star to the extra row since the "extra" is required if the box is shown
|
||||
add_star("row_maxlength");
|
||||
add_star("row_fieldlength");
|
||||
add_star("row_options");
|
||||
});
|
||||
</script>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("profilefields", "*", "fid = '".$mybb->get_input('fid', MyBB::INPUT_INT)."'");
|
||||
$profile_field = $db->fetch_array($query);
|
||||
|
||||
if(!$profile_field['fid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_fid, 'error');
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_description;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['fieldtype']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_fieldtype;
|
||||
}
|
||||
|
||||
$type = $mybb->input['fieldtype'];
|
||||
$options = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['options']));
|
||||
if($type != "text" && $type != "textarea")
|
||||
{
|
||||
$type = "$type\n$options";
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
foreach(array('viewableby', 'editableby') as $key)
|
||||
{
|
||||
if($mybb->input[$key] == 'all')
|
||||
{
|
||||
$mybb->input[$key] = -1;
|
||||
}
|
||||
elseif($mybb->input[$key] == 'custom')
|
||||
{
|
||||
if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
|
||||
{
|
||||
foreach($mybb->input['select'][$key] as &$val)
|
||||
{
|
||||
$val = (int)$val;
|
||||
}
|
||||
unset($val);
|
||||
|
||||
$mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input[$key] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$updated_profile_field = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"type" => $db->escape_string($type),
|
||||
"regex" => $db->escape_string($mybb->input['regex']),
|
||||
"length" => $mybb->get_input('length', MyBB::INPUT_INT),
|
||||
"maxlength" => $mybb->get_input('maxlength', MyBB::INPUT_INT),
|
||||
"required" => $mybb->get_input('required', MyBB::INPUT_INT),
|
||||
"registration" => $mybb->get_input('registration', MyBB::INPUT_INT),
|
||||
"profile" => $mybb->get_input('profile', MyBB::INPUT_INT),
|
||||
"viewableby" => $db->escape_string($mybb->input['viewableby']),
|
||||
"editableby" => $db->escape_string($mybb->input['editableby']),
|
||||
"postbit" => $mybb->get_input('postbit', MyBB::INPUT_INT),
|
||||
"postnum" => $mybb->get_input('postnum', MyBB::INPUT_INT),
|
||||
"allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT),
|
||||
"allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
|
||||
"allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_edit_commit");
|
||||
|
||||
$db->update_query("profilefields", $updated_profile_field, "fid='{$profile_field['fid']}'");
|
||||
|
||||
$cache->update_profilefields();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($profile_field['fid'], $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_profile_field_saved, 'success');
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_profile_field);
|
||||
$page->output_header($lang->custom_profile_fields." - ".$lang->edit_profile_field);
|
||||
|
||||
$sub_tabs['edit_profile_field'] = array(
|
||||
'title' => $lang->edit_profile_field,
|
||||
'link' => "index.php?module=config-profile_fields&action=edit&fid={$profile_field['fid']}",
|
||||
'description' => $lang->edit_profile_field_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_profile_field');
|
||||
$form = new Form("index.php?module=config-profile_fields&action=edit", "post", "edit");
|
||||
|
||||
|
||||
echo $form->generate_hidden_field("fid", $profile_field['fid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
switch($mybb->input['viewableby'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['viewableby'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['viewableby'] = implode(',', (array)$mybb->input['select']['viewableby']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['viewableby'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($mybb->input['editableby'])
|
||||
{
|
||||
case 'all':
|
||||
$mybb->input['editableby'] = -1;
|
||||
break;
|
||||
case 'custom':
|
||||
$mybb->input['editableby'] = implode(',', (array)$mybb->input['select']['editableby']);
|
||||
break;
|
||||
default:
|
||||
$mybb->input['editableby'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = explode("\n", $profile_field['type'], "2");
|
||||
|
||||
$mybb->input = $profile_field;
|
||||
$mybb->input['fieldtype'] = $type[0];
|
||||
$mybb->input['options'] = $type[1];
|
||||
}
|
||||
|
||||
if(empty($mybb->input['viewableby']))
|
||||
{
|
||||
$mybb->input['viewableby'] = '';
|
||||
}
|
||||
|
||||
if(empty($mybb->input['editableby']))
|
||||
{
|
||||
$mybb->input['editableby'] = '';
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_profile_field);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
$select_list = array(
|
||||
"text" => $lang->text,
|
||||
"textarea" => $lang->textarea,
|
||||
"select" => $lang->select,
|
||||
"multiselect" => $lang->multiselect,
|
||||
"radio" => $lang->radio,
|
||||
"checkbox" => $lang->checkbox
|
||||
);
|
||||
$form_container->output_row($lang->field_type." <em>*</em>", $lang->field_type_desc, $form->generate_select_box('fieldtype', $select_list, $mybb->input['fieldtype'], array('id' => 'fieldtype')), 'fieldtype');
|
||||
$form_container->output_row($lang->field_regex, $lang->field_regex_desc, $form->generate_text_box('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex', array(), array('id' => 'row_regex'));
|
||||
$form_container->output_row($lang->maximum_length, $lang->maximum_length_desc, $form->generate_numeric_field('maxlength', $mybb->input['maxlength'], array('id' => 'maxlength', 'min' => 0)), 'maxlength', array(), array('id' => 'row_maxlength'));
|
||||
$form_container->output_row($lang->field_length, $lang->field_length_desc, $form->generate_numeric_field('length', $mybb->input['length'], array('id' => 'length', 'min' => 0)), 'length', array(), array('id' => 'row_fieldlength'));
|
||||
$form_container->output_row($lang->selectable_options, $lang->selectable_options_desc, $form->generate_text_area('options', $mybb->input['options'], array('id' => 'options')), 'options', array(), array('id' => 'row_options'));
|
||||
$form_container->output_row($lang->min_posts_enabled, $lang->min_posts_enabled_desc, $form->generate_numeric_field('postnum', $mybb->input['postnum'], array('id' => 'postnum', 'min' => 0)), 'postnum');
|
||||
$form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->required." <em>*</em>", $lang->required_desc, $form->generate_yes_no_radio('required', $mybb->input['required']));
|
||||
$form_container->output_row($lang->show_on_registration." <em>*</em>", $lang->show_on_registration_desc, $form->generate_yes_no_radio('registration', $mybb->input['registration']));
|
||||
$form_container->output_row($lang->display_on_profile." <em>*</em>", $lang->display_on_profile_desc, $form->generate_yes_no_radio('profile', $mybb->input['profile']));
|
||||
$form_container->output_row($lang->display_on_postbit." <em>*</em>", $lang->display_on_postbit_desc, $form->generate_yes_no_radio('postbit', $mybb->input['postbit']));
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['viewableby'] != '' && $mybb->input['viewableby'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('viewableby'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['viewableby'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['viewableby'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"all\" {$group_checked['all']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"custom\" {$group_checked['custom']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"viewableby_forums_groups_custom\" class=\"viewableby_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[viewableby][]', $selected_values, array('id' => 'viewableby', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"none\" {$group_checked['none']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('viewableby');
|
||||
</script>";
|
||||
$form_container->output_row($lang->viewableby, $lang->viewableby_desc, $select_code, '', array(), array('id' => 'row_viewableby'));
|
||||
|
||||
$selected_values = '';
|
||||
if($mybb->input['editableby'] != '' && $mybb->input['editableby'] != -1)
|
||||
{
|
||||
$selected_values = explode(',', $mybb->get_input('editableby'));
|
||||
|
||||
foreach($selected_values as &$value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
$group_checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['editableby'] == -1)
|
||||
{
|
||||
$group_checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['editableby'] != '')
|
||||
{
|
||||
$group_checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked['none'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
$select_code = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"all\" {$group_checked['all']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"custom\" {$group_checked['custom']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"editableby_forums_groups_custom\" class=\"editableby_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('select[editableby][]', $selected_values, array('id' => 'editableby', 'multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"none\" {$group_checked['none']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('editableby');
|
||||
</script>";
|
||||
$form_container->output_row($lang->editableby, $lang->editableby_desc, $select_code, '', array(), array('id' => 'row_editableby'));
|
||||
|
||||
$parser_options = array(
|
||||
$form->generate_check_box('allowhtml', 1, $lang->parse_allowhtml, array('checked' => $mybb->input['allowhtml'], 'id' => 'allowhtml')),
|
||||
$form->generate_check_box('allowmycode', 1, $lang->parse_allowmycode, array('checked' => $mybb->input['allowmycode'], 'id' => 'allowmycode')),
|
||||
$form->generate_check_box('allowsmilies', 1, $lang->parse_allowsmilies, array('checked' => $mybb->input['allowsmilies'], 'id' => 'allowsmilies')),
|
||||
$form->generate_check_box('allowimgcode', 1, $lang->parse_allowimgcode, array('checked' => $mybb->input['allowimgcode'], 'id' => 'allowimgcode')),
|
||||
$form->generate_check_box('allowvideocode', 1, $lang->parse_allowvideocode, array('checked' => $mybb->input['allowvideocode'], 'id' => 'allowvideocode'))
|
||||
);
|
||||
$form_container->output_row($lang->parser_options, '', implode('<br />', $parser_options), '', array(), array('id' => 'row_parser_options'));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_profile_field);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
new Peeker($("#fieldtype"), $("#row_maxlength, #row_regex, #row_parser_options"), /text|textarea/);
|
||||
new Peeker($("#fieldtype"), $("#row_fieldlength"), /select|multiselect/);
|
||||
new Peeker($("#fieldtype"), $("#row_options"), /select|radio|checkbox/);
|
||||
// Add a star to the extra row since the "extra" is required if the box is shown
|
||||
add_star("row_maxlength");
|
||||
add_star("row_fieldlength");
|
||||
add_star("row_options");
|
||||
});
|
||||
</script>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("profilefields", "*", "fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'");
|
||||
$profile_field = $db->fetch_array($query);
|
||||
|
||||
// Does the profile field not exist?
|
||||
if(!$profile_field['fid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_fid, 'error');
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the profile field
|
||||
$db->delete_query("profilefields", "fid='{$profile_field['fid']}'");
|
||||
$db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields DROP fid{$profile_field['fid']}");
|
||||
|
||||
$plugins->run_hooks("admin_config_profile_fields_delete_commit");
|
||||
|
||||
$cache->update_profilefields();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($profile_field['fid'], $profile_field['name']);
|
||||
|
||||
flash_message($lang->success_profile_field_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-profile_fields");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-profile_fields&action=delete&fid={$profile_field['fid']}", $lang->confirm_profile_field_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_profile_fields_start");
|
||||
|
||||
$page->output_header($lang->custom_profile_fields);
|
||||
|
||||
$sub_tabs['custom_profile_fields'] = array(
|
||||
'title' => $lang->custom_profile_fields,
|
||||
'link' => "index.php?module=config-profile_fields",
|
||||
'description' => $lang->custom_profile_fields_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_profile_field'] = array(
|
||||
'title' => $lang->add_new_profile_field,
|
||||
'link' => "index.php?module=config-profile_fields&action=add",
|
||||
);
|
||||
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'custom_profile_fields');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->name);
|
||||
$table->construct_header($lang->required, array("class" => "align_center"));
|
||||
$table->construct_header($lang->registration, array("class" => "align_center"));
|
||||
$table->construct_header($lang->editable, array("class" => "align_center"));
|
||||
$table->construct_header($lang->profile, array("class" => "align_center"));
|
||||
$table->construct_header($lang->postbit, array("class" => "align_center"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center"));
|
||||
|
||||
$query = $db->simple_select("profilefields", "*", "", array('order_by' => 'disporder'));
|
||||
while($field = $db->fetch_array($query))
|
||||
{
|
||||
if($field['required'])
|
||||
{
|
||||
$required = $lang->yes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$required = $lang->no;
|
||||
}
|
||||
|
||||
if($field['registration'])
|
||||
{
|
||||
$registration = $lang->yes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$registration = $lang->no;
|
||||
}
|
||||
|
||||
if($field['editableby'] == '')
|
||||
{
|
||||
$editable = $lang->no;
|
||||
}
|
||||
else
|
||||
{
|
||||
$editable = $lang->yes;
|
||||
}
|
||||
|
||||
if($field['profile'])
|
||||
{
|
||||
$profile = $lang->yes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile = $lang->no;
|
||||
}
|
||||
|
||||
if($field['postbit'])
|
||||
{
|
||||
$postbit = $lang->yes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$postbit = $lang->no;
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong><a href=\"index.php?module=config-profile_fields&action=edit&fid={$field['fid']}\">".htmlspecialchars_uni($field['name'])."</a></strong><br /><small>".htmlspecialchars_uni($field['description'])."</small>", array('width' => '35%'));
|
||||
$table->construct_cell($required, array("class" => "align_center", 'width' => '10%'));
|
||||
$table->construct_cell($registration, array("class" => "align_center", 'width' => '10%'));
|
||||
$table->construct_cell($editable, array("class" => "align_center", 'width' => '10%'));
|
||||
$table->construct_cell($profile, array("class" => "align_center", 'width' => '10%'));
|
||||
$table->construct_cell($postbit, array("class" => "align_center", 'width' => '10%'));
|
||||
|
||||
$popup = new PopupMenu("field_{$field['fid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_field, "index.php?module=config-profile_fields&action=edit&fid={$field['fid']}");
|
||||
$popup->add_item($lang->delete_field, "index.php?module=config-profile_fields&action=delete&fid={$field['fid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_profile_field_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_profile_fields, array('colspan' => 7));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->custom_profile_fields);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
417
webroot/forum/admin/modules/config/questions.php
Normal file
417
webroot/forum/admin/modules/config/questions.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?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->security_questions, "index.php?module=config-questions");
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_questions_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['question']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_question;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['answer']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_answer;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(!isset($mybb->input['preview']))
|
||||
{
|
||||
$answer = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['answer']));
|
||||
|
||||
$new_question = array(
|
||||
"question" => $db->escape_string($mybb->input['question']),
|
||||
"answer" => $db->escape_string($answer),
|
||||
"active" => $mybb->get_input('active', MyBB::INPUT_INT)
|
||||
);
|
||||
$qid = $db->insert_query("questions", $new_question);
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_add_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($qid, $mybb->input['question']);
|
||||
|
||||
flash_message($lang->success_question_created, 'success');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_question);
|
||||
$page->output_header($lang->security_questions." - ".$lang->add_new_question);
|
||||
|
||||
$sub_tabs['security_questions'] = array(
|
||||
'title' => $lang->security_questions,
|
||||
'link' => "index.php?module=config-questions"
|
||||
);
|
||||
|
||||
$sub_tabs['add_new_question'] = array(
|
||||
'title' => $lang->add_new_question,
|
||||
'link' => "index.php?module=config-questions&action=add",
|
||||
'description' => $lang->add_new_question_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_new_question');
|
||||
|
||||
if(isset($mybb->input['preview']) && !$errors)
|
||||
{
|
||||
$table = new Table();
|
||||
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
|
||||
$parser_options = array(
|
||||
"allow_html" => 0,
|
||||
"allow_mycode" => 1,
|
||||
"allow_smilies" => 1,
|
||||
"allow_imgcode" => 1,
|
||||
"allow_videocode" => 1,
|
||||
"filter_badwords" => 1,
|
||||
"me_username" => 0,
|
||||
"shorten_urls" => 0,
|
||||
"highlight" => 0,
|
||||
);
|
||||
|
||||
$table->construct_cell($parser->parse_message($mybb->input['question'], $parser_options));
|
||||
$table->construct_row();
|
||||
$table->output($lang->preview_question);
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=config-questions&action=add", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['active'] = '1';
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_question);
|
||||
$form_container->output_row($lang->question." <em>*</em>", $lang->question_desc, $form->generate_text_area('question', $mybb->input['question'], array('id' => 'question')), 'question');
|
||||
$form_container->output_row($lang->answers." <em>*</em>", $lang->answers_desc, $form->generate_text_area('answer', $mybb->input['answer'], array('id' => 'answer')), 'answer');
|
||||
$form_container->output_row($lang->active." <em>*</em>", "", $form->generate_yes_no_radio('active', $mybb->input['active']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_question);
|
||||
$buttons[] = $form->generate_submit_button($lang->preview_question, array('name' => 'preview'));
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("questions", "*", "qid='".$mybb->get_input('qid', MyBB::INPUT_INT)."'");
|
||||
$question = $db->fetch_array($query);
|
||||
|
||||
if(!$question['qid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_question, 'error');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['question']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_question;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['answer']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_answer;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(!isset($mybb->input['preview']))
|
||||
{
|
||||
$answer = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['answer']));
|
||||
|
||||
$updated_question = array(
|
||||
"question" => $db->escape_string($mybb->input['question']),
|
||||
"answer" => $db->escape_string($answer),
|
||||
"active" => $mybb->get_input('active', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_edit_commit");
|
||||
|
||||
$db->update_query("questions", $updated_question, "qid='{$question['qid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($question['qid'], $mybb->input['question']);
|
||||
|
||||
flash_message($lang->success_question_updated, 'success');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_question);
|
||||
$page->output_header($lang->security_questions." - ".$lang->edit_question);
|
||||
|
||||
$sub_tabs['edit_question'] = array(
|
||||
'title' => $lang->edit_question,
|
||||
'link' => "index.php?module=config-questions&action=edit&qid={$question['qid']}",
|
||||
'description' => $lang->edit_question_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_question');
|
||||
|
||||
$form = new Form("index.php?module=config-questions&action=edit&qid={$question['qid']}", "post", "add");
|
||||
|
||||
$show_preview = false;
|
||||
if(isset($mybb->input['preview_list']))
|
||||
{
|
||||
$show_preview = true;
|
||||
}
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!isset($mybb->input['preview']))
|
||||
{
|
||||
$mybb->input = $question;
|
||||
}
|
||||
}
|
||||
|
||||
if((isset($mybb->input['preview']) || $show_preview === true) && !$errors)
|
||||
{
|
||||
$table = new Table();
|
||||
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
|
||||
$parser_options = array(
|
||||
"allow_html" => 0,
|
||||
"allow_mycode" => 1,
|
||||
"allow_smilies" => 1,
|
||||
"allow_imgcode" => 1,
|
||||
"allow_videocode" => 1,
|
||||
"filter_badwords" => 1,
|
||||
"me_username" => 0,
|
||||
"shorten_urls" => 0,
|
||||
"highlight" => 0,
|
||||
);
|
||||
|
||||
$table->construct_cell($parser->parse_message($mybb->input['question'], $parser_options));
|
||||
$table->construct_row();
|
||||
$table->output($lang->preview_question);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_question);
|
||||
$form_container->output_row($lang->question." <em>*</em>", $lang->question_desc, $form->generate_text_area('question', $mybb->input['question'], array('id' => 'question')), 'question');
|
||||
$form_container->output_row($lang->answers." <em>*</em>", $lang->answers_desc, $form->generate_text_area('answer', $mybb->input['answer'], array('id' => 'answer')), 'answer');
|
||||
$form_container->output_row($lang->active." <em>*</em>", "", $form->generate_yes_no_radio('active', $mybb->input['active']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_question);
|
||||
$buttons[] = $form->generate_submit_button($lang->preview_question, array('name' => 'preview'));
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("questions", "*", "qid='".$mybb->get_input('qid', MyBB::INPUT_INT)."'");
|
||||
$question = $db->fetch_array($query);
|
||||
|
||||
if(!$question['qid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_question, 'error');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("questions", "qid='{$question['qid']}'");
|
||||
$db->delete_query("questionsessions", "qid='{$question['qid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($question['qid'], $question['question']);
|
||||
|
||||
flash_message($lang->success_question_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-questions&action=delete&qid={$question['qid']}", $lang->confirm_question_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "disable")
|
||||
{
|
||||
$query = $db->simple_select("questions", "*", "qid='".$mybb->get_input('qid', MyBB::INPUT_INT)."'");
|
||||
$question = $db->fetch_array($query);
|
||||
|
||||
if(!$question['qid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_question, 'error');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_disable");
|
||||
|
||||
$update_question = array(
|
||||
"active" => 0
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_disable_commit");
|
||||
|
||||
$db->update_query("questions", $update_question, "qid = '{$question['qid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($question['qid'], $question['question']);
|
||||
|
||||
flash_message($lang->success_question_disabled, 'success');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "enable")
|
||||
{
|
||||
$query = $db->simple_select("questions", "*", "qid='".$mybb->get_input('qid', MyBB::INPUT_INT)."'");
|
||||
$question = $db->fetch_array($query);
|
||||
|
||||
if(!$question['qid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_question, 'error');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_enable");
|
||||
|
||||
$update_question = array(
|
||||
"active" => 1
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_questions_enable_commit");
|
||||
|
||||
$db->update_query("questions", $update_question, "qid = '{$question['qid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($question['qid'], $question['question']);
|
||||
|
||||
flash_message($lang->success_question_enabled, 'success');
|
||||
admin_redirect("index.php?module=config-questions");
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_questions_start");
|
||||
|
||||
$page->output_header($lang->security_questions);
|
||||
|
||||
$sub_tabs['security_questions'] = array(
|
||||
'title' => $lang->security_questions,
|
||||
'link' => "index.php?module=config-questions",
|
||||
'description' => $lang->security_questions_desc
|
||||
);
|
||||
$sub_tabs['add_new_question'] = array(
|
||||
'title' => $lang->add_new_question,
|
||||
'link' => "index.php?module=config-questions&action=add",
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'security_questions');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->question);
|
||||
$table->construct_header($lang->answers, array("width" => "35%"));
|
||||
$table->construct_header($lang->shown, array("width" => "5%", "class" => "align_center"));
|
||||
$table->construct_header($lang->correct, array("width" => "5%", "class" => "align_center"));
|
||||
$table->construct_header($lang->incorrect, array("width" => "5%", "class" => "align_center"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
$query = $db->simple_select("questions", "*", "", array('order_by' => 'question'));
|
||||
while($questions = $db->fetch_array($query))
|
||||
{
|
||||
$questions['question'] = htmlspecialchars_uni($questions['question']);
|
||||
$questions['answer'] = htmlspecialchars_uni($questions['answer']);
|
||||
$questions['answer'] = preg_replace("#(\n)#s", "<br />", trim($questions['answer']));
|
||||
$questions['shown'] = my_number_format($questions['shown']);
|
||||
$questions['correct'] = my_number_format($questions['correct']);
|
||||
$questions['incorrect'] = my_number_format($questions['incorrect']);
|
||||
|
||||
if($questions['active'] == 1)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
$table->construct_cell("<div>{$icon}{$questions['question']}</div>");
|
||||
$table->construct_cell($questions['answer']);
|
||||
$table->construct_cell($questions['shown'], array("class" => "align_center"));
|
||||
$table->construct_cell($questions['correct'], array("class" => "align_center"));
|
||||
$table->construct_cell($questions['incorrect'], array("class" => "align_center"));
|
||||
$popup = new PopupMenu("questions_{$questions['qid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_question, "index.php?module=config-questions&action=edit&qid={$questions['qid']}");
|
||||
$popup->add_item($lang->preview_question, "index.php?module=config-questions&action=edit&qid={$questions['qid']}&preview_list");
|
||||
if($questions['active'] == 1)
|
||||
{
|
||||
$popup->add_item($lang->disable_question, "index.php?module=config-questions&action=disable&qid={$questions['qid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup->add_item($lang->enable_question, "index.php?module=config-questions&action=enable&qid={$questions['qid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
$popup->add_item($lang->delete_question, "index.php?module=config-questions&action=delete&qid={$questions['qid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_question_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_security_questions, array('colspan' => 6));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->security_questions);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
449
webroot/forum/admin/modules/config/report_reasons.php
Normal file
449
webroot/forum/admin/modules/config/report_reasons.php
Normal file
@@ -0,0 +1,449 @@
|
||||
<?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->report_reasons, "index.php?module=config-report_reasons");
|
||||
|
||||
$content_types = array('post', 'profile', 'reputation');
|
||||
|
||||
$content_types = $plugins->run_hooks("report_content_types", $content_types);
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
cast_content_inputs();
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if($mybb->input['extra'] != 0 && $mybb->input['extra'] != 1)
|
||||
{
|
||||
$errors[] = $lang->error_missing_extra;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if($mybb->input['appliesto'] != 'all')
|
||||
{
|
||||
$appliesto = array();
|
||||
asort($content_types);
|
||||
foreach($content_types as $content)
|
||||
{
|
||||
if($mybb->input["appliesto_{$content}"] == 1)
|
||||
{
|
||||
$appliesto[] = $content;
|
||||
}
|
||||
}
|
||||
$appliesto = implode(",", $appliesto);
|
||||
}
|
||||
else
|
||||
{
|
||||
$appliesto = 'all';
|
||||
}
|
||||
|
||||
$new_reason = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"appliesto" => $db->escape_string($appliesto),
|
||||
"extra" => $mybb->input['extra']
|
||||
);
|
||||
$rid = $db->insert_query("reportreasons", $new_reason);
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_add_commit");
|
||||
|
||||
$cache->update_reportreasons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($rid, $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_reason_created, 'success');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_reason);
|
||||
$page->output_header($lang->report_reasons." - ".$lang->add_new_reason);
|
||||
|
||||
$sub_tabs['report_reasons'] = array(
|
||||
'title' => $lang->report_reasons,
|
||||
'link' => "index.php?module=config-report_reasons"
|
||||
);
|
||||
|
||||
$sub_tabs['add_new_reason'] = array(
|
||||
'title' => $lang->add_new_reason,
|
||||
'link' => "index.php?module=config-report_reasons&action=add",
|
||||
'description' => $lang->add_new_reason_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_new_reason');
|
||||
|
||||
$form = new Form("index.php?module=config-report_reasons&action=add", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['extra'] = 0;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_reason);
|
||||
$form_container->output_row($lang->reason_title." <em>*</em>", $lang->reason_title_desc, $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->applies_to." <em>*</em>", $lang->applies_to_desc, generate_content_select());
|
||||
$form_container->output_row($lang->requires_extra." <em>*</em>", $lang->requires_extra_desc, $form->generate_yes_no_radio('extra', $mybb->input['extra']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_reason);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("reportreasons", "*", "rid='".$mybb->get_input('rid', MyBB::INPUT_INT)."'");
|
||||
$reason = $db->fetch_array($query);
|
||||
|
||||
if(!$reason['rid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_reason, 'error');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
elseif($reason['rid'] == 1)
|
||||
{
|
||||
flash_message($lang->error_cannot_modify_reason, 'error');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
|
||||
cast_content_inputs();
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if($mybb->input['extra'] != 0 && $mybb->input['extra'] != 1)
|
||||
{
|
||||
$errors[] = $lang->error_missing_extra;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if($mybb->input['appliesto'] != 'all')
|
||||
{
|
||||
$appliesto = array();
|
||||
asort($content_types);
|
||||
foreach($content_types as $content)
|
||||
{
|
||||
if($mybb->input["appliesto_{$content}"] == 1)
|
||||
{
|
||||
$appliesto[] = $content;
|
||||
}
|
||||
}
|
||||
$appliesto = implode(",", $appliesto);
|
||||
}
|
||||
else
|
||||
{
|
||||
$appliesto = 'all';
|
||||
}
|
||||
|
||||
$updated_reason = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"appliesto" => $db->escape_string($appliesto),
|
||||
"extra" => $mybb->input['extra']
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_edit_commit");
|
||||
|
||||
$db->update_query("reportreasons", $updated_reason, "rid='{$reason['rid']}'");
|
||||
|
||||
$cache->update_reportreasons();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($reason['rid'], $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_reason_updated, 'success');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_reason);
|
||||
$page->output_header($lang->report_reasons." - ".$lang->edit_reason);
|
||||
|
||||
$sub_tabs['edit_reason'] = array(
|
||||
'title' => $lang->edit_reason,
|
||||
'link' => "index.php?module=config-report_reasons&action=edit&rid={$reason['rid']}",
|
||||
'description' => $lang->edit_reason_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_reason');
|
||||
|
||||
$form = new Form("index.php?module=config-report_reasons&action=edit&rid={$reason['rid']}", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = $reason;
|
||||
$appliesto = explode(",", $reason['appliesto']);
|
||||
foreach($appliesto as $content)
|
||||
{
|
||||
$mybb->input["appliesto_{$content}"] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_reason);
|
||||
$form_container->output_row($lang->reason_title." <em>*</em>", $lang->reason_title_desc, $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->applies_to." <em>*</em>", $lang->applies_to_desc, generate_content_select());
|
||||
$form_container->output_row($lang->requires_extra." <em>*</em>", $lang->requires_extra_desc, $form->generate_yes_no_radio('extra', $mybb->input['extra']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_reason);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("reportreasons", "*", "rid='".$mybb->get_input('rid', MyBB::INPUT_INT)."'");
|
||||
$reason = $db->fetch_array($query);
|
||||
|
||||
if(!$reason['rid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_reason, 'error');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
elseif($reason['rid'] == 1)
|
||||
{
|
||||
flash_message($lang->error_cannot_delete_reason, 'error');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
|
||||
// Change the reason of associated reports to Other and carry over the title
|
||||
$updated_report = array(
|
||||
'reasonid' => 1,
|
||||
'reason' => $db->escape_string($reason['title'])
|
||||
);
|
||||
$db->update_query("reportedcontent", $updated_report, "reasonid='{$reason['rid']}'");
|
||||
|
||||
$db->delete_query("reportreasons", "rid='{$reason['rid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($reason['rid'], $reason['title']);
|
||||
|
||||
flash_message($lang->success_reason_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-report_reasons&action=delete&rid={$reason['rid']}", $lang->confirm_reason_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_report_reasons_start");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!empty($mybb->input['disporder']))
|
||||
{
|
||||
foreach($mybb->input['disporder'] as $rid => $order)
|
||||
{
|
||||
$db->update_query("reportreasons", array('disporder' => (int)$order), "rid='".(int)$rid."'");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_report_reasons_start_commit");
|
||||
|
||||
$cache->update_reportreasons();
|
||||
|
||||
flash_message($lang->success_reasons_disporder_updated, 'success');
|
||||
admin_redirect("index.php?module=config-report_reasons");
|
||||
}
|
||||
}
|
||||
|
||||
$page->output_header($lang->report_reasons);
|
||||
|
||||
$sub_tabs['report_reasons'] = array(
|
||||
'title' => $lang->report_reasons,
|
||||
'link' => "index.php?module=config-report_reasons",
|
||||
'description' => $lang->report_reasons_desc
|
||||
);
|
||||
$sub_tabs['add_new_reason'] = array(
|
||||
'title' => $lang->add_new_reason,
|
||||
'link' => "index.php?module=config-report_reasons&action=add",
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'report_reasons');
|
||||
|
||||
$form = new Form("index.php?module=config-report_reasons", "post", "reasons");
|
||||
|
||||
$form_container = new FormContainer($lang->report_reasons);
|
||||
$form_container->output_row_header($lang->reason_title);
|
||||
$form_container->output_row_header($lang->applies_to, array("width" => "35%"));
|
||||
$form_container->output_row_header($lang->extra_comment, array("width" => "10%", "class" => "align_center"));
|
||||
$form_container->output_row_header($lang->order, array("width" => "5%", "class" => "align_center"));
|
||||
$form_container->output_row_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
$query = $db->simple_select("reportreasons", "*", "", array('order_by' => 'disporder'));
|
||||
while($reasons = $db->fetch_array($query))
|
||||
{
|
||||
$reasons['title'] = $lang->parse($reasons['title']);
|
||||
|
||||
$reasons['appliesto'] = explode(",", $reasons['appliesto']);
|
||||
|
||||
$appliesto = array();
|
||||
foreach($reasons['appliesto'] as $content)
|
||||
{
|
||||
$key = "report_content_".$content;
|
||||
$appliesto[] = $lang->$key;
|
||||
}
|
||||
$reasons['appliesto'] = implode(", ", $appliesto);
|
||||
|
||||
if($reasons['extra'] == 1)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->yes})\" title=\"{$lang->yes}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->no})\" title=\"{$lang->no}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
$form_container->output_cell(htmlspecialchars_uni($reasons['title']));
|
||||
$form_container->output_cell(htmlspecialchars_uni($reasons['appliesto']));
|
||||
$form_container->output_cell("<div>{$icon}</div>", array("class" => "align_center"));
|
||||
$form_container->output_cell("<input type=\"text\" name=\"disporder[{$reasons['rid']}]\" value=\"{$reasons['disporder']}\" class=\"text_input align_center\" style=\"width: 80%;\" />", array("class" => "align_center"));
|
||||
$popup = new PopupMenu("reasons_{$reasons['rid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_reason, "index.php?module=config-report_reasons&action=edit&rid={$reasons['rid']}");
|
||||
$popup->add_item($lang->delete_reason, "index.php?module=config-report_reasons&action=delete&rid={$reasons['rid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_reason_deletion}')");
|
||||
$form_container->output_cell($popup->fetch(), array("class" => "align_center"));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
if($form_container->num_rows() == 0)
|
||||
{
|
||||
$form_container->construct_cell($lang->no_report_reasons, array('colspan' => 5));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons = array();
|
||||
$buttons[] = $form->generate_submit_button($lang->update_reasons_order);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
function generate_content_select()
|
||||
{
|
||||
global $mybb, $lang;
|
||||
|
||||
$checked = array('all' => '', 'custom' => '', 'none' => '');
|
||||
if($mybb->input['appliesto'] == 'all')
|
||||
{
|
||||
$checked['all'] = 'checked="checked"';
|
||||
}
|
||||
elseif($mybb->input['appliesto'] == '')
|
||||
{
|
||||
$checked['none'] = 'checked="checked"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$checked['custom'] = 'checked="checked"';
|
||||
}
|
||||
|
||||
print_selection_javascript();
|
||||
|
||||
return "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"appliesto\" value=\"all\" {$checked['all']} class=\"appliesto_forums_groups_check\" onclick=\"checkAction('appliesto');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_content}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"appliesto\" value=\"custom\" {$checked['custom']} class=\"appliesto_forums_groups_check\" onclick=\"checkAction('appliesto');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_content}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"appliesto_forums_groups_custom\" class=\"appliesto_forums_groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->content_colon}</small></td>
|
||||
<td>".implode("<br />", generate_content_choices())."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"appliesto\" value=\"none\" {$checked['none']} class=\"appliesto_forums_groups_check\" onclick=\"checkAction('appliesto');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('appliesto');
|
||||
</script>";
|
||||
}
|
||||
|
||||
function generate_content_choices()
|
||||
{
|
||||
global $mybb, $lang, $form, $content_types;
|
||||
|
||||
asort($content_types);
|
||||
|
||||
$content_choices = array();
|
||||
foreach($content_types as $content)
|
||||
{
|
||||
$key = "report_content_{$content}";
|
||||
$content_choices[] = $form->generate_check_box("appliesto_{$content}", 1, $lang->$key, array('id' => "appliesto_{$content}", 'checked' => $mybb->input["appliesto_{$content}"]));
|
||||
}
|
||||
|
||||
return $content_choices;
|
||||
}
|
||||
|
||||
function cast_content_inputs()
|
||||
{
|
||||
global $mybb, $content_types;
|
||||
|
||||
asort($content_types);
|
||||
|
||||
foreach($content_types as $content)
|
||||
{
|
||||
$key = "appliesto_{$content}";
|
||||
$mybb->input[$key] = $mybb->get_input($key, MyBB::INPUT_INT);
|
||||
}
|
||||
|
||||
$mybb->input['extra'] = $mybb->get_input('extra', MyBB::INPUT_INT);
|
||||
}
|
||||
1838
webroot/forum/admin/modules/config/settings.php
Normal file
1838
webroot/forum/admin/modules/config/settings.php
Normal file
File diff suppressed because it is too large
Load Diff
769
webroot/forum/admin/modules/config/smilies.php
Normal file
769
webroot/forum/admin/modules/config/smilies.php
Normal file
@@ -0,0 +1,769 @@
|
||||
<?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->smilies, "index.php?module=config-smilies");
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['find']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_text_replacement;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['image']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['disporder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_order;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['disporder'] = $mybb->get_input('disporder', MyBB::INPUT_INT);
|
||||
$query = $db->simple_select('smilies', 'sid', 'disporder=\''.$mybb->input['disporder'].'\'');
|
||||
$duplicate_disporder = $db->fetch_field($query, 'sid');
|
||||
|
||||
if($duplicate_disporder)
|
||||
{
|
||||
$errors[] = $lang->error_duplicate_order;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$mybb->input['find'] = str_replace("\r\n", "\n", $mybb->input['find']);
|
||||
$mybb->input['find'] = str_replace("\r", "\n", $mybb->input['find']);
|
||||
$mybb->input['find'] = explode("\n", $mybb->input['find']);
|
||||
foreach(array_merge(array_keys($mybb->input['find'], ""), array_keys($mybb->input['find'], " ")) as $key)
|
||||
{
|
||||
unset($mybb->input['find'][$key]);
|
||||
}
|
||||
$mybb->input['find'] = implode("\n", $mybb->input['find']);
|
||||
|
||||
$new_smilie = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"find" => $db->escape_string($mybb->input['find']),
|
||||
"image" => $db->escape_string($mybb->input['image']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"showclickable" => $mybb->get_input('showclickable', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$sid = $db->insert_query("smilies", $new_smilie);
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_add_commit");
|
||||
|
||||
$cache->update_smilies();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($sid, $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_smilie_added, 'success');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_smilie);
|
||||
$page->output_header($lang->smilies." - ".$lang->add_smilie);
|
||||
|
||||
$sub_tabs['manage_smilies'] = array(
|
||||
'title' => $lang->manage_smilies,
|
||||
'link' => "index.php?module=config-smilies",
|
||||
);
|
||||
$sub_tabs['add_smilie'] = array(
|
||||
'title' => $lang->add_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=add",
|
||||
'description' => $lang->add_smilie_desc
|
||||
);
|
||||
$sub_tabs['add_multiple_smilies'] = array(
|
||||
'title' => $lang->add_multiple_smilies,
|
||||
'link' => "index.php?module=config-smilies&action=add_multiple",
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_smilie');
|
||||
$form = new Form("index.php?module=config-smilies&action=add", "post", "add");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['image'] = 'images/smilies/';
|
||||
$mybb->input['showclickable'] = 1;
|
||||
}
|
||||
|
||||
if(!$mybb->input['disporder'])
|
||||
{
|
||||
$query = $db->simple_select("smilies", "max(disporder) as dispordermax");
|
||||
$mybb->input['disporder'] = $db->fetch_field($query, "dispordermax")+1;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_smilie);
|
||||
$form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->text_replace." <em>*</em>", $lang->text_replace_desc, $form->generate_text_area('find', $mybb->input['find'], array('id' => 'find')), 'find');
|
||||
$form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('image', $mybb->input['image'], array('id' => 'image')), 'image');
|
||||
$form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->show_clickable." <em>*</em>", $lang->show_clickable_desc, $form->generate_yes_no_radio('showclickable', $mybb->input['showclickable']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_smilie);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("smilies", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
|
||||
$smilie = $db->fetch_array($query);
|
||||
|
||||
// Does the smilie not exist?
|
||||
if(!$smilie['sid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_smilie, 'error');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['find']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_text_replacement;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['image']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['disporder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_order;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['disporder'] = $mybb->get_input('disporder', MyBB::INPUT_INT);
|
||||
$query = $db->simple_select("smilies", "sid", "disporder= '".$mybb->input['disporder']."' AND sid != '".$smilie['sid']."'");
|
||||
$duplicate_disporder = $db->fetch_field($query, 'sid');
|
||||
|
||||
if($duplicate_disporder)
|
||||
{
|
||||
$errors[] = $lang->error_duplicate_order;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$mybb->input['find'] = str_replace("\r\n", "\n", $mybb->input['find']);
|
||||
$mybb->input['find'] = str_replace("\r", "\n", $mybb->input['find']);
|
||||
$mybb->input['find'] = explode("\n", $mybb->input['find']);
|
||||
foreach(array_merge(array_keys($mybb->input['find'], ""), array_keys($mybb->input['find'], " ")) as $key)
|
||||
{
|
||||
unset($mybb->input['find'][$key]);
|
||||
}
|
||||
$mybb->input['find'] = implode("\n", $mybb->input['find']);
|
||||
|
||||
$updated_smilie = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"find" => $db->escape_string($mybb->input['find']),
|
||||
"image" => $db->escape_string($mybb->input['image']),
|
||||
"disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
|
||||
"showclickable" => $mybb->get_input('showclickable', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_edit_commit");
|
||||
|
||||
$db->update_query("smilies", $updated_smilie, "sid = '{$smilie['sid']}'");
|
||||
|
||||
$cache->update_smilies();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($smilie['sid'], $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_smilie_updated, 'success');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_smilie);
|
||||
$page->output_header($lang->smilies." - ".$lang->edit_smilie);
|
||||
|
||||
$sub_tabs['edit_smilie'] = array(
|
||||
'title' => $lang->edit_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=edit",
|
||||
'description' => $lang->edit_smilie_desc
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit",
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_smilie');
|
||||
$form = new Form("index.php?module=config-smilies&action=edit", "post", "edit");
|
||||
|
||||
echo $form->generate_hidden_field("sid", $smilie['sid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $smilie);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_smilie);
|
||||
$form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->text_replace." <em>*</em>", $lang->text_replace_desc, $form->generate_text_area('find', $mybb->input['find'], array('id' => 'find')), 'find');
|
||||
$form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('image', $mybb->input['image'], array('id' => 'image')), 'image');
|
||||
$form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
|
||||
$form_container->output_row($lang->show_clickable." <em>*</em>", $lang->show_clickable_desc, $form->generate_yes_no_radio('showclickable', $mybb->input['showclickable']));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_smilie);
|
||||
$buttons[] = $form->generate_reset_button($lang->reset);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("smilies", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
|
||||
$smilie = $db->fetch_array($query);
|
||||
|
||||
// Does the smilie not exist?
|
||||
if(!$smilie['sid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_smilie, 'error');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the smilie
|
||||
$db->delete_query("smilies", "sid='{$smilie['sid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_delete_commit");
|
||||
|
||||
$cache->update_smilies();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($smilie['sid'], $smilie['name']);
|
||||
|
||||
flash_message($lang->success_smilie_updated, 'success');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-smilies&action=delete&sid={$smilie['sid']}", $lang->confirm_smilie_deletion);
|
||||
}}
|
||||
|
||||
if($mybb->input['action'] == "add_multiple")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_add_multiple");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if($mybb->input['step'] == 1)
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_add_multiple_step1");
|
||||
|
||||
if(!trim($mybb->input['pathfolder']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_path_multiple;
|
||||
}
|
||||
|
||||
$path = $mybb->input['pathfolder'];
|
||||
$dir = @opendir(MYBB_ROOT.$path);
|
||||
|
||||
if(!$dir)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_path;
|
||||
}
|
||||
|
||||
if($path && !is_array($errors))
|
||||
{
|
||||
if(substr($path, -1, 1) !== "/")
|
||||
{
|
||||
$path .= "/";
|
||||
}
|
||||
|
||||
$query = $db->simple_select("smilies");
|
||||
|
||||
$asmilies = array();
|
||||
while($smilie = $db->fetch_array($query))
|
||||
{
|
||||
$asmilies[$smilie['image']] = 1;
|
||||
}
|
||||
|
||||
$smilies = array();
|
||||
while($file = readdir($dir))
|
||||
{
|
||||
if($file != ".." && $file != ".")
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
if($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "bmp")
|
||||
{
|
||||
if(!$asmilies[$path.$file])
|
||||
{
|
||||
$smilies[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
if(count($smilies) == 0)
|
||||
{
|
||||
$errors[] = $lang->error_no_smilies;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->add_multiple_smilies);
|
||||
$page->output_header($lang->smilies." - ".$lang->add_multiple_smilies);
|
||||
|
||||
$sub_tabs['manage_smilies'] = array(
|
||||
'title' => $lang->manage_smilies,
|
||||
'link' => "index.php?module=config-smilies",
|
||||
);
|
||||
$sub_tabs['add_smilie'] = array(
|
||||
'title' => $lang->add_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=add"
|
||||
);
|
||||
$sub_tabs['add_multiple_smilies'] = array(
|
||||
'title' => $lang->add_multiple_smilies,
|
||||
'link' => "index.php?module=config-smilies&action=add_multiple",
|
||||
'description' => $lang->add_multiple_smilies_desc
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_multiple_smilies');
|
||||
$form = new Form("index.php?module=config-smilies&action=add_multiple", "post", "add_multiple");
|
||||
echo $form->generate_hidden_field("step", "2");
|
||||
echo $form->generate_hidden_field("pathfolder", $path);
|
||||
|
||||
$form_container = new FormContainer($lang->add_multiple_smilies);
|
||||
$form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '10%'));
|
||||
$form_container->output_row_header($lang->name);
|
||||
$form_container->output_row_header($lang->text_replace, array('width' => '20%'));
|
||||
$form_container->output_row_header($lang->include, array("class" => "align_center", 'width' => '5%'));
|
||||
|
||||
foreach($smilies as $key => $file)
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
$find = str_replace(".".$ext, "", $file);
|
||||
$name = ucfirst($find);
|
||||
|
||||
$file = htmlspecialchars_uni($file);
|
||||
|
||||
$form_container->output_cell("<img src=\"../".htmlspecialchars_uni($path).$file."\" alt=\"\" /><br /><small>{$file}</small>", array("class" => "align_center", "width" => 1));
|
||||
$form_container->output_cell($form->generate_text_box("name[{$file}]", htmlspecialchars_uni($name), array('id' => 'name', 'style' => 'width: 98%')));
|
||||
$form_container->output_cell($form->generate_text_box("find[{$file}]", ":".$find.":", array('id' => 'find', 'style' => 'width: 95%')));
|
||||
$form_container->output_cell($form->generate_check_box("include[{$file}]", 1, "", array('checked' => 1)), array("class" => "align_center"));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
if($form_container->num_rows() == 0)
|
||||
{
|
||||
flash_message($lang->error_no_images, 'error');
|
||||
admin_redirect("index.php?module=config-smilies&action=add_multiple");
|
||||
}
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_smilies);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_add_multiple_step2");
|
||||
|
||||
$path = $mybb->input['pathfolder'];
|
||||
reset($mybb->input['include']);
|
||||
$find = $mybb->input['find'];
|
||||
$name = $mybb->input['name'];
|
||||
|
||||
if(empty($mybb->input['include']))
|
||||
{
|
||||
flash_message($lang->error_none_included, 'error');
|
||||
admin_redirect("index.php?module=config-smilies&action=add_multiple");
|
||||
}
|
||||
|
||||
$query = $db->simple_select('smilies', 'MAX(disporder) as max_disporder');
|
||||
$disporder = $db->fetch_field($query, 'max_disporder');
|
||||
|
||||
foreach($mybb->input['include'] as $image => $insert)
|
||||
{
|
||||
$find[$image] = str_replace("\r\n", "\n", $find[$image]);
|
||||
$find[$image] = str_replace("\r", "\n", $find[$image]);
|
||||
$find[$image] = explode("\n", $find[$image]);
|
||||
foreach(array_merge(array_keys($find[$image], ""), array_keys($find[$image], " ")) as $key)
|
||||
{
|
||||
unset($find[$image][$key]);
|
||||
}
|
||||
$find[$image] = implode("\n", $find[$image]);
|
||||
|
||||
if($insert)
|
||||
{
|
||||
$new_smilie = array(
|
||||
"name" => $db->escape_string($name[$image]),
|
||||
"find" => $db->escape_string($find[$image]),
|
||||
"image" => $db->escape_string($path.$image),
|
||||
"disporder" => ++$disporder,
|
||||
"showclickable" => 1
|
||||
);
|
||||
|
||||
$db->insert_query("smilies", $new_smilie);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_add_multiple_commit");
|
||||
|
||||
$cache->update_smilies();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
flash_message($lang->success_multiple_smilies_added, 'success');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_multiple_smilies);
|
||||
$page->output_header($lang->smilies." - ".$lang->add_multiple_smilies);
|
||||
|
||||
$sub_tabs['manage_smilies'] = array(
|
||||
'title' => $lang->manage_smilies,
|
||||
'link' => "index.php?module=config-smilies",
|
||||
);
|
||||
$sub_tabs['add_smilie'] = array(
|
||||
'title' => $lang->add_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=add"
|
||||
);
|
||||
$sub_tabs['add_multiple_smilies'] = array(
|
||||
'title' => $lang->add_multiple_smilies,
|
||||
'link' => "index.php?module=config-smilies&action=add_multiple",
|
||||
'description' => $lang->add_multiple_smilies_desc
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_multiple_smilies');
|
||||
$form = new Form("index.php?module=config-smilies&action=add_multiple", "post", "add_multiple");
|
||||
echo $form->generate_hidden_field("step", "1");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_multiple_smilies);
|
||||
$form_container->output_row($lang->path_to_images, $lang->path_to_images_desc, $form->generate_text_box('pathfolder', $mybb->input['pathfolder'], array('id' => 'pathfolder')), 'pathfolder');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->show_smilies);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "mass_edit")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_mass_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
foreach($mybb->input['name'] as $sid => $name)
|
||||
{
|
||||
$disporder = (int)$mybb->input['disporder'][$sid];
|
||||
|
||||
$sid = (int)$sid;
|
||||
if($mybb->input['delete'][$sid] == 1)
|
||||
{
|
||||
// Dirty hack to get the disporder working. Note: this doesn't work in every case
|
||||
unset($mybb->input['disporder'][$sid]);
|
||||
|
||||
$db->delete_query("smilies", "sid = '{$sid}'", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['find'][$sid] = str_replace("\r\n", "\n", $mybb->input['find'][$sid]);
|
||||
$mybb->input['find'][$sid] = str_replace("\r", "\n", $mybb->input['find'][$sid]);
|
||||
$mybb->input['find'][$sid] = explode("\n", $mybb->input['find'][$sid]);
|
||||
foreach(array_merge(array_keys($mybb->input['find'][$sid], ""), array_keys($mybb->input['find'][$sid], " ")) as $key)
|
||||
{
|
||||
unset($mybb->input['find'][$sid][$key]);
|
||||
}
|
||||
$mybb->input['find'][$sid] = implode("\n", $mybb->input['find'][$sid]);
|
||||
|
||||
$smilie = array(
|
||||
"name" => $db->escape_string($mybb->input['name'][$sid]),
|
||||
"find" => $db->escape_string($mybb->input['find'][$sid]),
|
||||
"showclickable" => $db->escape_string($mybb->input['showclickable'][$sid])
|
||||
);
|
||||
|
||||
// $test contains all disporders except the actual one so we can check whether we have multiple disporders
|
||||
$test = $mybb->input['disporder'];
|
||||
unset($test[$sid]);
|
||||
if(!in_array($disporder, $test))
|
||||
{
|
||||
$smilie['disporder'] = $disporder;
|
||||
}
|
||||
|
||||
$db->update_query("smilies", $smilie, "sid = '{$sid}'");
|
||||
}
|
||||
|
||||
$disporder_list[$disporder] = $disporder;
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_smilies_mass_edit_commit");
|
||||
|
||||
$cache->update_smilies();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
flash_message($lang->success_multiple_smilies_updated, 'success');
|
||||
admin_redirect("index.php?module=config-smilies");
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->mass_edit);
|
||||
$page->output_header($lang->smilies." - ".$lang->mass_edit);
|
||||
|
||||
$sub_tabs['manage_smilies'] = array(
|
||||
'title' => $lang->manage_smilies,
|
||||
'link' => "index.php?module=config-smilies",
|
||||
);
|
||||
$sub_tabs['add_smilie'] = array(
|
||||
'title' => $lang->add_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=add",
|
||||
);
|
||||
$sub_tabs['add_multiple_smilies'] = array(
|
||||
'title' => $lang->add_multiple_smilies,
|
||||
'link' => "index.php?module=config-smilies&action=add_multiple",
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit",
|
||||
'description' => $lang->mass_edit_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'mass_edit');
|
||||
|
||||
$form = new Form("index.php?module=config-smilies&action=mass_edit", "post", "mass_edit");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['path'] = 'images/smilies/';
|
||||
$mybb->input['showclickable'] = 1;
|
||||
}
|
||||
|
||||
if(!$mybb->input['disporder'])
|
||||
{
|
||||
$query = $db->simple_select("smilies", "max(disporder) as dispordermax");
|
||||
$mybb->input['disporder'] = $db->fetch_field($query, "dispordermax")+1;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->manage_smilies);
|
||||
$form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '1'));
|
||||
$form_container->output_row_header($lang->name);
|
||||
$form_container->output_row_header($lang->text_replace, array('width' => '20%'));
|
||||
$form_container->output_row_header($lang->order, array('width' => '5%'));
|
||||
$form_container->output_row_header($lang->mass_edit_show_clickable, array("width" => 165));
|
||||
$form_container->output_row_header($lang->smilie_delete, array("class" => "align_center", 'width' => '5%'));
|
||||
|
||||
$query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder'));
|
||||
while($smilie = $db->fetch_array($query))
|
||||
{
|
||||
$smilie['image'] = str_replace("{theme}", "images", $smilie['image']);
|
||||
if(my_validate_url($smilie['image'], true))
|
||||
{
|
||||
$image = htmlspecialchars_uni($smilie['image']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = "../".htmlspecialchars_uni($smilie['image']);
|
||||
}
|
||||
|
||||
$form_container->output_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center", "width" => 1));
|
||||
$form_container->output_cell($form->generate_text_box("name[{$smilie['sid']}]", $smilie['name'], array('id' => 'name', 'style' => 'width: 98%')));
|
||||
$form_container->output_cell($form->generate_text_area("find[{$smilie['sid']}]", $smilie['find'], array('id' => 'find', 'style' => 'width: 95%')));
|
||||
$form_container->output_cell($form->generate_numeric_field("disporder[{$smilie['sid']}]", $smilie['disporder'], array('id' => 'disporder', 'style' => 'width: 80%', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_yes_no_radio("showclickable[{$smilie['sid']}]", $smilie['showclickable']), array("class" => "align_center"));
|
||||
$form_container->output_cell($form->generate_check_box("delete[{$smilie['sid']}]", 1, $mybb->input['delete']), array("class" => "align_center"));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
if($form_container->num_rows() == 0)
|
||||
{
|
||||
$form_container->output_cell($lang->no_smilies, array('colspan' => 6));
|
||||
$form_container->construct_row();
|
||||
}
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_smilies);
|
||||
$buttons[] = $form->generate_reset_button($lang->reset);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_smilies_start");
|
||||
|
||||
$page->output_header($lang->manage_smilies);
|
||||
|
||||
$sub_tabs['manage_smilies'] = array(
|
||||
'title' => $lang->manage_smilies,
|
||||
'link' => "index.php?module=config-smilies",
|
||||
'description' => $lang->manage_smilies_desc
|
||||
);
|
||||
$sub_tabs['add_smilie'] = array(
|
||||
'title' => $lang->add_smilie,
|
||||
'link' => "index.php?module=config-smilies&action=add",
|
||||
);
|
||||
$sub_tabs['add_multiple_smilies'] = array(
|
||||
'title' => $lang->add_multiple_smilies,
|
||||
'link' => "index.php?module=config-smilies&action=add_multiple",
|
||||
);
|
||||
$sub_tabs['mass_edit'] = array(
|
||||
'title' => $lang->mass_edit,
|
||||
'link' => "index.php?module=config-smilies&action=mass_edit",
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_smilies');
|
||||
|
||||
$query = $db->simple_select("smilies", "COUNT(sid) as smilies");
|
||||
$total_rows = $db->fetch_field($query, "smilies");
|
||||
|
||||
$pagenum = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
if($pagenum)
|
||||
{
|
||||
$start = ($pagenum-1) * 20;
|
||||
$pages = ceil($total_rows / 20);
|
||||
if($pagenum > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$pagenum = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$pagenum = 1;
|
||||
}
|
||||
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->image, array("class" => "align_center", "width" => 1));
|
||||
$table->construct_header($lang->name, array("width" => "35%"));
|
||||
$table->construct_header($lang->text_replace, array("width" => "35%"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("smilies", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'disporder'));
|
||||
while($smilie = $db->fetch_array($query))
|
||||
{
|
||||
$smilie['image'] = str_replace("{theme}", "images", $smilie['image']);
|
||||
if(my_validate_url($smilie['image'], true))
|
||||
{
|
||||
$image = htmlspecialchars_uni($smilie['image']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = "../".htmlspecialchars_uni($smilie['image']);
|
||||
}
|
||||
|
||||
$table->construct_cell("<img src=\"{$image}\" alt=\"\" class=\"smilie smilie_{$smilie['sid']}\" />", array("class" => "align_center"));
|
||||
$table->construct_cell(htmlspecialchars_uni($smilie['name']));
|
||||
$table->construct_cell(nl2br(htmlspecialchars_uni($smilie['find'])));
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=config-smilies&action=edit&sid={$smilie['sid']}\">{$lang->edit}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-smilies&action=delete&sid={$smilie['sid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_smilie_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_smilies, array('colspan' => 5));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->manage_smilies);
|
||||
|
||||
echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-smilies&page={page}");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
307
webroot/forum/admin/modules/config/spiders.php
Normal file
307
webroot/forum/admin/modules/config/spiders.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?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->spiders_bots, "index.php?module=config-spiders");
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_spiders_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['useragent']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_agent;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_spider = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"theme" => $mybb->get_input('theme', MyBB::INPUT_INT),
|
||||
"language" => $db->escape_string($mybb->input['language']),
|
||||
"usergroup" => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
"useragent" => $db->escape_string($mybb->input['useragent']),
|
||||
"lastvisit" => 0
|
||||
);
|
||||
$sid = $db->insert_query("spiders", $new_spider);
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_add_commit");
|
||||
|
||||
$cache->update_spiders();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($sid, $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_bot_created, 'success');
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_bot);
|
||||
$page->output_header($lang->spiders_bots." - ".$lang->add_new_bot);
|
||||
|
||||
$sub_tabs['spiders'] = array(
|
||||
'title' => $lang->spiders_bots,
|
||||
'link' => "index.php?module=config-spiders",
|
||||
);
|
||||
$sub_tabs['add_spider'] = array(
|
||||
'title' => $lang->add_new_bot,
|
||||
'link' => "index.php?module=config-spiders&action=add",
|
||||
'description' => $lang->add_new_bot_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "add_spider");
|
||||
|
||||
$form = new Form("index.php?module=config-spiders&action=add", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_bot);
|
||||
$form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->user_agent." <em>*</em>", $lang->user_agent_desc, $form->generate_text_box('useragent', $mybb->input['useragent'], array('id' => 'useragent')), 'useragent');
|
||||
|
||||
$languages = array('' => $lang->use_board_default);
|
||||
$languages = array_merge($languages, $lang->get_languages());
|
||||
$form_container->output_row($lang->language_str, $lang->language_desc, $form->generate_select_box("language", $languages, $mybb->input['language'], array("id" => "language")), 'language');
|
||||
|
||||
$form_container->output_row($lang->theme, $lang->theme_desc, build_theme_select("theme", $mybb->input['theme'], 0, "", true, false, true));
|
||||
|
||||
$query = $db->simple_select("usergroups", "*", "", array("order_by" => "title", "order_dir" => "asc"));
|
||||
|
||||
$usergroups = array();
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$usergroups[$usergroup['gid']] = $usergroup['title'];
|
||||
}
|
||||
if(!$mybb->input['usergroup'])
|
||||
{
|
||||
$mybb->input['usergroup'] = 1;
|
||||
}
|
||||
$form_container->output_row($lang->user_group, $lang->user_group_desc, $form->generate_select_box("usergroup", $usergroups, $mybb->input['usergroup'], array("id" => "usergroup")), 'usergroup');
|
||||
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->save_bot);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("spiders", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
|
||||
$spider = $db->fetch_array($query);
|
||||
|
||||
// Does the spider not exist?
|
||||
if(!$spider['sid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_bot, 'error');
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the spider
|
||||
$db->delete_query("spiders", "sid='{$spider['sid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_delete_commit");
|
||||
|
||||
$cache->update_spiders();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($spider['sid'], $spider['name']);
|
||||
|
||||
flash_message($lang->success_bot_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-spiders&action=delete&sid={$spider['sid']}", $lang->confirm_bot_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("spiders", "*", "sid='".$mybb->get_input('sid', MyBB::INPUT_INT)."'");
|
||||
$spider = $db->fetch_array($query);
|
||||
|
||||
// Does the spider not exist?
|
||||
if(!$spider['sid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_bot, 'error');
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['name']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_name;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['useragent']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_agent;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_spider = array(
|
||||
"name" => $db->escape_string($mybb->input['name']),
|
||||
"theme" => $mybb->get_input('theme', MyBB::INPUT_INT),
|
||||
"language" => $db->escape_string($mybb->input['language']),
|
||||
"usergroup" => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
"useragent" => $db->escape_string($mybb->input['useragent'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_spiders_edit_commit");
|
||||
|
||||
$db->update_query("spiders", $updated_spider, "sid='{$spider['sid']}'");
|
||||
|
||||
$cache->update_spiders();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($spider['sid'], $mybb->input['name']);
|
||||
|
||||
flash_message($lang->success_bot_updated, 'success');
|
||||
admin_redirect("index.php?module=config-spiders");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_bot);
|
||||
$page->output_header($lang->spiders_bots." - ".$lang->edit_bot);
|
||||
|
||||
$sub_tabs['edit_spider'] = array(
|
||||
'title' => $lang->edit_bot,
|
||||
'link' => "index.php?module=config-spiders&action=edit&sid={$spider['sid']}",
|
||||
'description' => $lang->edit_bot_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "edit_spider");
|
||||
|
||||
$form = new Form("index.php?module=config-spiders&action=edit&sid={$spider['sid']}", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
$spider_data = $mybb->input;
|
||||
}
|
||||
else
|
||||
{
|
||||
$spider_data = $spider;
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_bot);
|
||||
$form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $spider_data['name'], array('id' => 'name')), 'name');
|
||||
$form_container->output_row($lang->user_agent." <em>*</em>", $lang->user_agent_desc, $form->generate_text_box('useragent', $spider_data['useragent'], array('id' => 'useragent')), 'useragent');
|
||||
|
||||
$languages = array('' => $lang->use_board_default);
|
||||
$languages = array_merge($languages, $lang->get_languages());
|
||||
$form_container->output_row($lang->language_str, $lang->language_desc, $form->generate_select_box("language", $languages, $spider_data['language'], array("id" => "language")), 'language');
|
||||
|
||||
$form_container->output_row($lang->theme, $lang->theme_desc, build_theme_select("theme", $spider_data['theme'], 0, "", true, false, true));
|
||||
|
||||
$query = $db->simple_select("usergroups", "*", "", array("order_by" => "title", "order_dir" => "asc"));
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$usergroups[$usergroup['gid']] = $usergroup['title'];
|
||||
}
|
||||
if(!$spider_data['usergroup'])
|
||||
{
|
||||
$spider_data['usergroup'] = 1;
|
||||
}
|
||||
$form_container->output_row($lang->user_group, $lang->user_group_desc, $form->generate_select_box("usergroup", $usergroups, $spider_data['usergroup'], array("id" => "usergroup")), 'usergroup');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->save_bot);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_spiders_start");
|
||||
|
||||
$page->output_header($lang->spiders_bots);
|
||||
|
||||
$sub_tabs['spiders'] = array(
|
||||
'title' => $lang->spiders_bots,
|
||||
'link' => "index.php?module=config-spiders",
|
||||
'description' => $lang->spiders_bots_desc
|
||||
);
|
||||
$sub_tabs['add_spider'] = array(
|
||||
'title' => $lang->add_new_bot,
|
||||
'link' => "index.php?module=config-spiders&action=add"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "spiders");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->bot);
|
||||
$table->construct_header($lang->last_visit, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150, "colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("spiders", "*", "", array("order_by" => "lastvisit", "order_dir" => "desc"));
|
||||
while($spider = $db->fetch_array($query))
|
||||
{
|
||||
$lastvisit = $lang->never;
|
||||
$spider['name'] = htmlspecialchars_uni($spider['name']);
|
||||
|
||||
if($spider['lastvisit'])
|
||||
{
|
||||
$lastvisit = my_date('relative', $spider['lastvisit']);
|
||||
}
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=config-spiders&action=edit&sid={$spider['sid']}\"><strong>{$spider['name']}</strong></a>");
|
||||
$table->construct_cell($lastvisit, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-spiders&action=edit&sid={$spider['sid']}\">{$lang->edit}</a>", array("class" => "align_center", "width" => 75));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-spiders&action=delete&sid={$spider['sid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_bot_deletion}');\">{$lang->delete}</a>", array("class" => "align_center", "width" => 75));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_bots, array("colspan" => 4));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->spiders_bots);
|
||||
$page->output_footer();
|
||||
}
|
||||
536
webroot/forum/admin/modules/config/thread_prefixes.php
Normal file
536
webroot/forum/admin/modules/config/thread_prefixes.php
Normal file
@@ -0,0 +1,536 @@
|
||||
<?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->thread_prefixes, 'index.php?module=config-thread_prefixes');
|
||||
|
||||
$sub_tabs = array(
|
||||
"thread_prefixes" => array(
|
||||
'title' => $lang->thread_prefixes,
|
||||
'link' => 'index.php?module=config-thread_prefixes',
|
||||
'description' => $lang->thread_prefixes_desc
|
||||
),
|
||||
"add_prefix" => array(
|
||||
'title'=> $lang->add_new_thread_prefix,
|
||||
'link' => 'index.php?module=config-thread_prefixes&action=add_prefix',
|
||||
'description' => $lang->add_new_thread_prefix_desc
|
||||
)
|
||||
);
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_begin');
|
||||
|
||||
if($mybb->input['action'] == 'add_prefix')
|
||||
{
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_add_prefix');
|
||||
|
||||
if($mybb->request_method == 'post')
|
||||
{
|
||||
if(trim($mybb->input['prefix']) == '')
|
||||
{
|
||||
$errors[] = $lang->error_missing_prefix;
|
||||
}
|
||||
|
||||
if(trim($mybb->input['displaystyle']) == '')
|
||||
{
|
||||
$errors[] = $lang->error_missing_display_style;
|
||||
}
|
||||
|
||||
if($mybb->input['forum_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
|
||||
{
|
||||
$errors[] = $lang->error_no_forums_selected;
|
||||
}
|
||||
|
||||
$forum_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_checked[1] = "checked=\"checked\"";
|
||||
$mybb->input['forum_1_forums'] = '';
|
||||
}
|
||||
|
||||
if($mybb->input['group_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
|
||||
{
|
||||
$errors[] = $lang->error_no_groups_selected;
|
||||
}
|
||||
|
||||
$group_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked[1] = "checked=\"checked\"";
|
||||
$mybb->input['group_1_forums'] = '';
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_prefix = array(
|
||||
'prefix' => $db->escape_string($mybb->input['prefix']),
|
||||
'displaystyle' => $db->escape_string($mybb->input['displaystyle'])
|
||||
);
|
||||
|
||||
if($mybb->input['forum_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['forum_1_forums']))
|
||||
{
|
||||
$checked = array();
|
||||
foreach($mybb->input['forum_1_forums'] as $fid)
|
||||
{
|
||||
$checked[] = (int)$fid;
|
||||
}
|
||||
|
||||
$new_prefix['forums'] = implode(',', $checked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_prefix['forums'] = '-1';
|
||||
}
|
||||
|
||||
if($mybb->input['group_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['group_1_groups']))
|
||||
{
|
||||
$checked = array();
|
||||
foreach($mybb->input['group_1_groups'] as $gid)
|
||||
{
|
||||
$checked[] = (int)$gid;
|
||||
}
|
||||
|
||||
$new_prefix['groups'] = implode(',', $checked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_prefix['groups'] = '-1';
|
||||
}
|
||||
|
||||
$pid = $db->insert_query('threadprefixes', $new_prefix);
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_add_prefix_commit');
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($pid, $mybb->input['prefix']);
|
||||
$cache->update_threadprefixes();
|
||||
|
||||
flash_message($lang->success_thread_prefix_created, 'success');
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_thread_prefix);
|
||||
$page->output_header($lang->thread_prefixes." - ".$lang->add_new_thread_prefix);
|
||||
$page->output_nav_tabs($sub_tabs, 'add_prefix');
|
||||
|
||||
$form = new Form('index.php?module=config-thread_prefixes&action=add_prefix', 'post');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['prefix'] = '';
|
||||
$mybb->input['displaystyle'] = '';
|
||||
$mybb->input['forum_1_forums'] = '';
|
||||
$forum_checked[1] = "checked=\"checked\"";
|
||||
$forum_checked[2] = '';
|
||||
$mybb->input['group_1_groups'] = '';
|
||||
$group_checked[1] = "checked=\"checked\"";
|
||||
$group_checked[2] = '';
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->prefix_options);
|
||||
$form_container->output_row($lang->prefix.' <em>*</em>', $lang->prefix_desc, $form->generate_text_box('prefix', $mybb->input['prefix'], array('id' => 'prefix')), 'prefix');
|
||||
$form_container->output_row($lang->display_style.' <em>*</em>', $lang->display_style_desc, $form->generate_text_box('displaystyle', $mybb->input['displaystyle'], array('id' => 'displaystyle')), 'displaystyle');
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->forums_colon}</small></td>
|
||||
<td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('forum');
|
||||
</script>";
|
||||
$form_container->output_row($lang->available_in_forums.' <em>*</em>', '', $actions);
|
||||
|
||||
$group_select = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('group');
|
||||
</script>";
|
||||
$form_container->output_row($lang->available_to_groups." <em>*</em>", '', $group_select);
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_thread_prefix);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == 'edit_prefix')
|
||||
{
|
||||
$prefix = build_prefixes($mybb->input['pid']);
|
||||
if(empty($prefix['pid']))
|
||||
{
|
||||
flash_message($lang->error_invalid_prefix, 'error');
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_edit_prefix_start');
|
||||
|
||||
if($mybb->request_method == 'post')
|
||||
{
|
||||
if(trim($mybb->input['prefix']) == '')
|
||||
{
|
||||
$errors[] = $lang->error_missing_prefix;
|
||||
}
|
||||
|
||||
if(trim($mybb->input['displaystyle']) == '')
|
||||
{
|
||||
$errors[] = $lang->error_missing_display_style;
|
||||
}
|
||||
|
||||
if($mybb->input['forum_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
|
||||
{
|
||||
$errors[] = $lang->error_no_forums_selected;
|
||||
}
|
||||
|
||||
$forum_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_checked[1] = "checked=\"checked\"";
|
||||
$mybb->input['forum_1_forums'] = '';
|
||||
}
|
||||
|
||||
if($mybb->input['group_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
|
||||
{
|
||||
$errors[] = $lang->error_no_groups_selected;
|
||||
}
|
||||
|
||||
$group_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked[1] = "checked=\"checked\"";
|
||||
$mybb->input['group_1_forums'] = '';
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$update_prefix = array(
|
||||
'prefix' => $db->escape_string($mybb->input['prefix']),
|
||||
'displaystyle' => $db->escape_string($mybb->input['displaystyle'])
|
||||
);
|
||||
|
||||
if($mybb->input['forum_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['forum_1_forums']))
|
||||
{
|
||||
$checked = array();
|
||||
foreach($mybb->input['forum_1_forums'] as $fid)
|
||||
{
|
||||
$checked[] = (int)$fid;
|
||||
}
|
||||
|
||||
$update_prefix['forums'] = implode(',', $checked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$update_prefix['forums'] = '-1';
|
||||
}
|
||||
|
||||
if($mybb->input['group_type'] == 2)
|
||||
{
|
||||
if(is_array($mybb->input['group_1_groups']))
|
||||
{
|
||||
$checked = array();
|
||||
foreach($mybb->input['group_1_groups'] as $gid)
|
||||
{
|
||||
$checked[] = (int)$gid;
|
||||
}
|
||||
|
||||
$update_prefix['groups'] = implode(',', $checked);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$update_prefix['groups'] = '-1';
|
||||
}
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_edit_prefix_commit');
|
||||
|
||||
$db->update_query('threadprefixes', $update_prefix, "pid='{$prefix['pid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($prefix['pid'], $mybb->input['prefix']);
|
||||
$cache->update_threadprefixes();
|
||||
|
||||
flash_message($lang->success_thread_prefix_updated, 'success');
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_thread_prefix);
|
||||
$page->output_header($lang->thread_prefixes.' - '.$lang->edit_thread_prefix);
|
||||
|
||||
// Setup the edit prefix tab
|
||||
unset($sub_tabs);
|
||||
$sub_tabs['edit_prefix'] = array(
|
||||
"title" => $lang->edit_prefix,
|
||||
"link" => "index.php?module=config-thread_prefixes",
|
||||
"description" => $lang->edit_prefix_desc
|
||||
);
|
||||
$page->output_nav_tabs($sub_tabs, "edit_prefix");
|
||||
|
||||
$form = new Form('index.php?module=config-thread_prefixes&action=edit_prefix', 'post');
|
||||
echo $form->generate_hidden_field('pid', $prefix['pid']);
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select('threadprefixes', '*', "pid = '{$prefix['pid']}'");
|
||||
$threadprefix = $db->fetch_array($query);
|
||||
|
||||
$mybb->input['prefix'] = $threadprefix['prefix'];
|
||||
$mybb->input['displaystyle'] = $threadprefix['displaystyle'];
|
||||
$mybb->input['forum_1_forums'] = explode(",", $threadprefix['forums']);
|
||||
|
||||
if(!$threadprefix['forums'] || $threadprefix['forums'] == -1)
|
||||
{
|
||||
$forum_checked[1] = "checked=\"checked\"";
|
||||
$forum_checked[2] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_checked[1] = '';
|
||||
$forum_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
|
||||
$mybb->input['group_1_groups'] = explode(",", $threadprefix['groups']);
|
||||
|
||||
if(!$threadprefix['groups'] || $threadprefix['groups'] == -1)
|
||||
{
|
||||
$group_checked[1] = "checked=\"checked\"";
|
||||
$group_checked[2] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_checked[1] = '';
|
||||
$group_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->prefix_options);
|
||||
$form_container->output_row($lang->prefix.' <em>*</em>', $lang->prefix_desc, $form->generate_text_box('prefix', $mybb->input['prefix'], array('id' => 'prefix')), 'prefix');
|
||||
$form_container->output_row($lang->display_style.' <em>*</em>', $lang->display_style_desc, $form->generate_text_box('displaystyle', $mybb->input['displaystyle'], array('id' => 'displaystyle')), 'displaystyle');
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->forums_colon}</small></td>
|
||||
<td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('forum');
|
||||
</script>";
|
||||
$form_container->output_row($lang->available_in_forums.' <em>*</em>', '', $actions);
|
||||
|
||||
$group_select = "
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td valign=\"top\"><small>{$lang->groups_colon}</small></td>
|
||||
<td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('group');
|
||||
</script>";
|
||||
$form_container->output_row($lang->available_to_groups." <em>*</em>", '', $group_select);
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_thread_prefix);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == 'delete_prefix')
|
||||
{
|
||||
$prefix = build_prefixes($mybb->input['pid']);
|
||||
if(empty($prefix['pid']))
|
||||
{
|
||||
flash_message($lang->error_invalid_thread_prefix, 'error');
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_delete_prefix');
|
||||
|
||||
if($mybb->request_method == 'post')
|
||||
{
|
||||
// Remove prefix from existing threads
|
||||
$update_threads = array('prefix' => 0);
|
||||
|
||||
// Delete prefix
|
||||
$db->delete_query('threadprefixes', "pid='{$prefix['pid']}'");
|
||||
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_delete_thread_prefix_commit');
|
||||
|
||||
$db->update_query('threads', $update_threads, "prefix='{$prefix['pid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($prefix['pid'], $prefix['prefix']);
|
||||
$cache->update_threadprefixes();
|
||||
|
||||
flash_message($lang->success_thread_prefix_deleted, 'success');
|
||||
admin_redirect('index.php?module=config-thread_prefixes');
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-thread_prefixes&action=delete_prefix&pid={$prefix['pid']}", $lang->confirm_thread_prefix_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks('admin_config_thread_prefixes_start');
|
||||
|
||||
$page->output_header($lang->thread_prefixes);
|
||||
$page->output_nav_tabs($sub_tabs, 'thread_prefixes');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->prefix);
|
||||
$table->construct_header($lang->controls, array('class' => 'align_center', 'colspan' => 2));
|
||||
|
||||
$prefixes = build_prefixes();
|
||||
if(!empty($prefixes))
|
||||
{
|
||||
foreach($prefixes as $prefix)
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&action=edit_prefix&pid={$prefix['pid']}\"><strong>".htmlspecialchars_uni($prefix['prefix'])."</strong></a>");
|
||||
$table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&action=edit_prefix&pid={$prefix['pid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-thread_prefixes&action=delete_prefix&pid={$prefix['pid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_thread_prefix_deletion}')\">{$lang->delete}</a>", array('width' => 100, 'class' => 'align_center'));
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_thread_prefixes, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->thread_prefixes);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
774
webroot/forum/admin/modules/config/warning.php
Normal file
774
webroot/forum/admin/modules/config/warning.php
Normal file
@@ -0,0 +1,774 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
require_once MYBB_ROOT."inc/functions_warnings.php";
|
||||
|
||||
$page->add_breadcrumb_item($lang->warning_system, "index.php?module=config-warning");
|
||||
|
||||
if($mybb->input['action'] == "levels" || $mybb->input['action'] == "add_type" || $mybb->input['action'] == "add_level" || !$mybb->input['action'])
|
||||
{
|
||||
$sub_tabs['manage_types'] = array(
|
||||
'title' => $lang->warning_types,
|
||||
'link' => "index.php?module=config-warning",
|
||||
'description' => $lang->warning_types_desc
|
||||
);
|
||||
$sub_tabs['add_type'] = array(
|
||||
'title'=> $lang->add_warning_type,
|
||||
'link' => "index.php?module=config-warning&action=add_type",
|
||||
'description' => $lang->add_warning_type_desc
|
||||
);
|
||||
$sub_tabs['manage_levels'] = array(
|
||||
'title' => $lang->warning_levels,
|
||||
'link' => "index.php?module=config-warning&action=levels",
|
||||
'description' => $lang->warning_levels_desc,
|
||||
);
|
||||
$sub_tabs['add_level'] = array(
|
||||
'title'=> $lang->add_warning_level,
|
||||
'link' => "index.php?module=config-warning&action=add_level",
|
||||
'description' => $lang->add_warning_level_desc
|
||||
);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_begin");
|
||||
|
||||
if($mybb->input['action'] == "add_level")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_warning_add_level");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!is_numeric($mybb->input['percentage']) || $mybb->input['percentage'] > 100 || $mybb->input['percentage'] < 0)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_warning_percentage;
|
||||
}
|
||||
|
||||
if(!$mybb->input['action_type'])
|
||||
{
|
||||
$errors[] = $lang->error_missing_action_type;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
// Ban
|
||||
if($mybb->input['action_type'] == 1)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 1,
|
||||
"usergroup" => $mybb->get_input('action_1_usergroup', MyBB::INPUT_INT),
|
||||
"length" => fetch_time_length($mybb->input['action_1_time'], $mybb->input['action_1_period'])
|
||||
);
|
||||
}
|
||||
// Suspend posting
|
||||
else if($mybb->input['action_type'] == 2)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 2,
|
||||
"length" => fetch_time_length($mybb->input['action_2_time'], $mybb->input['action_2_period'])
|
||||
);
|
||||
}
|
||||
// Moderate posts
|
||||
else if($mybb->input['action_type'] == 3)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 3,
|
||||
"length" => fetch_time_length($mybb->input['action_3_time'], $mybb->input['action_3_period'])
|
||||
);
|
||||
}
|
||||
$new_level = array(
|
||||
"percentage" => $mybb->get_input('percentage', MyBB::INPUT_INT),
|
||||
"action" => my_serialize($action)
|
||||
);
|
||||
|
||||
$lid = $db->insert_query("warninglevels", $new_level);
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_add_level_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($lid, $mybb->input['percentage']);
|
||||
|
||||
flash_message($lang->success_warning_level_created, 'success');
|
||||
admin_redirect("index.php?module=config-warning&action=levels");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_warning_level);
|
||||
$page->output_header($lang->warning_levels." - ".$lang->add_warning_level);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_level');
|
||||
$form = new Form("index.php?module=config-warning&action=add_level", "post");
|
||||
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
$action_checked[$mybb->input['action_type']] = "checked=\"checked\"";
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_warning_level);
|
||||
$form_container->output_row($lang->warning_points_percentage, $lang->warning_points_percentage_desc, $form->generate_numeric_field('percentage', $mybb->input['percentage'], array('id' => 'percentage', 'min' => 0, 'max' => 100)), 'percentage');
|
||||
|
||||
$query = $db->simple_select("usergroups", "*", "isbannedgroup=1");
|
||||
while($group = $db->fetch_array($query))
|
||||
{
|
||||
$banned_groups[$group['gid']] = $group['title'];
|
||||
}
|
||||
|
||||
$periods = array(
|
||||
"hours" => $lang->expiration_hours,
|
||||
"days" => $lang->expiration_days,
|
||||
"weeks" => $lang->expiration_weeks,
|
||||
"months" => $lang->expiration_months,
|
||||
"never" => $lang->expiration_permanent
|
||||
);
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"1\" {$action_checked[1]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->ban_user}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_1\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->banned_group}</small></td>
|
||||
<td>".$form->generate_select_box('action_1_usergroup', $banned_groups, $mybb->input['action_1_usergroup'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><small>{$lang->ban_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_1_time', $mybb->input['action_1_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->input['action_1_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"2\" {$action_checked[2]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->suspend_posting_privileges}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_2\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->suspension_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_2_time', $mybb->input['action_2_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->input['action_2_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"3\" {$action_checked[3]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->moderate_posts}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_3\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->moderation_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_3_time', $mybb->input['action_3_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->input['action_3_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('action');
|
||||
</script>";
|
||||
$form_container->output_row($lang->action_to_be_taken, $lang->action_to_be_taken_desc, $actions);
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_warning_level);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit_level")
|
||||
{
|
||||
$query = $db->simple_select("warninglevels", "*", "lid='".$mybb->get_input('lid', MyBB::INPUT_INT)."'");
|
||||
$level = $db->fetch_array($query);
|
||||
|
||||
// Does the warning level not exist?
|
||||
if(!$level['lid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning_level, 'error');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_edit_level");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!is_numeric($mybb->input['percentage']) || $mybb->input['percentage'] > 100 || $mybb->input['percentage'] < 0)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_warning_percentage;
|
||||
}
|
||||
|
||||
if(!$mybb->input['action_type'])
|
||||
{
|
||||
$errors[] = $lang->error_missing_action_type;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
// Ban
|
||||
if($mybb->input['action_type'] == 1)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 1,
|
||||
"usergroup" => $mybb->get_input('action_1_usergroup', MyBB::INPUT_INT),
|
||||
"length" => fetch_time_length($mybb->input['action_1_time'], $mybb->input['action_1_period'])
|
||||
);
|
||||
}
|
||||
// Suspend posting
|
||||
else if($mybb->input['action_type'] == 2)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 2,
|
||||
"length" => fetch_time_length($mybb->input['action_2_time'], $mybb->input['action_2_period'])
|
||||
);
|
||||
}
|
||||
// Moderate posts
|
||||
else if($mybb->input['action_type'] == 3)
|
||||
{
|
||||
$action = array(
|
||||
"type" => 3,
|
||||
"length" => fetch_time_length($mybb->input['action_3_time'], $mybb->input['action_3_period'])
|
||||
);
|
||||
}
|
||||
$updated_level = array(
|
||||
"percentage" => $mybb->get_input('percentage', MyBB::INPUT_INT),
|
||||
"action" => my_serialize($action)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_edit_level_commit");
|
||||
|
||||
$db->update_query("warninglevels", $updated_level, "lid='{$level['lid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($level['lid'], $mybb->input['percentage']);
|
||||
|
||||
flash_message($lang->success_warning_level_updated, 'success');
|
||||
admin_redirect("index.php?module=config-warning&action=levels");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_warning_level);
|
||||
$page->output_header($lang->warning_levels." - ".$lang->edit_warning_level);
|
||||
|
||||
$sub_tabs['edit_level'] = array(
|
||||
'link' => "index.php?module=config-warning&action=edit_level&lid={$level['lid']}",
|
||||
'title' => $lang->edit_warning_level,
|
||||
'description' => $lang->edit_warning_level_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_level');
|
||||
$form = new Form("index.php?module=config-warning&action=edit_level&lid={$level['lid']}", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, array(
|
||||
"percentage" => $level['percentage'],
|
||||
)
|
||||
);
|
||||
$action = my_unserialize($level['action']);
|
||||
if($action['type'] == 1)
|
||||
{
|
||||
$mybb->input['action_1_usergroup'] = $action['usergroup'];
|
||||
$length = fetch_friendly_expiration($action['length']);
|
||||
$mybb->input['action_1_time'] = $length['time'];
|
||||
$mybb->input['action_1_period'] = $length['period'];
|
||||
}
|
||||
else if($action['type'] == 2)
|
||||
{
|
||||
$length = fetch_friendly_expiration($action['length']);
|
||||
$mybb->input['action_2_time'] = $length['time'];
|
||||
$mybb->input['action_2_period'] = $length['period'];
|
||||
}
|
||||
else if($action['type'] == 3)
|
||||
{
|
||||
$length = fetch_friendly_expiration($action['length']);
|
||||
$mybb->input['action_3_time'] = $length['time'];
|
||||
$mybb->input['action_3_period'] = $length['period'];
|
||||
}
|
||||
$action_checked[$action['type']] = "checked=\"checked\"";
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_warning_level);
|
||||
$form_container->output_row($lang->warning_points_percentage, $lang->warning_points_percentage_desc, $form->generate_numeric_field('percentage', $mybb->input['percentage'], array('id' => 'percentage', 'min' => 0, 'max' => 100)), 'percentage');
|
||||
|
||||
$query = $db->simple_select("usergroups", "*", "isbannedgroup=1");
|
||||
while($group = $db->fetch_array($query))
|
||||
{
|
||||
$banned_groups[$group['gid']] = $group['title'];
|
||||
}
|
||||
|
||||
$periods = array(
|
||||
"hours" => $lang->expiration_hours,
|
||||
"days" => $lang->expiration_days,
|
||||
"weeks" => $lang->expiration_weeks,
|
||||
"months" => $lang->expiration_months,
|
||||
"never" => $lang->expiration_permanent
|
||||
);
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"1\" {$action_checked[1]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->ban_user}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_1\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->banned_group}</small></td>
|
||||
<td>".$form->generate_select_box('action_1_usergroup', $banned_groups, $mybb->input['action_1_usergroup'])."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><small>{$lang->ban_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_1_time', $mybb->input['action_1_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->input['action_1_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"2\" {$action_checked[2]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->suspend_posting_privileges}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_2\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->suspension_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_2_time', $mybb->input['action_2_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->input['action_2_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"3\" {$action_checked[3]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->moderate_posts}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"action_3\" class=\"actions\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><small>{$lang->moderation_length}</small></td>
|
||||
<td>".$form->generate_numeric_field('action_3_time', $mybb->input['action_3_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->input['action_3_period'])."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('action');
|
||||
</script>";
|
||||
$form_container->output_row($lang->action_to_be_taken, $lang->action_to_be_taken_desc, $actions);
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_warning_level);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete_level")
|
||||
{
|
||||
$query = $db->simple_select("warninglevels", "*", "lid='".$mybb->get_input('lid', MyBB::INPUT_INT)."'");
|
||||
$level = $db->fetch_array($query);
|
||||
|
||||
// Does the warning level not exist?
|
||||
if(!$level['lid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning_level, 'error');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_delete_level");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the level
|
||||
$db->delete_query("warninglevels", "lid='{$level['lid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_delete_level_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($level['lid'], $level['percentage']);
|
||||
|
||||
flash_message($lang->success_warning_level_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-warning&action=delete_level&lid={$level['lid']}", $lang->confirm_warning_level_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "add_type")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_warning_add_type");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_type_title;
|
||||
}
|
||||
|
||||
if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] <= 0)
|
||||
{
|
||||
$errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_type = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"points" => $mybb->get_input('points', MyBB::INPUT_INT),
|
||||
"expirationtime" => fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
|
||||
);
|
||||
|
||||
$tid = $db->insert_query("warningtypes", $new_type);
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_add_type_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($tid, $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_warning_type_created, 'success');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, array(
|
||||
"points" => "2",
|
||||
"expire_time" => 1,
|
||||
"expire_period" => "days"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_warning_type);
|
||||
$page->output_header($lang->warning_types." - ".$lang->add_warning_type);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_type');
|
||||
$form = new Form("index.php?module=config-warning&action=add_type", "post");
|
||||
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_warning_type);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->points_to_add." <em>*</em>", $lang->points_to_add_desc, $form->generate_numeric_field('points', $mybb->input['points'], array('id' => 'points', 'min' => 0, 'max' => $mybb->settings['maxwarningpoints'])), 'points');
|
||||
$expiration_periods = array(
|
||||
"hours" => $lang->expiration_hours,
|
||||
"days" => $lang->expiration_days,
|
||||
"weeks" => $lang->expiration_weeks,
|
||||
"months" => $lang->expiration_months,
|
||||
"never" => $lang->expiration_never
|
||||
);
|
||||
$form_container->output_row($lang->warning_expiry, $lang->warning_expiry_desc, $form->generate_numeric_field('expire_time', $mybb->input['expire_time'], array('id' => 'expire_time', 'min' => 0))." ".$form->generate_select_box('expire_period', $expiration_periods, $mybb->input['expire_period'], array('id' => 'expire_period')), 'expire_time');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_warning_type);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit_type")
|
||||
{
|
||||
$query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$type = $db->fetch_array($query);
|
||||
|
||||
// Does the warning type not exist?
|
||||
if(!$type['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning_type, 'error');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_edit_type");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_type_title;
|
||||
}
|
||||
|
||||
if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] < 0)
|
||||
{
|
||||
$errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_type = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"points" => $mybb->get_input('points', MyBB::INPUT_INT),
|
||||
"expirationtime" => fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_edit_type_commit");
|
||||
|
||||
$db->update_query("warningtypes", $updated_type, "tid='{$type['tid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($type['tid'], $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_warning_type_updated, 'success');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$expiration = fetch_friendly_expiration($type['expirationtime']);
|
||||
$mybb->input = array_merge($mybb->input, array(
|
||||
"title" => $type['title'],
|
||||
"points" => $type['points'],
|
||||
"expire_time" => $expiration['time'],
|
||||
"expire_period" => $expiration['period']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_warning_type);
|
||||
$page->output_header($lang->warning_types." - ".$lang->edit_warning_type);
|
||||
|
||||
$sub_tabs['edit_type'] = array(
|
||||
'link' => "index.php?module=config-warning&action=edit_type&tid={$type['tid']}",
|
||||
'title' => $lang->edit_warning_type,
|
||||
'description' => $lang->edit_warning_type_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_type');
|
||||
$form = new Form("index.php?module=config-warning&action=edit_type&tid={$type['tid']}", "post");
|
||||
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_warning_type);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->points_to_add." <em>*</em>", $lang->points_to_add_desc, $form->generate_numeric_field('points', $mybb->input['points'], array('id' => 'points', 'min' => 0, 'max' => $mybb->settings['maxwarningpoints'])), 'points');
|
||||
$expiration_periods = array(
|
||||
"hours" => $lang->expiration_hours,
|
||||
"days" => $lang->expiration_days,
|
||||
"weeks" => $lang->expiration_weeks,
|
||||
"months" => $lang->expiration_months,
|
||||
"never" => $lang->expiration_never
|
||||
);
|
||||
$form_container->output_row($lang->warning_expiry, $lang->warning_expiry_desc, $form->generate_numeric_field('expire_time', $mybb->input['expire_time'], array('id' => 'expire_time', 'min' => 0))." ".$form->generate_select_box('expire_period', $expiration_periods, $mybb->input['expire_period'], array('id' => 'expire_period')), 'expire_time');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_warning_type);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete_type")
|
||||
{
|
||||
$query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$type = $db->fetch_array($query);
|
||||
|
||||
// Does the warning type not exist?
|
||||
if(!$type['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning_type, 'error');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_delete_type");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the type
|
||||
$db->delete_query("warningtypes", "tid='{$type['tid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_config_warning_delete_type_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($type['tid'], $type['title']);
|
||||
|
||||
flash_message($lang->success_warning_type_deleted, 'success');
|
||||
admin_redirect("index.php?module=config-warning");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=config-warning&action=delete_type&tid={$type['tid']}", $lang->confirm_warning_type_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "levels")
|
||||
{
|
||||
$plugins->run_hooks("admin_config_warning_levels");
|
||||
|
||||
$page->output_header($lang->warning_levels);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_levels');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->percentage, array('width' => '5%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->action_to_take);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("warninglevels", "*", "", array('order_by' => 'percentage'));
|
||||
while($level = $db->fetch_array($query))
|
||||
{
|
||||
$table->construct_cell("<strong>{$level['percentage']}%</strong>", array("class" => "align_center"));
|
||||
$action = my_unserialize($level['action']);
|
||||
$period = fetch_friendly_expiration($action['length']);
|
||||
|
||||
// Get the right language for the ban period
|
||||
$lang_str = "expiration_".$period['period'];
|
||||
$period_str = $lang->$lang_str;
|
||||
|
||||
if($action['type'] == 1)
|
||||
{
|
||||
$type = "move_banned_group";
|
||||
$group_name = $groupscache[$action['usergroup']]['title'];
|
||||
}
|
||||
elseif($action['type'] == 2)
|
||||
{
|
||||
$type = "suspend_posting";
|
||||
}
|
||||
elseif($action['type'] == 3)
|
||||
{
|
||||
$type = "moderate_new_posts";
|
||||
}
|
||||
|
||||
if($period['period'] == "never")
|
||||
{
|
||||
$type .= "_permanent";
|
||||
|
||||
if($group_name)
|
||||
{
|
||||
// Permanently banned? Oh noes... switch group to the first sprintf replacement...
|
||||
$period['time'] = $group_name;
|
||||
}
|
||||
}
|
||||
|
||||
// If this level is permanently in place, then $period_str and $group_name do not apply below...
|
||||
$type = $lang->sprintf($lang->$type, $period['time'], $period_str, $group_name);
|
||||
|
||||
$table->construct_cell($type);
|
||||
$table->construct_cell("<a href=\"index.php?module=config-warning&action=edit_level&lid={$level['lid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-warning&action=delete_level&lid={$level['lid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_warning_level_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_warning_levels, array('colspan' => 4));
|
||||
$table->construct_row();
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
$table->output($lang->warning_levels);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_config_warning_start");
|
||||
|
||||
$page->output_header($lang->warning_types);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_types');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->warning_type);
|
||||
$table->construct_header($lang->points, array('width' => '5%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->expires_after, array('width' => '25%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("warningtypes", "*", "", array('order_by' => 'title'));
|
||||
while($type = $db->fetch_array($query))
|
||||
{
|
||||
$type['name'] = htmlspecialchars_uni($type['title']);
|
||||
$table->construct_cell("<a href=\"index.php?module=config-warning&action=edit_type&tid={$type['tid']}\"><strong>{$type['name']}</strong></a>");
|
||||
$table->construct_cell("{$type['points']}", array("class" => "align_center"));
|
||||
$expiration = fetch_friendly_expiration($type['expirationtime']);
|
||||
$lang_str = "expiration_".$expiration['period'];
|
||||
if($type['expirationtime'] > 0)
|
||||
{
|
||||
$table->construct_cell("{$expiration['time']} {$lang->$lang_str}", array("class" => "align_center"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell($lang->never, array("class" => "align_center"));
|
||||
}
|
||||
$table->construct_cell("<a href=\"index.php?module=config-warning&action=edit_type&tid={$type['tid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=config-warning&action=delete_type&tid={$type['tid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_warning_type_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_warning_types, array('colspan' => 5));
|
||||
$table->construct_row();
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
$table->output($lang->warning_types);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
957
webroot/forum/admin/modules/forum/announcements.php
Normal file
957
webroot/forum/admin/modules/forum/announcements.php
Normal file
@@ -0,0 +1,957 @@
|
||||
<?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->forum_announcements, "index.php?module=forum-announcements");
|
||||
|
||||
if($mybb->input['action'] == "add" || !$mybb->input['action'])
|
||||
{
|
||||
$sub_tabs['forum_announcements'] = array(
|
||||
'title' => $lang->forum_announcements,
|
||||
'link' => "index.php?module=forum-announcements",
|
||||
'description' => $lang->forum_announcements_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_announcement'] = array(
|
||||
'title' => $lang->add_announcement,
|
||||
'link' => "index.php?module=forum-announcements&action=add",
|
||||
'description' => $lang->add_announcement_desc
|
||||
);
|
||||
}
|
||||
else if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$sub_tabs['forum_announcements'] = array(
|
||||
'title' => $lang->forum_announcements,
|
||||
'link' => "index.php?module=forum-announcements",
|
||||
'description' => $lang->forum_announcements_desc
|
||||
);
|
||||
|
||||
$sub_tabs['update_announcement'] = array(
|
||||
'title' => $lang->update_announcement,
|
||||
'link' => "index.php?module=forum-announcements&action=add",
|
||||
'description' => $lang->update_announcement_desc
|
||||
);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_announcements_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['message']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_message;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['fid']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_forum;
|
||||
}
|
||||
|
||||
if(!checkdate($mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_start_date;
|
||||
}
|
||||
|
||||
// End before startdate?
|
||||
$startdate = @explode(" ", $mybb->input['starttime_time']);
|
||||
$startdate = @explode(":", $startdate[0]);
|
||||
$enddate = @explode(" ", $mybb->input['endtime_time']);
|
||||
$enddate = @explode(":", $enddate[0]);
|
||||
|
||||
if(stristr($mybb->input['starttime_time'], "pm"))
|
||||
{
|
||||
$startdate[0] = 12+$startdate[0];
|
||||
if($startdate[0] >= 24)
|
||||
{
|
||||
$startdate[0] = "00";
|
||||
}
|
||||
}
|
||||
|
||||
if(stristr($mybb->input['endtime_time'], "pm"))
|
||||
{
|
||||
$enddate[0] = 12+$enddate[0];
|
||||
if($enddate[0] >= 24)
|
||||
{
|
||||
$enddate[0] = "00";
|
||||
}
|
||||
}
|
||||
|
||||
$startdate = gmmktime((int)$startdate[0], (int)$startdate[1], 0, $mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT));
|
||||
|
||||
if($mybb->input['endtime_type'] != "2")
|
||||
{
|
||||
$enddate = gmmktime((int)$enddate[0], (int)$enddate[1], 0, $mybb->get_input('endtime_month', MyBB::INPUT_INT), $mybb->get_input('endtime_day', MyBB::INPUT_INT), $mybb->get_input('endtime_year', MyBB::INPUT_INT));
|
||||
if(!checkdate($mybb->get_input('endtime_month', MyBB::INPUT_INT), $mybb->get_input('endtime_day', MyBB::INPUT_INT), $mybb->get_input('endtime_year', MyBB::INPUT_INT)))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_end_date;
|
||||
}
|
||||
if($enddate <= $startdate)
|
||||
{
|
||||
$errors[] = $lang->error_end_before_start;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(isset($mybb->input['preview']))
|
||||
{
|
||||
$parser_options = array();
|
||||
$parser_options['allow_html'] = $mybb->settings['announcementshtml'] && $mybb->get_input('allowhtml', MyBB::INPUT_INT);
|
||||
$parser_options['allow_mycode'] = $mybb->get_input('allowmycode', MyBB::INPUT_INT);
|
||||
$parser_options['allow_smilies'] = $mybb->get_input('allowsmilies', MyBB::INPUT_INT);
|
||||
$parser_options['allow_imgcode'] = 1;
|
||||
$parser_options['allow_videocode'] = 1;
|
||||
$parser_options['me_username'] = htmlspecialchars_uni($mybb->user['username']);
|
||||
$parser_options['filter_badwords'] = 1;
|
||||
|
||||
// Set up the message parser if it doesn't already exist.
|
||||
if(!is_object($parser))
|
||||
{
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
}
|
||||
|
||||
$preview['message'] = $parser->parse_message($mybb->input['message'], $parser_options);
|
||||
$preview['subject'] = htmlspecialchars_uni($mybb->input['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
|
||||
if(!in_array($mybb->input['starttime_month'], $months))
|
||||
{
|
||||
$mybb->input['starttime_month'] = 1;
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_type'] == "2")
|
||||
{
|
||||
$enddate = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!in_array($mybb->input['endtime_month'], $months))
|
||||
{
|
||||
$mybb->input['endtime_month'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$insert_announcement = array(
|
||||
"fid" => $mybb->input['fid'],
|
||||
"uid" => $mybb->user['uid'],
|
||||
"subject" => $db->escape_string($mybb->input['title']),
|
||||
"message" => $db->escape_string($mybb->input['message']),
|
||||
"startdate" => $startdate,
|
||||
"enddate" => $enddate,
|
||||
"allowhtml" => (int)($mybb->settings['announcementshtml'] && $mybb->get_input('allowhtml', MyBB::INPUT_INT)),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$aid = $db->insert_query("announcements", $insert_announcement);
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_add_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($aid, $mybb->input['title']);
|
||||
$cache->update_forumsdisplay();
|
||||
|
||||
flash_message($lang->success_added_announcement, 'success');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_an_announcement);
|
||||
$page->output_header($lang->add_an_announcement);
|
||||
$page->output_nav_tabs($sub_tabs, "add_announcement");
|
||||
|
||||
$form = new Form("index.php?module=forum-announcements&action=add", "post");
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$default_options = array(
|
||||
'starttime_time',
|
||||
'starttime_day',
|
||||
'starttime_month',
|
||||
'starttime_year',
|
||||
'endtime_type',
|
||||
'endtime_time',
|
||||
'endtime_day',
|
||||
'endtime_month',
|
||||
'endtime_year',
|
||||
'title',
|
||||
'message',
|
||||
'fid',
|
||||
'allowhtml',
|
||||
'allowmycode',
|
||||
'allowsmilies'
|
||||
);
|
||||
|
||||
foreach($default_options as $option)
|
||||
{
|
||||
if(!isset($mybb->input[$option]))
|
||||
{
|
||||
$mybb->input[$option] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_type'] == "1")
|
||||
{
|
||||
$endtime_checked[1] = "checked=\"checked\"";
|
||||
$endtime_checked[2] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$endtime_checked[1] = "";
|
||||
$endtime_checked[2] = "checked=\"checked\"";
|
||||
}
|
||||
|
||||
if(!$mybb->input['starttime_time'])
|
||||
{
|
||||
$mybb->input['starttime_time'] = gmdate($mybb->settings['timeformat'], TIME_NOW);
|
||||
}
|
||||
|
||||
if(!$mybb->input['endtime_time'])
|
||||
{
|
||||
$mybb->input['endtime_time'] = gmdate($mybb->settings['timeformat'], TIME_NOW);
|
||||
}
|
||||
|
||||
if($mybb->input['starttime_day'])
|
||||
{
|
||||
$startday = $mybb->get_input('starttime_day', MyBB::INPUT_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$startday = gmdate("j", TIME_NOW);
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_day'])
|
||||
{
|
||||
$endday = $mybb->get_input('endtime_day', MyBB::INPUT_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$endday = gmdate("j", TIME_NOW);
|
||||
}
|
||||
|
||||
$startdateday = $enddateday = $startdatemonth = $enddatemonth = '';
|
||||
|
||||
// Days
|
||||
for($i = 1; $i <= 31; ++$i)
|
||||
{
|
||||
if($startday == $i)
|
||||
{
|
||||
$startdateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$startdateday .= "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
|
||||
if($endday == $i)
|
||||
{
|
||||
$enddateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$enddateday .= "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Months
|
||||
for($i = 1; $i <= 12; ++$i)
|
||||
{
|
||||
$endmonthsel[$i] = $startmonthsel[$i] = '';
|
||||
}
|
||||
|
||||
if($mybb->input['starttime_month'])
|
||||
{
|
||||
$startmonth = $mybb->get_input('starttime_month', MyBB::INPUT_INT);
|
||||
$startmonthsel[$startmonth] = "selected=\"selected\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$startmonth = gmdate("m", TIME_NOW);
|
||||
$startmonthsel[$startmonth] = "selected=\"selected\"";
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_month'])
|
||||
{
|
||||
$endmonth = $mybb->get_input('endtime_month', MyBB::INPUT_INT);
|
||||
$endmonthsel[$endmonth] = "selected=\"selected\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$endmonth = gmdate("m", TIME_NOW);
|
||||
$endmonthsel[$endmonth] = "selected=\"selected\"";
|
||||
}
|
||||
|
||||
$startdatemonth .= "<option value=\"01\" {$startmonthsel['01']}>{$lang->january}</option>\n";
|
||||
$enddatemonth .= "<option value=\"01\" {$endmonthsel['01']}>{$lang->january}</option>\n";
|
||||
$startdatemonth .= "<option value=\"02\" {$startmonthsel['02']}>{$lang->february}</option>\n";
|
||||
$enddatemonth .= "<option value=\"02\" {$endmonthsel['02']}>{$lang->february}</option>\n";
|
||||
$startdatemonth .= "<option value=\"03\" {$startmonthsel['03']}>{$lang->march}</option>\n";
|
||||
$enddatemonth .= "<option value=\"03\" {$endmonthsel['03']}>{$lang->march}</option>\n";
|
||||
$startdatemonth .= "<option value=\"04\" {$startmonthsel['04']}>{$lang->april}</option>\n";
|
||||
$enddatemonth .= "<option value=\"04\" {$endmonthsel['04']}>{$lang->april}</option>\n";
|
||||
$startdatemonth .= "<option value=\"05\" {$startmonthsel['05']}>{$lang->may}</option>\n";
|
||||
$enddatemonth .= "<option value=\"05\" {$endmonthsel['05']}>{$lang->may}</option>\n";
|
||||
$startdatemonth .= "<option value=\"06\" {$startmonthsel['06']}>{$lang->june}</option>\n";
|
||||
$enddatemonth .= "<option value=\"06\" {$endmonthsel['06']}>{$lang->june}</option>\n";
|
||||
$startdatemonth .= "<option value=\"07\" {$startmonthsel['07']}>{$lang->july}</option>\n";
|
||||
$enddatemonth .= "<option value=\"07\" {$endmonthsel['07']}>{$lang->july}</option>\n";
|
||||
$startdatemonth .= "<option value=\"08\" {$startmonthsel['08']}>{$lang->august}</option>\n";
|
||||
$enddatemonth .= "<option value=\"08\" {$endmonthsel['08']}>{$lang->august}</option>\n";
|
||||
$startdatemonth .= "<option value=\"09\" {$startmonthsel['09']}>{$lang->september}</option>\n";
|
||||
$enddatemonth .= "<option value=\"09\" {$endmonthsel['09']}>{$lang->september}</option>\n";
|
||||
$startdatemonth .= "<option value=\"10\" {$startmonthsel['10']}>{$lang->october}</option>\n";
|
||||
$enddatemonth .= "<option value=\"10\" {$endmonthsel['10']}>{$lang->october}</option>\n";
|
||||
$startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n";
|
||||
$enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n";
|
||||
$startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n";
|
||||
$enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n";
|
||||
|
||||
if($mybb->input['starttime_year'])
|
||||
{
|
||||
$startdateyear = $mybb->get_input('starttime_year', MyBB::INPUT_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$startdateyear = gmdate("Y", TIME_NOW);
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_year'])
|
||||
{
|
||||
$enddateyear = $mybb->get_input('endtime_year', MyBB::INPUT_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$enddateyear = gmdate("Y", TIME_NOW) + 1;
|
||||
}
|
||||
|
||||
if(isset($preview))
|
||||
{
|
||||
$form_container = new FormContainer($lang->announcement_preview);
|
||||
$form_container->output_row($preview['subject'], "", $preview['message'], 'preview');
|
||||
$form_container->end();
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_an_announcement);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->start_date." <em>*</em>", $lang->start_date_desc, "<select name=\"starttime_day\">\n{$startdateday}</select>\n \n<select name=\"starttime_month\">\n{$startdatemonth}</select>\n \n<input type=\"text\" name=\"starttime_year\" value=\"{$startdateyear}\" size=\"4\" maxlength=\"4\" />\n - {$lang->time} ".$form->generate_text_box('starttime_time', $mybb->input['starttime_time'], array('id' => 'starttime_time', 'style' => 'width: 50px;')));
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"1\" {$endtime_checked[1]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->set_time}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"endtime_1\" class=\"endtimes\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><select name=\"endtime_day\">\n{$enddateday}</select>\n \n<select name=\"endtime_month\">\n{$enddatemonth}</select>\n \n<input type=\"text\" name=\"endtime_year\" value=\"{$enddateyear}\" class=\"text_input\" size=\"4\" maxlength=\"4\" />\n - {$lang->time} ".$form->generate_text_box('endtime_time', $mybb->input['endtime_time'], array('id' => 'endtime_time', 'style' => 'width: 50px;'))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"2\" {$endtime_checked[2]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->never}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('endtime');
|
||||
</script>";
|
||||
$form_container->output_row($lang->end_date." <em>*</em>", $lang->end_date_desc, $actions);
|
||||
|
||||
$form_container->output_row($lang->message." <em>*</em>", "", $form->generate_text_area('message', $mybb->input['message'], array('id' => 'message')), 'message');
|
||||
|
||||
$form_container->output_row($lang->forums_to_appear_in." <em>*</em>", $lang->forums_to_appear_in_desc, $form->generate_forum_select('fid', $mybb->input['fid'], array('size' => 5, 'main_option' => $lang->all_forums)));
|
||||
|
||||
if ($mybb->settings['announcementshtml'])
|
||||
{
|
||||
$form_container->output_row($lang->allow_html." <em>*</em>", "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml'], array('style' => 'width: 2em;')));
|
||||
}
|
||||
|
||||
$form_container->output_row($lang->allow_mycode." <em>*</em>", "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode'], array('style' => 'width: 2em;')));
|
||||
|
||||
$form_container->output_row($lang->allow_smilies." <em>*</em>", "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies'], array('style' => 'width: 2em;')));
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_announcement);
|
||||
$buttons[] = $form->generate_submit_button($lang->preview_announcement, array('name' => 'preview'));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
if(!trim($mybb->input['aid']))
|
||||
{
|
||||
flash_message($lang->error_invalid_announcement, 'error');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['message']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_message;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['fid']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_forum;
|
||||
}
|
||||
|
||||
if(!checkdate($mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT)))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_start_date;
|
||||
}
|
||||
|
||||
// End before startdate?
|
||||
$startdate = @explode(" ", $mybb->input['starttime_time']);
|
||||
$startdate = @explode(":", $startdate[0]);
|
||||
$enddate = @explode(" ", $mybb->input['endtime_time']);
|
||||
$enddate = @explode(":", $enddate[0]);
|
||||
|
||||
if(stristr($mybb->input['starttime_time'], "pm"))
|
||||
{
|
||||
$startdate[0] = 12+$startdate[0];
|
||||
if($startdate[0] >= 24)
|
||||
{
|
||||
$startdate[0] = "00";
|
||||
}
|
||||
}
|
||||
|
||||
if(stristr($mybb->input['endtime_time'], "pm"))
|
||||
{
|
||||
$enddate[0] = 12+$enddate[0];
|
||||
if($enddate[0] >= 24)
|
||||
{
|
||||
$enddate[0] = "00";
|
||||
}
|
||||
}
|
||||
|
||||
$startdate = gmmktime((int)$startdate[0], (int)$startdate[1], 0, $mybb->get_input('starttime_month', MyBB::INPUT_INT), $mybb->get_input('starttime_day', MyBB::INPUT_INT), $mybb->get_input('starttime_year', MyBB::INPUT_INT));
|
||||
|
||||
if($mybb->input['endtime_type'] != "2")
|
||||
{
|
||||
$enddate = gmmktime((int)$enddate[0], (int)$enddate[1], 0, $mybb->get_input('endtime_month', MyBB::INPUT_INT), $mybb->get_input('endtime_day', MyBB::INPUT_INT), $mybb->get_input('endtime_year', MyBB::INPUT_INT));
|
||||
if(!checkdate($mybb->get_input('endtime_month', MyBB::INPUT_INT), $mybb->get_input('endtime_day', MyBB::INPUT_INT), $mybb->get_input('endtime_year', MyBB::INPUT_INT)))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_end_date;
|
||||
}
|
||||
if($enddate <= $startdate)
|
||||
{
|
||||
$errors[] = $lang->error_end_before_start;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(isset($mybb->input['preview']))
|
||||
{
|
||||
$parser_options = array();
|
||||
$parser_options['allow_html'] = $mybb->settings['announcementshtml'] && $mybb->get_input('allowhtml', MyBB::INPUT_INT);
|
||||
$parser_options['allow_mycode'] = $mybb->get_input('allowmycode', MyBB::INPUT_INT);
|
||||
$parser_options['allow_smilies'] = $mybb->get_input('allowsmilies', MyBB::INPUT_INT);
|
||||
$parser_options['allow_imgcode'] = 1;
|
||||
$parser_options['allow_videocode'] = 1;
|
||||
$parser_options['me_username'] = htmlspecialchars_uni($mybb->user['username']);
|
||||
$parser_options['filter_badwords'] = 1;
|
||||
|
||||
// Set up the message parser if it doesn't already exist.
|
||||
if(!is_object($parser))
|
||||
{
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
}
|
||||
|
||||
$preview = array();
|
||||
$preview['message'] = $parser->parse_message($mybb->input['message'], $parser_options);
|
||||
$preview['subject'] = htmlspecialchars_uni($mybb->input['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
|
||||
if(!in_array($mybb->input['starttime_month'], $months))
|
||||
{
|
||||
$mybb->input['starttime_month'] = 1;
|
||||
}
|
||||
|
||||
if($mybb->input['endtime_type'] == "2")
|
||||
{
|
||||
$enddate = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!in_array($mybb->input['endtime_month'], $months))
|
||||
{
|
||||
$mybb->input['endtime_month'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$update_announcement = array(
|
||||
"fid" => $mybb->input['fid'],
|
||||
"subject" => $db->escape_string($mybb->input['title']),
|
||||
"message" => $db->escape_string($mybb->input['message']),
|
||||
"startdate" => $startdate,
|
||||
"enddate" => $enddate,
|
||||
"allowhtml" => (int)($mybb->settings['announcementshtml'] && $mybb->get_input('allowhtml', MyBB::INPUT_INT)),
|
||||
"allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
|
||||
"allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_edit_commit");
|
||||
|
||||
$db->update_query("announcements", $update_announcement, "aid='{$mybb->input['aid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['aid'], $mybb->input['title']);
|
||||
$cache->update_forumsdisplay();
|
||||
|
||||
flash_message($lang->success_updated_announcement, 'success');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->update_an_announcement);
|
||||
$page->output_header($lang->update_an_announcement);
|
||||
$page->output_nav_tabs($sub_tabs, "update_announcement");
|
||||
|
||||
$form = new Form("index.php?module=forum-announcements&action=edit", "post");
|
||||
echo $form->generate_hidden_field("aid", $mybb->input['aid']);
|
||||
|
||||
if($errors || isset($mybb->input['preview']))
|
||||
{
|
||||
// Only show errors if we have any
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
// Gather start and end date data
|
||||
$startday = $mybb->input['starttime_day'];
|
||||
$start_time = $mybb->input['starttime_time'];
|
||||
$startmonth = $mybb->input['starttime_month'];
|
||||
$startmonthsel[$startmonth] = 'selected="selected"';
|
||||
$startdateyear = $mybb->input['starttime_year'];
|
||||
|
||||
if($mybb->input['endtime_type'] == 1)
|
||||
{
|
||||
// Set time
|
||||
$endtime_checked[1] = 'checked="checked"';
|
||||
$endtime_checked[2] = '';
|
||||
|
||||
$endday = $mybb->input['endtime_day'];
|
||||
$endtime = $mybb->input['endtime_time'];
|
||||
$endmonth = $mybb->input['endtime_month'];
|
||||
$endmonthsel[$endmonth] = 'selected';
|
||||
$enddateyear = $mybb->input['endtime_year'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Never
|
||||
$endtime_checked[1] = '';
|
||||
$endtime_checked[2] = 'checked="checked"';
|
||||
|
||||
$endday = $startday;
|
||||
$endmonth = $startmonth;
|
||||
$endmonthsel[$endmonth] = 'selected';
|
||||
$enddateyear = $startdateyear + 1;
|
||||
}
|
||||
}
|
||||
elseif(!isset($mybb->input['preview']))
|
||||
{
|
||||
$query = $db->simple_select("announcements", "*", "aid='{$mybb->input['aid']}'");
|
||||
$announcement = $db->fetch_array($query);
|
||||
|
||||
if(!$announcement)
|
||||
{
|
||||
flash_message($lang->error_invalid_announcement, 'error');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
|
||||
$mybb->input['starttime_time'] = gmdate( $mybb->settings['timeformat'], $announcement['startdate']);
|
||||
|
||||
$startday = gmdate("j", $announcement['startdate']);
|
||||
|
||||
$startmonth = gmdate("m", $announcement['startdate']);
|
||||
$startmonthsel[$startmonth] = "selected=\"selected\"";
|
||||
|
||||
$startdateyear = gmdate("Y", $announcement['startdate']);
|
||||
|
||||
$mybb->input['title'] = $announcement['subject'];
|
||||
$mybb->input['message'] = $announcement['message'];
|
||||
$mybb->input['allowhtml'] = $mybb->settings['announcementshtml'] && $announcement['allowhtml'];
|
||||
$mybb->input['allowsmilies'] = $announcement['allowsmilies'];
|
||||
$mybb->input['allowmycode'] = $announcement['allowmycode'];
|
||||
$mybb->input['fid'] = $announcement['fid'];
|
||||
|
||||
if($announcement['enddate'])
|
||||
{
|
||||
$endtime_checked[1] = "checked=\"checked\"";
|
||||
$endtime_checked[2] = "";
|
||||
|
||||
$mybb->input['endtime_time'] = gmdate( $mybb->settings['timeformat'],$announcement['enddate']);
|
||||
|
||||
$endday = gmdate("j", $announcement['enddate']);
|
||||
|
||||
$endmonth = gmdate("m", $announcement['enddate']);
|
||||
$endmonthsel[$endmonth] = "selected";
|
||||
|
||||
$enddateyear = gmdate("Y", $announcement['enddate']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$endtime_checked[1] = "";
|
||||
$endtime_checked[2] = "checked=\"checked\"";
|
||||
|
||||
$mybb->input['endtime_time'] = $mybb->input['starttime_time'];
|
||||
$endday = $startday;
|
||||
$endmonth = $startmonth;
|
||||
$enddateyear = $startdateyear+1;
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 1; $i <= 31; ++$i)
|
||||
{
|
||||
if($startday == $i)
|
||||
{
|
||||
$startdateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$startdateday .= "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
|
||||
if($endday == $i)
|
||||
{
|
||||
$enddateday .= "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$enddateday .= "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$startdatemonth .= "<option value=\"01\" {$startmonthsel['01']}>{$lang->january}</option>\n";
|
||||
$enddatemonth .= "<option value=\"01\" {$endmonthsel['01']}>{$lang->january}</option>\n";
|
||||
$startdatemonth .= "<option value=\"02\" {$startmonthsel['02']}>{$lang->february}</option>\n";
|
||||
$enddatemonth .= "<option value=\"02\" {$endmonthsel['02']}>{$lang->february}</option>\n";
|
||||
$startdatemonth .= "<option value=\"03\" {$startmonthsel['03']}>{$lang->march}</option>\n";
|
||||
$enddatemonth .= "<option value=\"03\" {$endmonthsel['03']}>{$lang->march}</option>\n";
|
||||
$startdatemonth .= "<option value=\"04\" {$startmonthsel['04']}>{$lang->april}</option>\n";
|
||||
$enddatemonth .= "<option value=\"04\" {$endmonthsel['04']}>{$lang->april}</option>\n";
|
||||
$startdatemonth .= "<option value=\"05\" {$startmonthsel['05']}>{$lang->may}</option>\n";
|
||||
$enddatemonth .= "<option value=\"05\" {$endmonthsel['05']}>{$lang->may}</option>\n";
|
||||
$startdatemonth .= "<option value=\"06\" {$startmonthsel['06']}>{$lang->june}</option>\n";
|
||||
$enddatemonth .= "<option value=\"06\" {$endmonthsel['06']}>{$lang->june}</option>\n";
|
||||
$startdatemonth .= "<option value=\"07\" {$startmonthsel['07']}>{$lang->july}</option>\n";
|
||||
$enddatemonth .= "<option value=\"07\" {$endmonthsel['07']}>{$lang->july}</option>\n";
|
||||
$startdatemonth .= "<option value=\"08\" {$startmonthsel['08']}>{$lang->august}</option>\n";
|
||||
$enddatemonth .= "<option value=\"08\" {$endmonthsel['08']}>{$lang->august}</option>\n";
|
||||
$startdatemonth .= "<option value=\"09\" {$startmonthsel['09']}>{$lang->september}</option>\n";
|
||||
$enddatemonth .= "<option value=\"09\" {$endmonthsel['09']}>{$lang->september}</option>\n";
|
||||
$startdatemonth .= "<option value=\"10\" {$startmonthsel['10']}>{$lang->october}</option>\n";
|
||||
$enddatemonth .= "<option value=\"10\" {$endmonthsel['10']}>{$lang->october}</option>\n";
|
||||
$startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n";
|
||||
$enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n";
|
||||
$startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n";
|
||||
$enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n";
|
||||
|
||||
if(isset($preview))
|
||||
{
|
||||
$form_container = new FormContainer($lang->announcement_preview);
|
||||
$form_container->output_row($preview['subject'], "", $preview['message'], 'preview');
|
||||
$form_container->end();
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_an_announcement);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->start_date." <em>*</em>", $lang->start_date_desc, "<select name=\"starttime_day\">\n{$startdateday}</select>\n \n<select name=\"starttime_month\">\n{$startdatemonth}</select>\n \n<input type=\"text\" name=\"starttime_year\" value=\"{$startdateyear}\" size=\"4\" maxlength=\"4\" class=\"text_input\" />\n - {$lang->time} ".$form->generate_text_box('starttime_time', $mybb->input['starttime_time'], array('id' => 'starttime_time', 'style' => 'width: 50px;')));
|
||||
|
||||
$actions = "<script type=\"text/javascript\">
|
||||
function checkAction(id)
|
||||
{
|
||||
var checked = '';
|
||||
|
||||
$('.'+id+'s_check').each(function(e, val)
|
||||
{
|
||||
if($(this).prop('checked') == true)
|
||||
{
|
||||
checked = $(this).val();
|
||||
}
|
||||
});
|
||||
$('.'+id+'s').each(function(e)
|
||||
{
|
||||
$(this).hide();
|
||||
});
|
||||
if($('#'+id+'_'+checked))
|
||||
{
|
||||
$('#'+id+'_'+checked).show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"1\" {$endtime_checked[1]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->set_time}</strong></label></dt>
|
||||
<dd style=\"margin-top: 4px;\" id=\"endtime_1\" class=\"endtimes\">
|
||||
<table cellpadding=\"4\">
|
||||
<tr>
|
||||
<td><select name=\"endtime_day\">\n{$enddateday}</select>\n \n<select name=\"endtime_month\">\n{$enddatemonth}</select>\n \n<input type=\"text\" name=\"endtime_year\" value=\"{$enddateyear}\" size=\"4\" maxlength=\"4\" />\n - {$lang->time} ".$form->generate_text_box('endtime_time', $mybb->input['endtime_time'], array('id' => 'endtime_time', 'style' => 'width: 50px;'))."</td>
|
||||
</tr>
|
||||
</table>
|
||||
</dd>
|
||||
<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"2\" {$endtime_checked[2]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->never}</strong></label></dt>
|
||||
</dl>
|
||||
<script type=\"text/javascript\">
|
||||
checkAction('endtime');
|
||||
</script>";
|
||||
$form_container->output_row($lang->end_date." <em>*</em>", $lang->end_date_desc, $actions);
|
||||
|
||||
$form_container->output_row($lang->message." <em>*</em>", "", $form->generate_text_area('message', $mybb->input['message'], array('id' => 'message')), 'message');
|
||||
|
||||
$form_container->output_row($lang->forums_to_appear_in." <em>*</em>", $lang->forums_to_appear_in_desc, $form->generate_forum_select('fid', $mybb->input['fid'], array('size' => 5, 'main_option' => $lang->all_forums)));
|
||||
|
||||
if ($mybb->settings['announcementshtml'])
|
||||
{
|
||||
$form_container->output_row($lang->allow_html." <em>*</em>", "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml'], array('style' => 'width: 2em;')));
|
||||
}
|
||||
|
||||
$form_container->output_row($lang->allow_mycode." <em>*</em>", "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode'], array('style' => 'width: 2em;')));
|
||||
|
||||
$form_container->output_row($lang->allow_smilies." <em>*</em>", "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies'], array('style' => 'width: 2em;')));
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_announcement);
|
||||
$buttons[] = $form->generate_submit_button($lang->preview_announcement, array('name' => 'preview'));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("announcements", "*", "aid='{$mybb->input['aid']}'");
|
||||
$announcement = $db->fetch_array($query);
|
||||
|
||||
// Does the announcement not exist?
|
||||
if(!$announcement['aid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_announcement, 'error');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("announcements", "aid='{$announcement['aid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_forum_announcements_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($announcement['aid'], $announcement['subject']);
|
||||
$cache->update_forumsdisplay();
|
||||
|
||||
flash_message($lang->success_announcement_deleted, 'success');
|
||||
admin_redirect("index.php?module=forum-announcements");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=forum-announcements&action=delete&aid={$announcement['aid']}", $lang->confirm_announcement_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_announcements_start");
|
||||
|
||||
$page->output_header($lang->forum_announcements);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "forum_announcements");
|
||||
|
||||
// Fetch announcements into their proper arrays
|
||||
$global_announcements = $announcements = array();
|
||||
$query = $db->simple_select("announcements", "aid, fid, subject, enddate");
|
||||
while($announcement = $db->fetch_array($query))
|
||||
{
|
||||
if($announcement['fid'] == -1)
|
||||
{
|
||||
$global_announcements[$announcement['aid']] = $announcement;
|
||||
continue;
|
||||
}
|
||||
$announcements[$announcement['fid']][$announcement['aid']] = $announcement;
|
||||
}
|
||||
|
||||
if(!empty($global_announcements))
|
||||
{
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->announcement);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 150));
|
||||
|
||||
// Get the global announcements
|
||||
foreach($global_announcements as $aid => $announcement)
|
||||
{
|
||||
if($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"(Expired)\" title=\"Expired Announcement\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"(Active)\" title=\"Active Announcement\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
$table->construct_cell($icon."<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">".htmlspecialchars_uni($announcement['subject'])."</a>");
|
||||
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">{$lang->edit}</a>", array("class" => "align_center", "width" => 75));
|
||||
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=delete&aid={$aid}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_announcement_deletion}')\">{$lang->delete}</a>", array("class" => "align_center", "width" => 75));
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output($lang->global_announcements);
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->announcement);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
|
||||
|
||||
fetch_forum_announcements($table);
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_forums, array("colspan" => "3"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->forum_announcements);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DefaultTable $table
|
||||
* @param int $pid
|
||||
* @param int $depth
|
||||
*/
|
||||
function fetch_forum_announcements(&$table, $pid=0, $depth=1)
|
||||
{
|
||||
global $mybb, $db, $lang, $announcements, $page;
|
||||
static $forums_by_parent;
|
||||
|
||||
if(!is_array($forums_by_parent))
|
||||
{
|
||||
$forum_cache = cache_forums();
|
||||
|
||||
foreach($forum_cache as $forum)
|
||||
{
|
||||
$forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_array($forums_by_parent[$pid]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($forums_by_parent[$pid] as $children)
|
||||
{
|
||||
foreach($children as $forum)
|
||||
{
|
||||
$forum['name'] = htmlspecialchars_uni($forum['name']);
|
||||
if($forum['active'] == 0)
|
||||
{
|
||||
$forum['name'] = "<em>".$forum['name']."</em>";
|
||||
}
|
||||
|
||||
if($forum['type'] == "c")
|
||||
{
|
||||
$forum['name'] = "<strong>".$forum['name']."</strong>";
|
||||
}
|
||||
|
||||
$table->construct_cell("<div style=\"padding-left: ".(40*($depth-1))."px;\">{$forum['name']}</div>");
|
||||
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=add&fid={$forum['fid']}\">{$lang->add_announcement}</a>", array("class" => "align_center", "colspan" => 2));
|
||||
$table->construct_row();
|
||||
|
||||
if(isset($announcements[$forum['fid']]))
|
||||
{
|
||||
foreach($announcements[$forum['fid']] as $aid => $announcement)
|
||||
{
|
||||
if($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"(Expired)\" title=\"Expired Announcement\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"(Active)\" title=\"Active Announcement\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
$table->construct_cell("<div style=\"padding-left: ".(40*$depth)."px;\">{$icon}<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">".htmlspecialchars_uni($announcement['subject'])."</a></div>");
|
||||
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">{$lang->edit}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=delete&aid={$aid}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_announcement_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
// Build the list for any sub forums of this forum
|
||||
if(isset($forums_by_parent[$forum['fid']]))
|
||||
{
|
||||
fetch_forum_announcements($table, $forum['fid'], $depth+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1014
webroot/forum/admin/modules/forum/attachments.php
Normal file
1014
webroot/forum/admin/modules/forum/attachments.php
Normal file
File diff suppressed because it is too large
Load Diff
8
webroot/forum/admin/modules/forum/index.html
Normal file
8
webroot/forum/admin/modules/forum/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
2933
webroot/forum/admin/modules/forum/management.php
Normal file
2933
webroot/forum/admin/modules/forum/management.php
Normal file
File diff suppressed because it is too large
Load Diff
582
webroot/forum/admin/modules/forum/moderation_queue.php
Normal file
582
webroot/forum/admin/modules/forum/moderation_queue.php
Normal file
@@ -0,0 +1,582 @@
|
||||
<?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->moderation_queue, "index.php?module=forum-moderation_queue");
|
||||
|
||||
$sub_tabs['threads'] = array(
|
||||
'title' => $lang->threads,
|
||||
'link' => "index.php?module=forum-moderation_queue&type=threads",
|
||||
'description' => $lang->threads_desc
|
||||
);
|
||||
|
||||
$sub_tabs['posts'] = array(
|
||||
'title' => $lang->posts,
|
||||
'link' => "index.php?module=forum-moderation_queue&type=posts",
|
||||
'description' => $lang->posts_desc
|
||||
);
|
||||
|
||||
$sub_tabs['attachments'] = array(
|
||||
'title' => $lang->attachments,
|
||||
'link' => "index.php?module=forum-moderation_queue&type=attachments",
|
||||
'description' => $lang->attachments_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_begin");
|
||||
|
||||
// Actually performing our moderation choices
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_commit");
|
||||
|
||||
require_once MYBB_ROOT."inc/functions_upload.php";
|
||||
require_once MYBB_ROOT."inc/class_moderation.php";
|
||||
$moderation = new Moderation;
|
||||
|
||||
if(is_array($mybb->input['threads']))
|
||||
{
|
||||
$threads_to_approve = $threads_to_delete = array();
|
||||
// Fetch threads
|
||||
$query = $db->simple_select("threads", "tid", "tid IN (".implode(",", array_map("intval", array_keys($mybb->input['threads'])))."){$flist}");
|
||||
while($thread = $db->fetch_array($query))
|
||||
{
|
||||
$action = $mybb->input['threads'][$thread['tid']];
|
||||
if($action == "approve")
|
||||
{
|
||||
$threads_to_approve[] = $thread['tid'];
|
||||
}
|
||||
else if($action == "delete" && $mybb->settings['soft_delete'] != 1)
|
||||
{
|
||||
$moderation->delete_thread($thread['tid']);
|
||||
}
|
||||
else if($action == "delete")
|
||||
{
|
||||
$threads_to_delete[] = $thread['tid'];
|
||||
}
|
||||
}
|
||||
if(!empty($threads_to_approve))
|
||||
{
|
||||
$moderation->approve_threads($threads_to_approve);
|
||||
}
|
||||
if(!empty($threads_to_delete))
|
||||
{
|
||||
$moderation->soft_delete_threads($threads_to_delete);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_threads_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action('threads');
|
||||
|
||||
flash_message($lang->success_threads, 'success');
|
||||
admin_redirect("index.php?module=forum-moderation_queue&type=threads");
|
||||
}
|
||||
else if(is_array($mybb->input['posts']))
|
||||
{
|
||||
$posts_to_approve = $posts_to_delete = array();
|
||||
// Fetch posts
|
||||
$query = $db->simple_select("posts", "pid", "pid IN (".implode(",", array_map("intval", array_keys($mybb->input['posts'])))."){$flist}");
|
||||
while($post = $db->fetch_array($query))
|
||||
{
|
||||
$action = $mybb->input['posts'][$post['pid']];
|
||||
if($action == "approve")
|
||||
{
|
||||
$posts_to_approve[] = $post['pid'];
|
||||
}
|
||||
else if($action == "delete" && $mybb->settings['soft_delete'] != 1)
|
||||
{
|
||||
$moderation->delete_post($post['pid']);
|
||||
}
|
||||
else if($action == "delete")
|
||||
{
|
||||
$posts_to_delete[] = $post['pid'];
|
||||
}
|
||||
}
|
||||
if(!empty($posts_to_approve))
|
||||
{
|
||||
$moderation->approve_posts($posts_to_approve);
|
||||
}
|
||||
if(!empty($posts_to_delete))
|
||||
{
|
||||
$moderation->soft_delete_posts($posts_to_delete);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_posts_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action('posts');
|
||||
|
||||
flash_message($lang->success_posts, 'success');
|
||||
admin_redirect("index.php?module=forum-moderation_queue&type=posts");
|
||||
|
||||
}
|
||||
else if(is_array($mybb->input['attachments']))
|
||||
{
|
||||
$query = $db->simple_select("attachments", "aid, pid", "aid IN (".implode(",", array_map("intval", array_keys($mybb->input['attachments'])))."){$flist}");
|
||||
while($attachment = $db->fetch_array($query))
|
||||
{
|
||||
$action = $mybb->input['attachments'][$attachment['aid']];
|
||||
if($action == "approve")
|
||||
{
|
||||
$db->update_query("attachments", array("visible" => 1), "aid='{$attachment['aid']}'");
|
||||
}
|
||||
else if($action == "delete")
|
||||
{
|
||||
remove_attachment($attachment['pid'], '', $attachment['aid']);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_attachments_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action('attachments');
|
||||
|
||||
flash_message($lang->success_attachments, 'success');
|
||||
admin_redirect("index.php?module=forum-moderation_queue&type=attachments");
|
||||
}
|
||||
}
|
||||
|
||||
$all_options = "<ul class=\"modqueue_mass\">\n";
|
||||
$all_options .= "<li><a href=\"#\" class=\"mass_ignore\">{$lang->mark_as_ignored}</a></li>\n";
|
||||
$all_options .= "<li><a href=\"#\" class=\"mass_delete\">{$lang->mark_as_deleted}</a></li>\n";
|
||||
$all_options .= "<li><a href=\"#\" class=\"mass_approve\">{$lang->mark_as_approved}</a></li>\n";
|
||||
$all_options .= "</ul>\n";
|
||||
|
||||
// Threads awaiting moderation
|
||||
if($mybb->input['type'] == "threads" || !$mybb->input['type'])
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_threads");
|
||||
|
||||
$forum_cache = $cache->read("forums");
|
||||
|
||||
$query = $db->simple_select("threads", "COUNT(tid) AS unapprovedthreads", "visible=0");
|
||||
$unapproved_threads = $db->fetch_field($query, "unapprovedthreads");
|
||||
|
||||
if($unapproved_threads > 0)
|
||||
{
|
||||
// Figure out if we need to display multiple pages.
|
||||
$per_page = 15;
|
||||
if($mybb->input['page'] > 0)
|
||||
{
|
||||
$current_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($current_page-1)*$per_page;
|
||||
$pages = $unapproved_threads / $per_page;
|
||||
$pages = ceil($pages);
|
||||
if($current_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
|
||||
$pagination = draw_admin_pagination($current_page, $per_page, $unapproved_threads, "index.php?module=forum-moderation_queue&page={page}");
|
||||
|
||||
$page->add_breadcrumb_item($lang->threads_awaiting_moderation);
|
||||
$page->output_header($lang->threads_awaiting_moderation);
|
||||
$page->output_nav_tabs($sub_tabs, "threads");
|
||||
|
||||
$form = new Form("index.php?module=forum-moderation_queue", "post");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->subject);
|
||||
$table->construct_header($lang->author, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%"));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT t.tid, t.dateline, t.fid, t.subject, t.username AS threadusername, p.message AS postmessage, u.username AS username, t.uid
|
||||
FROM ".TABLE_PREFIX."threads t
|
||||
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=t.firstpost)
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
|
||||
WHERE t.visible='0'
|
||||
ORDER BY t.lastpost DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
while($thread = $db->fetch_array($query))
|
||||
{
|
||||
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
|
||||
$thread['threadlink'] = get_thread_link($thread['tid']);
|
||||
$thread['forumlink'] = get_forum_link($thread['fid']);
|
||||
$forum_name = $forum_cache[$thread['fid']]['name'];
|
||||
$threaddate = my_date('relative', $thread['dateline']);
|
||||
|
||||
if(!$thread['uid'])
|
||||
{
|
||||
if($thread['threadusername'] != "")
|
||||
{
|
||||
$profile_link = $thread['threadusername'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = htmlspecialchars_uni($lang->guest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = build_profile_link(htmlspecialchars_uni($thread['username']), $thread['uid'], "_blank");
|
||||
}
|
||||
|
||||
$thread['postmessage'] = nl2br(htmlspecialchars_uni($thread['postmessage']));
|
||||
|
||||
$table->construct_cell("<a href=\"../{$thread['threadlink']}\" target=\"_blank\">{$thread['subject']}</a>");
|
||||
$table->construct_cell($profile_link, array("class" => "align_center"));
|
||||
$table->construct_cell($threaddate, array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
|
||||
$controls = "<div class=\"modqueue_controls\">\n";
|
||||
$controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true))." ";
|
||||
$controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false))." ";
|
||||
$controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false));
|
||||
$controls .= "</div>";
|
||||
|
||||
$forum = "<strong>{$lang->forum} <a href=\"../{$thread['forumlink']}\" target=\"_blank\">{$forum_name}</a></strong><br />";
|
||||
|
||||
$table->construct_cell("<div class=\"modqueue_message\">{$controls}<div class=\"modqueue_meta\">{$forum}</div>{$thread['postmessage']}</div>", array("colspan" => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->threads_awaiting_moderation);
|
||||
echo $all_options;
|
||||
echo $pagination;
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->perform_action);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<script type="text/javascript">
|
||||
$(".mass_ignore").on("click", function () {
|
||||
$("input.radio_ignore").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_delete").on("click", function () {
|
||||
$("input.radio_delete").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_approve").on("click", function () {
|
||||
$("input.radio_approve").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
}
|
||||
|
||||
// Posts awaiting moderation
|
||||
if($mybb->input['type'] == "posts" || $mybb->input['type'] == "")
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_posts");
|
||||
|
||||
$forum_cache = $cache->read("forums");
|
||||
|
||||
$query = $db->query("
|
||||
SELECT COUNT(pid) AS unapprovedposts
|
||||
FROM ".TABLE_PREFIX."posts p
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
||||
WHERE p.visible='0' AND t.firstpost != p.pid
|
||||
");
|
||||
$unapproved_posts = $db->fetch_field($query, "unapprovedposts");
|
||||
|
||||
if($unapproved_posts > 0)
|
||||
{
|
||||
// Figure out if we need to display multiple pages.
|
||||
$per_page = 15;
|
||||
if($mybb->input['page'] > 0)
|
||||
{
|
||||
$current_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($current_page-1)*$per_page;
|
||||
$pages = $unapproved_posts / $per_page;
|
||||
$pages = ceil($pages);
|
||||
if($current_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
|
||||
$pagination = draw_admin_pagination($current_page, $per_page, $unapproved_posts, "index.php?module=forum-moderation_queue&type=posts&page={page}");
|
||||
|
||||
|
||||
$page->add_breadcrumb_item($lang->posts_awaiting_moderation);
|
||||
$page->output_header($lang->posts_awaiting_moderation);
|
||||
$page->output_nav_tabs($sub_tabs, "posts");
|
||||
|
||||
$form = new Form("index.php?module=forum-moderation_queue", "post");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->subject);
|
||||
$table->construct_header($lang->author, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%"));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT p.pid, p.subject, p.message, p.dateline, p.username AS postusername, t.subject AS threadsubject, t.tid, u.username, p.uid, t.fid
|
||||
FROM ".TABLE_PREFIX."posts p
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
||||
WHERE p.visible='0' AND t.firstpost != p.pid
|
||||
ORDER BY p.dateline DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
while($post = $db->fetch_array($query))
|
||||
{
|
||||
$altbg = alt_trow();
|
||||
$post['threadsubject'] = htmlspecialchars_uni($post['threadsubject']);
|
||||
$post['subject'] = htmlspecialchars_uni($post['subject']);
|
||||
|
||||
if(!$post['subject'])
|
||||
{
|
||||
$post['subject'] = $lang->re." ".$post['threadsubject'];
|
||||
}
|
||||
|
||||
$post['postlink'] = get_post_link($post['pid'], $post['tid']);
|
||||
$post['threadlink'] = get_thread_link($post['tid']);
|
||||
$post['forumlink'] = get_forum_link($post['fid']);
|
||||
$forum_name = $forum_cache[$post['fid']]['name'];
|
||||
$postdate = my_date('relative', $post['dateline']);
|
||||
|
||||
if(!$post['uid'])
|
||||
{
|
||||
if($post['postusername'] != "")
|
||||
{
|
||||
$profile_link = $post['postusername'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = $lang->guest;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = build_profile_link(htmlspecialchars_uni($post['username']), $post['uid'], "_blank");
|
||||
}
|
||||
|
||||
$post['message'] = nl2br(htmlspecialchars_uni($post['message']));
|
||||
|
||||
$table->construct_cell("<a href=\"../{$post['postlink']}#pid{$post['pid']}\" target=\"_blank\">{$post['subject']}</a>");
|
||||
$table->construct_cell($profile_link, array("class" => "align_center"));
|
||||
$table->construct_cell($postdate, array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
|
||||
$controls = "<div class=\"modqueue_controls\">\n";
|
||||
$controls .= $form->generate_radio_button("posts[{$post['pid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true))." ";
|
||||
$controls .= $form->generate_radio_button("posts[{$post['pid']}]", "delete",$lang->delete, array('class' => 'radio_delete', 'checked' => false))." ";
|
||||
$controls .= $form->generate_radio_button("posts[{$post['pid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false));
|
||||
$controls .= "</div>";
|
||||
|
||||
$thread = "<strong>{$lang->thread} <a href=\"../{$post['threadlink']}\" target=\"_blank\">{$post['threadsubject']}</a></strong>";
|
||||
$forum = "<strong>{$lang->forum} <a href=\"../{$post['forumlink']}\" target=\"_blank\">{$forum_name}</a></strong><br />";
|
||||
|
||||
$table->construct_cell("<div class=\"modqueue_message\">{$controls}<div class=\"modqueue_meta\">{$forum}{$thread}</div>{$post['message']}</div>", array("colspan" => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->posts_awaiting_moderation);
|
||||
echo $all_options;
|
||||
echo $pagination;
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->perform_action);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<script type="text/javascript">
|
||||
$(".mass_ignore").on("click", function () {
|
||||
$("input.radio_ignore").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_delete").on("click", function () {
|
||||
$("input.radio_delete").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_approve").on("click", function () {
|
||||
$("input.radio_approve").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
else if($mybb->input['type'] == "posts")
|
||||
{
|
||||
$page->output_header($lang->moderation_queue);
|
||||
$page->output_nav_tabs($sub_tabs, "posts");
|
||||
echo "<p class=\"notice\">{$lang->error_no_posts}</p>";
|
||||
$page->output_footer();
|
||||
}
|
||||
}
|
||||
|
||||
// Attachments awaiting moderation
|
||||
if($mybb->input['type'] == "attachments" || $mybb->input['type'] == "")
|
||||
{
|
||||
$plugins->run_hooks("admin_forum_moderation_queue_attachments");
|
||||
|
||||
$query = $db->query("
|
||||
SELECT COUNT(aid) AS unapprovedattachments
|
||||
FROM ".TABLE_PREFIX."attachments a
|
||||
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
||||
WHERE a.visible='0'
|
||||
");
|
||||
$unapproved_attachments = $db->fetch_field($query, "unapprovedattachments");
|
||||
|
||||
if($unapproved_attachments > 0)
|
||||
{
|
||||
// Figure out if we need to display multiple pages.
|
||||
$per_page = 15;
|
||||
if($mybb->input['page'] > 0)
|
||||
{
|
||||
$current_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($current_page-1)*$per_page;
|
||||
$pages = $unapproved_attachments / $per_page;
|
||||
$pages = ceil($pages);
|
||||
if($current_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
|
||||
$pagination = draw_admin_pagination($current_page, $per_page, $unapproved_attachments, "index.php?module=forum-moderation_queue&type=attachments&page={page}");
|
||||
|
||||
$page->add_breadcrumb_item($lang->attachments_awaiting_moderation);
|
||||
$page->output_header($lang->attachments_awaiting_moderation);
|
||||
$page->output_nav_tabs($sub_tabs, "attachments");
|
||||
|
||||
$form = new Form("index.php?module=forum-moderation_queue", "post");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->filename);
|
||||
$table->construct_header($lang->uploadedby, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT a.*, p.subject AS postsubject, p.dateline, p.username AS postusername, p.uid, u.username, t.tid, t.subject AS threadsubject
|
||||
FROM ".TABLE_PREFIX."attachments a
|
||||
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
|
||||
WHERE a.visible='0'
|
||||
ORDER BY a.dateuploaded DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
|
||||
while($attachment = $db->fetch_array($query))
|
||||
{
|
||||
if(!$attachment['dateuploaded']) $attachment['dateuploaded'] = $attachment['dateline'];
|
||||
$attachdate = my_date('relative', $attachment['dateuploaded']);
|
||||
|
||||
$attachment['postsubject'] = htmlspecialchars_uni($attachment['postsubject']);
|
||||
$attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
|
||||
$attachment['threadsubject'] = htmlspecialchars_uni($attachment['threadsubject']);
|
||||
$attachment['filesize'] = get_friendly_size($attachment['filesize']);
|
||||
|
||||
$link = get_post_link($attachment['pid'], $attachment['tid']) . "#pid{$attachment['pid']}";
|
||||
$thread_link = get_thread_link($attachment['tid']);
|
||||
|
||||
if(!$attachment['uid'])
|
||||
{
|
||||
if($attachment['postusername'] != "")
|
||||
{
|
||||
$profile_link = $attachment['postusername'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = htmlspecialchars_uni($lang->guest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$profile_link = build_profile_link(htmlspecialchars_uni($attachment['username']), $attachment['uid'], "_blank");
|
||||
}
|
||||
|
||||
$table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a> ({$attachment['filesize']})<br /><small class=\"modqueue_meta\">{$lang->post} <a href=\"{$link}\" target=\"_blank\">{$attachment['postsubject']}</a></small>");
|
||||
$table->construct_cell($profile_link, array("class" => "align_center"));
|
||||
$table->construct_cell($attachdate, array("class" => "align_center"));
|
||||
|
||||
$table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true)), array("class" => "align_center"));
|
||||
$table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false)), array("class" => "align_center"));
|
||||
$table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output($lang->attachments_awaiting_moderation);
|
||||
echo $all_options;
|
||||
echo $pagination;
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->perform_action);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<script type="text/javascript">
|
||||
$(".mass_ignore").on("click", function () {
|
||||
$("input.radio_ignore").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_delete").on("click", function () {
|
||||
$("input.radio_delete").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(".mass_approve").on("click", function () {
|
||||
$("input.radio_approve").each(function(e) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
</script>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
else if($mybb->input['type'] == "attachments")
|
||||
{
|
||||
$page->output_header($lang->moderation_queue);
|
||||
$page->output_nav_tabs($sub_tabs, "attachments");
|
||||
echo "<p class=\"notice\">{$lang->error_no_attachments}</p>";
|
||||
$page->output_footer();
|
||||
}
|
||||
}
|
||||
|
||||
// Still nothing? All queues are empty! :-D
|
||||
$page->output_header($lang->moderation_queue);
|
||||
echo "<p class=\"notice\">{$lang->error_no_threads}</p>";
|
||||
$page->output_footer();
|
||||
87
webroot/forum/admin/modules/forum/module_meta.php
Normal file
87
webroot/forum/admin/modules/forum/module_meta.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function forum_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "management", "title" => $lang->forum_management, "link" => "index.php?module=forum-management");
|
||||
$sub_menu['20'] = array("id" => "announcements", "title" => $lang->forum_announcements, "link" => "index.php?module=forum-announcements");
|
||||
$sub_menu['30'] = array("id" => "moderation_queue", "title" => $lang->moderation_queue, "link" => "index.php?module=forum-moderation_queue");
|
||||
$sub_menu['40'] = array("id" => "attachments", "title" => $lang->attachments, "link" => "index.php?module=forum-attachments");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_forum_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->forums_and_posts, "forum", "index.php?module=forum", 20, $sub_menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function forum_action_handler($action)
|
||||
{
|
||||
global $page, $plugins;
|
||||
|
||||
$page->active_module = "forum";
|
||||
|
||||
$actions = array(
|
||||
'moderation_queue' => array('active' => 'moderation_queue', 'file' => 'moderation_queue.php'),
|
||||
'announcements' => array('active' => 'announcements', 'file' => 'announcements.php'),
|
||||
'attachments' => array('active' => 'attachments', 'file' => 'attachments.php'),
|
||||
'management' => array('active' => 'management', 'file' => 'management.php')
|
||||
);
|
||||
|
||||
$actions = $plugins->run_hooks("admin_forum_action_handler", $actions);
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = "management";
|
||||
return "management.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function forum_admin_permissions()
|
||||
{
|
||||
global $lang, $plugins;
|
||||
|
||||
$admin_permissions = array(
|
||||
"management" => $lang->can_manage_forums,
|
||||
"announcements" => $lang->can_manage_forum_announcements,
|
||||
"moderation_queue" => $lang->can_moderate,
|
||||
"attachments" => $lang->can_manage_attachments,
|
||||
);
|
||||
|
||||
$admin_permissions = $plugins->run_hooks("admin_forum_permissions", $admin_permissions);
|
||||
|
||||
return array("name" => $lang->forums_and_posts, "permissions" => $admin_permissions, "disporder" => 20);
|
||||
}
|
||||
|
||||
8
webroot/forum/admin/modules/home/index.html
Normal file
8
webroot/forum/admin/modules/home/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
377
webroot/forum/admin/modules/home/index.php
Normal file
377
webroot/forum/admin/modules/home/index.php
Normal file
@@ -0,0 +1,377 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_home_index_begin");
|
||||
|
||||
$sub_tabs['dashboard'] = array(
|
||||
'title' => $lang->dashboard,
|
||||
'link' => "index.php",
|
||||
'description' => $lang->dashboard_description
|
||||
);
|
||||
|
||||
$sub_tabs['version_check'] = array(
|
||||
'title' => $lang->version_check,
|
||||
'link' => "index.php?module=home&action=version_check",
|
||||
'description' => $lang->version_check_description
|
||||
);
|
||||
|
||||
if($mybb->input['action'] == "version_check")
|
||||
{
|
||||
$plugins->run_hooks("admin_home_version_check_start");
|
||||
|
||||
$current_version = rawurlencode($mybb->version_code);
|
||||
|
||||
$updated_cache = array(
|
||||
"last_check" => TIME_NOW
|
||||
);
|
||||
|
||||
require_once MYBB_ROOT."inc/class_xml.php";
|
||||
$contents = fetch_remote_file("https://mybb.com/version_check.php");
|
||||
|
||||
if(!$contents)
|
||||
{
|
||||
flash_message($lang->error_communication, 'error');
|
||||
admin_redirect('index.php');
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_home_version_check");
|
||||
|
||||
$page->add_breadcrumb_item($lang->version_check, "index.php?module=home-version_check");
|
||||
$page->output_header($lang->version_check);
|
||||
$page->output_nav_tabs($sub_tabs, 'version_check');
|
||||
|
||||
$contents = trim($contents);
|
||||
|
||||
$parser = new XMLParser($contents);
|
||||
$tree = $parser->get_tree();
|
||||
|
||||
$latest_code = (int)$tree['mybb']['version_code']['value'];
|
||||
$latest_version = "<strong>".htmlspecialchars_uni($tree['mybb']['latest_version']['value'])."</strong> (".$latest_code.")";
|
||||
if($latest_code > $mybb->version_code)
|
||||
{
|
||||
$latest_version = "<span style=\"color: #C00;\">".$latest_version."</span>";
|
||||
$version_warn = 1;
|
||||
$updated_cache['latest_version'] = $latest_version;
|
||||
$updated_cache['latest_version_code'] = $latest_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$latest_version = "<span style=\"color: green;\">".$latest_version."</span>";
|
||||
}
|
||||
|
||||
if($version_warn)
|
||||
{
|
||||
$page->output_error("<p><em>{$lang->error_out_of_date}</em> {$lang->update_forum}</p>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_success("<p><em>{$lang->success_up_to_date}</em></p>");
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->your_version);
|
||||
$table->construct_header($lang->latest_version);
|
||||
|
||||
$table->construct_cell("<strong>".$mybb->version."</strong> (".$mybb->version_code.")");
|
||||
$table->construct_cell($latest_version);
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->version_check);
|
||||
|
||||
require_once MYBB_ROOT."inc/class_feedparser.php";
|
||||
|
||||
$feed_parser = new FeedParser();
|
||||
$feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
|
||||
|
||||
$updated_cache['news'] = array();
|
||||
|
||||
if($feed_parser->error == '')
|
||||
{
|
||||
require_once MYBB_ROOT . '/inc/class_parser.php';
|
||||
$post_parser = new postParser();
|
||||
|
||||
foreach($feed_parser->items as $item)
|
||||
{
|
||||
$description = $item['description'];
|
||||
$content = $item['content'];
|
||||
|
||||
$description = $post_parser->parse_message($description, array(
|
||||
'allow_html' => true,
|
||||
)
|
||||
);
|
||||
|
||||
$content = $post_parser->parse_message($content, array(
|
||||
'allow_html' => true,
|
||||
)
|
||||
);
|
||||
|
||||
$description = preg_replace('#<img(.*)/>#', '', $description);
|
||||
$content = preg_replace('#<img(.*)/>#', '', $content);
|
||||
|
||||
if(!isset($updated_cache['news'][2]))
|
||||
{
|
||||
$updated_cache['news'][] = array(
|
||||
'title' => htmlspecialchars_uni($item['title']),
|
||||
'description' => $description,
|
||||
'link' => htmlspecialchars_uni($item['link']),
|
||||
'author' => htmlspecialchars_uni($item['author']),
|
||||
'dateline' => $item['date_timestamp'],
|
||||
);
|
||||
}
|
||||
|
||||
$stamp = '';
|
||||
if($item['date_timestamp'])
|
||||
{
|
||||
$stamp = my_date('relative', $item['date_timestamp']);
|
||||
}
|
||||
|
||||
$link = htmlspecialchars_uni($item['link']);
|
||||
|
||||
$table->construct_cell("<span style=\"font-size: 16px;\"><strong>".htmlspecialchars_uni($item['title'])."</strong></span><br /><br />{$content}<strong><span style=\"float: right;\">{$stamp}</span><br /><br /><a href=\"{$link}\" target=\"_blank\" rel=\"noopener\">» {$lang->read_more}</a></strong>");
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("{$lang->error_fetch_news} <!-- error code: {$feed_parser->error} -->");
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$cache->update("update_check", $updated_cache);
|
||||
|
||||
$table->output($lang->latest_mybb_announcements);
|
||||
$page->output_footer();
|
||||
}
|
||||
elseif(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_home_index_start");
|
||||
|
||||
if($mybb->request_method == "post" && isset($mybb->input['adminnotes']))
|
||||
{
|
||||
// Update Admin Notes cache
|
||||
$update_cache = array(
|
||||
"adminmessage" => $mybb->input['adminnotes']
|
||||
);
|
||||
|
||||
$cache->update("adminnotes", $update_cache);
|
||||
|
||||
$plugins->run_hooks("admin_home_index_start_begin");
|
||||
|
||||
flash_message($lang->success_notes_updated, 'success');
|
||||
admin_redirect("index.php");
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->dashboard);
|
||||
$page->output_header($lang->dashboard);
|
||||
|
||||
$sub_tabs['dashboard'] = array(
|
||||
'title' => $lang->dashboard,
|
||||
'link' => "index.php",
|
||||
'description' => $lang->dashboard_description
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'dashboard');
|
||||
|
||||
// Load stats cache
|
||||
$stats = $cache->read("stats");
|
||||
|
||||
$serverload = get_server_load();
|
||||
|
||||
// Get the number of users
|
||||
$query = $db->simple_select("users", "COUNT(uid) AS numusers");
|
||||
$users = my_number_format($db->fetch_field($query, "numusers"));
|
||||
|
||||
// Get the number of users awaiting validation
|
||||
$awaitingusers = $cache->read('awaitingactivation');
|
||||
|
||||
if(!empty($awaitingusers['users']))
|
||||
{
|
||||
$awaitingusers = (int)$awaitingusers['users'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$awaitingusers = 0;
|
||||
}
|
||||
|
||||
if($awaitingusers < 1)
|
||||
{
|
||||
$awaitingusers = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$awaitingusers = my_number_format($awaitingusers);
|
||||
}
|
||||
|
||||
// Get the number of new users for today
|
||||
$timecut = TIME_NOW - 86400;
|
||||
$query = $db->simple_select("users", "COUNT(uid) AS newusers", "regdate > '$timecut'");
|
||||
$newusers = my_number_format($db->fetch_field($query, "newusers"));
|
||||
|
||||
// Get the number of active users today
|
||||
$query = $db->simple_select("users", "COUNT(uid) AS activeusers", "lastvisit > '$timecut'");
|
||||
$activeusers = my_number_format($db->fetch_field($query, "activeusers"));
|
||||
|
||||
// Get the number of threads
|
||||
$threads = my_number_format($stats['numthreads']);
|
||||
|
||||
// Get the number of unapproved threads
|
||||
$unapproved_threads = my_number_format($stats['numunapprovedthreads']);
|
||||
|
||||
// Get the number of new threads for today
|
||||
$query = $db->simple_select("threads", "COUNT(*) AS newthreads", "dateline > '$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'");
|
||||
$newthreads = my_number_format($db->fetch_field($query, "newthreads"));
|
||||
|
||||
// Get the number of posts
|
||||
$posts = my_number_format($stats['numposts']);
|
||||
|
||||
// Get the number of unapproved posts
|
||||
if($stats['numunapprovedposts'] < 0)
|
||||
{
|
||||
$stats['numunapprovedposts'] = 0;
|
||||
}
|
||||
|
||||
$unapproved_posts = my_number_format($stats['numunapprovedposts']);
|
||||
|
||||
// Get the number of new posts for today
|
||||
$query = $db->simple_select("posts", "COUNT(*) AS newposts", "dateline > '$timecut' AND visible='1'");
|
||||
$newposts = my_number_format($db->fetch_field($query, "newposts"));
|
||||
|
||||
// Get the number of reported post
|
||||
$query = $db->simple_select("reportedcontent", "COUNT(*) AS reported_posts", "type = 'post' OR type = ''");
|
||||
$reported_posts = my_number_format($db->fetch_field($query, "reported_posts"));
|
||||
|
||||
// If report medium is MCP...
|
||||
if($mybb->settings['reportmethod'] == "db")
|
||||
{
|
||||
// Get the number of reported posts that haven't been marked as read yet
|
||||
$query = $db->simple_select("reportedcontent", "COUNT(*) AS new_reported_posts", "reportstatus='0' AND (type = 'post' OR type = '')");
|
||||
$new_reported_posts = my_number_format($db->fetch_field($query, "new_reported_posts"));
|
||||
}
|
||||
|
||||
// Get the number and total file size of attachments
|
||||
$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid > '0'");
|
||||
$attachs = $db->fetch_array($query);
|
||||
$attachs['spaceused'] = get_friendly_size($attachs['spaceused']);
|
||||
$approved_attachs = my_number_format($attachs['numattachs']);
|
||||
|
||||
// Get the number of unapproved attachments
|
||||
$query = $db->simple_select("attachments", "COUNT(*) AS numattachs", "visible='0' AND pid > '0'");
|
||||
$unapproved_attachs = my_number_format($db->fetch_field($query, "numattachs"));
|
||||
|
||||
// Fetch the last time an update check was run
|
||||
$update_check = $cache->read("update_check");
|
||||
|
||||
// If last update check was greater than two weeks ago (14 days) show an alert
|
||||
if(isset($update_check['last_check']) && $update_check['last_check'] <= TIME_NOW-60*60*24*14)
|
||||
{
|
||||
$lang->last_update_check_two_weeks = $lang->sprintf($lang->last_update_check_two_weeks, "index.php?module=home&action=version_check");
|
||||
$page->output_error("<p>{$lang->last_update_check_two_weeks}</p>");
|
||||
}
|
||||
|
||||
// If the update check contains information about a newer version, show an alert
|
||||
if(isset($update_check['latest_version_code']) && $update_check['latest_version_code'] > $mybb->version_code)
|
||||
{
|
||||
$lang->new_version_available = $lang->sprintf($lang->new_version_available, "MyBB {$mybb->version}", "<a href=\"https://mybb.com/download\" target=\"_blank\" rel=\"noopener\">MyBB {$update_check['latest_version']}</a>");
|
||||
$page->output_error("<p><em>{$lang->new_version_available}</em></p>");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_home_index_output_message");
|
||||
|
||||
$adminmessage = $cache->read("adminnotes");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->mybb_server_stats, array("colspan" => 2));
|
||||
$table->construct_header($lang->forum_stats, array("colspan" => 2));
|
||||
|
||||
$table->construct_cell("<strong>{$lang->mybb_version}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell($mybb->version, array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->threads}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$threads}</strong> {$lang->threads}<br /><strong>{$newthreads}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&type=threads\"><strong>{$unapproved_threads}</strong> {$lang->unapproved}</a>", array('width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->php_version}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell(PHP_VERSION, array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->posts}</strong>", array('width' => '25%'));
|
||||
if($mybb->settings['reportmethod'] == "db")
|
||||
{
|
||||
$table->construct_cell("<strong>{$posts}</strong> {$lang->posts}<br /><strong>{$newposts}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&type=posts\"><strong>{$unapproved_posts}</strong> {$lang->unapproved}</a><br /><strong>{$reported_posts}</strong> {$lang->reported_posts}<br /><strong>{$new_reported_posts}</strong> {$lang->unread_reports}", array('width' => '25%'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong>{$posts}</strong> {$lang->posts}<br /><strong>{$newposts}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&type=posts\"><strong>{$unapproved_posts}</strong> {$lang->unapproved}</a><br /><strong>{$reported_posts}</strong> {$lang->reported_posts}", array('width' => '25%'));
|
||||
}
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->sql_engine}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell($db->short_title." ".$db->get_version(), array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->users}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-users\"><strong>{$users}</strong> {$lang->registered_users}</a><br /><strong>{$activeusers}</strong> {$lang->active_users}<br /><strong>{$newusers}</strong> {$lang->registrations_today}<br /><a href=\"index.php?module=user-awaiting_activation\"><strong>{$awaitingusers}</strong> {$lang->awaiting_activation}</a>", array('width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->server_load}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell($serverload, array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->attachments}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$approved_attachs}</strong> {$lang->attachments}<br /><a href=\"index.php?module=forum-moderation_queue&type=attachments\"><strong>{$unapproved_attachs}</strong> {$lang->unapproved}</a><br /><strong>{$attachs['spaceused']}</strong> {$lang->used}", array('width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->dashboard);
|
||||
|
||||
echo '
|
||||
<div class="float_right" style="width: 48%;">';
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->admin_notes_public);
|
||||
|
||||
$form = new Form("index.php", "post");
|
||||
$table->construct_cell($form->generate_text_area("adminnotes", $adminmessage['adminmessage'], array('style' => 'width: 99%; height: 200px;')));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->admin_notes);
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_notes);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '</div>
|
||||
<div class="float_left" style="width: 48%;">';
|
||||
|
||||
// Latest news widget
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->news_description);
|
||||
|
||||
if(!empty($update_check['news']) && is_array($update_check['news']))
|
||||
{
|
||||
foreach($update_check['news'] as $news_item)
|
||||
{
|
||||
$posted = my_date('relative', $news_item['dateline']);
|
||||
$table->construct_cell("<strong><a href=\"{$news_item['link']}\" target=\"_blank\" rel=\"noopener\">{$news_item['title']}</a></strong><br /><span class=\"smalltext\">{$posted}</span>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($news_item['description']);
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell($lang->no_announcements);
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->latest_mybb_announcements);
|
||||
echo '</div>';
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
190
webroot/forum/admin/modules/home/module_meta.php
Normal file
190
webroot/forum/admin/modules/home/module_meta.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function home_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "dashboard", "title" => $lang->dashboard, "link" => "index.php?module=home-dashboard");
|
||||
$sub_menu['20'] = array("id" => "preferences", "title" => $lang->preferences, "link" => "index.php?module=home-preferences");
|
||||
$sub_menu['30'] = array("id" => "docs", "title" => $lang->mybb_documentation, "link" => "https://docs.mybb.com");
|
||||
$sub_menu['40'] = array("id" => "credits", "title" => $lang->mybb_credits, "link" => "https://mybb.com/credits");
|
||||
$sub_menu = $plugins->run_hooks("admin_home_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->home, "home", "index.php", 1, $sub_menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function home_action_handler($action)
|
||||
{
|
||||
global $page, $db, $lang, $plugins;
|
||||
|
||||
$page->active_module = "home";
|
||||
|
||||
$actions = array(
|
||||
'preferences' => array('active' => 'preferences', 'file' => 'preferences.php'),
|
||||
'version_check' => array('active' => 'version_check', 'file' => 'version_check.php'),
|
||||
'dashboard' => array('active' => 'dashboard', 'file' => 'index.php')
|
||||
);
|
||||
|
||||
if(!isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = "dashboard";
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
}
|
||||
|
||||
$actions = $plugins->run_hooks("admin_home_action_handler", $actions);
|
||||
|
||||
if($page->active_action == "dashboard")
|
||||
{
|
||||
// Quick Access
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "add_forum", "title" => $lang->add_new_forum, "link" => "index.php?module=forum-management&action=add", "module" => "forum", "action" => "management");
|
||||
$sub_menu['20'] = array("id" => "search", "title" => $lang->search_for_users, "link" => "index.php?module=user-users&action=search", "module" => "user", "action" => "users");
|
||||
$sub_menu['30'] = array("id" => "themes", "title" => $lang->themes, "link" => "index.php?module=style-themes", "module" => "style", "action" => "themes");
|
||||
$sub_menu['40'] = array("id" => "templates", "title" => $lang->templates, "link" => "index.php?module=style-templates", "module" => "style", "action" => "templates");
|
||||
$sub_menu['50'] = array("id" => "plugins", "title" => $lang->plugins, "link" => "index.php?module=config-plugins", "module" => "config", "action" => "plugins");
|
||||
$sub_menu['60'] = array("id" => "backupdb", "title" => $lang->database_backups, "link" => "index.php?module=tools-backupdb", "module" => "tools", "action" => "backupdb");
|
||||
|
||||
foreach($sub_menu as $id => $sub)
|
||||
{
|
||||
if(!check_admin_permissions(array("module" => $sub['module'], "action" => $sub['action']), false))
|
||||
{
|
||||
unset($sub_menu[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_home_menu_quick_access", $sub_menu);
|
||||
|
||||
if(!empty($sub_menu))
|
||||
{
|
||||
$sidebar = new SidebarItem($lang->quick_access);
|
||||
$sidebar->add_menu_items($sub_menu, $page->active_action);
|
||||
$page->sidebar .= $sidebar->get_markup();
|
||||
}
|
||||
|
||||
// Online Administrators in the last 30 minutes
|
||||
$timecut = TIME_NOW-60*30;
|
||||
$query = $db->simple_select("adminsessions", "uid, ip, useragent", "lastactive > {$timecut}");
|
||||
$online_users = "<ul class=\"menu online_admins\">";
|
||||
$online_admins = array();
|
||||
|
||||
// If there's only 1 user online, it has to be us.
|
||||
if($db->num_rows($query) == 1)
|
||||
{
|
||||
$user = $db->fetch_array($query);
|
||||
global $mybb;
|
||||
|
||||
// Are we on a mobile device?
|
||||
// Stolen from http://stackoverflow.com/a/10989424
|
||||
$user_type = "desktop";
|
||||
if(is_mobile($user["useragent"]))
|
||||
{
|
||||
$user_type = "mobile";
|
||||
}
|
||||
|
||||
$online_admins[$mybb->user['username']] = array(
|
||||
"uid" => $mybb->user['uid'],
|
||||
"username" => $mybb->user['username'],
|
||||
"ip" => $user["ip"],
|
||||
"type" => $user_type
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$uid_in = array();
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$uid_in[] = $user['uid'];
|
||||
|
||||
$user_type = "desktop";
|
||||
if(is_mobile($user['useragent']))
|
||||
{
|
||||
$user_type = "mobile";
|
||||
}
|
||||
|
||||
$online_admins[$user['uid']] = array(
|
||||
"ip" => $user['ip'],
|
||||
"type" => $user_type
|
||||
);
|
||||
}
|
||||
|
||||
$query = $db->simple_select("users", "uid, username", "uid IN(".implode(',', $uid_in).")", array('order_by' => 'username'));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$online_admins[$user['username']] = array(
|
||||
"uid" => $user['uid'],
|
||||
"username" => $user['username'],
|
||||
"ip" => $online_admins[$user['uid']]['ip'],
|
||||
"type" => $online_admins[$user['uid']]['type']
|
||||
);
|
||||
unset($online_admins[$user['uid']]);
|
||||
}
|
||||
}
|
||||
|
||||
$done_users = array();
|
||||
|
||||
asort($online_admins);
|
||||
|
||||
foreach($online_admins as $user)
|
||||
{
|
||||
if(!isset($done_users["{$user['uid']}.{$user['ip']}"]))
|
||||
{
|
||||
if($user['type'] == "mobile")
|
||||
{
|
||||
$class = " class=\"mobile_user\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = "";
|
||||
}
|
||||
$ip_address = my_inet_ntop($db->unescape_binary($user['ip']));
|
||||
$online_users .= "<li title=\"{$lang->ipaddress} {$ip_address}\"{$class}>".build_profile_link(htmlspecialchars_uni($user['username']).' ('.$ip_address.')', $user['uid'], "_blank")."</li>";
|
||||
$done_users["{$user['uid']}.{$user['ip']}"] = 1;
|
||||
}
|
||||
}
|
||||
$online_users .= "</ul>";
|
||||
$sidebar = new SidebarItem($lang->online_admins);
|
||||
$sidebar->set_contents($online_users);
|
||||
|
||||
$page->sidebar .= $sidebar->get_markup();
|
||||
}
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = "dashboard";
|
||||
return "index.php";
|
||||
}
|
||||
}
|
||||
|
||||
192
webroot/forum/admin/modules/home/preferences.php
Normal file
192
webroot/forum/admin/modules/home/preferences.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?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->preferences_and_personal_notes, "index.php?module=home-preferences");
|
||||
|
||||
$plugins->run_hooks("admin_home_preferences_begin");
|
||||
|
||||
if($mybb->input['action'] == "recovery_codes")
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->recovery_codes, "index.php?module=home-preferences&action=recovery_codes");
|
||||
|
||||
// First: regenerate the codes
|
||||
$codes = generate_recovery_codes();
|
||||
$db->update_query("adminoptions", array("recovery_codes" => $db->escape_string(my_serialize($codes))), "uid='{$mybb->user['uid']}'");
|
||||
|
||||
// And now display them
|
||||
$page->output_header($lang->recovery_codes);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->recovery_codes);
|
||||
|
||||
$table->construct_cell("{$lang->recovery_codes_warning} <strong><a href=\"javascript:window.print()\">{$lang->print_recovery_codes}</a></strong>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell(implode("<br />", $codes));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->recovery_codes);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
require_once MYBB_ROOT."inc/3rdparty/2fa/GoogleAuthenticator.php";
|
||||
$auth = new PHPGangsta_GoogleAuthenticator;
|
||||
|
||||
$plugins->run_hooks("admin_home_preferences_start");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$query = $db->simple_select("adminoptions", "permissions, defaultviews, authsecret, recovery_codes", "uid='{$mybb->user['uid']}'");
|
||||
$adminopts = $db->fetch_array($query);
|
||||
|
||||
$secret = $adminopts['authsecret'];
|
||||
// Was the option changed? empty = disabled so ==
|
||||
if($mybb->input['2fa'] == empty($secret))
|
||||
{
|
||||
// 2FA was enabled -> create secret and log
|
||||
if($mybb->input['2fa'])
|
||||
{
|
||||
$secret = $auth->createSecret();
|
||||
// We don't want to close this session now
|
||||
$db->update_query("adminsessions", array("authenticated" => 1), "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
|
||||
log_admin_action("enabled");
|
||||
}
|
||||
// 2FA was disabled -> clear secret
|
||||
else
|
||||
{
|
||||
$secret = "";
|
||||
$adminopts['recovery_codes'] = "";
|
||||
log_admin_action("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
$sqlarray = array(
|
||||
"notes" => $db->escape_string($mybb->input['notes']),
|
||||
"cpstyle" => $db->escape_string($mybb->input['cpstyle']),
|
||||
"cplanguage" => $db->escape_string($mybb->input['cplanguage']),
|
||||
"permissions" => $db->escape_string($adminopts['permissions']),
|
||||
"defaultviews" => $db->escape_string($adminopts['defaultviews']),
|
||||
"uid" => $mybb->user['uid'],
|
||||
"codepress" => $mybb->get_input('codepress', MyBB::INPUT_INT), // It's actually CodeMirror but for compatibility purposes lets leave it codepress
|
||||
"authsecret" => $db->escape_string($secret),
|
||||
"recovery_codes" => $db->escape_string($adminopts['recovery_codes']),
|
||||
);
|
||||
|
||||
$db->replace_query("adminoptions", $sqlarray, "uid");
|
||||
|
||||
$plugins->run_hooks("admin_home_preferences_start_commit");
|
||||
|
||||
flash_message($lang->success_preferences_updated, 'success');
|
||||
admin_redirect("index.php?module=home-preferences");
|
||||
}
|
||||
|
||||
$page->output_header($lang->preferences_and_personal_notes);
|
||||
|
||||
$sub_tabs['preferences'] = array(
|
||||
'title' => $lang->preferences_and_personal_notes,
|
||||
'link' => "index.php?module=home-preferences",
|
||||
'description' => $lang->prefs_and_personal_notes_description
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'preferences');
|
||||
|
||||
$query = $db->simple_select("adminoptions", "notes, cpstyle, cplanguage, codepress, authsecret", "uid='".$mybb->user['uid']."'", array('limit' => 1));
|
||||
$admin_options = $db->fetch_array($query);
|
||||
|
||||
$form = new Form("index.php?module=home-preferences", "post");
|
||||
$dir = @opendir(MYBB_ADMIN_DIR."/styles");
|
||||
|
||||
$folders = array();
|
||||
while($folder = readdir($dir))
|
||||
{
|
||||
if($folder != "." && $folder != ".." && @file_exists(MYBB_ADMIN_DIR."/styles/$folder/main.css"))
|
||||
{
|
||||
$folders[$folder] = ucfirst($folder);
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
ksort($folders);
|
||||
$setting_code = $form->generate_select_box("cpstyle", $folders, $admin_options['cpstyle']);
|
||||
|
||||
$languages = array_merge(array('' => $lang->use_default), $lang->get_languages(1));
|
||||
$language_code = $form->generate_select_box("cplanguage", $languages, $admin_options['cplanguage']);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->global_preferences);
|
||||
|
||||
$table->construct_cell("<strong>{$lang->acp_theme}</strong><br /><small>{$lang->select_acp_theme}</small><br /><br />{$setting_code}");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->acp_language}</strong><br /><small>{$lang->select_acp_language}</small><br /><br />{$language_code}");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->codemirror}</strong><br /><small>{$lang->use_codemirror_desc}</small><br /><br />".$form->generate_on_off_radio('codepress', $admin_options['codepress']));
|
||||
$table->construct_row();
|
||||
|
||||
// If 2FA is enabled we need to display a link to the recovery codes page
|
||||
if(!empty($admin_options['authsecret']))
|
||||
{
|
||||
$lang->use_2fa_desc .= "<br />".$lang->recovery_codes_desc." ".$lang->recovery_codes_warning;
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong>{$lang->my2fa}</strong><br /><small>{$lang->use_2fa_desc}</small><br /><br />".$form->generate_on_off_radio('2fa', (int)!empty($admin_options['authsecret'])));
|
||||
$table->construct_row();
|
||||
|
||||
if(!empty($admin_options['authsecret']))
|
||||
{
|
||||
$qr = $auth->getQRCodeGoogleUrl($mybb->user['username']."@".str_replace(" ", "", $mybb->settings['bbname']), $admin_options['authsecret']);
|
||||
$table->construct_cell("<strong>{$lang->my2fa_qr}</strong><br /><img src=\"{$qr}\"");
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->preferences);
|
||||
|
||||
$table->construct_header($lang->notes_not_shared);
|
||||
|
||||
$table->construct_cell($form->generate_text_area("notes", $admin_options['notes'], array('style' => 'width: 99%; height: 300px;')));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->personal_notes);
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_notes_and_prefs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate 10 random recovery codes, each with a length of 6 and without duplicates
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generate_recovery_codes()
|
||||
{
|
||||
$t = array();
|
||||
while(count($t) < 10)
|
||||
{
|
||||
$g = random_str(6);
|
||||
if(!in_array($g, $t))
|
||||
{
|
||||
$t[] = $g;
|
||||
}
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
8
webroot/forum/admin/modules/index.html
Normal file
8
webroot/forum/admin/modules/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
8
webroot/forum/admin/modules/style/index.html
Normal file
8
webroot/forum/admin/modules/style/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
79
webroot/forum/admin/modules/style/module_meta.php
Normal file
79
webroot/forum/admin/modules/style/module_meta.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function style_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "themes", "title" => $lang->themes, "link" => "index.php?module=style-themes");
|
||||
$sub_menu['20'] = array("id" => "templates", "title" => $lang->templates, "link" => "index.php?module=style-templates");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_style_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->templates_and_style, "style", "index.php?module=style", 40, $sub_menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function style_action_handler($action)
|
||||
{
|
||||
global $page, $plugins;
|
||||
|
||||
$page->active_module = "style";
|
||||
|
||||
$actions = array(
|
||||
'templates' => array('active' => 'templates', 'file' => 'templates.php'),
|
||||
'themes' => array('active' => 'themes', 'file' => 'themes.php')
|
||||
);
|
||||
|
||||
$actions = $plugins->run_hooks("admin_style_action_handler", $actions);
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = "themes";
|
||||
return "themes.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function style_admin_permissions()
|
||||
{
|
||||
global $lang, $plugins;
|
||||
|
||||
$admin_permissions = array(
|
||||
"themes" => $lang->can_manage_themes,
|
||||
"templates" => $lang->can_manage_templates,
|
||||
);
|
||||
|
||||
$admin_permissions = $plugins->run_hooks("admin_style_permissions", $admin_permissions);
|
||||
|
||||
return array("name" => $lang->templates_and_style, "permissions" => $admin_permissions, "disporder" => 40);
|
||||
}
|
||||
2017
webroot/forum/admin/modules/style/templates.php
Normal file
2017
webroot/forum/admin/modules/style/templates.php
Normal file
File diff suppressed because it is too large
Load Diff
3019
webroot/forum/admin/modules/style/themes.php
Normal file
3019
webroot/forum/admin/modules/style/themes.php
Normal file
File diff suppressed because it is too large
Load Diff
614
webroot/forum/admin/modules/tools/adminlog.php
Normal file
614
webroot/forum/admin/modules/tools/adminlog.php
Normal file
@@ -0,0 +1,614 @@
|
||||
<?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->admin_logs, "index.php?module=tools-adminlog");
|
||||
|
||||
$sub_tabs['admin_logs'] = array(
|
||||
'title' => $lang->admin_logs,
|
||||
'link' => "index.php?module=tools-adminlog",
|
||||
'description' => $lang->admin_logs_desc
|
||||
);
|
||||
$sub_tabs['prune_admin_logs'] = array(
|
||||
'title' => $lang->prune_admin_logs,
|
||||
'link' => "index.php?module=tools-adminlog&action=prune",
|
||||
'description' => $lang->prune_admin_logs_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_adminlog_begin");
|
||||
|
||||
if($mybb->input['action'] == 'prune')
|
||||
{
|
||||
if(!is_super_admin($mybb->user['uid']))
|
||||
{
|
||||
flash_message($lang->cannot_perform_action_super_admin_general, 'error');
|
||||
admin_redirect("index.php?module=tools-adminlog");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_adminlog_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['filter_module'])
|
||||
{
|
||||
$where .= " AND module='".$db->escape_string($mybb->input['filter_module'])."'";
|
||||
}
|
||||
|
||||
$query = $db->delete_query("adminlog", $where);
|
||||
$num_deleted = $db->affected_rows();
|
||||
|
||||
$plugins->run_hooks("admin_tools_adminlog_prune_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['older_than'], $mybb->input['uid'], $mybb->input['filter_module'], $num_deleted);
|
||||
|
||||
$success = $lang->success_pruned_admin_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-adminlog");
|
||||
}
|
||||
flash_message($success, 'success');
|
||||
admin_redirect("index.php?module=tools-adminlog");
|
||||
}
|
||||
$page->add_breadcrumb_item($lang->prune_admin_logs, "index.php?module=tools-adminlog&action=prune");
|
||||
$page->output_header($lang->prune_admin_logs);
|
||||
$page->output_nav_tabs($sub_tabs, 'prune_admin_logs');
|
||||
|
||||
// Fetch filter options
|
||||
$sortbysel[$mybb->input['sortby']] = 'selected="selected"';
|
||||
$ordersel[$mybb->input['order']] = 'selected="selected"';
|
||||
|
||||
$user_options[''] = $lang->all_administrators;
|
||||
$user_options['0'] = '----------';
|
||||
|
||||
$query = $db->query("
|
||||
SELECT DISTINCT l.uid, u.username
|
||||
FROM ".TABLE_PREFIX."adminlog l
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid)
|
||||
ORDER BY u.username ASC
|
||||
");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$user_options[$user['uid']] = htmlspecialchars_uni($user['username']);
|
||||
}
|
||||
|
||||
$module_options = array();
|
||||
$module_options[''] = $lang->all_modules;
|
||||
$module_options['0'] = '----------';
|
||||
$query = $db->query("
|
||||
SELECT DISTINCT l.module
|
||||
FROM ".TABLE_PREFIX."adminlog l
|
||||
ORDER BY l.module ASC
|
||||
");
|
||||
while($module = $db->fetch_array($query))
|
||||
{
|
||||
$module_options[$module['module']] = str_replace(' ', ' -> ', ucwords(str_replace('/', ' ', $module['module'])));
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=tools-adminlog&action=prune", "post");
|
||||
$form_container = new FormContainer($lang->prune_administrator_logs);
|
||||
$form_container->output_row($lang->module, "", $form->generate_select_box('filter_module', $module_options, $mybb->input['filter_module'], array('id' => 'filter_module')), 'filter_module');
|
||||
$form_container->output_row($lang->administrator, "", $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_administrator_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->admin_logs);
|
||||
$page->output_nav_tabs($sub_tabs, 'admin_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 = '';
|
||||
|
||||
$plugins->run_hooks("admin_tools_adminlog_start");
|
||||
|
||||
// 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 module
|
||||
if($mybb->input['filter_module'])
|
||||
{
|
||||
$where .= " AND module='".$db->escape_string($mybb->input['filter_module'])."'";
|
||||
}
|
||||
|
||||
// Order?
|
||||
switch($mybb->input['sortby'])
|
||||
{
|
||||
case "username":
|
||||
$sortby = "u.username";
|
||||
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."adminlog l
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
|
||||
WHERE 1=1 {$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->information, array('class' => 'align_center', 'width' => '65%'));
|
||||
$table->construct_header($lang->ipaddress, array('class' => 'align_center', 'width' => '10%'));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT l.*, u.username, u.usergroup, u.displaygroup
|
||||
FROM ".TABLE_PREFIX."adminlog l
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
|
||||
WHERE 1=1 {$where}
|
||||
ORDER BY {$sortby} {$order}
|
||||
LIMIT {$start}, {$perpage}
|
||||
");
|
||||
while($logitem = $db->fetch_array($query))
|
||||
{
|
||||
$information = '';
|
||||
$trow = alt_trow();
|
||||
$logitem['username'] = htmlspecialchars_uni($logitem['username']);
|
||||
$username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
|
||||
|
||||
$logitem['data'] = my_unserialize($logitem['data']);
|
||||
$logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank");
|
||||
$logitem['dateline'] = my_date('relative', $logitem['dateline']);
|
||||
|
||||
// Get detailed information from meta
|
||||
$information = get_admin_log_action($logitem);
|
||||
|
||||
$table->construct_cell($logitem['profilelink']);
|
||||
$table->construct_cell($logitem['dateline'], 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_adminlogs, array('colspan' => '4'));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->admin_logs);
|
||||
|
||||
// Do we need to construct the pagination?
|
||||
if($rescount > $perpage)
|
||||
{
|
||||
echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools-adminlog&perpage=$perpage&uid={$mybb->input['uid']}&fid={$mybb->input['fid']}&sortby={$mybb->input['sortby']}&order={$order}&filter_module=".htmlspecialchars_uni($mybb->input['filter_module']))."<br />";
|
||||
}
|
||||
|
||||
// Fetch filter options
|
||||
$sortbysel[$mybb->input['sortby']] = 'selected="selected"';
|
||||
$ordersel[$mybb->input['order']] = 'selected="selected"';
|
||||
|
||||
$user_options[''] = $lang->all_administrators;
|
||||
$user_options['0'] = '----------';
|
||||
|
||||
$query = $db->query("
|
||||
SELECT DISTINCT l.uid, u.username
|
||||
FROM ".TABLE_PREFIX."adminlog l
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid)
|
||||
ORDER BY u.username ASC
|
||||
");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$user_options[$user['uid']] = htmlspecialchars_uni($user['username']);
|
||||
}
|
||||
|
||||
$module_options = array();
|
||||
$module_options[''] = $lang->all_modules;
|
||||
$module_options['0'] = '----------';
|
||||
$query = $db->query("
|
||||
SELECT DISTINCT l.module
|
||||
FROM ".TABLE_PREFIX."adminlog l
|
||||
ORDER BY l.module ASC
|
||||
");
|
||||
while($module = $db->fetch_array($query))
|
||||
{
|
||||
$module_options[$module['module']] = str_replace(' ', ' -> ', ucwords(str_replace('/', ' ', $module['module'])));
|
||||
}
|
||||
|
||||
$sort_by = array(
|
||||
'dateline' => $lang->date,
|
||||
'username' => $lang->username
|
||||
);
|
||||
|
||||
$order_array = array(
|
||||
'asc' => $lang->asc,
|
||||
'desc' => $lang->desc
|
||||
);
|
||||
|
||||
$form = new Form("index.php?module=tools-adminlog", "post");
|
||||
$form_container = new FormContainer($lang->filter_administrator_logs);
|
||||
$form_container->output_row($lang->module, "", $form->generate_select_box('filter_module', $module_options, $mybb->input['filter_module'], array('id' => 'filter_module')), 'filter_module');
|
||||
$form_container->output_row($lang->administrator, "", $form->generate_select_box('uid', $user_options, $mybb->input['uid'], array('id' => 'uid')), 'uid');
|
||||
$form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $order_array, $order, array('id' => 'order'))." {$lang->order}", 'order');
|
||||
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $perpage, array('id' => 'perpage', 'min' => 1)), 'perpage');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_administrator_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns language-friendly string describing $logitem
|
||||
* @param array $logitem The log item (one row from mybb_adminlogs)
|
||||
* @return string The description
|
||||
*/
|
||||
function get_admin_log_action($logitem)
|
||||
{
|
||||
global $lang, $plugins, $mybb;
|
||||
|
||||
$logitem['module'] = str_replace('/', '-', $logitem['module']);
|
||||
list($module, $action) = explode('-', $logitem['module']);
|
||||
$lang_string = 'admin_log_'.$module.'_'.$action.'_'.$logitem['action'];
|
||||
|
||||
// Specific page overrides
|
||||
switch($lang_string)
|
||||
{
|
||||
// == CONFIG ==
|
||||
case 'admin_log_config_banning_add': // Banning IP/Username/Email
|
||||
case 'admin_log_config_banning_delete': // Removing banned IP/username/emails
|
||||
switch($logitem['data'][2])
|
||||
{
|
||||
case 1:
|
||||
$lang_string = 'admin_log_config_banning_'.$logitem['action'].'_ip';
|
||||
break;
|
||||
case 2:
|
||||
$lang_string = 'admin_log_config_banning_'.$logitem['action'].'_username';
|
||||
break;
|
||||
case 3:
|
||||
$lang_string = 'admin_log_config_banning_'.$logitem['action'].'_email';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'admin_log_config_help_documents_add': // Help documents and sections
|
||||
case 'admin_log_config_help_documents_edit':
|
||||
case 'admin_log_config_help_documents_delete':
|
||||
$lang_string .= "_{$logitem['data'][2]}"; // adds _section or _document
|
||||
break;
|
||||
|
||||
case 'admin_log_config_languages_edit': // Editing language variables
|
||||
$logitem['data'][1] = basename($logitem['data'][1]);
|
||||
if($logitem['data'][2] == 1)
|
||||
{
|
||||
$lang_string = 'admin_log_config_languages_edit_admin';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'admin_log_config_mycode_toggle_status': // Custom MyCode toggle activation
|
||||
if($logitem['data'][2] == 1)
|
||||
{
|
||||
$lang_string .= '_enabled';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_string .= '_disabled';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_config_plugins_activate': // Installing plugin
|
||||
if($logitem['data'][1])
|
||||
{
|
||||
$lang_string .= '_install';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_config_plugins_deactivate': // Uninstalling plugin
|
||||
if($logitem['data'][1])
|
||||
{
|
||||
$lang_string .= '_uninstall';
|
||||
}
|
||||
break;
|
||||
// == FORUM ==
|
||||
case 'admin_log_forum_attachments_delete': // Deleting attachments
|
||||
if($logitem['data'][2])
|
||||
{
|
||||
$lang_string .= '_post';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_forum_management_copy': // Forum copy
|
||||
if($logitem['data'][4])
|
||||
{
|
||||
$lang_string .= '_with_permissions';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_forum_management_': // add mod, permissions, forum orders
|
||||
// first parameter already set with action
|
||||
$lang_string .= $logitem['data'][0];
|
||||
if($logitem['data'][0] == 'orders' && $logitem['data'][1])
|
||||
{
|
||||
$lang_string .= '_sub'; // updating forum orders in a subforum
|
||||
}
|
||||
break;
|
||||
case 'admin_log_forum_moderation_queue_': //moderation queue
|
||||
// first parameter already set with action
|
||||
$lang_string .= $logitem['data'][0];
|
||||
break;
|
||||
// == HOME ==
|
||||
case 'admin_log_home_preferences_': // 2FA
|
||||
$lang_string .= $logitem['data'][0]; // either "enabled" or "disabled"
|
||||
break;
|
||||
// == STYLE ==
|
||||
case 'admin_log_style_templates_delete_template': // deleting templates
|
||||
// global template set
|
||||
if($logitem['data'][2] == -1)
|
||||
{
|
||||
$lang_string .= '_global';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_style_templates_edit_template': // editing templates
|
||||
// global template set
|
||||
if($logitem['data'][2] == -1)
|
||||
{
|
||||
$lang_string .= '_global';
|
||||
}
|
||||
break;
|
||||
// == TOOLS ==
|
||||
case 'admin_log_tools_adminlog_prune': // Admin Log Pruning
|
||||
if($logitem['data'][1] && !$logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_adminlog_prune_user';
|
||||
}
|
||||
elseif($logitem['data'][2] && !$logitem['data'][1])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_adminlog_prune_module';
|
||||
}
|
||||
elseif($logitem['data'][1] && $logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_adminlog_prune_user_module';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_tools_modlog_prune': // Moderator Log Pruning
|
||||
if($logitem['data'][1] && !$logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_modlog_prune_user';
|
||||
}
|
||||
elseif($logitem['data'][2] && !$logitem['data'][1])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_modlog_prune_forum';
|
||||
}
|
||||
elseif($logitem['data'][1] && $logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_modlog_prune_user_forum';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_tools_backupdb_backup': // Create backup
|
||||
if($logitem['data'][0] == 'download')
|
||||
{
|
||||
$lang_string = 'admin_log_tools_backupdb_backup_download';
|
||||
}
|
||||
$logitem['data'][1] = '...'.substr($logitem['data'][1], -20);
|
||||
break;
|
||||
case 'admin_log_tools_backupdb_dlbackup': // Download backup
|
||||
$logitem['data'][0] = '...'.substr($logitem['data'][0], -20);
|
||||
break;
|
||||
case 'admin_log_tools_backupdb_delete': // Delete backup
|
||||
$logitem['data'][0] = '...'.substr($logitem['data'][0], -20);
|
||||
break;
|
||||
case 'admin_log_tools_optimizedb_': // Optimize DB
|
||||
$logitem['data'][0] = @implode(', ', my_unserialize($logitem['data'][0]));
|
||||
break;
|
||||
case 'admin_log_tools_recount_rebuild_': // Recount and rebuild
|
||||
$detail_lang_string = $lang_string.$logitem['data'][0];
|
||||
if(isset($lang->$detail_lang_string))
|
||||
{
|
||||
$lang_string = $detail_lang_string;
|
||||
}
|
||||
break;
|
||||
case 'admin_log_tools_spamlog_prune': // Spam Log Pruning
|
||||
if($logitem['data'][1] && !$logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_spamlog_prune_user';
|
||||
}
|
||||
elseif($logitem['data'][2] && !$logitem['data'][1])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_spamlog_prune_email';
|
||||
}
|
||||
elseif($logitem['data'][1] && $logitem['data'][2])
|
||||
{
|
||||
$lang_string = 'admin_log_tools_spamlog_prune_user_email';
|
||||
}
|
||||
break;
|
||||
// == USERS ==
|
||||
case 'admin_log_user_admin_permissions_edit': // editing default/group/user admin permissions
|
||||
if($logitem['data'][0] > 0)
|
||||
{
|
||||
// User
|
||||
$lang_string .= '_user';
|
||||
}
|
||||
elseif($logitem['data'][0] < 0)
|
||||
{
|
||||
// Group
|
||||
$logitem['data'][0] = abs($logitem['data'][0]);
|
||||
$lang_string .= '_group';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_user_admin_permissions_delete': // deleting group/user admin permissions
|
||||
if($logitem['data'][0] > 0)
|
||||
{
|
||||
// User
|
||||
$lang_string .= '_user';
|
||||
}
|
||||
elseif($logitem['data'][0] < 0)
|
||||
{
|
||||
// Group
|
||||
$logitem['data'][0] = abs($logitem['data'][0]);
|
||||
$lang_string .= '_group';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_user_awaiting_activation_activate':
|
||||
if($logitem['data'][0] == 'deleted')
|
||||
{
|
||||
$lang_string .= '_deleted';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_string .= '_activated';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_user_banning_': // banning
|
||||
if($logitem['data'][2] == 0)
|
||||
{
|
||||
$lang_string = 'admin_log_user_banning_add_permanent';
|
||||
}
|
||||
else
|
||||
{
|
||||
$logitem['data'][2] = my_date($mybb->settings['dateformat'], $logitem['data'][2]);
|
||||
$lang_string = 'admin_log_user_banning_add_temporary';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_user_groups_join_requests':
|
||||
if($logitem['data'][0] == 'approve')
|
||||
{
|
||||
$lang_string = 'admin_log_user_groups_join_requests_approve';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_string = 'admin_log_user_groups_join_requests_deny';
|
||||
}
|
||||
break;
|
||||
case 'admin_log_user_users_inline_banned':
|
||||
if($logitem['data'][1] == 0)
|
||||
{
|
||||
$lang_string = 'admin_log_user_users_inline_banned_perm';
|
||||
}
|
||||
else
|
||||
{
|
||||
$logitem['data'][1] = my_date($mybb->settings['dateformat'], $logitem['data'][1]);
|
||||
$lang_string = 'admin_log_user_users_inline_banned_temp';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$plugin_array = array('logitem' => &$logitem, 'lang_string' => &$lang_string);
|
||||
$plugins->run_hooks("admin_tools_get_admin_log_action", $plugin_array);
|
||||
|
||||
foreach($logitem['data'] as $key => $value)
|
||||
{
|
||||
$logitem['data'][$key] = htmlspecialchars_uni($value);
|
||||
}
|
||||
|
||||
if(isset($lang->$lang_string))
|
||||
{
|
||||
array_unshift($logitem['data'], $lang->$lang_string); // First parameter for sprintf is the format string
|
||||
$string = call_user_func_array(array($lang, 'sprintf'), $logitem['data']);
|
||||
if(!$string)
|
||||
{
|
||||
$string = $lang->$lang_string; // Fall back to the one in the language pack
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($logitem['data']['type']) && $logitem['data']['type'] == 'admin_locked_out')
|
||||
{
|
||||
$string = $lang->sprintf($lang->admin_log_admin_locked_out, (int) $logitem['data']['uid'], htmlspecialchars_uni($logitem['data']['username']));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build a default string
|
||||
$string = $logitem['module'].' - '.$logitem['action'];
|
||||
if(is_array($logitem['data']) && count($logitem['data']) > 0)
|
||||
{
|
||||
$string .= '('.implode(', ', $logitem['data']).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
483
webroot/forum/admin/modules/tools/backupdb.php
Normal file
483
webroot/forum/admin/modules/tools/backupdb.php
Normal file
@@ -0,0 +1,483 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows us to refresh cache to prevent over flowing
|
||||
*
|
||||
* @param resource $fp
|
||||
* @param string $contents
|
||||
*/
|
||||
function clear_overflow($fp, &$contents)
|
||||
{
|
||||
global $mybb;
|
||||
|
||||
if($mybb->input['method'] == 'disk')
|
||||
{
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
gzwrite($fp, $contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite($fp, $contents);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($mybb->input['filetype'] == "gzip")
|
||||
{
|
||||
echo gzencode($contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $contents;
|
||||
}
|
||||
}
|
||||
|
||||
$contents = '';
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->database_backups, "index.php?module=tools-backupdb");
|
||||
|
||||
$plugins->run_hooks("admin_tools_backupdb_begin");
|
||||
|
||||
if($mybb->input['action'] == "dlbackup")
|
||||
{
|
||||
if(empty($mybb->input['file']))
|
||||
{
|
||||
flash_message($lang->error_file_not_specified, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_backupdb_dlbackup");
|
||||
|
||||
$file = basename($mybb->input['file']);
|
||||
$ext = get_extension($file);
|
||||
|
||||
if(file_exists(MYBB_ADMIN_DIR.'backups/'.$file) && filetype(MYBB_ADMIN_DIR.'backups/'.$file) == 'file' && ($ext == 'gz' || $ext == 'sql'))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_backupdb_dlbackup_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($file);
|
||||
|
||||
header('Content-disposition: attachment; filename='.$file);
|
||||
header("Content-type: ".$ext);
|
||||
header("Content-length: ".filesize(MYBB_ADMIN_DIR.'backups/'.$file));
|
||||
|
||||
$handle = fopen(MYBB_ADMIN_DIR.'backups/'.$file, 'rb');
|
||||
while(!feof($handle))
|
||||
{
|
||||
echo fread($handle, 8192);
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_message($lang->error_invalid_backup, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
|
||||
$file = basename($mybb->input['file']);
|
||||
|
||||
if(!trim($mybb->input['file']) || !file_exists(MYBB_ADMIN_DIR.'backups/'.$file))
|
||||
{
|
||||
flash_message($lang->error_backup_doesnt_exist, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_backupdb_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$delete = @unlink(MYBB_ADMIN_DIR.'backups/'.$file);
|
||||
|
||||
if($delete)
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_backupdb_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($file);
|
||||
|
||||
flash_message($lang->success_backup_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_message($lang->error_backup_not_deleted, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=tools-backupdb&action=delete&file={$mybb->input['file']}", $lang->confirm_backup_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "backup")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_backupdb_backup");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!is_array($mybb->input['tables']))
|
||||
{
|
||||
flash_message($lang->error_tables_not_selected, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb&action=backup");
|
||||
}
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
if($mybb->input['method'] == 'disk')
|
||||
{
|
||||
$file = MYBB_ADMIN_DIR.'backups/backup_'.date("_Ymd_His_").random_str(16);
|
||||
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
if(!function_exists('gzopen')) // check zlib-ness
|
||||
{
|
||||
flash_message($lang->error_no_zlib, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb&action=backup");
|
||||
}
|
||||
|
||||
$fp = gzopen($file.'.incomplete.sql.gz', 'w9');
|
||||
}
|
||||
else
|
||||
{
|
||||
$fp = fopen($file.'.incomplete.sql', 'w');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = 'backup_'.substr(md5($mybb->user['uid'].TIME_NOW), 0, 10).random_str(54);
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
if(!function_exists('gzopen')) // check zlib-ness
|
||||
{
|
||||
flash_message($lang->error_no_zlib, 'error');
|
||||
admin_redirect("index.php?module=tools-backupdb&action=backup");
|
||||
}
|
||||
|
||||
// Send headers for gzip file
|
||||
header('Content-Type: application/x-gzip');
|
||||
header('Content-Disposition: attachment; filename="'.$file.'.sql.gz"');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send standard headers for .sql
|
||||
header('Content-Type: text/x-sql');
|
||||
header('Content-Disposition: attachment; filename="'.$file.'.sql"');
|
||||
}
|
||||
}
|
||||
$db->set_table_prefix('');
|
||||
|
||||
$time = date('dS F Y \a\t H:i', TIME_NOW);
|
||||
$header = "-- MyBB Database Backup\n-- Generated: {$time}\n-- -------------------------------------\n\n";
|
||||
$contents = $header;
|
||||
foreach($mybb->input['tables'] as $table)
|
||||
{
|
||||
if(!$db->table_exists($db->escape_string($table)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if($mybb->input['analyzeoptimize'] == 1)
|
||||
{
|
||||
$db->optimize_table($table);
|
||||
$db->analyze_table($table);
|
||||
}
|
||||
|
||||
$field_list = array();
|
||||
$fields_array = $db->show_fields_from($table);
|
||||
foreach($fields_array as $field)
|
||||
{
|
||||
$field_list[] = $field['Field'];
|
||||
}
|
||||
|
||||
$fields = "`".implode("`,`", $field_list)."`";
|
||||
if($mybb->input['contents'] != 'data')
|
||||
{
|
||||
$structure = $db->show_create_table($table).";\n";
|
||||
$contents .= $structure;
|
||||
clear_overflow($fp, $contents);
|
||||
}
|
||||
|
||||
if($mybb->input['contents'] != 'structure')
|
||||
{
|
||||
if($db->engine == 'mysqli')
|
||||
{
|
||||
$query = mysqli_query($db->read_link, "SELECT * FROM {$db->table_prefix}{$table}", MYSQLI_USE_RESULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select($table);
|
||||
}
|
||||
|
||||
while($row = $db->fetch_array($query))
|
||||
{
|
||||
$insert = "INSERT INTO {$table} ($fields) VALUES (";
|
||||
$comma = '';
|
||||
foreach($field_list as $field)
|
||||
{
|
||||
if(!isset($row[$field]) || is_null($row[$field]))
|
||||
{
|
||||
$insert .= $comma."NULL";
|
||||
}
|
||||
else if($db->engine == 'mysqli')
|
||||
{
|
||||
$insert .= $comma."'".mysqli_real_escape_string($db->read_link, $row[$field])."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert .= $comma."'".$db->escape_string($row[$field])."'";
|
||||
}
|
||||
$comma = ',';
|
||||
}
|
||||
$insert .= ");\n";
|
||||
$contents .= $insert;
|
||||
clear_overflow($fp, $contents);
|
||||
}
|
||||
$db->free_result($query);
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_table_prefix(TABLE_PREFIX);
|
||||
|
||||
if($mybb->input['method'] == 'disk')
|
||||
{
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
gzwrite($fp, $contents);
|
||||
gzclose($fp);
|
||||
rename($file.'.incomplete.sql.gz', $file.'.sql.gz');
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite($fp, $contents);
|
||||
fclose($fp);
|
||||
rename($file.'.incomplete.sql', $file.'.sql');
|
||||
}
|
||||
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
$ext = '.sql.gz';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ext = '.sql';
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_backupdb_backup_disk_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action("disk", $file.$ext);
|
||||
|
||||
$file_from_admindir = 'index.php?module=tools-backupdb&action=dlbackup&file='.basename($file).$ext;
|
||||
flash_message("<span><em>{$lang->success_backup_created}</em></span><p>{$lang->backup_saved_to}<br />{$file}{$ext} (<a href=\"{$file_from_admindir}\">{$lang->download}</a>)</p>", 'success');
|
||||
admin_redirect("index.php?module=tools-backupdb");
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_backupdb_backup_download_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action("download");
|
||||
|
||||
if($mybb->input['filetype'] == 'gzip')
|
||||
{
|
||||
echo gzencode($contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $contents;
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$page->extra_header = " <script type=\"text/javascript\">
|
||||
function changeSelection(action, prefix)
|
||||
{
|
||||
var select_box = document.getElementById('table_select');
|
||||
|
||||
for(var i = 0; i < select_box.length; i++)
|
||||
{
|
||||
if(action == 'select')
|
||||
{
|
||||
select_box[i].selected = true;
|
||||
}
|
||||
else if(action == 'deselect')
|
||||
{
|
||||
select_box[i].selected = false;
|
||||
}
|
||||
else if(action == 'forum' && prefix != 0)
|
||||
{
|
||||
select_box[i].selected = false;
|
||||
var row = select_box[i].value;
|
||||
var subString = row.substring(prefix.length, 0);
|
||||
if(subString == prefix)
|
||||
{
|
||||
select_box[i].selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>\n";
|
||||
|
||||
$page->add_breadcrumb_item($lang->new_database_backup);
|
||||
$page->output_header($lang->new_database_backup);
|
||||
|
||||
$sub_tabs['database_backup'] = array(
|
||||
'title' => $lang->database_backups,
|
||||
'link' => "index.php?module=tools-backupdb"
|
||||
);
|
||||
|
||||
$sub_tabs['new_backup'] = array(
|
||||
'title' => $lang->new_backup,
|
||||
'link' => "index.php?module=tools-backupdb&action=backup",
|
||||
'description' => $lang->new_backup_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'new_backup');
|
||||
|
||||
// Check if file is writable, before allowing submission
|
||||
if(!is_writable(MYBB_ADMIN_DIR."/backups"))
|
||||
{
|
||||
$lang->update_button = '';
|
||||
$page->output_alert($lang->alert_not_writable);
|
||||
$cannot_write = true;
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->table_selection);
|
||||
$table->construct_header($lang->backup_options);
|
||||
|
||||
$table_selects = array();
|
||||
$table_list = $db->list_tables($config['database']['database']);
|
||||
foreach($table_list as $id => $table_name)
|
||||
{
|
||||
$table_selects[$table_name] = $table_name;
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=tools-backupdb&action=backup", "post", "table_selection", 0, "table_selection");
|
||||
|
||||
$table->construct_cell("{$lang->table_select_desc}\n<br /><br />\n<a href=\"javascript:changeSelection('select', 0);\">{$lang->select_all}</a><br />\n<a href=\"javascript:changeSelection('deselect', 0);\">{$lang->deselect_all}</a><br />\n<a href=\"javascript:changeSelection('forum', '".TABLE_PREFIX."');\">{$lang->select_forum_tables}</a>\n<br /><br />\n<div class=\"form_row\">".$form->generate_select_box("tables[]", $table_selects, false, array('multiple' => true, 'id' => 'table_select', 'size' => 20))."</div>", array('rowspan' => 5, 'width' => '50%', 'style' => 'border-bottom: 0px'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->file_type}</strong><br />\n{$lang->file_type_desc}<br />\n<div class=\"form_row\">".$form->generate_radio_button("filetype", "gzip", $lang->gzip_compressed, array('checked' => 1))."<br />\n".$form->generate_radio_button("filetype", "plain", $lang->plain_text)."</div>", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
$table->construct_cell("<strong>{$lang->save_method}</strong><br />\n{$lang->save_method_desc}<br /><div class=\"form_row\">".$form->generate_radio_button("method", "disk", $lang->backup_directory)."<br />\n".$form->generate_radio_button("method", "download", $lang->download, array('checked' => 1))."</div>", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
$table->construct_cell("<strong>{$lang->backup_contents}</strong><br />\n{$lang->backup_contents_desc}<br /><div class=\"form_row\">".$form->generate_radio_button("contents", "both", $lang->structure_and_data, array('checked' => 1))."<br />\n".$form->generate_radio_button("contents", "structure", $lang->structure_only)."<br />\n".$form->generate_radio_button("contents", "data", $lang->data_only)."</div>", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
$table->construct_cell("<strong>{$lang->analyze_and_optimize}</strong><br />\n{$lang->analyze_and_optimize_desc}<br /><div class=\"form_row\">".$form->generate_yes_no_radio("analyzeoptimize")."</div>", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->new_database_backup);
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->perform_backup);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->backups);
|
||||
$page->output_header($lang->database_backups);
|
||||
|
||||
$sub_tabs['database_backup'] = array(
|
||||
'title' => $lang->database_backups,
|
||||
'link' => "index.php?module=tools-backupdb",
|
||||
'description' => $lang->database_backups_desc
|
||||
);
|
||||
|
||||
$sub_tabs['new_backup'] = array(
|
||||
'title' => $lang->new_backup,
|
||||
'link' => "index.php?module=tools-backupdb&action=backup",
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_backupdb_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'database_backup');
|
||||
|
||||
$backups = array();
|
||||
$dir = MYBB_ADMIN_DIR.'backups/';
|
||||
$handle = opendir($dir);
|
||||
|
||||
if($handle !== false)
|
||||
{
|
||||
while(($file = readdir($handle)) !== false)
|
||||
{
|
||||
if(filetype(MYBB_ADMIN_DIR.'backups/'.$file) == 'file')
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
if($ext == 'gz' || $ext == 'sql')
|
||||
{
|
||||
$backups[@filemtime(MYBB_ADMIN_DIR.'backups/'.$file)] = array(
|
||||
"file" => $file,
|
||||
"time" => @filemtime(MYBB_ADMIN_DIR.'backups/'.$file),
|
||||
"type" => $ext
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
$count = count($backups);
|
||||
krsort($backups);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->backup_filename);
|
||||
$table->construct_header($lang->file_size, array("class" => "align_center"));
|
||||
$table->construct_header($lang->creation_date);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center"));
|
||||
|
||||
foreach($backups as $backup)
|
||||
{
|
||||
$time = "-";
|
||||
if($backup['time'])
|
||||
{
|
||||
$time = my_date('relative', $backup['time']);
|
||||
}
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-backupdb&action=dlbackup&file={$backup['file']}\">{$backup['file']}</a>");
|
||||
$table->construct_cell(get_friendly_size(filesize(MYBB_ADMIN_DIR.'backups/'.$backup['file'])), array("class" => "align_center"));
|
||||
$table->construct_cell($time);
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-backupdb&action=backup&action=delete&file={$backup['file']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_backup_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($count == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_backups, array('colspan' => 4));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->existing_database_backups);
|
||||
$page->output_footer();
|
||||
}
|
||||
276
webroot/forum/admin/modules/tools/cache.php
Normal file
276
webroot/forum/admin/modules/tools/cache.php
Normal file
@@ -0,0 +1,276 @@
|
||||
<?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->cache_manager, "index.php?module=tools-cache");
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_begin");
|
||||
|
||||
if($mybb->input['action'] == 'view')
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
flash_message($lang->error_no_cache_specified, 'error');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_view");
|
||||
|
||||
// Rebuilds forum settings
|
||||
if($mybb->input['title'] == 'settings')
|
||||
{
|
||||
$cachedsettings = (array)$mybb->settings;
|
||||
if(isset($cachedsettings['internal']))
|
||||
{
|
||||
unset($cachedsettings['internal']);
|
||||
}
|
||||
|
||||
$cacheitem = array(
|
||||
'title' => 'settings',
|
||||
'cache' => my_serialize($cachedsettings)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("datacache", "*", "title = '".$db->escape_string($mybb->input['title'])."'");
|
||||
$cacheitem = $db->fetch_array($query);
|
||||
}
|
||||
|
||||
if(!$cacheitem)
|
||||
{
|
||||
flash_message($lang->error_incorrect_cache, 'error');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
$cachecontents = unserialize($cacheitem['cache']);
|
||||
if(empty($cachecontents))
|
||||
{
|
||||
$cachecontents = $lang->error_empty_cache;
|
||||
}
|
||||
ob_start();
|
||||
print_r($cachecontents);
|
||||
$cachecontents = htmlspecialchars_uni(ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
$page->add_breadcrumb_item($lang->view);
|
||||
$page->output_header($lang->cache_manager);
|
||||
|
||||
$table = new Table;
|
||||
|
||||
$table->construct_cell("<pre>\n{$cachecontents}\n</pre>");
|
||||
$table->construct_row();
|
||||
$table->output($lang->cache." {$cacheitem['title']}");
|
||||
|
||||
$page->output_footer();
|
||||
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "rebuild" || $mybb->input['action'] == "reload")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild");
|
||||
|
||||
// Rebuilds forum settings
|
||||
if($mybb->input['title'] == 'settings')
|
||||
{
|
||||
rebuild_settings();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_cache_reloaded, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
if(method_exists($cache, "update_{$mybb->input['title']}"))
|
||||
{
|
||||
$func = "update_{$mybb->input['title']}";
|
||||
$cache->$func();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_cache_rebuilt, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
elseif(method_exists($cache, "reload_{$mybb->input['title']}"))
|
||||
{
|
||||
$func = "reload_{$mybb->input['title']}";
|
||||
$cache->$func();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_cache_reloaded, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
elseif(function_exists("update_{$mybb->input['title']}"))
|
||||
{
|
||||
$func = "update_{$mybb->input['title']}";
|
||||
$func();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_cache_rebuilt, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
elseif(function_exists("reload_{$mybb->input['title']}"))
|
||||
{
|
||||
$func = "reload_{$mybb->input['title']}";
|
||||
$func();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_cache_reloaded, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_message($lang->error_cannot_rebuild, 'error');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "rebuild_all")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_all");
|
||||
|
||||
$query = $db->simple_select("datacache");
|
||||
while($cacheitem = $db->fetch_array($query))
|
||||
{
|
||||
if(method_exists($cache, "update_{$cacheitem['title']}"))
|
||||
{
|
||||
$func = "update_{$cacheitem['title']}";
|
||||
$cache->$func();
|
||||
}
|
||||
elseif(method_exists($cache, "reload_{$cacheitem['title']}"))
|
||||
{
|
||||
$func = "reload_{$cacheitem['title']}";
|
||||
$cache->$func();
|
||||
}
|
||||
elseif(function_exists("update_{$cacheitem['title']}"))
|
||||
{
|
||||
$func = "update_{$cacheitem['title']}";
|
||||
$func();
|
||||
}
|
||||
elseif(function_exists("reload_{$cacheitem['title']}"))
|
||||
{
|
||||
$func = "reload_{$cacheitem['title']}";
|
||||
$func();
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilds forum settings
|
||||
rebuild_settings();
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_rebuild_all_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
flash_message($lang->success_cache_reloaded, 'success');
|
||||
admin_redirect("index.php?module=tools-cache");
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->cache_manager);
|
||||
|
||||
$sub_tabs['cache_manager'] = array(
|
||||
'title' => $lang->cache_manager,
|
||||
'link' => "index.php?module=tools-cache",
|
||||
'description' => $lang->cache_manager_description
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_cache_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'cache_manager');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->name);
|
||||
$table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
$query = $db->simple_select("datacache");
|
||||
while($cacheitem = $db->fetch_array($query))
|
||||
{
|
||||
$table->construct_cell("<strong><a href=\"index.php?module=tools-cache&action=view&title=".urlencode($cacheitem['title'])."\">{$cacheitem['title']}</a></strong>");
|
||||
$table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
|
||||
|
||||
if(method_exists($cache, "update_".$cacheitem['title']))
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=rebuild&title=".urlencode($cacheitem['title'])."&my_post_key={$mybb->post_code}\">".$lang->rebuild_cache."</a>", array("class" => "align_center"));
|
||||
}
|
||||
elseif(method_exists($cache, "reload_".$cacheitem['title']))
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=".urlencode($cacheitem['title'])."&my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));
|
||||
}
|
||||
elseif(function_exists("update_".$cacheitem['title']))
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=rebuild&title=".urlencode($cacheitem['title'])."&my_post_key={$mybb->post_code}\">".$lang->rebuild_cache."</a>", array("class" => "align_center"));
|
||||
}
|
||||
elseif(function_exists("reload_".$cacheitem['title']))
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=".urlencode($cacheitem['title'])."&my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("");
|
||||
}
|
||||
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
// Rebuilds forum settings
|
||||
$cachedsettings = (array)$mybb->settings;
|
||||
if(isset($cachedsettings['internal']))
|
||||
{
|
||||
unset($cachedsettings['internal']);
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong><a href=\"index.php?module=tools-cache&action=view&title=settings\">settings</a></strong>");
|
||||
$table->construct_cell(get_friendly_size(strlen(my_serialize($cachedsettings))), array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-cache&action=reload&title=settings&my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));
|
||||
|
||||
$table->construct_row();
|
||||
|
||||
$table->output("<div style=\"float: right;\"><small><a href=\"index.php?module=tools-cache&action=rebuild_all&my_post_key={$mybb->post_code}\">".$lang->rebuild_reload_all."</a></small></div>".$lang->cache_manager);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
137
webroot/forum/admin/modules/tools/file_verification.php
Normal file
137
webroot/forum/admin/modules/tools/file_verification.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
$page->add_breadcrumb_item($lang->file_verification, "index.php?module=tools-file_verification");
|
||||
|
||||
$plugins->run_hooks("admin_tools_file_verification_begin");
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_file_verification_check");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->checking, "index.php?module=tools-file_verification");
|
||||
|
||||
$page->output_header($lang->file_verification." - ".$lang->checking);
|
||||
|
||||
$file = explode("\n", @file_get_contents("https://mybb.com/checksums/release_mybb_{$mybb->version_code}.txt"));
|
||||
|
||||
if(strstr($file[0], "<?xml") !== false || empty($file[0]))
|
||||
{
|
||||
$page->output_inline_error($lang->error_communication);
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Parser-up our checksum file from the MyBB Server
|
||||
foreach($file as $line)
|
||||
{
|
||||
$parts = explode(" ", $line, 2);
|
||||
if(empty($parts[0]) || empty($parts[1]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(substr($parts[1], 0, 7) == "./admin")
|
||||
{
|
||||
$parts[1] = "./{$mybb->config['admin_dir']}".substr($parts[1], 7);
|
||||
}
|
||||
|
||||
if(file_exists(MYBB_ROOT."forums.php") && !file_exists(MYBB_ROOT."portal.php"))
|
||||
{
|
||||
if(trim($parts[1]) == "./index.php")
|
||||
{
|
||||
$parts[1] = "./forums.php";
|
||||
}
|
||||
elseif($parts[1] == "./portal.php")
|
||||
{
|
||||
$parts[1] = "./index.php";
|
||||
}
|
||||
}
|
||||
|
||||
if(!file_exists(MYBB_ROOT."inc/plugins/hello.php") && $parts[1] == "./inc/plugins/hello.php")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!is_dir(MYBB_ROOT."install/") && substr($parts[1], 0, 10) == "./install/")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$checksums[trim($parts[1])][] = $parts[0];
|
||||
}
|
||||
|
||||
$bad_files = verify_files();
|
||||
|
||||
$plugins->run_hooks("admin_tools_file_verification_check_commit_start");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->file);
|
||||
$table->construct_header($lang->status, array("class" => "align_center", "width" => 100));
|
||||
|
||||
foreach($bad_files as $file)
|
||||
{
|
||||
switch($file['status'])
|
||||
{
|
||||
case "changed":
|
||||
$file['status'] = $lang->changed;
|
||||
$color = "#F22B48";
|
||||
break;
|
||||
case "missing":
|
||||
$file['status'] = $lang->missing;
|
||||
$color = "#5B5658";
|
||||
break;
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong><span style=\"color: {$color};\">".htmlspecialchars_uni(substr($file['path'], 2))."</span></strong>");
|
||||
|
||||
$table->construct_cell("<strong><span style=\"color: {$color};\">{$file['status']}</span></strong>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$no_errors = false;
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$no_errors = true;
|
||||
$table->construct_cell($lang->no_corrupt_files_found, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($no_errors)
|
||||
{
|
||||
$table->output($lang->file_verification.": ".$lang->no_problems_found);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output($lang->file_verification.": ".$lang->found_problems);
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$page->output_confirm_action("index.php?module=tools-file_verification", $lang->file_verification_message, $lang->file_verification);
|
||||
}
|
||||
8
webroot/forum/admin/modules/tools/index.html
Normal file
8
webroot/forum/admin/modules/tools/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
269
webroot/forum/admin/modules/tools/mailerrors.php
Normal file
269
webroot/forum/admin/modules/tools/mailerrors.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?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->system_email_log, "index.php?module=tools-mailerrors");
|
||||
|
||||
$plugins->run_hooks("admin_tools_mailerrors_begin");
|
||||
|
||||
if($mybb->input['action'] == "prune" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_mailerrors_prune");
|
||||
|
||||
if($mybb->input['delete_all'])
|
||||
{
|
||||
$db->delete_query("mailerrors");
|
||||
$num_deleted = $db->affected_rows();
|
||||
|
||||
$plugins->run_hooks("admin_tools_mailerrors_prune_delete_all_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($num_deleted);
|
||||
|
||||
flash_message($lang->all_logs_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-mailerrors");
|
||||
}
|
||||
else if(is_array($mybb->input['log']))
|
||||
{
|
||||
$log_ids = implode(",", array_map("intval", $mybb->input['log']));
|
||||
if($log_ids)
|
||||
{
|
||||
$db->delete_query("mailerrors", "eid IN ({$log_ids})");
|
||||
$num_deleted = $db->affected_rows();
|
||||
}
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($num_deleted);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_mailerrors_prune_commit");
|
||||
|
||||
flash_message($lang->selected_logs_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-mailerrors");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "view")
|
||||
{
|
||||
$query = $db->simple_select("mailerrors", "*", "eid='".$mybb->get_input('eid', MyBB::INPUT_INT)."'");
|
||||
$log = $db->fetch_array($query);
|
||||
|
||||
if(!$log['eid'])
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_mailerrors_view");
|
||||
|
||||
$log['toaddress'] = htmlspecialchars_uni($log['toaddress']);
|
||||
$log['fromaddress'] = htmlspecialchars_uni($log['fromaddress']);
|
||||
$log['subject'] = htmlspecialchars_uni($log['subject']);
|
||||
$log['error'] = htmlspecialchars_uni($log['error']);
|
||||
$log['smtperror'] = htmlspecialchars_uni($log['smtpcode']);
|
||||
$log['dateline'] = my_date('relative', $log['dateline']);
|
||||
$log['message'] = nl2br(htmlspecialchars_uni($log['message']));
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal">
|
||||
<div style="overflow-y: auto; max-height: 400px;">
|
||||
|
||||
<?php
|
||||
$table = new Table();
|
||||
|
||||
$table->construct_cell($log['error'], array("colspan" => 2));
|
||||
$table->construct_row();
|
||||
|
||||
if($log['smtpcode'])
|
||||
{
|
||||
$table->construct_cell($lang->smtp_code);
|
||||
$table->construct_cell($log['smtpcode']);
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($log['smtperror'])
|
||||
{
|
||||
$table->construct_cell($lang->smtp_server_response);
|
||||
$table->construct_cell($log['smtperror']);
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output($lang->error);
|
||||
|
||||
$table = new Table();
|
||||
|
||||
$table->construct_cell($lang->to.":");
|
||||
$table->construct_cell("<a href=\"mailto:{$log['toaddress']}\">{$log['toaddress']}</a>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->from.":");
|
||||
$table->construct_cell("<a href=\"mailto:{$log['fromaddress']}\">{$log['fromaddress']}</a>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->subject.":");
|
||||
$table->construct_cell($log['subject']);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->date.":");
|
||||
$table->construct_cell($log['dateline']);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($log['message'], array("colspan" => 2));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->email);
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$query = $db->simple_select("mailerrors l", "COUNT(eid) AS logs", "1=1 {$additional_sql_criteria}");
|
||||
$total_rows = $db->fetch_field($query, "logs");
|
||||
|
||||
$per_page = 20;
|
||||
|
||||
if($mybb->input['page'] && $mybb->input['page'] > 1)
|
||||
{
|
||||
$mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($mybb->input['page']*$per_page)-$per_page;
|
||||
$pages = ceil($total_rows / $per_page);
|
||||
if($mybb->input['page'] > $pages)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$additional_criteria = array();
|
||||
|
||||
$plugins->run_hooks("admin_tools_mailerrors_start");
|
||||
|
||||
$page->output_header($lang->system_email_log);
|
||||
|
||||
$sub_tabs['mailerrors'] = array(
|
||||
'title' => $lang->system_email_log,
|
||||
'link' => "index.php?module=tools-mailerrors",
|
||||
'description' => $lang->system_email_log_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'mailerrors');
|
||||
|
||||
$form = new Form("index.php?module=tools-mailerrors&action=prune", "post");
|
||||
|
||||
// Begin criteria filtering
|
||||
if($mybb->input['subject'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND subject LIKE '%".$db->escape_string_like($mybb->input['subject'])."%'";
|
||||
$additional_criteria[] = "subject=".htmlspecialchars_uni($mybb->input['subject']);
|
||||
$form->generate_hidden_field("subject", $mybb->input['subject']);
|
||||
}
|
||||
|
||||
if($mybb->input['fromaddress'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND fromaddress LIKE '%".$db->escape_string_like($mybb->input['fromaddress'])."%'";
|
||||
$additional_criteria[] = "fromaddress=".urlencode($mybb->input['fromaddress']);
|
||||
$form->generate_hidden_field("fromaddress", $mybb->input['fromaddress']);
|
||||
}
|
||||
|
||||
if($mybb->input['toaddress'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND toaddress LIKE '%".$db->escape_string_like($mybb->input['toaddress'])."%'";
|
||||
$additional_criteria[] = "toaddress=".urlencode($mybb->input['toaddress']);
|
||||
$form->generate_hidden_field("toaddress", $mybb->input['toaddress']);
|
||||
}
|
||||
|
||||
if($mybb->input['error'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND error LIKE '%".$db->escape_string_like($mybb->input['error'])."%'";
|
||||
$additional_criteria[] = "error=".urlencode($mybb->input['error']);
|
||||
$form->generate_hidden_field("error", $mybb->input['error']);
|
||||
}
|
||||
|
||||
if($additional_criteria)
|
||||
{
|
||||
$additional_criteria = "&".implode("&", $additional_criteria);
|
||||
}
|
||||
else
|
||||
{
|
||||
$additional_criteria = '';
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($form->generate_check_box("allbox", 1, '', array('class' => 'checkall')));
|
||||
$table->construct_header($lang->subject);
|
||||
$table->construct_header($lang->to, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->error_message, array("class" => "align_center", "width" => "30%"));
|
||||
$table->construct_header($lang->date_sent, array("class" => "align_center", "width" => "20%"));
|
||||
|
||||
$query = $db->simple_select('mailerrors', '*', "1=1 $additional_sql_criteria", array('order_by' => 'dateline', 'order_dir' => 'DESC', 'limit_start' => $start, 'limit' => $per_page));
|
||||
|
||||
while($log = $db->fetch_array($query))
|
||||
{
|
||||
$log['subject'] = htmlspecialchars_uni($log['subject']);
|
||||
$log['toemail'] = htmlspecialchars_uni($log['toemail']);
|
||||
$log['error'] = htmlspecialchars_uni($log['error']);
|
||||
$log['dateline'] = my_date('relative', $log['dateline']);
|
||||
|
||||
$table->construct_cell($form->generate_check_box("log[{$log['eid']}]", $log['eid'], ''));
|
||||
$table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-mailerrors&action=view&eid={$log['eid']}', null, true);\">{$log['subject']}</a>");
|
||||
$find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-mailerrors&toaddress={$log['toaddress']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->fine_emails_to_addr}\" alt=\"{$lang->find}\" /></a></div>";
|
||||
$table->construct_cell("{$find_from}<div>{$log['toaddress']}</div>");
|
||||
$table->construct_cell($log['error']);
|
||||
$table->construct_cell($log['dateline'], array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_logs, array("colspan" => 5));
|
||||
$table->construct_row();
|
||||
$table->output($lang->system_email_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output($lang->system_email_log);
|
||||
$buttons[] = $form->generate_submit_button($lang->delete_selected, array('onclick' => "return confirm('{$lang->confirm_delete_logs}');"));
|
||||
$buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_delete_all_logs}');"));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
}
|
||||
|
||||
$form->end();
|
||||
|
||||
echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools-mailerrors&page={page}{$additional_criteria}");
|
||||
|
||||
$form = new Form("index.php?module=tools-mailerrors", "post");
|
||||
$form_container = new FormContainer($lang->filter_system_email_log);
|
||||
$form_container->output_row($lang->subject_contains, "", $form->generate_text_box('subject', $mybb->input['subject'], array('id' => 'subject')), 'subject');
|
||||
$form_container->output_row($lang->error_message_contains, "", $form->generate_text_box('error', $mybb->input['error'], array('id' => 'error')), 'error');
|
||||
$form_container->output_row($lang->to_address_contains, "", $form->generate_text_box('toaddress', $mybb->input['toaddress'], array('id' => 'toaddress')), 'toaddress');
|
||||
$form_container->output_row($lang->from_address_contains, "", $form->generate_text_box('fromaddress', $mybb->input['fromaddress'], array('id' => 'fromaddress')), 'fromaddress');
|
||||
|
||||
$form_container->end();
|
||||
$buttons = array();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_system_email_log);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
456
webroot/forum/admin/modules/tools/maillogs.php
Normal file
456
webroot/forum/admin/modules/tools/maillogs.php
Normal file
@@ -0,0 +1,456 @@
|
||||
<?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->user_email_log, "index.php?module=tools-maillogs");
|
||||
|
||||
$plugins->run_hooks("admin_tools_maillogs_begin");
|
||||
|
||||
if($mybb->input['action'] == "prune" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_maillogs_prune");
|
||||
|
||||
if($mybb->input['delete_all'])
|
||||
{
|
||||
$db->delete_query("maillogs");
|
||||
$num_deleted = $db->affected_rows();
|
||||
|
||||
$plugins->run_hooks("admin_tools_maillogs_prune_delete_all_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($num_deleted);
|
||||
|
||||
flash_message($lang->all_logs_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-maillogs");
|
||||
}
|
||||
else if(is_array($mybb->input['log']))
|
||||
{
|
||||
$log_ids = implode(",", array_map("intval", $mybb->input['log']));
|
||||
if($log_ids)
|
||||
{
|
||||
$db->delete_query("maillogs", "mid IN ({$log_ids})");
|
||||
$num_deleted = $db->affected_rows();
|
||||
}
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($num_deleted);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_maillogs_prune_commit");
|
||||
|
||||
flash_message($lang->selected_logs_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-maillogs");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "view")
|
||||
{
|
||||
$query = $db->simple_select("maillogs", "*", "mid='".$mybb->get_input('mid', MyBB::INPUT_INT)."'");
|
||||
$log = $db->fetch_array($query);
|
||||
|
||||
if(!$log['mid'])
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_maillogs_view");
|
||||
|
||||
$log['toemail'] = htmlspecialchars_uni($log['toemail']);
|
||||
$log['fromemail'] = htmlspecialchars_uni($log['fromemail']);
|
||||
$log['subject'] = htmlspecialchars_uni($log['subject']);
|
||||
$log['dateline'] = my_date('relative', $log['dateline']);
|
||||
if($mybb->settings['mail_logging'] == 1)
|
||||
{
|
||||
$log['message'] = $lang->na;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['message'] = nl2br(htmlspecialchars_uni($log['message']));
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="modal">
|
||||
<div style="overflow-y: auto; max-height: 400px;">
|
||||
|
||||
<?php
|
||||
$table = new Table();
|
||||
|
||||
$table->construct_cell($lang->to.":");
|
||||
$table->construct_cell("<a href=\"mailto:{$log['toemail']}\">{$log['toemail']}</a>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->from.":");
|
||||
$table->construct_cell("<a href=\"mailto:{$log['fromemail']}\">{$log['fromemail']}</a>");
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->ip_address.":");
|
||||
$table->construct_cell(my_inet_ntop($db->unescape_binary($log['ipaddress'])));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->subject.":");
|
||||
$table->construct_cell($log['subject']);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->date.":");
|
||||
$table->construct_cell($log['dateline']);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($log['message'], array("colspan" => 2));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->user_email_log_viewer);
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$query = $db->simple_select("maillogs l", "COUNT(l.mid) as logs", "1=1 {$additional_sql_criteria}");
|
||||
$total_rows = $db->fetch_field($query, "logs");
|
||||
|
||||
if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
|
||||
{
|
||||
$mybb->settings['threadsperpage'] = 20;
|
||||
}
|
||||
|
||||
$per_page = $mybb->settings['threadsperpage'];
|
||||
|
||||
if(!$per_page)
|
||||
{
|
||||
$per_page = 20;
|
||||
}
|
||||
|
||||
if($mybb->input['page'] && $mybb->input['page'] > 1)
|
||||
{
|
||||
$mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($mybb->input['page']*$per_page)-$per_page;
|
||||
$pages = ceil($total_rows / $per_page);
|
||||
if($mybb->input['page'] > $pages)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$additional_criteria = array();
|
||||
|
||||
$plugins->run_hooks("admin_tools_maillogs_start");
|
||||
|
||||
// Filter form was submitted - play around with the values
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if($mybb->input['from_type'] == "user")
|
||||
{
|
||||
$mybb->input['fromname'] = $mybb->input['from_value'];
|
||||
}
|
||||
else if($mybb->input['from_type'] == "email")
|
||||
{
|
||||
$mybb->input['fromemail'] = $mybb->input['from_value'];
|
||||
}
|
||||
|
||||
if($mybb->input['to_type'] == "user")
|
||||
{
|
||||
$mybb->input['toname'] = $mybb->input['to_value'];
|
||||
}
|
||||
else if($mybb->input['to_type'] == "email")
|
||||
{
|
||||
$mybb->input['toemail'] = $mybb->input['to_value'];
|
||||
}
|
||||
}
|
||||
|
||||
$touid = $mybb->get_input('touid', MyBB::INPUT_INT);
|
||||
$toname = $db->escape_string($mybb->input['toname']);
|
||||
$toemail = $db->escape_string_like($mybb->input['toemail']);
|
||||
|
||||
$fromuid = $mybb->get_input('fromuid', MyBB::INPUT_INT);
|
||||
$fromemail = $db->escape_string_like($mybb->input['fromemail']);
|
||||
|
||||
$subject = $db->escape_string_like($mybb->input['subject']);
|
||||
|
||||
// Begin criteria filtering
|
||||
if($mybb->input['subject'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND l.subject LIKE '%{$subject}%'";
|
||||
$additional_criteria[] = "subject=".urlencode($mybb->input['subject']);
|
||||
}
|
||||
|
||||
if($mybb->input['fromuid'])
|
||||
{
|
||||
$query = $db->simple_select("users", "uid, username", "uid = '{$fromuid}'");
|
||||
$user = $db->fetch_array($query);
|
||||
$from_filter = $user['username'];
|
||||
|
||||
$additional_sql_criteria .= " AND l.fromuid = '{$fromuid}'";
|
||||
$additional_criteria[] = "fromuid={$fromuid}";
|
||||
}
|
||||
else if($mybb->input['fromname'])
|
||||
{
|
||||
$user = get_user_by_username($mybb->input['fromname'], array('fields' => 'uid, username'));
|
||||
$from_filter = $user['username'];
|
||||
|
||||
if(!$user['uid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_user, 'error');
|
||||
admin_redirect("index.php?module=tools-maillogs");
|
||||
}
|
||||
|
||||
$additional_sql_criteria .= "AND l.fromuid = '{$user['uid']}'";
|
||||
$additional_criteria[] = "fromuid={$user['uid']}";
|
||||
}
|
||||
|
||||
if($mybb->input['fromemail'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND l.fromemail LIKE '%{$fromemail}%'";
|
||||
$additional_criteria[] = "fromemail=".urlencode($mybb->input['fromemail']);
|
||||
$from_filter = $mybb->input['fromemail'];
|
||||
}
|
||||
|
||||
if($mybb->input['touid'])
|
||||
{
|
||||
$query = $db->simple_select("users", "uid, username", "uid = '{$touid}'");
|
||||
$user = $db->fetch_array($query);
|
||||
$to_filter = $user['username'];
|
||||
|
||||
$additional_sql_criteria .= " AND l.touid = '{$touid}'";
|
||||
$additional_criteria[] = "touid={$touid}";
|
||||
}
|
||||
else if($mybb->input['toname'])
|
||||
{
|
||||
$user = get_user_by_username($toname, array('fields' => 'username'));
|
||||
$to_filter = $user['username'];
|
||||
|
||||
if(!$user['uid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_user, 'error');
|
||||
admin_redirect("index.php?module=tools-maillogs");
|
||||
}
|
||||
|
||||
$additional_sql_criteria .= "AND l.touid='{$user['uid']}'";
|
||||
$additional_criteria[] = "touid={$user['uid']}";
|
||||
}
|
||||
|
||||
if($mybb->input['toemail'])
|
||||
{
|
||||
$additional_sql_criteria .= " AND l.toemail LIKE '%{$toemail}%'";
|
||||
$additional_criteria[] = "toemail=".urlencode($mybb->input['toemail']);
|
||||
$to_filter = $mybb->input['toemail'];
|
||||
}
|
||||
|
||||
if(!empty($additional_criteria))
|
||||
{
|
||||
$additional_criteria = "&".implode("&", $additional_criteria);
|
||||
}
|
||||
else
|
||||
{
|
||||
$additional_criteria = '';
|
||||
}
|
||||
|
||||
$page->output_header($lang->user_email_log);
|
||||
|
||||
$sub_tabs['maillogs'] = array(
|
||||
'title' => $lang->user_email_log,
|
||||
'link' => "index.php?module=tools-maillogs",
|
||||
'description' => $lang->user_email_log_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'maillogs');
|
||||
|
||||
$form = new Form("index.php?module=tools-maillogs&action=prune", "post");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($form->generate_check_box("allbox", 1, '', array('class' => 'checkall')));
|
||||
$table->construct_header($lang->subject, array("colspan" => 2));
|
||||
$table->construct_header($lang->from, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->to, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->date_sent, array("class" => "align_center", "width" => "20%"));
|
||||
$table->construct_header($lang->ip_address, array("class" => "align_center", 'width' => '10%'));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT l.*, r.username AS to_username, f.username AS from_username, t.subject AS thread_subject
|
||||
FROM ".TABLE_PREFIX."maillogs l
|
||||
LEFT JOIN ".TABLE_PREFIX."users r ON (r.uid=l.touid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users f ON (f.uid=l.fromuid)
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid)
|
||||
WHERE 1=1 {$additional_sql_criteria}
|
||||
ORDER BY l.dateline DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
while($log = $db->fetch_array($query))
|
||||
{
|
||||
$table->construct_cell($form->generate_check_box("log[{$log['mid']}]", $log['mid'], ''), array("width" => 1));
|
||||
$log['subject'] = htmlspecialchars_uni($log['subject']);
|
||||
$log['dateline'] = my_date('relative', $log['dateline']);
|
||||
|
||||
if($log['type'] == 2)
|
||||
{
|
||||
if($log['thread_subject'])
|
||||
{
|
||||
$log['thread_subject'] = htmlspecialchars_uni($log['thread_subject']);
|
||||
$thread_link = "<a href=\"../".get_thread_link($log['tid'])."\">".$log['thread_subject']."</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$thread_link = $lang->deleted;
|
||||
}
|
||||
$table->construct_cell("<img src=\"styles/{$page->style}/images/icons/maillogs_thread.png\" title=\"{$lang->sent_using_send_thread_feature}\" alt=\"\" />", array("width" => 1));
|
||||
$table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-maillogs&action=view&mid={$log['mid']}', null, true);\">{$log['subject']}</a><br /><small>{$lang->thread} {$thread_link}</small>");
|
||||
|
||||
if($log['fromuid'] > 0)
|
||||
{
|
||||
$find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-maillogs&fromuid={$log['fromuid']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->find_emails_by_user}\" alt=\"{$lang->find}\" /></a></div>";
|
||||
}
|
||||
|
||||
if(!$log['from_username'] && $log['fromuid'] > 0)
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div>{$lang->deleted_user}</div>");
|
||||
}
|
||||
elseif($log['fromuid'] == 0)
|
||||
{
|
||||
$log['fromemail'] = htmlspecialchars_uni($log['fromemail']);
|
||||
$table->construct_cell("{$find_from}<div>{$log['fromemail']}</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div><a href=\"../".get_profile_link($log['fromuid'])."\">{$log['from_username']}</a></div>");
|
||||
}
|
||||
|
||||
$log['toemail'] = htmlspecialchars_uni($log['toemail']);
|
||||
$table->construct_cell($log['toemail']);
|
||||
}
|
||||
elseif($log['type'] == 1)
|
||||
{
|
||||
$table->construct_cell("<img src=\"styles/{$page->style}/images/icons/maillogs_user.png\" title=\"{$lang->email_sent_to_user}\" alt=\"\" />", array("width" => 1));
|
||||
$table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-maillogs&action=view&mid={$log['mid']}', null, true);\">{$log['subject']}</a>");
|
||||
|
||||
if($log['fromuid'] > 0)
|
||||
{
|
||||
$find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-maillogs&fromuid={$log['fromuid']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->find_emails_by_user}\" alt=\"{$lang->find}\" /></a></div>";
|
||||
}
|
||||
|
||||
if(!$log['from_username'] && $log['fromuid'] > 0)
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div>{$lang->deleted_user}</div>");
|
||||
}
|
||||
elseif($log['fromuid'] == 0)
|
||||
{
|
||||
$log['fromemail'] = htmlspecialchars_uni($log['fromemail']);
|
||||
$table->construct_cell("{$find_from}<div>{$log['fromemail']}</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div><a href=\"../".get_profile_link($log['fromuid'])."\">{$log['from_username']}</a></div>");
|
||||
}
|
||||
|
||||
$find_to = "<div class=\"float_right\"><a href=\"index.php?module=tools-maillogs&touid={$log['touid']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->find_emails_to_user}\" alt=\"{$lang->find}\" /></a></div>";
|
||||
if(!$log['to_username'])
|
||||
{
|
||||
$table->construct_cell("{$find_to}<div>{$lang->deleted_user}</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("{$find_to}<div><a href=\"../".get_profile_link($log['touid'])."\">{$log['to_username']}</a></div>");
|
||||
}
|
||||
}
|
||||
elseif($log['type'] == 3)
|
||||
{
|
||||
$table->construct_cell("<img src=\"styles/{$page->style}/images/icons/maillogs_contact.png\" title=\"{$lang->email_sent_using_contact_form}\" alt=\"\" />", array("width" => 1));
|
||||
$table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-maillogs&action=view&mid={$log['mid']}', null, true);\">{$log['subject']}</a>");
|
||||
|
||||
if($log['fromuid'] > 0)
|
||||
{
|
||||
$find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-maillogs&fromuid={$log['fromuid']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->find_emails_by_user}\" alt=\"{$lang->find}\" /></a></div>";
|
||||
}
|
||||
|
||||
if(!$log['from_username'] && $log['fromuid'] > 0)
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div>{$lang->deleted_user}</div>");
|
||||
}
|
||||
elseif($log['fromuid'] == 0)
|
||||
{
|
||||
$log['fromemail'] = htmlspecialchars_uni($log['fromemail']);
|
||||
$table->construct_cell("{$find_from}<div>{$log['fromemail']}</div>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("{$find_from}<div><a href=\"../".get_profile_link($log['fromuid'])."\">{$log['from_username']}</a></div>");
|
||||
}
|
||||
|
||||
$log['toemail'] = htmlspecialchars_uni($log['toemail']);
|
||||
$table->construct_cell($log['toemail']);
|
||||
}
|
||||
|
||||
$table->construct_cell($log['dateline'], array("class" => "align_center"));
|
||||
$table->construct_cell(my_inet_ntop($db->unescape_binary($log['ipaddress'])), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_logs, array("colspan" => "7"));
|
||||
$table->construct_row();
|
||||
$table->output($lang->user_email_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output($lang->user_email_log);
|
||||
$buttons[] = $form->generate_submit_button($lang->delete_selected, array('onclick' => "return confirm('{$lang->confirm_delete_logs}');"));
|
||||
$buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_delete_all_logs}');"));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
}
|
||||
|
||||
$form->end();
|
||||
|
||||
echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools-maillogs&page={page}{$additional_criteria}");
|
||||
|
||||
$form = new Form("index.php?module=tools-maillogs", "post");
|
||||
$form_container = new FormContainer($lang->filter_user_email_log);
|
||||
$user_email = array(
|
||||
"user" => $lang->username_is,
|
||||
"email" => $lang->email_contains
|
||||
);
|
||||
$form_container->output_row($lang->subject_contains, "", $form->generate_text_box('subject', $mybb->input['subject'], array('id' => 'subject')), 'subject');
|
||||
if($from_username)
|
||||
{
|
||||
$from_type = "user";
|
||||
}
|
||||
else if($mybb->input['fromemail'])
|
||||
{
|
||||
$from_type = "email";
|
||||
}
|
||||
$form_container->output_row($lang->from, "", $form->generate_select_box('from_type', $user_email, $from_type)." ".$form->generate_text_box('from_value', htmlspecialchars_uni($from_filter), array('id' => 'from_value')), 'from_value');
|
||||
if($to_username)
|
||||
{
|
||||
$to_type = "user";
|
||||
}
|
||||
else if($mybb->input['toemail'])
|
||||
{
|
||||
$to_type = "email";
|
||||
}
|
||||
$form_container->output_row($lang->to, "", $form->generate_select_box('to_type', $user_email, $to_type)." ".$form->generate_text_box('to_value', htmlspecialchars_uni($to_filter), array('id' => 'to_value')), 'to_value');
|
||||
$form_container->end();
|
||||
$buttons = array();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_user_email_log);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
362
webroot/forum/admin/modules/tools/modlog.php
Normal file
362
webroot/forum/admin/modules/tools/modlog.php
Normal file
@@ -0,0 +1,362 @@
|
||||
<?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&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&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&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?
|
||||
if($rescount > $perpage)
|
||||
{
|
||||
echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools-modlog&perpage=$perpage&uid={$mybb->input['uid']}&fid={$mybb->input['fid']}&sortby={$mybb->input['sortby']}&order={$order}")."<br />";
|
||||
}
|
||||
|
||||
// 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'] = $lang->na_deleted;
|
||||
}
|
||||
|
||||
$selected = '';
|
||||
if($mybb->input['uid'] == $user['uid'])
|
||||
{
|
||||
$selected = "selected=\"selected\"";
|
||||
}
|
||||
$user_options[$user['uid']] = htmlspecialchars_uni($user['username']);
|
||||
}
|
||||
|
||||
$sort_by = array(
|
||||
'dateline' => $lang->date,
|
||||
'username' => $lang->username,
|
||||
'forum' => $lang->forum_name,
|
||||
'thread' => $lang->thread_subject
|
||||
);
|
||||
|
||||
$order_array = array(
|
||||
'asc' => $lang->asc,
|
||||
'desc' => $lang->desc
|
||||
);
|
||||
|
||||
$form = new Form("index.php?module=tools-modlog", "post");
|
||||
$form_container = new FormContainer($lang->filter_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');
|
||||
$form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $order_array, $order, array('id' => 'order'))." {$lang->order}", 'order');
|
||||
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $perpage, array('id' => 'perpage', 'min' => 1)), 'perpage');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_moderator_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
133
webroot/forum/admin/modules/tools/module_meta.php
Normal file
133
webroot/forum/admin/modules/tools/module_meta.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function tools_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "system_health", "title" => $lang->system_health, "link" => "index.php?module=tools-system_health");
|
||||
$sub_menu['20'] = array("id" => "cache", "title" => $lang->cache_manager, "link" => "index.php?module=tools-cache");
|
||||
$sub_menu['30'] = array("id" => "tasks", "title" => $lang->task_manager, "link" => "index.php?module=tools-tasks");
|
||||
$sub_menu['40'] = array("id" => "recount_rebuild", "title" => $lang->recount_and_rebuild, "link" => "index.php?module=tools-recount_rebuild");
|
||||
$sub_menu['50'] = array("id" => "php_info", "title" => $lang->view_php_info, "link" => "index.php?module=tools-php_info");
|
||||
$sub_menu['60'] = array("id" => "backupdb", "title" => $lang->database_backups, "link" => "index.php?module=tools-backupdb");
|
||||
$sub_menu['70'] = array("id" => "optimizedb", "title" => $lang->optimize_database, "link" => "index.php?module=tools-optimizedb");
|
||||
$sub_menu['80'] = array("id" => "file_verification", "title" => $lang->file_verification, "link" => "index.php?module=tools-file_verification");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_tools_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->tools_and_maintenance, "tools", "index.php?module=tools", 50, $sub_menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function tools_action_handler($action)
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$page->active_module = "tools";
|
||||
|
||||
$actions = array(
|
||||
'php_info' => array('active' => 'php_info', 'file' => 'php_info.php'),
|
||||
'tasks' => array('active' => 'tasks', 'file' => 'tasks.php'),
|
||||
'backupdb' => array('active' => 'backupdb', 'file' => 'backupdb.php'),
|
||||
'optimizedb' => array('active' => 'optimizedb', 'file' => 'optimizedb.php'),
|
||||
'cache' => array('active' => 'cache', 'file' => 'cache.php'),
|
||||
'recount_rebuild' => array('active' => 'recount_rebuild', 'file' => 'recount_rebuild.php'),
|
||||
'maillogs' => array('active' => 'maillogs', 'file' => 'maillogs.php'),
|
||||
'mailerrors' => array('active' => 'mailerrors', 'file' => 'mailerrors.php'),
|
||||
'adminlog' => array('active' => 'adminlog', 'file' => 'adminlog.php'),
|
||||
'modlog' => array('active' => 'modlog', 'file' => 'modlog.php'),
|
||||
'warninglog' => array('active' => 'warninglog', 'file' => 'warninglog.php'),
|
||||
'spamlog' => array('active' => 'spamlog', 'file' => 'spamlog.php'),
|
||||
'system_health' => array('active' => 'system_health', 'file' => 'system_health.php'),
|
||||
'file_verification' => array('active' => 'file_verification', 'file' => 'file_verification.php'),
|
||||
'statistics' => array('active' => 'statistics', 'file' => 'statistics.php'),
|
||||
);
|
||||
|
||||
$actions = $plugins->run_hooks("admin_tools_action_handler", $actions);
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "adminlog", "title" => $lang->administrator_log, "link" => "index.php?module=tools-adminlog");
|
||||
$sub_menu['20'] = array("id" => "modlog", "title" => $lang->moderator_log, "link" => "index.php?module=tools-modlog");
|
||||
$sub_menu['30'] = array("id" => "maillogs", "title" => $lang->user_email_log, "link" => "index.php?module=tools-maillogs");
|
||||
$sub_menu['40'] = array("id" => "mailerrors", "title" => $lang->system_mail_log, "link" => "index.php?module=tools-mailerrors");
|
||||
$sub_menu['50'] = array("id" => "warninglog", "title" => $lang->user_warning_log, "link" => "index.php?module=tools-warninglog");
|
||||
$sub_menu['60'] = array("id" => "spamlog", "title" => $lang->spam_log, "link" => "index.php?module=tools-spamlog");
|
||||
$sub_menu['70'] = array("id" => "statistics", "title" => $lang->statistics, "link" => "index.php?module=tools-statistics");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_tools_menu_logs", $sub_menu);
|
||||
|
||||
if(!isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = "system_health";
|
||||
}
|
||||
|
||||
$sidebar = new SidebarItem($lang->logs);
|
||||
$sidebar->add_menu_items($sub_menu, $actions[$action]['active']);
|
||||
|
||||
$page->sidebar .= $sidebar->get_markup();
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "system_health.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function tools_admin_permissions()
|
||||
{
|
||||
global $lang, $plugins;
|
||||
|
||||
$admin_permissions = array(
|
||||
"system_health" => $lang->can_access_system_health,
|
||||
"cache" => $lang->can_manage_cache,
|
||||
"tasks" => $lang->can_manage_tasks,
|
||||
"backupdb" => $lang->can_manage_db_backup,
|
||||
"optimizedb" => $lang->can_optimize_db,
|
||||
"recount_rebuild" => $lang->can_recount_and_rebuild,
|
||||
"adminlog" => $lang->can_manage_admin_logs,
|
||||
"modlog" => $lang->can_manage_mod_logs,
|
||||
"maillogs" => $lang->can_manage_user_mail_log,
|
||||
"mailerrors" => $lang->can_manage_system_mail_log,
|
||||
"warninglog" => $lang->can_manage_user_warning_log,
|
||||
"spamlog" => $lang->can_manage_spam_log,
|
||||
"php_info" => $lang->can_view_php_info,
|
||||
"file_verification" => $lang->can_manage_file_verification,
|
||||
"statistics" => $lang->can_view_statistics,
|
||||
);
|
||||
|
||||
$admin_permissions = $plugins->run_hooks("admin_tools_permissions", $admin_permissions);
|
||||
|
||||
return array("name" => $lang->tools_and_maintenance, "permissions" => $admin_permissions, "disporder" => 50);
|
||||
}
|
||||
|
||||
112
webroot/forum/admin/modules/tools/optimizedb.php
Normal file
112
webroot/forum/admin/modules/tools/optimizedb.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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->optimize_database, "index.php?module=tools-optimizedb");
|
||||
|
||||
$plugins->run_hooks("admin_tools_optimizedb_begin");
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_optimizedb_start");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!is_array($mybb->input['tables']))
|
||||
{
|
||||
flash_message($lang->error_no_tables_selected, 'error');
|
||||
admin_redirect("index.php?module=tools-optimizedb");
|
||||
}
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
$db->set_table_prefix('');
|
||||
|
||||
foreach($mybb->input['tables'] as $table)
|
||||
{
|
||||
if($db->table_exists($db->escape_string($table)))
|
||||
{
|
||||
$db->optimize_table($table);
|
||||
$db->analyze_table($table);
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_table_prefix(TABLE_PREFIX);
|
||||
|
||||
$plugins->run_hooks("admin_tools_optimizedb_start_begin");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action(my_serialize($mybb->input['tables']));
|
||||
|
||||
flash_message($lang->success_tables_optimized, 'success');
|
||||
admin_redirect("index.php?module=tools-optimizedb");
|
||||
}
|
||||
|
||||
$page->extra_header = " <script type=\"text/javascript\">
|
||||
function changeSelection(action, prefix)
|
||||
{
|
||||
var select_box = document.getElementById('table_select');
|
||||
|
||||
for(var i = 0; i < select_box.length; i++)
|
||||
{
|
||||
if(action == 'select')
|
||||
{
|
||||
select_box[i].selected = true;
|
||||
}
|
||||
else if(action == 'deselect')
|
||||
{
|
||||
select_box[i].selected = false;
|
||||
}
|
||||
else if(action == 'forum' && prefix != 0)
|
||||
{
|
||||
select_box[i].selected = false;
|
||||
var row = select_box[i].value;
|
||||
var subString = row.substring(prefix.length, 0);
|
||||
if(subString == prefix)
|
||||
{
|
||||
select_box[i].selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>\n";
|
||||
|
||||
$page->output_header($lang->optimize_database);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->table_selection);
|
||||
|
||||
$table_selects = array();
|
||||
$table_list = $db->list_tables($config['database']['database']);
|
||||
foreach($table_list as $id => $table_name)
|
||||
{
|
||||
$table_selects[$table_name] = $table_name;
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=tools-optimizedb", "post", "table_selection", 0, "table_selection");
|
||||
|
||||
$table->construct_cell("{$lang->tables_select_desc}\n<br /><br />\n<a href=\"javascript:changeSelection('select', 0);\">{$lang->select_all}</a><br />\n<a href=\"javascript:changeSelection('deselect', 0);\">{$lang->deselect_all}</a><br />\n<a href=\"javascript:changeSelection('forum', '".TABLE_PREFIX."');\">{$lang->select_forum_tables}</a>\n<br /><br />\n<div class=\"form_row\">".$form->generate_select_box("tables[]", $table_selects, false, array('multiple' => true, 'id' => 'table_select', 'size' => 20))."</div>", array('rowspan' => 5, 'width' => '50%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->optimize_database);
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->optimize_selected_tables);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
42
webroot/forum/admin/modules/tools/php_info.php
Normal file
42
webroot/forum/admin/modules/tools/php_info.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == 'phpinfo')
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_php_info_phpinfo");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action();
|
||||
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->php_info, "index.php?module=tools-php_info");
|
||||
|
||||
$plugins->run_hooks("admin_tools_php_info_begin");
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_php_info_start");
|
||||
|
||||
$page->output_header($lang->php_info);
|
||||
|
||||
echo "<iframe src=\"index.php?module=tools-php_info&action=phpinfo\" width=\"100%\" height=\"500\" frameborder=\"0\">{$lang->browser_no_iframe_support}</iframe>";
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
767
webroot/forum/admin/modules/tools/recount_rebuild.php
Normal file
767
webroot/forum/admin/modules/tools/recount_rebuild.php
Normal file
@@ -0,0 +1,767 @@
|
||||
<?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->recount_rebuild, "index.php?module=tools-recount_rebuild");
|
||||
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild");
|
||||
|
||||
/**
|
||||
* Rebuild forum counters
|
||||
*/
|
||||
function acp_rebuild_forum_counters()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("forums", "COUNT(*) as num_forums");
|
||||
$num_forums = $db->fetch_field($query, 'num_forums');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('forumcounters', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("forums", "fid", '', array('order_by' => 'fid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($forum = $db->fetch_array($query))
|
||||
{
|
||||
$update['parentlist'] = make_parent_list($forum['fid']);
|
||||
$db->update_query("forums", $update, "fid='{$forum['fid']}'");
|
||||
rebuild_forum_counters($forum['fid']);
|
||||
}
|
||||
|
||||
check_proceed($num_forums, $end, ++$page, $per_page, "forumcounters", "do_rebuildforumcounters", $lang->success_rebuilt_forum_counters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild thread counters
|
||||
*/
|
||||
function acp_rebuild_thread_counters()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("threads", "COUNT(*) as num_threads");
|
||||
$num_threads = $db->fetch_field($query, 'num_threads');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('threadcounters', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("threads", "tid", '', array('order_by' => 'tid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($thread = $db->fetch_array($query))
|
||||
{
|
||||
rebuild_thread_counters($thread['tid']);
|
||||
}
|
||||
|
||||
check_proceed($num_threads, $end, ++$page, $per_page, "threadcounters", "do_rebuildthreadcounters", $lang->success_rebuilt_thread_counters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild poll counters
|
||||
*/
|
||||
function acp_rebuild_poll_counters()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("polls", "COUNT(*) as num_polls");
|
||||
$num_polls = $db->fetch_field($query, 'num_polls');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('pollcounters', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("polls", "pid", '', array('order_by' => 'pid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($poll = $db->fetch_array($query))
|
||||
{
|
||||
rebuild_poll_counters($poll['pid']);
|
||||
}
|
||||
|
||||
check_proceed($num_polls, $end, ++$page, $per_page, "pollcounters", "do_rebuildpollcounters", $lang->success_rebuilt_poll_counters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount user posts
|
||||
*/
|
||||
function acp_recount_user_posts()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('userposts', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("forums", "fid", "usepostcounts = 0");
|
||||
while($forum = $db->fetch_array($query))
|
||||
{
|
||||
$fids[] = $forum['fid'];
|
||||
}
|
||||
if(is_array($fids))
|
||||
{
|
||||
$fids = implode(',', $fids);
|
||||
}
|
||||
if($fids)
|
||||
{
|
||||
$fids = " AND p.fid NOT IN($fids)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fids = "";
|
||||
}
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT COUNT(p.pid) AS post_count
|
||||
FROM ".TABLE_PREFIX."posts p
|
||||
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
|
||||
WHERE p.uid='{$user['uid']}' AND t.visible > 0 AND p.visible > 0{$fids}
|
||||
");
|
||||
$num_posts = $db->fetch_field($query2, "post_count");
|
||||
|
||||
$db->update_query("users", array("postnum" => (int)$num_posts), "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "userposts", "do_recountuserposts", $lang->success_rebuilt_user_post_counters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount user threads
|
||||
*/
|
||||
function acp_recount_user_threads()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('userthreads', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("forums", "fid", "usethreadcounts = 0");
|
||||
while($forum = $db->fetch_array($query))
|
||||
{
|
||||
$fids[] = $forum['fid'];
|
||||
}
|
||||
if(is_array($fids))
|
||||
{
|
||||
$fids = implode(',', $fids);
|
||||
}
|
||||
if($fids)
|
||||
{
|
||||
$fids = " AND t.fid NOT IN($fids)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fids = "";
|
||||
}
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT COUNT(t.tid) AS thread_count
|
||||
FROM ".TABLE_PREFIX."threads t
|
||||
WHERE t.uid='{$user['uid']}' AND t.visible > 0 AND t.closed NOT LIKE 'moved|%'{$fids}
|
||||
");
|
||||
$num_threads = $db->fetch_field($query2, "thread_count");
|
||||
|
||||
$db->update_query("users", array("threadnum" => (int)$num_threads), "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "userthreads", "do_recountuserthreads", $lang->success_rebuilt_user_thread_counters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount reputation values
|
||||
*/
|
||||
function acp_recount_reputation()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('reputation', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT SUM(reputation) as total_rep
|
||||
FROM ".TABLE_PREFIX."reputation
|
||||
WHERE uid='{$user['uid']}'
|
||||
");
|
||||
$total_rep = $db->fetch_field($query2, "total_rep");
|
||||
|
||||
$db->update_query("users", array("reputation" => (int)$total_rep), "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "reputation", "do_recountreputation", $lang->success_rebuilt_reputation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount warnings for users
|
||||
*/
|
||||
function acp_recount_warning()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('warning', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT SUM(points) as warn_lev
|
||||
FROM ".TABLE_PREFIX."warnings
|
||||
WHERE uid='{$user['uid']}' AND expired='0'
|
||||
");
|
||||
$warn_lev = $db->fetch_field($query2, "warn_lev");
|
||||
|
||||
$db->update_query("users", array("warningpoints" => (int)$warn_lev), "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "warning", "do_recountwarning", $lang->success_rebuilt_warning);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount private messages (total and unread) for users
|
||||
*/
|
||||
function acp_recount_private_messages()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('privatemessages', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
require_once MYBB_ROOT."inc/functions_user.php";
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
update_pm_count($user['uid']);
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "privatemessages", "do_recountprivatemessages", $lang->success_rebuilt_private_messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount referrals for users
|
||||
*/
|
||||
function acp_recount_referrals()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) as num_users");
|
||||
$num_users = $db->fetch_field($query, 'num_users');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('referral', MyBB::INPUT_INT);
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("users", "uid", '', array('order_by' => 'uid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT COUNT(uid) as num_referrers
|
||||
FROM ".TABLE_PREFIX."users
|
||||
WHERE referrer='{$user['uid']}'
|
||||
");
|
||||
$num_referrers = $db->fetch_field($query2, "num_referrers");
|
||||
|
||||
$db->update_query("users", array("referrals" => (int)$num_referrers), "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_users, $end, ++$page, $per_page, "referral", "do_recountreferral", $lang->success_rebuilt_referral);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount thread ratings
|
||||
*/
|
||||
function acp_recount_thread_ratings()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("threads", "COUNT(*) as num_threads");
|
||||
$num_threads = $db->fetch_field($query, 'num_threads');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('threadrating', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$query = $db->simple_select("threads", "tid", '', array('order_by' => 'tid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($thread = $db->fetch_array($query))
|
||||
{
|
||||
$query2 = $db->query("
|
||||
SELECT COUNT(tid) as num_ratings, SUM(rating) as total_rating
|
||||
FROM ".TABLE_PREFIX."threadratings
|
||||
WHERE tid='{$thread['tid']}'
|
||||
");
|
||||
$recount = $db->fetch_array($query2);
|
||||
|
||||
$db->update_query("threads", array("numratings" => (int)$recount['num_ratings'], "totalratings" => (int)$recount['total_rating']), "tid='{$thread['tid']}'");
|
||||
}
|
||||
|
||||
check_proceed($num_threads, $end, ++$page, $per_page, "threadrating", "do_recountthreadrating", $lang->success_rebuilt_thread_ratings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild thumbnails for attachments
|
||||
*/
|
||||
function acp_rebuild_attachment_thumbnails()
|
||||
{
|
||||
global $db, $mybb, $lang;
|
||||
|
||||
$query = $db->simple_select("attachments", "COUNT(aid) as num_attachments");
|
||||
$num_attachments = $db->fetch_field($query, 'num_attachments');
|
||||
|
||||
$page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$per_page = $mybb->get_input('attachmentthumbs', MyBB::INPUT_INT);
|
||||
|
||||
$start = ($page-1) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
|
||||
$uploadspath = $mybb->settings['uploadspath'];
|
||||
if(my_substr($uploadspath, 0, 1) == '.')
|
||||
{
|
||||
$uploadspath = MYBB_ROOT . $mybb->settings['uploadspath'];
|
||||
}
|
||||
|
||||
require_once MYBB_ROOT."inc/functions_image.php";
|
||||
|
||||
$query = $db->simple_select("attachments", "*", '', array('order_by' => 'aid', 'order_dir' => 'asc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($attachment = $db->fetch_array($query))
|
||||
{
|
||||
$ext = my_strtolower(my_substr(strrchr($attachment['filename'], "."), 1));
|
||||
if($ext == "gif" || $ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "jpe")
|
||||
{
|
||||
$thumbname = str_replace(".attach", "_thumb.$ext", $attachment['attachname']);
|
||||
$thumbnail = generate_thumbnail($uploadspath."/".$attachment['attachname'], $uploadspath, $thumbname, $mybb->settings['attachthumbh'], $mybb->settings['attachthumbw']);
|
||||
if($thumbnail['code'] == 4)
|
||||
{
|
||||
$thumbnail['filename'] = "SMALL";
|
||||
}
|
||||
$db->update_query("attachments", array("thumbnail" => $thumbnail['filename']), "aid='{$attachment['aid']}'");
|
||||
}
|
||||
}
|
||||
|
||||
check_proceed($num_attachments, $end, ++$page, $per_page, "attachmentthumbs", "do_rebuildattachmentthumbs", $lang->success_rebuilt_attachment_thumbnails);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $current
|
||||
* @param int $finish
|
||||
* @param int $next_page
|
||||
* @param int $per_page
|
||||
* @param string $name
|
||||
* @param string $name2
|
||||
* @param string $message
|
||||
*/
|
||||
function check_proceed($current, $finish, $next_page, $per_page, $name, $name2, $message)
|
||||
{
|
||||
global $page, $lang;
|
||||
|
||||
if($finish >= $current)
|
||||
{
|
||||
flash_message($message, 'success');
|
||||
admin_redirect("index.php?module=tools-recount_rebuild");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_header();
|
||||
|
||||
$form = new Form("index.php?module=tools-recount_rebuild", 'post');
|
||||
|
||||
echo $form->generate_hidden_field("page", $next_page);
|
||||
echo $form->generate_hidden_field($name, $per_page);
|
||||
echo $form->generate_hidden_field($name2, $lang->go);
|
||||
echo "<div class=\"confirm_action\">\n";
|
||||
echo "<p>{$lang->confirm_proceed_rebuild}</p>\n";
|
||||
echo "<br />\n";
|
||||
echo "<script type=\"text/javascript\">
|
||||
$(function() {
|
||||
var button = $(\"#proceed_button\");
|
||||
if(button.length > 0) {
|
||||
button.val(\"{$lang->automatically_redirecting}\");
|
||||
button.attr(\"disabled\", true);
|
||||
button.css(\"color\", \"#aaa\");
|
||||
button.css(\"borderColor\", \"#aaa\");
|
||||
|
||||
var parent_form = button.closest('form');
|
||||
|
||||
if (parent_form.length > 0) {
|
||||
parent_form.submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>";
|
||||
echo "<p class=\"buttons\">\n";
|
||||
echo $form->generate_submit_button($lang->proceed, array('class' => 'button_yes', 'id' => 'proceed_button'));
|
||||
echo "</p>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_start");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
require_once MYBB_ROOT."inc/functions_rebuild.php";
|
||||
|
||||
if(!isset($mybb->input['page']) || $mybb->get_input('page', MyBB::INPUT_INT) < 1)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_do_recount_rebuild");
|
||||
|
||||
if(isset($mybb->input['do_rebuildforumcounters']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_forum_counters");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("forum");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('forumcounters', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['forumcounters'] = 50;
|
||||
}
|
||||
|
||||
acp_rebuild_forum_counters();
|
||||
}
|
||||
elseif(isset($mybb->input['do_rebuildthreadcounters']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_thread_counters");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("thread");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('threadcounters', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['threadcounters'] = 500;
|
||||
}
|
||||
|
||||
acp_rebuild_thread_counters();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountuserposts']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_user_posts");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("userposts");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('userposts', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['userposts'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_user_posts();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountuserthreads']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_user_threads");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("userthreads");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('userthreads', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['userthreads'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_user_threads();
|
||||
}
|
||||
elseif(isset($mybb->input['do_rebuildattachmentthumbs']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_attachment_thumbs");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("attachmentthumbs");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('attachmentthumbs', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['attachmentthumbs'] = 500;
|
||||
}
|
||||
|
||||
acp_rebuild_attachment_thumbnails();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountreputation']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_recount_reputation");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("reputation");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('reputation', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['reputation'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_reputation();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountwarning']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_recount_warning");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("warning");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('warning', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['warning'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_warning();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountprivatemessages']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_recount_private_messages");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("privatemessages");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('privatemessages', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['privatemessages'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_private_messages();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountreferral']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_recount_referral");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("referral");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('referral', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['referral'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_referrals();
|
||||
}
|
||||
elseif(isset($mybb->input['do_recountthreadrating']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_recount_thread_ratings");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("threadrating");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('threadrating', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['threadrating'] = 500;
|
||||
}
|
||||
|
||||
acp_recount_thread_ratings();
|
||||
}
|
||||
elseif(isset($mybb->input['do_rebuildpollcounters']))
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_poll_counters");
|
||||
|
||||
if($mybb->input['page'] == 1)
|
||||
{
|
||||
// Log admin action
|
||||
log_admin_action("poll");
|
||||
}
|
||||
|
||||
$per_page = $mybb->get_input('pollcounters', MyBB::INPUT_INT);
|
||||
if(!$per_page || $per_page <= 0)
|
||||
{
|
||||
$mybb->input['pollcounters'] = 500;
|
||||
}
|
||||
|
||||
acp_rebuild_poll_counters();
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_stats");
|
||||
|
||||
$cache->update_stats();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action("stats");
|
||||
|
||||
flash_message($lang->success_rebuilt_forum_stats, 'success');
|
||||
admin_redirect("index.php?module=tools-recount_rebuild");
|
||||
}
|
||||
}
|
||||
|
||||
$page->output_header($lang->recount_rebuild);
|
||||
|
||||
$sub_tabs['recount_rebuild'] = array(
|
||||
'title' => $lang->recount_rebuild,
|
||||
'link' => "index.php?module=tools-recount_rebuild",
|
||||
'description' => $lang->recount_rebuild_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'recount_rebuild');
|
||||
|
||||
$form = new Form("index.php?module=tools-recount_rebuild", "post");
|
||||
|
||||
$form_container = new FormContainer($lang->recount_rebuild);
|
||||
$form_container->output_row_header($lang->name);
|
||||
$form_container->output_row_header($lang->data_per_page, array('width' => 50));
|
||||
$form_container->output_row_header(" ");
|
||||
|
||||
$form_container->output_cell("<label>{$lang->rebuild_forum_counters}</label><div class=\"description\">{$lang->rebuild_forum_counters_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("forumcounters", 50, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildforumcounters")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->rebuild_thread_counters}</label><div class=\"description\">{$lang->rebuild_thread_counters_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("threadcounters", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildthreadcounters")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->rebuild_poll_counters}</label><div class=\"description\">{$lang->rebuild_poll_counters_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("pollcounters", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildpollcounters")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_user_posts}</label><div class=\"description\">{$lang->recount_user_posts_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("userposts", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountuserposts")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_user_threads}</label><div class=\"description\">{$lang->recount_user_threads_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("userthreads", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountuserthreads")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->rebuild_attachment_thumbs}</label><div class=\"description\">{$lang->rebuild_attachment_thumbs_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("attachmentthumbs", 20, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_rebuildattachmentthumbs")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_stats}</label><div class=\"description\">{$lang->recount_stats_desc}</div>");
|
||||
$form_container->output_cell($lang->na);
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountstats")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_reputation}</label><div class=\"description\">{$lang->recount_reputation_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("reputation", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountreputation")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_warning}</label><div class=\"description\">{$lang->recount_warning_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("warning", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountwarning")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_private_messages}</label><div class=\"description\">{$lang->recount_private_messages_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("privatemessages", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountprivatemessages")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_referrals}</label><div class=\"description\">{$lang->recount_referrals_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("referral", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountreferral")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$form_container->output_cell("<label>{$lang->recount_thread_ratings}</label><div class=\"description\">{$lang->recount_thread_ratings_desc}</div>");
|
||||
$form_container->output_cell($form->generate_numeric_field("threadrating", 500, array('style' => 'width: 150px;', 'min' => 0)));
|
||||
$form_container->output_cell($form->generate_submit_button($lang->go, array("name" => "do_recountthreadrating")));
|
||||
$form_container->construct_row();
|
||||
|
||||
$plugins->run_hooks("admin_tools_recount_rebuild_output_list");
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
296
webroot/forum/admin/modules/tools/spamlog.php
Normal file
296
webroot/forum/admin/modules/tools/spamlog.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?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->spam_logs, "index.php?module=tools-spamlog");
|
||||
|
||||
$sub_tabs['spam_logs'] = array(
|
||||
'title' => $lang->spam_logs,
|
||||
'link' => "index.php?module=tools-spamlog",
|
||||
'description' => $lang->spam_logs_desc
|
||||
);
|
||||
$sub_tabs['prune_spam_logs'] = array(
|
||||
'title' => $lang->prune_spam_logs,
|
||||
'link' => "index.php?module=tools-spamlog&action=prune",
|
||||
'description' => $lang->prune_spam_logs_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_spamlog_begin");
|
||||
|
||||
if($mybb->input['action'] == 'prune')
|
||||
{
|
||||
if(!is_super_admin($mybb->user['uid']))
|
||||
{
|
||||
flash_message($lang->cannot_perform_action_super_admin_general, 'error');
|
||||
admin_redirect("index.php?module=tools-spamlog");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_spamlog_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 in a specific module
|
||||
if($mybb->input['filter_username'])
|
||||
{
|
||||
$where .= " AND username='".$db->escape_string($mybb->input['filter_username'])."'";
|
||||
}
|
||||
|
||||
// Searching for entries in a specific module
|
||||
if($mybb->input['filter_email'])
|
||||
{
|
||||
$where .= " AND email='".$db->escape_string($mybb->input['filter_email'])."'";
|
||||
}
|
||||
|
||||
$query = $db->delete_query("spamlog", $where);
|
||||
$num_deleted = $db->affected_rows();
|
||||
|
||||
$plugins->run_hooks("admin_tools_spamlog_prune_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['older_than'], $mybb->input['filter_username'], $mybb->input['filter_email'], $num_deleted);
|
||||
|
||||
$success = $lang->success_pruned_spam_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-spamlog');
|
||||
}
|
||||
flash_message($success, 'success');
|
||||
admin_redirect('index.php?module=tools-spamlog');
|
||||
}
|
||||
$page->add_breadcrumb_item($lang->prune_spam_logs, 'index.php?module=tools-spamlog&action=prune');
|
||||
$page->output_header($lang->prune_spam_logs);
|
||||
$page->output_nav_tabs($sub_tabs, 'prune_spam_logs');
|
||||
|
||||
// Fetch filter options
|
||||
$sortbysel[$mybb->input['sortby']] = 'selected="selected"';
|
||||
$ordersel[$mybb->input['order']] = 'selected="selected"';
|
||||
|
||||
$form = new Form("index.php?module=tools-spamlog&action=prune", "post");
|
||||
$form_container = new FormContainer($lang->prune_spam_logs);
|
||||
$form_container->output_row($lang->spam_username, "", $form->generate_text_box('filter_username', $mybb->input['filter_username'], array('id' => 'filter_username')), 'filter_username');
|
||||
$form_container->output_row($lang->spam_email, "", $form->generate_text_box('filter_email', $mybb->input['filter_email'], array('id' => 'filter_email')), 'filter_email');
|
||||
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_spam_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_spamlog_start");
|
||||
|
||||
$page->output_header($lang->spam_logs);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'spam_logs');
|
||||
|
||||
$perpage = $mybb->get_input('perpage', MyBB::INPUT_INT);
|
||||
if(!$perpage)
|
||||
{
|
||||
$perpage = 20;
|
||||
}
|
||||
|
||||
$where = '1=1';
|
||||
|
||||
$additional_criteria = array();
|
||||
|
||||
// Searching for entries witha specific username
|
||||
if($mybb->input['username'])
|
||||
{
|
||||
$where .= " AND username='".$db->escape_string($mybb->input['username'])."'";
|
||||
$additional_criteria[] = "username=".urlencode($mybb->input['username']);
|
||||
}
|
||||
|
||||
// Searching for entries with a specific email
|
||||
if($mybb->input['email'])
|
||||
{
|
||||
$where .= " AND email='".$db->escape_string($mybb->input['email'])."'";
|
||||
$additional_criteria[] = "email=".urlencode($mybb->input['email']);
|
||||
}
|
||||
|
||||
// Searching for entries with a specific IP
|
||||
if($mybb->input['ipaddress'] > 0)
|
||||
{
|
||||
$where .= " AND ipaddress=".$db->escape_binary(my_inet_pton($mybb->input['ipaddress']));
|
||||
$additional_criteria[] = "ipaddress=".urlencode($mybb->input['ipaddress']);
|
||||
}
|
||||
|
||||
if($additional_criteria)
|
||||
{
|
||||
$additional_criteria = "&".implode("&", $additional_criteria);
|
||||
}
|
||||
else
|
||||
{
|
||||
$additional_criteria = '';
|
||||
}
|
||||
|
||||
// Order?
|
||||
switch($mybb->input['sortby'])
|
||||
{
|
||||
case "username":
|
||||
$sortby = "username";
|
||||
break;
|
||||
case "email":
|
||||
$sortby = "email";
|
||||
break;
|
||||
case "ipaddress":
|
||||
$sortby = "ipaddress";
|
||||
break;
|
||||
default:
|
||||
$sortby = "dateline";
|
||||
}
|
||||
$order = $mybb->input['order'];
|
||||
if($order != "asc")
|
||||
{
|
||||
$order = "desc";
|
||||
}
|
||||
|
||||
$query = $db->simple_select("spamlog", "COUNT(sid) AS count", $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);
|
||||
}
|
||||
|
||||
$logcount = (int)$rescount;
|
||||
$pages = $logcount / $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->spam_username, array('width' => '20%'));
|
||||
$table->construct_header($lang->spam_email, array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_header($lang->spam_ip, array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_header($lang->spam_date, array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_header($lang->spam_confidence, array("class" => "align_center", 'width' => '20%'));
|
||||
|
||||
$query = $db->simple_select("spamlog", "*", $where, array('order_by' => $sortby, 'order_dir' => $order, 'limit_start' => $start, 'limit' => $perpage));
|
||||
while($row = $db->fetch_array($query))
|
||||
{
|
||||
$username = htmlspecialchars_uni($row['username']);
|
||||
$email = htmlspecialchars_uni($row['email']);
|
||||
$ip_address = my_inet_ntop($db->unescape_binary($row['ipaddress']));
|
||||
|
||||
$dateline = '';
|
||||
if($row['dateline'] > 0)
|
||||
{
|
||||
$dateline = my_date('relative', $row['dateline']);
|
||||
}
|
||||
|
||||
$confidence = '0%';
|
||||
$data = @my_unserialize($row['data']);
|
||||
if(is_array($data) && !empty($data))
|
||||
{
|
||||
if(isset($data['confidence']))
|
||||
{
|
||||
$confidence = (double)$data['confidence'].'%';
|
||||
}
|
||||
}
|
||||
|
||||
$search_sfs = "<div class=\"float_right\"><a href=\"http://www.stopforumspam.com/ipcheck/{$ip_address}\" target=\"_blank\" rel=\"noopener\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->search_ip_on_sfs}\" alt=\"{$lang->search}\" /></a></div>";
|
||||
|
||||
$table->construct_cell($username);
|
||||
$table->construct_cell($email);
|
||||
$table->construct_cell("{$search_sfs}<div>{$ip_address}</div>");
|
||||
$table->construct_cell($dateline);
|
||||
$table->construct_cell($confidence);
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_spam_logs, array("colspan" => "5"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->spam_logs);
|
||||
|
||||
// Do we need to construct the pagination?
|
||||
if($rescount > $perpage)
|
||||
{
|
||||
echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools-spamlog&perpage={$perpage}{$additional_criteria}&sortby={$mybb->input['sortby']}&order={$order}")."<br />";
|
||||
}
|
||||
|
||||
// Fetch filter options
|
||||
$sortbysel[$mybb->input['sortby']] = "selected=\"selected\"";
|
||||
$ordersel[$mybb->input['order']] = "selected=\"selected\"";
|
||||
|
||||
$sort_by = array(
|
||||
'dateline' => $lang->spam_date,
|
||||
'username' => $lang->spam_username,
|
||||
'email' => $lang->spam_email,
|
||||
'ipaddress' => $lang->spam_ip,
|
||||
);
|
||||
|
||||
$order_array = array(
|
||||
'asc' => $lang->asc,
|
||||
'desc' => $lang->desc
|
||||
);
|
||||
|
||||
$form = new Form("index.php?module=tools-spamlog", "post");
|
||||
$form_container = new FormContainer($lang->filter_spam_logs);
|
||||
$form_container->output_row($lang->spam_username, "", $form->generate_text_box('username', htmlspecialchars_uni($mybb->get_input('username')), array('id' => 'username')), 'suername');
|
||||
$form_container->output_row($lang->spam_email, "", $form->generate_text_box('email', $mybb->input['email'], array('id' => 'email')), 'email');
|
||||
$form_container->output_row($lang->spam_ip, "", $form->generate_text_box('ipaddress', $mybb->input['ipaddress'], array('id' => 'ipaddress')), 'ipaddress');
|
||||
$form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $order_array, $order, array('id' => 'order'))." {$lang->order}", 'order');
|
||||
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $perpage, array('id' => 'perpage', 'min' => 1)), 'perpage');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_spam_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
290
webroot/forum/admin/modules/tools/statistics.php
Normal file
290
webroot/forum/admin/modules/tools/statistics.php
Normal file
@@ -0,0 +1,290 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "do_graph")
|
||||
{
|
||||
$range = array(
|
||||
'start' => $mybb->get_input('start', MyBB::INPUT_INT),
|
||||
'end' => $mybb->get_input('end', MyBB::INPUT_INT)
|
||||
);
|
||||
create_graph($mybb->input['type'], $range);
|
||||
die;
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->statistics, "index.php?module=tools-statistics");
|
||||
|
||||
$sub_tabs['overall_statistics'] = array(
|
||||
'title' => $lang->overall_statistics,
|
||||
'link' => "index.php?module=tools-statistics",
|
||||
'description' => $lang->overall_statistics_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_statistics_begin");
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$query = $db->simple_select("stats", "COUNT(*) as total");
|
||||
if($db->fetch_field($query, "total") == 0)
|
||||
{
|
||||
flash_message($lang->error_no_statistics_available_yet, 'error');
|
||||
admin_redirect("index.php?module=tools");
|
||||
}
|
||||
|
||||
$per_page = 20;
|
||||
|
||||
$plugins->run_hooks("admin_tools_statistics_overall_begin");
|
||||
|
||||
// Do we have date range criteria?
|
||||
if($mybb->input['from_year'])
|
||||
{
|
||||
$start_dateline = mktime(0, 0, 0, $mybb->get_input('from_month', MyBB::INPUT_INT), $mybb->get_input('from_day', MyBB::INPUT_INT), $mybb->get_input('from_year', MyBB::INPUT_INT));
|
||||
$end_dateline = mktime(23, 59, 59, $mybb->get_input('to_month', MyBB::INPUT_INT), $mybb->get_input('to_day', MyBB::INPUT_INT), $mybb->get_input('to_year', MyBB::INPUT_INT));
|
||||
$range = "&start={$start_dateline}&end={$end_dateline}";
|
||||
}
|
||||
|
||||
// Otherwise default to the last 30 days
|
||||
if(!$mybb->input['from_year'] || $start_dateline > TIME_NOW || $end_dateline > mktime(23, 59, 59))
|
||||
{
|
||||
$start_dateline = TIME_NOW-(60*60*24*30);
|
||||
$end_dateline = TIME_NOW;
|
||||
|
||||
list($mybb->input['from_day'], $mybb->input['from_month'], $mybb->input['from_year']) = explode('-', date('j-n-Y', $start_dateline));
|
||||
list($mybb->input['to_day'], $mybb->input['to_month'], $mybb->input['to_year']) = explode('-', date('j-n-Y', $end_dateline));
|
||||
|
||||
$range = "&start={$start_dateline}&end={$end_dateline}";
|
||||
}
|
||||
|
||||
$last_dateline = 0;
|
||||
|
||||
if($mybb->input['page'] && $mybb->input['page'] > 1)
|
||||
{
|
||||
$mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($mybb->input['page']*$per_page)-$per_page;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$query = $db->simple_select("stats", "*", "dateline >= '".(int)$start_dateline."' AND dateline <= '".(int)$end_dateline."'", array('order_by' => 'dateline', 'order_dir' => 'asc'));
|
||||
|
||||
$stats = array();
|
||||
while($stat = $db->fetch_array($query))
|
||||
{
|
||||
if($last_dateline)
|
||||
{
|
||||
$stat['change_users'] = ($stat['numusers'] - $stats[$last_dateline]['numusers']);
|
||||
$stat['change_threads'] = ($stat['numthreads'] - $stats[$last_dateline]['numthreads']);
|
||||
$stat['change_posts'] = ($stat['numposts'] - $stats[$last_dateline]['numposts']);
|
||||
}
|
||||
|
||||
$stats[$stat['dateline']] = $stat;
|
||||
|
||||
$last_dateline = $stat['dateline'];
|
||||
}
|
||||
|
||||
if(empty($stats))
|
||||
{
|
||||
flash_message($lang->error_no_results_found_for_criteria, 'error');
|
||||
}
|
||||
|
||||
krsort($stats, SORT_NUMERIC);
|
||||
|
||||
$page->add_breadcrumb_item($lang->overall_statistics, "index.php?module=tools-statistics");
|
||||
|
||||
$page->output_header($lang->statistics." - ".$lang->overall_statistics);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'overall_statistics');
|
||||
|
||||
// Date range fields
|
||||
$form = new Form("index.php?module=tools-statistics", "post", "overall");
|
||||
echo "<fieldset><legend>{$lang->date_range}</legend>\n";
|
||||
echo "{$lang->from} ".$form->generate_date_select('from', $mybb->input['from_day'], $mybb->input['from_month'], $mybb->input['from_year']);
|
||||
echo " {$lang->to} ".$form->generate_date_select('to', $mybb->input['to_day'], $mybb->input['to_month'], $mybb->input['to_year']);
|
||||
echo " ".$form->generate_submit_button($lang->view);
|
||||
echo "</fieldset>\n";
|
||||
$form->end();
|
||||
|
||||
if(!empty($stats))
|
||||
{
|
||||
echo "<fieldset><legend>{$lang->users}</legend>\n";
|
||||
echo "<img src=\"index.php?module=tools-statistics&action=do_graph&type=users{$range}\" />\n";
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "<fieldset><legend>{$lang->threads}</legend>\n";
|
||||
echo "<img src=\"index.php?module=tools-statistics&action=do_graph&type=threads{$range}\" />\n";
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "<fieldset><legend>{$lang->posts}</legend>\n";
|
||||
echo "<img src=\"index.php?module=tools-statistics&action=do_graph&type=posts{$range}\" />\n";
|
||||
echo "</fieldset>\n";
|
||||
|
||||
$total_rows = count($stats);
|
||||
$pages = ceil($total_rows / $per_page);
|
||||
if($mybb->input['page'] > $pages)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->date);
|
||||
$table->construct_header($lang->users);
|
||||
$table->construct_header($lang->threads);
|
||||
$table->construct_header($lang->posts);
|
||||
$query = $db->simple_select("stats", "*", "dateline >= '".(int)$start_dateline."' AND dateline <= '".(int)$end_dateline."'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit_start' => $start, 'limit' => $per_page));
|
||||
while($stat = $db->fetch_array($query))
|
||||
{
|
||||
$table->construct_cell("<strong>".date($mybb->settings['dateformat'], $stat['dateline'])."</strong>");
|
||||
$table->construct_cell(my_number_format($stat['numusers'])." <small>".generate_growth_string($stats[$stat['dateline']]['change_users'])."</small>");
|
||||
$table->construct_cell(my_number_format($stat['numthreads'])." <small>".generate_growth_string($stats[$stat['dateline']]['change_threads'])."</small>");
|
||||
$table->construct_cell(my_number_format($stat['numposts'])." <small>".generate_growth_string($stats[$stat['dateline']]['change_posts'])."</small>");
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output($lang->overall_statistics);
|
||||
|
||||
$url_range = "&from_month=".$mybb->get_input('from_month', MyBB::INPUT_INT)."&from_day=".$mybb->get_input('from_day', MyBB::INPUT_INT)."&from_year=".$mybb->get_input('from_year', MyBB::INPUT_INT);
|
||||
$url_range .= "&to_month=".$mybb->get_input('to_month', MyBB::INPUT_INT)."&to_day=".$mybb->get_input('to_day', MyBB::INPUT_INT)."&to_year=".$mybb->get_input('to_year', MyBB::INPUT_INT);
|
||||
|
||||
echo draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools-statistics{$url_range}&page={page}");
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function generate_growth_string($number)
|
||||
{
|
||||
global $lang, $cp_style;
|
||||
|
||||
if($number === null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$number = (int)$number;
|
||||
$friendly_number = my_number_format(abs($number));
|
||||
|
||||
if($number > 0)
|
||||
{
|
||||
$growth_string = "(<img src=\"./styles/{$cp_style}/images/icons/increase.png\" alt=\"{$lang->increase}\" title=\"{$lang->increase}\" style=\"vertical-align: middle; margin-top: -2px;\" /> {$friendly_number})";
|
||||
}
|
||||
elseif($number == 0)
|
||||
{
|
||||
$growth_string = "(<img src=\"./styles/{$cp_style}/images/icons/no_change.png\" alt=\"{$lang->no_change}\" title=\"{$lang->no_change}\" style=\"vertical-align: middle; margin-top: -2px;\" /> {$friendly_number})";
|
||||
}
|
||||
else
|
||||
{
|
||||
$growth_string = "(<img src=\"./styles/{$cp_style}/images/icons/decrease.png\" alt=\"{$lang->decrease}\" title=\"{$lang->decrease}\" style=\"vertical-align: middle; margin-top: -2px;\" /> {$friendly_number})";
|
||||
}
|
||||
|
||||
return $growth_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type users, threads, posts
|
||||
* @param array $range
|
||||
*/
|
||||
function create_graph($type, $range=null)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Do we have date range criteria?
|
||||
if($range['end'] || $range['start'])
|
||||
{
|
||||
$start = (int)$range['start'];
|
||||
$end = (int)$range['end'];
|
||||
}
|
||||
// Otherwise default to the last 30 days
|
||||
else
|
||||
{
|
||||
$start = TIME_NOW-(60*60*24*30);
|
||||
$end = TIME_NOW;
|
||||
}
|
||||
|
||||
$allowed_types = array('users', 'threads', 'posts');
|
||||
if(!in_array($type, $allowed_types))
|
||||
{
|
||||
die;
|
||||
}
|
||||
|
||||
require_once MYBB_ROOT.'inc/class_graph.php';
|
||||
|
||||
$points = $stats = $datelines = array();
|
||||
if($start == 0)
|
||||
{
|
||||
$query = $db->simple_select("stats", "dateline,num{$type}", "dateline <= '".(int)$end."'", array('order_by' => 'dateline', 'order_dir' => 'desc', 'limit' => 2));
|
||||
while($stat = $db->fetch_array($query))
|
||||
{
|
||||
$stats[] = $stat['num'.$type];
|
||||
$datelines[] = $stat['dateline'];
|
||||
$x_labels[] = date("m/j", $stat['dateline']);
|
||||
}
|
||||
$points[$datelines[0]] = 0;
|
||||
$points[$datelines[1]] = $stats[0]-$stats[1];
|
||||
ksort($points, SORT_NUMERIC);
|
||||
}
|
||||
elseif($end == 0)
|
||||
{
|
||||
$query = $db->simple_select("stats", "dateline,num{$type}", "dateline >= '".(int)$start."'", array('order_by' => 'dateline', 'order_dir' => 'asc', 'limit' => 2));
|
||||
while($stat = $db->fetch_array($query))
|
||||
{
|
||||
$stats[] = $stat['num'.$type];
|
||||
$datelines[] = $stat['dateline'];
|
||||
$x_labels[] = date("m/j", $stat['dateline']);
|
||||
}
|
||||
$points[$datelines[0]] = 0;
|
||||
$points[$datelines[1]] = $stats[1]-$stats[0];
|
||||
ksort($points, SORT_NUMERIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("stats", "dateline,num{$type}", "dateline >= '".(int)$start."' AND dateline <= '".(int)$end."'", array('order_by' => 'dateline', 'order_dir' => 'asc'));
|
||||
while($stat = $db->fetch_array($query))
|
||||
{
|
||||
$points[$stat['dateline']] = $stat['num'.$type];
|
||||
$datelines[] = $stat['dateline'];
|
||||
$x_labels[] = date("m/j", $stat['dateline']);
|
||||
}
|
||||
}
|
||||
|
||||
sort($datelines, SORT_NUMERIC);
|
||||
|
||||
// Find our year(s) label
|
||||
$start_year = date('Y', $datelines[0]);
|
||||
$last_year = date('Y', $datelines[count($datelines)-1]);
|
||||
if(($last_year - $start_year) == 0)
|
||||
{
|
||||
$bottom_label = $start_year;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bottom_label = $start_year." - ".$last_year;
|
||||
}
|
||||
|
||||
// Create the graph outline
|
||||
$graph = new Graph();
|
||||
$graph->add_points(array_values($points));
|
||||
$graph->add_x_labels($x_labels);
|
||||
$graph->set_bottom_label($bottom_label);
|
||||
$graph->render();
|
||||
$graph->output();
|
||||
}
|
||||
981
webroot/forum/admin/modules/tools/system_health.php
Normal file
981
webroot/forum/admin/modules/tools/system_health.php
Normal file
@@ -0,0 +1,981 @@
|
||||
<?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->system_health, "index.php?module=tools-system_health");
|
||||
|
||||
$sub_tabs['system_health'] = array(
|
||||
'title' => $lang->system_health,
|
||||
'link' => "index.php?module=tools-system_health",
|
||||
'description' => $lang->system_health_desc
|
||||
);
|
||||
|
||||
$sub_tabs['utf8_conversion'] = array(
|
||||
'title' => $lang->utf8_conversion,
|
||||
'link' => "index.php?module=tools-system_health&action=utf8_conversion",
|
||||
'description' => $lang->utf8_conversion_desc2
|
||||
);
|
||||
|
||||
$sub_tabs['template_check'] = array(
|
||||
'title' => $lang->check_templates,
|
||||
'link' => "index.php?module=tools-system_health&action=check_templates",
|
||||
'description' => $lang->check_templates_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_begin");
|
||||
|
||||
if($mybb->input['action'] == "do_check_templates" && $mybb->request_method == "post")
|
||||
{
|
||||
$query = $db->simple_select("templates", "*", "", array("order_by" => "sid, title", "order_dir" => "ASC"));
|
||||
|
||||
if(!$db->num_rows($query))
|
||||
{
|
||||
flash_message($lang->error_invalid_input, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_template_do_check_start");
|
||||
|
||||
$t_cache = array();
|
||||
while($template = $db->fetch_array($query))
|
||||
{
|
||||
if(check_template($template['template']) == true)
|
||||
{
|
||||
$t_cache[$template['sid']][] = $template;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($t_cache))
|
||||
{
|
||||
flash_message($lang->success_templates_checked, 'success');
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_template_do_check");
|
||||
|
||||
$page->add_breadcrumb_item($lang->check_templates);
|
||||
$page->output_header($lang->check_templates);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'template_check');
|
||||
$page->output_inline_error(array($lang->check_templates_info_desc));
|
||||
|
||||
$templatesets = array(
|
||||
-2 => array(
|
||||
"title" => "MyBB Master Templates"
|
||||
)
|
||||
);
|
||||
$query = $db->simple_select("templatesets", "*");
|
||||
while($set = $db->fetch_array($query))
|
||||
{
|
||||
$templatesets[$set['sid']] = $set;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach($t_cache as $sid => $templates)
|
||||
{
|
||||
if(!$done_set[$sid])
|
||||
{
|
||||
$table = new Table();
|
||||
$table->construct_header($templatesets[$sid]['title'], array("colspan" => 2));
|
||||
|
||||
$done_set[$sid] = 1;
|
||||
++$count;
|
||||
}
|
||||
|
||||
if($sid == -2)
|
||||
{
|
||||
// Some cheeky clown has altered the master templates!
|
||||
$table->construct_cell($lang->error_master_templates_altered, array("colspan" => 2));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
foreach($templates as $template)
|
||||
{
|
||||
if($sid == -2)
|
||||
{
|
||||
$table->construct_cell($template['title'], array('colspan' => 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup = new PopupMenu("template_{$template['tid']}", $lang->options);
|
||||
$popup->add_item($lang->full_edit, "index.php?module=style-templates&action=edit_template&title=".urlencode($template['title'])."&sid={$sid}");
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=style-templates&action=edit_template&title=".urlencode($template['title'])."&sid={$sid}&from=diff_report\">{$template['title']}</a>", array('width' => '80%'));
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
}
|
||||
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($done_set[$sid] && !$done_output[$sid])
|
||||
{
|
||||
$done_output[$sid] = 1;
|
||||
if($count == 1)
|
||||
{
|
||||
$table->output($lang->check_templates);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "check_templates")
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->check_templates);
|
||||
$page->output_header($lang->check_templates);
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_template_check");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'template_check');
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=tools-system_health", "post", "check_set");
|
||||
echo $form->generate_hidden_field("action", "do_check_templates");
|
||||
|
||||
$form_container = new FormContainer($lang->check_templates);
|
||||
$form_container->output_row($lang->check_templates_title, "", $lang->check_templates_info);
|
||||
$form_container->end();
|
||||
|
||||
$buttons = array();
|
||||
$buttons[] = $form->generate_submit_button($lang->proceed);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "utf8_conversion")
|
||||
{
|
||||
if($db->type == "sqlite" || $db->type == "pgsql")
|
||||
{
|
||||
flash_message($lang->error_not_supported, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_utf8_conversion");
|
||||
|
||||
if($mybb->request_method == "post" || ($mybb->input['do'] == "all" && !empty($mybb->input['table'])))
|
||||
{
|
||||
if(!empty($mybb->input['mb4']) && version_compare($db->get_version(), '5.5.3', '<'))
|
||||
{
|
||||
flash_message($lang->error_utf8mb4_version, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
|
||||
}
|
||||
@set_time_limit(0);
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
if(!$db->table_exists($db->escape_string($mybb->input['table'])))
|
||||
{
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
flash_message($lang->error_invalid_table, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
|
||||
}
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&action=utf8_conversion");
|
||||
|
||||
$page->output_header($lang->system_health." - ".$lang->utf8_conversion);
|
||||
|
||||
$sub_tabs['system_health'] = array(
|
||||
'title' => $lang->system_health,
|
||||
'link' => "index.php?module=tools-system_health",
|
||||
'description' => $lang->system_health_desc
|
||||
);
|
||||
|
||||
$sub_tabs['utf8_conversion'] = array(
|
||||
'title' => $lang->utf8_conversion,
|
||||
'link' => "index.php?module=tools-system_health&action=utf8_conversion",
|
||||
'description' => $lang->utf8_conversion_desc2
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'utf8_conversion');
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
$table = new Table;
|
||||
|
||||
$table1 = $db->show_create_table($db->escape_string($mybb->input['table']));
|
||||
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table1, $matches);
|
||||
$charset = $matches[1];
|
||||
|
||||
if(!empty($mybb->input['mb4']))
|
||||
{
|
||||
$table->construct_cell("<strong>".$lang->sprintf($lang->converting_to_utf8mb4, $mybb->input['table'], $charset)."</strong>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong>".$lang->sprintf($lang->converting_to_utf8, $mybb->input['table'], $charset)."</strong>");
|
||||
}
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->please_wait);
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($converting_table." {$mybb->input['table']}");
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$page->output_footer(false);
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
flush();
|
||||
|
||||
$types = array(
|
||||
'text' => 'blob',
|
||||
'mediumtext' => 'mediumblob',
|
||||
'longtext' => 'longblob',
|
||||
'char' => 'varbinary',
|
||||
'varchar' => 'varbinary',
|
||||
'tinytext' => 'tinyblob'
|
||||
);
|
||||
|
||||
$blob_types = array( 'blob', 'tinyblob', 'mediumblog', 'longblob', 'text', 'tinytext', 'mediumtext', 'longtext' );
|
||||
|
||||
// Get next table in list
|
||||
$convert_to_binary = '';
|
||||
$convert_to_utf8 = '';
|
||||
$comma = '';
|
||||
|
||||
if(!empty($mybb->input['mb4']))
|
||||
{
|
||||
$character_set = 'utf8mb4';
|
||||
$collation = 'utf8mb4_general_ci';
|
||||
}
|
||||
else
|
||||
{
|
||||
$character_set = 'utf8';
|
||||
$collation = 'utf8_general_ci';
|
||||
}
|
||||
|
||||
// Set table default charset
|
||||
$db->write_query("ALTER TABLE {$mybb->input['table']} DEFAULT CHARACTER SET {$character_set} COLLATE {$collation}");
|
||||
|
||||
// Fetch any fulltext keys
|
||||
if($db->supports_fulltext($mybb->input['table']))
|
||||
{
|
||||
$table_structure = $db->show_create_table($mybb->input['table']);
|
||||
switch($db->type)
|
||||
{
|
||||
case "mysql":
|
||||
case "mysqli":
|
||||
preg_match_all("#FULLTEXT KEY `?([a-zA-Z0-9_]+)`? \(([a-zA-Z0-9_`,']+)\)#i", $table_structure, $matches);
|
||||
if(is_array($matches))
|
||||
{
|
||||
foreach($matches[0] as $key => $matched)
|
||||
{
|
||||
$db->write_query("ALTER TABLE {$mybb->input['table']} DROP INDEX {$matches[1][$key]}");
|
||||
$fulltext_to_create[$matches[1][$key]] = $matches[2][$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find out which columns need converting and build SQL statements
|
||||
$query = $db->query("SHOW FULL COLUMNS FROM {$mybb->input['table']}");
|
||||
while($column = $db->fetch_array($query))
|
||||
{
|
||||
list($type) = explode('(', $column['Type']);
|
||||
if(array_key_exists($type, $types))
|
||||
{
|
||||
// Build the actual strings for converting the columns
|
||||
$names = "CHANGE `{$column['Field']}` `{$column['Field']}` ";
|
||||
|
||||
if(($db->type == 'mysql' || $db->type == 'mysqli') && in_array($type, $blob_types))
|
||||
{
|
||||
if($column['Null'] == 'YES')
|
||||
{
|
||||
$attributes = 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = 'NOT NULL';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes = " DEFAULT ";
|
||||
if($column['Default'] == 'NULL')
|
||||
{
|
||||
$attributes .= "NULL ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes .= "'".$db->escape_string($column['Default'])."' ";
|
||||
|
||||
if($column['Null'] == 'YES')
|
||||
{
|
||||
$attributes .= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$attributes .= 'NOT NULL';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$convert_to_binary .= $comma.$names.preg_replace('/'.$type.'/i', $types[$type], $column['Type']).' '.$attributes;
|
||||
$convert_to_utf8 .= "{$comma}{$names}{$column['Type']} CHARACTER SET {$character_set} COLLATE {$collation} {$attributes}";
|
||||
|
||||
$comma = ',';
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($convert_to_binary))
|
||||
{
|
||||
// This converts the columns to UTF-8 while also doing the same for data
|
||||
$db->write_query("ALTER TABLE {$mybb->input['table']} {$convert_to_binary}");
|
||||
$db->write_query("ALTER TABLE {$mybb->input['table']} {$convert_to_utf8}");
|
||||
}
|
||||
|
||||
// Any fulltext indexes to recreate?
|
||||
if(is_array($fulltext_to_create))
|
||||
{
|
||||
foreach($fulltext_to_create as $name => $fields)
|
||||
{
|
||||
$db->create_fulltext_index($mybb->input['table'], $fields, $name);
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_utf8_conversion_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($mybb->input['table']);
|
||||
|
||||
flash_message($lang->sprintf($lang->success_table_converted, $mybb->input['table']), 'success');
|
||||
|
||||
if($mybb->input['do'] == "all")
|
||||
{
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
$tables = $db->list_tables($mybb->config['database']['database']);
|
||||
foreach($tables as $key => $tablename)
|
||||
{
|
||||
if(substr($tablename, 0, strlen(TABLE_PREFIX)) == TABLE_PREFIX)
|
||||
{
|
||||
$table = $db->show_create_table($tablename);
|
||||
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
|
||||
if(empty($mybb->input['mb4']) && (fetch_iconv_encoding($matches[1]) == 'utf-8' || $matches[1] == 'utf8mb4') && $mybb->input['table'] != $tablename)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
elseif(!empty($mybb->input['mb4']) && fetch_iconv_encoding($matches[1]) != 'utf-8' && $mybb->input['table'] != $tablename)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$mybb_tables[$key] = $tablename;
|
||||
}
|
||||
}
|
||||
|
||||
asort($mybb_tables);
|
||||
reset($mybb_tables);
|
||||
|
||||
$is_next = false;
|
||||
$nexttable = "";
|
||||
|
||||
foreach($mybb_tables as $key => $tablename)
|
||||
{
|
||||
if($is_next == true)
|
||||
{
|
||||
$nexttable = $tablename;
|
||||
break;
|
||||
}
|
||||
else if($mybb->input['table'] == $tablename)
|
||||
{
|
||||
$is_next = true;
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
if($nexttable)
|
||||
{
|
||||
$nexttable = $db->escape_string($nexttable);
|
||||
$mb4 = '';
|
||||
if(!empty($mybb->input['mb4']))
|
||||
{
|
||||
$mb4 = "&mb4=1";
|
||||
}
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion&do=all&table={$nexttable}{$mb4}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if($mybb->input['table'] || $mybb->input['do'] == "all")
|
||||
{
|
||||
if(!empty($mybb->input['mb4']) && version_compare($db->get_version(), '5.5.3', '<'))
|
||||
{
|
||||
flash_message($lang->error_utf8mb4_version, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
|
||||
}
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
if($mybb->input['do'] != "all" && !$db->table_exists($db->escape_string($mybb->input['table'])))
|
||||
{
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
flash_message($lang->error_invalid_table, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
|
||||
}
|
||||
|
||||
if($mybb->input['do'] == "all")
|
||||
{
|
||||
$tables = $db->list_tables($mybb->config['database']['database']);
|
||||
foreach($tables as $key => $tablename)
|
||||
{
|
||||
if(substr($tablename, 0, strlen(TABLE_PREFIX)) == TABLE_PREFIX)
|
||||
{
|
||||
$table = $db->show_create_table($tablename);
|
||||
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
|
||||
if(empty($mybb->input['mb4']) && (fetch_iconv_encoding($matches[1]) == 'utf-8' || $matches[1] == 'utf8mb4'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
elseif(!empty($mybb->input['mb4']) && fetch_iconv_encoding($matches[1]) != 'utf-8')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$mybb_tables[$key] = $tablename;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($mybb_tables))
|
||||
{
|
||||
asort($mybb_tables);
|
||||
reset($mybb_tables);
|
||||
$nexttable = current($mybb_tables);
|
||||
$table = $db->show_create_table($db->escape_string($nexttable));
|
||||
$mybb->input['table'] = $nexttable;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
flash_message($lang->success_all_tables_already_converted, 'success');
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = $db->show_create_table($db->escape_string($mybb->input['table']));
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&action=utf8_conversion");
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$page->output_header($lang->system_health." - ".$lang->utf8_conversion);
|
||||
|
||||
$sub_tabs['system_health'] = array(
|
||||
'title' => $lang->system_health,
|
||||
'link' => "index.php?module=tools-system_health",
|
||||
'description' => $lang->system_health_desc
|
||||
);
|
||||
|
||||
$sub_tabs['utf8_conversion'] = array(
|
||||
'title' => $lang->utf8_conversion,
|
||||
'link' => "index.php?module=tools-system_health&action=utf8_conversion",
|
||||
'description' => $lang->utf8_conversion_desc2
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'utf8_conversion');
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
|
||||
$charset = $matches[1];
|
||||
|
||||
$mb4 = '';
|
||||
if(!empty($mybb->input['mb4']))
|
||||
{
|
||||
$mb4 = "&mb4=1";
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=tools-system_health&action=utf8_conversion{$mb4}", "post", "utf8_conversion");
|
||||
echo $form->generate_hidden_field("table", $mybb->input['table']);
|
||||
|
||||
if($mybb->input['do'] == "all")
|
||||
{
|
||||
echo $form->generate_hidden_field("do", "all");
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
|
||||
if(!empty($mybb->input['mb4']))
|
||||
{
|
||||
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_all_to_utf8mb4, $charset)."</strong>");
|
||||
$lang->notice_process_long_time .= "<br /><br /><strong>{$lang->notice_mb4_warning}</strong>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if($mybb->input['do'] == "all")
|
||||
{
|
||||
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_all_to_utf, $charset)."</strong>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_to_utf8, $mybb->input['table'], $charset)."</strong>");
|
||||
}
|
||||
}
|
||||
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell($lang->notice_process_long_time);
|
||||
$table->construct_row();
|
||||
|
||||
if($mybb->input['do'] == "all")
|
||||
{
|
||||
$table->output($lang->convert_tables);
|
||||
$buttons[] = $form->generate_submit_button($lang->convert_database_tables);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output($lang->convert_table.": {$mybb->input['table']}");
|
||||
$buttons[] = $form->generate_submit_button($lang->convert_database_table);
|
||||
}
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
|
||||
$form->end();
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$page->output_footer();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$mybb->config['database']['encoding'])
|
||||
{
|
||||
flash_message($lang->error_db_encoding_not_set, 'error');
|
||||
admin_redirect("index.php?module=tools-system_health");
|
||||
}
|
||||
|
||||
$tables = $db->list_tables($mybb->config['database']['database']);
|
||||
|
||||
$old_table_prefix = $db->table_prefix;
|
||||
$db->set_table_prefix('');
|
||||
|
||||
$encodings = array();
|
||||
|
||||
foreach($tables as $key => $tablename)
|
||||
{
|
||||
if(substr($tablename, 0, strlen($old_table_prefix)) == $old_table_prefix)
|
||||
{
|
||||
$table = $db->show_create_table($tablename);
|
||||
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
|
||||
$encodings[$key] = fetch_iconv_encoding($matches[1]);
|
||||
$mybb_tables[$key] = $tablename;
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_table_prefix($old_table_prefix);
|
||||
|
||||
$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&action=utf8_conversion");
|
||||
|
||||
$page->output_header($lang->system_health." - ".$lang->utf8_conversion);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'utf8_conversion');
|
||||
|
||||
asort($mybb_tables);
|
||||
|
||||
$unique = array_unique($encodings);
|
||||
|
||||
$convert_utf8 = $convert_utf8mb4 = false;
|
||||
foreach($unique as $encoding)
|
||||
{
|
||||
if($encoding == 'utf-8')
|
||||
{
|
||||
$convert_utf8mb4 = true;
|
||||
}
|
||||
elseif($encoding != 'utf8mb4')
|
||||
{
|
||||
$convert_utf8 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($unique) > 1)
|
||||
{
|
||||
$page->output_error("<p><em>{$lang->warning_multiple_encodings}</em></p>");
|
||||
}
|
||||
|
||||
if(in_array('utf8mb4', $unique) && $mybb->config['database']['encoding'] != 'utf8mb4')
|
||||
{
|
||||
$page->output_error("<p><em>{$lang->warning_utf8mb4_config}</em></p>");
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->table);
|
||||
$table->construct_header($lang->status_utf8, array("class" => "align_center"));
|
||||
$table->construct_header($lang->status_utf8mb4, array("class" => "align_center"));
|
||||
|
||||
$all_utf8 = $all_utf8mb4 = '-';
|
||||
if($convert_utf8)
|
||||
{
|
||||
$all_utf8 = "<strong><a href=\"index.php?module=tools-system_health&action=utf8_conversion&do=all\">{$lang->convert_all}</a></strong>";
|
||||
}
|
||||
if($convert_utf8mb4)
|
||||
{
|
||||
$all_utf8mb4 = "<strong><a href=\"index.php?module=tools-system_health&action=utf8_conversion&do=all&mb4=1\">{$lang->convert_all}</a></strong>";
|
||||
}
|
||||
$table->construct_cell("<strong>{$lang->all_tables}</strong>");
|
||||
$table->construct_cell($all_utf8, array("class" => "align_center", 'width' => '15%'));
|
||||
$table->construct_cell($all_utf8mb4, array("class" => "align_center", 'width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
$db_version = $db->get_version();
|
||||
|
||||
foreach($mybb_tables as $key => $tablename)
|
||||
{
|
||||
if($encodings[$key] != 'utf-8' && $encodings[$key] != 'utf8mb4')
|
||||
{
|
||||
$status = "<a href=\"index.php?module=tools-system_health&action=utf8_conversion&table={$tablename}\" style=\"background: url(styles/{$page->style}/images/icons/cross.png) no-repeat; padding-left: 20px;\">{$lang->convert_now}</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = "<img src=\"styles/{$page->style}/images/icons/tick.png\" alt=\"{$lang->ok}\" />";
|
||||
}
|
||||
if(version_compare($db_version, '5.5.3', '<'))
|
||||
{
|
||||
$utf8mb4 = $lang->not_available;
|
||||
}
|
||||
elseif($encodings[$key] == 'utf8mb4')
|
||||
{
|
||||
$utf8mb4 = "<img src=\"styles/{$page->style}/images/icons/tick.png\" alt=\"{$lang->ok}\" />";
|
||||
}
|
||||
elseif($encodings[$key] == 'utf-8')
|
||||
{
|
||||
$utf8mb4 = "<a href=\"index.php?module=tools-system_health&action=utf8_conversion&table={$tablename}&mb4=1\" style=\"background: url(styles/{$page->style}/images/icons/cross.png) no-repeat; padding-left: 20px;\">{$lang->convert_now}</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$utf8mb4 = "-";
|
||||
}
|
||||
$table->construct_cell("<strong>{$tablename}</strong>");
|
||||
$table->construct_cell($status, array("class" => "align_center", 'width' => '15%'));
|
||||
$table->construct_cell($utf8mb4, array("class" => "align_center", 'width' => '25%'));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output("<div>{$lang->utf8_conversion}</div>");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->system_health);
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'system_health');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->totals, array("colspan" => 2));
|
||||
$table->construct_header($lang->attachments, array("colspan" => 2));
|
||||
|
||||
$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused, SUM(downloads*filesize) as bandwidthused", "visible='1' AND pid > '0'");
|
||||
$attachs = $db->fetch_array($query);
|
||||
|
||||
$table->construct_cell("<strong>{$lang->total_database_size}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell(get_friendly_size($db->fetch_size()), array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->attachment_space_used}</strong>", array('width' => '200'));
|
||||
$table->construct_cell(get_friendly_size((int)$attachs['spaceused']), array('width' => '200'));
|
||||
$table->construct_row();
|
||||
|
||||
if($attachs['spaceused'] > 0)
|
||||
{
|
||||
$attach_average_size = round($attachs['spaceused']/$attachs['numattachs']);
|
||||
$bandwidth_average_usage = round($attachs['bandwidthused']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$attach_average_size = 0;
|
||||
$bandwidth_average_usage = 0;
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong>{$lang->total_cache_size}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell(get_friendly_size($cache->size_of()), array('width' => '25%'));
|
||||
$table->construct_cell("<strong>{$lang->estimated_attachment_bandwidth_usage}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell(get_friendly_size($bandwidth_average_usage), array('width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
|
||||
$table->construct_cell("<strong>{$lang->max_upload_post_size}</strong>", array('width' => '200'));
|
||||
$table->construct_cell(@ini_get('upload_max_filesize').' / '.@ini_get('post_max_size'), array('width' => '200'));
|
||||
$table->construct_cell("<strong>{$lang->average_attachment_size}</strong>", array('width' => '25%'));
|
||||
$table->construct_cell(get_friendly_size($attach_average_size), array('width' => '25%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output($lang->stats);
|
||||
|
||||
$table->construct_header($lang->task);
|
||||
$table->construct_header($lang->run_time, array("width" => 200, "class" => "align_center"));
|
||||
|
||||
$task_cache = $cache->read("tasks");
|
||||
$nextrun = $task_cache['nextrun'];
|
||||
|
||||
$query = $db->simple_select("tasks", "*", "nextrun >= '{$nextrun}' AND enabled='1'", array("order_by" => "nextrun", "order_dir" => "asc", 'limit' => 3));
|
||||
while($task = $db->fetch_array($query))
|
||||
{
|
||||
$task['title'] = htmlspecialchars_uni($task['title']);
|
||||
$next_run = my_date('normal', $task['nextrun'], "", 2);
|
||||
$table->construct_cell("<strong>{$task['title']}</strong>");
|
||||
$table->construct_cell($next_run, array("class" => "align_center"));
|
||||
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_tasks, array('colspan' => 2));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->next_3_tasks);
|
||||
|
||||
if(isset($mybb->admin['permissions']['tools']['backupdb']) && $mybb->admin['permissions']['tools']['backupdb'] == 1)
|
||||
{
|
||||
$backups = array();
|
||||
$dir = MYBB_ADMIN_DIR.'backups/';
|
||||
$handle = opendir($dir);
|
||||
while(($file = readdir($handle)) !== false)
|
||||
{
|
||||
if(filetype(MYBB_ADMIN_DIR.'backups/'.$file) == 'file')
|
||||
{
|
||||
$ext = get_extension($file);
|
||||
if($ext == 'gz' || $ext == 'sql')
|
||||
{
|
||||
$backups[@filemtime(MYBB_ADMIN_DIR.'backups/'.$file)] = array(
|
||||
"file" => $file,
|
||||
"time" => @filemtime(MYBB_ADMIN_DIR.'backups/'.$file),
|
||||
"type" => $ext
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$count = count($backups);
|
||||
krsort($backups);
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->name);
|
||||
$table->construct_header($lang->backup_time, array("width" => 200, "class" => "align_center"));
|
||||
|
||||
$backupscnt = 0;
|
||||
foreach($backups as $backup)
|
||||
{
|
||||
++$backupscnt;
|
||||
|
||||
if($backupscnt == 4)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$time = "-";
|
||||
if($backup['time'])
|
||||
{
|
||||
$time = my_date('relative', $backup['time']);
|
||||
}
|
||||
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-backupdb&action=dlbackup&file={$backup['file']}\">{$backup['file']}</a>");
|
||||
$table->construct_cell($time, array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($count == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_backups, array('colspan' => 2));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->existing_db_backups);
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.'inc/settings.php'))
|
||||
{
|
||||
$message_settings = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_settings = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.'inc/config.php'))
|
||||
{
|
||||
$message_config = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_config = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
$uploadspath = $mybb->settings['uploadspath'];
|
||||
if(my_substr($uploadspath, 0, 1) == '.')
|
||||
{
|
||||
$uploadspath = MYBB_ROOT . $mybb->settings['uploadspath'];
|
||||
}
|
||||
if(is_writable($uploadspath))
|
||||
{
|
||||
$message_upload = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_upload = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
$avataruploadpath = $mybb->settings['avataruploadpath'];
|
||||
if(my_substr($avataruploadpath, 0, 1) == '.')
|
||||
{
|
||||
$avataruploadpath = MYBB_ROOT . $mybb->settings['avataruploadpath'];
|
||||
}
|
||||
if(is_writable($avataruploadpath))
|
||||
{
|
||||
$message_avatar = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_avatar = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.'inc/languages/'))
|
||||
{
|
||||
$message_language = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_language = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.$config['admin_dir'].'/backups/'))
|
||||
{
|
||||
$message_backup = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_backup = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.'/cache/'))
|
||||
{
|
||||
$message_cache = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_cache = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if(is_writable(MYBB_ROOT.'/cache/themes/'))
|
||||
{
|
||||
$message_themes = "<span style=\"color: green;\">{$lang->writable}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_themes = "<strong><span style=\"color: #C00\">{$lang->not_writable}</span></strong><br />{$lang->please_chmod_777}";
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_error("<p><em>{$errors} {$lang->error_chmod}</span></strong> {$lang->chmod_info} <a href=\"https://docs.mybb.com/1.8/administration/security/file-permissions\" target=\"_blank\" rel=\"noopener\">MyBB Docs</a>.</em></p>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_success("<p><em>{$lang->success_chmod}</em></p>");
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->file);
|
||||
$table->construct_header($lang->location, array("colspan" => 2, 'width' => 250));
|
||||
|
||||
$table->construct_cell("<strong>{$lang->config_file}</strong>");
|
||||
$table->construct_cell("./inc/config.php");
|
||||
$table->construct_cell($message_config);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->settings_file}</strong>");
|
||||
$table->construct_cell("./inc/settings.php");
|
||||
$table->construct_cell($message_settings);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->file_upload_dir}</strong>");
|
||||
$table->construct_cell($mybb->settings['uploadspath']);
|
||||
$table->construct_cell($message_upload);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->avatar_upload_dir}</strong>");
|
||||
$table->construct_cell($mybb->settings['avataruploadpath']);
|
||||
$table->construct_cell($message_avatar);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->language_files}</strong>");
|
||||
$table->construct_cell("./inc/languages");
|
||||
$table->construct_cell($message_language);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->backup_dir}</strong>");
|
||||
$table->construct_cell('./'.$config['admin_dir'].'/backups');
|
||||
$table->construct_cell($message_backup);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->cache_dir}</strong>");
|
||||
$table->construct_cell('./cache');
|
||||
$table->construct_cell($message_cache);
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->themes_dir}</strong>");
|
||||
$table->construct_cell('./cache/themes');
|
||||
$table->construct_cell($message_themes);
|
||||
$table->construct_row();
|
||||
|
||||
$plugins->run_hooks("admin_tools_system_health_output_chmod_list");
|
||||
|
||||
$table->output($lang->chmod_files_and_dirs);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
776
webroot/forum/admin/modules/tools/tasks.php
Normal file
776
webroot/forum/admin/modules/tools/tasks.php
Normal file
@@ -0,0 +1,776 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
require_once MYBB_ROOT."/inc/functions_task.php";
|
||||
|
||||
$page->add_breadcrumb_item($lang->task_manager, "index.php?module=tools-tasks");
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_begin");
|
||||
|
||||
/**
|
||||
* Validates a string or array of values
|
||||
*
|
||||
* @param string|array $value Comma-separated list or array of values
|
||||
* @param int $min Minimum value
|
||||
* @param int $max Maximum value
|
||||
* @param string $return_type Set "string" to return in a comma-separated list, or "array" to return in an array
|
||||
* @return string|array String or array of valid values OR false if string/array is invalid
|
||||
*/
|
||||
function check_time_values($value, $min, $max, $return_type)
|
||||
{
|
||||
// If the values aren't in an array form, make them into an array
|
||||
if(!is_array($value))
|
||||
{
|
||||
// Empty value == *
|
||||
if($value === '')
|
||||
{
|
||||
return ($return_type == 'string') ? '*' : array('*');
|
||||
}
|
||||
$implode = 1;
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
// If * is in the array, always return with * because it overrides all
|
||||
if(in_array('*', $value))
|
||||
{
|
||||
return ($return_type == 'string') ? '*' : array('*');
|
||||
}
|
||||
// Validate each value in array
|
||||
foreach($value as $time)
|
||||
{
|
||||
if($time < $min || $time > $max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Return based on return type
|
||||
if($return_type == 'string')
|
||||
{
|
||||
$value = implode(',', $value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_tasks_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_description;
|
||||
}
|
||||
|
||||
$file = $mybb->get_input('file');
|
||||
$file = basename($file, '.php');
|
||||
|
||||
if(!file_exists(MYBB_ROOT."inc/tasks/".$file.".php"))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_task_file;
|
||||
}
|
||||
|
||||
$mybb->input['minute'] = check_time_values($mybb->input['minute'], 0, 59, 'string');
|
||||
if($mybb->input['minute'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_minute;
|
||||
}
|
||||
|
||||
$mybb->input['hour'] = check_time_values($mybb->input['hour'], 0, 59, 'string');
|
||||
if($mybb->input['hour'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_hour;
|
||||
}
|
||||
|
||||
if($mybb->input['day'] != "*" && $mybb->input['day'] != '')
|
||||
{
|
||||
$mybb->input['day'] = check_time_values($mybb->input['day'], 1, 31, 'string');
|
||||
if($mybb->input['day'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_day;
|
||||
}
|
||||
$mybb->input['weekday'] = array('*');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['weekday'] = check_time_values($mybb->input['weekday'], 0, 6, 'array');
|
||||
if($mybb->input['weekday'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_weekday;
|
||||
}
|
||||
$mybb->input['day'] = '*';
|
||||
}
|
||||
|
||||
$mybb->input['month'] = check_time_values($mybb->input['month'], 1, 12, 'array');
|
||||
if($mybb->input['month'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_month;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_task = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"file" => $db->escape_string($file),
|
||||
"minute" => $db->escape_string($mybb->input['minute']),
|
||||
"hour" => $db->escape_string($mybb->input['hour']),
|
||||
"day" => $db->escape_string($mybb->input['day']),
|
||||
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
|
||||
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$new_task['nextrun'] = fetch_next_run($new_task);
|
||||
$tid = $db->insert_query("tasks", $new_task);
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_add_commit");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($tid, $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_task_created, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
}
|
||||
$page->add_breadcrumb_item($lang->add_new_task);
|
||||
$page->output_header($lang->scheduled_tasks." - ".$lang->add_new_task);
|
||||
|
||||
|
||||
$sub_tabs['scheduled_tasks'] = array(
|
||||
'title' => $lang->scheduled_tasks,
|
||||
'link' => "index.php?module=tools-tasks"
|
||||
);
|
||||
|
||||
$sub_tabs['add_task'] = array(
|
||||
'title' => $lang->add_new_task,
|
||||
'link' => "index.php?module=tools-tasks&action=add",
|
||||
'description' => $lang->add_new_task_desc
|
||||
);
|
||||
|
||||
$sub_tabs['task_logs'] = array(
|
||||
'title' => $lang->view_task_logs,
|
||||
'link' => "index.php?module=tools-tasks&action=logs"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_task');
|
||||
$form = new Form("index.php?module=tools-tasks&action=add", "post", "add");
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['minute'] = '*';
|
||||
$mybb->input['hour'] = '*';
|
||||
$mybb->input['day'] = '*';
|
||||
$mybb->input['weekday'] = '*';
|
||||
$mybb->input['month'] = '*';
|
||||
}
|
||||
$form_container = new FormContainer($lang->add_new_task);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
|
||||
$task_list = array();
|
||||
$task_files = scandir(MYBB_ROOT."inc/tasks/");
|
||||
foreach($task_files as $task_file)
|
||||
{
|
||||
if(is_file(MYBB_ROOT."inc/tasks/{$task_file}") && get_extension($task_file) == "php")
|
||||
{
|
||||
$file_id = preg_replace("#\.".get_extension($task_file)."$#i", "$1", $task_file);
|
||||
$task_list[$file_id] = $task_file;
|
||||
}
|
||||
}
|
||||
$form_container->output_row($lang->task_file." <em>*</em>", $lang->task_file_desc, $form->generate_select_box("file", $task_list, $mybb->input['file'], array('id' => 'file')), 'file');
|
||||
$form_container->output_row($lang->time_minutes, $lang->time_minutes_desc, $form->generate_text_box('minute', $mybb->input['minute'], array('id' => 'minute')), 'minute');
|
||||
$form_container->output_row($lang->time_hours, $lang->time_hours_desc, $form->generate_text_box('hour', $mybb->input['hour'], array('id' => 'hour')), 'hour');
|
||||
$form_container->output_row($lang->time_days_of_month, $lang->time_days_of_month_desc, $form->generate_text_box('day', $mybb->input['day'], array('id' => 'day')), 'day');
|
||||
|
||||
$options = array(
|
||||
"*" => $lang->every_weekday,
|
||||
"0" => $lang->sunday,
|
||||
"1" => $lang->monday,
|
||||
"2" => $lang->tuesday,
|
||||
"3" => $lang->wednesday,
|
||||
"4" => $lang->thursday,
|
||||
"5" => $lang->friday,
|
||||
"6" => $lang->saturday
|
||||
);
|
||||
$form_container->output_row($lang->time_weekdays, $lang->time_weekdays_desc, $form->generate_select_box('weekday[]', $options, $mybb->input['weekday'], array('id' => 'weekday', 'multiple' => true, 'size' => 8)), 'weekday');
|
||||
|
||||
$options = array(
|
||||
"*" => $lang->every_month,
|
||||
"1" => $lang->january,
|
||||
"2" => $lang->february,
|
||||
"3" => $lang->march,
|
||||
"4" => $lang->april,
|
||||
"5" => $lang->may,
|
||||
"6" => $lang->june,
|
||||
"7" => $lang->july,
|
||||
"8" => $lang->august,
|
||||
"9" => $lang->september,
|
||||
"10" => $lang->october,
|
||||
"11" => $lang->november,
|
||||
"12" => $lang->december
|
||||
);
|
||||
$form_container->output_row($lang->time_months, $lang->time_months_desc, $form->generate_select_box('month[]', $options, $mybb->input['month'], array('id' => 'month', 'multiple' => true, 'size' => 13)), 'month');
|
||||
|
||||
$form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $mybb->input['logging'], true));
|
||||
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $mybb->input['enabled'], true));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_task);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$task = $db->fetch_array($query);
|
||||
|
||||
// Does the task not exist?
|
||||
if(!$task['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_task, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_description;
|
||||
}
|
||||
|
||||
$file = $mybb->get_input('file');
|
||||
$file = basename($file, '.php');
|
||||
|
||||
if(!file_exists(MYBB_ROOT."inc/tasks/".$file.".php"))
|
||||
{
|
||||
$errors[] = $lang->error_invalid_task_file;
|
||||
}
|
||||
|
||||
$mybb->input['minute'] = check_time_values($mybb->input['minute'], 0, 59, 'string');
|
||||
if($mybb->input['minute'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_minute;
|
||||
}
|
||||
|
||||
$mybb->input['hour'] = check_time_values($mybb->input['hour'], 0, 59, 'string');
|
||||
if($mybb->input['hour'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_hour;
|
||||
}
|
||||
|
||||
if($mybb->input['day'] != "*" && $mybb->input['day'] != '')
|
||||
{
|
||||
$mybb->input['day'] = check_time_values($mybb->input['day'], 1, 31, 'string');
|
||||
if($mybb->input['day'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_day;
|
||||
}
|
||||
$mybb->input['weekday'] = array('*');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['weekday'] = check_time_values($mybb->input['weekday'], 0, 6, 'array');
|
||||
if($mybb->input['weekday'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_weekday;
|
||||
}
|
||||
$mybb->input['day'] = '*';
|
||||
}
|
||||
|
||||
$mybb->input['month'] = check_time_values($mybb->input['month'], 1, 12, 'array');
|
||||
if($mybb->input['month'] === false)
|
||||
{
|
||||
$errors[] = $lang->error_invalid_month;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$enable_confirmation = false;
|
||||
// Check if we need to ask the user to confirm turning on the task
|
||||
if(($task['file'] == "backupdb" || $task['file'] == "checktables") && $task['enabled'] == 0 && $mybb->input['enabled'] == 1)
|
||||
{
|
||||
$mybb->input['enabled'] = 0;
|
||||
$enable_confirmation = true;
|
||||
}
|
||||
|
||||
$updated_task = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"file" => $db->escape_string($file),
|
||||
"minute" => $db->escape_string($mybb->input['minute']),
|
||||
"hour" => $db->escape_string($mybb->input['hour']),
|
||||
"day" => $db->escape_string($mybb->input['day']),
|
||||
"month" => $db->escape_string(implode(',', $mybb->input['month'])),
|
||||
"weekday" => $db->escape_string(implode(',', $mybb->input['weekday'])),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$updated_task['nextrun'] = fetch_next_run($updated_task);
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_edit_commit");
|
||||
|
||||
$db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_task_updated, 'success');
|
||||
|
||||
if($enable_confirmation == true)
|
||||
{
|
||||
admin_redirect("index.php?module=tools-tasks&action=enable&tid={$task['tid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_task);
|
||||
$page->output_header($lang->scheduled_tasks." - ".$lang->edit_task);
|
||||
|
||||
$sub_tabs['edit_task'] = array(
|
||||
'title' => $lang->edit_task,
|
||||
'description' => $lang->edit_task_desc,
|
||||
'link' => "index.php?module=tools-tasks&action=edit&tid={$task['tid']}"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_task');
|
||||
|
||||
$form = new Form("index.php?module=tools-tasks&action=edit", "post");
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
$task_data = $mybb->input;
|
||||
}
|
||||
else
|
||||
{
|
||||
$task_data = $task;
|
||||
$task_data['weekday'] = explode(',', $task['weekday']);
|
||||
$task_data['month'] = explode(',', $task['month']);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_task);
|
||||
echo $form->generate_hidden_field("tid", $task['tid']);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $task_data['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $task_data['description'], array('id' => 'description')), 'description');
|
||||
|
||||
$task_list = array();
|
||||
$task_files = scandir(MYBB_ROOT."inc/tasks/");
|
||||
foreach($task_files as $task_file)
|
||||
{
|
||||
if(is_file(MYBB_ROOT."inc/tasks/{$task_file}") && get_extension($task_file) == "php")
|
||||
{
|
||||
$file_id = preg_replace("#\.".get_extension($task_file)."$#i", "$1", $task_file);
|
||||
$task_list[$file_id] = $task_file;
|
||||
}
|
||||
}
|
||||
$form_container->output_row($lang->task." <em>*</em>", $lang->task_file_desc, $form->generate_select_box("file", $task_list, $task_data['file'], array('id' => 'file')), 'file');
|
||||
$form_container->output_row($lang->time_minutes, $lang->time_minutes_desc, $form->generate_text_box('minute', $task_data['minute'], array('id' => 'minute')), 'minute');
|
||||
$form_container->output_row($lang->time_hours, $lang->time_hours_desc, $form->generate_text_box('hour', $task_data['hour'], array('id' => 'hour')), 'hour');
|
||||
$form_container->output_row($lang->time_days_of_month, $lang->time_days_of_month_desc, $form->generate_text_box('day', $task_data['day'], array('id' => 'day')), 'day');
|
||||
|
||||
$options = array(
|
||||
"*" => $lang->every_weekday,
|
||||
"0" => $lang->sunday,
|
||||
"1" => $lang->monday,
|
||||
"2" => $lang->tuesday,
|
||||
"3" => $lang->wednesday,
|
||||
"4" => $lang->thursday,
|
||||
"5" => $lang->friday,
|
||||
"6" => $lang->saturday
|
||||
);
|
||||
$form_container->output_row($lang->time_weekdays, $lang->time_weekdays_desc, $form->generate_select_box('weekday[]', $options, $task_data['weekday'], array('id' => 'weekday', 'multiple' => true)), 'weekday');
|
||||
|
||||
$options = array(
|
||||
"*" => $lang->every_month,
|
||||
"1" => $lang->january,
|
||||
"2" => $lang->february,
|
||||
"3" => $lang->march,
|
||||
"4" => $lang->april,
|
||||
"5" => $lang->may,
|
||||
"6" => $lang->june,
|
||||
"7" => $lang->july,
|
||||
"8" => $lang->august,
|
||||
"9" => $lang->september,
|
||||
"10" => $lang->october,
|
||||
"11" => $lang->november,
|
||||
"12" => $lang->december
|
||||
);
|
||||
$form_container->output_row($lang->time_months, $lang->time_months_desc, $form->generate_select_box('month[]', $options, $task_data['month'], array('id' => 'month', 'multiple' => true)), 'month');
|
||||
|
||||
$form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $task_data['logging'], true));
|
||||
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $task_data['enabled'], true));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_task);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$task = $db->fetch_array($query);
|
||||
|
||||
// Does the task not exist?
|
||||
if(!$task['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_task, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
// Delete the task & any associated task log entries
|
||||
$db->delete_query("tasks", "tid='{$task['tid']}'");
|
||||
$db->delete_query("tasklog", "tid='{$task['tid']}'");
|
||||
|
||||
// Fetch next task run
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_delete_commit");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $task['title']);
|
||||
|
||||
flash_message($lang->success_task_deleted, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=tools-tasks&action=delete&tid={$task['tid']}", $lang->confirm_task_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "enable" || $mybb->input['action'] == "disable")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$task = $db->fetch_array($query);
|
||||
|
||||
// Does the task not exist?
|
||||
if(!$task['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_task, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "enable")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_tasks_enable");
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_tasks_disable");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "enable")
|
||||
{
|
||||
if($task['file'] == "backupdb" || $task['file'] == "checktables")
|
||||
{
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$nextrun = fetch_next_run($task);
|
||||
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_enable_commit");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);
|
||||
|
||||
flash_message($lang->success_task_enabled, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=tools-tasks&action=enable&tid={$task['tid']}", $lang->confirm_task_enable);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$nextrun = fetch_next_run($task);
|
||||
$db->update_query("tasks", array("nextrun" => $nextrun, "enabled" => 1), "tid='{$task['tid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_enable_commit");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);
|
||||
|
||||
flash_message($lang->success_task_enabled, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->update_query("tasks", array("enabled" => 0), "tid='{$task['tid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_disable_commit");
|
||||
|
||||
$cache->update_tasks();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $task['title'], $mybb->input['action']);
|
||||
|
||||
flash_message($lang->success_task_disabled, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "run")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
ignore_user_abort(true);
|
||||
@set_time_limit(0);
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_run");
|
||||
|
||||
$query = $db->simple_select("tasks", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
|
||||
$task = $db->fetch_array($query);
|
||||
|
||||
// Does the task not exist?
|
||||
if(!$task['tid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_task, 'error');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
run_task($task['tid']);
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_run_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($task['tid'], $task['title']);
|
||||
|
||||
flash_message($lang->success_task_run, 'success');
|
||||
admin_redirect("index.php?module=tools-tasks");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "logs")
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_tasks_logs");
|
||||
|
||||
$page->output_header($lang->task_logs);
|
||||
|
||||
$sub_tabs['scheduled_tasks'] = array(
|
||||
'title' => $lang->scheduled_tasks,
|
||||
'link' => "index.php?module=tools-tasks"
|
||||
);
|
||||
|
||||
$sub_tabs['add_task'] = array(
|
||||
'title' => $lang->add_new_task,
|
||||
'link' => "index.php?module=tools-tasks&action=add"
|
||||
);
|
||||
|
||||
$sub_tabs['task_logs'] = array(
|
||||
'title' => $lang->view_task_logs,
|
||||
'link' => "index.php?module=tools-tasks&action=logs",
|
||||
'description' => $lang->view_task_logs_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'task_logs');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->task);
|
||||
$table->construct_header($lang->date, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->data, array("width" => "60%"));
|
||||
|
||||
$query = $db->simple_select("tasklog", "COUNT(*) AS log_count");
|
||||
$log_count = $db->fetch_field($query, "log_count");
|
||||
|
||||
$start = 0;
|
||||
$per_page = 50;
|
||||
$current_page = 1;
|
||||
|
||||
if($mybb->input['page'] > 0)
|
||||
{
|
||||
$current_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($current_page-1)*$per_page;
|
||||
$pages = $log_count / $per_page;
|
||||
$pages = ceil($pages);
|
||||
if($current_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination = draw_admin_pagination($current_page, $per_page, $log_count, "index.php?module=tools-tasks&action=logs&page={page}");
|
||||
|
||||
$query = $db->query("
|
||||
SELECT l.*, t.title
|
||||
FROM ".TABLE_PREFIX."tasklog l
|
||||
LEFT JOIN ".TABLE_PREFIX."tasks t ON (t.tid=l.tid)
|
||||
ORDER BY l.dateline DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
while($log_entry = $db->fetch_array($query))
|
||||
{
|
||||
$log_entry['title'] = htmlspecialchars_uni($log_entry['title']);
|
||||
$log_entry['data'] = htmlspecialchars_uni($log_entry['data']);
|
||||
|
||||
$date = my_date('relative', $log_entry['dateline']);
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-tasks&action=edit&tid={$log_entry['tid']}\">{$log_entry['title']}</a>");
|
||||
$table->construct_cell($date, array("class" => "align_center"));
|
||||
$table->construct_cell($log_entry['data']);
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_task_logs, array("colspan" => "3"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->task_logs);
|
||||
echo $pagination;
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$page->output_header($lang->task_manager);
|
||||
|
||||
$sub_tabs['scheduled_tasks'] = array(
|
||||
'title' => $lang->scheduled_tasks,
|
||||
'link' => "index.php?module=tools-tasks",
|
||||
'description' => $lang->scheduled_tasks_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_task'] = array(
|
||||
'title' => $lang->add_new_task,
|
||||
'link' => "index.php?module=tools-tasks&action=add"
|
||||
);
|
||||
|
||||
$sub_tabs['task_logs'] = array(
|
||||
'title' => $lang->view_task_logs,
|
||||
'link' => "index.php?module=tools-tasks&action=logs"
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_tasks_start");
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'scheduled_tasks');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->task);
|
||||
$table->construct_header($lang->next_run, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
$query = $db->simple_select("tasks", "*", "", array("order_by" => "title", "order_dir" => "asc"));
|
||||
while($task = $db->fetch_array($query))
|
||||
{
|
||||
$task['title'] = htmlspecialchars_uni($task['title']);
|
||||
$task['description'] = htmlspecialchars_uni($task['description']);
|
||||
$next_run = my_date('normal', $task['nextrun'], "", 2);
|
||||
if($task['enabled'] == 1)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
$table->construct_cell("<div class=\"float_right\"><a href=\"index.php?module=tools-tasks&action=run&tid={$task['tid']}&my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/run_task.png\" title=\"{$lang->run_task_now}\" alt=\"{$lang->run_task}\" /></a></div><div>{$icon}<strong><a href=\"index.php?module=tools-tasks&action=edit&tid={$task['tid']}\">{$task['title']}</a></strong><br /><small>{$task['description']}</small></div>");
|
||||
$table->construct_cell($next_run, array("class" => "align_center"));
|
||||
|
||||
$popup = new PopupMenu("task_{$task['tid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_task, "index.php?module=tools-tasks&action=edit&tid={$task['tid']}");
|
||||
if($task['enabled'] == 1)
|
||||
{
|
||||
$popup->add_item($lang->run_task, "index.php?module=tools-tasks&action=run&tid={$task['tid']}&my_post_key={$mybb->post_code}");
|
||||
$popup->add_item($lang->disable_task, "index.php?module=tools-tasks&action=disable&tid={$task['tid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup->add_item($lang->enable_task, "index.php?module=tools-tasks&action=enable&tid={$task['tid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
$popup->add_item($lang->delete_task, "index.php?module=tools-tasks&action=delete&tid={$task['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_task_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_tasks, array('colspan' => 3));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->scheduled_tasks);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
486
webroot/forum/admin/modules/tools/warninglog.php
Normal file
486
webroot/forum/admin/modules/tools/warninglog.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?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->warning_logs, "index.php?module=tools-warninglog");
|
||||
|
||||
$plugins->run_hooks("admin_tools_warninglog_begin");
|
||||
|
||||
// Revoke a warning
|
||||
if($mybb->input['action'] == "do_revoke" && $mybb->request_method == "post")
|
||||
{
|
||||
$query = $db->simple_select("warnings", "*", "wid='".$mybb->get_input('wid', MyBB::INPUT_INT)."'");
|
||||
$warning = $db->fetch_array($query);
|
||||
|
||||
if(!$warning['wid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning, 'error');
|
||||
admin_redirect("index.php?module=tools-warninglog");
|
||||
}
|
||||
else if($warning['daterevoked'])
|
||||
{
|
||||
flash_message($lang->error_already_revoked, 'error');
|
||||
admin_redirect("index.php?module=tools-warninglog&action=view&wid={$warning['wid']}");
|
||||
}
|
||||
|
||||
$user = get_user($warning['uid']);
|
||||
|
||||
$plugins->run_hooks("admin_tools_warninglog_do_revoke");
|
||||
|
||||
if(!trim($mybb->input['reason']))
|
||||
{
|
||||
$warn_errors[] = $lang->error_no_revoke_reason;
|
||||
$mybb->input['action'] = "view";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Warning is still active, lower users point count
|
||||
if($warning['expired'] != 1)
|
||||
{
|
||||
$new_warning_points = $user['warningpoints']-$warning['points'];
|
||||
if($new_warning_points < 0)
|
||||
{
|
||||
$new_warning_points = 0;
|
||||
}
|
||||
|
||||
// Update user
|
||||
$updated_user = array(
|
||||
"warningpoints" => $new_warning_points
|
||||
);
|
||||
}
|
||||
|
||||
// Update warning
|
||||
$updated_warning = array(
|
||||
"expired" => 1,
|
||||
"daterevoked" => TIME_NOW,
|
||||
"revokedby" => $mybb->user['uid'],
|
||||
"revokereason" => $db->escape_string($mybb->input['reason'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_tools_warninglog_do_revoke_commit");
|
||||
|
||||
if($warning['expired'] != 1)
|
||||
{
|
||||
$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");
|
||||
}
|
||||
|
||||
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");
|
||||
|
||||
flash_message($lang->redirect_warning_revoked, 'success');
|
||||
admin_redirect("index.php?module=tools-warninglog&action=view&wid={$warning['wid']}");
|
||||
}
|
||||
}
|
||||
|
||||
// Detailed view of a warning
|
||||
if($mybb->input['action'] == "view")
|
||||
{
|
||||
$query = $db->query("
|
||||
SELECT w.*, t.title AS type_title, u.username, p.subject AS post_subject
|
||||
FROM ".TABLE_PREFIX."warnings w
|
||||
LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (t.tid=w.tid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=w.issuedby)
|
||||
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=w.pid)
|
||||
WHERE w.wid='".$mybb->get_input('wid', MyBB::INPUT_INT)."'
|
||||
");
|
||||
$warning = $db->fetch_array($query);
|
||||
|
||||
if(!$warning['wid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_warning, 'error');
|
||||
admin_redirect("index.php?module=tools-warninglog");
|
||||
}
|
||||
|
||||
$user = get_user((int)$warning['uid']);
|
||||
|
||||
$plugins->run_hooks("admin_tools_warninglog_view");
|
||||
|
||||
$page->add_breadcrumb_item($lang->warning_details, "index.php?module=tools-warninglog&action=view&wid={$warning['wid']}");
|
||||
|
||||
$page->output_header($lang->warning_details);
|
||||
|
||||
$user_link = build_profile_link(htmlspecialchars_uni($user['username']), $user['uid'], "_blank");
|
||||
|
||||
if(is_array($warn_errors))
|
||||
{
|
||||
$page->output_inline_error($warn_errors);
|
||||
$mybb->input['reason'] = htmlspecialchars_uni($mybb->input['reason']);
|
||||
}
|
||||
|
||||
$table = new Table;
|
||||
|
||||
$post_link = "";
|
||||
if($warning['post_subject'])
|
||||
{
|
||||
if(!is_object($parser))
|
||||
{
|
||||
require_once MYBB_ROOT."inc/class_parser.php";
|
||||
$parser = new postParser;
|
||||
}
|
||||
|
||||
$warning['post_subject'] = $parser->parse_badwords($warning['post_subject']);
|
||||
$warning['post_subject'] = htmlspecialchars_uni($warning['post_subject']);
|
||||
$post_link = get_post_link($warning['pid']);
|
||||
$table->construct_cell("<strong>{$lang->warned_user}</strong><br /><br />{$user_link}");
|
||||
$table->construct_cell("<strong>{$lang->post}</strong><br /><br /><a href=\"{$mybb->settings['bburl']}/{$post_link}\" target=\"_blank\">{$warning['post_subject']}</a>");
|
||||
$table->construct_row();
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<strong>{$lang->warned_user}</strong><br /><br />{$user_link}", array('colspan' => 2));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$issuedby = build_profile_link(htmlspecialchars_uni($warning['username']), $warning['issuedby'], "_blank");
|
||||
$notes = nl2br(htmlspecialchars_uni($warning['notes']));
|
||||
|
||||
$date_issued = my_date('relative', $warning['dateline']);
|
||||
if($warning['type_title'])
|
||||
{
|
||||
$warning_type = $warning['type_title'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$warning_type = $warning['title'];
|
||||
}
|
||||
$warning_type = htmlspecialchars_uni($warning_type);
|
||||
if($warning['points'] > 0)
|
||||
{
|
||||
$warning['points'] = "+{$warning['points']}";
|
||||
}
|
||||
|
||||
$points = $lang->sprintf($lang->warning_points, $warning['points']);
|
||||
if($warning['expired'] != 1)
|
||||
{
|
||||
if($warning['expires'] == 0)
|
||||
{
|
||||
$expires = $lang->never;
|
||||
}
|
||||
else
|
||||
{
|
||||
$expires = my_date('relative', $warning['expires']);
|
||||
}
|
||||
$status = $lang->warning_active;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($warning['daterevoked'])
|
||||
{
|
||||
$expires = $status = $lang->warning_revoked;
|
||||
}
|
||||
else if($warning['expires'])
|
||||
{
|
||||
$expires = $status = $lang->already_expired;
|
||||
}
|
||||
}
|
||||
|
||||
$table->construct_cell("<strong>{$lang->warning}</strong><br /><br />{$warning_type} {$points}", array('width' => '50%'));
|
||||
$table->construct_cell("<strong>{$lang->date_issued}</strong><br /><br />{$date_issued}", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->issued_by}</strong><br /><br />{$issuedby}", array('width' => '50%'));
|
||||
$table->construct_cell("<strong>{$lang->expires}</strong><br /><br />{$expires}", array('width' => '50%'));
|
||||
$table->construct_row();
|
||||
|
||||
$table->construct_cell("<strong>{$lang->warning_note}</strong><br /><br />{$notes}", array('colspan' => 2));
|
||||
$table->construct_row();
|
||||
|
||||
$table->output("<div class=\"float_right\" style=\"font-weight: normal;\">{$status}</div>".$lang->warning_details);
|
||||
|
||||
if(!$warning['daterevoked'])
|
||||
{
|
||||
$form = new Form("index.php?module=tools-warninglog", "post");
|
||||
$form_container = new FormContainer($lang->revoke_warning);
|
||||
echo $form->generate_hidden_field('action', 'do_revoke');
|
||||
echo $form->generate_hidden_field('wid', $warning['wid']);
|
||||
$form_container->output_row("", $lang->revoke_warning_desc, $form->generate_text_area('reason', $mybb->input['reason'], array('id' => 'reason')), 'reason');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->revoke_warning);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
}
|
||||
else
|
||||
{
|
||||
$date_revoked = my_date('relative', $warning['daterevoked']);
|
||||
$revoked_user = get_user($warning['revokedby']);
|
||||
$revoked_by = build_profile_link(htmlspecialchars_uni($revoked_user['username']), $revoked_user['uid'], "_blank");
|
||||
$revoke_reason = nl2br(htmlspecialchars_uni($warning['revokereason']));
|
||||
|
||||
$revoke_table = new Table;
|
||||
$revoke_table->construct_cell("<strong>{$lang->revoked_by}</strong><br /><br />{$revoked_by}", array('width' => '50%'));
|
||||
$revoke_table->construct_cell("<strong>{$lang->date_revoked}</strong><br /><br />{$date_revoked}", array('width' => '50%'));
|
||||
$revoke_table->construct_row();
|
||||
|
||||
$revoke_table->construct_cell("<strong>{$lang->reason}</strong><br /><br />{$revoke_reason}", array('colspan' => 2));
|
||||
$revoke_table->construct_row();
|
||||
|
||||
$revoke_table->output($lang->warning_is_revoked);
|
||||
}
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_tools_warninglog_start");
|
||||
|
||||
$page->output_header($lang->warning_logs);
|
||||
|
||||
$sub_tabs['warning_logs'] = array(
|
||||
'title' => $lang->warning_logs,
|
||||
'link' => "index.php?module=tools-warninglog",
|
||||
'description' => $lang->warning_logs_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'warning_logs');
|
||||
|
||||
// Filter options
|
||||
$where_sql = '';
|
||||
if(!empty($mybb->input['filter']['username']))
|
||||
{
|
||||
$search_user = get_user_by_username($mybb->input['filter']['username']);
|
||||
|
||||
$mybb->input['filter']['uid'] = (int)$search_user['uid'];
|
||||
$mybb->input['filter']['uid'] = $db->fetch_field($query, "uid");
|
||||
}
|
||||
if($mybb->input['filter']['uid'])
|
||||
{
|
||||
$search['uid'] = (int)$mybb->input['filter']['uid'];
|
||||
$where_sql .= " AND w.uid='{$search['uid']}'";
|
||||
if(!isset($mybb->input['search']['username']))
|
||||
{
|
||||
$user = get_user($mybb->input['search']['uid']);
|
||||
$mybb->input['search']['username'] = $user['username'];
|
||||
}
|
||||
}
|
||||
if(!empty($mybb->input['filter']['mod_username']))
|
||||
{
|
||||
$mod_user = get_user_by_username($mybb->input['filter']['mod_username']);
|
||||
|
||||
$mybb->input['filter']['mod_uid'] = (int)$mod_user['uid'];
|
||||
}
|
||||
if($mybb->input['filter']['mod_uid'])
|
||||
{
|
||||
$search['mod_uid'] = (int)$mybb->input['filter']['mod_uid'];
|
||||
$where_sql .= " AND w.issuedby='{$search['mod_uid']}'";
|
||||
if(!isset($mybb->input['search']['mod_username']))
|
||||
{
|
||||
$mod_user = get_user($mybb->input['search']['uid']);
|
||||
$mybb->input['search']['mod_username'] = $mod_user['username'];
|
||||
}
|
||||
}
|
||||
if($mybb->input['filter']['reason'])
|
||||
{
|
||||
$search['reason'] = $db->escape_string_like($mybb->input['filter']['reason']);
|
||||
$where_sql .= " AND (w.notes LIKE '%{$search['reason']}%' OR t.title LIKE '%{$search['reason']}%' OR w.title LIKE '%{$search['reason']}%')";
|
||||
}
|
||||
$sortbysel = array();
|
||||
switch($mybb->input['filter']['sortby'])
|
||||
{
|
||||
case "username":
|
||||
$sortby = "u.username";
|
||||
$sortbysel['username'] = ' selected="selected"';
|
||||
break;
|
||||
case "expires":
|
||||
$sortby = "w.expires";
|
||||
$sortbysel['expires'] = ' selected="selected"';
|
||||
break;
|
||||
case "issuedby":
|
||||
$sortby = "i.username";
|
||||
$sortbysel['issuedby'] = ' selected="selected"';
|
||||
break;
|
||||
default: // "dateline"
|
||||
$sortby = "w.dateline";
|
||||
$sortbysel['dateline'] = ' selected="selected"';
|
||||
}
|
||||
$order = $mybb->input['filter']['order'];
|
||||
$ordersel = array();
|
||||
if($order != "asc")
|
||||
{
|
||||
$order = "desc";
|
||||
$ordersel['desc'] = ' selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordersel['asc'] = ' selected="selected"';
|
||||
}
|
||||
|
||||
// Expire any warnings past their expiration date
|
||||
require_once MYBB_ROOT.'inc/datahandlers/warnings.php';
|
||||
$warningshandler = new WarningsHandler('update');
|
||||
|
||||
$warningshandler->expire_warnings();
|
||||
|
||||
// Pagination stuff
|
||||
$sql = "
|
||||
SELECT COUNT(wid) as count
|
||||
FROM
|
||||
".TABLE_PREFIX."warnings w
|
||||
LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (w.tid=t.tid)
|
||||
WHERE 1=1
|
||||
{$where_sql}
|
||||
";
|
||||
$query = $db->query($sql);
|
||||
$total_warnings = $db->fetch_field($query, 'count');
|
||||
$view_page = 1;
|
||||
if(isset($mybb->input['page']) && $mybb->get_input('page', MyBB::INPUT_INT) > 0)
|
||||
{
|
||||
$view_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
}
|
||||
$per_page = 20;
|
||||
if(isset($mybb->input['filter']['per_page']) && (int)$mybb->input['filter']['per_page'] > 0)
|
||||
{
|
||||
$per_page = (int)$mybb->input['filter']['per_page'];
|
||||
}
|
||||
$start = ($view_page-1) * $per_page;
|
||||
$pages = ceil($total_warnings / $per_page);
|
||||
if($view_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$view_page = 1;
|
||||
}
|
||||
// Build the base URL for pagination links
|
||||
$url = 'index.php?module=tools-warninglog';
|
||||
if(is_array($mybb->input['filter']) && count($mybb->input['filter']))
|
||||
{
|
||||
foreach($mybb->input['filter'] as $field => $value)
|
||||
{
|
||||
$value = urlencode($value);
|
||||
$url .= "&filter[{$field}]={$value}";
|
||||
}
|
||||
}
|
||||
|
||||
// The actual query
|
||||
$sql = "
|
||||
SELECT
|
||||
w.wid, w.title as custom_title, w.points, w.dateline, w.issuedby, w.expires, w.expired, w.daterevoked, w.revokedby,
|
||||
t.title,
|
||||
u.uid, u.username, u.usergroup, u.displaygroup,
|
||||
i.uid as mod_uid, i.username as mod_username, i.usergroup as mod_usergroup, i.displaygroup as mod_displaygroup
|
||||
FROM ".TABLE_PREFIX."warnings w
|
||||
LEFT JOIN ".TABLE_PREFIX."users u on (w.uid=u.uid)
|
||||
LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (w.tid=t.tid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users i ON (i.uid=w.issuedby)
|
||||
WHERE 1=1
|
||||
{$where_sql}
|
||||
ORDER BY {$sortby} {$order}
|
||||
LIMIT {$start}, {$per_page}
|
||||
";
|
||||
$query = $db->query($sql);
|
||||
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->warned_user, array('width' => '15%'));
|
||||
$table->construct_header($lang->warning, array("class" => "align_center", 'width' => '25%'));
|
||||
$table->construct_header($lang->date_issued, array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_header($lang->expires, array("class" => "align_center", 'width' => '20%'));
|
||||
$table->construct_header($lang->issued_by, array("class" => "align_center", 'width' => '15%'));
|
||||
$table->construct_header($lang->options, array("class" => "align_center", 'width' => '5%'));
|
||||
|
||||
while($row = $db->fetch_array($query))
|
||||
{
|
||||
if(!$row['username'])
|
||||
{
|
||||
$row['username'] = $lang->guest;
|
||||
}
|
||||
|
||||
$trow = alt_trow();
|
||||
$username = format_name(htmlspecialchars_uni($row['username']), $row['usergroup'], $row['displaygroup']);
|
||||
if(!$row['uid'])
|
||||
{
|
||||
$username_link = $username;
|
||||
}
|
||||
else
|
||||
{
|
||||
$username_link = build_profile_link($username, $row['uid'], "_blank");
|
||||
}
|
||||
$mod_username = format_name(htmlspecialchars_uni($row['mod_username']), $row['mod_usergroup'], $row['mod_displaygroup']);
|
||||
$mod_username_link = build_profile_link($mod_username, $row['mod_uid'], "_blank");
|
||||
$issued_date = my_date('relative', $row['dateline']);
|
||||
$revoked_text = '';
|
||||
if($row['daterevoked'] > 0)
|
||||
{
|
||||
$revoked_date = my_date('relative', $row['daterevoked']);
|
||||
$revoked_text = "<br /><small><strong>{$lang->revoked}</strong> {$revoked_date}</small>";
|
||||
}
|
||||
if($row['expires'] > 0)
|
||||
{
|
||||
$expire_date = my_date('relative', $row['expires']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$expire_date = $lang->never;
|
||||
}
|
||||
$title = $row['title'];
|
||||
if(empty($row['title']))
|
||||
{
|
||||
$title = $row['custom_title'];
|
||||
}
|
||||
$title = htmlspecialchars_uni($title);
|
||||
if($row['points'] > 0)
|
||||
{
|
||||
$points = '+'.$row['points'];
|
||||
}
|
||||
|
||||
$table->construct_cell($username_link);
|
||||
$table->construct_cell("{$title} ({$points})");
|
||||
$table->construct_cell($issued_date, array("class" => "align_center"));
|
||||
$table->construct_cell($expire_date.$revoked_text, array("class" => "align_center"));
|
||||
$table->construct_cell($mod_username_link);
|
||||
$table->construct_cell("<a href=\"index.php?module=tools-warninglog&action=view&wid={$row['wid']}\">{$lang->view}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_warning_logs, array("colspan" => "6"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->warning_logs);
|
||||
|
||||
// Do we need to construct the pagination?
|
||||
if($total_warnings > $per_page)
|
||||
{
|
||||
echo draw_admin_pagination($view_page, $per_page, $total_warnings, $url)."<br />";
|
||||
}
|
||||
|
||||
$sort_by = array(
|
||||
'expires' => $lang->expiry_date,
|
||||
'dateline' => $lang->issued_date,
|
||||
'username' => $lang->warned_user,
|
||||
'issuedby' => $lang->issued_by
|
||||
);
|
||||
|
||||
$order_array = array(
|
||||
'asc' => $lang->asc,
|
||||
'desc' => $lang->desc
|
||||
);
|
||||
|
||||
$form = new Form("index.php?module=tools-warninglog", "post");
|
||||
$form_container = new FormContainer($lang->filter_warning_logs);
|
||||
$form_container->output_row($lang->filter_warned_user, "", $form->generate_text_box('filter[username]', $mybb->input['filter']['username'], array('id' => 'filter_username')), 'filter_username');
|
||||
$form_container->output_row($lang->filter_issued_by, "", $form->generate_text_box('filter[mod_username]', $mybb->input['filter']['mod_username'], array('id' => 'filter_mod_username')), 'filter_mod_username');
|
||||
$form_container->output_row($lang->filter_reason, "", $form->generate_text_box('filter[reason]', $mybb->input['filter']['reason'], array('id' => 'filter_reason')), 'filter_reason');
|
||||
$form_container->output_row($lang->sort_by, "", $form->generate_select_box('filter[sortby]', $sort_by, $mybb->input['filter']['sortby'], array('id' => 'filter_sortby'))." {$lang->in} ".$form->generate_select_box('filter[order]', $order_array, $order, array('id' => 'filter_order'))." {$lang->order}", 'filter_order');
|
||||
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('filter[per_page]', $per_page, array('id' => 'filter_per_page', 'min' => 1)), 'filter_per_page');
|
||||
|
||||
$form_container->end();
|
||||
$buttons[] = $form->generate_submit_button($lang->filter_warning_logs);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
537
webroot/forum/admin/modules/user/admin_permissions.php
Normal file
537
webroot/forum/admin/modules/user/admin_permissions.php
Normal file
@@ -0,0 +1,537 @@
|
||||
<?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->admin_permissions, "index.php?module=user-admin_permissions");
|
||||
|
||||
if(($mybb->input['action'] == "edit" && $mybb->input['uid'] == 0) || $mybb->input['action'] == "group" || !$mybb->input['action'])
|
||||
{
|
||||
$sub_tabs['user_permissions'] = array(
|
||||
'title' => $lang->user_permissions,
|
||||
'link' => "index.php?module=user-admin_permissions",
|
||||
'description' => $lang->user_permissions_desc
|
||||
);
|
||||
|
||||
$sub_tabs['group_permissions'] = array(
|
||||
'title' => $lang->group_permissions,
|
||||
'link' => "index.php?module=user-admin_permissions&action=group",
|
||||
'description' => $lang->group_permissions_desc
|
||||
);
|
||||
|
||||
$sub_tabs['default_permissions'] = array(
|
||||
'title' => $lang->default_permissions,
|
||||
'link' => "index.php?module=user-admin_permissions&action=edit&uid=0",
|
||||
'description' => $lang->default_permissions_desc
|
||||
);
|
||||
}
|
||||
|
||||
$uid = $mybb->get_input('uid', MyBB::INPUT_INT);
|
||||
|
||||
$plugins->run_hooks("admin_user_admin_permissions_begin");
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if(is_super_admin($uid))
|
||||
{
|
||||
flash_message($lang->error_super_admin, 'error');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['uid']))
|
||||
{
|
||||
flash_message($lang->error_delete_no_uid, 'error');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("adminoptions", "COUNT(uid) as adminoptions", "uid = '{$mybb->input['uid']}'");
|
||||
if($db->fetch_field($query, 'adminoptions') == 0)
|
||||
{
|
||||
flash_message($lang->error_delete_invalid_uid, 'error');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_admin_permissions_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$newperms = array(
|
||||
"permissions" => ''
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_admin_permissions_delete_commit");
|
||||
|
||||
$db->update_query("adminoptions", $newperms, "uid = '{$uid}'");
|
||||
|
||||
// Log admin action
|
||||
if($uid < 0)
|
||||
{
|
||||
$gid = abs($uid);
|
||||
$query = $db->simple_select("usergroups", "title", "gid='{$gid}'");
|
||||
$group = $db->fetch_array($query);
|
||||
log_admin_action($uid, $group['title']);
|
||||
|
||||
}
|
||||
elseif($uid == 0)
|
||||
{
|
||||
// Default
|
||||
log_admin_action(0, $lang->default);
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = get_user($uid);
|
||||
log_admin_action($uid, $user['username']);
|
||||
}
|
||||
|
||||
flash_message($lang->success_perms_deleted, 'success');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-admin_permissions&action=delete&uid={$mybb->input['uid']}", $lang->confirm_perms_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
if(is_super_admin($uid))
|
||||
{
|
||||
flash_message($lang->error_super_admin, 'error');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_admin_permissions_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
foreach($mybb->input['permissions'] as $module => $actions)
|
||||
{
|
||||
if(is_array($actions))
|
||||
{
|
||||
$no_access = 0;
|
||||
foreach($actions as $action => $access)
|
||||
{
|
||||
if($access == 0)
|
||||
{
|
||||
++$no_access;
|
||||
}
|
||||
}
|
||||
// User can't access any actions in this module - just disallow it completely
|
||||
if($no_access == count($actions))
|
||||
{
|
||||
unset($mybb->input['permissions'][$module]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Does an options row exist for this admin already?
|
||||
$query = $db->simple_select("adminoptions", "COUNT(uid) AS existing_options", "uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'");
|
||||
$existing_options = $db->fetch_field($query, "existing_options");
|
||||
if($existing_options > 0)
|
||||
{
|
||||
$db->update_query("adminoptions", array('permissions' => $db->escape_string(my_serialize($mybb->input['permissions']))), "uid = '".$mybb->get_input('uid', MyBB::INPUT_INT)."'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert_array = array(
|
||||
"uid" => $mybb->get_input('uid', MyBB::INPUT_INT),
|
||||
"permissions" => $db->escape_string(my_serialize($mybb->input['permissions'])),
|
||||
"notes" => '',
|
||||
"defaultviews" => ''
|
||||
);
|
||||
$db->insert_query("adminoptions", $insert_array);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_admin_permissions_edit_commit");
|
||||
|
||||
// Log admin action
|
||||
if($uid > 0)
|
||||
{
|
||||
// Users
|
||||
$user = get_user($uid);
|
||||
log_admin_action($uid, $user['username']);
|
||||
}
|
||||
elseif($uid < 0)
|
||||
{
|
||||
// Groups
|
||||
$gid = abs($uid);
|
||||
$query = $db->simple_select("usergroups", "title", "gid='{$gid}'");
|
||||
$group = $db->fetch_array($query);
|
||||
log_admin_action($uid, $group['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default
|
||||
log_admin_action(0);
|
||||
}
|
||||
|
||||
flash_message($lang->admin_permissions_updated, 'success');
|
||||
admin_redirect("index.php?module=user-admin_permissions");
|
||||
}
|
||||
|
||||
if($uid > 0)
|
||||
{
|
||||
switch($db->type)
|
||||
{
|
||||
case "pgsql":
|
||||
case "sqlite":
|
||||
$query = $db->query("
|
||||
SELECT u.uid, u.username, g.cancp, g.gid
|
||||
FROM ".TABLE_PREFIX."users u
|
||||
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))
|
||||
WHERE u.uid='$uid'
|
||||
AND g.cancp=1
|
||||
LIMIT 1
|
||||
");
|
||||
break;
|
||||
default:
|
||||
$query = $db->query("
|
||||
SELECT u.uid, u.username, g.cancp, g.gid
|
||||
FROM ".TABLE_PREFIX."users u
|
||||
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))
|
||||
WHERE u.uid='$uid'
|
||||
AND g.cancp=1
|
||||
LIMIT 1
|
||||
");
|
||||
}
|
||||
|
||||
$admin = $db->fetch_array($query);
|
||||
$permission_data = get_admin_permissions($uid, $admin['gid']);
|
||||
$title = htmlspecialchars_uni($admin['username']);
|
||||
$page->add_breadcrumb_item($lang->user_permissions, "index.php?module=user-admin_permissions");
|
||||
}
|
||||
elseif($uid < 0)
|
||||
{
|
||||
$gid = abs($uid);
|
||||
$query = $db->simple_select("usergroups", "title", "gid='$gid'");
|
||||
$group = $db->fetch_array($query);
|
||||
$permission_data = get_admin_permissions("", $gid);
|
||||
$title = $group['title'];
|
||||
$page->add_breadcrumb_item($lang->group_permissions, "index.php?module=user-admin_permissions&action=group");
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("adminoptions", "permissions", "uid='0'");
|
||||
$permission_data = my_unserialize($db->fetch_field($query, "permissions"));
|
||||
$page->add_breadcrumb_item($lang->default_permissions);
|
||||
$title = $lang->default;
|
||||
}
|
||||
|
||||
if($uid != 0)
|
||||
{
|
||||
$page->add_breadcrumb_item($lang->edit_permissions.": {$title}");
|
||||
}
|
||||
|
||||
$page->output_header($lang->edit_permissions);
|
||||
|
||||
if($uid != 0)
|
||||
{
|
||||
$sub_tabs['edit_permissions'] = array(
|
||||
'title' => $lang->edit_permissions,
|
||||
'link' => "index.php?module=user-admin_permissions&action=edit&uid={$uid}",
|
||||
'description' => $lang->edit_permissions_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_permissions');
|
||||
}
|
||||
|
||||
$form = new Form("index.php?module=user-admin_permissions&action=edit", "post", "edit");
|
||||
|
||||
echo $form->generate_hidden_field("uid", $uid);
|
||||
|
||||
// Fetch all of the modules we have
|
||||
$modules_dir = MYBB_ADMIN_DIR."modules";
|
||||
$dir = opendir($modules_dir);
|
||||
$modules = array();
|
||||
while(($module = readdir($dir)) !== false)
|
||||
{
|
||||
if(is_dir($modules_dir."/".$module) && !in_array($module, array(".", "..")) && file_exists($modules_dir."/".$module."/module_meta.php"))
|
||||
{
|
||||
require_once $modules_dir."/".$module."/module_meta.php";
|
||||
$meta_function = $module."_admin_permissions";
|
||||
|
||||
// Module has no permissions, skip it
|
||||
if(function_exists($meta_function) && is_array($meta_function()))
|
||||
{
|
||||
$permission_modules[$module] = $meta_function();
|
||||
$modules[$permission_modules[$module]['disporder']][] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
ksort($modules);
|
||||
foreach($modules as $disp_order => $mod)
|
||||
{
|
||||
if(!is_array($mod))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($mod as $module)
|
||||
{
|
||||
$module_tabs[$module] = $permission_modules[$module]['name'];
|
||||
}
|
||||
}
|
||||
$page->output_tab_control($module_tabs);
|
||||
|
||||
foreach($permission_modules as $key => $module)
|
||||
{
|
||||
echo "<div id=\"tab_{$key}\">\n";
|
||||
$form_container = new FormContainer("{$module['name']}");
|
||||
foreach($module['permissions'] as $action => $title)
|
||||
{
|
||||
$form_container->output_row($title, "", $form->generate_yes_no_radio('permissions['.$key.']['.$action.']', (int)$permission_data[$key][$action], array('yes' => 1, 'no' => 0)), 'permissions['.$key.']['.$action.']');
|
||||
}
|
||||
$form_container->end();
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->update_permissions);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "group")
|
||||
{
|
||||
$plugins->run_hooks("admin_user_admin_permissions_group");
|
||||
|
||||
$page->add_breadcrumb_item($lang->group_permissions);
|
||||
$page->output_header($lang->group_permissions);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'group_permissions');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->group);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
// Get usergroups with ACP access
|
||||
$query = $db->query("
|
||||
SELECT g.title, g.cancp, a.permissions, g.gid
|
||||
FROM ".TABLE_PREFIX."usergroups g
|
||||
LEFT JOIN ".TABLE_PREFIX."adminoptions a ON (a.uid = -g.gid)
|
||||
WHERE g.cancp = 1
|
||||
ORDER BY g.title ASC
|
||||
");
|
||||
while($group = $db->fetch_array($query))
|
||||
{
|
||||
if($group['permissions'] != "")
|
||||
{
|
||||
$perm_type = "group";
|
||||
}
|
||||
else
|
||||
{
|
||||
$perm_type = "default";
|
||||
}
|
||||
$uid = -$group['gid'];
|
||||
|
||||
$group['title'] = htmlspecialchars_uni($group['title']);
|
||||
|
||||
$table->construct_cell("<div class=\"float_right\"><img src=\"styles/{$page->style}/images/icons/{$perm_type}.png\" title=\"{$lang->permissions_type_group}\" alt=\"{$perm_type}\" /></div><div><strong><a href=\"index.php?module=user-admin_permissions&action=edit&uid={$uid}\" title=\"{$lang->edit_group}\">{$group['title']}</a></strong><br /></div>");
|
||||
|
||||
if($group['permissions'] != "")
|
||||
{
|
||||
$popup = new PopupMenu("groupperm_{$uid}", $lang->options);
|
||||
$popup->add_item($lang->edit_permissions, "index.php?module=user-admin_permissions&action=edit&uid={$uid}");
|
||||
|
||||
// Check permissions for Revoke
|
||||
$popup->add_item($lang->revoke_permissions, "index.php?module=user-admin_permissions&action=delete&uid={$uid}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, 'Are you sure you wish to revoke this group\'s permissions?')");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->construct_cell("<a href=\"index.php?module=user-admin_permissions&action=edit&uid={$uid}\">{$lang->set_permissions}</a>", array("class" => "align_center"));
|
||||
}
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_group_perms, array("colspan" => "3"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->group_permissions);
|
||||
|
||||
echo <<<LEGEND
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend>{$lang->legend}</legend>
|
||||
<img src="styles/{$page->style}/images/icons/group.png" alt="{$lang->using_custom_perms}" style="vertical-align: middle;" /> {$lang->using_custom_perms}<br />
|
||||
<img src="styles/{$page->style}/images/icons/default.png" alt="{$lang->using_default_perms}" style="vertical-align: middle;" /> {$lang->using_default_perms}</fieldset>
|
||||
LEGEND;
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_user_admin_permissions_start");
|
||||
|
||||
$page->add_breadcrumb_item($lang->user_permissions);
|
||||
$page->output_header($lang->user_permissions);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'user_permissions');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->user);
|
||||
$table->construct_header($lang->last_active, array("class" => "align_center", "width" => 200));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
// Get usergroups with ACP access
|
||||
$usergroups = array();
|
||||
$query = $db->simple_select("usergroups", "*", "cancp = 1");
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$usergroups[$usergroup['gid']] = $usergroup;
|
||||
}
|
||||
|
||||
if(!empty($usergroups))
|
||||
{
|
||||
// Get users whose primary or secondary usergroup has ACP access
|
||||
$comma = $primary_group_list = $secondary_group_list = '';
|
||||
foreach($usergroups as $gid => $group_info)
|
||||
{
|
||||
$primary_group_list .= $comma.$gid;
|
||||
switch($db->type)
|
||||
{
|
||||
case "pgsql":
|
||||
case "sqlite":
|
||||
$secondary_group_list .= " OR ','|| u.additionalgroups||',' LIKE '%,{$gid},%'";
|
||||
break;
|
||||
default:
|
||||
$secondary_group_list .= " OR CONCAT(',', u.additionalgroups,',') LIKE '%,{$gid},%'";
|
||||
}
|
||||
|
||||
$comma = ',';
|
||||
}
|
||||
|
||||
$group_list = implode(',', array_keys($usergroups));
|
||||
$secondary_groups = ','.$group_list.',';
|
||||
|
||||
// Get usergroups with ACP access
|
||||
$query = $db->query("
|
||||
SELECT g.title, g.cancp, a.permissions, g.gid
|
||||
FROM ".TABLE_PREFIX."usergroups g
|
||||
LEFT JOIN ".TABLE_PREFIX."adminoptions a ON (a.uid = -g.gid)
|
||||
WHERE g.cancp = 1
|
||||
ORDER BY g.title ASC
|
||||
");
|
||||
while($group = $db->fetch_array($query))
|
||||
{
|
||||
$group_permissions[$group['gid']] = $group['permissions'];
|
||||
}
|
||||
|
||||
$query = $db->query("
|
||||
SELECT u.uid, u.username, u.lastactive, u.usergroup, u.additionalgroups, a.permissions
|
||||
FROM ".TABLE_PREFIX."users u
|
||||
LEFT JOIN ".TABLE_PREFIX."adminoptions a ON (a.uid=u.uid)
|
||||
WHERE u.usergroup IN ({$primary_group_list}) {$secondary_group_list}
|
||||
ORDER BY u.username ASC
|
||||
");
|
||||
while($admin = $db->fetch_array($query))
|
||||
{
|
||||
$perm_type = "default";
|
||||
|
||||
if($admin['permissions'] != "")
|
||||
{
|
||||
$perm_type = "user";
|
||||
}
|
||||
else
|
||||
{
|
||||
$groups = explode(",", $admin['additionalgroups'].",".$admin['usergroup']);
|
||||
foreach($groups as $group)
|
||||
{
|
||||
if($group == "") continue;
|
||||
if($group_permissions[$group] != "")
|
||||
{
|
||||
$perm_type = "group";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$usergroup_list = array();
|
||||
|
||||
// Build a list of group memberships that have access to the Admin CP
|
||||
// Primary usergroup?
|
||||
if($usergroups[$admin['usergroup']]['cancp'] == 1)
|
||||
{
|
||||
$usergroup_list[] = "<i>".htmlspecialchars_uni($usergroups[$admin['usergroup']]['title'])."</i>";
|
||||
}
|
||||
|
||||
// Secondary usergroups?
|
||||
$additional_groups = explode(',', $admin['additionalgroups']);
|
||||
if(is_array($additional_groups))
|
||||
{
|
||||
foreach($additional_groups as $gid)
|
||||
{
|
||||
if($usergroups[$gid]['cancp'] == 1)
|
||||
{
|
||||
$usergroup_list[] = htmlspecialchars_uni($usergroups[$gid]['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$usergroup_list = implode($lang->comma, $usergroup_list);
|
||||
|
||||
$username = htmlspecialchars_uni($admin['username']);
|
||||
$table->construct_cell("<div class=\"float_right\"><img src=\"styles/{$page->style}/images/icons/{$perm_type}.png\" title=\"{$lang->perms_type_user}\" alt=\"{$perm_type}\" /></div><div><strong><a href=\"index.php?module=user-admin_permissions&action=edit&uid={$admin['uid']}\" title=\"{$lang->edit_user}\">{$username}</a></strong><br /><small>{$usergroup_list}</small></div>");
|
||||
|
||||
$table->construct_cell(my_date('relative', $admin['lastactive']), array("class" => "align_center"));
|
||||
|
||||
$popup = new PopupMenu("adminperm_{$admin['uid']}", $lang->options);
|
||||
if(!is_super_admin($admin['uid']))
|
||||
{
|
||||
if($admin['permissions'] != "")
|
||||
{
|
||||
$popup->add_item($lang->edit_permissions, "index.php?module=user-admin_permissions&action=edit&uid={$admin['uid']}");
|
||||
$popup->add_item($lang->revoke_permissions, "index.php?module=user-admin_permissions&action=delete&uid={$admin['uid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_perms_deletion2}')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup->add_item($lang->set_permissions, "index.php?module=user-admin_permissions&action=edit&uid={$admin['uid']}");
|
||||
}
|
||||
}
|
||||
$popup->add_item($lang->view_log, "index.php?module=tools-adminlog&uid={$admin['uid']}");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($usergroups) || $table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_user_perms, array("colspan" => "3"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->user_permissions);
|
||||
|
||||
echo <<<LEGEND
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend>{$lang->legend}</legend>
|
||||
<img src="styles/{$page->style}/images/icons/user.png" alt="{$lang->using_individual_perms}" style="vertical-align: middle;" /> {$lang->using_individual_perms}<br />
|
||||
<img src="styles/{$page->style}/images/icons/group.png" alt="{$lang->using_group_perms}" style="vertical-align: middle;" /> {$lang->using_group_perms}<br />
|
||||
<img src="styles/{$page->style}/images/icons/default.png" alt="{$lang->using_default_perms}" style="vertical-align: middle;" /> {$lang->using_default_perms}</fieldset>
|
||||
LEGEND;
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
224
webroot/forum/admin/modules/user/awaiting_activation.php
Normal file
224
webroot/forum/admin/modules/user/awaiting_activation.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?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->awaiting_activation, "index.php?module=user-awaiting_activation");
|
||||
|
||||
$sub_tabs['awaiting_activation'] = array(
|
||||
'title' => $lang->awaiting_activation,
|
||||
'link' => "index.php?module=user-awaiting_activation",
|
||||
'description' => $lang->awaiting_activation_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_awaiting_activation_begin");
|
||||
|
||||
if($mybb->input['action'] == "activate" && $mybb->request_method == "post")
|
||||
{
|
||||
$plugins->run_hooks("admin_user_awaiting_activation_activate");
|
||||
|
||||
if(!is_array($mybb->input['user']))
|
||||
{
|
||||
$mybb->input['user'] = array();
|
||||
}
|
||||
|
||||
$mybb->input['user'] = array_map('intval', $mybb->input['user']);
|
||||
$user_ids = implode(", ", $mybb->input['user']);
|
||||
|
||||
if(empty($user_ids))
|
||||
{
|
||||
flash_message($lang->no_users_selected, 'error');
|
||||
admin_redirect("index.php?module=user-awaiting_activation");
|
||||
}
|
||||
|
||||
$num_activated = $num_deleted = 0;
|
||||
$users_to_delete = array();
|
||||
if($mybb->input['delete']) // Delete selected user(s)
|
||||
{
|
||||
require_once MYBB_ROOT.'inc/datahandlers/user.php';
|
||||
$userhandler = new UserDataHandler('delete');
|
||||
|
||||
$query = $db->simple_select("users", "uid, usergroup", "uid IN ({$user_ids})");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
if($user['usergroup'] == 5)
|
||||
{
|
||||
++$num_deleted;
|
||||
$users_to_delete[] = (int)$user['uid'];
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($users_to_delete))
|
||||
{
|
||||
$userhandler->delete_user($users_to_delete, 1);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_awaiting_activation_activate_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action('deleted', $num_deleted);
|
||||
|
||||
flash_message($lang->success_users_deleted, 'success');
|
||||
admin_redirect("index.php?module=user-awaiting_activation");
|
||||
}
|
||||
else // Activate selected user(s)
|
||||
{
|
||||
$query = $db->simple_select("users", "uid, username, email, usergroup, coppauser", "uid IN ({$user_ids})");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
++$num_activated;
|
||||
if($user['coppauser'])
|
||||
{
|
||||
$updated_user = array(
|
||||
"coppauser" => 0
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->delete_query("awaitingactivation", "uid='{$user['uid']}'");
|
||||
}
|
||||
|
||||
// Move out of awaiting activation if they're in it.
|
||||
if($user['usergroup'] == 5)
|
||||
{
|
||||
$updated_user['usergroup'] = 2;
|
||||
}
|
||||
|
||||
$db->update_query("users", $updated_user, "uid='{$user['uid']}'");
|
||||
|
||||
$message = $lang->sprintf($lang->email_adminactivateaccount, $user['username'], $mybb->settings['bbname'], $mybb->settings['bburl']); my_mail($user['email'], $lang->sprintf($lang->emailsubject_activateaccount, $mybb->settings['bbname']), $message);
|
||||
}
|
||||
|
||||
$cache->update_awaitingactivation();
|
||||
|
||||
$plugins->run_hooks("admin_user_awaiting_activation_activate_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action('activated', $num_activated);
|
||||
|
||||
flash_message($lang->success_users_activated, 'success');
|
||||
admin_redirect("index.php?module=user-awaiting_activation");
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_user_awaiting_activation_start");
|
||||
|
||||
$query = $db->simple_select("users", "COUNT(uid) AS users", "usergroup='5'");
|
||||
$total_rows = $db->fetch_field($query, "users");
|
||||
|
||||
$per_page = 20;
|
||||
|
||||
if($mybb->input['page'] && $mybb->input['page'] > 1)
|
||||
{
|
||||
$mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($mybb->input['page']*$per_page)-$per_page;
|
||||
$pages = ceil($total_rows / $per_page);
|
||||
if($mybb->input['page'] > $pages)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$page->output_header($lang->manage_awaiting_activation);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'awaiting_activation');
|
||||
|
||||
$form = new Form("index.php?module=user-awaiting_activation&action=activate", "post");
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($form->generate_check_box("allbox", 1, '', array('class' => 'checkall')));
|
||||
$table->construct_header($lang->username, array('width' => '20%'));
|
||||
$table->construct_header($lang->registered, array('width' => '15%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->last_active, array('width' => '15%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->email, array('width' => '15%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->ipaddress, array('width' => '10%', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->type, array('class' => 'align_center'));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT u.uid, u.username, u.regdate, u.regip, u.lastactive, u.email, u.coppauser, a.type AS reg_type, a.validated
|
||||
FROM ".TABLE_PREFIX."users u
|
||||
LEFT JOIN ".TABLE_PREFIX."awaitingactivation a ON (a.uid=u.uid)
|
||||
WHERE u.usergroup='5'
|
||||
ORDER BY u.regdate DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$trow = alt_trow();
|
||||
$user['username'] = htmlspecialchars_uni($user['username']);
|
||||
$user['profilelink'] = build_profile_link($user['username'], $user['uid'], "_blank");
|
||||
$user['email'] = htmlspecialchars_uni($user['email']);
|
||||
$user['regdate'] = my_date('relative', $user['regdate']);
|
||||
$user['lastactive'] = my_date('relative', $user['lastactive']);
|
||||
|
||||
if($user['reg_type'] == 'r' || $user['reg_type'] == 'b' && $user['validated'] == 0)
|
||||
{
|
||||
$user['type'] = $lang->email_activation;
|
||||
}
|
||||
elseif($user['coppauser'] == 1)
|
||||
{
|
||||
$user['type'] = $lang->admin_activation_coppa;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user['type'] = $lang->administrator_activation;
|
||||
}
|
||||
|
||||
if(empty($user['regip']))
|
||||
{
|
||||
$user['regip'] = $lang->na;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user['regip'] = my_inet_ntop($db->unescape_binary($user['regip']));
|
||||
}
|
||||
|
||||
$table->construct_cell($form->generate_check_box("user[{$user['uid']}]", $user['uid'], ''));
|
||||
$table->construct_cell($user['profilelink']);
|
||||
$table->construct_cell($user['regdate'], array("class" => "align_center"));
|
||||
$table->construct_cell($user['lastactive'], array("class" => "align_center"));
|
||||
$table->construct_cell($user['email'], array("class" => "align_center"));
|
||||
$table->construct_cell($user['regip'], array("class" => "align_center"));
|
||||
$table->construct_cell($user['type'], array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_users_awaiting_activation, array('colspan' => 7));
|
||||
$table->construct_row();
|
||||
$table->output($lang->manage_awaiting_activation);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->output($lang->manage_awaiting_activation);
|
||||
$buttons[] = $form->generate_submit_button($lang->activate_users, array('onclick' => "return confirm('{$lang->confirm_activate_users}');"));
|
||||
$buttons[] = $form->generate_submit_button($lang->delete_users, array('name' => 'delete', 'onclick' => "return confirm('{$lang->confirm_delete_users}');"));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
}
|
||||
|
||||
$form->end();
|
||||
|
||||
echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=user-awaiting_activation&page={page}");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
609
webroot/forum/admin/modules/user/banning.php
Normal file
609
webroot/forum/admin/modules/user/banning.php
Normal file
@@ -0,0 +1,609 @@
|
||||
<?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->banning, "index.php?module=user-banning");
|
||||
|
||||
|
||||
$sub_tabs['ips'] = array(
|
||||
'title' => $lang->banned_ips,
|
||||
'link' => "index.php?module=config-banning",
|
||||
);
|
||||
|
||||
$sub_tabs['bans'] = array(
|
||||
'title' => $lang->banned_accounts,
|
||||
'link' => "index.php?module=user-banning",
|
||||
'description' => $lang->banned_accounts_desc
|
||||
);
|
||||
|
||||
$sub_tabs['usernames'] = array(
|
||||
'title' => $lang->disallowed_usernames,
|
||||
'link' => "index.php?module=config-banning&type=usernames",
|
||||
);
|
||||
|
||||
$sub_tabs['emails'] = array(
|
||||
'title' => $lang->disallowed_email_addresses,
|
||||
'link' => "index.php?module=config-banning&type=emails",
|
||||
);
|
||||
|
||||
// Fetch banned groups
|
||||
$query = $db->simple_select("usergroups", "gid,title", "isbannedgroup=1", array('order_by' => 'title'));
|
||||
$banned_groups = array();
|
||||
while($group = $db->fetch_array($query))
|
||||
{
|
||||
$banned_groups[$group['gid']] = $group['title'];
|
||||
}
|
||||
|
||||
// Fetch ban times
|
||||
$ban_times = fetch_ban_times();
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_begin");
|
||||
|
||||
if($mybb->input['action'] == "prune")
|
||||
{
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("banned", "*", "uid='{$mybb->input['uid']}'");
|
||||
$ban = $db->fetch_array($query);
|
||||
|
||||
if(!$ban['uid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_ban, 'error');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$user = get_user($ban['uid']);
|
||||
|
||||
if(is_super_admin($user['uid']) && ($mybb->user['uid'] != $user['uid'] && !is_super_admin($mybb->user['uid'])))
|
||||
{
|
||||
flash_message($lang->cannot_perform_action_super_admin_general, 'error');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_prune");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
require_once MYBB_ROOT."inc/class_moderation.php";
|
||||
$moderation = new Moderation();
|
||||
|
||||
$query = $db->simple_select("threads", "tid", "uid='{$user['uid']}'");
|
||||
while($thread = $db->fetch_array($query))
|
||||
{
|
||||
$moderation->delete_thread($thread['tid']);
|
||||
}
|
||||
|
||||
$query = $db->simple_select("posts", "pid", "uid='{$user['uid']}'");
|
||||
while($post = $db->fetch_array($query))
|
||||
{
|
||||
$moderation->delete_post($post['pid']);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_prune_commit");
|
||||
|
||||
$cache->update_reportedcontent();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($user['uid'], $user['username']);
|
||||
|
||||
flash_message($lang->success_pruned, 'success');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-banning&action=prune&uid={$user['uid']}", $lang->confirm_prune);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "lift")
|
||||
{
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("banned", "*", "uid='{$mybb->input['uid']}'");
|
||||
$ban = $db->fetch_array($query);
|
||||
|
||||
if(!$ban['uid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_ban, 'error');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$user = get_user($ban['uid']);
|
||||
|
||||
if(is_super_admin($user['uid']) && ($mybb->user['uid'] != $user['uid'] && !is_super_admin($mybb->user['uid'])))
|
||||
{
|
||||
flash_message($lang->cannot_perform_action_super_admin_general, 'error');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_lift");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$updated_group = array(
|
||||
'usergroup' => $ban['oldgroup'],
|
||||
'additionalgroups' => $ban['oldadditionalgroups'],
|
||||
'displaygroup' => $ban['olddisplaygroup']
|
||||
);
|
||||
$db->delete_query("banned", "uid='{$ban['uid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_lift_commit");
|
||||
|
||||
$db->update_query("users", $updated_group, "uid='{$ban['uid']}'");
|
||||
|
||||
$cache->update_banned();
|
||||
$cache->update_moderators();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($ban['uid'], $user['username']);
|
||||
|
||||
flash_message($lang->success_ban_lifted, 'success');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-banning&action=lift&uid={$ban['uid']}", $lang->confirm_lift_ban);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("banned", "*", "uid='{$mybb->input['uid']}'");
|
||||
$ban = $db->fetch_array($query);
|
||||
|
||||
$user = get_user($ban['uid']);
|
||||
|
||||
if(!$ban['uid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_ban, 'error');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!$ban['uid'])
|
||||
{
|
||||
$errors[] = $lang->error_invalid_username;
|
||||
}
|
||||
// Is the user we're trying to ban a super admin and we're not?
|
||||
else if(is_super_admin($ban['uid']) && !is_super_admin($ban['uid']))
|
||||
{
|
||||
$errors[] = $lang->error_no_perm_to_ban;
|
||||
}
|
||||
|
||||
if($ban['uid'] == $mybb->user['uid'])
|
||||
{
|
||||
$errors[] = $lang->error_ban_self;
|
||||
}
|
||||
|
||||
// No errors? Update
|
||||
if(!$errors)
|
||||
{
|
||||
// Ban the user
|
||||
if($mybb->input['bantime'] == '---')
|
||||
{
|
||||
$lifted = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lifted = ban_date2timestamp($mybb->input['bantime'], $ban['dateline']);
|
||||
}
|
||||
|
||||
$reason = my_substr($mybb->input['reason'], 0, 255);
|
||||
|
||||
if(count($banned_groups) == 1)
|
||||
{
|
||||
$group = array_keys($banned_groups);
|
||||
$mybb->input['usergroup'] = $group[0];
|
||||
}
|
||||
|
||||
$update_array = array(
|
||||
'gid' => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
'dateline' => TIME_NOW,
|
||||
'bantime' => $db->escape_string($mybb->input['bantime']),
|
||||
'lifted' => $db->escape_string($lifted),
|
||||
'reason' => $db->escape_string($reason)
|
||||
);
|
||||
|
||||
$db->update_query('banned', $update_array, "uid='{$ban['uid']}'");
|
||||
|
||||
// Move the user to the banned group
|
||||
$update_array = array(
|
||||
'usergroup' => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
'displaygroup' => 0,
|
||||
'additionalgroups' => '',
|
||||
);
|
||||
$db->update_query('users', $update_array, "uid = {$ban['uid']}");
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_edit_commit");
|
||||
|
||||
$cache->update_banned();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($ban['uid'], $user['username']);
|
||||
|
||||
flash_message($lang->success_ban_updated, 'success');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
}
|
||||
$page->add_breadcrumb_item($lang->edit_ban);
|
||||
$page->output_header($lang->edit_ban);
|
||||
|
||||
$sub_tabs = array();
|
||||
$sub_tabs['edit'] = array(
|
||||
'title' => $lang->edit_ban,
|
||||
'description' => $lang->edit_ban_desc
|
||||
);
|
||||
$page->output_nav_tabs($sub_tabs, "edit");
|
||||
|
||||
$form = new Form("index.php?module=user-banning&action=edit&uid={$ban['uid']}", "post");
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $ban);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_ban);
|
||||
$form_container->output_row($lang->ban_username, "", htmlspecialchars_uni($user['username']));
|
||||
$form_container->output_row($lang->ban_reason, "", $form->generate_text_area('reason', $mybb->input['reason'], array('id' => 'reason', 'maxlength' => '255')), 'reason');
|
||||
if(count($banned_groups) > 1)
|
||||
{
|
||||
$form_container->output_row($lang->ban_group, $lang->ban_group_desc, $form->generate_select_box('usergroup', $banned_groups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
|
||||
}
|
||||
|
||||
if($mybb->input['bantime'] == 'perm' || $mybb->input['bantime'] == '' || $mybb->input['lifted'] == 'perm' ||$mybb->input['lifted'] == '')
|
||||
{
|
||||
$mybb->input['bantime'] = '---';
|
||||
$mybb->input['lifted'] = '---';
|
||||
}
|
||||
|
||||
foreach($ban_times as $time => $period)
|
||||
{
|
||||
if($time != '---')
|
||||
{
|
||||
$friendly_time = my_date("D, jS M Y @ {$mybb->settings['timeformat']}", ban_date2timestamp($time));
|
||||
$period = "{$period} ({$friendly_time})";
|
||||
}
|
||||
$length_list[$time] = $period;
|
||||
}
|
||||
$form_container->output_row($lang->ban_time, "", $form->generate_select_box('bantime', $length_list, $mybb->input['bantime'], array('id' => 'bantime')), 'bantime');
|
||||
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->update_ban);
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$where_sql_full = $where_sql = '';
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_start");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$options = array(
|
||||
'fields' => array('username', 'usergroup', 'additionalgroups', 'displaygroup')
|
||||
);
|
||||
|
||||
$user = get_user_by_username($mybb->input['username'], $options);
|
||||
|
||||
// Are we searching a user?
|
||||
if(isset($mybb->input['search']))
|
||||
{
|
||||
$where_sql = 'uid=\''.(int)$user['uid'].'\'';
|
||||
$where_sql_full = 'WHERE b.uid=\''.(int)$user['uid'].'\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$user['uid'])
|
||||
{
|
||||
$errors[] = $lang->error_invalid_username;
|
||||
}
|
||||
// Is the user we're trying to ban a super admin and we're not?
|
||||
else if(is_super_admin($user['uid']) && !is_super_admin($mybb->user['uid']))
|
||||
{
|
||||
$errors[] = $lang->error_no_perm_to_ban;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->simple_select("banned", "uid", "uid='{$user['uid']}'");
|
||||
if($db->fetch_field($query, "uid"))
|
||||
{
|
||||
$errors[] = $lang->error_already_banned;
|
||||
}
|
||||
|
||||
// Get PRIMARY usergroup information
|
||||
$usergroups = $cache->read("usergroups");
|
||||
if(!empty($usergroups[$user['usergroup']]) && $usergroups[$user['usergroup']]['isbannedgroup'] == 1)
|
||||
{
|
||||
$errors[] = $lang->error_already_banned;
|
||||
}
|
||||
}
|
||||
|
||||
if($user['uid'] == $mybb->user['uid'])
|
||||
{
|
||||
$errors[] = $lang->error_ban_self;
|
||||
}
|
||||
|
||||
// No errors? Insert
|
||||
if(!$errors)
|
||||
{
|
||||
// Ban the user
|
||||
if($mybb->input['bantime'] == '---')
|
||||
{
|
||||
$lifted = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lifted = ban_date2timestamp($mybb->input['bantime']);
|
||||
}
|
||||
|
||||
$reason = my_substr($mybb->input['reason'], 0, 255);
|
||||
|
||||
if(count($banned_groups) == 1)
|
||||
{
|
||||
$group = array_keys($banned_groups);
|
||||
$mybb->input['usergroup'] = $group[0];
|
||||
}
|
||||
|
||||
$insert_array = array(
|
||||
'uid' => $user['uid'],
|
||||
'gid' => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
'oldgroup' => $user['usergroup'],
|
||||
'oldadditionalgroups' => $user['additionalgroups'],
|
||||
'olddisplaygroup' => $user['displaygroup'],
|
||||
'admin' => (int)$mybb->user['uid'],
|
||||
'dateline' => TIME_NOW,
|
||||
'bantime' => $db->escape_string($mybb->input['bantime']),
|
||||
'lifted' => $db->escape_string($lifted),
|
||||
'reason' => $db->escape_string($reason)
|
||||
);
|
||||
$db->insert_query('banned', $insert_array);
|
||||
|
||||
// Move the user to the banned group
|
||||
$update_array = array(
|
||||
'usergroup' => $mybb->get_input('usergroup', MyBB::INPUT_INT),
|
||||
'displaygroup' => 0,
|
||||
'additionalgroups' => '',
|
||||
);
|
||||
|
||||
$db->delete_query("forumsubscriptions", "uid = '{$user['uid']}'");
|
||||
$db->delete_query("threadsubscriptions", "uid = '{$user['uid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_user_banning_start_commit");
|
||||
|
||||
$db->update_query('users', $update_array, "uid = '{$user['uid']}'");
|
||||
|
||||
$cache->update_banned();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($user['uid'], $user['username'], $lifted);
|
||||
|
||||
flash_message($lang->success_banned, 'success');
|
||||
admin_redirect("index.php?module=user-banning");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->output_header($lang->banned_accounts);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, "bans");
|
||||
|
||||
$query = $db->simple_select("banned", "COUNT(*) AS ban_count", $where_sql);
|
||||
$ban_count = $db->fetch_field($query, "ban_count");
|
||||
|
||||
$per_page = 20;
|
||||
|
||||
if($mybb->input['page'] > 0)
|
||||
{
|
||||
$current_page = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($current_page-1)*$per_page;
|
||||
$pages = $ban_count / $per_page;
|
||||
$pages = ceil($pages);
|
||||
if($current_page > $pages)
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = 0;
|
||||
$current_page = 1;
|
||||
}
|
||||
|
||||
$pagination = draw_admin_pagination($current_page, $per_page, $ban_count, "index.php?module=user-banning&page={page}");
|
||||
|
||||
$form = new Form("index.php?module=user-banning", "post");
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
if($mybb->input['uid'] && !$mybb->input['username'])
|
||||
{
|
||||
$user = get_user($mybb->input['uid']);
|
||||
$mybb->input['username'] = $user['username'];
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->ban_a_user);
|
||||
$form_container->output_row($lang->ban_username, $lang->autocomplete_enabled, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
|
||||
$form_container->output_row($lang->ban_reason, "", $form->generate_text_area('reason', $mybb->input['reason'], array('id' => 'reason', 'maxlength' => '255')), 'reason');
|
||||
if(count($banned_groups) > 1)
|
||||
{
|
||||
$form_container->output_row($lang->ban_group, $lang->add_ban_group_desc, $form->generate_select_box('usergroup', $banned_groups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
|
||||
}
|
||||
foreach($ban_times as $time => $period)
|
||||
{
|
||||
if($time != "---")
|
||||
{
|
||||
$friendly_time = my_date("D, jS M Y @ {$mybb->settings['timeformat']}", ban_date2timestamp($time));
|
||||
$period = "{$period} ({$friendly_time})";
|
||||
}
|
||||
$length_list[$time] = $period;
|
||||
}
|
||||
$form_container->output_row($lang->ban_time, "", $form->generate_select_box('bantime', $length_list, $mybb->input['bantime'], array('id' => 'bantime')), 'bantime');
|
||||
|
||||
$form_container->end();
|
||||
|
||||
// Autocompletion for usernames
|
||||
echo '
|
||||
<link rel="stylesheet" href="../jscripts/select2/select2.css">
|
||||
<script type="text/javascript" src="../jscripts/select2/select2.min.js?ver=1804"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
$("#username").select2({
|
||||
placeholder: "'.$lang->search_for_a_user.'",
|
||||
minimumInputLength: 2,
|
||||
multiple: false,
|
||||
ajax: { // instead of writing the function to execute the request we use Select2\'s convenient helper
|
||||
url: "../xmlhttp.php?action=get_users",
|
||||
dataType: \'json\',
|
||||
data: function (term, page) {
|
||||
return {
|
||||
query: term, // search term
|
||||
};
|
||||
},
|
||||
results: function (data, page) { // parse the results into the format expected by Select2.
|
||||
// since we are using custom formatting functions we do not need to alter remote JSON data
|
||||
return {results: data};
|
||||
}
|
||||
},
|
||||
initSelection: function(element, callback) {
|
||||
var query = $(element).val();
|
||||
if (query !== "") {
|
||||
$.ajax("../xmlhttp.php?action=get_users&getone=1", {
|
||||
data: {
|
||||
query: query
|
||||
},
|
||||
dataType: "json"
|
||||
}).done(function(data) { callback(data); });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
$(\'[for=username]\').on(\'click\', function(){
|
||||
$("#username").select2(\'open\');
|
||||
return false;
|
||||
});
|
||||
// -->
|
||||
</script>';
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->ban_user);
|
||||
$buttons[] = $form->generate_submit_button($lang->search_for_a_user, array('name' => 'search'));
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
echo '<br />';
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->user);
|
||||
$table->construct_header($lang->ban_lifts_on, array("class" => "align_center", "width" => 150));
|
||||
$table->construct_header($lang->time_left, array("class" => "align_center", "width" => 150));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
|
||||
$table->construct_header($lang->moderation, array("class" => "align_center", "colspan" => 1, "width" => 200));
|
||||
|
||||
// Fetch bans
|
||||
$query = $db->query("
|
||||
SELECT b.*, a.username AS adminuser, u.username
|
||||
FROM ".TABLE_PREFIX."banned b
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (b.uid=u.uid)
|
||||
LEFT JOIN ".TABLE_PREFIX."users a ON (b.admin=a.uid)
|
||||
{$where_sql_full}
|
||||
ORDER BY dateline DESC
|
||||
LIMIT {$start}, {$per_page}
|
||||
");
|
||||
|
||||
// Get the banned users
|
||||
while($ban = $db->fetch_array($query))
|
||||
{
|
||||
$profile_link = build_profile_link(htmlspecialchars_uni($ban['username']), $ban['uid'], "_blank");
|
||||
$ban_date = my_date($mybb->settings['dateformat'], $ban['dateline']);
|
||||
if($ban['lifted'] == 'perm' || $ban['lifted'] == '' || $ban['bantime'] == 'perm' || $ban['bantime'] == '---')
|
||||
{
|
||||
$ban_period = $lang->permenantly;
|
||||
$time_remaining = $lifts_on = $lang->na;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ban_period = $lang->for." ".$ban_times[$ban['bantime']];
|
||||
|
||||
$remaining = $ban['lifted']-TIME_NOW;
|
||||
$time_remaining = nice_time($remaining, array('short' => 1, 'seconds' => false))."";
|
||||
|
||||
if($remaining < 3600)
|
||||
{
|
||||
$time_remaining = "<span style=\"color: red;\">{$time_remaining}</span>";
|
||||
}
|
||||
else if($remaining < 86400)
|
||||
{
|
||||
$time_remaining = "<span style=\"color: maroon;\">{$time_remaining}</span>";
|
||||
}
|
||||
else if($remaining < 604800)
|
||||
{
|
||||
$time_remaining = "<span style=\"color: green;\">{$time_remaining}</span>";
|
||||
}
|
||||
|
||||
$lifts_on = my_date($mybb->settings['dateformat'], $ban['lifted']);
|
||||
}
|
||||
|
||||
if(!$ban['adminuser'])
|
||||
{
|
||||
if($ban['admin'] == 0)
|
||||
{
|
||||
$ban['adminuser'] = $lang->mybb_engine;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ban['adminuser'] = $ban['admin'];
|
||||
}
|
||||
}
|
||||
|
||||
$table->construct_cell($lang->sprintf($lang->bannedby_x_on_x, $profile_link, htmlspecialchars_uni($ban['adminuser']), $ban_date, $ban_period));
|
||||
$table->construct_cell($lifts_on, array("class" => "align_center"));
|
||||
$table->construct_cell($time_remaining, array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-banning&action=edit&uid={$ban['uid']}\">{$lang->edit}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-banning&action=lift&uid={$ban['uid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_lift_ban}');\">{$lang->lift}</a>", array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-banning&action=prune&uid={$ban['uid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_prune}');\">{$lang->prune_threads_and_posts}</a>", array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_banned_users, array("colspan" => "6"));
|
||||
$table->construct_row();
|
||||
}
|
||||
$table->output($lang->banned_accounts);
|
||||
echo $pagination;
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
775
webroot/forum/admin/modules/user/group_promotions.php
Normal file
775
webroot/forum/admin/modules/user/group_promotions.php
Normal file
@@ -0,0 +1,775 @@
|
||||
<?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->user_group_promotions, "index.php?module=user-group_promotions");
|
||||
|
||||
$sub_tabs['usergroup_promotions'] = array(
|
||||
'title' => $lang->user_group_promotions,
|
||||
'link' => "index.php?module=user-group_promotions",
|
||||
'description' => $lang->user_group_promotions_desc
|
||||
);
|
||||
|
||||
$sub_tabs['add_promotion'] = array(
|
||||
'title' => $lang->add_new_promotion,
|
||||
'link' => "index.php?module=user-group_promotions&action=add",
|
||||
'description' => $lang->add_new_promotion_desc
|
||||
);
|
||||
|
||||
$sub_tabs['promotion_logs'] = array(
|
||||
'title' => $lang->view_promotion_logs,
|
||||
'link' => "index.php?module=user-group_promotions&action=logs",
|
||||
'description' => $lang->view_promotion_logs_desc
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_begin");
|
||||
|
||||
if($mybb->input['action'] == "disable")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['pid']))
|
||||
{
|
||||
flash_message($lang->error_no_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("promotions", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
||||
$promotion = $db->fetch_array($query);
|
||||
|
||||
if(!$promotion['pid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_disable");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$update_promotion = array(
|
||||
"enabled" => 0
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_disable_commit");
|
||||
|
||||
$db->update_query("promotions", $update_promotion, "pid = '{$promotion['pid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($promotion['pid'], $promotion['title']);
|
||||
|
||||
flash_message($lang->success_promo_disabled, 'success');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-group_promotions&action=disable&pid={$promotion['pid']}", $lang->confirm_promo_disable);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['pid']))
|
||||
{
|
||||
flash_message($lang->error_no_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("promotions", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
||||
$promotion = $db->fetch_array($query);
|
||||
|
||||
if(!$promotion['pid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("promotions", "pid = '{$promotion['pid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_delete_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($promotion['pid'], $promotion['title']);
|
||||
|
||||
flash_message($lang->success_promo_deleted, 'success');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-group_promotions&action=delete&pid={$mybb->input['pid']}", $lang->confirm_promo_deletion);
|
||||
}
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "enable")
|
||||
{
|
||||
if(!verify_post_check($mybb->input['my_post_key']))
|
||||
{
|
||||
flash_message($lang->invalid_post_verify_key2, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['pid']))
|
||||
{
|
||||
flash_message($lang->error_no_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("promotions", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
||||
$promotion = $db->fetch_array($query);
|
||||
|
||||
if(!$promotion['pid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_enable");
|
||||
|
||||
$update_promotion = array(
|
||||
"enabled" => 1
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_enable_commit");
|
||||
|
||||
$db->update_query("promotions", $update_promotion, "pid = '{$promotion['pid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($promotion['pid'], $promotion['title']);
|
||||
|
||||
flash_message($lang->success_promo_enabled, 'success');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
if(!trim($mybb->input['pid']))
|
||||
{
|
||||
flash_message($lang->error_no_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$query = $db->simple_select("promotions", "*", "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'");
|
||||
$promotion = $db->fetch_array($query);
|
||||
|
||||
if(!$promotion)
|
||||
{
|
||||
flash_message($lang->error_invalid_promo_id, 'error');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_no_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_no_desc;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['requirements']))
|
||||
{
|
||||
$errors[] = $lang->error_no_requirements;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['originalusergroup']))
|
||||
{
|
||||
$errors[] = $lang->error_no_orig_usergroup;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['newusergroup']))
|
||||
{
|
||||
$errors[] = $lang->error_no_new_usergroup;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['usergroupchangetype']))
|
||||
{
|
||||
$errors[] = $lang->error_no_usergroup_change_type;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(in_array('*', $mybb->input['originalusergroup']))
|
||||
{
|
||||
$mybb->input['originalusergroup'] = '*';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['originalusergroup'] = implode(',', array_map('intval', $mybb->input['originalusergroup']));
|
||||
}
|
||||
|
||||
$allowed_operators = array('>', '>=', '=', '<=', '<');
|
||||
$operator_fields = array('posttype', 'threadtype', 'reputationtype', 'referralstype', 'warningstype');
|
||||
|
||||
foreach($operator_fields as $field)
|
||||
{
|
||||
if(!in_array($mybb->get_input($field), $allowed_operators))
|
||||
{
|
||||
$mybb->input[$field] = '=';
|
||||
}
|
||||
}
|
||||
|
||||
$allowed_times = array('hours', 'days', 'weeks', 'months', 'years');
|
||||
$time_fields = array('timeregisteredtype', 'timeonlinetype');
|
||||
|
||||
foreach($time_fields as $field)
|
||||
{
|
||||
if(!in_array($mybb->get_input($field), $allowed_times))
|
||||
{
|
||||
$mybb->input[$field] = 'days';
|
||||
}
|
||||
}
|
||||
|
||||
$update_promotion = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"posts" => $mybb->get_input('postcount', MyBB::INPUT_INT),
|
||||
"posttype" => $db->escape_string($mybb->input['posttype']),
|
||||
"threads" => $mybb->get_input('threadcount', MyBB::INPUT_INT),
|
||||
"threadtype" => $db->escape_string($mybb->input['threadtype']),
|
||||
"registered" => $mybb->get_input('timeregistered', MyBB::INPUT_INT),
|
||||
"registeredtype" => $db->escape_string($mybb->input['timeregisteredtype']),
|
||||
"online" => $mybb->get_input('timeonline', MyBB::INPUT_INT),
|
||||
"onlinetype" => $db->escape_string($mybb->input['timeonlinetype']),
|
||||
"reputations" => $mybb->get_input('reputationcount', MyBB::INPUT_INT),
|
||||
"reputationtype" => $db->escape_string($mybb->input['reputationtype']),
|
||||
"referrals" => $mybb->get_input('referrals', MyBB::INPUT_INT),
|
||||
"referralstype" => $db->escape_string($mybb->input['referralstype']),
|
||||
"warnings" => $mybb->get_input('warnings', MyBB::INPUT_INT),
|
||||
"warningstype" => $db->escape_string($mybb->input['warningstype']),
|
||||
"requirements" => $db->escape_string(implode(",", $mybb->input['requirements'])),
|
||||
"originalusergroup" => $db->escape_string($mybb->input['originalusergroup']),
|
||||
"newusergroup" => $mybb->get_input('newusergroup', MyBB::INPUT_INT),
|
||||
"usergrouptype" => $db->escape_string($mybb->input['usergroupchangetype']),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_edit_commit");
|
||||
|
||||
$db->update_query("promotions", $update_promotion, "pid = '{$promotion['pid']}'");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($promotion['pid'], $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_promo_updated, 'success');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_promotion);
|
||||
$page->output_header($lang->user_group_promotions." - ".$lang->edit_promotion);
|
||||
|
||||
$sub_tabs = array();
|
||||
$sub_tabs['edit_promotion'] = array(
|
||||
'title' => $lang->edit_promotion,
|
||||
'link' => "index.php?module=user-group_promotions&action=edit",
|
||||
'description' => $lang->edit_promotion_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_promotion');
|
||||
$form = new Form("index.php?module=user-group_promotions&action=edit", "post", "edit");
|
||||
echo $form->generate_hidden_field("pid", $promotion['pid']);
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['title'] = $promotion['title'];
|
||||
$mybb->input['description'] = $promotion['description'];
|
||||
$mybb->input['requirements'] = explode(',', $promotion['requirements']);
|
||||
$mybb->input['reputationcount'] = $promotion['reputations'];
|
||||
$mybb->input['reputationtype'] = $promotion['reputationtype'];
|
||||
$mybb->input['postcount'] = $promotion['posts'];
|
||||
$mybb->input['posttype'] = $promotion['posttype'];
|
||||
$mybb->input['threadcount'] = $promotion['threads'];
|
||||
$mybb->input['threadtype'] = $promotion['threadtype'];
|
||||
$mybb->input['referrals'] = $promotion['referrals'];
|
||||
$mybb->input['referralstype'] = $promotion['referralstype'];
|
||||
$mybb->input['warnings'] = $promotion['warnings'];
|
||||
$mybb->input['warningstype'] = $promotion['warningstype'];
|
||||
$mybb->input['timeregistered'] = $promotion['registered'];
|
||||
$mybb->input['timeregisteredtype'] = $promotion['registeredtype'];
|
||||
$mybb->input['timeonline'] = $promotion['online'];
|
||||
$mybb->input['timeonlinetype'] = $promotion['onlinetype'];
|
||||
$mybb->input['originalusergroup'] = explode(',', $promotion['originalusergroup']);
|
||||
$mybb->input['usergroupchangetype'] = $promotion['usergrouptype'];
|
||||
$mybb->input['newusergroup'] = $promotion['newusergroup'];
|
||||
$mybb->input['enabled'] = $promotion['enabled'];
|
||||
$mybb->input['logging'] = $promotion['logging'];
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_promotion);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_desc." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
|
||||
$options = array(
|
||||
"postcount" => $lang->post_count,
|
||||
"threadcount" => $lang->thread_count,
|
||||
"reputation" => $lang->reputation,
|
||||
"referrals" => $lang->referrals,
|
||||
"warnings" => $lang->warning_points,
|
||||
"timeregistered" => $lang->time_registered,
|
||||
"timeonline" => $lang->time_online
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->promo_requirements." <em>*</em>", $lang->promo_requirements_desc, $form->generate_select_box('requirements[]', $options, $mybb->input['requirements'], array('id' => 'requirements', 'multiple' => true, 'size' => 5)), 'requirements');
|
||||
|
||||
$options_type = array(
|
||||
">" => $lang->greater_than,
|
||||
">=" => $lang->greater_than_or_equal_to,
|
||||
"=" => $lang->equal_to,
|
||||
"<=" => $lang->less_than_or_equal_to,
|
||||
"<" => $lang->less_than
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->post_count, $lang->post_count_desc, $form->generate_numeric_field('postcount', $mybb->input['postcount'], array('id' => 'postcount', 'min' => 0))." ".$form->generate_select_box("posttype", $options_type, $mybb->input['posttype'], array('id' => 'posttype')), 'postcount');
|
||||
|
||||
$form_container->output_row($lang->thread_count, $lang->thread_count_desc, $form->generate_numeric_field('threadcount', $mybb->input['threadcount'], array('id' => 'threadcount', 'min' => 0))." ".$form->generate_select_box("threadtype", $options_type, $mybb->input['threadtype'], array('id' => 'threadtype')), 'threadcount');
|
||||
|
||||
$form_container->output_row($lang->reputation_count, $lang->reputation_count_desc, $form->generate_numeric_field('reputationcount', $mybb->input['reputationcount'], array('id' => 'reputationcount', 'min' => 0))." ".$form->generate_select_box("reputationtype", $options_type, $mybb->input['reputationtype'], array('id' => 'reputationtype')), 'reputationcount');
|
||||
|
||||
$options = array(
|
||||
"hours" => $lang->hours,
|
||||
"days" => $lang->days,
|
||||
"weeks" => $lang->weeks,
|
||||
"months" => $lang->months,
|
||||
"years" => $lang->years
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->referral_count, $lang->referral_count_desc, $form->generate_numeric_field('referrals', $mybb->input['referrals'], array('id' => 'referrals', 'min' => 0))." ".$form->generate_select_box("referralstype", $options_type, $mybb->input['referralstype'], array('id' => 'referralstype')), 'referrals');
|
||||
|
||||
$form_container->output_row($lang->warning_points, $lang->warning_points_desc, $form->generate_numeric_field('warnings', $mybb->input['warnings'], array('id' => 'warnings', 'min' => 0))." ".$form->generate_select_box("warningstype", $options_type, $mybb->input['warningstype'], array('id' => 'warningstype')), 'warnings');
|
||||
|
||||
$form_container->output_row($lang->time_registered, $lang->time_registered_desc, $form->generate_numeric_field('timeregistered', $mybb->input['timeregistered'], array('id' => 'timeregistered', 'min' => 0))." ".$form->generate_select_box("timeregisteredtype", $options, $mybb->input['timeregisteredtype'], array('id' => 'timeregisteredtype')), 'timeregistered');
|
||||
|
||||
$form_container->output_row($lang->time_online, $lang->time_online_desc, $form->generate_numeric_field('timeonline', $mybb->input['timeonline'], array('id' => 'timeonline', 'min' => 0))." ".$form->generate_select_box("timeonlinetype", $options, $mybb->input['timeonlinetype'], array('id' => 'timeonlinetype')), 'timeonline');
|
||||
|
||||
$options = array();
|
||||
|
||||
$query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$options[(int)$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
|
||||
}
|
||||
|
||||
$form_container->output_row($lang->orig_user_group." <em>*</em>", $lang->orig_user_group_desc, $form->generate_select_box('originalusergroup[]', $options, $mybb->input['originalusergroup'], array('id' => 'originalusergroup', 'multiple' => true, 'size' => 5)), 'originalusergroup');
|
||||
|
||||
unset($options['*']); // Remove the all usergroups option
|
||||
$form_container->output_row($lang->new_user_group." <em>*</em>", $lang->new_user_group_desc, $form->generate_select_box('newusergroup', $options, $mybb->input['newusergroup'], array('id' => 'newusergroup')), 'newusergroup');
|
||||
|
||||
$options = array(
|
||||
'primary' => $lang->primary_user_group,
|
||||
'secondary' => $lang->secondary_user_group
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->user_group_change_type." <em>*</em>", $lang->user_group_change_type_desc, $form->generate_select_box('usergroupchangetype', $options, $mybb->input['usergroupchangetype'], array('id' => 'usergroupchangetype')), 'usergroupchangetype');
|
||||
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $mybb->input['enabled'], true));
|
||||
|
||||
$form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $mybb->input['logging'], true));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->update_promotion);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_user_group_promotions_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_no_title;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['description']))
|
||||
{
|
||||
$errors[] = $lang->error_no_desc;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['requirements']))
|
||||
{
|
||||
$errors[] = $lang->error_no_requirements;
|
||||
}
|
||||
|
||||
if(empty($mybb->input['originalusergroup']))
|
||||
{
|
||||
$errors[] = $lang->error_no_orig_usergroup;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['newusergroup']))
|
||||
{
|
||||
$errors[] = $lang->error_no_new_usergroup;
|
||||
}
|
||||
|
||||
if(!trim($mybb->input['usergroupchangetype']))
|
||||
{
|
||||
$errors[] = $lang->error_no_usergroup_change_type;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
if(in_array('*', $mybb->input['originalusergroup']))
|
||||
{
|
||||
$mybb->input['originalusergroup'] = '*';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['originalusergroup'] = implode(',', array_map('intval', $mybb->input['originalusergroup']));
|
||||
}
|
||||
|
||||
$allowed_operators = array('>', '>=', '=', '<=', '<');
|
||||
$operator_fields = array('posttype', 'threadtype', 'reputationtype', 'referralstype', 'warningstype');
|
||||
|
||||
foreach($operator_fields as $field)
|
||||
{
|
||||
if(!in_array($mybb->get_input($field), $allowed_operators))
|
||||
{
|
||||
$mybb->input[$field] = '=';
|
||||
}
|
||||
}
|
||||
|
||||
$allowed_times = array('hours', 'days', 'weeks', 'months', 'years');
|
||||
$time_fields = array('timeregisteredtype', 'timeonlinetype');
|
||||
|
||||
foreach($time_fields as $field)
|
||||
{
|
||||
if(!in_array($mybb->get_input($field), $allowed_times))
|
||||
{
|
||||
$mybb->input[$field] = 'days';
|
||||
}
|
||||
}
|
||||
|
||||
$new_promotion = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"description" => $db->escape_string($mybb->input['description']),
|
||||
"posts" => $mybb->get_input('postcount', MyBB::INPUT_INT),
|
||||
"posttype" => $db->escape_string($mybb->input['posttype']),
|
||||
"threads" => $mybb->get_input('threadcount', MyBB::INPUT_INT),
|
||||
"threadtype" => $db->escape_string($mybb->input['threadtype']),
|
||||
"registered" => $mybb->get_input('timeregistered', MyBB::INPUT_INT),
|
||||
"registeredtype" => $db->escape_string($mybb->input['timeregisteredtype']),
|
||||
"online" => $mybb->get_input('timeonline', MyBB::INPUT_INT),
|
||||
"onlinetype" => $db->escape_string($mybb->input['timeonlinetype']),
|
||||
"reputations" => $mybb->get_input('reputationcount', MyBB::INPUT_INT),
|
||||
"reputationtype" => $db->escape_string($mybb->input['reputationtype']),
|
||||
"referrals" => $mybb->get_input('referrals', MyBB::INPUT_INT),
|
||||
"referralstype" => $db->escape_string($mybb->input['referralstype']),
|
||||
"warnings" => $mybb->get_input('warnings', MyBB::INPUT_INT),
|
||||
"warningstype" => $db->escape_string($mybb->input['warningstype']),
|
||||
"requirements" => $db->escape_string(implode(",", $mybb->input['requirements'])),
|
||||
"originalusergroup" => $db->escape_string($mybb->input['originalusergroup']),
|
||||
"usergrouptype" => $db->escape_string($mybb->input['usergroupchangetype']),
|
||||
"newusergroup" => $mybb->get_input('newusergroup', MyBB::INPUT_INT),
|
||||
"enabled" => $mybb->get_input('enabled', MyBB::INPUT_INT),
|
||||
"logging" => $mybb->get_input('logging', MyBB::INPUT_INT)
|
||||
);
|
||||
|
||||
$pid = $db->insert_query("promotions", $new_promotion);
|
||||
|
||||
$plugins->run_hooks("admin_user_group_promotions_add_commit");
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($pid, $mybb->input['title']);
|
||||
|
||||
flash_message($lang->success_promo_added, 'success');
|
||||
admin_redirect("index.php?module=user-group_promotions");
|
||||
}
|
||||
}
|
||||
$page->add_breadcrumb_item($lang->add_new_promotion);
|
||||
$page->output_header($lang->user_group_promotions." - ".$lang->add_new_promotion);
|
||||
|
||||
$sub_tabs['usergroup_promotions'] = array(
|
||||
'title' => $lang->user_group_promotions,
|
||||
'link' => "index.php?module=user-group_promotions"
|
||||
);
|
||||
|
||||
$sub_tabs['add_promotion'] = array(
|
||||
'title' => $lang->add_new_promotion,
|
||||
'link' => "index.php?module=user-group_promotions&action=add",
|
||||
'description' => $lang->add_new_promotion_desc
|
||||
);
|
||||
|
||||
$sub_tabs['promotion_logs'] = array(
|
||||
'title' => $lang->view_promotion_logs,
|
||||
'link' => "index.php?module=user-group_promotions&action=logs"
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_promotion');
|
||||
$form = new Form("index.php?module=user-group_promotions&action=add", "post", "add");
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['reputationcount'] = '0';
|
||||
$mybb->input['referrals'] = '0';
|
||||
$mybb->input['warnings'] = '0';
|
||||
$mybb->input['postcount'] = '0';
|
||||
$mybb->input['threadcount'] = '0';
|
||||
$mybb->input['timeregistered'] = '0';
|
||||
$mybb->input['timeregisteredtype'] = 'days';
|
||||
$mybb->input['timeonline'] = '0';
|
||||
$mybb->input['timeonlinetype'] = 'days';
|
||||
$mybb->input['originalusergroup'] = '*';
|
||||
$mybb->input['newusergroup'] = '2';
|
||||
$mybb->input['enabled'] = '1';
|
||||
$mybb->input['logging'] = '1';
|
||||
}
|
||||
$form_container = new FormContainer($lang->add_new_promotion);
|
||||
$form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->short_desc." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
|
||||
|
||||
$options = array(
|
||||
"postcount" => $lang->post_count,
|
||||
"threadcount" => $lang->thread_count,
|
||||
"reputation" => $lang->reputation,
|
||||
"referrals" => $lang->referrals,
|
||||
"warnings" => $lang->warning_points,
|
||||
"timeregistered" => $lang->time_registered,
|
||||
"timeonline" => $lang->time_online
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->promo_requirements." <em>*</em>", $lang->promo_requirements_desc, $form->generate_select_box('requirements[]', $options, $mybb->input['requirements'], array('id' => 'requirements', 'multiple' => true, 'size' => 5)), 'requirements');
|
||||
|
||||
$options_type = array(
|
||||
">" => $lang->greater_than,
|
||||
">=" => $lang->greater_than_or_equal_to,
|
||||
"=" => $lang->equal_to,
|
||||
"<=" => $lang->less_than_or_equal_to,
|
||||
"<" => $lang->less_than
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->post_count, $lang->post_count_desc, $form->generate_numeric_field('postcount', $mybb->input['postcount'], array('id' => 'postcount', 'min' => 0))." ".$form->generate_select_box("posttype", $options_type, $mybb->input['posttype'], array('id' => 'posttype')), 'postcount');
|
||||
|
||||
$form_container->output_row($lang->thread_count, $lang->thread_count_desc, $form->generate_numeric_field('threadcount', $mybb->input['threadcount'], array('id' => 'threadcount', 'min' => 0))." ".$form->generate_select_box("threadtype", $options_type, $mybb->input['threadtype'], array('id' => 'threadtype')), 'threadcount');
|
||||
|
||||
$form_container->output_row($lang->reputation_count, $lang->reputation_count_desc, $form->generate_numeric_field('reputationcount', $mybb->input['reputationcount'], array('id' => 'reputationcount', 'min' => 0))." ".$form->generate_select_box("reputationtype", $options_type, $mybb->input['reputationtype'], array('id' => 'reputationtype')), 'reputationcount');
|
||||
|
||||
$options = array(
|
||||
"hours" => $lang->hours,
|
||||
"days" => $lang->days,
|
||||
"weeks" => $lang->weeks,
|
||||
"months" => $lang->months,
|
||||
"years" => $lang->years
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->referral_count, $lang->referral_count_desc, $form->generate_numeric_field('referrals', $mybb->input['referrals'], array('id' => 'referrals', 'min' => 0))." ".$form->generate_select_box("referralstype", $options_type, $mybb->input['referralstype'], array('id' => 'referralstype')), 'referrals');
|
||||
|
||||
$form_container->output_row($lang->warning_points, $lang->warning_points_desc, $form->generate_numeric_field('warnings', $mybb->input['warnings'], array('id' => 'warnings', 'min' => 0))." ".$form->generate_select_box("warningstype", $options_type, $mybb->input['warningstype'], array('id' => 'warningstype')), 'warnings');
|
||||
|
||||
$form_container->output_row($lang->time_registered, $lang->time_registered_desc, $form->generate_numeric_field('timeregistered', $mybb->input['timeregistered'], array('id' => 'timeregistered', 'min' => 0))." ".$form->generate_select_box("timeregisteredtype", $options, $mybb->input['timeregisteredtype'], array('id' => 'timeregisteredtype')), 'timeregistered');
|
||||
|
||||
$form_container->output_row($lang->time_online, $lang->time_online_desc, $form->generate_numeric_field('timeonline', $mybb->input['timeonline'], array('id' => 'timeonline', 'min' => 0))." ".$form->generate_select_box("timeonlinetype", $options, $mybb->input['timeonlinetype'], array('id' => 'timeonlinetype')), 'timeonline');
|
||||
$options = array();
|
||||
|
||||
$query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
|
||||
while($usergroup = $db->fetch_array($query))
|
||||
{
|
||||
$options[(int)$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
|
||||
}
|
||||
|
||||
$form_container->output_row($lang->orig_user_group." <em>*</em>", $lang->orig_user_group_desc, $form->generate_select_box('originalusergroup[]', $options, $mybb->input['originalusergroup'], array('id' => 'originalusergroup', 'multiple' => true, 'size' => 5)), 'originalusergroup');
|
||||
|
||||
unset($options['*']);
|
||||
$form_container->output_row($lang->new_user_group." <em>*</em>", $lang->new_user_group_desc, $form->generate_select_box('newusergroup', $options, $mybb->input['newusergroup'], array('id' => 'newusergroup')), 'newusergroup');
|
||||
|
||||
$options = array(
|
||||
'primary' => $lang->primary_user_group,
|
||||
'secondary' => $lang->secondary_user_group
|
||||
);
|
||||
|
||||
$form_container->output_row($lang->user_group_change_type." <em>*</em>", $lang->user_group_change_type_desc, $form->generate_select_box('usergroupchangetype', $options, $mybb->input['usergroupchangetype'], array('id' => 'usergroupchangetype')), 'usergroupchangetype');
|
||||
|
||||
$form_container->output_row($lang->enabled." <em>*</em>", "", $form->generate_yes_no_radio("enabled", $mybb->input['enabled'], true));
|
||||
|
||||
$form_container->output_row($lang->enable_logging." <em>*</em>", "", $form->generate_yes_no_radio("logging", $mybb->input['logging'], true));
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->update_promotion);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "logs")
|
||||
{
|
||||
$plugins->run_hooks("admin_user_group_promotions_logs");
|
||||
|
||||
$query = $db->simple_select("promotionlogs", "COUNT(plid) as promotionlogs");
|
||||
$total_rows = $db->fetch_field($query, "promotionlogs");
|
||||
|
||||
if($mybb->get_input('page', MyBB::INPUT_INT) > 1)
|
||||
{
|
||||
$mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
||||
$start = ($mybb->input['page']*20)-20;
|
||||
$pages = ceil($total_rows / 20);
|
||||
if($mybb->input['page'] > $pages)
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input['page'] = 1;
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->promotion_logs);
|
||||
$page->output_header($lang->user_group_promotions." - ".$lang->promotion_logs);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'promotion_logs');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->promoted_user, array("class" => "align_center", "width" => '20%'));
|
||||
$table->construct_header($lang->user_group_change_type, array("class" => "align_center", "width" => '20%'));
|
||||
$table->construct_header($lang->orig_user_group, array("class" => "align_center", "width" => '20%'));
|
||||
$table->construct_header($lang->new_user_group, array("class" => "align_center", "width" => '20%'));
|
||||
$table->construct_header($lang->time_promoted, array("class" => "align_center", "width" => '20%'));
|
||||
|
||||
$query = $db->query("
|
||||
SELECT pl.*,u.username
|
||||
FROM ".TABLE_PREFIX."promotionlogs pl
|
||||
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=pl.uid)
|
||||
ORDER BY dateline DESC
|
||||
LIMIT {$start}, 20
|
||||
");
|
||||
while($log = $db->fetch_array($query))
|
||||
{
|
||||
$log['username'] = "<a href=\"index.php?module=user-view&action=edit&uid={$log['uid']}\">".htmlspecialchars_uni($log['username'])."</a>";
|
||||
|
||||
if($log['type'] == "secondary" || (!empty($log['oldusergroup']) && strstr(",", $log['oldusergroup'])))
|
||||
{
|
||||
$log['oldusergroup'] = "<i>".$lang->multiple_usergroups."</i>";
|
||||
$log['newusergroup'] = htmlspecialchars_uni($groupscache[$log['newusergroup']]['title']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['oldusergroup'] = htmlspecialchars_uni($groupscache[$log['oldusergroup']]['title']);
|
||||
$log['newusergroup'] = htmlspecialchars_uni($groupscache[$log['newusergroup']]['title']);
|
||||
}
|
||||
|
||||
if($log['type'] == "secondary")
|
||||
{
|
||||
$log['type'] = $lang->secondary;
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['type'] = $lang->primary;
|
||||
}
|
||||
|
||||
$log['dateline'] = my_date('relative', $log['dateline']);
|
||||
$table->construct_cell($log['username']);
|
||||
$table->construct_cell($log['type'], array('style' => 'text-align: center;'));
|
||||
$table->construct_cell($log['oldusergroup'], array('style' => 'text-align: center;'));
|
||||
$table->construct_cell($log['newusergroup'], array('style' => 'text-align: center;'));
|
||||
$table->construct_cell($log['dateline'], array('style' => 'text-align: center;'));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_promotion_logs, array("colspan" => "5"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->promotion_logs);
|
||||
|
||||
echo "<br />".draw_admin_pagination($mybb->input['page'], "20", $total_rows, "index.php?module=user-group_promotions&action=logs&page={page}");
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_user_group_promotions_start");
|
||||
|
||||
$page->output_header($lang->promotion_manager);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'usergroup_promotions');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->promotion);
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
|
||||
|
||||
$query = $db->simple_select("promotions", "*", "", array("order_by" => "title", "order_dir" => "asc"));
|
||||
while($promotion = $db->fetch_array($query))
|
||||
{
|
||||
$promotion['title'] = htmlspecialchars_uni($promotion['title']);
|
||||
$promotion['description'] = htmlspecialchars_uni($promotion['description']);
|
||||
if($promotion['enabled'] == 1)
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\" style=\"vertical-align: middle;\" /> ";
|
||||
}
|
||||
|
||||
$table->construct_cell("<div>{$icon}<strong><a href=\"index.php?module=user-group_promotions&action=edit&pid={$promotion['pid']}\">{$promotion['title']}</a></strong><br /><small>{$promotion['description']}</small></div>");
|
||||
|
||||
$popup = new PopupMenu("promotion_{$promotion['pid']}", $lang->options);
|
||||
$popup->add_item($lang->edit_promotion, "index.php?module=user-group_promotions&action=edit&pid={$promotion['pid']}");
|
||||
if($promotion['enabled'] == 1)
|
||||
{
|
||||
$popup->add_item($lang->disable_promotion, "index.php?module=user-group_promotions&action=disable&pid={$promotion['pid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_disable}')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$popup->add_item($lang->enable_promotion, "index.php?module=user-group_promotions&action=enable&pid={$promotion['pid']}&my_post_key={$mybb->post_code}");
|
||||
}
|
||||
$popup->add_item($lang->delete_promotion, "index.php?module=user-group_promotions&action=delete&pid={$promotion['pid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_deletion}')");
|
||||
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_promotions_set, array("colspan" => "2"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
$table->output($lang->user_group_promotions);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
1564
webroot/forum/admin/modules/user/groups.php
Normal file
1564
webroot/forum/admin/modules/user/groups.php
Normal file
File diff suppressed because it is too large
Load Diff
8
webroot/forum/admin/modules/user/index.html
Normal file
8
webroot/forum/admin/modules/user/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1668
webroot/forum/admin/modules/user/mass_mail.php
Normal file
1668
webroot/forum/admin/modules/user/mass_mail.php
Normal file
File diff suppressed because it is too large
Load Diff
97
webroot/forum/admin/modules/user/module_meta.php
Normal file
97
webroot/forum/admin/modules/user/module_meta.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true
|
||||
*/
|
||||
function user_meta()
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$sub_menu = array();
|
||||
$sub_menu['10'] = array("id" => "users", "title" => $lang->users, "link" => "index.php?module=user-users");
|
||||
$sub_menu['20'] = array("id" => "awaiting_activation", "title" => $lang->awaiting_activation, "link" => "index.php?module=user-awaiting_activation");
|
||||
$sub_menu['30'] = array("id" => "groups", "title" => $lang->groups, "link" => "index.php?module=user-groups");
|
||||
$sub_menu['40'] = array("id" => "titles", "title" => $lang->user_titles, "link" => "index.php?module=user-titles");
|
||||
$sub_menu['50'] = array("id" => "banning", "title" => $lang->banning, "link" => "index.php?module=user-banning");
|
||||
$sub_menu['60'] = array("id" => "admin_permissions", "title" => $lang->admin_permissions, "link" => "index.php?module=user-admin_permissions");
|
||||
$sub_menu['70'] = array("id" => "mass_mail", "title" => $lang->mass_mail, "link" => "index.php?module=user-mass_mail");
|
||||
$sub_menu['80'] = array("id" => "group_promotions", "title" => $lang->group_promotions, "link" => "index.php?module=user-group_promotions");
|
||||
|
||||
$sub_menu = $plugins->run_hooks("admin_user_menu", $sub_menu);
|
||||
|
||||
$page->add_menu_item($lang->users_and_groups, "user", "index.php?module=user", 30, $sub_menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function user_action_handler($action)
|
||||
{
|
||||
global $page, $lang, $plugins;
|
||||
|
||||
$page->active_module = "user";
|
||||
|
||||
$actions = array(
|
||||
'awaiting_activation' => array('active' => 'awaiting_activation', 'file' => 'awaiting_activation.php'),
|
||||
'group_promotions' => array('active' => 'group_promotions', 'file' => 'group_promotions.php'),
|
||||
'admin_permissions' => array('active' => 'admin_permissions', 'file' => 'admin_permissions.php'),
|
||||
'titles' => array('active' => 'titles', 'file' => 'titles.php'),
|
||||
'banning' => array('active' => 'banning', 'file' => 'banning.php'),
|
||||
'groups' => array('active' => 'groups', 'file' => 'groups.php'),
|
||||
'mass_mail' => array('active' => 'mass_mail', 'file' => 'mass_mail.php'),
|
||||
'users' => array('active' => 'users', 'file' => 'users.php')
|
||||
);
|
||||
|
||||
$actions = $plugins->run_hooks("admin_user_action_handler", $actions);
|
||||
|
||||
if(isset($actions[$action]))
|
||||
{
|
||||
$page->active_action = $actions[$action]['active'];
|
||||
return $actions[$action]['file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->active_action = "users";
|
||||
return "users.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function user_admin_permissions()
|
||||
{
|
||||
global $lang, $plugins;
|
||||
|
||||
$admin_permissions = array(
|
||||
"users" => $lang->can_manage_users,
|
||||
"awaiting_activation" => $lang->can_manage_awaiting_activation,
|
||||
"groups" => $lang->can_manage_user_groups,
|
||||
"titles" => $lang->can_manage_user_titles,
|
||||
"banning" => $lang->can_manage_user_bans,
|
||||
"admin_permissions" => $lang->can_manage_admin_permissions,
|
||||
"mass_mail" => $lang->can_send_mass_mail,
|
||||
"group_promotions" => $lang->can_manage_group_promotions
|
||||
);
|
||||
|
||||
$admin_permissions = $plugins->run_hooks("admin_user_permissions", $admin_permissions);
|
||||
|
||||
return array("name" => $lang->users_and_groups, "permissions" => $admin_permissions, "disporder" => 30);
|
||||
}
|
||||
280
webroot/forum/admin/modules/user/titles.php
Normal file
280
webroot/forum/admin/modules/user/titles.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?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->user_titles, "index.php?module=user-titles");
|
||||
|
||||
if($mybb->input['action'] == "add" || !$mybb->input['action'])
|
||||
{
|
||||
$sub_tabs['manage_titles'] = array(
|
||||
'title' => $lang->user_titles,
|
||||
'link' => "index.php?module=user-titles",
|
||||
'description' => $lang->user_titles_desc
|
||||
);
|
||||
$sub_tabs['add_title'] = array(
|
||||
'title' => $lang->add_new_user_title,
|
||||
'link' => "index.php?module=user-titles&action=add",
|
||||
'description' => $lang->add_new_user_title_desc
|
||||
);
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_begin");
|
||||
|
||||
if($mybb->input['action'] == "add")
|
||||
{
|
||||
$plugins->run_hooks("admin_user_titles_add");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['posts']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_posts;
|
||||
}
|
||||
|
||||
$query = $db->simple_select("usertitles", "utid", "posts= '".$mybb->get_input('posts', MyBB::INPUT_INT)."'");
|
||||
if($db->num_rows($query))
|
||||
{
|
||||
$errors[] = $lang->error_cannot_have_same_posts;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$new_title = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"posts" => $mybb->get_input('posts', MyBB::INPUT_INT),
|
||||
"stars" => $mybb->get_input('stars', MyBB::INPUT_INT),
|
||||
"starimage" => $db->escape_string($mybb->input['starimage'])
|
||||
);
|
||||
|
||||
$utid = $db->insert_query("usertitles", $new_title);
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_add_commit");
|
||||
|
||||
$cache->update_usertitles();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($utid, $mybb->input['title'], $mybb->input['posts']);
|
||||
|
||||
flash_message($lang->success_user_title_created, 'success');
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, array(
|
||||
'stars' => '1',
|
||||
'starimage' => '{theme}/star.png',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->add_new_user_title);
|
||||
$page->output_header($lang->user_titles." - ".$lang->add_new_user_title);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'add_title');
|
||||
$form = new Form("index.php?module=user-titles&action=add", "post");
|
||||
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->add_new_user_title);
|
||||
$form_container->output_row($lang->title_to_assign."<em>*</em>", $lang->title_to_assign_desc, $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_numeric_field('posts', $mybb->input['posts'], array('id' => 'posts', 'min' => 0)), 'posts');
|
||||
$form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_numeric_field('stars', $mybb->input['stars'], array('id' => 'stars', 'min' => 0)), 'stars');
|
||||
$form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->input['starimage'], array('id' => 'starimage')), 'starimage');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_user_title);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "edit")
|
||||
{
|
||||
$query = $db->simple_select("usertitles", "*", "utid='".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
|
||||
$usertitle = $db->fetch_array($query);
|
||||
|
||||
if(!$usertitle['utid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_user_title, 'error');
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_edit");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
if(!trim($mybb->input['title']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_title;
|
||||
}
|
||||
|
||||
if(!isset($mybb->input['posts']))
|
||||
{
|
||||
$errors[] = $lang->error_missing_posts;
|
||||
}
|
||||
|
||||
$query = $db->simple_select("usertitles", "utid", "posts= '".$mybb->get_input('posts', MyBB::INPUT_INT)."' AND utid!= '".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
|
||||
if($db->num_rows($query))
|
||||
{
|
||||
$errors[] = $lang->error_cannot_have_same_posts;
|
||||
}
|
||||
|
||||
if(!$errors)
|
||||
{
|
||||
$updated_title = array(
|
||||
"title" => $db->escape_string($mybb->input['title']),
|
||||
"posts" => $mybb->get_input('posts', MyBB::INPUT_INT),
|
||||
"stars" => $mybb->get_input('stars', MyBB::INPUT_INT),
|
||||
"starimage" => $db->escape_string($mybb->input['starimage'])
|
||||
);
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_edit_commit");
|
||||
|
||||
$db->update_query("usertitles", $updated_title, "utid='{$usertitle['utid']}'");
|
||||
|
||||
$cache->update_usertitles();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($usertitle['utid'], $mybb->input['title'], $mybb->input['posts']);
|
||||
|
||||
flash_message($lang->success_user_title_updated, 'success');
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
}
|
||||
|
||||
$page->add_breadcrumb_item($lang->edit_user_title);
|
||||
$page->output_header($lang->user_titles." - ".$lang->edit_user_title);
|
||||
|
||||
$sub_tabs['edit_title'] = array(
|
||||
'title' => $lang->edit_user_title,
|
||||
'link' => "index.php?module=user-titles&action=edit&utid=".$usertitle['utid'],
|
||||
'description' => $lang->edit_user_title_desc
|
||||
);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'edit_title');
|
||||
$form = new Form("index.php?module=user-titles&action=edit&utid={$usertitle['utid']}", "post");
|
||||
|
||||
|
||||
if($errors)
|
||||
{
|
||||
$page->output_inline_error($errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mybb->input = array_merge($mybb->input, $usertitle);
|
||||
}
|
||||
|
||||
$form_container = new FormContainer($lang->edit_user_title);
|
||||
$form_container->output_row($lang->title_to_assign."<em>*</em>", $lang->title_to_assign_desc, $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
|
||||
$form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_numeric_field('posts', $mybb->input['posts'], array('id' => 'posts', 'min' => 0)), 'posts');
|
||||
$form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_numeric_field('stars', $mybb->input['stars'], array('id' => 'stars', 'min' => 0)), 'stars');
|
||||
$form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->input['starimage'], array('id' => 'starimage')), 'starimage');
|
||||
$form_container->end();
|
||||
|
||||
$buttons[] = $form->generate_submit_button($lang->save_user_title);
|
||||
|
||||
$form->output_submit_wrapper($buttons);
|
||||
$form->end();
|
||||
|
||||
$page->output_footer();
|
||||
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "delete")
|
||||
{
|
||||
$query = $db->simple_select("usertitles", "*", "utid='".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
|
||||
$usertitle = $db->fetch_array($query);
|
||||
|
||||
if(!$usertitle['utid'])
|
||||
{
|
||||
flash_message($lang->error_invalid_user_title, 'error');
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
|
||||
// User clicked no
|
||||
if($mybb->input['no'])
|
||||
{
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_delete");
|
||||
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$db->delete_query("usertitles", "utid='{$usertitle['utid']}'");
|
||||
|
||||
$plugins->run_hooks("admin_user_titles_delete_commit");
|
||||
|
||||
$cache->update_usertitles();
|
||||
|
||||
// Log admin action
|
||||
log_admin_action($usertitle['utid'], $usertitle['title'], $usertitle['posts']);
|
||||
|
||||
flash_message($lang->success_user_title_deleted, 'success');
|
||||
admin_redirect("index.php?module=user-titles");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->output_confirm_action("index.php?module=user-titles&action=delete&utid={$usertitle['utid']}", $lang->user_title_deletion_confirmation);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$mybb->input['action'])
|
||||
{
|
||||
$plugins->run_hooks("admin_user_titles_start");
|
||||
|
||||
$page->output_header($lang->manage_user_titles);
|
||||
|
||||
$page->output_nav_tabs($sub_tabs, 'manage_titles');
|
||||
|
||||
$table = new Table;
|
||||
$table->construct_header($lang->user_title);
|
||||
$table->construct_header($lang->minimum_posts, array('width' => '130', 'class' => 'align_center'));
|
||||
$table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
|
||||
|
||||
$query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts'));
|
||||
while($usertitle = $db->fetch_array($query))
|
||||
{
|
||||
$usertitle['title'] = htmlspecialchars_uni($usertitle['title']);
|
||||
$table->construct_cell("<a href=\"index.php?module=user-titles&action=edit&utid={$usertitle['utid']}\"><strong>{$usertitle['title']}</strong></a>");
|
||||
$table->construct_cell($usertitle['posts'], array("class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-titles&action=edit&utid={$usertitle['utid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_cell("<a href=\"index.php?module=user-titles&action=delete&utid={$usertitle['utid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->user_title_deletion_confirmation}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
|
||||
$table->construct_row();
|
||||
}
|
||||
|
||||
if($table->num_rows() == 0)
|
||||
{
|
||||
$table->construct_cell($lang->no_user_titles, array('colspan' => 4));
|
||||
$table->construct_row();
|
||||
$no_results = true;
|
||||
}
|
||||
|
||||
$table->output($lang->manage_user_titles);
|
||||
|
||||
$page->output_footer();
|
||||
}
|
||||
4308
webroot/forum/admin/modules/user/users.php
Normal file
4308
webroot/forum/admin/modules/user/users.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user