#navTabsDlmngr();
 // well, now go on with the real code
 // create the page table, and add the column headers
 $table = new Table();
 $table->construct_header($lang->downloads_dlmngr_project);
 $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 // get the downloads
 $query = $db->simple_select("downloads", "dlid, title, desc_short, preview", "1=1 ORDER BY 'dlid' DESC");
 while ($dlitem = $db->fetch_array($query)) {
     // display each download
     // get some info about the download
     $projectname = $dlitem['title'];
     $dlid = $dlitem['dlid'];
     $desc_short = $dlitem['desc_short'];
     // create the "Edit/Delete" popup menu
     $popup = new PopupMenu("project_{$dlid}", $lang->options);
     // Add the items
     $popup->add_item($lang->downloads_dlmngr_edit, "index.php?module=dlmngr/manage&action=edit&dlid={$dlid}");
     $popup->add_item($lang->downloads_dlmngr_delete, "index.php?module=dlmngr/manage&action=delete&dlid={$dlid}");
     if ($dlitem['public'] == 1) {
         $popup->add_item($lang->downloads_dlmngr_reject, "index.php?module=dlmngr/manage&action=reject&dlid={$dlid}");
     } else {
         $popup->add_item($lang->downloads_dlmngr_accept, "index.php?module=dlmngr/manage&action=accept&dlid={$dlid}");
     }
     // create the info cell
     // construct_cell(content, array(html modifiers))
     $table->construct_cell("<a href=\"index.php?module=dlmngr/manage&amp;action=edit&amp;dlid={$dlid}\"><strong>" . $projectname . "</strong></a><br /><span style=\"font-size: 75%;\">" . $desc_short . "</span>");
     // create the menu cell
     $table->construct_cell($popup->fetch(), array("class" => "align_center"));
     // output the row
     $table->construct_row();
 $page->output_header($lang->promotion_manager);
 $page->output_nav_tabs($sub_tabs, 'usergroup_promotions');
 $table = new Table();
 $table->construct_header($lang->promotion);
 $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
 $query = $db->simple_select("promotions", "*", "", array("order_by" => "title", "order_dir" => "asc"));
 while ($promotion = $db->fetch_array($query)) {
     $promotion['title'] = htmlspecialchars_uni($promotion['title']);
     $promotion['description'] = htmlspecialchars_uni($promotion['description']);
     if ($promotion['enabled'] == 1) {
         $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\"  style=\"vertical-align: middle;\" /> ";
     } else {
         $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\"  style=\"vertical-align: middle;\" /> ";
     }
     $table->construct_cell("<div>{$icon}<strong><a href=\"index.php?module=user-group_promotions&amp;action=edit&amp;pid={$promotion['pid']}\">{$promotion['title']}</a></strong><br /><small>{$promotion['description']}</small></div>");
     $popup = new PopupMenu("promotion_{$promotion['pid']}", $lang->options);
     $popup->add_item($lang->edit_promotion, "index.php?module=user-group_promotions&amp;action=edit&amp;pid={$promotion['pid']}");
     if ($promotion['enabled'] == 1) {
         $popup->add_item($lang->disable_promotion, "index.php?module=user-group_promotions&amp;action=disable&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_disable}')");
     } else {
         $popup->add_item($lang->enable_promotion, "index.php?module=user-group_promotions&amp;action=enable&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}");
     }
     $popup->add_item($lang->delete_promotion, "index.php?module=user-group_promotions&amp;action=delete&amp;pid={$promotion['pid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_promo_deletion}')");
     $table->construct_cell($popup->fetch(), array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_promotions_set, array("colspan" => "2"));
     $table->construct_row();
 }
 $table->output($lang->user_group_promotions);
Example #3
0
    $page->output_nav_tabs($sub_tabs, 'scheduled_tasks');
    $table = new Table();
    $table->construct_header($lang->task);
    $table->construct_header($lang->next_run, array("class" => "align_center", "width" => 200));
    $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
    $query = $db->simple_select("tasks", "*", "", array("order_by" => "title", "order_dir" => "asc"));
    while ($task = $db->fetch_array($query)) {
        $task['title'] = htmlspecialchars_uni($task['title']);
        $task['description'] = htmlspecialchars_uni($task['description']);
        $next_run = date($mybb->settings['dateformat'], $task['nextrun']) . ", " . date($mybb->settings['timeformat'], $task['nextrun']);
        if ($task['enabled'] == 1) {
            $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.gif\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}\"  style=\"vertical-align: middle;\" /> ";
        } else {
            $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.gif\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}\"  style=\"vertical-align: middle;\" /> ";
        }
        $table->construct_cell("<div class=\"float_right\"><a href=\"index.php?module=tools/tasks&amp;action=run&amp;tid={$task['tid']}&amp;my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/run_task.gif\" title=\"{$lang->run_task_now}\" alt=\"{$lang->run_task}\" /></a></div><div>{$icon}<strong><a href=\"index.php?module=tools/tasks&amp;action=edit&amp;tid={$task['tid']}\">{$task['title']}</a></strong><br /><small>{$task['description']}</small></div>");
        $table->construct_cell($next_run, array("class" => "align_center"));
        $popup = new PopupMenu("task_{$task['tid']}", $lang->options);
        $popup->add_item($lang->edit_task, "index.php?module=tools/tasks&amp;action=edit&amp;tid={$task['tid']}");
        if ($task['enabled'] == 1) {
            $popup->add_item($lang->disable_task, "index.php?module=tools/tasks&amp;action=disable&amp;tid={$task['tid']}&amp;my_post_key={$mybb->post_code}");
        } else {
            $popup->add_item($lang->enable_task, "index.php?module=tools/tasks&amp;action=enable&amp;tid={$task['tid']}&amp;my_post_key={$mybb->post_code}");
        }
        $popup->add_item($lang->delete_task, "index.php?module=tools/tasks&amp;action=delete&amp;tid={$task['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_task_deletion}')");
        $table->construct_cell($popup->fetch(), array("class" => "align_center"));
        $table->construct_row();
    }
    $table->output($lang->scheduled_tasks);
    $page->output_footer();
}
/**
 * Displays peekers in settings
 **/
