function main_page()
{
    $form = new Form('index.php?module=cloudflare-purge_cache&action=purge', 'post');
    $form_container = new FormContainer('Purge Cache');
    $form_container->output_row('Purge Entire Cache', 'Remove ALL files from CloudFlare\'s cache. This will include javascript, stylesheets and images. CloudFlare can take up to 3 hours to recache resources again<br /><b>Note: </b>This may have dramatic affects on your origin server load after performing this action.', $form->generate_yes_no_radio('purge_input', 0));
    $form_container->output_row('Purge by URL', 'Granularly remove one or more files from CloudFlare\'s cache either by specifying the URL<br /><b>Note: </b><u>One</u> URL per line (max: 30)', $form->generate_text_area('urls'));
    $form_container->end();
    $buttons[] = $form->generate_submit_button('Submit');
    $form->output_submit_wrapper($buttons);
    $form->end();
}
Example #2
0
        $protected = 0;
        if ($mybb->input['protected']) {
            $protected = 1;
        }
        $arr = array('authors' => intval($mybb->user['uid']), 'title' => $db->escape_string($mybb->input['title']), 'content' => $db->escape_string($mybb->input['message']), 'original' => $db->escape_string($mybb->input['message']), 'protected' => $protected, 'lastauthor' => $db->escape_string($mybb->user['username']), 'lastauthorid' => $db->escape_string($mybb->user['uid']), 'category' => (int) $category);
        $db->insert_query('wiki', $arr);
        $updates = $cache->read('wiki_articles');
        $updates[$db->insert_id()] = $title;
        $cache->update('wiki_articles', $updates);
        flash_message($lang->wiki_new_done, 'success');
        admin_redirect('index.php?module=wiki-articles');
    }
    $page->output_nav_tabs($sub_tabs, 'wiki_articles_new');
    $form = new Form('', 'post');
    $form_container = new FormContainer($lang->wiki_articles_new);
    $form_container->output_row($lang->wiki_new_title, $lang->wiki_new_title_desc, $form->generate_text_box('title', '', array('id' => 'title')));
    $form_container->output_row($lang->wiki_new_content, $lang->wiki_new_content_desc, $form->generate_text_area('message', '', array('id' => 'message', 'style' => 'width: 100%; height: 300px;')));
    $form_container->output_row($lang->wiki_new_protect, $lang->wiki_new_protect_desc, $form->generate_yes_no_radio('protected', '1', true));
    $query = $db->simple_select('wiki_categories', '*');
    $options = array();
    while ($row = $db->fetch_array($query)) {
        $options[$row['cid']] = $row['title'];
    }
    $form_container->output_row($lang->wiki_new_cat, $lang->wiki_new_cat_desc, $form->generate_select_box('category', $options, '', array('id' => 'category', 'size' => '1')));
    $form_container->end();
    $buttons = array();
    $buttons[] = $form->generate_submit_button($lang->wiki_commit);
    $form->output_submit_wrapper($buttons);
    $form->end();
}
$page->output_footer();
    $enddatemonth .= "<option value=\"10\" {$endmonthsel['10']}>{$lang->october}</option>\n";
    $startdatemonth .= "<option value=\"11\" {$startmonthsel['11']}>{$lang->november}</option>\n";
    $enddatemonth .= "<option value=\"11\" {$endmonthsel['11']}>{$lang->november}</option>\n";
    $startdatemonth .= "<option value=\"12\" {$startmonthsel['12']}>{$lang->december}</option>\n";
    $enddatemonth .= "<option value=\"12\" {$endmonthsel['12']}>{$lang->december}</option>\n";
    if (isset($preview)) {
        $form_container = new FormContainer($lang->announcement_preview);
        $form_container->output_row($preview['subject'], "", $preview['message'], 'preview');
        $form_container->end();
    }
    $form_container = new FormContainer($lang->add_an_announcement);
    $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
    $form_container->output_row($lang->start_date . " <em>*</em>", $lang->start_date_desc, "<select name=\"starttime_day\">\n{$startdateday}</select>\n &nbsp; \n<select name=\"starttime_month\">\n{$startdatemonth}</select>\n &nbsp; \n<input type=\"text\" name=\"starttime_year\" value=\"{$startdateyear}\" size=\"4\" maxlength=\"4\" class=\"text_input\" />\n - {$lang->time} " . $form->generate_text_box('starttime_time', $mybb->input['starttime_time'], array('id' => 'starttime_time', 'style' => 'width: 50px;')));
    $actions = "<script type=\"text/javascript\">\n\tfunction checkAction(id)\n\t{\n\t\tvar checked = '';\n\n\t\t\$('.'+id+'s_check').each(function(e, val)\n\t\t{\n\t\t\tif(\$(this).prop('checked') == true)\n\t\t\t{\n\t\t\t\tchecked = \$(this).val();\n\t\t\t}\n\t\t});\n\t\t\$('.'+id+'s').each(function(e)\n\t\t{\n\t\t\t\$(this).hide();\n\t\t});\n\t\tif(\$('#'+id+'_'+checked))\n\t\t{\n\t\t\t\$('#'+id+'_'+checked).show();\n\t\t}\n\t}\n</script>\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"1\" {$endtime_checked[1]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->set_time}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"endtime_1\" class=\"endtimes\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td><select name=\"endtime_day\">\n{$enddateday}</select>\n &nbsp; \n<select name=\"endtime_month\">\n{$enddatemonth}</select>\n &nbsp; \n<input type=\"text\" name=\"endtime_year\" value=\"{$enddateyear}\" size=\"4\" maxlength=\"4\" />\n - {$lang->time} " . $form->generate_text_box('endtime_time', $mybb->input['endtime_time'], array('id' => 'endtime_time', 'style' => 'width: 50px;')) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"endtime_type\" value=\"2\" {$endtime_checked[2]} class=\"endtimes_check\" onclick=\"checkAction('endtime');\" style=\"vertical-align: middle;\" /> <strong>{$lang->never}</strong></label></dt>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('endtime');\n\t</script>";
    $form_container->output_row($lang->end_date . " <em>*</em>", $lang->end_date_desc, $actions);
    $form_container->output_row($lang->message . " <em>*</em>", "", $form->generate_text_area('message', $mybb->input['message'], array('id' => 'message')), 'message');
    $form_container->output_row($lang->forums_to_appear_in . " <em>*</em>", $lang->forums_to_appear_in_desc, $form->generate_forum_select('fid', $mybb->input['fid'], array('size' => 5, 'main_option' => $lang->all_forums)));
    $form_container->output_row($lang->allow_html . " <em>*</em>", "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml'], array('style' => 'width: 2em;')));
    $form_container->output_row($lang->allow_mycode . " <em>*</em>", "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode'], array('style' => 'width: 2em;')));
    $form_container->output_row($lang->allow_smilies . " <em>*</em>", "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies'], array('style' => 'width: 2em;')));
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_announcement);
    $buttons[] = $form->generate_submit_button($lang->preview_announcement, array('name' => 'preview'));
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
if ($mybb->input['action'] == "delete") {
    $query = $db->simple_select("announcements", "*", "aid='{$mybb->input['aid']}'");
    $announcement = $db->fetch_array($query);
    // Does the announcement not exist?
Example #4
0
 // Provide the user with a warning of what they're about to do
 $table = new Table();
 $lang->mass_ban_info = $lang->sprintf($lang->mass_ban_info, count($selected));
 $table->construct_cell($lang->mass_ban_info);
 $table->construct_row();
 $table->output($lang->important);
 // If there's any errors, display inline
 if ($errors) {
     $page->output_inline_error($errors);
 }
 $form = new Form("index.php?module=user-users", "post");
 echo $form->generate_hidden_field('action', 'inline_edit');
 echo $form->generate_hidden_field('inline_action', 'multiban');
 echo $form->generate_hidden_field('processed', '1');
 $form_container = new FormContainer('<div class="float_right"><a href="index.php?module=user-users&amp;action=inline_edit&amp;inline_action=multilift&amp;my_post_key=' . $mybb->post_code . '">' . $lang->lift_bans . '</a></div>' . $lang->mass_ban);
 $form_container->output_row($lang->ban_reason, "", $form->generate_text_area('reason', $mybb->input['reason'], array('id' => 'reason', 'maxlength' => '255')), 'reason');
 $ban_times = fetch_ban_times();
 foreach ($ban_times as $time => $period) {
     if ($time != '---') {
         $friendly_time = my_date("D, jS M Y @ g:ia", ban_date2timestamp($time));
         $period = "{$period} ({$friendly_time})";
     }
     $length_list[$time] = $period;
 }
 $form_container->output_row($lang->ban_time, "", $form->generate_select_box('bantime', $length_list, $mybb->input['bantime'], array('id' => 'bantime')), 'bantime');
 $form_container->end();
 $buttons[] = $form->generate_submit_button($lang->ban_users);
 $form->output_submit_wrapper($buttons);
 $form->end();
 $page->output_footer();
 break;
Example #5
0
    }
    if ($admin_options['codepress'] != 0) {
        $page->extra_header .= '
	<link type="text/css" href="./jscripts/codepress/languages/codepress-php.css" rel="stylesheet" id="cp-lang-style" />
	<script type="text/javascript" src="./jscripts/codepress/codepress.js"></script>
	<script type="text/javascript">
		CodePress.language = \'php\';
	</script>';
    }
    $page->add_breadcrumb_item($lang->search_replace);
    $page->output_header($lang->search_replace);
    $page->output_nav_tabs($sub_tabs, 'search_replace');
    $form = new Form("index.php?module=style/templates&amp;action=search_replace", "post", "do_template");
    echo $form->generate_hidden_field('type', "templates");
    $form_container = new FormContainer($lang->search_replace);
    $form_container->output_row($lang->search_for, "", $form->generate_text_area('find', $mybb->input['find'], array('id' => 'find', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 200px;')));
    $form_container->output_row($lang->replace_with, "", $form->generate_text_area('replace', $mybb->input['replace'], array('id' => 'replace', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 200px;')));
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->find_and_replace);
    $form->output_submit_wrapper($buttons);
    $form->end();
    echo "<br />";
    $form = new Form("index.php?module=style/templates&amp;action=search_replace", "post", "do_title");
    echo $form->generate_hidden_field('type', "titles");
    $form_container = new FormContainer($lang->search_template_names);
    $form_container->output_row($lang->search_for, "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
    $form_container->end();
    $buttons = array();
    $buttons[] = $form->generate_submit_button($lang->find_templates);
    $buttons[] = $form->generate_reset_button($lang->reset);
    $form->output_submit_wrapper($buttons);
Example #6
0
 $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_strpos($smilie['image'], "p://") || substr($smilie['image'], 0, 1) == "/") {
         $image = $smilie['image'];
     } else {
         $image = "../" . $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();
     $dlitem['grplist'] = $mybb->input['grplist'];
 }
 // Prepare the data
 if (!is_array($dlitem['grplist'])) {
     $dlitem['grplist'] = explode(',', $dlitem['grplist']);
 }
 // create a standard form container
 $form_container = new FormContainer($lang->downloads_dlmngr_edit);
 // create the save flag
 echo $form->generate_hidden_field("save", "save", array('id' => "save")) . "\n";
 // display the text fields
 // output_row(title, desc, item, something I just set to the same as the ID)
 // generate_INPUTTYPE(name, vlaue, array(html modifiers))
 $form_container->output_row($lang->downloads_dlmngr_title, $lang->downloads_dlmngr_title_desc, $form->generate_text_box('title', $dlitem['title'], array('id' => 'title')), 'title');
 $form_container->output_row($lang->downloads_dlmngr_desc_short, $lang->downloads_dlmngr_desc_short_desc, $form->generate_text_box('desc_short', $dlitem['desc_short'], array('id' => 'desc_short')), 'desc_short');
 $form_container->output_row($lang->downloads_dlmngr_description, $lang->downloads_dlmngr_description_desc, $form->generate_text_area('description', $dlitem['description'], array('id' => 'description', 'style' => 'width: 100%;')), 'description');
 $form_container->output_row($lang->downloads_dlmngr_fid, $lang->downloads_dlmngr_fid_desc, $form->generate_forum_select('fid', $dlitem['fid'], array('id' => 'fid', 'main_option' => $lang->none)), 'fid');
 $query = $db->simple_select("downloads_catlist", "*", "1=1");
 while ($cat = $db->fetch_array($query)) {
     $categories[$cat['catid']] = $cat['title'];
 }
 $form_container->output_row($lang->downloads_dlmngr_cat, $lang->downloads_dlmngr_cat_desc, $form->generate_select_box('cat', $categories, $dlitem['cat'], array('id' => 'cat')), 'cat');
 $form_container->output_row($lang->downloads_dlmngr_grpflag, $lang->downloads_dlmngr_grpflag_desc, $form->generate_check_box('grpflag', '1', $lang->downloads_dlmngr_grpflag_desc_option, array('checked' => $dlitem['grpflag'])), 'grpflag');
 $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
 while ($usergroup = $db->fetch_array($query)) {
     $options[$usergroup['gid']] = $usergroup['title'];
     $display_group_options[$usergroup['gid']] = $usergroup['title'];
 }
 $form_container->output_row($lang->downloads_dlmngr_grpflag, $lang->downloads_dlmngr_grpflag_desc, $form->generate_select_box('grplist[]', $options, $dlitem['grplist'], array('multiple' => true, 'size' => 5)), 'grplist');
 $form_container->output_row($lang->downloads_dlmngr_preview, $lang->downloads_dlmngr_preview_desc, $form->generate_text_box('preview', $dlitem['preview'], array('id' => 'preview')), 'preview');
 $form_container->output_row($lang->downloads_dlmngr_filename, $lang->downloads_dlmngr_filename_desc, $form->generate_text_box('filename', $dlitem['filename'], array('id' => 'filename')), 'filename');
Example #8
0
function asb_admin_manage_scripts()
{
    global $mybb, $db, $page, $lang, $html, $min;
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/script_info.php';
    $page->add_breadcrumb_item($lang->asb, $html->url());
    if ($mybb->request_method == 'post') {
        if ($mybb->input['mode'] == 'edit') {
            $mybb->input['action'] = $mybb->input['script_action'];
            $script_info = new ScriptInfo($mybb->input);
            if (!$script_info->save()) {
                flash_message($lang->asb_script_save_fail, 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            flash_message($lang->asb_script_save_success, 'success');
            asb_cache_has_changed();
            admin_redirect($html->url(array("action" => 'manage_scripts')));
        } elseif ($mybb->input['mode'] == 'import') {
            if (!$_FILES['file'] || $_FILES['file']['error'] == 4) {
                flash_message($lang->asb_custom_import_no_file, 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            if ($_FILES['file']['error']) {
                flash_message($lang->sprintf($lang->asb_custom_import_file_error, $_FILES['file']['error']), 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
                flash_message($lang->asb_custom_import_file_upload_error, 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            $contents = @file_get_contents($_FILES['file']['tmp_name']);
            @unlink($_FILES['file']['tmp_name']);
            if (strlen(trim($contents)) == 0) {
                flash_message($lang->asb_custom_import_file_empty, 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            $this_script = new ScriptInfo();
            if (!$this_script->import($contents)) {
                flash_message($lang->asb_script_import_fail, 'error');
                admin_redirect($html->url(array("action" => 'manage_scripts')));
            }
            if (!$this_script->save()) {
                flash_message($lang->asb_script_import_fail, 'error');
            }
            flash_message($lang->asb_script_import_success, 'success');
            asb_cache_has_changed();
            admin_redirect($html->url(array("action" => 'manage_scripts')));
        }
    }
    if ($mybb->input['mode'] == 'delete' && $mybb->input['id']) {
        $this_script = new ScriptInfo((int) $mybb->input['id']);
        if (!$this_script->remove()) {
            flash_message($lang->asb_script_delete_fail, 'error');
        } else {
            flash_message($lang->asb_script_delete_success, 'success');
            asb_cache_has_changed();
        }
    } elseif ($mybb->input['mode'] == 'export' && $mybb->input['id']) {
        $this_script = new ScriptInfo((int) $mybb->input['id']);
        if (!$this_script->export()) {
            flash_message($lang->asb_script_export_fail, 'error');
            admin_redirect($html->url(array("action" => 'manage_scripts')));
        }
        exit;
    } elseif (($mybb->input['mode'] == 'activate' || $mybb->input['mode'] == 'deactivate') && $mybb->input['id']) {
        $this_script = new ScriptInfo((int) $mybb->input['id']);
        $this_script->set('active', $mybb->input['mode'] == 'activate');
        if (!$this_script->save()) {
            $action = $mybb->input['mode'] == 'activate' ? $lang->asb_script_activate_fail : $lang->asb_script_deactivate_fail;
            flash_message($action, 'error');
        } else {
            $action = $mybb->input['mode'] == 'activate' ? $lang->asb_script_activate_success : $lang->asb_script_deactivate_success;
            flash_message($action, 'success');
            asb_cache_has_changed();
        }
        admin_redirect($html->url(array("action" => 'manage_scripts')));
    }
    $data = array("active" => 'false', "find_top" => '{$header}', "find_bottom" => '{$footer}', "replace_all" => 0, "eval" => 0, "width_left" => 160, "width_right" => 160);
    if ($mybb->input['mode'] == 'edit') {
        $this_script = new ScriptInfo((int) $mybb->input['id']);
        $detected_show = ' style="display: none;"';
        $button_text = $lang->asb_add;
        $filename = '';
        $action = $lang->asb_edit_script;
        if ($this_script->is_valid()) {
            $data = $this_script->get('data');
            $detected_info = asb_detect_script_info($data['filename']);
            $detected_show = '';
            $button_text = $lang->asb_update;
            $filename = $data['filename'];
            $action = "{$lang->asb_edit} {$data['title']}";
        }
        $lang->asb_edit_script = $action;
        $queryadmin = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'");
        $admin_options = $db->fetch_array($queryadmin);
        if ($admin_options['codepress'] != 0) {
            $page->extra_header .= <<<EOF
\t<link type="text/css" href="./jscripts/codepress/languages/codepress-mybb.css" rel="stylesheet" id="cp-lang-style"/>
\t<script type="text/javascript" src="./jscripts/codepress/codepress.js"></script>
\t<script type="text/javascript">
\t<!--
\t\tCodePress.language = 'mybb';
\t// -->
\t</script>'
EOF;
        }
        $page->extra_header .= <<<EOF
\t<script type="text/javascript" src="./jscripts/peeker.js"></script>
\t<script type="text/javascript" src="jscripts/asb/asb_scripts{$min}.js"></script>
\t<script type="text/javascript">
\t<!--
\t\tASB.scripts.setCurrent('{$filename}');
\t// -->
\t</script>
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>

EOF;
        $page->add_breadcrumb_item($lang->asb_manage_scripts, $html->url(array("action" => 'manage_scripts')));
        $page->add_breadcrumb_item($lang->asb_edit_script);
        $page->output_header("{$lang->asb} - {$lang->asb_manage_scripts} - {$lang->asb_edit_script}");
        asb_output_tabs('asb_edit_script');
        $spinner = <<<EOF
<div class="ajax_spinners" style="display: none;">
\t<img src="../images/spinner.gif" alt="{$lang->asb_detecting} . . ."/><br /><br />
</div>
EOF;
        $form = new Form($html->url(array("action" => 'manage_scripts', "mode" => 'edit')), 'post', 'edit_script');
        $form_container = new FormContainer($lang->asb_edit_script);
        $form_container->output_row("{$lang->asb_title}:", $lang->asb_title_desc, $form->generate_text_box('title', $data['title']));
        $form_container->output_row("{$lang->asb_filename}:", $lang->asb_filename_desc, $form->generate_text_box('filename', $data['filename'], array("id" => 'filename')));
        $form_container->output_row("{$lang->asb_action}:", $lang->sprintf($lang->asb_scriptvar_generic_desc, strtolower($lang->asb_action)), "{$spinner}<div id=\"action_list\"{$detected_show}>{$detected_info['actions']}</div>" . $form->generate_text_box('script_action', $data['action'], array("id" => 'action')));
        $form_container->output_row($lang->asb_page, $lang->sprintf($lang->asb_scriptvar_generic_desc, strtolower($lang->asb_page)), $form->generate_text_box('page', $data['page']));
        $form_container->output_row($lang->asb_width_left, $lang->asb_width_left_desc, $form->generate_text_box('width_left', $data['width_left']));
        $form_container->output_row($lang->asb_width_right, $lang->asb_width_right_desc, $form->generate_text_box('width_right', $data['width_right']));
        $form_container->output_row("{$lang->asb_output_to_vars}?", $lang->sprintf($lang->asb_output_to_vars_desc, '<span style="font-family: courier; font-weight: bold; font-size: 1.2em;">$asb_left</span> and <span style="font-family: courier; font-weight: bold; font-size: 1.2em;";>$asb_right</span>'), $form->generate_yes_no_radio('eval', $data['eval'], true, array("id" => 'eval_yes', "class" => 'eval'), array("id" => 'eval_no', "class" => 'eval')), '', '', array("id" => 'var_output'));
        $form_container->output_row("{$lang->asb_template}:", $lang->asb_template_desc, "{$spinner}<div id=\"template_list\"{$detected_show}>{$detected_info['templates']}</div>" . $form->generate_text_box('template_name', $data['template_name'], array("id" => 'template_name')), '', '', array("id" => 'template_row'));
        $form_container->output_row("{$lang->asb_hook}:", $lang->asb_hook_desc, "{$spinner}<div id=\"hook_list\"{$detected_show}>{$detected_info['hooks']}</div>" . $form->generate_text_box('hook', $data['hook'], array("id" => 'hook')), '', '', array("id" => 'hook_row'));
        $form_container->output_row($lang->asb_header_search_text, $lang->asb_header_search_text_desc, $form->generate_text_area('find_top', $data['find_top'], array("id" => 'find_top', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 100px;')), '', '', array("id" => 'header_search'));
        $form_container->output_row($lang->asb_footer_search_text, $lang->asb_footer_search_text_desc, $form->generate_text_area('find_bottom', $data['find_bottom'], array("id" => 'find_bottom', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 100px;')) . $form->generate_hidden_field('id', $data['id']) . $form->generate_hidden_field('active', $data['active']) . $form->generate_hidden_field('action', 'manage_scripts') . $form->generate_hidden_field('mode', 'edit'), '', '', array("id" => 'footer_search'));
        $form_container->output_row($lang->asb_replace_template, $lang->asb_replace_template_desc, $form->generate_yes_no_radio('replace_all', $data['replace_all'], true, array("id" => 'replace_all_yes', "class" => 'replace_all'), array("id" => 'replace_all_no', "class" => 'replace_all')), '', '', array("id" => 'replace_all'));
        $form_container->output_row($lang->asb_replacement_content, $lang->asb_replacement_content_desc, $form->generate_text_area('replacement', $data['replacement'], array("id" => 'replacement', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 240px;')), '', '', array("id" => 'replace_content'));
        $form_container->end();
        $buttons = array($form->generate_submit_button($button_text, array('name' => 'add')));
        $form->output_submit_wrapper($buttons);
        $form->end();
        // output CodePress scripts if necessary
        if ($admin_options['codepress'] != 0) {
            echo <<<EOF
\t\t<script type="text/javascript">
\t\t<!--
\t\t\tEvent.observe('edit_script', 'submit', function() {
\t\t\t\tif (\$('find_top_cp')) {
\t\t\t\t\tvar area = \$('find_top_cp');
\t\t\t\t\tarea.id = 'find_top';
\t\t\t\t\tarea.value = find_top.getCode();
\t\t\t\t\tarea.disabled = false;
\t\t\t\t}

\t\t\t\tif (\$('find_bottom_cp')) {
\t\t\t\t\tvar area = \$('find_bottom_cp');
\t\t\t\t\tarea.id = 'find_bottom';
\t\t\t\t\tarea.value = find_bottom.getCode();
\t\t\t\t\tarea.disabled = false;
\t\t\t\t}

\t\t\t\tif (\$('replacement_cp')) {
\t\t\t\t\tvar area = \$('replacement_cp');
\t\t\t\t\tarea.id = 'replacement';
\t\t\t\t\tarea.value = replacement.getCode();
\t\t\t\t\tarea.disabled = false;
\t\t\t\t}
\t\t\t});
\t\t// -->
\t\t</script>
EOF;
        }
        // output the link menu and MyBB footer
        asb_output_footer('edit_scripts');
    } else {
        $page->extra_header .= <<<EOF
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>

EOF;
        $page->add_breadcrumb_item($lang->asb_manage_scripts);
        $page->output_header("{$lang->asb} - {$lang->asb_manage_scripts}");
        asb_output_tabs('asb_scripts');
        $new_script_url = $html->url(array("action" => 'manage_scripts', "mode" => 'edit'));
        $new_script_link = $html->link($new_script_url, $lang->asb_add_new_script, array("style" => 'font-weight: bold;', "title" => $lang->asb_add_new_script, "icon" => "{$mybb->settings['bburl']}/inc/plugins/asb/images/add.png"), array("alt" => '+', "title" => $lang->asb_add_new_script, "style" => 'margin-bottom: -3px;'));
        echo $new_script_link . '<br /><br />';
        $table = new Table();
        $table->construct_header($lang->asb_title, array("width" => '16%'));
        $table->construct_header($lang->asb_filename, array("width" => '16%'));
        $table->construct_header($lang->asb_action, array("width" => '7%'));
        $table->construct_header($lang->asb_page, array("width" => '7%'));
        $table->construct_header($lang->asb_template, array("width" => '18%'));
        $table->construct_header($lang->asb_hook, array("width" => '20%'));
        $table->construct_header($lang->asb_status, array("width" => '7%'));
        $table->construct_header($lang->asb_controls, array("width" => '8%'));
        $query = $db->simple_select('asb_script_info', '*', '', array("order_by" => 'title', "order_dir" => 'ASC'));
        if ($db->num_rows($query) > 0) {
            while ($data = $db->fetch_array($query)) {
                $edit_url = $html->url(array("action" => 'manage_scripts', "mode" => 'edit', "id" => $data['id']));
                $activate_url = $html->url(array("action" => 'manage_scripts', "mode" => 'activate', "id" => $data['id']));
                $deactivate_url = $html->url(array("action" => 'manage_scripts', "mode" => 'deactivate', "id" => $data['id']));
                $activate_link = $html->link($activate_url, $lang->asb_inactive, array("style" => 'font-weight: bold; color: red;', "title" => $lang->asb_inactive_desc));
                $deactivate_link = $html->link($deactivate_url, $lang->asb_active, array("style" => 'font-weight: bold; color: green', "title" => $lang->asb_active_desc));
                $none = <<<EOF
<span style="color: gray;"><em>{$lang->asb_none}</em></span>
EOF;
                $table->construct_cell($html->link($edit_url, $data['title'], array("style" => 'font-weight: bold;')));
                $table->construct_cell($data['filename']);
                $table->construct_cell($data['action'] ? $data['action'] : $none);
                $table->construct_cell($data['page'] ? $data['page'] : $none);
                $table->construct_cell($data['template_name'] ? $data['template_name'] : $none);
                $table->construct_cell($data['hook'] ? $data['hook'] : $none);
                $table->construct_cell($data['active'] ? $deactivate_link : $activate_link);
                // options popup
                $popup = new PopupMenu("script_{$data['id']}", $lang->asb_options);
                // edit
                $popup->add_item($lang->asb_edit, $edit_url);
                // export
                $popup->add_item($lang->asb_custom_export, $html->url(array("action" => 'manage_scripts', "mode" => 'export', "id" => $data['id'])));
                // delete
                $popup->add_item($lang->asb_delete, $html->url(array("action" => 'manage_scripts', "mode" => 'delete', "id" => $data['id'])), "return confirm('{$lang->asb_script_del_warning}');");
                // popup cell
                $table->construct_cell($popup->fetch());
                $table->construct_row();
            }
        } else {
            $table->construct_cell("<span style=\"color: gray;\"><em>{$lang->asb_no_scripts}</em></span>", array("colspan" => 8));
            $table->construct_row();
        }
        $table->output($lang->asb_script_info);
        $form = new Form($html->url(array("action" => 'manage_scripts', "mode" => 'import')), 'post', '', 1);
        $form_container = new FormContainer($lang->asb_custom_import);
        $form_container->output_row($lang->asb_custom_import_select_file, '', $form->generate_file_upload_box('file'));
        $form_container->end();
        $import_buttons[] = $form->generate_submit_button($lang->asb_custom_import, array('name' => 'import'));
        $form->output_submit_wrapper($import_buttons);
        $form->end();
        // output the link menu and MyBB footer
        asb_output_footer('manage_scripts');
    }
}
Example #9
0
 }
 $form_container = new FormContainer(htmlspecialchars_uni($file));
 if ($editwithfile) {
     // Editing with another file
     $form_container->output_row_header($languages[$editwith]);
     $form_container->output_row_header($languages[$editlang]);
     // Make each editing row
     foreach ($editvars as $key => $value) {
         if (my_strtolower($langinfo['charset']) == "utf-8") {
             $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]);
             $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $value);
         } else {
             $withvars[$key] = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $withvars[$key]);
             $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value);
         }
         $form_container->output_row($key, "", $form->generate_text_area("", $withvars[$key], array('disabled' => true, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), "", array('width' => '50%', 'skip_construct' => true));
         $form_container->output_row($key, "", $form->generate_text_area("edit[{$key}]", $value, array('id' => 'lang_' . $key, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), 'lang_' . $key, array('width' => '50%'));
     }
 } else {
     // Editing individually
     $form_container->output_row_header($languages[$editlang]);
     // Make each editing row
     foreach ($editvars as $key => $value) {
         if (my_strtolower($langinfo['charset']) == "utf-8") {
             $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return dec_to_utf8(hexdec($matches[1]));'), $value);
         } else {
             $value = preg_replace_callback("#%u([0-9A-F]{1,4})#i", create_function('$matches', 'return "&#".hexdec($matches[1]).";";'), $value);
         }
         $form_container->output_row($key, "", $form->generate_text_area("edit[{$key}]", $value, array('id' => 'lang_' . $key, 'rows' => 2, 'style' => "width: 98%; padding: 4px;")), 'lang_' . $key, array('width' => '50%'));
     }
 }
Example #10
0
     $table->construct_header($lang->mysupport_description);
     $table->construct_header($lang->controls, array("colspan" => 2, 'class' => 'align_center'));
     while ($deniedreason = $db->fetch_array($query)) {
         $table->construct_cell($deniedreason['name'], array('width' => '20%'));
         $table->construct_cell($deniedreason['description'], array('width' => '50%'));
         $table->construct_cell("<a href=\"index.php?module=config-mysupport&amp;action=support_denial&amp;do=edit&amp;drid={$deniedreason['mid']}\">{$lang->edit}</a>", array('class' => 'align_center', 'width' => '10%'));
         $table->construct_cell("<a href=\"index.php?module=config-mysupport&amp;action=support_denial&amp;do=delete&amp;drid={$deniedreason['mid']}\">{$lang->delete}</a>", array('class' => 'align_center', 'width' => '10%'));
         $table->construct_row();
     }
     $table->output($lang->support_denial_reason_current);
 }
 $form = new Form("index.php?module=config-mysupport&amp;action=do_support_denial", "post");
 $form_container = new FormContainer($lang->support_denial_reason_add);
 $add_support_denial_reason_name = $form->generate_text_box("name");
 $form_container->output_row($lang->mysupport_name . " <em>*</em>", '', $add_support_denial_reason_name);
 $add_support_denial_reason_description = $form->generate_text_area("description");
 $form_container->output_row($lang->mysupport_description . " <em>*</em>", $lang->support_denial_reason_description_description, $add_support_denial_reason_description);
 echo $form->generate_hidden_field("do", "do_add");
 $form_container->end();
 $buttons[] = $form->generate_submit_button($lang->mysupport_add_support_denial_reason_submit);
 $form->output_submit_wrapper($buttons);
 $form->end();
 echo "<br />";
 $form = new Form("index.php?module=config-mysupport&amp;action=do_support_denial", "post");
 $form_container = new FormContainer($lang->support_denial_header);
 $table = new Table();
 $table->construct_header($lang->mysupport);
 $current_canmanagesupportdenial_groups = array();
 $groups = $cache->read("usergroups");
 foreach ($groups as $group) {
     if ($group['canmanagesupportdenial'] == 1) {
Example #11
0
    $table->construct_cell("<strong>{$lang->mybb_version}</strong>", array('width' => '25%'));
    $table->construct_cell($mybb->version, array('width' => '25%'));
    $table->construct_cell("<strong>{$lang->threads}</strong>", array('width' => '25%'));
    $table->construct_cell("<strong>{$threads}</strong> {$lang->threads}<br /><strong>{$newthreads}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=threads\"><strong>{$unapproved_threads}</strong> {$lang->unapproved}</a>", array('width' => '25%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->php_version}</strong>", array('width' => '25%'));
    $table->construct_cell(PHP_VERSION, array('width' => '25%'));
    $table->construct_cell("<strong>{$lang->posts}</strong>", array('width' => '25%'));
    $table->construct_cell("<strong>{$posts}</strong> {$lang->posts}<br /><strong>{$newposts}</strong> {$lang->new_today}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=posts\"><strong>{$unapproved_posts}</strong> {$lang->unapproved}</a>", array('width' => '25%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->sql_engine}</strong>", array('width' => '25%'));
    $table->construct_cell($db->short_title . " " . $db->get_version(), array('width' => '25%'));
    $table->construct_cell("<strong>{$lang->users}</strong>", array('width' => '25%'));
    $table->construct_cell("<a href=\"index.php?module=user-users\"><strong>{$users}</strong> {$lang->registered_users}</a><br /><strong>{$activeusers}</strong> {$lang->active_users}<br /><strong>{$newusers}</strong> {$lang->registrations_today}<br /><a href=\"index.php?module=user-users&amp;action=search&amp;results=1&amp;conditions=" . urlencode(serialize(array('usergroup' => '5'))) . "&amp;from=home\"><strong>{$awaitingusers}</strong> {$lang->awaiting_activation}</a>", array('width' => '25%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->server_load}</strong>", array('width' => '25%'));
    $table->construct_cell($serverload, array('width' => '25%'));
    $table->construct_cell("<strong>{$lang->attachments}</strong>", array('width' => '25%'));
    $table->construct_cell("<strong>{$attachs['numattachs']}</strong> {$lang->attachments}<br /><a href=\"index.php?module=forum-moderation_queue&amp;type=attachments\"><strong>{$unapproved_attachs}</strong> {$lang->unapproved}</a><br /><strong>{$attachs['spaceused']}</strong> {$lang->used}", array('width' => '25%'));
    $table->construct_row();
    $table->output($lang->dashboard);
    $table->construct_header($lang->admin_notes_public);
    $form = new Form("index.php", "post");
    $table->construct_cell($form->generate_text_area("adminnotes", $adminmessage['adminmessage'], array('style' => 'width: 99%; height: 200px;')));
    $table->construct_row();
    $table->output($lang->admin_notes);
    $buttons[] = $form->generate_submit_button($lang->save_notes);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
Example #12
0
                $table->construct_row();
            }
        } else {
            $table->construct_cell($lang->wiki_no_templates, array('colspan' => 3, 'class' => 'align_center'));
            $table->construct_row();
        }
    } else {
        $table->construct_cell($lang->wiki_no_templates, array('colspan' => 3, 'class' => 'align_center'));
        $table->construct_row();
    }
    $table->output($lang->wiki_templates);
} elseif ($mybb->input['action'] == 'new') {
    if ($mybb->request_method == "post") {
        $arr = array('name' => $db->escape_string($mybb->input['name']), 'search' => $db->escape_string($mybb->input['search']), 'replace' => $db->escape_string($mybb->input['replace']));
        $db->insert_query('wiki_templates', $arr);
        flash_message($lang->wiki_new_template_done, 'success');
        admin_redirect('index.php?module=wiki-templates');
    }
    $page->output_nav_tabs($sub_tabs, 'wiki_templates_new');
    $form = new Form('', 'post');
    $form_container = new FormContainer($lang->wiki_templates_new);
    $form_container->output_row($lang->wiki_new_template_title, $lang->wiki_new_template_title_desc, $form->generate_text_box('name', '', array('id' => 'title')));
    $form_container->output_row($lang->wiki_new_template_search, $lang->wiki_new_template_search_desc, $form->generate_text_box('search', '', array('id' => 'search')));
    $form_container->output_row($lang->wiki_new_template_replace, $lang->wiki_new_template_replace_desc, $form->generate_text_area('replace', '', array('id' => 'replace', 'style' => 'width: 100%; height: 300px;')));
    $form_container->end();
    $buttons = array();
    $buttons[] = $form->generate_submit_button($lang->wiki_commit);
    $form->output_submit_wrapper($buttons);
    $form->end();
}
$page->output_footer();
Example #13
0
     flash_message($lang->announcement_error, 'error');
     admin_redirect("index.php?module=" . MODULE);
 }
 $aid = (int) $mybb->input['aid'];
 $query = $db->simple_select("announcement", "*", "ID='{$aid}'");
 if ($db->num_rows($query) != 1) {
     flash_message($lang->announcement_error, 'error');
     admin_redirect("index.php?module=" . MODULE);
 }
 $announcement = $db->fetch_array($query);
 $page->add_breadcrumb_item($lang->edit, "index.php?module=" . MODULE . "&amp;action=edit&amp;aid={$aid}");
 $page->output_header($lang->announcement);
 generate_tabs("list");
 $form = new Form("index.php?module=" . MODULE . "&amp;action=do_edit", "post");
 $form_container = new FormContainer($lang->announcement);
 $add_announcement = $form->generate_text_area("announcement", $announcement['Announcement']);
 $form_container->output_row($lang->announcement_simple . " <em>*</em>", $lang->announcement_desc, $add_announcement);
 $id = "global";
 $add_global = $form->generate_yes_no_radio("global", $announcement['Global'], true, array("id" => $id . "_yes", "class" => $id), array("id" => $id . "_no", "class" => $id));
 $form_container->output_row($lang->announcement_global . " <em>*</em>", '', $add_global);
 $add_forum = $form->generate_forum_select("forum[]", @unserialize($announcement['Forum']), array("multiple" => true));
 $form_container->output_row($lang->announcement_forum, $lang->announcement_forum_desc, $add_forum, '', array(), array('id' => 'forum'));
 $add_thread = $form->generate_text_box("thread", $announcement['tid']);
 $form_container->output_row($lang->announcement_thread, $lang->announcement_thread_desc, $add_thread, '', array(), array('id' => 'thread'));
 $add_group = $form->generate_group_select("group[]", @unserialize($announcement['Groups']), array("multiple" => true));
 $form_container->output_row($lang->announcement_group, $lang->announcement_group_desc, $add_group);
 $languages = $lang->get_languages();
 $add_languages = $form->generate_select_box("langs[]", $languages, @unserialize($announcement['Langs']), array("multiple" => true));
 $form_container->output_row($lang->announcement_languages, $lang->announcement_languages_desc, $add_languages);
 $add_color = $form->generate_text_box("color", $announcement['Color']);
 $form_container->output_row($lang->announcement_color . " <em>*</em>", $lang->announcement_color_desc, $add_color);
Example #14
0
            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&amp;action=edit&amp;qid={$question['qid']}", 'description' => $lang->edit_question_desc);
    $page->output_nav_tabs($sub_tabs, 'edit_question');
    $form = new Form("index.php?module=config-questions&amp;action=edit&amp;qid={$question['qid']}", "post", "add");
    if ($errors) {
        $page->output_inline_error($errors);
    } else {
        $mybb->input = $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);
    $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']) {
Example #15
0
		' . $specific_files . '
		' . $specific_colors_option . '
		' . $specific_colors . '
	</dl>
	<script type="text/javascript">
	checkAction(\'attach\');' . $check_actions . '
	</script>';
    echo $form->generate_hidden_field("sid", $stylesheet['sid']) . "<br />\n";
    $form_container = new FormContainer($lang->add_stylesheet_to . ' ' . htmlspecialchars_uni($theme['name']), 'tfixed');
    $form_container->output_row($lang->file_name, $lang->file_name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name', 'style' => 'width: 200px;')), 'name');
    $form_container->output_row($lang->attached_to, $lang->attached_to_desc, $actions);
    $sheetnames = array();
    foreach ($stylesheets as $filename => $style) {
        $sheetnames[basename($filename)] = basename($filename);
    }
    $actions = "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"add_type\" value=\"1\" {$add_checked[1]} class=\"adds_check\" onclick=\"checkAction('add');\" style=\"vertical-align: middle;\" /> <strong>{$lang->import_stylesheet_from}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"add_1\" class=\"adds\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . $form->generate_select_box('import', $sheetnames, $mybb->input['import'], array('id' => 'import')) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"add_type\" value=\"2\" {$add_checked[2]} class=\"adds_check\" onclick=\"checkAction('add');\" style=\"vertical-align: middle;\" /> <strong>{$lang->write_own}</strong></label></dt>\n\t\t<span id=\"add_2\" class=\"adds\"><br />" . $form->generate_text_area('stylesheet', $mybb->input['stylesheet'], array('id' => 'stylesheet', 'style' => 'width: 99%;', 'class' => '', 'rows' => '30')) . "</span>\n\t</dl>";
    $form_container->output_row("", "", $actions);
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_stylesheet);
    $form->output_submit_wrapper($buttons);
    if ($admin_options['codepress'] != 0) {
        echo '<script type="text/javascript">
			var editor = CodeMirror.fromTextArea(document.getElementById("stylesheet"), {
				lineNumbers: true,
				lineWrapping: true,
				viewportMargin: Infinity,
				indentWithTabs: true,
				indentUnit: 4,
				mode: "text/css",
				theme: "mybb"
			});</script>';
Example #16
0
    $table->construct_cell("<strong>{$lang->codemirror}</strong><br /><small>{$lang->use_codemirror_desc}</small><br /><br />" . $form->generate_on_off_radio('codepress', $admin_options['codepress']));
    $table->construct_row();
    // If 2FA is enabled we need to display a link to the recovery codes page
    if (!empty($admin_options['authsecret'])) {
        $lang->use_2fa_desc .= "<br />" . $lang->recovery_codes_desc . " " . $lang->recovery_codes_warning;
    }
    $table->construct_cell("<strong>{$lang->my2fa}</strong><br /><small>{$lang->use_2fa_desc}</small><br /><br />" . $form->generate_on_off_radio('2fa', (int) (!empty($admin_options['authsecret']))));
    $table->construct_row();
    if (!empty($admin_options['authsecret'])) {
        $qr = $auth->getQRCodeGoogleUrl($mybb->user['username'] . "@" . str_replace(" ", "", $mybb->settings['bbname']), $admin_options['authsecret']);
        $table->construct_cell("<strong>{$lang->my2fa_qr}</strong><br /><img src=\"{$qr}\"");
        $table->construct_row();
    }
    $table->output($lang->preferences);
    $table->construct_header($lang->notes_not_shared);
    $table->construct_cell($form->generate_text_area("notes", $admin_options['notes'], array('style' => 'width: 99%; height: 300px;')));
    $table->construct_row();
    $table->output($lang->personal_notes);
    $buttons[] = $form->generate_submit_button($lang->save_notes_and_prefs);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
/**
 * Generate 10 random recovery codes, each with a length of 6 and without duplicates
 *
 * @return array
 */
function generate_recovery_codes()
{
    $t = array();
Example #17
0
    }
    $awards->set_url(array('action' => 'user', 'aid' => $award['aid']));
    if (!($gived = $awards->get_gived_award($award['aid'], $mybb->get_input('uid', 1)))) {
        $awards->admin_redirect($lang->ougc_awards_error_invaliduser, true);
    }
    $page->add_breadcrumb_item($lang->ougc_awards_acp_nav, $awards->build_url());
    $page->output_header($lang->ougc_awards_acp_nav);
    $page->output_nav_tabs($sub_tabs, 'ougc_awards_edit_user');
    if ($mybb->request_method == 'post') {
        $awards->update_gived($gived['gid'], array('date' => $mybb->input['date'], 'reason' => $mybb->input['reason']));
        $awards->log_action();
        $awards->admin_redirect($lang->ougc_awards_success_edit);
    }
    $form = new Form($awards->build_url(array('uid' => $mybb->get_input('uid', 1))));
    $form_container = new FormContainer($lang->ougc_awards_tab_edit_user_d);
    $form_container->output_row($lang->ougc_awards_form_reason, $lang->ougc_awards_form_reason_d, $form->generate_text_area('reason', isset($mybb->input['reason']) ? $mybb->input['reason'] : $gived['reason'], array('rows' => 8, 'style' => 'width:80%;')));
    $form_container->output_row($lang->ougc_awards_users_timestamp, $lang->ougc_awards_users_timestamp_d, $form->generate_text_box('date', isset($mybb->input['date']) ? (int) $mybb->input['date'] : intval($gived['date'])));
    $form_container->end();
    $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_awards_button_submit), $form->generate_reset_button($lang->reset)));
    $form->end();
    $page->output_footer();
} else {
    $page->add_breadcrumb_item($lang->ougc_awards_acp_nav, $awards->build_url());
    $page->output_header($lang->ougc_awards_acp_nav);
    $page->output_nav_tabs($sub_tabs, 'ougc_awards_view');
    $table = new Table();
    $table->construct_header($lang->ougc_awards_view_image, array('width' => '1%'));
    $table->construct_header($lang->ougc_awards_form_name, array('width' => '19%'));
    $table->construct_header($lang->ougc_awards_form_desc, array('width' => '45%'));
    $table->construct_header($lang->ougc_awards_form_order, array('width' => '10%', 'class' => 'align_center'));
    $table->construct_header($lang->ougc_awards_form_visible, array('width' => '10%', 'class' => 'align_center'));
Example #18
0
    foreach ($mybb->input['setting'] as $name => $value) {
        $row = array("value" => $db->escape_string($value));
        $db->update_query('wiki_settings', $row, "name=\"" . $name . "\"");
    }
    flash_message($lang->wiki_settings_success, 'success');
    admin_redirect('index.php?module=wiki-settings');
}
$table = new Table();
$form = new Form('', 'post');
$table->construct_header($lang->wiki_setting_title);
$table->construct_header($lang->wiki_setting_givevalue);
$query = $db->write_query("SELECT * FROM `" . TABLE_PREFIX . "wiki_settings`");
while ($row = $db->fetch_array($query)) {
    $table->construct_cell($row['title']);
    $code = $row['optionscode'];
    if ($code == 'text') {
        $setting_code = $form->generate_text_box('setting[' . $row['name'] . ']', $row['value'], array('id' => $row['name']));
    } elseif ($code == 'yesno') {
        $setting_code = $form->generate_yes_no_radio('setting[' . $row['name'] . ']', $row['value'], true, array('id' => $row['name'] . '_yes', 'class' => $row['name']), array('id' => $row['name'] . '_no', 'class' => $row['name']));
    } elseif ($code == 'onoff') {
        $setting_code = $form->generate_on_off_radio('setting[' . $row['name'] . ']', $row['value'], true, array('id' => 'on', 'class' => $row['name']), array('id' => 'off', 'class' => $row['name']));
    } elseif ($code == 'textarea') {
        $setting_code = $form->generate_text_area('setting[' . $row['name'] . ']', $row['value'], array('id' => $row['name']));
    }
    $table->construct_cell($setting_code);
    $table->construct_row();
}
$buttons[] = $form->generate_submit_button($lang->wiki_commit);
$table->output($lang->wiki_settings_alt);
$form->output_submit_wrapper($buttons);
$page->output_footer();
function restfulapi_admin_load()
{
    global $mybb, $db, $page, $lang, $cache;
    if ($page->active_action == RESTFULAPI_URL) {
        $page->add_breadcrumb_item($lang->restfulapi_title);
        $page->output_header($lang->restfulapi_title);
        $result = $db->simple_select("apisettings");
        $action = "config";
        if (isset($mybb->input["action"]) && in_array($mybb->input["action"], array("manage-keys", "add-key"))) {
            $action = $mybb->input["action"];
        }
        $navs = array("config" => array("link" => "index.php?module=config-" . RESTFULAPI_URL, "title" => $lang->restfulapi_config, "description" => $lang->restfulapi_config_description), "manage-keys" => array("link" => "index.php?module=config-" . RESTFULAPI_URL . "&amp;action=manage-keys", "title" => $lang->restfulapi_manage_api_keys, "description" => $lang->restfulapi_manage_api_keys_description), "add-key" => array("link" => "index.php?module=config-" . RESTFULAPI_URL . "&amp;action=add-key", "title" => $lang->restfulapi_add_api_key, "description" => $lang->restfulapi_add_api_key_description));
        $page->output_nav_tabs($navs, $action);
        switch ($action) {
            case "manage-keys":
                if (isset($mybb->input["do"]) && in_array($mybb->input["do"], array("regenerate", "edit", "delete"))) {
                    $do = $mybb->input["do"];
                    if ($do == "edit" && isset($mybb->input["key_id"]) && is_string($mybb->input["key_id"])) {
                        $key_id = (int) $db->escape_string($mybb->input["key_id"]);
                        $result = $db->simple_select("apikeys", "*", "id='{$key_id}'");
                        if ($result->num_rows != 1) {
                            flash_message($lang->restfulapi_key_not_found, "error");
                            admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                            exit;
                        }
                        if ($mybb->request_method == "post" && isset($mybb->input["apicustomer"]) && is_string($mybb->input["apicustomer"]) && isset($mybb->input["apicomment"]) && is_string($mybb->input["apicomment"]) && isset($mybb->input["maxreq"]) && is_numeric($mybb->input["maxreq"]) && isset($mybb->input["maxreqrate"]) && in_array($mybb->input["maxreqrate"], array("m", "w", "d", "h"))) {
                            $update = array("apicustomer" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicustomer"])), "apicomment" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicomment"])), "maxreq" => (int) $mybb->input["maxreq"], "maxreqrate" => $db->escape_string(htmlspecialchars_uni($mybb->input["maxreqrate"])));
                            $db->update_query("apikeys", $update, "id='{$key_id}'");
                            $db->delete_query("apipermissions", "apikey='{$key_id}'");
                            if (isset($mybb->input["apinames"]) && is_array($mybb->input["apinames"])) {
                                $insert_allowed = array();
                                foreach ($mybb->input["apinames"] as $apiname) {
                                    $insert_allowed[] = array("apikey" => $key_id, "apiname" => $db->escape_string($apiname));
                                }
                                $db->insert_query_multiple("apipermissions", $insert_allowed);
                            }
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_edited_successfully, "success");
                            admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                        } else {
                            $keyset = $result->fetch_array();
                            $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&amp;action=manage-keys&amp;do=edit&amp;key_id={$key_id}", "post", "edit");
                            $form_container = new FormContainer($lang->restfulapi_edit_api_key);
                            $form_container->output_row($lang->restfulapi_customer_name . " <em>*</em>", $lang->restfulapi_customer_name_description, $form->generate_text_box('apicustomer', htmlspecialchars_uni($keyset["apicustomer"]), array('id' => 'apicustomer')), 'apicustomer');
                            $rate_types = array("h" => $lang->restfulapi_per_hour, "d" => $lang->restfulapi_per_day, "w" => $lang->restfulapi_per_week, "m" => $lang->restfulapi_per_month);
                            $form_container->output_row($lang->restfulapi_max_requests . " <em>*</em>", $lang->restfulapi_max_requests_description, $form->generate_text_box('maxreq', htmlspecialchars_uni($keyset["maxreq"]), array('id' => 'maxreq')) . " " . $form->generate_select_box('maxreqrate', $rate_types, htmlspecialchars_uni($keyset["maxreqrate"]), array('id' => 'maxreqrate')), 'maxreq');
                            $form_container->output_row($lang->restfulapi_comment, $lang->restfulapi_comment_description, $form->generate_text_area('apicomment', htmlspecialchars_uni($keyset["apicomment"]), array('id' => 'apicomment')), 'apicomment');
                            $apis = glob(RESTFULAPI_PATH . "api/*api.class.php");
                            $presentable_apis = array();
                            foreach ($apis as $key => $value) {
                                $value = htmlspecialchars_uni(str_replace(array(RESTFULAPI_PATH . "api/", "api.class.php"), "", $value));
                                $presentable_apis[$value] = $value;
                            }
                            $selected = array();
                            // reminder, $key_id has already been escaped!
                            $result = $db->simple_select("apipermissions", "*", "apikey='{$key_id}'");
                            while ($apipermission = $db->fetch_array($result)) {
                                $selected[] = $apipermission["apiname"];
                            }
                            $form_container->output_row($lang->restfulapi_select_allowed_apis, $lang->restfulapi_select_allowed_apis_description, $form->generate_select_box('apinames[]', $presentable_apis, $selected, array('id' => 'apinames', 'multiple' => true, 'size' => 10)), 'apinames');
                            $form_container->end();
                            $buttons[] = $form->generate_submit_button($lang->restfulapi_edit_api_key);
                            $form->output_submit_wrapper($buttons);
                            $form->end();
                        }
                    } elseif ($do == "delete" && isset($mybb->input["key_id"]) && isset($mybb->input["my_post_key"]) && verify_post_check($mybb->input["my_post_key"])) {
                        $key_id = $db->escape_string($mybb->input["key_id"]);
                        if ($db->simple_select("apikeys", "*", "id='{$key_id}'")->num_rows == 1) {
                            $db->delete_query("apipermissions", "apikey='{$key_id}'");
                            $db->delete_query("apikeys", "id='{$key_id}'");
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_deleted_successfully, "success");
                        } else {
                            flash_message($lang->restfulapi_key_not_found, "error");
                        }
                        admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                    } elseif ($do == "regenerate" && isset($mybb->input["key_id"]) && isset($mybb->input["my_post_key"]) && verify_post_check($mybb->input["my_post_key"])) {
                        $key_id = $db->escape_string($mybb->input["key_id"]);
                        if ($db->simple_select("apikeys", "*", "id='{$key_id}'")->num_rows == 1) {
                            $apikey = restfulapi_generate_key();
                            /* can't figure out a better way to generate a random yet never-generated-before API key than this one */
                            while ($db->simple_select("apikeys", "*", "apikey='{$apikey}'")->num_rows != 0) {
                                $apikey = restfulapi_generate_key();
                            }
                            $update = array("apikey" => $db->escape_string(htmlspecialchars_uni($apikey)));
                            $db->update_query("apikeys", $update, "id='{$key_id}'");
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_regenerated_successfully, "success");
                        } else {
                            flash_message($lang->restfulapi_key_not_found, "error");
                        }
                        admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                    }
                } else {
                    $restfulapi_cache = $cache->read("restfulapi");
                    $apikeysets = $restfulapi_cache["keys"];
                    $table = new Table();
                    $table->construct_header($lang->restfulapi_customer, array("width" => "15%"));
                    $table->construct_header($lang->restfulapi_api_key, array("class" => "align_center", "width" => "29%"));
                    $table->construct_header($lang->restfulapi_comment, array("class" => "align_center", "width" => "30%"));
                    $table->construct_header($lang->restfulapi_usage, array("class" => "align_center", "width" => "5%"));
                    $table->construct_header($lang->restfulapi_controls, array("class" => "align_center", "width" => "21%", "colspan" => 3));
                    if (count($apikeysets) == 0) {
                        $table->construct_cell($lang->sprintf($lang->restfulapi_no_api_key, '<a href="index.php?module=config-restfulapi&action=add-key">', '</a>'), array("class" => "first", "colspan" => 5));
                        $table->construct_row();
                    } else {
                        // TODO : pagination maybe ?
                        foreach ($apikeysets as $key => $keyset) {
                            $table->construct_cell("<b>" . htmlspecialchars_uni($keyset['apicustomer']) . "</b>");
                            $table->construct_cell(htmlspecialchars_uni($keyset['apikey']));
                            $table->construct_cell(htmlspecialchars_uni($keyset['apicomment']));
                            $table->construct_cell(htmlspecialchars_uni($keyset['access']), array("class" => "align_center"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=regenerate&amp;key_id={$keyset['id']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->restfulapi_regenerate_api_key_confirmation}')\">{$lang->restfulapi_regenerate_api_key}</a>", array("class" => "align_center", "width" => "9%"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=edit&amp;key_id={$keyset['id']}\">{$lang->restfulapi_edit}</a>", array("class" => "align_center", "width" => "6%"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=delete&amp;key_id={$keyset['id']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->restfulapi_delete_confirm}')\">{$lang->restfulapi_delete}</a>", array("class" => "align_center", "width" => "6%"));
                            $table->construct_row();
                        }
                    }
                    $table->output($lang->restfulapi_manage_api_keys);
                }
                break;
            case "add-key":
                if ($mybb->request_method == "post" && isset($mybb->input["apicustomer"]) && is_string($mybb->input["apicustomer"]) && isset($mybb->input["apicomment"]) && is_string($mybb->input["apicomment"]) && isset($mybb->input["maxreq"]) && is_numeric($mybb->input["maxreq"]) && isset($mybb->input["maxreqrate"]) && in_array($mybb->input["maxreqrate"], array("m", "w", "d", "h"))) {
                    $apikey = restfulapi_generate_key();
                    /* can't figure out a better way to generate a random yet never-generated-before API key than this one */
                    while ($db->simple_select("apikeys", "*", "apikey='{$db->escape_string($apikey)}'")->num_rows != 0) {
                        $apikey = restfulapi_generate_key();
                    }
                    $insert = array("apicustomer" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicustomer"])), "apicomment" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicomment"])), "access" => 0, "maxreq" => (int) $mybb->input["maxreq"], "maxreqrate" => $db->escape_string(htmlspecialchars_uni($mybb->input["maxreqrate"])), "apikey" => $db->escape_string(htmlspecialchars_uni($apikey)));
                    $apikeyid = $db->insert_query("apikeys", $insert);
                    if (isset($mybb->input["apinames"]) && is_array($mybb->input["apinames"])) {
                        $insert_allowed = array();
                        foreach ($mybb->input["apinames"] as $apiname) {
                            $insert_allowed[] = array("apikey" => $db->escape_string($apikeyid), "apiname" => $db->escape_string($apiname));
                        }
                        $db->insert_query_multiple("apipermissions", $insert_allowed);
                    }
                    restfulapi_cache_rebuild();
                    flash_message($lang->sprintf($lang->restfulapi_generated_successfully, $apikey, $mybb->input["apicustomer"]), 'success');
                    admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                } else {
                    $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&amp;action=add-key", "post", "add");
                    $form_container = new FormContainer($lang->restfulapi_add_api_key);
                    $form_container->output_row($lang->restfulapi_customer_name . " <em>*</em>", $lang->restfulapi_customer_name_description, $form->generate_text_box('apicustomer', '', array('id' => 'apicustomer')), 'apicustomer');
                    $rate_types = array("h" => $lang->restfulapi_per_hour, "d" => $lang->restfulapi_per_day, "w" => $lang->restfulapi_per_week, "m" => $lang->restfulapi_per_month);
                    $form_container->output_row($lang->restfulapi_max_requests . " <em>*</em>", $lang->restfulapi_max_requests_description, $form->generate_text_box('maxreq', '0', array('id' => 'maxreq')) . " " . $form->generate_select_box('maxreqrate', $rate_types, "m", array('id' => 'maxreqrate')), 'maxreq');
                    $form_container->output_row($lang->restfulapi_comment, $lang->restfulapi_comment_description, $form->generate_text_area('apicomment', '', array('id' => 'apicomment')), 'apicomment');
                    $apis = glob(RESTFULAPI_PATH . "api/*api.class.php");
                    $presentable_apis = array();
                    foreach ($apis as $key => $value) {
                        $value = htmlspecialchars_uni(str_replace(array(RESTFULAPI_PATH . "api/", "api.class.php"), "", $value));
                        $presentable_apis[$value] = $value;
                    }
                    $form_container->output_row($lang->restfulapi_select_allowed_apis . " <em>*</em>", $lang->restfulapi_select_allowed_apis_description, $form->generate_select_box('apinames[]', $presentable_apis, array_keys($presentable_apis), array('id' => 'apinames', 'multiple' => true, 'size' => 10)), 'apinames');
                    $form_container->end();
                    $buttons[] = $form->generate_submit_button($lang->restfulapi_generate_api_key);
                    $form->output_submit_wrapper($buttons);
                    $form->end();
                }
                break;
            default:
                $apilist = $cache->read("restfulapilist");
                // routine to install newly detected APIs, and activate them if needed
                restfulapi_apilist_activate();
                if ($mybb->request_method == "post") {
                    // we delete all the previously-deactivated options
                    $db->delete_query("apisettings", "apiaction='deactivate'");
                    $inserts = array();
                    foreach ($mybb->input as $key => $input) {
                        if (substr($key, 0, 7) == "option_" && $input == "1") {
                            // replace first occurrence of 'option_' with '' in case the option name is 'option_', so that 'option_option_' won't be all replaced into an empty string
                            // yeah I know, probably would never happen but we never know
                            $option = preg_replace('/option\\_/', '', $key, 1);
                            restfulapi_api_activate($option);
                        } elseif (substr($key, 0, 7) == "option_" && $input == "0") {
                            $option = preg_replace('/option\\_/', '', $key, 1);
                            restfulapi_api_deactivate($option);
                        }
                    }
                    flash_message($lang->restfulapi_saved_config, "success");
                    admin_redirect("index.php?module=config-restfulapi");
                } else {
                    $result = $db->simple_select("apisettings", "*", "apiaction='deactivate'");
                    $deactivatedapis = array();
                    while ($apiarray = $db->fetch_array($result)) {
                        $deactivatedapis[] = $apiarray["apivalue"];
                    }
                    if (count($apilist) == 0) {
                        echo '<div class="notice">' . $lang->sprintf($lang->restfulapi_no_api, '<a href="index.php?module=config-restfulapi&action=add-key">', '</a>') . '</div>';
                    } else {
                        $form = new Form("index.php?module=config-" . RESTFULAPI_URL, "post", "config");
                        $form_container = new FormContainer($lang->restfulapi_config);
                        $table = new Table();
                        foreach ($apilist as $api => $info_array) {
                            require_once RESTFULAPI_PATH . "api/" . $api . "api.class.php";
                            $api = htmlspecialchars_uni($api);
                            $apiclass = $api . "api";
                            $api_instance = new $apiclass();
                            $info_array = $api_instance->info();
                            $name = isset($info_array["name"]) && is_string($info_array["name"]) ? htmlspecialchars_uni($info_array["name"]) . " : " . $api : $api;
                            $description = isset($info_array["description"]) && is_string($info_array["description"]) ? htmlspecialchars_uni($info_array["description"]) : $lang->restfulapi_config_on_off_description;
                            $setting_code = $form->generate_on_off_radio("option_" . $api, in_array($api, $deactivatedapis) ? 0 : 1, true, array('id' => $api . '_yes'), array('id' => $api . '_no'));
                            $form_container->output_row($name, $description, $setting_code, '', array(), array('id' => 'row_' . $api));
                        }
                        $form_container->end();
                        $buttons[] = $form->generate_submit_button($lang->restfulapi_save_config);
                        $form->output_submit_wrapper($buttons);
                        $form->end();
                    }
                }
                break;
        }
        $page->output_footer();
    }
}
Example #20
0
                $automatic_text_check = true;
                $text_display = 'display: none';
                $automatic_display = 'display: none;';
            }
        } else {
            if ($mybb->input['format'] == 1 && $mybb->input['type'] != 1) {
                $text_display = 'display: none;';
            } else {
                if ($mybb->input['format'] == 0 || $mybb->input['type'] == 1) {
                    $html_display = 'display: none';
                }
            }
        }
        echo "<div id=\"message_html\" style=\"{$html_display}\">";
        $form_container = new FormContainer("{$lang->send_mass_mail}: {$lang->step_one} - {$lang->define_html_message}");
        $form_container->output_row("{$lang->define_html_message_desc}:", $html_personalisation, $form->generate_text_area('htmlmessage', $input['htmlmessage'], array('id' => 'htmlmessage', 'rows' => 15, 'cols ' => 70, 'style' => 'width: 95%')) . "<div id=\"automatic_display\" style=\"{$automatic_display}\">" . $form->generate_check_box('automatic_text', 1, $lang->auto_gen_plain_text, array('checked' => $automatic_text_check, "id" => "automatic_text")) . "</div>");
        $form_container->end();
        echo "</div>";
        echo "<div id=\"message_text\" style=\"{$text_display}\">";
        $form_container = new FormContainer("{$lang->send_mass_mail}: {$lang->step_one} - {$lang->define_text_version}");
        $form_container->output_row("{$lang->define_text_version_desc}:", $text_personalisation, $form->generate_text_area('message', $input['message'], array('id' => 'message', 'rows' => 15, 'cols ' => 70, 'style' => 'width: 95%')));
        $form_container->end();
        echo "</div>";
        echo "\n\t\t<script type=\"text/javascript\">\n\t\tfunction ToggleFormat()\n\t\t{\n\t\t\tvar v = \$('format').options[\$('format').selectedIndex].value;\n\t\t\tif(v == 2)\n\t\t\t{\n\t\t\t\t\$('automatic_display').show();\n\t\t\t\t\$('message_html').show();\n\t\t\t\tif(\$('automatic_text').checked)\n\t\t\t\t{\n\t\t\t\t\t\$('message_text').hide();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\$('message_text').show();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(v == 1)\n\t\t\t{\n\t\t\t\t\$('message_text').hide();\n\t\t\t\t\$('message_html').show();\n\t\t\t\t\$('automatic_display').hide();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t\$('message_text').show();\n\t\t\t\t\$('message_html').hide();\n\t\t\t}\n\t\t}\n\t\tEvent.observe(\$('format'), 'change', ToggleFormat);\n\n\t\tfunction ToggleType()\n\t\t{\n\t\t\tvar v = \$('type_pm').checked;\n\t\t\tif(v == true)\n\t\t\t{\n\t\t\t\t\$('message_html').hide();\n\t\t\t\t\$('message_text').show();\n\t\t\t\t\$('format_container').hide();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t\$('message_html').show();\n\t\t\t\t\$('format_container').show();\n\t\t\t\tToggleFormat();\n\t\t\t}\n\t\t}\n\t\tEvent.observe(\$('type_pm'), 'click', ToggleType);\n\t\tEvent.observe(\$('type_email'), 'click', ToggleType);\n\t\tToggleType();\n\n\t\tfunction ToggleAutomatic()\n\t\t{\n\t\t\tvar v = \$('automatic_text').checked;\n\t\t\tif(v == true)\n\t\t\t{\n\t\t\t\t\$('message_text').hide();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t\$('message_text').show();\n\t\t\t}\n\t\t}\n\n\t\tEvent.observe(\$('automatic_text'), 'click', ToggleAutomatic);\n\t\t\n\t\tfunction insertText(value, textarea)\n\t\t{\n\t\t\t// Internet Explorer\n\t\t\tif(document.selection)\n\t\t\t{\n\t\t\t\ttextarea.focus();\n\t\t\t\tvar selection = document.selection.createRange();\n\t\t\t\tselection.text = value;\n\t\t\t}\n\t\t\t// Firefox\n\t\t\telse if(textarea.selectionStart || textarea.selectionStart == '0')\n\t\t\t{\n\t\t\t\tvar start = textarea.selectionStart;\n\t\t\t\tvar end = textarea.selectionEnd;\n\t\t\t\ttextarea.value = textarea.value.substring(0, start)\t+ value\t+ textarea.value.substring(end, textarea.value.length);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttextarea.value += value;\n\t\t\t}\n\t\t}\n\t\t\n\t\t</script>";
        $buttons[] = $form->generate_submit_button($lang->next_step);
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    }
}
if ($mybb->input['action'] == "delete") {
            $mybb->input['disporder'] = $doc['disporder'];
            $mybb->input['enabled'] = $doc['enabled'];
            $mybb->input['usetranslation'] = $doc['usetranslation'];
        }
        $form = new Form("index.php?module=config-help_documents&amp;action=edit", "post", "edit");
        echo $form->generate_hidden_field("hid", $mybb->input['hid']);
        echo $form->generate_hidden_field("usetranslation", $mybb->input['usetranslation']);
        $form_container = new FormContainer($lang->edit_document . " ({$lang->id} " . intval($mybb->input['hid']) . ")");
        $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_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), '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") {
    $plugins->run_hooks("admin_config_help_documents_delete");
    // User clicked no
    if ($mybb->input['no']) {
        admin_redirect("index.php?module=config-help_documents");
Example #22
0
 $query = $db->simple_select("forumpermissions", "*", "fid='{$fid}'");
 while ($existing = $db->fetch_array($query)) {
     $existing_permissions[$existing['gid']] = $existing;
 }
 $types = array('f' => $lang->forum, 'c' => $lang->category);
 $create_a_options_f = array('id' => 'forum');
 $create_a_options_c = array('id' => 'category');
 if ($forum_data['type'] == "f") {
     $create_a_options_f['checked'] = true;
 } else {
     $create_a_options_c['checked'] = true;
 }
 $form_container = new FormContainer($lang->edit_forum);
 $form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f) . "<br />\n" . $form->generate_radio_button('type', 'c', $lang->category, $create_a_options_c));
 $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $forum_data['title'], array('id' => 'title')), 'title');
 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $forum_data['description'], array('id' => 'description')), 'description');
 $form_container->output_row($lang->parent_forum . " <em>*</em>", $lang->parent_forum_desc, $form->generate_forum_select('pid', $forum_data['pid'], array('id' => 'pid', 'main_option' => $lang->none)), 'pid');
 $form_container->output_row($lang->display_order, "", $form->generate_numeric_field('disporder', $forum_data['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 $form_container->end();
 $form_container = new FormContainer($lang->additional_forum_options);
 $form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box('linkto', $forum_data['linkto'], array('id' => 'linkto')), 'linkto');
 $form_container->output_row($lang->forum_password, $lang->forum_password_desc, $form->generate_text_box('password', $forum_data['password'], array('id' => 'password')), 'password');
 $access_options = array($form->generate_check_box('active', 1, $lang->forum_is_active . "<br />\n<small>{$lang->forum_is_active_desc}</small>", array('checked' => $forum_data['active'], 'id' => 'active')), $form->generate_check_box('open', 1, $lang->forum_is_open . "<br />\n<small>{$lang->forum_is_open_desc}</small>", array('checked' => $forum_data['open'], 'id' => 'open')));
 $form_container->output_row($lang->access_options, "", "<div class=\"forum_settings_bit\">" . implode("</div><div class=\"forum_settings_bit\">", $access_options) . "</div>");
 $styles = array('0' => $lang->use_default);
 $query = $db->simple_select("themes", "tid,name", "name!='((master))' AND name!='((master-backup))'", array('order_by' => 'name'));
 while ($style = $db->fetch_array($query)) {
     $styles[$style['tid']] = $style['name'];
 }
 $style_options = array($form->generate_check_box('overridestyle', 1, $lang->override_user_style, array('checked' => $forum_data['overridestyle'], 'id' => 'overridestyle')), $lang->forum_specific_style . "<br />\n" . $form->generate_select_box('style', $styles, $forum_data['style'], array('id' => 'style')));
 $form_container->output_row($lang->style_options, "", "<div class=\"forum_settings_bit\">" . implode("</div><div class=\"forum_settings_bit\">", $style_options) . "</div>");
Example #23
0
function newpoints_shop_admin()
{
    global $db, $lang, $mybb, $page, $run_module, $action_file, $mybbadmin, $plugins;
    newpoints_lang_load('newpoints_shop');
    if ($run_module == 'newpoints' && $action_file == 'newpoints_shop') {
        if ($mybb->request_method == "post") {
            switch ($mybb->input['action']) {
                case 'do_addcat':
                    if ($mybb->input['name'] == '') {
                        newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1);
                    }
                    $name = $db->escape_string($mybb->input['name']);
                    $description = $db->escape_string($mybb->input['description']);
                    // get visible to user groups options
                    if (is_array($mybb->input['usergroups'])) {
                        foreach ($mybb->input['usergroups'] as $gid) {
                            if ($gid == $mybb->input['usergroups']) {
                                unset($mybb->input['usergroups'][$gid]);
                            }
                        }
                        $usergroups = implode(",", $mybb->input['usergroups']);
                    } else {
                        $usergroups = '';
                    }
                    $usergroups = $db->escape_string($usergroups);
                    $visible = intval($mybb->input['visible']);
                    $icon = $db->escape_string($mybb->input['icon']);
                    $disporder = intval($mybb->input['disporder']);
                    $expanded = intval($mybb->input['expanded']);
                    $insert_query = array('name' => $name, 'description' => $description, 'usergroups' => $usergroups, 'visible' => $visible, 'disporder' => $disporder, 'icon' => $icon, 'expanded' => $expanded);
                    $db->insert_query('newpoints_shop_categories', $insert_query);
                    newpoints_shop_messageredirect($lang->newpoints_shop_cat_added);
                    break;
                case 'do_editcat':
                    $cid = intval($mybb->input['cid']);
                    if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                    }
                    if ($mybb->input['name'] == '') {
                        newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1);
                    }
                    $name = $db->escape_string($mybb->input['name']);
                    $description = $db->escape_string($mybb->input['description']);
                    // get visible to user groups options
                    if (is_array($mybb->input['usergroups'])) {
                        foreach ($mybb->input['usergroups'] as $gid) {
                            if ($gid == $mybb->input['usergroups']) {
                                unset($mybb->input['usergroups'][$gid]);
                            }
                        }
                        $usergroups = implode(",", $mybb->input['usergroups']);
                    } else {
                        $usergroups = '';
                    }
                    $usergroups = $db->escape_string($usergroups);
                    $visible = intval($mybb->input['visible']);
                    $icon = $db->escape_string($mybb->input['icon']);
                    $disporder = intval($mybb->input['disporder']);
                    $expanded = intval($mybb->input['expanded']);
                    $update_query = array('name' => $name, 'description' => $description, 'usergroups' => $usergroups, 'visible' => $visible, 'disporder' => $disporder, 'icon' => $icon, 'expanded' => $expanded);
                    $db->update_query('newpoints_shop_categories', $update_query, 'cid=\'' . $cid . '\'');
                    newpoints_shop_messageredirect($lang->newpoints_shop_cat_edited);
                    break;
                case 'do_additem':
                    if ($mybb->input['name'] == '' || $mybb->input['cid'] == '') {
                        newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1);
                    }
                    $name = $db->escape_string($mybb->input['name']);
                    $description = $db->escape_string($mybb->input['description']);
                    $icon = $db->escape_string($mybb->input['icon']);
                    $pm = $db->escape_string($mybb->input['pm']);
                    $price = floatval($mybb->input['price']);
                    $infinite = intval($mybb->input['infinite']);
                    if ($infinite == 1) {
                        $stock = 0;
                    } else {
                        $stock = intval($mybb->input['stock']);
                    }
                    $limit = intval($mybb->input['limit']);
                    $visible = intval($mybb->input['visible']);
                    $disporder = intval($mybb->input['disporder']);
                    $sendable = intval($mybb->input['sendable']);
                    $sellable = intval($mybb->input['sellable']);
                    $cid = intval($mybb->input['cid']);
                    if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                    }
                    $insert_array = array('name' => $name, 'description' => $description, 'icon' => $icon, 'visible' => $visible, 'disporder' => $disporder, 'price' => $price, 'infinite' => $infinite, 'stock' => $stock, 'limit' => $limit, 'sendable' => $sendable, 'sellable' => $sellable, 'cid' => $cid, 'pm' => $pm);
                    $plugins->run_hooks("newpoints_shop_commit", $insert_array);
                    $db->insert_query('newpoints_shop_items', $insert_array);
                    $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items+1 WHERE cid=\'' . $cid . '\'');
                    newpoints_shop_messageredirect($lang->newpoints_shop_item_added, 0, "items&amp;cid=" . $cid);
                    break;
                case 'do_edititem':
                    $iid = intval($mybb->input['iid']);
                    if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, 'items');
                    }
                    if ($mybb->input['name'] == '' || $mybb->input['cid'] == '') {
                        newpoints_shop_messageredirect($lang->newpoints_shop_missing_field, 1);
                    }
                    $name = $db->escape_string($mybb->input['name']);
                    $description = $db->escape_string($mybb->input['description']);
                    $icon = $db->escape_string($mybb->input['icon']);
                    $price = floatval($mybb->input['price']);
                    $pm = $db->escape_string($mybb->input['pm']);
                    $infinite = intval($mybb->input['infinite']);
                    if ($infinite == 1) {
                        $stock = 0;
                    } else {
                        $stock = intval($mybb->input['stock']);
                    }
                    $limit = intval($mybb->input['limit']);
                    $visible = intval($mybb->input['visible']);
                    $disporder = intval($mybb->input['disporder']);
                    $sendable = intval($mybb->input['sendable']);
                    $sellable = intval($mybb->input['sellable']);
                    $cid = intval($mybb->input['cid']);
                    if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                    }
                    $update_array = array('name' => $name, 'description' => $description, 'icon' => $icon, 'visible' => $visible, 'disporder' => $disporder, 'price' => $price, 'infinite' => $infinite, 'stock' => $stock, 'limit' => $limit, 'sendable' => $sendable, 'sellable' => $sellable, 'cid' => $cid, 'pm' => $pm);
                    $plugins->run_hooks("newpoints_shop_commit", $update_array);
                    $db->update_query('newpoints_shop_items', $update_array, 'iid=\'' . $iid . '\'');
                    if ($cid != $item['cid']) {
                        $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items-1 WHERE cid=\'' . $item['cid'] . '\'');
                        $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items+1 WHERE cid=\'' . $cid . '\'');
                    }
                    newpoints_shop_messageredirect($lang->newpoints_shop_item_edited, 0, "items&amp;cid=" . $cid);
                    break;
            }
        }
        if ($mybb->input['action'] == 'do_deletecat') {
            $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop');
            $page->output_header($lang->newpoints_shop);
            $cid = intval($mybb->input['cid']);
            if ($mybb->input['no']) {
                admin_redirect("index.php?module=newpoints-shop");
            }
            if ($mybb->request_method == "post") {
                if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', 'cid', "cid = {$cid}")))) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                }
                $db->delete_query('newpoints_shop_categories', "cid = {$cid}");
                // unassign items from this category
                $db->update_query('newpoints_shop_items', array('cid' => 0), "cid = {$cid}");
                newpoints_shop_messageredirect($lang->newpoints_shop_cat_deleted);
            } else {
                $mybb->input['cid'] = intval($mybb->input['cid']);
                $form = new Form("index.php?module=newpoints-shop&amp;action=do_deletecat&amp;cid={$mybb->input['cid']}&amp;my_post_key={$mybb->post_code}", 'post');
                echo "<div class=\"confirm_action\">\n";
                echo "<p>{$lang->newpoints_shop_confirm_deletecat}</p>\n";
                echo "<br />\n";
                echo "<p class=\"buttons\">\n";
                echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes'));
                echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no'));
                echo "</p>\n";
                echo "</div>\n";
                $form->end();
            }
        } elseif ($mybb->input['action'] == 'do_deleteitem') {
            $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop');
            $page->output_header($lang->newpoints_shop);
            $iid = intval($mybb->input['iid']);
            if ($mybb->input['no']) {
                admin_redirect("index.php?module=newpoints-shop", 0, "items&amp;cid=" . $cid);
            }
            if ($mybb->request_method == "post") {
                if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', 'cid', "iid = {$iid}")))) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, "items&amp;cid=" . $cid);
                }
                $db->delete_query('newpoints_shop_items', "iid = {$iid}");
                // remove one from the items count
                $db->write_query('UPDATE ' . TABLE_PREFIX . 'newpoints_shop_categories SET items = items-1 WHERE cid=\'' . $item['cid'] . '\'');
                newpoints_shop_messageredirect($lang->newpoints_shop_item_deleted, 0, "items&amp;cid=" . $cid);
            } else {
                $mybb->input['iid'] = intval($mybb->input['iid']);
                $form = new Form("index.php?module=newpoints-shop&amp;action=do_deleteitem&amp;iid={$mybb->input['iid']}&amp;my_post_key={$mybb->post_code}", 'post');
                echo "<div class=\"confirm_action\">\n";
                echo "<p>{$lang->newpoints_shop_confirm_deleteitem}</p>\n";
                echo "<br />\n";
                echo "<p class=\"buttons\">\n";
                echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes'));
                echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no'));
                echo "</p>\n";
                echo "</div>\n";
                $form->end();
            }
        } elseif ($mybb->input['action'] == 'remove') {
            $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop');
            $page->output_header($lang->newpoints_shop);
            $iid = intval($mybb->input['iid']);
            $mybb->input['uid'] = intval($mybb->input['uid']);
            if ($mybb->input['no']) {
                admin_redirect("index.php?module=newpoints-shop", 0, "items&amp;cid=" . $cid);
            }
            if ($mybb->request_method == "post") {
                if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, "items&amp;cid=" . $cid);
                }
                $uid = (int) $mybb->input['uid'];
                if ($uid <= 0) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1);
                }
                $user = get_user($uid);
                // we're viewing someone else's inventory
                if (empty($user)) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1);
                }
                $inventory = @unserialize($user['newpoints_items']);
                if (!$inventory) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_inventory_empty, 1);
                }
                // make sure we own the item
                $key = array_search($item['iid'], $inventory);
                if ($key === false) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_selected_item_not_owned, 1);
                }
                // remove item from our inventory
                unset($inventory[$key]);
                sort($inventory);
                $db->update_query('users', array('newpoints_items' => serialize($inventory)), 'uid=\'' . $uid . '\'');
                // update stock
                if ($item['infinite'] != 1) {
                    $db->update_query('newpoints_shop_items', array('stock' => $item['stock'] + 1), 'iid=\'' . $item['iid'] . '\'');
                }
                newpoints_addpoints($uid, floatval($item['price']) * $mybb->settings['newpoints_shop_percent']);
                newpoints_shop_messageredirect($lang->newpoints_shop_item_removed, 0, "inventory&amp;uid=" . $uid);
            } else {
                $form = new Form("index.php?module=newpoints-shop&amp;action=remove&amp;iid={$mybb->input['iid']}&amp;uid={$mybb->input['uid']}&amp;my_post_key={$mybb->post_code}", 'post');
                echo "<div class=\"confirm_action\">\n";
                echo "<p>{$lang->newpoints_shop_confirm_removeitem}</p>\n";
                echo "<br />\n";
                echo "<p class=\"buttons\">\n";
                echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes'));
                echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no'));
                echo "</p>\n";
                echo "</div>\n";
                $form->end();
            }
        }
        if (!$mybb->input['action'] || $mybb->input['action'] == 'categories' || $mybb->input['action'] == 'inventory' || $mybb->input['action'] == 'addcat' || $mybb->input['action'] == 'editcat') {
            $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop');
            $page->output_header($lang->newpoints_shop);
            $sub_tabs['newpoints_shop_categories'] = array('title' => $lang->newpoints_shop_categories, 'link' => 'index.php?module=newpoints-shop', 'description' => $lang->newpoints_shop_categories_desc);
            if (!$mybb->input['action'] || $mybb->input['action'] == 'categories' || $mybb->input['action'] == 'addcat' || $mybb->input['action'] == 'editcat') {
                $sub_tabs['newpoints_shop_categories_add'] = array('title' => $lang->newpoints_shop_addcat, 'link' => 'index.php?module=newpoints-shop&amp;action=addcat', 'description' => $lang->newpoints_shop_addcat_desc);
                $sub_tabs['newpoints_shop_categories_edit'] = array('title' => $lang->newpoints_shop_editcat, 'link' => 'index.php?module=newpoints-shop&amp;action=editcat', 'description' => $lang->newpoints_shop_editcat_desc);
                $sub_tabs['newpoints_shop_categories_delete'] = array('title' => $lang->newpoints_shop_deletecat, 'link' => 'index.php?module=newpoints-shop&amp;action=do_deletecat', 'description' => $lang->newpoints_shop_deletecat_desc);
            }
        }
        if ($mybb->input['action'] == 'inventory') {
            $sub_tabs['newpoints_shop_inventory'] = array('title' => $lang->newpoints_shop_inventory, 'link' => 'index.php?module=newpoints-shop&amp;action=inventory&amp;uid=' . intval($mybb->input['uid']), 'description' => $lang->newpoints_shop_inventory_desc);
        }
        if ($mybb->input['action'] == 'items' || $mybb->input['action'] == 'additem' || $mybb->input['action'] == 'edititem') {
            $page->add_breadcrumb_item($lang->newpoints_shop, 'index.php?module=newpoints-shop');
            $page->output_header($lang->newpoints_shop);
            $sub_tabs['newpoints_shop_categories'] = array('title' => $lang->newpoints_shop_categories, 'link' => 'index.php?module=newpoints-shop', 'description' => $lang->newpoints_shop_categories_desc);
            $sub_tabs['newpoints_shop_items'] = array('title' => $lang->newpoints_shop_items, 'link' => 'index.php?module=newpoints-shop&amp;action=items&amp;cid=' . intval($mybb->input['cid']), 'description' => $lang->newpoints_shop_items_desc);
            if ($mybb->input['action'] == 'items' || $mybb->input['action'] == 'additem' || $mybb->input['action'] == 'edititem') {
                $sub_tabs['newpoints_shop_items_add'] = array('title' => $lang->newpoints_shop_additem, 'link' => 'index.php?module=newpoints-shop&amp;action=additem&amp;cid=' . intval($mybb->input['cid']), 'description' => $lang->newpoints_shop_additem_desc);
                $sub_tabs['newpoints_shop_items_edit'] = array('title' => $lang->newpoints_shop_edititem, 'link' => 'index.php?module=newpoints-shop&amp;action=edititem', 'description' => $lang->newpoints_shop_edititem_desc);
                $sub_tabs['newpoints_shop_items_delete'] = array('title' => $lang->newpoints_shop_deleteitem, 'link' => 'index.php?module=newpoints-shop&amp;action=do_deleteitem', 'description' => $lang->newpoints_shop_deleteitem_desc);
            }
        }
        if (!$mybb->input['action'] || $mybb->input['action'] == 'categories') {
            $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories');
            // table
            $table = new Table();
            $table->construct_header($lang->newpoints_shop_cat_name, array('width' => '30%'));
            $table->construct_header($lang->newpoints_shop_cat_description, array('width' => '35%'));
            $table->construct_header($lang->newpoints_shop_cat_items, array('width' => '10%', 'class' => 'align_center'));
            $table->construct_header($lang->newpoints_shop_cat_disporder, array('width' => '10%', 'class' => 'align_center'));
            $table->construct_header($lang->newpoints_shop_cat_action, array('width' => '25%', 'class' => 'align_center'));
            $query = $db->simple_select('newpoints_shop_categories', '*', '', array('order_by' => 'disporder', 'order_dir' => 'ASC'));
            while ($cat = $db->fetch_array($query)) {
                $table->construct_cell("<a href=\"index.php?module=newpoints-shop&amp;action=items&amp;cid={$cat['cid']}\">" . htmlspecialchars_uni($cat['name']) . "</a>");
                $table->construct_cell(htmlspecialchars_uni($cat['description']));
                $table->construct_cell(intval($cat['items']), array('class' => 'align_center'));
                $table->construct_cell(intval($cat['disporder']), array('class' => 'align_center'));
                // actions column
                $table->construct_cell("<a href=\"index.php?module=newpoints-shop&amp;action=editcat&amp;cid=" . intval($cat['cid']) . "\">" . $lang->newpoints_shop_edit . "</a> - <a href=\"index.php?module=newpoints-shop&amp;action=do_deletecat&amp;cid=" . intval($cat['cid']) . "\">" . $lang->newpoints_shop_delete . "</a>", array('class' => 'align_center'));
                $table->construct_row();
            }
            if ($table->num_rows() == 0) {
                $table->construct_cell($lang->newpoints_shop_no_cats, array('colspan' => 5));
                $table->construct_row();
            }
            $table->output($lang->newpoints_shop_categories);
        } elseif ($mybb->input['action'] == 'addcat') {
            $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories_add');
            $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
            while ($usergroup = $db->fetch_array($query)) {
                $options[$usergroup['gid']] = $usergroup['title'];
            }
            $form = new Form("index.php?module=newpoints-shop&amp;action=do_addcat", "post", "newpoints_shop");
            $form_container = new FormContainer($lang->newpoints_shop_addcat);
            $form_container->output_row($lang->newpoints_shop_addedit_cat_name . "<em>*</em>", $lang->newpoints_shop_addedit_cat_name_desc, $form->generate_text_box('name', '', array('id' => 'name')), 'name');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_description, $lang->newpoints_shop_addedit_cat_description_desc, $form->generate_text_box('description', '', array('id' => 'description')), 'description');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_visible, $lang->newpoints_shop_addedit_cat_visible_desc, $form->generate_yes_no_radio('visible', 1), 'visible');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_icon, $lang->newpoints_shop_addedit_cat_icon_desc, $form->generate_text_box('icon', '', array('id' => 'icon')), 'icon');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_usergroups, $lang->newpoints_shop_addedit_cat_usergroups_desc, $form->generate_select_box('usergroups[]', $options, '', array('id' => 'usergroups', 'multiple' => true, 'size' => 5)), 'groups');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_disporder, $lang->newpoints_shop_addedit_cat_disporder_desc, $form->generate_text_box('disporder', '0', array('id' => 'disporder')), 'disporder');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_expanded, $lang->newpoints_shop_addedit_cat_expanded_desc, $form->generate_yes_no_radio('expanded', 1), 'expanded');
            $form_container->end();
            $buttons = "";
            $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit);
            $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset);
            $form->output_submit_wrapper($buttons);
            $form->end();
        } elseif ($mybb->input['action'] == 'editcat') {
            $page->output_nav_tabs($sub_tabs, 'newpoints_shop_categories_edit');
            $cid = intval($mybb->input['cid']);
            if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
            }
            $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
            while ($usergroup = $db->fetch_array($query)) {
                $options[$usergroup['gid']] = $usergroup['title'];
            }
            $form = new Form("index.php?module=newpoints-shop&amp;action=do_editcat", "post", "newpoints_shop");
            echo $form->generate_hidden_field('cid', $cat['cid']);
            $form_container = new FormContainer($lang->newpoints_shop_addcat);
            $form_container->output_row($lang->newpoints_shop_addedit_cat_name . "<em>*</em>", $lang->newpoints_shop_addedit_cat_name_desc, $form->generate_text_box('name', htmlspecialchars_uni($cat['name']), array('id' => 'name')), 'name');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_description, $lang->newpoints_shop_addedit_cat_description_desc, $form->generate_text_box('description', htmlspecialchars_uni($cat['description']), array('id' => 'description')), 'description');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_visible, $lang->newpoints_shop_addedit_cat_visible_desc, $form->generate_yes_no_radio('visible', intval($cat['visible'])), 'visible');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_icon, $lang->newpoints_shop_addedit_cat_icon_desc, $form->generate_text_box('icon', htmlspecialchars_uni($cat['icon']), array('id' => 'icon')), 'icon');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_usergroups, $lang->newpoints_shop_addedit_cat_usergroups_desc, $form->generate_select_box('usergroups[]', $options, explode(',', $cat['usergroups']), array('id' => 'usergroups', 'multiple' => true, 'size' => 5)), 'groups');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_disporder, $lang->newpoints_shop_addedit_cat_disporder_desc, $form->generate_text_box('disporder', intval($cat['disporder']), array('id' => 'disporder')), 'disporder');
            $form_container->output_row($lang->newpoints_shop_addedit_cat_expanded, $lang->newpoints_shop_addedit_cat_expanded_desc, $form->generate_yes_no_radio('expanded', intval($cat['expanded'])), 'expanded');
            $form_container->end();
            $buttons = "";
            $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit);
            $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset);
            $form->output_submit_wrapper($buttons);
            $form->end();
        } else {
            if ($mybb->input['action'] == 'items') {
                $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items');
                $cid = intval($mybb->input['cid']);
                if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                }
                // table
                $table = new Table();
                $table->construct_header($lang->newpoints_shop_item_icon, array('width' => '10%', 'class' => 'align_center'));
                $table->construct_header($lang->newpoints_shop_item_name, array('width' => '30%'));
                $table->construct_header($lang->newpoints_shop_item_price, array('width' => '15%', 'class' => 'align_center'));
                $table->construct_header($lang->newpoints_shop_item_disporder, array('width' => '15%', 'class' => 'align_center'));
                $table->construct_header($lang->newpoints_shop_item_action, array('width' => '20%', 'class' => 'align_center'));
                $query = $db->simple_select('newpoints_shop_items', '*', 'cid=\'' . $cid . '\'', array('order_by' => 'disporder', 'order_dir' => 'ASC'));
                while ($item = $db->fetch_array($query)) {
                    if ($item['infinite'] == 1) {
                        $item['stock'] = $lang->newpoints_shop_infinite;
                    }
                    if ($item['visible'] == 0) {
                        $visible_info = ' (<span style="color: #FF0000;">hidden</span>)';
                    } else {
                        $visible_info = '';
                    }
                    $table->construct_cell(htmlspecialchars_uni($item['icon']) ? '<img src="' . $mybb->settings['bburl'] . '/' . $item['icon'] . '">' : '<img src="' . $mybb->settings['bburl'] . '/images/newpoints/default.png">', array('class' => 'align_center'));
                    $table->construct_cell(htmlspecialchars_uni($item['name']) . " (" . (intval($item['infinite']) ? $lang->newpoints_shop_infinite : intval($item['stock'])) . ")" . $visible_info . "<br /><small>" . htmlspecialchars_uni($item['description']) . "</small>");
                    $table->construct_cell(newpoints_format_points($item['price']), array('class' => 'align_center'));
                    $table->construct_cell(intval($item['disporder']), array('class' => 'align_center'));
                    // actions column
                    $table->construct_cell("<a href=\"index.php?module=newpoints-shop&amp;action=edititem&amp;iid=" . intval($item['iid']) . "\">" . $lang->newpoints_shop_edit . "</a> - <a href=\"index.php?module=newpoints-shop&amp;action=do_deleteitem&amp;iid=" . intval($item['iid']) . "\">" . $lang->newpoints_shop_delete . "</a>", array('class' => 'align_center'));
                    $table->construct_row();
                }
                if ($table->num_rows() == 0) {
                    $table->construct_cell($lang->newpoints_shop_no_items, array('colspan' => 6));
                    $table->construct_row();
                }
                $table->output($lang->newpoints_shop_items);
            } elseif ($mybb->input['action'] == 'additem') {
                $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items_add');
                $cid = intval($mybb->input['cid']);
                if ($cid > 0) {
                    if ($cid <= 0 || !($cat = $db->fetch_array($db->simple_select('newpoints_shop_categories', '*', "cid = {$cid}")))) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_cat, 1);
                    }
                } else {
                    $cid = 0;
                }
                $categories[0] = $lang->newpoints_shop_select_cat;
                $query = $db->simple_select('newpoints_shop_categories', '*');
                while ($cat = $db->fetch_array($query)) {
                    $categories[$cat['cid']] = $cat['name'];
                }
                $form = new Form("index.php?module=newpoints-shop&amp;action=do_additem", "post", "newpoints_shop");
                $form_container = new FormContainer($lang->newpoints_shop_additem);
                $form_container->output_row($lang->newpoints_shop_addedit_item_name . "<em>*</em>", $lang->newpoints_shop_addedit_item_name_desc, $form->generate_text_box('name', '', array('id' => 'name')), 'name');
                $form_container->output_row($lang->newpoints_shop_addedit_item_description, $lang->newpoints_shop_addedit_item_description_desc, $form->generate_text_box('description', '', array('id' => 'description')), 'description');
                $form_container->output_row($lang->newpoints_shop_addedit_item_price, $lang->newpoints_shop_addedit_item_price_desc, $form->generate_text_box('price', '0', array('id' => 'price')), 'price');
                $form_container->output_row($lang->newpoints_shop_addedit_item_icon, $lang->newpoints_shop_addedit_item_icon_desc, $form->generate_text_box('icon', '', array('id' => 'icon')), 'icon');
                $form_container->output_row($lang->newpoints_shop_addedit_item_disporder, $lang->newpoints_shop_addedit_item_disporder_desc, $form->generate_text_box('disporder', '0', array('id' => 'disporder')), 'disporder');
                $form_container->output_row($lang->newpoints_shop_addedit_item_stock, $lang->newpoints_shop_addedit_item_stock_desc, $form->generate_text_box('stock', '0', array('id' => 'stock')), 'stock');
                $form_container->output_row($lang->newpoints_shop_addedit_item_infinite, $lang->newpoints_shop_addedit_item_infinite_desc, $form->generate_yes_no_radio('infinite', 1), 'infinite');
                $form_container->output_row($lang->newpoints_shop_addedit_item_limit, $lang->newpoints_shop_addedit_item_limit_desc, $form->generate_text_box('limit', '0', array('id' => 'limit')), 'limit');
                $form_container->output_row($lang->newpoints_shop_addedit_item_visible, $lang->newpoints_shop_addedit_item_visible_desc, $form->generate_yes_no_radio('visible', 1), 'visible');
                $form_container->output_row($lang->newpoints_shop_addedit_item_sendable, $lang->newpoints_shop_addedit_item_sendable_desc, $form->generate_yes_no_radio('sendable', 1), 'sendable');
                $form_container->output_row($lang->newpoints_shop_addedit_item_sellable, $lang->newpoints_shop_addedit_item_sellable_desc, $form->generate_yes_no_radio('sellable', 1), 'sellable');
                $form_container->output_row($lang->newpoints_shop_addedit_item_pm, $lang->newpoints_shop_addedit_item_pm_desc, $form->generate_text_area('pm', '', array('id' => 'pm_text')), 'pm');
                $form_container->output_row($lang->newpoints_shop_addedit_item_category . "<em>*</em>", $lang->newpoints_shop_addedit_item_category_desc, $form->generate_select_box('cid', $categories, $cid, array('id' => 'cid')), 'cid');
                $args = array($form_container, $form, array());
                $plugins->run_hooks("newpoints_shop_row", $args);
                $form_container->end();
                $buttons = "";
                $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit);
                $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset);
                $form->output_submit_wrapper($buttons);
                $form->end();
            } elseif ($mybb->input['action'] == 'edititem') {
                $page->output_nav_tabs($sub_tabs, 'newpoints_shop_items_edit');
                $iid = intval($mybb->input['iid']);
                if ($iid <= 0 || !($item = $db->fetch_array($db->simple_select('newpoints_shop_items', '*', "iid = {$iid}")))) {
                    newpoints_shop_messageredirect($lang->newpoints_shop_invalid_item, 1, 'items');
                }
                $categories[0] = $lang->newpoints_shop_select_cat;
                $query = $db->simple_select('newpoints_shop_categories', '*');
                while ($cat = $db->fetch_array($query)) {
                    $categories[$cat['cid']] = $cat['name'];
                }
                $form = new Form("index.php?module=newpoints-shop&amp;action=do_edititem", "post", "newpoints_shop");
                echo $form->generate_hidden_field('iid', $iid);
                $form_container = new FormContainer($lang->newpoints_shop_additem);
                $form_container->output_row($lang->newpoints_shop_addedit_item_name . "<em>*</em>", $lang->newpoints_shop_addedit_item_name_desc, $form->generate_text_box('name', htmlspecialchars_uni($item['name']), array('id' => 'name')), 'name');
                $form_container->output_row($lang->newpoints_shop_addedit_item_description, $lang->newpoints_shop_addedit_item_description_desc, $form->generate_text_box('description', htmlspecialchars_uni($item['description']), array('id' => 'description')), 'description');
                $form_container->output_row($lang->newpoints_shop_addedit_item_price, $lang->newpoints_shop_addedit_item_price_desc, $form->generate_text_box('price', floatval($item['price']), array('id' => 'price')), 'price');
                $form_container->output_row($lang->newpoints_shop_addedit_item_icon, $lang->newpoints_shop_addedit_item_icon_desc, $form->generate_text_box('icon', htmlspecialchars_uni($item['icon']), array('id' => 'icon')), 'icon');
                $form_container->output_row($lang->newpoints_shop_addedit_item_disporder, $lang->newpoints_shop_addedit_item_disporder_desc, $form->generate_text_box('disporder', intval($item['disporder']), array('id' => 'disporder')), 'disporder');
                $form_container->output_row($lang->newpoints_shop_addedit_item_stock, $lang->newpoints_shop_addedit_item_stock_desc, $form->generate_text_box('stock', intval($item['stock']), array('id' => 'stock')), 'stock');
                $form_container->output_row($lang->newpoints_shop_addedit_item_infinite, $lang->newpoints_shop_addedit_item_infinite_desc, $form->generate_yes_no_radio('infinite', intval($item['infinite'])), 'infinite');
                $form_container->output_row($lang->newpoints_shop_addedit_item_limit, $lang->newpoints_shop_addedit_item_limit_desc, $form->generate_text_box('limit', intval($item['limit']), array('id' => 'limit')), 'limit');
                $form_container->output_row($lang->newpoints_shop_addedit_item_visible, $lang->newpoints_shop_addedit_item_visible_desc, $form->generate_yes_no_radio('visible', intval($item['visible'])), 'visible');
                $form_container->output_row($lang->newpoints_shop_addedit_item_sendable, $lang->newpoints_shop_addedit_item_sendable_desc, $form->generate_yes_no_radio('sendable', intval($item['sendable'])), 'sendable');
                $form_container->output_row($lang->newpoints_shop_addedit_item_sellable, $lang->newpoints_shop_addedit_item_sellable_desc, $form->generate_yes_no_radio('sellable', intval($item['sellable'])), 'sellable');
                $form_container->output_row($lang->newpoints_shop_addedit_item_pm, $lang->newpoints_shop_addedit_item_pm_desc, $form->generate_text_area('pm', htmlspecialchars_uni($item['pm']), array('id' => 'pm_text')), 'pm');
                $form_container->output_row($lang->newpoints_shop_addedit_item_category . "<em>*</em>", $lang->newpoints_shop_addedit_item_category_desc, $form->generate_select_box('cid', $categories, intval($item['cid']), array('id' => 'cid')), 'cid');
                $args = array($form_container, $form, $item);
                $plugins->run_hooks("newpoints_shop_row", $args);
                $form_container->end();
                $buttons = "";
                $buttons[] = $form->generate_submit_button($lang->newpoints_shop_submit);
                $buttons[] = $form->generate_reset_button($lang->newpoints_shop_reset);
                $form->output_submit_wrapper($buttons);
                $form->end();
            } else {
                if ($mybb->input['action'] == 'inventory') {
                    $page->output_nav_tabs($sub_tabs, 'newpoints_shop_inventory');
                    $uid = (int) $mybb->input['uid'];
                    if ($uid <= 0) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1);
                    }
                    $user = get_user($uid);
                    // we're viewing someone else's inventory
                    if (empty($user)) {
                        newpoints_shop_messageredirect($lang->newpoints_shop_invalid_user, 1);
                    }
                    $inventory = @unserialize($user['newpoints_items']);
                    if (!$inventory) {
                        $inventory = array(0);
                    }
                    // Item id is 0 because it doesn't exist, this when we use it in the query we won't show anything
                    // table
                    $table = new Table();
                    $table->construct_header($lang->newpoints_shop_item_icon, array('width' => '10%', 'class' => 'align_center'));
                    $table->construct_header($lang->newpoints_shop_item_name, array('width' => '30%'));
                    $table->construct_header($lang->newpoints_shop_item_price, array('width' => '15%', 'class' => 'align_center'));
                    $table->construct_header($lang->newpoints_shop_item_disporder, array('width' => '15%', 'class' => 'align_center'));
                    $table->construct_header($lang->newpoints_shop_item_action, array('width' => '20%', 'class' => 'align_center'));
                    $query = $db->simple_select('newpoints_shop_items', '*', 'iid IN (' . implode(',', array_unique($inventory)) . ')', array('order_by' => 'disporder', 'order_dir' => 'ASC'));
                    while ($item = $db->fetch_array($query)) {
                        if ($item['infinite'] == 1) {
                            $item['stock'] = $lang->newpoints_shop_infinite;
                        }
                        if ($item['visible'] == 0) {
                            $visible_info = ' (<span style="color: #FF0000;">hidden</span>)';
                        } else {
                            $visible_info = '';
                        }
                        $table->construct_cell(htmlspecialchars_uni($item['icon']) ? '<img src="' . $mybb->settings['bburl'] . '/' . $item['icon'] . '">' : '<img src="' . $mybb->settings['bburl'] . '/images/newpoints/default.png">', array('class' => 'align_center'));
                        $table->construct_cell(htmlspecialchars_uni($item['name']) . " (" . count(array_keys($inventory, $item['iid'])) . ")" . $visible_info . "<br /><small>" . htmlspecialchars_uni($item['description']) . "</small>");
                        $table->construct_cell(newpoints_format_points($item['price']), array('class' => 'align_center'));
                        $table->construct_cell(intval($item['disporder']), array('class' => 'align_center'));
                        // actions column
                        $table->construct_cell("<a href=\"index.php?module=newpoints-shop&amp;action=remove&amp;iid=" . intval($item['iid']) . "&amp;uid=" . (int) $user['uid'] . "\">" . $lang->newpoints_shop_remove . "</a>", array('class' => 'align_center'));
                        $table->construct_row();
                    }
                    if ($table->num_rows() == 0) {
                        $table->construct_cell($lang->newpoints_shop_no_items, array('colspan' => 5));
                        $table->construct_row();
                    }
                    $table->output($lang->newpoints_shop_inventory_of . " " . htmlspecialchars_uni($user['username']));
                }
            }
        }
        $page->output_footer();
        exit;
    }
}
Example #24
0
    $querydata = $db->fetch_array($query);
    if (!$querydata['PID']) {
        // The announcement was defined, but did not exist.
        flash_message($lang->bam_delete_error, 'error');
        admin_redirect('index.php?module=config-bam');
    }
    $db->delete_query('bam', "PID='{$PID}'");
    flash_message($lang->bam_delete_success, 'success');
    admin_redirect('index.php?module=config-bam');
}
if ($mybb->input['action'] == "add") {
    // generate add announcement form.
    $form = new Form("index.php?module=config-bam", "post");
    $form_container = new FormContainer($lang->bam_form_add);
    echo $form->generate_hidden_field("action", "submit_add");
    $form_container->output_row($lang->bam_form_announcement, $lang->bam_form_announcement_desc, $form->generate_text_area("announcement", '', array("class" => "text_input align_left", "style" => "width: 50%;")), 'announcement');
    $form_container->output_row($lang->bam_form_style, $lang->bam_form_style_desc, $form->generate_select_box('class', $class_select, $mybb->input['fieldtype'], array('id' => 'style')), 'class');
    $form_container->output_row($lang->bam_form_class_custom, $lang->bam_form_class_custom_desc, $form->generate_text_box("custom_class", $mybb->input['custom_class'], array("class" => "text_input", "style" => "width: 25%;")), 'custom_class');
    $options = array();
    $query = $db->simple_select("usergroups", "gid, title", null, array('order_by' => 'title'));
    while ($usergroup = $db->fetch_array($query)) {
        $options[(int) $usergroup['gid']] = $usergroup['title'];
        $default_usergroups[] = (int) $usergroup['gid'];
    }
    $form_container->output_row($lang->bam_form_groups, $lang->bam_form_groups_desc, $form->generate_select_box('usergroup[]', $options, $default_usergroups, array('id' => 'usergroup', 'multiple' => true, 'size' => 5)), 'usergroup');
    $query = $db->query("SELECT disporder FROM " . TABLE_PREFIX . "bam ORDER BY disporder DESC LIMIT 1");
    // select last announcement by display order.
    $last = $db->fetch_array($query);
    $form_container->output_row($lang->bam_form_order, $lang->bam_form_order_desc, $form->generate_text_box("disporder", (int) $last['disporder'] + 1, array("class" => "text_input align_right", "style" => "width: 25%;")), 'disporder');
    $form_container->output_row($lang->bam_form_url, $lang->bam_form_url_desc, $form->generate_text_box("url", $mybb->input['url'], array("class" => "text_input align_right", "style" => "width: 25%;")), 'url');
    $form_container->output_row($lang->bam_form_pinned, $lang->bam_form_pinned_desc, $form->generate_yes_no_radio('pinned', 0));
Example #25
0
 }
 $table->construct_cell("<strong>{$lang->warning}</strong><br /><br />{$warning_type} {$points}", array('width' => '50%'));
 $table->construct_cell("<strong>{$lang->date_issued}</strong><br /><br />{$date_issued}", array('width' => '50%'));
 $table->construct_row();
 $table->construct_cell("<strong>{$lang->issued_by}</strong><br /><br />{$issuedby}", array('width' => '50%'));
 $table->construct_cell("<strong>{$lang->expires}</strong><br /><br />{$expires}", array('width' => '50%'));
 $table->construct_row();
 $table->construct_cell("<strong>{$lang->warning_note}</strong><br /><br />{$notes}", array('colspan' => 2));
 $table->construct_row();
 $table->output("<div class=\"float_right\" style=\"font-weight: normal;\">{$status}</div>" . $lang->warning_details);
 if (!$warning['daterevoked']) {
     $form = new Form("index.php?module=tools-warninglog", "post");
     $form_container = new FormContainer($lang->revoke_warning);
     echo $form->generate_hidden_field('action', 'do_revoke');
     echo $form->generate_hidden_field('wid', $warning['wid']);
     $form_container->output_row("", $lang->revoke_warning_desc, $form->generate_text_area('reason', $mybb->input['reason'], array('id' => 'reason')), 'reason');
     $form_container->end();
     $buttons[] = $form->generate_submit_button($lang->revoke_warning);
     $form->output_submit_wrapper($buttons);
     $form->end();
 } else {
     $date_revoked = my_date($mybb->settings['dateformat'], $warning['daterevoked']) . ", " . my_date($mybb->settings['timeformat'], $warning['daterevoked']);
     $revoked_user = get_user($warning['revokedby']);
     $revoked_by = build_profile_link($revoked_user['username'], $revoked_user['uid'], "_blank");
     $revoke_reason = nl2br(htmlspecialchars_uni($warning['revokereason']));
     $revoke_table = new Table();
     $revoke_table->construct_cell("<strong>{$lang->revoked_by}</strong><br /><br />{$revoked_by}", array('width' => '50%'));
     $revoke_table->construct_cell("<strong>{$lang->date_revoked}</strong><br /><br />{$date_revoked}", array('width' => '50%'));
     $revoke_table->construct_row();
     $revoke_table->construct_cell("<strong>{$lang->reason}</strong><br /><br />{$revoke_reason}", array('colspan' => 2));
     $revoke_table->construct_row();
Example #26
0
    if ($errors) {
        $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];
    }
    $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->maximum_length, $lang->maximum_length_desc, $form->generate_text_box('maxlength', $mybb->input['maxlength'], array('id' => 'maxlength')), 'maxlength', array(), array('id' => 'row_maxlength'));
    $form_container->output_row($lang->field_length, $lang->field_length_desc, $form->generate_text_box('length', $mybb->input['length'], array('id' => 'length')), '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->display_order . " <em>*</em>", $lang->display_order_desc, $form->generate_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), '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->editable_by_user . " <em>*</em>", $lang->editable_by_user_desc, $form->generate_yes_no_radio('editable', $mybb->input['editable']));
    $form_container->output_row($lang->hide_on_profile . " <em>*</em>", $lang->hide_on_profile_desc, $form->generate_yes_no_radio('hidden', $mybb->input['hidden']));
    $form_container->output_row($lang->min_posts_enabled, $lang->min_posts_enabled_desc, $form->generate_text_box('postnum', $mybb->input['postnum'], array('id' => 'postnum')), 'postnum');
    $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"></script>
	<script type="text/javascript">
		Event.observe(window, "load", function() {
				var maxlength_peeker = new Peeker($("fieldtype"), $("row_maxlength"), /text|textarea/);
				var fieldlength_peeker = new Peeker($("fieldtype"), $("row_fieldlength"), /select|multiselect/);
				var options_peeker = new Peeker($("fieldtype"), $("row_options"), /select|radio|checkbox/);
Example #27
0
 $sub_tabs['edit_mycode'] = array('title' => $lang->edit_mycode, 'link' => "index.php?module=config/mycode&amp;action=edit", 'description' => $lang->edit_mycode_desc);
 $page->extra_header .= "\n\t<script type=\"text/javascript\">\n\tvar my_post_key = '" . $mybb->post_code . "';\n\t</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&amp;action=edit", "post", "edit");
 echo $form->generate_hidden_field('cid', $mycode['cid']);
 if ($errors) {
     $page->output_inline_error($errors);
 } else {
     $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> &lt;strong&gt;$1&lt;/strong&gt;', $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_text_box('parseorder', $mybb->input['parseorder'], array('id' => 'parseorder')), '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>';
Example #28
0
     $form_container->end();
     echo '<br />';
     $form->end();
     $page->output_footer();
 }
 foreach ($cache_settings[$groupinfo['plugin']] as $setting) {
     $options = "";
     $type = explode("\n", $setting['type']);
     $type[0] = trim($type[0]);
     $element_name = "upsetting[{$setting['name']}]";
     $element_id = "setting_{$setting['name']}";
     if ($type[0] == "text" || $type[0] == "") {
         $setting_code = $form->generate_text_box($element_name, $setting['value'], array('id' => $element_id));
     } else {
         if ($type[0] == "textarea") {
             $setting_code = $form->generate_text_area($element_name, $setting['value'], array('id' => $element_id));
         } else {
             if ($type[0] == "yesno") {
                 $setting_code = $form->generate_yes_no_radio($element_name, $setting['value'], true, array('id' => $element_id . '_yes', 'class' => $element_id), array('id' => $element_id . '_no', 'class' => $element_id));
             } else {
                 if ($type[0] == "onoff") {
                     $setting_code = $form->generate_on_off_radio($element_name, $setting['value'], true, array('id' => $element_id . '_on', 'class' => $element_id), array('id' => $element_id . '_off', 'class' => $element_id));
                 } else {
                     if ($type[0] == "cpstyle") {
                         $dir = @opendir(MYBB_ROOT . $config['admin_dir'] . "/styles");
                         while ($folder = readdir($dir)) {
                             if ($file != "." && $file != ".." && @file_exists(MYBB_ROOT . $config['admin_dir'] . "/styles/{$folder}/main.css")) {
                                 $folders[$folder] = ucfirst($folder);
                             }
                         }
                         closedir($dir);
Example #29
0
 $form_container->end();
 $approve_unapprove = array('' => $lang->no_change, 'approve' => $lang->approve, 'unapprove' => $lang->unapprove, 'toggle' => $lang->toggle);
 $form_container = new FormContainer($lang->inline_post_moderation);
 $form_container->output_row($lang->delete_posts . " <em>*</em>", '', $form->generate_yes_no_radio('deleteposts', $mybb->input['deleteposts']));
 $form_container->output_row($lang->merge_posts . " <em>*</em>", $lang->merge_posts_desc, $form->generate_yes_no_radio('mergeposts', $mybb->input['mergeposts']));
 $form_container->output_row($lang->approve_unapprove_posts . " <em>*</em>", '', $form->generate_select_box('approveposts', $approve_unapprove, $mybb->input['approveposts'], array('id' => 'approveposts')), 'approveposts');
 $form_container->end();
 $selectoptions = "<option value=\"-1\"{$do_not_split_checked}>{$lang->do_not_split}</option>\n";
 $selectoptions .= "<option value=\"-2\"{$split_same_checked} style=\"border-bottom: 1px solid #000;\">{$lang->split_to_same_forum}</option>\n";
 $form_container = new FormContainer($lang->split_posts);
 $form_container->output_row($lang->split_posts2 . " <em>*</em>", '', $form->generate_forum_select('splitposts', $mybb->input['splitposts']));
 $form_container->output_row($lang->close_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsclose', $mybb->input['splitpostsclose']));
 $form_container->output_row($lang->stick_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsstick', $mybb->input['splitpostsstick']));
 $form_container->output_row($lang->unapprove_split_thread . " <em>*</em>", '', $form->generate_yes_no_radio('splitpostsunapprove', $mybb->input['splitpostsunapprove']));
 $form_container->output_row($lang->split_thread_subject, $lang->split_thread_subject_desc, $form->generate_text_box('splitpostsnewsubject', $mybb->input['splitpostsnewsubject'], array('id' => 'splitpostsnewsubject ')), 'newreplysubject');
 $form_container->output_row($lang->add_new_split_reply, $lang->add_new_split_reply_desc, $form->generate_text_area('splitpostsaddreply', $mybb->input['splitpostsaddreply'], array('id' => 'splitpostsaddreply')), 'splitpostsaddreply');
 $form_container->output_row($lang->split_reply_subject, $lang->split_reply_subject_desc, $form->generate_text_box('splitpostsreplysubject', $mybb->input['splitpostsreplysubject'], array('id' => 'splitpostsreplysubject')), 'splitpostsreplysubject');
 $form_container->end();
 $open_close = array('' => $lang->no_change, 'open' => $lang->open, 'close' => $lang->close, 'toggle' => $lang->toggle);
 $form_container = new FormContainer($lang->thread_moderation);
 $form_container->output_row($lang->approve_unapprove . " <em>*</em>", '', $form->generate_select_box('approvethread', $approve_unapprove, $mybb->input['approvethread'], array('id' => 'approvethread')), 'approvethread');
 $form_container->output_row($lang->open_close_thread . " <em>*</em>", '', $form->generate_select_box('openthread', $open_close, $mybb->input['openthread'], array('id' => 'openthread')), 'openthread');
 $actions = "\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"1\" {$move_checked[1]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_move_thread}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"2\" {$move_checked[2]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->move_thread}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"move_2\" class=\"moves\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td><small>{$lang->forum_to_move_to}</small></td>\n\t\t\t\t\t<td>" . $form->generate_forum_select('move_1_forum', $mybb->input['move_1_forum']) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><small>{$lang->leave_redirect}</small></td>\n\t\t\t\t\t<td>" . $form->generate_yes_no_radio('move_2_redirect', $mybb->input['move_2_redirect']) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><small>{$lang->delete_redirect_after}</small></td>\n\t\t\t\t\t<td>" . $form->generate_text_box('move_3_redirecttime', $mybb->input['move_3_redirecttime'], array('style' => 'width: 2em;')) . " {$lang->days}</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('move');\n\t</script>";
 $form_container->output_row($lang->move_thread . " <em>*</em>", $lang->move_thread_desc, $actions);
 $actions = "\n\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">\n\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"1\" {$copy_checked[1]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_copy_thread}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"2\" {$copy_checked[2]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->copy_thread}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"copy_2\" class=\"copys\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td><small>{$lang->forum_to_copy_to}</small></td>\n\t\t\t\t\t<td>" . $form->generate_forum_select('copy_1_forum', $mybb->input['copy_1_forum']) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</dd>\n\t</dl>\n\t<script type=\"text/javascript\">\n\tcheckAction('copy');\n\t</script>";
 $form_container->output_row($lang->copy_thread . " <em>*</em>", '', $actions);
 $form_container->output_row($lang->delete_thread . " <em>*</em>", '', $form->generate_yes_no_radio('deletethread', $mybb->input['deletethread']));
 $query = $db->simple_select('threadprefixes', 'pid, prefix');
 if ($db->num_rows($query) > 0) {
     $thread_prefixes = array('-1' => $lang->no_change, '0' => $lang->no_prefix);
     while ($prefix = $db->fetch_array($query)) {
Example #30
0
        $form = new Form($ougc_pages->build_url($add ? 'action=add' : array('action' => 'edit', 'pid' => $pages['pid'])), 'post');
        $form_container = new FormContainer($sub_tabs['ougc_pages_' . ($add ? 'add' : 'edit')]['description']);
        $form_container->output_row($lang->ougc_pages_form_category, $lang->ougc_pages_form_category_desc, $ougc_pages->generate_category_select('category', $mybb->get_input('cid', 1)));
        $form_container->output_row($lang->ougc_pages_form_name . ' <em>*</em>', $lang->ougc_pages_form_name_desc, $form->generate_text_box('name', $mybb->get_input('name')));
        $form_container->output_row($lang->ougc_pages_form_description . ' <em>*</em>', $lang->ougc_pages_form_description_desc, $form->generate_text_box('description', $mybb->get_input('description')));
        $form_container->output_row($lang->ougc_pages_form_url . ' <em>*</em>', $lang->ougc_pages_form_url_desc, $form->generate_text_box('url', $mybb->get_input('url')));
        ougc_print_selection_javascript();
        $groups_select = "\n\t\t<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">\n\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups_type\" value=\"all\" {$group_checked['all']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>\n\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups_type\" value=\"custom\" {$group_checked['custom']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>\n\t\t\t<dd style=\"margin-top: 4px;\" id=\"groups_forums_groups_custom\" class=\"groups_forums_groups\">\n\t\t\t\t<table cellpadding=\"4\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign=\"top\"><small>{$lang->groups_colon}</small></td>\n\t\t\t\t\t\t<td>" . $form->generate_group_select('groups[]', $mybb->get_input('groups', 2), array('multiple' => true, 'size' => 5)) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</dd>\n\t\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups_type\" value=\"none\" {$group_checked['none']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>\n\t\t</dl>\n\t\t<script type=\"text/javascript\">\n\t\t\tcheckAction('groups');\n\t\t</script>";
        $form_container->output_row($lang->ougc_pages_form_groups, $lang->ougc_pages_form_groups_desc, $groups_select, '', array(), array('id' => 'row_groups'));
        $form_container->output_row($lang->ougc_pages_form_php, $lang->ougc_pages_form_php_desc, $form->generate_yes_no_radio('php', $mybb->get_input('php', 1)));
        $form_container->output_row($lang->ougc_pages_form_wol, $lang->ougc_pages_form_wol_desc, $form->generate_yes_no_radio('wol', $mybb->get_input('wol', 1)));
        $form_container->output_row($lang->ougc_pages_form_visible, $lang->ougc_pages_form_visible_desc, $form->generate_yes_no_radio('visible', $mybb->get_input('visible', 1)));
        $form_container->output_row($lang->ougc_pages_form_wrapper, $lang->ougc_pages_form_wrapper_desc, $form->generate_yes_no_radio('wrapper', $mybb->get_input('wrapper', 1)));
        $form_container->output_row($lang->ougc_pages_form_init, $lang->ougc_pages_form_init_desc, $form->generate_yes_no_radio('init', $mybb->get_input('init', 1)));
        $form_container->output_row($lang->ougc_pages_form_disporder, $lang->ougc_pages_form_disporder_desc, $form->generate_text_box('disporder', $mybb->get_input('disporder', 1), array('style' => 'text-align: center; width: 30px;" maxlength="5')));
        $form_container->output_row($lang->ougc_pages_form_template, $lang->ougc_pages_form_template_desc, $form->generate_text_area('template', $mybb->get_input('template'), array('rows' => 5, 'id' => 'template', 'class' => '', 'style' => 'width: 100%; height: 500px;')));
        $form_container->end();
        $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_pages_button_submit), $form->generate_reset_button($lang->reset)));
        $form->end();
        if (!empty($admin_options['codepress'])) {
            echo '<script type="text/javascript">
				var editor = CodeMirror.fromTextArea(document.getElementById("template"), {
					lineNumbers: true,
					lineWrapping: true,
					tabMode: "indent",
					theme: "mybb",
					mode: "application/x-httpd-php",
					matchBrackets: true,
				});
			</script>';
        }