function main_page($current_cache_level, $modified_on)
{
    $form = new Form('index.php?module=cloudflare-cache_lvl&action=change', 'post');
    $form_container = new FormContainer('Modify Cache Level');
    $form_container->output_row('Cache Level', "Cache Level functions based off the setting level. The basic setting will cache most static resources (i.e., css, images, and JavaScript). The simplified setting will ignore the query string when delivering a cached resource. The aggressive setting will cache all static resources, including ones with a query string. ", $form->generate_select_box('cache_level', array('basic' => 'Basic', 'simplified' => 'Simplified', 'aggressive' => 'Aggressive'), $current_cache_level));
    $form_container->end();
    $buttons[] = $form->generate_submit_button('Submit');
    $form->output_submit_wrapper($buttons);
    $form->end();
}
function main_page($current_setting)
{
    global $security_levels;
    $form = new Form('index.php?module=cloudflare-security_lvl&action=change_security_level', 'post');
    $form_container = new FormContainer('Modify Security Level');
    $form_container->output_row('Security Level', 'The Security Level you choose will determine which visitors will be presented with a challenge page<br />
		<ul>
			<li><b>Essentially Off:</b> Challenges only the most grievous offenders</li>
			<li><b>Low:</b> Challenges only the most threatening visitors</li>
			<li><b>Medium:</b> Challenges both moderate threat visitors and the most threatening visitors</li>
			<li><b>High:</b> Challenges all visitors that have exhibited threatening behavior within the last 14 days</li>
			<li><b>I\'m Under Attack!:</b> Should only be used if your website is under a DDoS attack</li>
				<ul><li>Visitors will receive an interstitial page while we analyze their traffic and behavior to make sure they are a legitimate human visitor trying to access your website</li></ul>
			</li>
		</ul>', $form->generate_select_box('sec_level', $security_levels, $current_setting));
    $form_container->end();
    $buttons[] = $form->generate_submit_button('Submit');
    $form->output_submit_wrapper($buttons);
    $form->end();
}
예제 #3
0
파일: themes.php 프로젝트: GeorgeLVP/mybb
	<dt><label style="display: block;"><input type="radio" name="attach" value="0" ' . $global_checked[1] . ' class="attachs_check" onclick="checkAction(\'attach\');" style="vertical-align: middle;" /> ' . $lang->globally . '</label></dt>
		<dt><label style="display: block;"><input type="radio" name="attach" value="1" ' . $global_checked[2] . ' class="attachs_check" onclick="checkAction(\'attach\');" style="vertical-align: middle;" /> ' . $lang->specific_files . ' (<a id="new_specific_file">' . $lang->add_another . '</a>)</label></dt><br />
		' . $specific_files . '
	</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']));
    $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' => 'codepress css', '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\">\n\tEvent.observe('add_stylesheet', 'submit', function()\n\t{\n\t\tif(\$('stylesheet_cp')) {\n\t\t\tvar area = \$('stylesheet_cp');\n\t\t\tarea.id = 'stylesheet';\n\t\t\tarea.value = stylesheet.getCode();\n\t\t\tarea.disabled = false;\n\t\t}\n\t});\n</script>\n";
    }
    echo '<script type="text/javascript" src="./jscripts/themes.js"></script>';
    echo '<script type="text/javascript">
Event.observe(window, "load", function() {
//<![CDATA[
    new ThemeSelector(\'' . $count . '\');
	checkAction(\'add\');
});
//]]>
    $query = $db->query("\n\t\tSELECT DISTINCT l.uid, u.username\n\t\tFROM " . TABLE_PREFIX . "adminlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (l.uid=u.uid)\n\t\tORDER BY u.username ASC\n\t");
    while ($user = $db->fetch_array($query)) {
        $user_options[$user['uid']] = $user['username'];
    }
    $module_options = array();
    $module_options[''] = $lang->all_modules;
    $module_options['0'] = '----------';
    $query = $db->query("\n\t\tSELECT DISTINCT l.module\n\t\tFROM " . TABLE_PREFIX . "adminlog l\n\t\tORDER BY l.module ASC\n\t");
    while ($module = $db->fetch_array($query)) {
        $module_options[$module['module']] = str_replace(' ', ' -&gt; ', ucwords(str_replace('/', ' ', $module['module'])));
    }
    $sort_by = array('dateline' => $lang->date, 'username' => $lang->username);
    $order_array = array('asc' => $lang->asc, 'desc' => $lang->desc);
    $form = new Form("index.php?module=tools-adminlog", "post");
    $form_container = new FormContainer($lang->filter_administrator_logs);
    $form_container->output_row($lang->module, "", $form->generate_select_box('filter_module', $module_options, $mybb->input['filter_module'], array('id' => 'filter_module')), 'filter_module');
    $form_container->output_row($lang->administrator, "", $form->generate_select_box('uid', $user_options, $mybb->input['uid'], array('id' => 'uid')), 'uid');
    $form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('order', $order_array, $order, array('id' => 'order')) . " {$lang->order}", 'order');
    $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $perpage, array('id' => 'perpage')), 'perpage');
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->filter_administrator_logs);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
/**
 * Returns language-friendly string describing $logitem
 * @param array The log item (one row from mybb_adminlogs)
 * @return string The description
 */