function myfbconnect_settings_footer()
{
    global $mybb, $db, $lang;
    if ($mybb->input["action"] == "change" and $mybb->request_method != "post") {
        $gid = myfbconnect_settings_gid();
        if ($mybb->input['gid'] == $gid) {
            // Delete reports
            if ($mybb->input['delete_report']) {
                switch ($mybb->input['delete_report']) {
                    case 'all':
                        $db->delete_query('myfbconnect_reports');
                        break;
                    default:
                        $db->delete_query('myfbconnect_reports', 'id = ' . (int) $mybb->input['delete_report']);
                }
                flash_message($lang->myfbconnect_success_deleted_reports, 'success');
                admin_redirect('index.php?module=config-settings&action=change&gid=' . $gid);
            }
            $reports = array();
            $query = $db->simple_select('myfbconnect_reports');
            while ($report = $db->fetch_array($query)) {
                $reports[] = $report;
            }
            if ($reports) {
                $table = new Table();
                $table->construct_header($lang->myfbconnect_reports_date, array('width' => '15%'));
                $table->construct_header($lang->myfbconnect_reports_code, array('width' => '5%'));
                $table->construct_header($lang->myfbconnect_reports_file);
                $table->construct_header($lang->myfbconnect_reports_line, array('width' => '5%'));
                $table->construct_header($lang->options, array('width' => '10%', 'style' => 'text-align: center'));
                foreach ($reports as $report) {
                    foreach ($report as $k => $val) {
                        if (in_array($k, array('id', 'message', 'trace'))) {
                            continue;
                        }
                        if ($k == 'dateline') {
                            $val = my_date($mybb->settings['dateformat'], $val) . ', ' . my_date($mybb->settings['timeformat'], $val);
                        }
                        $table->construct_cell($val);
                    }
                    $popup = new PopupMenu("item_{$report['id']}", $lang->options);
                    $popup->add_item($lang->myfbconnect_reports_download, 'index.php?module=config-settings&action=change&gid=' . $gid . '&export_id=' . $report['id']);
                    $popup->add_item($lang->myfbconnect_reports_delete, 'index.php?module=config-settings&action=change&gid=' . $gid . '&delete_report=' . $report['id']);
                    $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
                    $table->construct_row();
                }
                $table->construct_cell('<a href="index.php?module=config-settings&action=change&gid=' . $gid . '&delete_report=all" class="button">' . $lang->myfbconnect_reports_delete_all . '</a>', array('colspan' => 5, 'class' => 'align_center'));
                $table->construct_row();
                $table->output($lang->myfbconnect_reports);
            }
        }
        if ($mybb->input["gid"] == $gid or !$mybb->input['gid']) {
            // 1.8 has jQuery, not Prototype
            if ($mybb->version_code >= 1700) {
                echo '<script type="text/javascript">
	$(document).ready(function() {
		loadMyFBConnectPeekers();
		loadStars();
	});
	function loadMyFBConnectPeekers()
	{
		new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_subject"), /1/, true);
		new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_message"), /1/, true);
		new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_fromid"), /1/, true);
		new Peeker($(".setting_myfbconnect_fbbio"), $("#row_setting_myfbconnect_fbbiofield"), /1/, true);
		new Peeker($(".setting_myfbconnect_fblocation"), $("#row_setting_myfbconnect_fblocationfield"), /1/, true);
		new Peeker($(".setting_myfbconnect_fbdetails"), $("#row_setting_myfbconnect_fbdetailsfield"), /1/, true);
		new Peeker($(".setting_myfbconnect_fbsex"), $("#row_setting_myfbconnect_fbsexfield"), /1/, true);
		new Peeker($(".setting_myfbconnect_postonwall"), $("#row_setting_myfbconnect_postonwall_message"), /1/, true);
	}
	function loadStars()
	{
		add_star("row_setting_myfbconnect_appid");
		add_star("row_setting_myfbconnect_appsecret");
	}
	</script>';
            } else {
                echo '<script type="text/javascript">
	Event.observe(window, "load", function() {
		loadMyFBConnectPeekers();
		loadStars();
	});
	function loadMyFBConnectPeekers()
	{
		new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_subject"), /1/, true);
		new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_message"), /1/, true);
		new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_fromid"), /1/, true);
		new Peeker($$(".setting_myfbconnect_fbbio"), $("row_setting_myfbconnect_fbbiofield"), /1/, true);
		new Peeker($$(".setting_myfbconnect_fblocation"), $("row_setting_myfbconnect_fblocationfield"), /1/, true);
		new Peeker($$(".setting_myfbconnect_fbdetails"), $("row_setting_myfbconnect_fbdetailsfield"), /1/, true);
		new Peeker($$(".setting_myfbconnect_fbsex"), $("row_setting_myfbconnect_fbsexfield"), /1/, true);
		new Peeker($$(".setting_myfbconnect_postonwall"), $("row_setting_myfbconnect_postonwall_message"), /1/, true);
	}
	function loadStars()
	{
		add_star("row_setting_myfbconnect_appid");
		add_star("row_setting_myfbconnect_appsecret");
	}
	</script>';
            }
        }
    }
}
Example #5
0
            }
            $awards->update_cache();
            $awards->admin_redirect();
        }
        $form = new Form($awards->build_url('action=updatedisporder'), 'post');
        $query2 = $db->simple_select('ougc_awards', 'COUNT(aid) AS awards');
        $awardscount = (int) $db->fetch_field($query2, 'awards');
        echo draw_admin_pagination($mybb->input['page'], $limit, $awardscount, 'index.php?module=user-ougc_awards');
        while ($award = $db->fetch_array($query)) {
            $edit_link = "index.php?module=user-ougc_awards&amp;action=edit&amp;aid={$award['aid']}";
            $award['visible'] or $award['name'] = '<i>' . $award['name'] . '</i>';
            $table->construct_cell('<img src="' . $awards->get_award_icon($award['aid']) . '" />', array('class' => 'align_center'));
            $table->construct_cell('<a href="' . $edit_link . '">' . $award['name'] . '</a>');
            $table->construct_cell($award['description']);
            $table->construct_cell($form->generate_text_box('disporder[' . $award['aid'] . ']', (int) $award['disporder'], array('style' => 'text-align: center; width: 30px;')), array('class' => 'align_center'));
            $table->construct_cell('<img src="styles/default/images/icons/bullet_o' . (!$award['visible'] ? 'ff' : 'n') . '.png" alt="" title="' . (!$award['visible'] ? $lang->ougc_awards_form_hidden : $lang->ougc_awards_form_visible) . '" />', array('class' => 'align_center'));
            $popup = new PopupMenu("award_{$award['aid']}", $lang->options);
            $popup->add_item($lang->ougc_awards_tab_give, "index.php?module=user-ougc_awards&amp;action=give&amp;aid={$award['aid']}");
            $popup->add_item($lang->ougc_awards_tab_revoke, "index.php?module=user-ougc_awards&amp;action=revoke&amp;aid={$award['aid']}");
            $popup->add_item($lang->ougc_awards_tab_users, "index.php?module=user-ougc_awards&amp;action=users&amp;aid={$award['aid']}");
            $popup->add_item($lang->ougc_awards_tab_edit, $edit_link);
            $popup->add_item($lang->ougc_awards_tab_delete, "index.php?module=user-ougc_awards&amp;action=delete&amp;aid={$award['aid']}");
            $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
            $table->construct_row();
        }
        $table->output($lang->ougc_awards_tab_view_d);
        $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_awards_button_order), $form->generate_reset_button($lang->reset)));
        $form->end();
    }
    $page->output_footer();
}
Example #6
0
         continue;
     }
     if ($themes[$set['sid']]) {
         $used_by_note = $lang->used_by;
         $comma = "";
         foreach ($themes[$set['sid']] as $theme_name) {
             $used_by_note .= $comma . $theme_name;
             $comma = ", ";
         }
     } else {
         $used_by_note = $lang->not_used_by_any_themes;
     }
     if ($set['sid'] == 1) {
         $actions = "<a href=\"index.php?module=style/templates&amp;sid={$set['sid']}\">{$lang->expand_templates}</a>";
     } else {
         $popup = new PopupMenu("templateset_{$set['sid']}", $lang->options);
         $popup->add_item($lang->expand_templates, "index.php?module=style/templates&amp;sid={$set['sid']}");
         if ($set['sid'] != 1) {
             $popup->add_item($lang->edit_template_set, "index.php?module=style/templates&amp;action=edit_set&amp;sid={$set['sid']}");
             if (!$themes[$set['sid']]) {
                 $popup->add_item($lang->delete_template_set, "index.php?module=style/templates&amp;action=delete_set&amp;sid={$set['sid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_template_set_deletion}')");
             }
         }
         $actions = $popup->fetch();
     }
     $table->construct_cell("<strong><a href=\"index.php?module=style/templates&amp;sid={$set['sid']}\">{$set['title']}</a></strong><br /><small>{$used_by_note}</small>");
     $table->construct_cell($actions, array("class" => "align_center"));
     $table->construct_row();
 }
 $table->output($lang->template_sets);
 $page->output_footer();
