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();
|
||||
}
|
||||
Reference in New Issue
Block a user