function get_admin_log_action($logitem)
            flash_message($lang->invalid_post_verify_key2, 'error');
            admin_redirect("index.php?module=cloudflare-manage_firewall");
        }
        $request = $cloudflare->update_access_rule($mybb->get_input('mode'), $mybb->get_input('ip_address'), $mybb->get_input('notes'));
        if (!empty($request['success'])) {
            flash_message("Updated the firewall rule with IP {$mybb->get_input('ip_address')}", "success");
            admin_redirect("index.php?module=cloudflare-manage_firewall");
        } else {
            flash_message($request['errors'], "error");
            admin_redirect("index.php?module=cloudflare-manage_firewall");
        }
    }
    $form = new Form('index.php?module=cloudflare-manage_firewall&amp;action=modify_rule_by_ip', 'post');
    $form_container = new FormContainer("Modify Firewall Rule");
    $form_container->output_row("IP Address", "The IP address you would like to whitelist", $form->generate_text_box('ip_address', $mybb->get_input('ip')));
    $form_container->output_row('Mode', '', $form->generate_select_box("mode", array("whitelist" => "Whitelist", "block" => "Blacklist", "challenge" => "Challenge"), $mybb->get_input('current_mode')));
    $form_container->output_row("Notes", "Any notes you would like to add", $form->generate_text_box('notes', $mybb->get_input('current_notes')));
    echo $form->generate_hidden_field('update_rule', 'update');
    $form_container->end();
    $buttons[] = $form->generate_submit_button("Submit");
    $form->output_submit_wrapper($buttons);
    $form->end();
} elseif ($mybb->input['action'] == 'delete_rule_by_id') {
    if (!verify_post_check($mybb->input['my_post_key'])) {
        flash_message($lang->invalid_post_verify_key2, 'error');
        admin_redirect("index.php?module=cloudflare-manage_firewall");
    }
    $request = $cloudflare->delete_firewall_rule($mybb->get_input('rule_id'));
    if (!empty($request->success)) {
        flash_message("Deleted the firewall rule with IP {$mybb->get_input('ip_address')}", "success");
        admin_redirect("index.php?module=cloudflare-manage_firewall");
예제 #6
0
        $sub_tabs['diff_report'] = array('title' => $lang->diff_report, 'link' => "index.php?module=style/templates&amp;action=diff_report&amp;title=" . $db->escape_string($template['title']) . "&amp;sid1=" . intval($template['sid']) . "&amp;sid2=-2");
    }
    $sub_tabs['edit_template'] = array('title' => $lang->edit_template, 'link' => "index.php?module=style/templates&amp;action=edit_template&amp;title=" . htmlspecialchars_uni($template['title']) . $expand_str, 'description' => $lang->edit_template_desc);
    $page->output_nav_tabs($sub_tabs, 'edit_template');
    $form = new Form("index.php?module=style/templates&amp;action=edit_template{$expand_str}", "post", "edit_template");
    echo $form->generate_hidden_field('tid', $template['tid']) . "\n";
    if ($mybb->input['from'] == "diff_report") {
        echo $form->generate_hidden_field('from', "diff_report");
    }
    $form_container = new FormContainer($lang->edit_template_breadcrumb . $template['title']);
    $form_container->output_row($lang->template_name, $lang->template_name_desc, $form->generate_text_box('title', $template['title'], array('id' => 'title')), 'title');
    // Force users to save the default template to a specific set, rather than the "global" templates - where they can delete it
    if ($template['sid'] == "-2") {
        unset($template_sets[-1]);
    }
    $form_container->output_row($lang->template_set, $lang->template_set_desc, $form->generate_select_box('sid', $template_sets, $sid));
    $form_container->output_row("", "", $form->generate_text_area('template', $template['template'], array('id' => 'template', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 500px;')));
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_continue, array('name' => 'continue'));
    $buttons[] = $form->generate_submit_button($lang->save_close, array('name' => 'close'));
    $form->output_submit_wrapper($buttons);
    $form->end();
    if ($admin_options['codepress'] != 0) {
        echo "<script type=\"text/javascript\">\n\tEvent.observe('edit_template', 'submit', function()\n\t{\n\t\tif(\$('template_cp')) {\n\t\t\tvar area = \$('template_cp');\n\t\t\tarea.id = 'template';\n\t\t\tarea.value = template.getCode();\n\t\t\tarea.disabled = false;\n\t\t}\n\t});\n</script>";
    }
    $page->output_footer();
}
if ($mybb->input['action'] == "search_replace") {
    $plugins->run_hooks("admin_style_templates_search_replace");
    if ($mybb->request_method == "post") {
        if ($mybb->input['type'] == "templates") {
예제 #7
0
    if ($errors) {
        $page->output_inline_error($errors);
    } else {
        $mybb->input = array_merge($mybb->input, array("namestyle" => "{username}"));
    }
    $form_container = new FormContainer($lang->add_user_group);
    $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->username_style, $lang->username_style_desc, $form->generate_text_box('namestyle', $mybb->input['namestyle'], array('id' => 'namestyle')), 'namestyle');
    $form_container->output_row($lang->user_title, $lang->user_title_desc, $form->generate_text_box('usertitle', $mybb->input['usertitle'], array('id' => 'usertitle')), 'usertitle');
    $options[0] = $lang->do_not_copy_permissions;
    $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
    while ($usergroup = $db->fetch_array($query)) {
        $options[$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
    }
    $form_container->output_row($lang->copy_permissions_from, $lang->copy_permissions_from_desc, $form->generate_select_box('copyfrom', $options, $mybb->input['copyfrom'], array('id' => 'copyfrom')), 'copyfrom');
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_user_group);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
if ($mybb->input['action'] == "edit") {
    $query = $db->simple_select("usergroups", "*", "gid='" . $mybb->get_input('gid', MyBB::INPUT_INT) . "'");
    $usergroup = $db->fetch_array($query);
    if (!$usergroup['gid']) {
        flash_message($lang->error_invalid_user_group, 'error');
        admin_redirect("index.php?module=user-group");
    } else {
        if (preg_match("#<((m[^a])|(b[^diloru>])|(s[^aemptu>]))(\\s*[^>]*)>#si", $mybb->input['namestyle'])) {
            $errors[] = $lang->error_disallowed_namestyle_username;
            $mybb->input['name'] = $doc['name'];
            $mybb->input['description'] = $doc['description'];
            $mybb->input['document'] = $doc['document'];
            $mybb->input['disporder'] = $doc['disporder'];
            $mybb->input['enabled'] = $doc['enabled'];
            $mybb->input['usetranslation'] = $doc['usetranslation'];
        }
        $form = new Form("index.php?module=config-help_documents&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");
예제 #9
0
    }
    $page->output_header($lang->find_attachments);
    $page->output_nav_tabs($sub_tabs, 'find_attachments');
    // If we have any error messages, show them
    if ($errors) {
        $page->output_inline_error($errors);
    }
    $form = new Form("index.php?module=forum-attachments", "post");
    $form_container = new FormContainer($lang->find_where);
    $form_container->output_row($lang->name_contains, $lang->name_contains_desc, $form->generate_text_box('filename', $mybb->input['filename'], array('id' => 'filename')), 'filename');
    $form_container->output_row($lang->type_contains, "", $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype');
    $form_container->output_row($lang->forum_is, "", $form->generate_forum_select('forum[]', $mybb->input['forum'], array('multiple' => true, 'size' => 5, 'id' => 'forum')), 'forum');
    $form_container->output_row($lang->username_is, "", $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
    $more_options = array("less_than" => $lang->more_than, "greater_than" => $lang->less_than);
    $greater_options = array("greater_than" => $lang->greater_than, "is_exactly" => $lang->is_exactly, "less_than" => $lang->less_than);
    $form_container->output_row($lang->date_posted_is, "", $form->generate_select_box('dateuploaded_dir', $more_options, $mybb->input['dateuploaded_dir'], array('id' => 'dateuploaded_dir')) . " " . $form->generate_text_box('dateuploaded', $mybb->input['dateuploaded'], array('id' => 'dateuploaded')) . " {$lang->days_ago}", 'dateuploaded');
    $form_container->output_row($lang->file_size_is, "", $form->generate_select_box('filesize_dir', $greater_options, $mybb->input['filesize_dir'], array('id' => 'filesize_dir')) . " " . $form->generate_text_box('filesize', $mybb->input['filesize'], array('id' => 'filesize')) . " {$lang->kb}", 'dateuploaded');
    $form_container->output_row($lang->download_count_is, "", $form->generate_select_box('downloads_dir', $greater_options, $mybb->input['downloads_dir'], array('id' => 'downloads_dir')) . " " . $form->generate_text_box('downloads', $mybb->input['downloads'], array('id' => 'downloads')) . "", 'dateuploaded');
    $form_container->end();
    $form_container = new FormContainer($lang->display_options);
    $sort_options = array("filename" => $lang->filename, "filesize" => $lang->filesize, "downloads" => $lang->download_count, "dateuploaded" => $lang->date_uploaded, "username" => $lang->post_username);
    $sort_directions = array("asc" => $lang->asc, "desc" => $lang->desc);
    $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('order', $sort_directions, $mybb->input['order'], array('id' => 'order')), 'sortby');
    $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $mybb->input['perpage'], array('id' => 'perpage')), 'perpage');
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->button_find_attachments);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
function build_attachment_row($attachment, &$table, $use_form = false)
                if ($ip_record['city']) {
                    $ipaddress_location .= htmlspecialchars_uni($ip_record['city']) . $lang->comma . ' ';
                }
                $ipaddress_location .= htmlspecialchars_uni($ip_record['country_name']);
                $table->construct_cell('<a href="https://maps.google.com/maps?q=' . urlencode($ipaddress_location) . '" target="_blank">' . $ipaddress_location . '</a>', array('width' => '25%'));
            } else {
                $table->construct_cell('N/A', array('width' => '25%'));
            }
        }
        if ($mybb->settings['cloudflare_showdns'] == "1") {
            $table->construct_cell(gethostbyaddr($data['ip']), array('width' => '25%'));
        }
        $popup = new PopupMenu("rv_options_" . $number, "Options");
        $popup->add_item("Black List", "index.php?module=cloudflare-blacklist&amp;action=run&amp;my_post_key={$mybb->post_code}&amp;address=" . $data['ip'] . "&amp;submit=Black List");
        $popup->add_item("White List", "index.php?module=cloudflare-whitelist&amp;action=run&my_post_key={$mybb->post_code}&amp;address=" . $data['ip'] . "&amp;submit=White List");
        $controls = $popup->fetch();
        $table->construct_cell($controls, array('width' => '5%'));
        $table->construct_row();
    }
    $table->output("Recent Visitors Data - 48 Hours");
    echo multipage($quantity, (int) $perpage, (int) $page, $profile_page);
    $types = array("all" => "Show All", "" => "----------", "regular" => "Regular", "bot" => "Spider/Bot", "threat" => "Threat");
    $form = new Form("index.php?module=cloudflare-recent_visitors_48", "post");
    $form_container = new FormContainer("Filter Visitors");
    $form_container->output_row("Type:", "", $form->generate_select_box('onlyshow', $types, $mybb->input['onlyshow'], array('id' => 'onlyshow')), 'onlyshow');
    $form_container->end();
    $buttons[] = $form->generate_submit_button("Filter Visitors");
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
예제 #11
0
 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);
             ksort($folders);
             $setting_code = $form->generate_select_box($element_name, $folders, $setting['value'], array('id' => $element_id));
         } else {
             if ($type[0] == "language") {
                 $languages = $lang->get_languages();
                 $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
             } else {
                 if ($type[0] == "adminlanguage") {
                     $languages = $lang->get_languages(1);
                     $setting_code = $form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id));
                 } else {
                     if ($type[0] == "passwordbox") {
                         $setting_code = $form->generate_password_box($element_name, $setting['value'], array('id' => $element_id));
                     } else {
                         if ($type[0] == "php") {
                             $setting['type'] = substr($setting['type'], 3);
                             eval("\$setting_code = \"" . $setting['type'] . "\";");
예제 #12
0
    $page->output_nav_tabs($sub_tabs, 'edit_profile_field');
    $form = new Form("index.php?module=config-profile_fields&amp;action=edit", "post", "edit");
    echo $form->generate_hidden_field("fid", $profile_field['fid']);
    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() {
예제 #13
0
파일: bam.php 프로젝트: Darth-Apple/BAM
    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));
    $buttons[] = $form->generate_submit_button($lang->bam_form_add_submit);
예제 #14
0
        echo $form->generate_hidden_field("add", "moderators");
        // Usergroup Moderator
        if (!is_array($usergroups)) {
            $usergroups = $groupscache;
        }
        foreach ($usergroups as $group) {
            $modgroups[$group['gid']] = $lang->usergroup . " " . $group['gid'] . ": " . htmlspecialchars_uni($group['title']);
        }
        if (!isset($mybb->input['usergroup'])) {
            $mybb->input['usergroup'] = '';
        }
        if (!isset($mybb->input['username'])) {
            $mybb->input['username'] = '';
        }
        $form_container = new FormContainer($lang->add_usergroup_as_moderator);
        $form_container->output_row($lang->usergroup . " <em>*</em>", $lang->moderator_usergroup_desc, $form->generate_select_box('usergroup', $modgroups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
        $form_container->end();
        $buttons[] = $form->generate_submit_button($lang->add_usergroup_moderator);
        $form->output_submit_wrapper($buttons);
        $form->end();
        echo "<br />";
        $form = new Form("index.php?module=forum-management", "post", "management");
        echo $form->generate_hidden_field("fid", $mybb->input['fid']);
        echo $form->generate_hidden_field("add", "moderators");
        $form_container = new FormContainer($lang->add_user_as_moderator);
        $form_container->output_row($lang->username . " <em>*</em>", $lang->moderator_username_desc, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
        $form_container->end();
        // Autocompletion for usernames
        echo '
		<link rel="stylesheet" href="../jscripts/select2/select2.css">
		<script type="text/javascript" src="../jscripts/select2/select2.min.js?ver=1804"></script>
예제 #15
0
 }
 $form_container = new FormContainer("{$lang->send_mass_mail}: {$lang->step_one} - {$lang->message_settings}");
 $form_container->output_row("{$lang->subject}: <em>*</em>", $lang->subject_desc, $form->generate_text_box('subject', $input['subject'], array('id' => 'subject')), 'subject');
 if ($mybb->input['type'] == 0) {
     $type_email_checked = true;
     $type_pm_checked = false;
 } else {
     if ($mybb->input['type'] == 1) {
         $type_email_checked = false;
         $type_pm_checked = true;
     }
 }
 $type_options = array($form->generate_radio_button("type", 0, $lang->send_via_email, array("id" => "type_email", "checked" => $type_email_checked)), $form->generate_radio_button("type", 1, $lang->send_via_pm, array("id" => "type_pm", "checked" => $type_pm_checked)));
 $form_container->output_row("{$lang->message_type}:", "", implode("<br />", $type_options));
 $format_options = array(0 => $lang->plain_text_only, 1 => $lang->html_only, 2 => $lang->html_and_plain_text);
 $form_container->output_row("{$lang->message_format}:", "", $form->generate_select_box('format', $format_options, $input['format'], array('id' => 'format')), 'format', null, array("id" => "format_container"));
 $form_container->output_row("{$lang->per_page}: <em>*</em>", $lang->per_page_desc, $form->generate_text_box('perpage', $input['perpage'], array('id' => 'perpage')), 'perpage');
 $form_container->end();
 if ($mybb->input['format'] == 2) {
     if ($mybb->input['automatic_text'] && !$email['mid']) {
         $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';
         }
예제 #16
0
        $task_data['weekday'] = explode(',', $task['weekday']);
        $task_data['month'] = explode(',', $task['month']);
    }
    $form_container = new FormContainer($lang->edit_task);
    echo $form->generate_hidden_field("tid", $task['tid']);
    $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $task_data['title'], array('id' => 'title')), 'title');
    $form_container->output_row($lang->short_description, "", $form->generate_text_box('description', $task_data['description'], array('id' => 'description')), 'description');
    $task_list = array();
    $task_files = scandir(MYBB_ROOT . "inc/tasks/");
    foreach ($task_files as $task_file) {
        if (is_file(MYBB_ROOT . "inc/tasks/{$task_file}") && get_extension($task_file) == "php") {
            $file_id = preg_replace("#\\." . get_extension($task_file) . "\$#i", "\$1", $task_file);
            $task_list[$file_id] = $task_file;
        }
    }
    $form_container->output_row($lang->task . " <em>*</em>", $lang->task_desc, $form->generate_select_box("file", $task_list, $task_data['file'], array('id' => 'file')), 'file');
    $form_container->output_row($lang->time_minutes, $lang->time_minutes_desc, $form->generate_text_box('minute', $task_data['minute'], array('id' => 'minute')), 'minute');
    $form_container->output_row($lang->time_hours, $lang->time_hours_desc, $form->generate_text_box('hour', $task_data['hour'], array('id' => 'hour')), 'hour');
    $form_container->output_row($lang->time_days_of_month, $lang->time_days_of_month_desc, $form->generate_text_box('day', $task_data['day'], array('id' => 'day')), 'day');
    $options = array("*" => $lang->every_weekday, "0" => $lang->sunday, "1" => $lang->monday, "2" => $lang->tuesday, "3" => $lang->wednesday, "4" => $lang->thursday, "5" => $lang->friday, "6" => $lang->saturday);
    $form_container->output_row($lang->time_weekdays, $lang->time_weekdays_desc, $form->generate_select_box('weekday[]', $options, $task_data['weekday'], array('id' => 'weekday', 'multiple' => true)), 'weekday');
    $options = array("*" => $lang->every_month, "1" => $lang->january, "2" => $lang->february, "3" => $lang->march, "4" => $lang->april, "5" => $lang->may, "6" => $lang->june, "7" => $lang->july, "8" => $lang->august, "9" => $lang->september, "10" => $lang->october, "11" => $lang->november, "12" => $lang->december);
    $form_container->output_row($lang->time_months, $lang->time_months_desc, $form->generate_select_box('month[]', $options, $task_data['month'], array('id' => 'month', 'multiple' => true)), 'month');
    $form_container->output_row($lang->enable_logging . " <em>*</em>", "", $form->generate_yes_no_radio("logging", $task_data['logging'], true));
    $form_container->output_row($lang->enabled . " <em>*</em>", "", $form->generate_yes_no_radio("enabled", $task_data['enabled'], true));
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_task);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
예제 #17
0
 // 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');
 // end the container
 $form_container->end();
 // add the save button
 $buttons[] = $form->generate_submit_button($lang->downloads_dlmngr_save);
 // display and end
 $form->output_submit_wrapper($buttons);
예제 #18
0
                }
                if (!empty($stylesheet['colors'])) {
                    $global_checked[3] = "checked=\"checked\"";
                    $global_checked[2] = "";
                    $global_checked[1] = "";
                }
            }
        }
    }
    $specific_files .= "</div>";
    // Colors
    $specific_colors = $specific_colors_option = '';
    if (is_array($properties['colors'])) {
        $specific_colors = "<br /><div id=\"attach_2\" class=\"attachs\">";
        $specific_colors_option = '<dt><label style="display: block;"><input type="radio" name="attach" value="2" ' . $global_checked[3] . ' class="attachs_check" onclick="checkAction(\'attach\');" style="vertical-align: middle;" /> ' . $lang->colors_specific_color . '</label></dt>';
        $specific_color = "\n\t\t\t<small>{$lang->colors_add_edit_desc}</small>\n\t\t\t<br /><br />\n\t\t\t" . $form->generate_select_box('color[]', $properties['colors'], $stylesheet['colors'], array('multiple' => true, 'size' => "5\" style=\"width: 200px;")) . "\n\t\t";
        $form_container = new FormContainer();
        $form_container->output_row("", "", $specific_color);
        $specific_colors .= $form_container->end(true) . "</div>";
    }
    $actions = '<script type="text/javascript">
	function checkAction(id)
	{
		var checked = \'\';

		$(\'.\'+id+\'s_check\').each(function(e, val)
		{
			if($(this).prop(\'checked\') == true)
			{
				checked = $(this).val();
			}
예제 #19
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;
    }
}
예제 #20
0
            $awards->{$method}(array('name' => $mybb->input['name'], 'description' => $mybb->input['description'], 'image' => $mybb->input['image'], 'visible' => $mybb->input['visible'], 'pm' => $mybb->input['pm'], 'type' => $mybb->input['type'], 'disporder' => $mybb->input['disporder']), (int) $mybb->input['aid']);
            $awards->update_cache();
            $awards->log_action();
            $awards->admin_redirect($lang->{$lang_val});
        } else {
            $page->output_inline_error($errors);
        }
    }
    $form = new Form($awards->build_url($add ? 'action=add' : array('action' => 'edit', 'aid' => $award['aid'])), 'post');
    $form_container = new FormContainer($sub_tabs['ougc_awards_' . ($add ? 'add' : 'edit')]['description']);
    $form_container->output_row($lang->ougc_awards_form_name . ' <em>*</em>', $lang->ougc_awards_form_name_d, $form->generate_text_box('name', $mybb->input['name']));
    $form_container->output_row($lang->ougc_awards_form_desc, $lang->ougc_awards_form_desc_d, $form->generate_text_box('description', $mybb->input['description']));
    $form_container->output_row($lang->ougc_awards_form_image, $lang->ougc_awards_form_image_d, $form->generate_text_box('image', $mybb->input['image']));
    $form_container->output_row($lang->ougc_awards_form_visible, $lang->ougc_awards_form_visible_d, $form->generate_yes_no_radio('visible', (int) $mybb->input['visible']));
    $form_container->output_row($lang->ougc_awards_form_pm, $lang->ougc_awards_form_pm_d, $form->generate_text_area('pm', $mybb->input['pm'], array('rows' => 8, 'style' => 'width:80%;')));
    $form_container->output_row($lang->ougc_awards_form_type, $lang->ougc_awards_form_type_d, $form->generate_select_box('type', array(0 => $lang->ougc_awards_form_type_0, 1 => $lang->ougc_awards_form_type_1, 2 => $lang->ougc_awards_form_type_2), (int) $mybb->input['type']));
    $form_container->output_row($lang->ougc_awards_form_order, $lang->ougc_awards_form_order_d, $form->generate_text_box('disporder', (int) $mybb->input['disporder'], array('style' => 'text-align: center; width: 30px;" maxlength="5')));
    $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();
} elseif ($mybb->get_input('action') == 'delete') {
    if (!($award = $awards->get_award($mybb->input['aid']))) {
        $awards->admin_redirect($lang->ougc_awards_error_invalidaward, true);
    }
    if ($mybb->request_method == 'post') {
        if (!verify_post_check($mybb->input['my_post_key'], true)) {
            $awards->admin_redirect($lang->invalid_post_verify_key2, true);
        }
        !isset($mybb->input['no']) or $awards->admin_redirect();
        $awards->delete_award($award['aid']);
/**
 * Builds the "view management" interface allowing administrators to edit their custom designed "views"
 *
 * @param string The base URL to this instance of the view manager
 * @param string The internal type identifier for this view
 * @param array Array of fields this view supports
 * @param array Array of possible sort options this view supports if any
 * @param string Optional callback function which generates list of "conditions" for this view
 */
function view_manager($base_url, $type, $fields, $sort_options = array(), $conditions_callback = "")
{
    global $mybb, $db, $page, $lang;
    $sub_tabs['views'] = array('title' => $lang->views, 'link' => "{$base_url}&amp;action=views", 'description' => $lang->views_desc);
    $sub_tabs['create_view'] = array('title' => $lang->create_new_view, 'link' => "{$base_url}&amp;action=views&amp;do=add", 'description' => $lang->create_new_view_desc);
    $page->add_breadcrumb_item($lang->view_manager, 'index.php?module=user-users&amp;action=views');
    // Lang strings should be in global lang file
    if ($mybb->input['do'] == "set_default") {
        $query = $db->simple_select("adminviews", "vid, uid, visibility", "vid='" . $mybb->get_input('vid', MyBB::INPUT_INT) . "'");
        $admin_view = $db->fetch_array($query);
        if (!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) {
            flash_message($lang->error_invalid_admin_view, 'error');
            admin_redirect($base_url . "&action=views");
        }
        set_default_view($type, $admin_view['vid']);
        flash_message($lang->succuss_view_set_as_default, 'success');
        admin_redirect($base_url . "&action=views");
    }
    if ($mybb->input['do'] == "add") {
        if ($mybb->request_method == "post") {
            if (!trim($mybb->input['title'])) {
                $errors[] = $lang->error_missing_view_title;
            }
            if ($mybb->input['fields_js']) {
                $mybb->input['fields'] = explode(",", $mybb->input['fields_js']);
            }
            if (count($mybb->input['fields']) <= 0) {
                $errors[] = $lang->error_no_view_fields;
            }
            if ($mybb->get_input('perpage', MyBB::INPUT_INT) <= 0) {
                $errors[] = $lang->error_invalid_view_perpage;
            }
            if (!in_array($mybb->input['sortby'], array_keys($sort_options))) {
                $errors[] = $lang->error_invalid_view_sortby;
            }
            if ($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") {
                $errors[] = $lang->error_invalid_view_sortorder;
            }
            if ($mybb->input['visibility'] == 0) {
                $mybb->input['visibility'] = 2;
            }
            if (!$errors) {
                $new_view = array("uid" => $mybb->user['uid'], "title" => $db->escape_string($mybb->input['title']), "type" => $type, "visibility" => $mybb->get_input('visibility', MyBB::INPUT_INT), "fields" => $db->escape_string(my_serialize($mybb->input['fields'])), "conditions" => $db->escape_string(my_serialize($mybb->input['conditions'])), "custom_profile_fields" => $db->escape_string(my_serialize($mybb->input['profile_fields'])), "sortby" => $db->escape_string($mybb->input['sortby']), "sortorder" => $db->escape_string($mybb->input['sortorder']), "perpage" => $mybb->get_input('perpage', MyBB::INPUT_INT), "view_type" => $db->escape_string($mybb->input['view_type']));
                $vid = $db->insert_query("adminviews", $new_view);
                if ($mybb->input['isdefault']) {
                    set_default_view($type, $vid);
                }
                flash_message($lang->success_view_created, "success");
                admin_redirect($base_url . "&vid={$vid}");
            }
        } else {
            $mybb->input = array_merge($mybb->input, array('perpage' => 20));
        }
        // Write in our JS based field selector
        $page->extra_header .= "<script src=\"jscripts/view_manager.js\" type=\"text/javascript\"></script>\n";
        $page->add_breadcrumb_item($lang->create_new_view);
        $page->output_header($lang->create_new_view);
        $form = new Form($base_url . "&amp;action=views&amp;do=add", "post");
        $page->output_nav_tabs($sub_tabs, 'create_view');
        // If we have any error messages, show them
        if ($errors) {
            $page->output_inline_error($errors);
        }
        $form_container = new FormContainer($lang->create_new_view);
        $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
        if ($mybb->input['visibility'] == 2) {
            $visibility_public_checked = true;
        } else {
            $visibility_private_checked = true;
        }
        $visibility_options = array($form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)));
        $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
        $form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0)));
        if (count($sort_options) > 0) {
            $sort_directions = array("asc" => $lang->ascending, "desc" => $lang->descending);
            $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('sortorder', $sort_directions, $mybb->input['sortorder'], array('id' => 'sortorder')), 'sortby');
        }
        $form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $mybb->input['perpage'], array('id' => 'perpage', 'min' => 1)), 'perpage');
        if ($type == "user") {
            $form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => $mybb->input['view_type'] != "card" ? true : false)) . "<br />" . $form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => $mybb->input['view_type'] == "card" ? true : false)));
        }
        $form_container->end();
        $field_select .= "<div class=\"view_fields\">\n";
        $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n";
        if (is_array($mybb->input['fields'])) {
            foreach ($mybb->input['fields'] as $field) {
                if ($fields[$field]) {
                    $field_select .= "<li id=\"field-{$field}\">&#149; {$fields[$field]['title']}</li>";
                    $active[$field] = 1;
                }
            }
        }
        $field_select .= "</ul></div>\n";
        $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n";
        foreach ($fields as $key => $field) {
            if ($active[$key]) {
                continue;
            }
            $field_select .= "<li id=\"field-{$key}\">&#149; {$field['title']}</li>";
        }
        $field_select .= "</div></ul>\n";
        $field_select .= $form->generate_hidden_field("fields_js", @implode(",", @array_keys($active)), array('id' => 'fields_js'));
        $field_select = str_replace("'", "\\'", $field_select);
        $field_select = str_replace("\n", "", $field_select);
        $field_select = "<script type=\"text/javascript\">\n//<![CDATA[\ndocument.write('" . str_replace("/", "\\/", $field_select) . "');\n//]]>\n</script>\n";
        foreach ($fields as $key => $field) {
            $field_options[$key] = $field['title'];
        }
        $field_select .= "<noscript>" . $form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true)) . "</noscript>\n";
        $form_container = new FormContainer($lang->fields_to_show);
        $form_container->output_row($lang->fields_to_show_desc, $description, $field_select);
        $form_container->end();
        // Build the search conditions
        if (function_exists($conditions_callback)) {
            $conditions_callback($mybb->input, $form);
        }
        $buttons[] = $form->generate_submit_button($lang->save_view);
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    } else {
        if ($mybb->input['do'] == "edit") {
            $query = $db->simple_select("adminviews", "*", "vid='" . $mybb->get_input('vid', MyBB::INPUT_INT) . "'");
            $admin_view = $db->fetch_array($query);
            // Does the view not exist?
            if (!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) {
                flash_message($lang->error_invalid_admin_view, 'error');
                admin_redirect($base_url . "&action=views");
            }
            if ($mybb->request_method == "post") {
                if (!trim($mybb->input['title'])) {
                    $errors[] = $lang->error_missing_view_title;
                }
                if ($mybb->input['fields_js']) {
                    $mybb->input['fields'] = explode(",", $mybb->input['fields_js']);
                }
                if (count($mybb->input['fields']) <= 0) {
                    $errors[] = $lang->error_no_view_fields;
                }
                if ($mybb->get_input('perpage', MyBB::INPUT_INT) <= 0) {
                    $errors[] = $lang->error_invalid_view_perpage;
                }
                if (!in_array($mybb->input['sortby'], array_keys($sort_options))) {
                    $errors[] = $lang->error_invalid_view_sortby;
                }
                if ($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") {
                    $errors[] = $lang->error_invalid_view_sortorder;
                }
                if ($mybb->input['visibility'] == 0) {
                    $mybb->input['visibility'] = 2;
                }
                if (!$errors) {
                    $updated_view = array("title" => $db->escape_string($mybb->input['title']), "type" => $type, "visibility" => $mybb->get_input('visibility', MyBB::INPUT_INT), "fields" => $db->escape_string(my_serialize($mybb->input['fields'])), "conditions" => $db->escape_string(my_serialize($mybb->input['conditions'])), "custom_profile_fields" => $db->escape_string(my_serialize($mybb->input['profile_fields'])), "sortby" => $db->escape_string($mybb->input['sortby']), "sortorder" => $db->escape_string($mybb->input['sortorder']), "perpage" => $mybb->get_input('perpage', MyBB::INPUT_INT), "view_type" => $db->escape_string($mybb->input['view_type']));
                    $db->update_query("adminviews", $updated_view, "vid='{$admin_view['vid']}'");
                    if ($mybb->input['isdefault']) {
                        set_default_view($type, $admin_view['vid']);
                    }
                    flash_message($lang->success_view_updated, "success");
                    admin_redirect($base_url . "&vid={$admin_view['vid']}");
                }
            }
            // Write in our JS based field selector
            $page->extra_header .= "<script src=\"jscripts/view_manager.js\" type=\"text/javascript\"></script>\n";
            $page->add_breadcrumb_item($lang->edit_view);
            $page->output_header($lang->edit_view);
            $form = new Form($base_url . "&amp;action=views&amp;do=edit&amp;vid={$admin_view['vid']}", "post");
            $sub_tabs = array();
            $sub_tabs['edit_view'] = array('title' => $lang->edit_view, 'link' => $base_url . "&amp;action=views&amp;do=edit&amp;vid={$admin_view['vid']}", 'description' => $lang->edit_view_desc);
            $page->output_nav_tabs($sub_tabs, 'edit_view');
            // If we have any error messages, show them
            if ($errors) {
                $page->output_inline_error($errors);
            } else {
                $admin_view['conditions'] = my_unserialize($admin_view['conditions']);
                $admin_view['fields'] = my_unserialize($admin_view['fields']);
                $admin_view['profile_fields'] = my_unserialize($admin_view['custom_profile_fields']);
                $mybb->input = array_merge($mybb->input, $admin_view);
                $mybb->input['isdefault'] = 0;
                $default_view = fetch_default_view($type);
                if ($default_view == $admin_view['vid']) {
                    $mybb->input['isdefault'] = 1;
                }
            }
            $form_container = new FormContainer($lang->edit_view);
            $form_container->output_row($lang->view . " <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
            if ($mybb->input['visibility'] == 2) {
                $visibility_public_checked = true;
            } else {
                $visibility_private_checked = true;
            }
            $visibility_options = array($form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)));
            $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options));
            $form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0)));
            if (count($sort_options) > 0) {
                $sort_directions = array("asc" => $lang->ascending, "desc" => $lang->descending);
                $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby')) . " {$lang->in} " . $form->generate_select_box('sortorder', $sort_directions, $mybb->input['sortorder'], array('id' => 'sortorder')), 'sortby');
            }
            $form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $mybb->input['perpage'], array('id' => 'perpage', 'min' => 1)), 'perpage');
            if ($type == "user") {
                $form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => $mybb->input['view_type'] != "card" ? true : false)) . "<br />" . $form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => $mybb->input['view_type'] == "card" ? true : false)));
            }
            $form_container->end();
            $field_select .= "<div class=\"view_fields\">\n";
            $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n";
            if (is_array($mybb->input['fields'])) {
                foreach ($mybb->input['fields'] as $field) {
                    if ($fields[$field]) {
                        $field_select .= "<li id=\"field-{$field}\">&#149; {$fields[$field]['title']}</li>";
                        $active[$field] = 1;
                    }
                }
            }
            $field_select .= "</ul></div>\n";
            $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n";
            if (is_array($fields)) {
                foreach ($fields as $key => $field) {
                    if ($active[$key]) {
                        continue;
                    }
                    $field_select .= "<li id=\"field-{$key}\">&#149; {$field['title']}</li>";
                }
            }
            $field_select .= "</div></ul>\n";
            $field_select .= $form->generate_hidden_field("fields_js", @implode(",", @array_keys($active)), array('id' => 'fields_js'));
            $field_select = str_replace("'", "\\'", $field_select);
            $field_select = str_replace("\n", "", $field_select);
            $field_select = "<script type=\"text/javascript\">\n//<![CDATA[\ndocument.write('" . str_replace("/", "\\/", $field_select) . "');\n//]]></script>\n";
            foreach ($fields as $key => $field) {
                $field_options[$key] = $field['title'];
            }
            $field_select .= "<noscript>" . $form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true)) . "</noscript>\n";
            $form_container = new FormContainer($lang->fields_to_show);
            $form_container->output_row($lang->fields_to_show_desc, $description, $field_select);
            $form_container->end();
            // Build the search conditions
            if (function_exists($conditions_callback)) {
                $conditions_callback($mybb->input, $form);
            }
            $buttons[] = $form->generate_submit_button($lang->save_view);
            $form->output_submit_wrapper($buttons);
            $form->end();
            $page->output_footer();
        } else {
            if ($mybb->input['do'] == "delete") {
                if ($mybb->input['no']) {
                    admin_redirect($base_url . "&action=views");
                }
                $query = $db->simple_select("adminviews", "COUNT(vid) as views");
                $views = $db->fetch_field($query, "views");
                if ($views == 0) {
                    flash_message($lang->error_cannot_delete_view, 'error');
                    admin_redirect($base_url . "&action=views");
                }
                $vid = $mybb->get_input('vid', MyBB::INPUT_INT);
                $query = $db->simple_select("adminviews", "vid, uid, visibility", "vid = '{$vid}'");
                $admin_view = $db->fetch_array($query);
                if ($vid == 1 || !$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) {
                    flash_message($lang->error_invalid_view_delete, 'error');
                    admin_redirect($base_url . "&action=views");
                }
                if ($mybb->request_method == "post") {
                    $db->delete_query("adminviews", "vid='{$admin_view['vid']}'");
                    flash_message($lang->success_view_deleted, 'success');
                    admin_redirect($base_url . "&action=views");
                } else {
                    $page->output_confirm_action($base_url . "&amp;action=views&amp;do=delete&amp;vid={$admin_view['vid']}", $lang->confirm_view_deletion);
                }
            } else {
                if ($mybb->input['do'] == "export") {
                    $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?" . ">\n";
                    $xml = "<adminviews version=\"" . $mybb->version_code . "\" exported=\"" . TIME_NOW . "\">\n";
                    if ($mybb->input['type']) {
                        $type_where = "type='" . $db->escape_string($mybb->input['type']) . "'";
                    }
                    $query = $db->simple_select("adminviews", "*", $type_where);
                    while ($admin_view = $db->fetch_array($query)) {
                        $fields = my_unserialize($admin_view['fields']);
                        $conditions = my_unserialize($admin_view['conditions']);
                        $admin_view['title'] = str_replace(']]>', ']]]]><![CDATA[>', $admin_view['title']);
                        $admin_view['sortby'] = str_replace(']]>', ']]]]><![CDATA[>', $admin_view['sortby']);
                        $admin_view['sortorder'] = str_replace(']]>', ']]]]><![CDATA[>', $admin_view['sortorder']);
                        $admin_view['view_type'] = str_replace(']]>', ']]]]><![CDATA[>', $admin_view['view_type']);
                        $xml .= "\t<view vid=\"{$admin_view['vid']}\" uid=\"{$admin_view['uid']}\" type=\"{$admin_view['type']}\" visibility=\"{$admin_view['visibility']}\">\n";
                        $xml .= "\t\t<title><![CDATA[{$admin_view['title']}]]></title>\n";
                        $xml .= "\t\t<fields>\n";
                        foreach ($fields as $field) {
                            $xml .= "\t\t\t<field name=\"{$field}\" />\n";
                        }
                        $xml .= "\t\t</fields>\n";
                        $xml .= "\t\t<conditions>\n";
                        foreach ($conditions as $name => $condition) {
                            if (!$conditions) {
                                continue;
                            }
                            if (is_array($condition)) {
                                $condition = my_serialize($condition);
                                $is_serialized = " is_serialized=\"1\"";
                            }
                            $condition = str_replace(']]>', ']]]]><![CDATA[>', $condition);
                            $xml .= "\t\t\t<condition name=\"{$name}\"{$is_serialized}><![CDATA[{$condition}]]></condition>\n";
                        }
                        $xml .= "\t\t</conditions>\n";
                        $xml .= "\t\t<sortby><![CDATA[{$admin_view['sortby']}]]></sortby>\n";
                        $xml .= "\t\t<sortorder><![CDATA[{$admin_view['sortorder']}]]></sortorder>\n";
                        $xml .= "\t\t<perpage><![CDATA[{$admin_view['perpage']}]]></perpage>\n";
                        $xml .= "\t\t<view_type><![CDATA[{$admin_view['view_type']}]]></view_type>\n";
                        $xml .= "\t</view>\n";
                    }
                    $xml .= "</adminviews>\n";
                    $mybb->settings['bbname'] = urlencode($mybb->settings['bbname']);
                    header("Content-disposition: filename=" . $mybb->settings['bbname'] . "-views.xml");
                    header("Content-Length: " . my_strlen($xml));
                    header("Content-type: unknown/unknown");
                    header("Pragma: no-cache");
                    header("Expires: 0");
                    echo $xml;
                    exit;
                } else {
                    $page->output_header($lang->view_manager);
                    $page->output_nav_tabs($sub_tabs, 'views');
                    $table = new Table();
                    $table->construct_header($lang->view);
                    $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
                    $default_view = fetch_default_view($type);
                    $query = $db->simple_select("adminviews", "COUNT(vid) as views");
                    $views = $db->fetch_field($query, "views");
                    $query = $db->query("\n\t\t\tSELECT v.*, u.username\n\t\t\tFROM " . TABLE_PREFIX . "adminviews v\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=v.uid)\n\t\t\tWHERE v.visibility='2' OR (v.visibility='1' AND v.uid='{$mybb->user['uid']}')\n\t\t\tORDER BY title\n\t\t");
                    while ($view = $db->fetch_array($query)) {
                        $created = "";
                        if ($view['uid'] == 0) {
                            $view_type = "default";
                            $default_class = "grey";
                        } else {
                            if ($view['visibility'] == 2) {
                                $view_type = "group";
                                if ($view['username']) {
                                    $created = "<br /><small>{$lang->created_by} {$view['username']}</small>";
                                }
                            } else {
                                $view_type = "user";
                            }
                        }
                        $default_add = '';
                        if ($default_view == $view['vid']) {
                            $default_add = " ({$lang->default})";
                        }
                        $title_string = "view_title_{$view['vid']}";
                        if ($lang->{$title_string}) {
                            $view['title'] = $lang->{$title_string};
                        }
                        $table->construct_cell("<div class=\"float_right\"><img src=\"styles/{$page->style}/images/icons/{$view_type}.png\" title=\"" . $lang->sprintf($lang->this_is_a_view, $view_type) . "\" alt=\"{$view_type}\" /></div><div class=\"{$default_class}\"><strong><a href=\"{$base_url}&amp;action=views&amp;do=edit&amp;vid={$view['vid']}\" >{$view['title']}</a></strong>{$default_add}{$created}</div>");
                        $popup = new PopupMenu("view_{$view['vid']}", $lang->options);
                        $popup->add_item($lang->edit_view, "{$base_url}&amp;action=views&amp;do=edit&amp;vid={$view['vid']}");
                        if ($view['vid'] != $default_view) {
                            $popup->add_item($lang->set_as_default, "{$base_url}&amp;action=views&amp;do=set_default&amp;vid={$view['vid']}");
                        }
                        if ($views > 1 && $view['vid'] != 1) {
                            $popup->add_item($lang->delete_view, "{$base_url}&amp;action=views&amp;do=delete&amp;vid={$view['vid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_view_deletion}')");
                        }
                        $controls = $popup->fetch();
                        $table->construct_cell($controls, array("class" => "align_center"));
                        $table->construct_row();
                    }
                    $table->output($lang->view);
                    echo <<<LEGEND
<br />
<fieldset>
<legend>{$lang->legend}</legend>
<img src="styles/{$page->style}/images/icons/default.png" alt="{$lang->default}" style="vertical-align: middle;" /> {$lang->default_view_desc}<br />
<img src="styles/{$page->style}/images/icons/group.png" alt="{$lang->public}" style="vertical-align: middle;" /> {$lang->public_view_desc}<br />
<img src="styles/{$page->style}/images/icons/user.png" alt="{$lang->private}" style="vertical-align: middle;" /> {$lang->private_view_desc}</fieldset>
LEGEND;
                    $page->output_footer();
                }
            }
        }
    }
}
    // Check if file is writable, before allowing submission
    if (!is_writable(MYBB_ADMIN_DIR . "/backups")) {
        $lang->update_button = '';
        $page->output_alert($lang->alert_not_writable);
        $cannot_write = true;
    }
    $table = new Table();
    $table->construct_header($lang->table_selection);
    $table->construct_header($lang->backup_options);
    $table_selects = array();
    $table_list = $db->list_tables($config['database']['database']);
    foreach ($table_list as $id => $table_name) {
        $table_selects[$table_name] = $table_name;
    }
    $form = new Form("index.php?module=tools-backupdb&amp;action=backup", "post", "table_selection", 0, "table_selection");
    $table->construct_cell("{$lang->table_select_desc}\n<br /><br />\n<a href=\"javascript:changeSelection('select', 0);\">{$lang->select_all}</a><br />\n<a href=\"javascript:changeSelection('deselect', 0);\">{$lang->deselect_all}</a><br />\n<a href=\"javascript:changeSelection('forum', '" . TABLE_PREFIX . "');\">{$lang->select_forum_tables}</a>\n<br /><br />\n<div class=\"form_row\">" . $form->generate_select_box("tables[]", $table_selects, false, array('multiple' => true, 'id' => 'table_select', 'size' => 20)) . "</div>", array('rowspan' => 5, 'width' => '50%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->file_type}</strong><br />\n{$lang->file_type_desc}<br />\n<div class=\"form_row\">" . $form->generate_radio_button("filetype", "gzip", $lang->gzip_compressed, array('checked' => 1)) . "<br />\n" . $form->generate_radio_button("filetype", "plain", $lang->plain_text) . "</div>", array('width' => '50%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->save_method}</strong><br />\n{$lang->save_method_desc}<br /><div class=\"form_row\">" . $form->generate_radio_button("method", "disk", $lang->backup_directory) . "<br />\n" . $form->generate_radio_button("method", "download", $lang->download, array('checked' => 1)) . "</div>", array('width' => '50%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->backup_contents}</strong><br />\n{$lang->backup_contents_desc}<br /><div class=\"form_row\">" . $form->generate_radio_button("contents", "both", $lang->structure_and_data, array('checked' => 1)) . "<br />\n" . $form->generate_radio_button("contents", "structure", $lang->structure_only) . "<br />\n" . $form->generate_radio_button("contents", "data", $lang->data_only) . "</div>", array('width' => '50%'));
    $table->construct_row();
    $table->construct_cell("<strong>{$lang->analyze_and_optimize}</strong><br />\n{$lang->analyze_and_optimize_desc}<br /><div class=\"form_row\">" . $form->generate_yes_no_radio("analyzeoptimize") . "</div>", array('width' => '50%'));
    $table->construct_row();
    $table->output($lang->new_database_backup);
    $buttons[] = $form->generate_submit_button($lang->perform_backup);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
예제 #23
0
        $table->construct_cell("{$title} ({$points})");
        $table->construct_cell($issued_date, array("class" => "align_center"));
        $table->construct_cell($expire_date . $revoked_text, array("class" => "align_center"));
        $table->construct_cell($mod_username_link);
        $table->construct_cell("<a href=\"index.php?module=tools-warninglog&amp;action=view&amp;wid={$row['wid']}\">{$lang->view}</a>", array("class" => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_warning_logs, array("colspan" => "6"));
        $table->construct_row();
    }
    $table->output($lang->warning_logs);
    // Do we need to construct the pagination?
    if ($total_warnings > $per_page) {
        echo draw_admin_pagination($view_page, $per_page, $total_warnings, $url) . "<br />";
    }
    $sort_by = array('expires' => $lang->expiry_date, 'dateline' => $lang->issued_date, 'username' => $lang->warned_user, 'issuedby' => $lang->issued_by);
    $order_array = array('asc' => $lang->asc, 'desc' => $lang->desc);
    $form = new Form("index.php?module=tools-warninglog", "post");
    $form_container = new FormContainer($lang->filter_warning_logs);
    $form_container->output_row($lang->filter_warned_user, "", $form->generate_text_box('filter[username]', $mybb->input['filter']['username'], array('id' => 'filter_username')), 'filter_username');
    $form_container->output_row($lang->filter_issued_by, "", $form->generate_text_box('filter[mod_username]', $mybb->input['filter']['mod_username'], array('id' => 'filter_mod_username')), 'filter_mod_username');
    $form_container->output_row($lang->filter_reason, "", $form->generate_text_box('filter[reason]', $mybb->input['filter']['reason'], array('id' => 'filter_reason')), 'filter_reason');
    $form_container->output_row($lang->sort_by, "", $form->generate_select_box('filter[sortby]', $sort_by, $mybb->input['filter']['sortby'], array('id' => 'filter_sortby')) . " {$lang->in} " . $form->generate_select_box('filter[order]', $order_array, $order, array('id' => 'filter_order')) . " {$lang->order}", 'filter_order');
    $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('filter[per_page]', $per_page, array('id' => 'filter_per_page')), 'filter_per_page');
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->filter_warning_logs);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
예제 #24
0
     $mybb->input['postcount'] = '0';
     $mybb->input['threadcount'] = '0';
     $mybb->input['timeregistered'] = '0';
     $mybb->input['timeregisteredtype'] = 'days';
     $mybb->input['timeonline'] = '0';
     $mybb->input['timeonlinetype'] = 'days';
     $mybb->input['originalusergroup'] = '*';
     $mybb->input['newusergroup'] = '2';
     $mybb->input['enabled'] = '1';
     $mybb->input['logging'] = '1';
 }
 $form_container = new FormContainer($lang->add_new_promotion);
 $form_container->output_row($lang->title . " <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 $form_container->output_row($lang->short_desc . " <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 $options = array("postcount" => $lang->post_count, "threadcount" => $lang->thread_count, "reputation" => $lang->reputation, "referrals" => $lang->referrals, "warnings" => $lang->warning_points, "timeregistered" => $lang->time_registered, "timeonline" => $lang->time_online);
 $form_container->output_row($lang->promo_requirements . " <em>*</em>", $lang->promo_requirements_desc, $form->generate_select_box('requirements[]', $options, $mybb->input['requirements'], array('id' => 'requirements', 'multiple' => true, 'size' => 5)), 'requirements');
 $options_type = array(">" => $lang->greater_than, ">=" => $lang->greater_than_or_equal_to, "=" => $lang->equal_to, "<=" => $lang->less_than_or_equal_to, "<" => $lang->less_than);
 $form_container->output_row($lang->post_count, $lang->post_count_desc, $form->generate_numeric_field('postcount', $mybb->input['postcount'], array('id' => 'postcount', 'min' => 0)) . " " . $form->generate_select_box("posttype", $options_type, $mybb->input['posttype'], array('id' => 'posttype')), 'postcount');
 $form_container->output_row($lang->thread_count, $lang->thread_count_desc, $form->generate_numeric_field('threadcount', $mybb->input['threadcount'], array('id' => 'threadcount', 'min' => 0)) . " " . $form->generate_select_box("threadtype", $options_type, $mybb->input['threadtype'], array('id' => 'threadtype')), 'threadcount');
 $form_container->output_row($lang->reputation_count, $lang->reputation_count_desc, $form->generate_numeric_field('reputationcount', $mybb->input['reputationcount'], array('id' => 'reputationcount', 'min' => 0)) . " " . $form->generate_select_box("reputationtype", $options_type, $mybb->input['reputationtype'], array('id' => 'reputationtype')), 'reputationcount');
 $options = array("hours" => $lang->hours, "days" => $lang->days, "weeks" => $lang->weeks, "months" => $lang->months, "years" => $lang->years);
 $form_container->output_row($lang->referral_count, $lang->referral_count_desc, $form->generate_numeric_field('referrals', $mybb->input['referrals'], array('id' => 'referrals', 'min' => 0)) . " " . $form->generate_select_box("referralstype", $options_type, $mybb->input['referralstype'], array('id' => 'referralstype')), 'referrals');
 $form_container->output_row($lang->warning_points, $lang->warning_points_desc, $form->generate_numeric_field('warnings', $mybb->input['warnings'], array('id' => 'warnings', 'min' => 0)) . " " . $form->generate_select_box("warningstype", $options_type, $mybb->input['warningstype'], array('id' => 'warningstype')), 'warnings');
 $form_container->output_row($lang->time_registered, $lang->time_registered_desc, $form->generate_numeric_field('timeregistered', $mybb->input['timeregistered'], array('id' => 'timeregistered', 'min' => 0)) . " " . $form->generate_select_box("timeregisteredtype", $options, $mybb->input['timeregisteredtype'], array('id' => 'timeregisteredtype')), 'timeregistered');
 $form_container->output_row($lang->time_online, $lang->time_online_desc, $form->generate_numeric_field('timeonline', $mybb->input['timeonline'], array('id' => 'timeonline', 'min' => 0)) . " " . $form->generate_select_box("timeonlinetype", $options, $mybb->input['timeonlinetype'], array('id' => 'timeonlinetype')), 'timeonline');
 $options = array();
 $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
 while ($usergroup = $db->fetch_array($query)) {
     $options[(int) $usergroup['gid']] = $usergroup['title'];
 }
 $form_container->output_row($lang->orig_user_group . " <em>*</em>", $lang->orig_user_group_desc, $form->generate_select_box('originalusergroup[]', $options, $mybb->input['originalusergroup'], array('id' => 'originalusergroup', 'multiple' => true, 'size' => 5)), 'originalusergroup');
예제 #25
0
파일: banning.php 프로젝트: Nidrax/ppm-1.6
    }
    $table->output($lang->banned_accounts);
    echo $pagination;
    $form = new Form("index.php?module=user-banning", "post");
    if ($errors) {
        $page->output_inline_error($errors);
    }
    if ($mybb->input['uid'] && !$mybb->input['username']) {
        $user = get_user($mybb->input['uid']);
        $mybb->input['username'] = $user['username'];
    }
    $form_container = new FormContainer($lang->ban_a_user);
    $form_container->output_row($lang->ban_username, $lang->autocomplete_enabled, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
    $form_container->output_row($lang->ban_reason, "", $form->generate_text_box('reason', $mybb->input['reason'], array('id' => 'reason')), 'reason');
    if (count($banned_groups) > 1) {
        $form_container->output_row($lang->ban_group, $lang->add_ban_group_desc, $form->generate_select_box('usergroup', $banned_groups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
    }
    foreach ($ban_times as $time => $period) {
        if ($time != "---") {
            $friendly_time = my_date("D, jS M Y @ 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();
    // Autocompletion for usernames
    echo '
	<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
	<script type="text/javascript">
	<!--
예제 #26
0
    $page->add_breadcrumb_item($lang->edit_calendar);
    $page->output_header($lang->calendars . " - " . $lang->edit_calendar);
    $sub_tabs['edit_calendar'] = array('title' => $lang->edit_calendar, 'link' => "index.php?module=config-calendars&amp;action=edit", 'description' => $lang->edit_calendar_desc);
    $page->output_nav_tabs($sub_tabs, 'edit_calendar');
    $form = new Form("index.php?module=config-calendars&amp;action=edit", "post");
    echo $form->generate_hidden_field("cid", $calendar['cid']);
    if ($errors) {
        $page->output_inline_error($errors);
    } else {
        $mybb->input = $calendar;
    }
    $form_container = new FormContainer($lang->edit_calendar);
    $form_container->output_row($lang->name . " <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
    $form_container->output_row($lang->display_order . " <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
    $select_list = array($lang->sunday, $lang->monday, $lang->tuesday, $lang->wednesday, $lang->thursday, $lang->friday, $lang->saturday);
    $form_container->output_row($lang->week_start, $lang->week_start_desc, $form->generate_select_box('startofweek', $select_list, $mybb->input['startofweek'], array('id' => 'startofweek')), 'startofweek');
    $form_container->output_row($lang->event_limit, $lang->event_limit_desc, $form->generate_numeric_field('eventlimit', $mybb->input['eventlimit'], array('id' => 'eventlimit', 'min' => 0)), 'eventlimit');
    $form_container->output_row($lang->show_birthdays, $lang->show_birthdays_desc, $form->generate_yes_no_radio('showbirthdays', $mybb->input['showbirthdays'], true));
    $form_container->output_row($lang->moderate_events, $lang->moderate_events_desc, $form->generate_yes_no_radio('moderation', $mybb->input['moderation'], true));
    $form_container->output_row($lang->allow_html, "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml']));
    $form_container->output_row($lang->allow_mycode, "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode']));
    $form_container->output_row($lang->allow_img, "", $form->generate_yes_no_radio('allowimgcode', $mybb->input['allowimgcode']));
    $form_container->output_row($lang->allow_video, "", $form->generate_yes_no_radio('allowvideocode', $mybb->input['allowvideocode']));
    $form_container->output_row($lang->allow_smilies, "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies']));
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_calendar);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
if ($mybb->input['action'] == "delete") {
예제 #27
0
파일: users.php 프로젝트: GeorgeLVP/mybb
                echo $form->generate_hidden_field('action', 'inline_edit');
                echo $form->generate_hidden_field('inline_action', 'multiusergroup');
                echo $form->generate_hidden_field('processed', '1');
                $form_container = new FormContainer($lang->mass_usergroups);
                // Usergroups
                $display_group_options[0] = $lang->use_primary_user_group;
                $options = array();
                $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
                while ($usergroup = $db->fetch_array($query)) {
                    $options[$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
                    $display_group_options[$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
                }
                if (!is_array($mybb->input['additionalgroups'])) {
                    $mybb->input['additionalgroups'] = explode(',', $mybb->input['additionalgroups']);
                }
                $form_container->output_row($lang->primary_user_group, "", $form->generate_select_box('usergroup', $options, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
                $form_container->output_row($lang->additional_user_groups, $lang->additional_user_groups_desc, $form->generate_select_box('additionalgroups[]', $options, $mybb->input['additionalgroups'], array('id' => 'additionalgroups', 'multiple' => true, 'size' => 5)), 'additionalgroups');
                $form_container->output_row($lang->display_user_group, "", $form->generate_select_box('displaygroup', $display_group_options, $mybb->input['displaygroup'], array('id' => 'displaygroup')), 'displaygroup');
                $form_container->end();
                $buttons[] = $form->generate_submit_button($lang->alter_usergroups);
                $form->output_submit_wrapper($buttons);
                $form->end();
                $page->output_footer();
                break;
        }
    }
}
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_user_users_start");
    $page->output_header($lang->browse_users);
    echo "<script type=\"text/javascript\" src=\"jscripts/users.js\"></script>";
예제 #28
0
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();
    }
}
예제 #29
0
     $mybb->input['splitpostsunapprove'] = '0';
     $mybb->input['splitpostsnewsubject'] = '{subject}';
     $mybb->input['splitpostsaddreply'] = '';
     $mybb->input['splitpostsreplysubject'] = '{subject}';
 }
 $form_container = new FormContainer($lang->general_options);
 $form_container->output_row($lang->name . " <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 $form_container->output_row($lang->short_description . " <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 $actions = "<script type=\"text/javascript\">\n    function checkAction(id)\n    {\n        var checked = '';\n        \n        \$\$('.'+id+'s_check').each(function(e)\n        {\n            if(e.checked == true)\n            {\n                checked = e.value;\n            }\n        });\n        \$\$('.'+id+'s').each(function(e)\n        {\n        \tElement.hide(e);\n        });\n        if(\$(id+'_'+checked))\n        {\n            Element.show(id+'_'+checked);\n        }\n    }    \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=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>\n\t\t<dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>\n\t\t<dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">\n\t\t\t<table cellpadding=\"4\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign=\"top\"><small>{$lang->forums_colon}</small></td>\n\t\t\t\t\t<td>" . $form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5)) . "</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('forum');\n\t</script>";
 $form_container->output_row($lang->available_in_forums . " <em>*</em>", '', $actions);
 $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');
예제 #30
0
 $page->output_header($lang->preferences_and_personal_notes);
 $sub_tabs['preferences'] = array('title' => $lang->preferences_and_personal_notes, 'link' => "index.php?module=home-preferences", 'description' => $lang->prefs_and_personal_notes_description);
 $page->output_nav_tabs($sub_tabs, 'preferences');
 $query = $db->simple_select("adminoptions", "notes, cpstyle, cplanguage, codepress, authsecret", "uid='" . $mybb->user['uid'] . "'", array('limit' => 1));
 $admin_options = $db->fetch_array($query);
 $form = new Form("index.php?module=home-preferences", "post");
 $dir = @opendir(MYBB_ADMIN_DIR . "/styles");
 $folders = array();
 while ($folder = readdir($dir)) {
     if ($folder != "." && $folder != ".." && @file_exists(MYBB_ADMIN_DIR . "/styles/{$folder}/main.css")) {
         $folders[$folder] = ucfirst($folder);
     }
 }
 closedir($dir);
 ksort($folders);
 $setting_code = $form->generate_select_box("cpstyle", $folders, $admin_options['cpstyle']);
 $languages = array_merge(array('' => $lang->use_default), $lang->get_languages(1));
 $language_code = $form->generate_select_box("cplanguage", $languages, $admin_options['cplanguage']);
 $table = new Table();
 $table->construct_header($lang->global_preferences);
 $table->construct_cell("<strong>{$lang->acp_theme}</strong><br /><small>{$lang->select_acp_theme}</small><br /><br />{$setting_code}");
 $table->construct_row();
 $table->construct_cell("<strong>{$lang->acp_language}</strong><br /><small>{$lang->select_acp_language}</small><br /><br />{$language_code}");
 $table->construct_row();
 $table->construct_cell("<strong>{$lang->codemirror}</strong><br /><small>{$lang->use_codemirror_desc}</small><br /><br />" . $form->generate_on_off_radio('codepress', $admin_options['codepress']));
 $table->construct_row();
 // If 2FA is enabled we need to display a link to the recovery codes page
 if (!empty($admin_options['authsecret'])) {
     $lang->use_2fa_desc .= "<br />" . $lang->recovery_codes_desc . " " . $lang->recovery_codes_warning;
 }
 $table->construct_cell("<strong>{$lang->my2fa}</strong><br /><small>{$lang->use_2fa_desc}</small><br /><br />" . $form->generate_on_off_radio('2fa', (int) (!empty($admin_options['authsecret']))));