Example #7
0
    $table->construct_header($lang->title);
    $table->construct_header($lang->controls, array('class' => 'align_center', 'width' => 150));
    $query = $db->simple_select("mycode", "*", "", array('order_by' => 'parseorder'));
    while ($mycode = $db->fetch_array($query)) {
        if ($mycode['active'] == 1) {
            $phrase = $lang->deactivate_mycode;
            $indicator = '';
        } else {
            $phrase = $lang->activate_mycode;
            $indicator = "<div class=\"float_right\"><small>{$lang->deactivated}</small></div>";
        }
        if ($mycode['description']) {
            $mycode['description'] = "<small>{$mycode['description']}</small>";
        }
        $table->construct_cell("{$indicator}<strong><a href=\"index.php?module=config/mycode&amp;action=edit&amp;cid={$mycode['cid']}\">{$mycode['title']}</a></strong><br />{$mycode['description']}");
        $popup = new PopupMenu("mycode_{$mycode['cid']}", $lang->options);
        $popup->add_item($lang->edit_mycode, "index.php?module=config/mycode&amp;action=edit&amp;cid={$mycode['cid']}");
        $popup->add_item($phrase, "index.php?module=config/mycode&amp;action=toggle_status&amp;cid={$mycode['cid']}&amp;my_post_key={$mybb->post_code}");
        $popup->add_item($lang->delete_mycode, "index.php?module=config/mycode&amp;action=delete&amp;cid={$mycode['cid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_mycode_deletion}')");
        $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_mycode, array('colspan' => 2));
        $table->construct_row();
    }
    $table->output($lang->custom_mycode);
    $page->output_footer();
}
function test_regex($regex, $replacement, $test)
{
Example #8
0
/**
 * @param DefaultFormContainer $form_container
 * @param int $pid
 * @param int $depth
 */
function build_admincp_forums_list(&$form_container, $pid = 0, $depth = 1)
{
    global $mybb, $lang, $db, $sub_forums;
    static $forums_by_parent;
    if (!is_array($forums_by_parent)) {
        $forum_cache = cache_forums();
        foreach ($forum_cache as $forum) {
            $forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
        }
    }
    if (!is_array($forums_by_parent[$pid])) {
        return;
    }
    foreach ($forums_by_parent[$pid] as $children) {
        foreach ($children as $forum) {
            $forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['name']);
            // Fix & but allow unicode
            if ($forum['active'] == 0) {
                $forum['name'] = "<em>" . $forum['name'] . "</em>";
            }
            if ($forum['type'] == "c" && ($depth == 1 || $depth == 2)) {
                $sub_forums = '';
                if (isset($forums_by_parent[$forum['fid']]) && $depth == 2) {
                    build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
                }
                if ($sub_forums) {
                    $sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>";
                }
                $form_container->output_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\"><a href=\"index.php?module=forum-management&amp;fid={$forum['fid']}\"><strong>{$forum['name']}</strong></a>{$sub_forums}</div>");
                $form_container->output_cell("<input type=\"text\" name=\"disporder[" . $forum['fid'] . "]\" value=\"" . $forum['disporder'] . "\" class=\"text_input align_center\" style=\"width: 80%; font-weight: bold;\" />", array("class" => "align_center"));
                $popup = new PopupMenu("forum_{$forum['fid']}", $lang->options);
                $popup->add_item($lang->edit_forum, "index.php?module=forum-management&amp;action=edit&amp;fid={$forum['fid']}");
                $popup->add_item($lang->subforums, "index.php?module=forum-management&amp;fid={$forum['fid']}");
                $popup->add_item($lang->moderators, "index.php?module=forum-management&amp;fid={$forum['fid']}#tab_moderators");
                $popup->add_item($lang->permissions, "index.php?module=forum-management&amp;fid={$forum['fid']}#tab_permissions");
                $popup->add_item($lang->add_child_forum, "index.php?module=forum-management&amp;action=add&amp;pid={$forum['fid']}");
                $popup->add_item($lang->copy_forum, "index.php?module=forum-management&amp;action=copy&amp;fid={$forum['fid']}");
                $popup->add_item($lang->delete_forum, "index.php?module=forum-management&amp;action=delete&amp;fid={$forum['fid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')");
                $form_container->output_cell($popup->fetch(), array("class" => "align_center"));
                $form_container->construct_row();
                // Does this category have any sub forums?
                if ($forums_by_parent[$forum['fid']]) {
                    build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
                }
            } elseif ($forum['type'] == "f" && ($depth == 1 || $depth == 2)) {
                if ($forum['description']) {
                    $forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['description']);
                    $forum['description'] = "<br /><small>" . $forum['description'] . "</small>";
                }
                $sub_forums = '';
                if (isset($forums_by_parent[$forum['fid']]) && $depth == 2) {
                    build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
                }
                if ($sub_forums) {
                    $sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>";
                }
                $form_container->output_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\"><a href=\"index.php?module=forum-management&amp;fid={$forum['fid']}\">{$forum['name']}</a>{$forum['description']}{$sub_forums}</div>");
                $form_container->output_cell("<input type=\"text\" name=\"disporder[" . $forum['fid'] . "]\" value=\"" . $forum['disporder'] . "\" class=\"text_input align_center\" style=\"width: 80%;\" />", array("class" => "align_center"));
                $popup = new PopupMenu("forum_{$forum['fid']}", $lang->options);
                $popup->add_item($lang->edit_forum, "index.php?module=forum-management&amp;action=edit&amp;fid={$forum['fid']}");
                $popup->add_item($lang->subforums, "index.php?module=forum-management&amp;fid={$forum['fid']}");
                $popup->add_item($lang->moderators, "index.php?module=forum-management&amp;fid={$forum['fid']}#tab_moderators");
                $popup->add_item($lang->permissions, "index.php?module=forum-management&amp;fid={$forum['fid']}#tab_permissions");
                $popup->add_item($lang->add_child_forum, "index.php?module=forum-management&amp;action=add&amp;pid={$forum['fid']}");
                $popup->add_item($lang->copy_forum, "index.php?module=forum-management&amp;action=copy&amp;fid={$forum['fid']}");
                $popup->add_item($lang->delete_forum, "index.php?module=forum-management&amp;action=delete&amp;fid={$forum['fid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')");
                $form_container->output_cell($popup->fetch(), array("class" => "align_center"));
                $form_container->construct_row();
                if (isset($forums_by_parent[$forum['fid']]) && $depth == 1) {
                    build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
                }
            } else {
                if ($depth == 3) {
                    if ($donecount < $mybb->settings['subforumsindex']) {
                        $sub_forums .= "{$comma} <a href=\"index.php?module=forum-management&amp;fid={$forum['fid']}\">{$forum['name']}</a>";
                        $comma = $lang->comma;
                    }
                    // Have we reached our max visible subforums? put a nice message and break out of the loop
                    ++$donecount;
                    if ($donecount == $mybb->settings['subforumsindex']) {
                        if (subforums_count($forums_by_parent[$pid]) > $donecount) {
                            $sub_forums .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($forums_by_parent[$pid]) - $donecount);
                            return;
                        }
                    }
                }
            }
        }
    }
}
Example #9
0
        } else {
            $required = $lang->no;
        }
        if ($field['editable']) {
            $editable = $lang->yes;
        } else {
            $editable = $lang->no;
        }
        if ($field['hidden']) {
            $hidden = $lang->yes;
        } else {
            $hidden = $lang->no;
        }
        $table->construct_cell("<strong><a href=\"index.php?module=config-profile_fields&amp;action=edit&amp;fid={$field['fid']}\">" . htmlspecialchars_uni($field['name']) . "</a></strong><br /><small>" . htmlspecialchars_uni($field['description']) . "</small>", array('width' => '45%'));
        $table->construct_cell($field['fid'], array("class" => "align_center", 'width' => '5%'));
        $table->construct_cell($required, array("class" => "align_center", 'width' => '10%'));
        $table->construct_cell($editable, array("class" => "align_center", 'width' => '10%'));
        $table->construct_cell($hidden, array("class" => "align_center", 'width' => '10%'));
        $popup = new PopupMenu("field_{$field['fid']}", $lang->options);
        $popup->add_item($lang->edit_field, "index.php?module=config-profile_fields&amp;action=edit&amp;fid={$field['fid']}");
        $popup->add_item($lang->delete_field, "index.php?module=config-profile_fields&amp;action=delete&amp;fid={$field['fid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_profile_field_deletion}')");
        $table->construct_cell($popup->fetch(), array("class" => "align_center", 'width' => '20%'));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_profile_fields, array('colspan' => 6));
        $table->construct_row();
    }
    $table->output($lang->custom_profile_fields);
    $page->output_footer();
}
/**
 * show a table row for each categorie
 * 
 * @param $id ID of the parent categorie
 * @param $depth depth of the parent categorie; neccessary to display the icons
 */
function showCatsTable($id = false, $depth = 0)
{
    global $db, $mybb, $table, $form, $lang;
    if ($id == false) {
        $query = $db->simple_select('downloads_catlist', '*', "parentID IS NULL", array('order by' => 'catid'));
    } else {
        $query = $db->simple_select('downloads_catlist', '*', "parentID={$id}", array('order by' => 'catid'));
    }
    while ($depth > $i) {
        $i++;
        $subdeepth .= "<img src=\"/images/nav_bit.gif\" /> ";
    }
    $depth++;
    while ($cat = $db->fetch_array($query)) {
        if ($mybb->input['action'] == "addsub" && $cat['catid'] == $mybb->input['catid']) {
            $table->construct_cell($subdeepth . "<strong><a href=\"index.php?module=dlmngr/cats&amp;action=edit&amp;catid={$cat['catid']}\">{$cat['title']}</a></strong>", array("colspan" => "2"));
            $table->construct_row();
            $table->construct_cell($subdeepth . "<img src=\"/images/nav_bit.gif\" /> " . $form->generate_text_box('title', "Sub - {$cat['title']}", array('id' => 'title')));
            $table->construct_cell($form->generate_hidden_field('parentcat', $cat['catid'], array('id' => 'parentcat')) . $form->generate_submit_button($lang->downloads_dlmngr_save, array('name' => 'savesub')) . $form->generate_submit_button($lang->downloads_dlmngr_cancel, array('name' => 'cancel')), array("class" => "align_center"));
        } elseif ($mybb->input['action'] != "edit" || $cat['catid'] != $mybb->input['catid']) {
            $table->construct_cell($subdeepth . "<strong><a href=\"index.php?module=dlmngr/cats&amp;action=edit&amp;catid={$cat['catid']}\">{$cat['title']}</a></strong>");
            $popup = new PopupMenu("cat_{$cat['catid']}", $lang->options);
            $popup->add_item($lang->downloads_dlmngr_edit, "index.php?module=dlmngr/cats&amp;action=edit&amp;catid={$cat['catid']}");
            $popup->add_item($lang->downloads_dlmngr_delete, "index.php?module=dlmngr/cats&amp;action=delete&amp;catid={$cat['catid']}");
            $popup->add_item($lang->downloads_dlmngr_addsub, "index.php?module=dlmngr/cats&amp;action=addsub&amp;catid={$cat['catid']}");
            $table->construct_cell($popup->fetch(), array("class" => "align_center"));
        } else {
            $table->construct_cell($form->generate_text_box('title', $cat['title'], array('id' => 'title')));
            $table->construct_cell($form->generate_submit_button($lang->downloads_dlmngr_save, array('name' => 'save')), array("class" => "align_center"));
        }
        $table->construct_row();
        showCatsTable($cat['catid'], $depth);
    }
}
     if ($usergroups[$admin['usergroup']]['cancp'] == 1) {
         $usergroup_list[] = "<i>" . $usergroups[$admin['usergroup']]['title'] . "</i>";
     }
     // Secondary usergroups?
     $additional_groups = explode(',', $admin['additionalgroups']);
     if (is_array($additional_groups)) {
         foreach ($additional_groups as $gid) {
             if ($usergroups[$gid]['cancp'] == 1) {
                 $usergroup_list[] = $usergroups[$gid]['title'];
             }
         }
     }
     $usergroup_list = implode($lang->comma, $usergroup_list);
     $table->construct_cell("<div class=\"float_right\"><img src=\"styles/{$page->style}/images/icons/{$perm_type}.png\" title=\"{$lang->perms_type_user}\" alt=\"{$perm_type}\" /></div><div><strong><a href=\"index.php?module=user-admin_permissions&amp;action=edit&amp;uid={$admin['uid']}\" title=\"{$lang->edit_user}\">{$admin['username']}</a></strong><br /><small>{$usergroup_list}</small></div>");
     $table->construct_cell(my_date('relative', $admin['lastactive']), array("class" => "align_center"));
     $popup = new PopupMenu("adminperm_{$admin['uid']}", $lang->options);
     if (!is_super_admin($admin['uid'])) {
         if ($admin['permissions'] != "") {
             $popup->add_item($lang->edit_permissions, "index.php?module=user-admin_permissions&amp;action=edit&amp;uid={$admin['uid']}");
             $popup->add_item($lang->revoke_permissions, "index.php?module=user-admin_permissions&amp;action=delete&amp;uid={$admin['uid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_perms_deletion2}')");
         } else {
             $popup->add_item($lang->set_permissions, "index.php?module=user-admin_permissions&amp;action=edit&amp;uid={$admin['uid']}");
         }
     }
     $popup->add_item($lang->view_log, "index.php?module=tools-adminlog&amp;uid={$admin['uid']}");
     $table->construct_cell($popup->fetch(), array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_user_perms, array("colspan" => "3"));
     $table->construct_row();
Example #12
0
    $table->construct_header($lang->version, array("class" => "align_center", "width" => 100));
    $table->construct_header($lang->controls, array("class" => "align_center", "width" => 155));
    asort($languages);
    foreach ($languages as $key1 => $langname1) {
        $langselectlangs[$key1] = $lang->sprintf($lang->edit_with, $langname1);
    }
    foreach ($languages as $key => $langname) {
        include MYBB_ROOT . "inc/languages/" . $key . ".php";
        if (!empty($langinfo['website'])) {
            $author = "<a href=\"{$langinfo['website']}\" target=\"_blank\">{$langinfo['author']}</a>";
        } else {
            $author = $langinfo['author'];
        }
        $table->construct_cell("<strong>{$langinfo['name']}</strong><br /><small>{$author}</small>");
        $table->construct_cell($langinfo['version'], array("class" => "align_center"));
        $popup = new PopupMenu("laguage_{$key}", $lang->options);
        $popup->add_item($lang->edit_language_variables, "index.php?module=config-languages&amp;action=edit&amp;lang={$key}");
        foreach ($langselectlangs as $key1 => $langname1) {
            $popup->add_item($langname1, "index.php?module=config-languages&amp;action=edit&amp;lang={$key}&amp;editwith={$key1}");
        }
        $popup->add_item($lang->edit_properties, "index.php?module=config-languages&amp;action=edit_properties&amp;lang={$key}");
        $table->construct_cell($popup->fetch(), array("class" => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_language, array('colspan' => 3));
        $table->construct_row();
    }
    $table->output($lang->installed_language_packs);
    $page->output_footer();
}
Example #13
0
function asb_admin_manage_modules()
{
    global $lang, $mybb, $db, $page, $html, $min;
    $page->extra_header .= <<<EOF
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>

EOF;
    $page->add_breadcrumb_item($lang->asb, $html->url());
    $page->add_breadcrumb_item($lang->asb_manage_modules);
    $page->output_header("{$lang->asb} - {$lang->asb_manage_modules}");
    asb_output_tabs('asb_modules');
    $table = new Table();
    $table->construct_header($lang->asb_name, array("width" => '22%'));
    $table->construct_header($lang->asb_description, array("width" => '55%'));
    $table->construct_header($lang->asb_modules_author, array("width" => '15%'));
    $table->construct_header($lang->asb_controls, array("width" => '8%'));
    $addons = asb_get_all_modules();
    // if there are installed modules display them
    if (!empty($addons) && is_array($addons)) {
        foreach ($addons as $this_module) {
            $data = $this_module->get(array('title', 'description', 'base_name', 'author', 'author_site', 'module_site', 'version', 'public_version', 'compatibility'));
            $out_of_date = '';
            if (!$data['compatibility'] || version_compare('2.1', $data['compatibility'], '<')) {
                $out_of_date = <<<EOF
<br /><span style="color: red;">{$lang->asb_module_out_of_date}</span>
EOF;
            }
            $version = $data['version'];
            if ($data['public_version']) {
                $version = $data['public_version'];
            }
            // title
            $table->construct_cell($html->link($data['module_site'], $data['title'], array("style" => 'font-weight: bold;')) . " ({$version})");
            // description
            $table->construct_cell($data['description'] . $out_of_date);
            if ($data['author'] == 'Wildcard') {
                $data['author'] = 'default';
            }
            $author = $data['author'];
            if ($data['author_site']) {
                $author = $html->link($data['author_site'], $data['author'], array("style" => 'font-weight: bold;'));
            }
            // author
            $table->construct_cell($author);
            // options pop-up
            $popup = new PopupMenu('module_' . $data['base_name'], $lang->asb_options);
            // delete
            $popup->add_item($lang->asb_delete, $html->url(array("action" => 'delete_addon', "addon" => $data['base_name'])), "return confirm('{$lang->asb_modules_del_warning}');");
            // pop-up cell
            $table->construct_cell($popup->fetch(), array("width" => '10%'));
            // finish row
            $table->construct_row();
        }
    } else {
        $table->construct_cell("<span style=\"color: gray;\">{$lang->asb_no_modules_detected}</span>", array("colspan" => 3));
        $table->construct_row();
    }
    $table->output($lang->asb_addon_modules);
    // build link bar and ACP footer
    asb_output_footer('addons');
}
Example #14
0
function build_theme_list($parent = 0, $depth = 0)
{
    global $mybb, $db, $table, $lang, $page;
    // Global $table is bad, but it will have to do for now
    static $theme_cache;
    $padding = $depth * 20;
    // Padding
    if (!is_array($theme_cache)) {
        $themes = cache_themes();
        $query = $db->query("\n\t\t\tSELECT style, COUNT(uid) AS users\n\t\t\tFROM " . TABLE_PREFIX . "users\n\t\t\tGROUP BY style\n\t\t");
        while ($user_themes = $db->fetch_array($query)) {
            if ($user_themes['style'] == 0) {
                $user_themes['style'] = $themes['default'];
            }
            if ($themes[$user_themes['style']]['users'] > 0) {
                $themes[$user_themes['style']]['users'] += intval($user_themes['users']);
            } else {
                $themes[$user_themes['style']]['users'] = intval($user_themes['users']);
            }
        }
        // Restrucure the theme array to something we can "loop-de-loop" with
        foreach ($themes as $key => $theme) {
            if ($key == "default") {
                continue;
            }
            $theme_cache[$theme['pid']][$theme['tid']] = $theme;
        }
        $theme_cache['num_themes'] = count($themes);
        unset($themes);
    }
    if (!is_array($theme_cache[$parent])) {
        return;
    }
    foreach ($theme_cache[$parent] as $theme) {
        $popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);
        if ($theme['tid'] > 1) {
            $popup->add_item($lang->edit_theme, "index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}");
            $theme['name'] = "<a href=\"index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}\">" . htmlspecialchars_uni($theme['name']) . "</a>";
            // We must have at least the master and 1 other active theme
            if ($theme_cache['num_themes'] > 2) {
                $popup->add_item($lang->delete_theme, "index.php?module=style-themes&amp;action=delete&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')");
            }
            if ($theme['def'] != 1) {
                $popup->add_item($lang->set_as_default, "index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}");
                $set_default = "<a href=\"index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/make_default.gif\" alt=\"{$lang->set_as_default}\" style=\"vertical-align: middle;\" title=\"{$lang->set_as_default}\" /></a>";
            } else {
                $set_default = "<img src=\"styles/{$page->style}/images/icons/default.gif\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />";
            }
            $popup->add_item($lang->force_on_users, "index.php?module=style-themes&amp;action=force&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')");
        }
        $popup->add_item($lang->export_theme, "index.php?module=style-themes&amp;action=export&amp;tid={$theme['tid']}");
        $table->construct_cell("<div class=\"float_right\">{$set_default}</div><div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>");
        $table->construct_cell(my_number_format($theme['users']), array("class" => "align_center"));
        $table->construct_cell($popup->fetch(), array("class" => "align_center"));
        $table->construct_row();
        // Fetch & build any child themes
        build_theme_list($theme['tid'], ++$depth);
    }
}
Example #15
0
             $join_requests = " <small><a href=\"index.php?module=user-groups&amp;action=join_requests&amp;gid={$usergroup['gid']}\"><span style=\"color: red;\">({$joinrequests[$usergroup['gid']]} {$lang->outstanding_join_request})</span></a></small>";
         }
     }
     $form_container->output_cell("<div class=\"float_right\">{$icon}</div><div><strong><a href=\"index.php?module=user-groups&amp;action=edit&amp;gid={$usergroup['gid']}\">" . htmlspecialchars_uni($usergroup['title']) . "</a></strong>{$join_requests}<br /><small>" . htmlspecialchars_uni($usergroup['description']) . "{$leaders_list}</small></div>");
     if (!$primaryusers[$usergroup['gid']]) {
         $primaryusers[$usergroup['gid']] = 0;
     }
     $numusers = $primaryusers[$usergroup['gid']];
     $numusers += $secondaryusers[$usergroup['gid']];
     $form_container->output_cell(my_number_format($numusers), array("class" => "align_center"));
     if ($usergroup['showforumteam'] == 1) {
         $form_container->output_cell("<input type=\"text\" name=\"disporder[{$usergroup['gid']}]\" value=\"{$usergroup['disporder']}\" class=\"text_input align_center\" style=\"width: 80%;\" />", array("class" => "align_center"));
     } else {
         $form_container->output_cell("&nbsp;", array("class" => "align_center"));
     }
     $popup = new PopupMenu("usergroup_{$usergroup['gid']}", $lang->options);
     $popup->add_item($lang->edit_group, "index.php?module=user-groups&amp;action=edit&amp;gid={$usergroup['gid']}");
     $popup->add_item($lang->list_users, "index.php?module=user-users&amp;action=search&amp;results=1&amp;conditions[usergroup]={$usergroup['gid']}");
     if ($joinrequests[$usergroup['gid']] > 0 && $usergroup['type'] == 4) {
         $popup->add_item($lang->join_requests, "index.php?module=user-groups&amp;action=join_requests&amp;gid={$usergroup['gid']}");
     }
     $popup->add_item($lang->group_leaders, "index.php?module=user-groups&amp;action=leaders&amp;gid={$usergroup['gid']}");
     if ($usergroup['type'] > 1) {
         $popup->add_item($lang->delete_group, "index.php?module=user-groups&amp;action=delete&amp;gid={$usergroup['gid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_group_deletion}')");
     }
     $form_container->output_cell($popup->fetch(), array("class" => "align_center"));
     $form_container->construct_row();
 }
 if ($form_container->num_rows() == 0) {
     $form_container->output_cell($lang->no_groups, array('colspan' => 4));
     $form_container->construct_row();
Example #16
0
     }
     $table->construct_row(array('class' => 'alt_row', 'no_alt_row' => 1));
     // Make rows for each setting in the group
     if (is_array($settings_cache[$group['gid']])) {
         foreach ($settings_cache[$group['gid']] as $setting) {
             $setting_lang_var = "setting_{$setting['name']}";
             if ($lang->{$setting_lang_var}) {
                 $setting_title = htmlspecialchars_uni($lang->{$setting_lang_var});
             } else {
                 $setting_title = htmlspecialchars_uni($setting['title']);
             }
             $table->construct_cell($setting_title, array('style' => 'padding-left: 40px;'));
             $table->construct_cell($form->generate_numeric_field("setting_disporder[{$setting['sid']}]", $setting['disporder'], array('style' => 'width: 80%', 'class' => 'align_center', 'min' => 0)));
             // Only show options if not a default setting group or is a custom setting
             if ($group['isdefault'] != 1 || $setting['isdefault'] != 1) {
                 $popup = new PopupMenu("setting_{$setting['sid']}", $lang->options);
                 $popup->add_item($lang->edit_setting, "index.php?module=config-settings&amp;action=edit&amp;sid={$setting['sid']}");
                 $popup->add_item($lang->delete_setting, "index.php?module=config-settings&amp;action=delete&amp;sid={$setting['sid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_setting_deletion}')");
                 $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
             } else {
                 $table->construct_cell('');
             }
             $table->construct_row(array('no_alt_row' => 1, 'class' => "group{$group['gid']}"));
         }
     }
 }
 $table->output($lang->modify_existing_settings);
 $buttons[] = $form->generate_submit_button($lang->save_display_orders);
 $form->output_submit_wrapper($buttons);
 $form->end();
 $page->output_footer();
/**
 * 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();
                }
            }
        }
    }
}
     if (!$done_set[$sid]) {
         $table = new Table();
         $table->construct_header($templatesets[$sid]['title'], array("colspan" => 2));
         $done_set[$sid] = 1;
         ++$count;
     }
     if ($sid == -2) {
         // Some cheeky clown has altered the master templates!
         $table->construct_cell($lang->error_master_templates_altered, array("colspan" => 2));
         $table->construct_row();
     }
     foreach ($templates as $template) {
         if ($sid == -2) {
             $table->construct_cell($template['title'], array('colspan' => 2));
         } else {
             $popup = new PopupMenu("template_{$template['tid']}", $lang->options);
             $popup->add_item($lang->full_edit, "index.php?module=style-templates&amp;action=edit_template&amp;title=" . urlencode($template['title']) . "&amp;sid={$sid}");
             $table->construct_cell("<a href=\"index.php?module=style-templates&amp;action=edit_template&amp;title=" . urlencode($template['title']) . "&amp;sid={$sid}&amp;from=diff_report\">{$template['title']}</a>", array('width' => '80%'));
             $table->construct_cell($popup->fetch(), array("class" => "align_center"));
         }
         $table->construct_row();
     }
     if ($done_set[$sid] && !$done_output[$sid]) {
         $done_output[$sid] = 1;
         if ($count == 1) {
             $table->output($lang->check_templates);
         } else {
             $table->output();
         }
     }
 }
            $table->construct_cell(number_format($data['hits']), array('width' => '25%'));
            $table->construct_cell(cloudflare_threat_score($data['ip']), array('width' => '25%'));
            if (function_exists('geoip_record_by_name')) {
                $ip_record = @geoip_record_by_name($data['ip']);
                if ($ip_record) {
                    $ipaddress_location = htmlspecialchars_uni($ip_record['country_name']);
                    if ($ip_record['city']) {
                        $ipaddress_location .= $lang->comma . htmlspecialchars_uni($ip_record['city']);
                    }
                    $table->construct_cell($ipaddress_location, array('width' => '25%'));
                } else {
                    $table->construct_cell('N/A', array('width' => '25%'));
                }
            }
            $dns = @gethostbyaddr($data['ip']);
            if ($dns == $data['ip']) {
                $dns = 'N/A';
            }
            $dns = htmlspecialchars_uni($dns);
            $table->construct_cell($dns, array('width' => '25%'));
            $popup = new PopupMenu("rv_options_" . $number, "Options");
            $popup->add_item("Black List", "index.php?module=cloudflare-blacklist&action=run&my_post_key={$mybb->post_code}&address={$data['ip']}&submit=Black List");
            $popup->add_item("White List", "index.php?module=cloudflare-whitelist&action=run&my_post_key={$mybb->post_code}&address={$data['ip']}&submit=White List");
            $controls = $popup->fetch();
            $table->construct_cell($controls, array('width' => '5%'));
            $table->construct_row();
        }
    }
    $table->output("Top Threats");
    $page->output_footer();
}
Example #20
0
                     $sep = " {$lang->and} ";
                 }
                 $color_list .= $sep . trim($color);
                 ++$count;
                 $sep = ', ';
             }
             $attached_to = "<small>{$lang->attached_to} " . $lang->sprintf($lang->colors_attached_to) . " {$color_list}</small>";
         }
         if ($attached_to == '') {
             // Orphaned! :(
             $attached_to = "<small>{$lang->attached_to_nothing}</small>";
         }
     } else {
         $attached_to = "<small>{$lang->attached_to_all_pages}</small>";
     }
     $popup = new PopupMenu("style_{$style['sid']}", $lang->options);
     $popup->add_item($lang->edit_style, "index.php?module=style-themes&amp;action=edit_stylesheet&amp;file=" . htmlspecialchars_uni($filename) . "&amp;tid={$theme['tid']}");
     $popup->add_item($lang->properties, "index.php?module=style-themes&amp;action=stylesheet_properties&amp;file=" . htmlspecialchars_uni($filename) . "&amp;tid={$theme['tid']}");
     if ($inherited == "") {
         $popup->add_item($lang->delete_revert, "index.php?module=style-themes&amp;action=delete_stylesheet&amp;file=" . htmlspecialchars_uni($filename) . "&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_stylesheet_deletion}')");
     }
     $table->construct_cell("<strong><a href=\"index.php?module=style-themes&amp;action=edit_stylesheet&amp;file=" . htmlspecialchars_uni($filename) . "&amp;tid={$theme['tid']}\">{$filename}</a></strong>{$inherited}<br />{$attached_to}");
     $table->construct_cell($form->generate_numeric_field("disporder[{$theme_stylesheets[$filename]['sid']}]", $properties['disporder'][$filename], array('style' => 'width: 80%; text-align: center;', 'min' => 0)), array("class" => "align_center"));
     $table->construct_cell($popup->fetch(), array("class" => "align_center"));
     $table->construct_row();
 }
 $table->output("{$lang->stylesheets_in} " . htmlspecialchars_uni($theme['name']));
 $buttons = array($form->generate_submit_button($lang->save_stylesheet_order));
 $form->output_submit_wrapper($buttons);
 $form->end();
 echo '<br />';
Example #21
0
function build_users_view($view)
{
    global $mybb, $db, $cache, $lang, $user_view_fields, $page;
    $view_title = '';
    if ($view['title']) {
        $title_string = "view_title_{$view['vid']}";
        if ($lang->{$title_string}) {
            $view['title'] = $lang->{$title_string};
        }
        $view_title .= " (" . htmlspecialchars_uni($view['title']) . ")";
    }
    // Build the URL to this view
    if (!isset($view['url'])) {
        $view['url'] = "index.php?module=user-users";
    }
    if (!is_array($view['conditions'])) {
        $view['conditions'] = unserialize($view['conditions']);
    }
    if (!is_array($view['fields'])) {
        $view['fields'] = unserialize($view['fields']);
    }
    if (!is_array($view['custom_profile_fields'])) {
        $view['custom_profile_fields'] = unserialize($view['custom_profile_fields']);
    }
    if (isset($mybb->input['username'])) {
        $view['conditions']['username'] = $mybb->input['username'];
    }
    if ($view['vid']) {
        $view['url'] .= "&amp;vid={$view['vid']}";
    } else {
        // If this is a custom view we need to save everything ready to pass it on from page to page
        global $admin_session;
        if (!$mybb->input['search_id']) {
            $search_id = md5(random_str());
            $admin_session['data']['user_views'][$search_id] = $view;
            update_admin_session('user_views', $admin_session['data']['user_views']);
            $mybb->input['search_id'] = $search_id;
        }
        $view['url'] .= "&amp;search_id=" . htmlspecialchars_uni($mybb->input['search_id']);
    }
    if (isset($mybb->input['username'])) {
        $view['url'] .= "&amp;username="******"&amp;", "&", $view['url'])) {
        update_admin_session('last_users_url', str_replace("&amp;", "&", $view['url']));
    }
    if (isset($view['conditions']['referrer'])) {
        $view['url'] .= "&amp;action=referrers&amp;uid=" . htmlspecialchars_uni($view['conditions']['referrer']);
    }
    // Do we not have any views?
    if (empty($view)) {
        return false;
    }
    $table = new Table();
    // Build header for table based view
    if ($view['view_type'] != "card") {
        foreach ($view['fields'] as $field) {
            if (!$user_view_fields[$field]) {
                continue;
            }
            $view_field = $user_view_fields[$field];
            $field_options = array();
            if ($view_field['width']) {
                $field_options['width'] = $view_field['width'];
            }
            if ($view_field['align']) {
                $field_options['class'] = "align_" . $view_field['align'];
            }
            $table->construct_header($view_field['title'], $field_options);
        }
        $table->construct_header("<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this);\" />");
        // Create a header for the "select" boxes
    }
    $search_sql = '1=1';
    // Build the search SQL for users
    // List of valid LIKE search fields
    $user_like_fields = array("username", "email", "website", "icq", "aim", "yahoo", "msn", "signature", "usertitle");
    foreach ($user_like_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && !$view['conditions'][$search_field . '_blank']) {
            $search_sql .= " AND u.{$search_field} LIKE '%" . $db->escape_string_like($view['conditions'][$search_field]) . "%'";
        } else {
            if (!empty($view['conditions'][$search_field . '_blank'])) {
                $search_sql .= " AND u.{$search_field} != ''";
            }
        }
    }
    // EXACT matching fields
    $user_exact_fields = array("referrer");
    foreach ($user_exact_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            $search_sql .= " AND u.{$search_field}='" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // LESS THAN or GREATER THAN
    $direction_fields = array("postnum");
    foreach ($direction_fields as $search_field) {
        $direction_field = $search_field . "_dir";
        if (isset($view['conditions'][$search_field]) && ($view['conditions'][$search_field] || $view['conditions'][$search_field] === '0') && $view['conditions'][$direction_field]) {
            switch ($view['conditions'][$direction_field]) {
                case "greater_than":
                    $direction = ">";
                    break;
                case "less_than":
                    $direction = "<";
                    break;
                default:
                    $direction = "=";
            }
            $search_sql .= " AND u.{$search_field}{$direction}'" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // Registration searching
    $reg_fields = array("regdate");
    foreach ($reg_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && intval($view['conditions'][$search_field])) {
            $threshold = TIME_NOW - intval($view['conditions'][$search_field]) * 24 * 60 * 60;
            $search_sql .= " AND u.{$search_field} >= '{$threshold}'";
        }
    }
    // IP searching
    $ip_fields = array("regip", "lastip");
    foreach ($ip_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            // IPv6 IP
            if (strpos($view['conditions'][$search_field], ":") !== false) {
                $view['conditions'][$search_field] = str_replace("*", "%", $view['conditions'][$search_field]);
                $ip_sql = "{$search_field} LIKE '" . $db->escape_string($view['conditions'][$search_field]) . "'";
            } else {
                $ip_range = fetch_longipv4_range($view['conditions'][$search_field]);
                if (!is_array($ip_range)) {
                    $ip_sql = "long{$search_field}='{$ip_range}'";
                } else {
                    $ip_sql = "long{$search_field} > '{$ip_range[0]}' AND long{$search_field} < '{$ip_range[1]}'";
                }
            }
            $search_sql .= " AND {$ip_sql}";
        }
    }
    // Post IP searching
    if (!empty($view['conditions']['postip'])) {
        // IPv6 IP
        if (strpos($view['conditions']['postip'], ":") !== false) {
            $view['conditions']['postip'] = str_replace("*", "%", $view['conditions']['postip']);
            $ip_sql = "ipaddress LIKE '" . $db->escape_string($view['conditions']['postip']) . "'";
        } else {
            $ip_range = fetch_longipv4_range($view['conditions']['postip']);
            if (!is_array($ip_range)) {
                $ip_sql = "longipaddress='{$ip_range}'";
            } else {
                $ip_sql = "longipaddress > '{$ip_range[0]}' AND longipaddress < '{$ip_range[1]}'";
            }
        }
        $ip_uids = array(0);
        $query = $db->simple_select("posts", "uid", $ip_sql);
        while ($uid = $db->fetch_field($query, "uid")) {
            $ip_uids[] = $uid;
        }
        $search_sql .= " AND u.uid IN(" . implode(',', $ip_uids) . ")";
        unset($ip_uids);
    }
    // Custom Profile Field searching
    if ($view['custom_profile_fields']) {
        $userfield_sql = '1=1';
        foreach ($view['custom_profile_fields'] as $column => $input) {
            if (is_array($input)) {
                foreach ($input as $value => $text) {
                    if ($value == $column) {
                        $value = $text;
                    }
                    if ($value == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . "='" . $db->escape_string($value) . "'";
                    }
                }
            } else {
                if (!empty($input)) {
                    if ($input == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " LIKE '%" . $db->escape_string($input) . "%'";
                    }
                }
            }
        }
        if ($userfield_sql != '1=1') {
            $userfield_uids = array(0);
            $query = $db->simple_select("userfields", "ufid", $userfield_sql);
            while ($userfield = $db->fetch_array($query)) {
                $userfield_uids[] = $userfield['ufid'];
            }
            $search_sql .= " AND u.uid IN(" . implode(',', $userfield_uids) . ")";
            unset($userfield_uids);
        }
    }
    // Usergroup based searching
    if (isset($view['conditions']['usergroup'])) {
        if (!is_array($view['conditions']['usergroup'])) {
            $view['conditions']['usergroup'] = array($view['conditions']['usergroup']);
        }
        foreach ($view['conditions']['usergroup'] as $usergroup) {
            $usergroup = intval($usergroup);
            if (!$usergroup) {
                continue;
            }
            switch ($db->type) {
                case "pgsql":
                case "sqlite":
                    $additional_sql .= " OR ','||additionalgroups||',' LIKE '%,{$usergroup},%'";
                    break;
                default:
                    $additional_sql .= "OR CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup},%'";
            }
        }
        $search_sql .= " AND (u.usergroup IN (" . implode(",", array_map('intval', $view['conditions']['usergroup'])) . ") {$additional_sql})";
    }
    // COPPA users only?
    if (isset($view['conditions']['coppa'])) {
        $search_sql .= " AND u.coppauser=1 AND u.usergroup=5";
    }
    // Extra SQL?
    if (isset($view['extra_sql'])) {
        $search_sql .= $view['extra_sql'];
    }
    // Lets fetch out how many results we have
    $query = $db->query("\n\t\tSELECT COUNT(u.uid) AS num_results\n\t\tFROM " . TABLE_PREFIX . "users u\n\t\tWHERE {$search_sql}\n\t");
    $num_results = $db->fetch_field($query, "num_results");
    // No matching results then return false
    if (!$num_results) {
        return false;
    } else {
        if (!$view['perpage']) {
            $view['perpage'] = 20;
        }
        $view['perpage'] = intval($view['perpage']);
        // Establish which page we're viewing and the starting index for querying
        // Establish which page we're viewing and the starting index for querying
        if (!isset($mybb->input['page'])) {
            $mybb->input['page'] = 1;
        } else {
            $mybb->input['page'] = intval($mybb->input['page']);
        }
        if ($mybb->input['page']) {
            $start = ($mybb->input['page'] - 1) * $view['perpage'];
        } else {
            $start = 0;
            $mybb->input['page'] = 1;
        }
        $from_bit = "";
        if (isset($mybb->input['from']) && $mybb->input['from'] == "home") {
            $from_bit = "&amp;from=home";
        }
        switch ($view['sortby']) {
            case "regdate":
            case "lastactive":
            case "postnum":
            case "reputation":
                $view['sortby'] = $db->escape_string($view['sortby']);
                break;
            case "numposts":
                $view['sortby'] = "postnum";
                break;
            case "warninglevel":
                $view['sortby'] = "warningpoints";
                break;
            default:
                $view['sortby'] = "username";
        }
        if ($view['sortorder'] != "desc") {
            $view['sortorder'] = "asc";
        }
        $usergroups = $cache->read("usergroups");
        // Fetch matching users
        $query = $db->query("\n\t\t\tSELECT u.*\n\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\tWHERE {$search_sql}\n\t\t\tORDER BY {$view['sortby']} {$view['sortorder']}\n\t\t\tLIMIT {$start}, {$view['perpage']}\n\t\t");
        $users = '';
        while ($user = $db->fetch_array($query)) {
            $comma = $groups_list = '';
            $user['view']['username'] = "******"index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}\">" . format_name($user['username'], $user['usergroup'], $user['displaygroup']) . "</a>";
            $user['view']['usergroup'] = htmlspecialchars_uni($usergroups[$user['usergroup']]['title']);
            if ($user['additionalgroups']) {
                $additional_groups = explode(",", $user['additionalgroups']);
                foreach ($additional_groups as $group) {
                    $groups_list .= $comma . htmlspecialchars_uni($usergroups[$group]['title']);
                    $comma = $lang->comma;
                }
            }
            if (!$groups_list) {
                $groups_list = $lang->none;
            }
            $user['view']['additionalgroups'] = "<small>{$groups_list}</small>";
            $user['view']['email'] = "<a href=\"mailto:" . htmlspecialchars_uni($user['email']) . "\">" . htmlspecialchars_uni($user['email']) . "</a>";
            $user['view']['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']) . ", " . my_date($mybb->settings['timeformat'], $user['regdate']);
            $user['view']['lastactive'] = my_date($mybb->settings['dateformat'], $user['lastactive']) . ", " . my_date($mybb->settings['timeformat'], $user['lastactive']);
            // Build popup menu
            $popup = new PopupMenu("user_{$user['uid']}", $lang->options);
            $popup->add_item($lang->edit_profile_and_settings, "index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}");
            $popup->add_item($lang->ban_user, "index.php?module=user-banning&amp;uid={$user['uid']}#username");
            if ($user['usergroup'] == 5) {
                if ($user['coppauser']) {
                    $popup->add_item($lang->approve_coppa_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                } else {
                    $popup->add_item($lang->approve_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                }
            }
            $popup->add_item($lang->delete_user, "index.php?module=user-users&amp;action=delete&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->user_deletion_confirmation}')");
            $popup->add_item($lang->show_referred_users, "index.php?module=user-users&amp;action=referrers&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_ip_addresses, "index.php?module=user-users&amp;action=ipaddresses&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_attachments, "index.php?module=forum-attachments&amp;results=1&amp;username="******"-";
            }
            if ($mybb->settings['enablewarningsystem'] != 0 && $usergroups[$user['usergroup']]['canreceivewarnings'] != 0) {
                $warning_level = round($user['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
                if ($warning_level > 100) {
                    $warning_level = 100;
                }
                $user['view']['warninglevel'] = get_colored_warning_level($warning_level);
            }
            if ($user['avatar'] && !stristr($user['avatar'], 'http://')) {
                $user['avatar'] = "../{$user['avatar']}";
            }
            if ($view['view_type'] == "card") {
                $scaled_avatar = fetch_scaled_avatar($user, 80, 80);
            } else {
                $scaled_avatar = fetch_scaled_avatar($user, 34, 34);
            }
            if (!$user['avatar']) {
                $user['avatar'] = "styles/{$page->style}/images/default_avatar.gif";
            }
            $user['view']['avatar'] = "<img src=\"" . htmlspecialchars_uni($user['avatar']) . "\" alt=\"\" width=\"{$scaled_avatar['width']}\" height=\"{$scaled_avatar['height']}\" />";
            if ($view['view_type'] == "card") {
                $users .= build_user_view_card($user, $view, $i);
            } else {
                build_user_view_table($user, $view, $table);
            }
        }
        // If card view, we need to output the results
        if ($view['view_type'] == "card") {
            $table->construct_cell($users);
            $table->construct_row();
        }
    }
    if (!isset($view['table_id'])) {
        $view['table_id'] = "users_list";
    }
    $switch_view = "<div class=\"float_right\">";
    $switch_url = $view['url'];
    if ($mybb->input['page'] > 0) {
        $switch_url .= "&amp;page=" . intval($mybb->input['page']);
    }
    if ($view['view_type'] != "card") {
        $switch_view .= "<strong>{$lang->table_view}</strong> | <a href=\"{$switch_url}&amp;type=card\" style=\"font-weight: normal;\">{$lang->card_view}</a>";
    } else {
        $switch_view .= "<a href=\"{$switch_url}&amp;type=table\" style=\"font-weight: normal;\">{$lang->table_view}</a> | <strong>{$lang->card_view}</strong>";
    }
    $switch_view .= "</div>";
    // Do we need to construct the pagination?
    if ($num_results > $view['perpage']) {
        $pagination = draw_admin_pagination($mybb->input['page'], $view['perpage'], $num_results, $view['url'] . "&amp;type={$view['view_type']}");
        $search_class = "float_right";
        $search_style = "";
    } else {
        $search_class = '';
        $search_style = "text-align: right;";
    }
    $search_action = $view['url'];
    // stop &username= in the query string
    if ($view_upos = strpos($search_action, '&amp;username='******'post', 'search_form', 0, '', true);
    $built_view = $search->construct_return;
    $built_view .= "<div class=\"{$search_class}\" style=\"padding-bottom: 3px; margin-top: -9px; {$search_style}\">";
    $built_view .= $search->generate_hidden_field('action', 'search') . "\n";
    if (isset($view['conditions']['username'])) {
        $default_class = '';
        $value = $view['conditions']['username'];
    } else {
        $default_class = "search_default";
        $value = $lang->search_for_user;
    }
    $built_view .= $search->generate_text_box('username', $value, array('id' => 'search_keywords', 'class' => "{$default_class} field150 field_small")) . "\n";
    $built_view .= "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />\n";
    if ($view['popup']) {
        $built_view .= " <div style=\"display: inline\">{$view['popup']}</div>\n";
    }
    $built_view .= "<script type='text/javascript'>\n\t\tvar form = document.getElementById('search_form');\n\t\tform.onsubmit = function() {\n\t\t\tvar search = document.getElementById('search_keywords');\n\t\t\tif(search.value == '' || search.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\tsearch.focus();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tvar search = document.getElementById('search_keywords');\n\t\tsearch.onfocus = function()\n\t\t{\n\t\t\tif(this.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\t\$(this).removeClassName('search_default');\n\t\t\t\tthis.value = '';\n\t\t\t}\n\t\t}\n\t\tsearch.onblur = function()\n\t\t{\n\t\t\tif(this.value == '')\n\t\t\t{\n\t\t\t\t\$(this).addClassName('search_default');\n\t\t\t\tthis.value = '" . addcslashes($lang->search_for_user, "'") . "';\n\t\t\t}\n\t\t}\n\t\t// fix the styling used if we have a different default value\n\t\tif(search.value != '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t{\n\t\t\t\$(search).removeClassName('search_default');\n\t\t}\n\t\t</script>\n";
    $built_view .= "</div>\n";
    // Autocompletion for usernames
    $built_view .= '
	<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
	<script type="text/javascript">
	<!--
		new autoComplete("search_keywords", "../xmlhttp.php?action=get_users", {valueSpan: "username"});
	// -->
	</script>';
    $built_view .= $search->end();
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    if ($view['view_type'] != "card") {
        $checkbox = '';
    } else {
        $checkbox = "<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this)\" /> ";
    }
    $built_view .= $table->construct_html("{$switch_view}<div>{$checkbox}{$lang->users}{$view_title}</div>", 1, "", $view['table_id']);
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    $built_view .= '
<script type="text/javascript" src="' . $mybb->settings['bburl'] . '/jscripts/inline_moderation.js?ver=1400"></script>
<form action="index.php?module=user-users" method="post">
<input type="hidden" name="my_post_key" value="' . $mybb->post_code . '" />
<input type="hidden" name="action" value="inline_edit" />
<div class="float_right"><span class="smalltext"><strong>' . $lang->inline_edit . '</strong></span>
<select name="inline_action" class="inline_select">
	<option value="multiactivate">' . $lang->inline_activate . '</option>
	<option value="multiban">' . $lang->inline_ban . '</option>
	<option value="multiusergroup">' . $lang->inline_usergroup . '</option>
	<option value="multidelete">' . $lang->inline_delete . '</option>
	<option value="multiprune">' . $lang->inline_prune . '</option>
</select>
<input type="submit" class="button" name="go" value="' . $lang->go . ' (0)" id="inline_go" />&nbsp;
<input type="button" onclick="javascript:inlineModeration.clearChecked();" value="' . $lang->clear . '" class="button" />
</div>
</form>
<br style="clear: both;" />
<script type="text/javascript">
<!--
	var go_text = "' . $lang->go . '";
	var all_text = "1";
	var inlineType = "user";
	var inlineId = "acp";
// -->
</script>';
    return $built_view;
}
Example #22
0
    } else {
        if ($mybb->request_method == 'post' && $mybb->get_input('action') == 'updatedisporder') {
            foreach ($mybb->get_input('disporder', 2) as $cid => $disporder) {
                $ougc_pages->update_category(array('disporder' => $disporder), $cid);
            }
            $ougc_pages->update_cache();
            $ougc_pages->redirect();
        }
        echo $multipage;
        $query = $db->simple_select('ougc_pages_categories', '*', '', array('limit_start' => $ougc_pages->query_start, 'limit' => $ougc_pages->query_limit, 'order_by' => 'disporder'));
        $form = new Form($ougc_pages->build_url('action=updatedisporder'), 'post');
        while ($category = $db->fetch_array($query)) {
            $manage_link = $ougc_pages->build_url(array('manage' => 'pages', 'cid' => $category['cid']));
            $category['name'] = htmlspecialchars_uni($category['name']);
            $category['visible'] or $category['name'] = '<em>' . $category['name'] . '</em>';
            $table->construct_cell('<a href="' . $manage_link . '"><strong>' . $category['name'] . '</strong></a> <span style="font-size: 90%">(' . $ougc_pages->build_category_link($lang->ougc_pages_view_page, $category['cid']) . ')</span>');
            $table->construct_cell($form->generate_text_box('disporder[' . $category['cid'] . ']', (int) $category['disporder'], array('style' => 'text-align: center; width: 30px;')), array('class' => 'align_center'));
            $table->construct_cell('<a href="' . $ougc_pages->build_url(array('action' => 'update', 'cid' => $category['cid'], 'my_post_key' => $mybb->post_code)) . '"><img src="styles/default/images/icons/bullet_o' . (!$category['visible'] ? 'ff' : 'n') . '.png" alt="" title="' . (!$category['visible'] ? $lang->ougc_pages_form_disabled : $lang->ougc_pages_form_visible) . '" /></a>', array('class' => 'align_center'));
            $popup = new PopupMenu('category_' . $category['cid'], $lang->options);
            $popup->add_item($lang->ougc_pages_manage, $manage_link);
            $popup->add_item($lang->edit, $ougc_pages->build_url(array('action' => 'edit', 'cid' => $category['cid'])));
            $popup->add_item($lang->delete, $ougc_pages->build_url(array('action' => 'delete', 'cid' => $category['cid'])));
            $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
            $table->construct_row();
        }
        $table->output($sub_tabs['ougc_pages_cat_view']['title']);
        $form->output_submit_wrapper(array($form->generate_submit_button($lang->ougc_pages_button_disponder), $form->generate_reset_button($lang->reset)));
        $form->end();
    }
    $page->output_footer();
}