Example #1
0
function myalerts_acp_manage_alert_types()
{
    global $mybb, $lang, $page, $db, $cache;
    $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
    $alertTypes = $alertTypeManager->getAlertTypes();
    if (strtolower($mybb->request_method) == 'post') {
        if (!verify_post_check($mybb->get_input('my_post_key'))) {
            flash_message($lang->invalid_post_verify_key2, 'error');
            admin_redirect("index.php?module=config-myalerts_alert_types");
        }
        $enabledAlertTypes = $mybb->get_input('alert_types_enabled', MyBB::INPUT_ARRAY);
        $canBeUserDisabled = $mybb->get_input('alert_types_can_be_user_disabled', MyBB::INPUT_ARRAY);
        $enabledAlertTypes = array_map('intval', array_keys($enabledAlertTypes));
        $canBeUserDisabled = array_map('intval', array_keys($canBeUserDisabled));
        $updateArray = array();
        foreach ($alertTypes as $alertType) {
            $type = MybbStuff_MyAlerts_Entity_AlertType::unserialize($alertType);
            $type->setEnabled(in_array($type->getId(), $enabledAlertTypes));
            $type->setCanBeUserDisabled(in_array($type->getId(), $canBeUserDisabled));
            $updateArray[] = $type;
        }
        $alertTypeManager->updateAlertTypes($updateArray);
        flash_message($lang->myalerts_alert_types_updated, 'success');
        admin_redirect("index.php?module=config-myalerts_alert_types");
    } else {
        $page->output_header($lang->myalerts_alert_types);
        $form = new Form('index.php?module=config-myalerts_alert_types', 'post');
        $table = new Table();
        $table->construct_header($lang->myalerts_alert_type_code);
        $table->construct_header($lang->myalerts_alert_type_enabled, array('width' => '5%', 'class' => 'align_center'));
        $table->construct_header($lang->myalerts_alert_type_can_be_user_disabled, array('width' => '10%', 'class' => 'align_center'));
        $noResults = false;
        if (!empty($alertTypes)) {
            foreach ($alertTypes as $type) {
                $alertCode = htmlspecialchars_uni($type['code']);
                $table->construct_cell($alertCode);
                $table->construct_cell($form->generate_check_box('alert_types_enabled[' . $type['id'] . ']', '', '', array('checked' => $type['enabled'])));
                $table->construct_cell($form->generate_check_box('alert_types_can_be_user_disabled[' . $type['id'] . ']', '', '', array('checked' => $type['can_be_user_disabled'])));
                $table->construct_row();
            }
        } else {
            $table->construct_cell($lang->myalerts_no_alert_types, array('colspan' => 2));
            $table->construct_row();
            $noResults = true;
        }
        $table->output($lang->myalerts_alert_types);
        if (!$noResults) {
            $buttons[] = $form->generate_submit_button($lang->myalerts_update_alert_types);
            $form->output_submit_wrapper($buttons);
        }
        $form->end();
        $page->output_footer();
    }
}
Example #2
0
function jb_update_core()
{
    $auto = jb_download_core();
    if ($auto === false) {
        global $page;
        $page->output_header(JB_Lang::get("update_failed"));
        $table = new Table();
        $table->construct_header(JB_Lang::get("attention"));
        $table->construct_cell(JB_Lang::get("update_get"));
        $table->construct_row();
        $table->output(JB_Lang::get("update_failed"));
        $page->output_footer();
        exit;
    }
}
function main_page()
{
    global $cloudflare, $mybb;
    $request = $cloudflare->get_access_rules();
    $table = new Table();
    $table->construct_header("Mode");
    $table->construct_header("IP Address");
    $table->construct_header("Notes");
    $table->construct_header("Modify");
    foreach ($request->result as $rule) {
        $table->construct_cell($rule->mode);
        $table->construct_cell($rule->configuration->value);
        $table->construct_cell($rule->notes);
        $table->construct_cell("<a href=\"index.php?module=cloudflare-manage_firewall&action=modify_rule_by_ip&ip={$rule->configuration->value}&my_post_key={$mybb->post_code}&current_mode={$rule->mode}&current_notes={$rule->notes}\">Modify</a>&nbsp;/&nbsp;<a href=\"index.php?module=cloudflare-manage_firewall&action=delete_rule_by_id&rule_id={$rule->id}&ip_address={$rule->configuration->value}&my_post_key={$mybb->post_code}\">Delete</a>");
        $table->construct_row();
    }
    $table->output("Firewall Rules");
}
            $attachment['postsubject'] = htmlspecialchars_uni($attachment['postsubject']);
            $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
            $attachment['threadsubject'] = htmlspecialchars_uni($attachment['threadsubject']);
            $attachment['filesize'] = get_friendly_size($attachment['filesize']);
            $link = get_post_link($attachment['pid'], $attachment['tid']) . "#pid{$attachment['pid']}";
            $thread_link = get_thread_link($attachment['tid']);
            $profile_link = build_profile_link($attachment['username'], $attachment['uid']);
            $table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a> ({$attachment['filesize']})<br /><small class=\"modqueue_meta\">{$lang->post} <a href=\"{$link}\">{$attachment['postsubject']}</a></small>");
            $table->construct_cell($profile_link, array("class" => "align_center"));
            $table->construct_cell("{$attachdate}, {$attachtime}", array("class" => "align_center"));
            $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true)), array("class" => "align_center"));
            $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false)), array("class" => "align_center"));
            $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)), array("class" => "align_center"));
            $table->construct_row();
        }
        $table->output($lang->attachments_awaiting_moderation);
        echo $all_options;
        echo $pagination;
        $buttons[] = $form->generate_submit_button($lang->perform_action);
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    } else {
        if ($mybb->input['type'] == "attachments") {
            $page->output_header($lang->moderation_queue);
            $page->output_nav_tabs($sub_tabs, "attachments");
            echo "<p class=\"notice\">{$lang->error_no_attachments}</p>";
            $page->output_footer();
        }
    }
}
Example #5
0
     }
     if ($logitem['psubject']) {
         $information .= "<strong>{$lang->post}</strong> <a href=\"../" . get_post_link($logitem['pid']) . "#pid{$logitem['pid']}\">" . htmlspecialchars_uni($logitem['psubject']) . "</a>";
     }
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], array("class" => "align_center"));
     $table->construct_cell($logitem['action'], array("class" => "align_center"));
     $table->construct_cell($information);
     $table->construct_cell($logitem['ipaddress'], array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_modlogs, array("colspan" => "5"));
     $table->construct_row();
 }
 $table->output($lang->mod_logs);
 // Do we need to construct the pagination?
 if ($rescount > $perpage) {
     echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools/modlog&amp;perpage={$perpage}&amp;uid={$mybb->input['uid']}&amp;fid={$mybb->input['fid']}&amp;sortby={$mybb->input['sortby']}&amp;order={$order}") . "<br />";
 }
 // Fetch filter options
 $sortbysel[$mybb->input['sortby']] = "selected=\"selected\"";
 $ordersel[$mybb->input['order']] = "selected=\"selected\"";
 $user_options[''] = $lang->all_moderators;
 $user_options['0'] = '----------';
 $query = $db->query("\n\t\tSELECT DISTINCT l.uid, u.username\n\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (l.uid=u.uid)\n\t\tORDER BY u.username ASC\n\t");
 while ($user = $db->fetch_array($query)) {
     $selected = '';
     if ($mybb->input['uid'] == $user['uid']) {
         $selected = "selected=\"selected\"";
     }
Example #6
0
         my_unsetcookie("inlinemod_useracp");
         flash_message($lang->success_mass_usergroups, 'success');
         admin_redirect("index.php?module=user-users" . $vid_url);
     } else {
         // They tried to edit super admins! Uh-oh!
         $errors[] = $lang->no_usergroup_changed;
     }
 }
 $page->output_header($lang->manage_users);
 $page->output_nav_tabs($sub_tabs, 'manage_users');
 // Display a table warning
 $table = new Table();
 $lang->usergroup_info = $lang->sprintf($lang->usergroup_info, count($selected));
 $table->construct_cell($lang->usergroup_info);
 $table->construct_row();
 $table->output($lang->important);
 if ($errors) {
     $page->output_inline_error($errors);
 }
 // Display the usergroup options
 $form = new Form("index.php?module=user-users", "post");
 echo $form->generate_hidden_field('action', 'inline_edit');
 echo $form->generate_hidden_field('inline_action', 'multiusergroup');
 echo $form->generate_hidden_field('processed', '1');
 $form_container = new FormContainer($lang->mass_usergroups);
 // Usergroups
 $display_group_options[0] = $lang->use_primary_user_group;
 $options = array();
 $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title'));
 while ($usergroup = $db->fetch_array($query)) {
     $options[$usergroup['gid']] = htmlspecialchars_uni($usergroup['title']);
function akismet_admin()
{
    global $mybb, $db, $page, $lang;
    if ($page->active_action != "akismet") {
        return;
    }
    $page->add_breadcrumb_item($lang->akismet);
    if ($mybb->input['delete_all'] && $mybb->request_method == "post") {
        // User clicked no
        if ($mybb->input['no']) {
            admin_redirect("index.php?module=forum-akismet");
        }
        if ($mybb->request_method == "post") {
            // Delete the template
            $db->delete_query("posts", "visible = '-4'");
            // Log admin action
            log_admin_action();
            flash_message($lang->success_deleted_spam, 'success');
            admin_redirect("index.php?module=forum-akismet");
        } else {
            $page->output_confirm_action("index.php?module=forum-akismet&amp;delete_all=1", $lang->confirm_spam_deletion);
        }
    }
    if ($mybb->input['unmark'] && $mybb->request_method == "post") {
        $unmark = $mybb->input['akismet'];
        if (empty($unmark)) {
            flash_message($lang->error_unmark, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($unmark as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        $thread_list = implode(',', $threadp);
        $query = $db->query("\r\n\t\t\tSELECT p.tid, f.usepostcounts, p.uid, p.fid, p.dateline, p.replyto, t.lastpost, t.lastposter, t.lastposteruid, t.subject\r\n\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=p.fid)\r\n\t\t\tWHERE p.pid IN ({$posts_in}) AND p.visible = '-4'\r\n\t\t");
        while ($post = $db->fetch_array($query)) {
            // Fetch the last post for this forum
            $query2 = $db->query("\r\n\t\t\t\tSELECT tid, lastpost, lastposter, lastposteruid, subject\r\n\t\t\t\tFROM " . TABLE_PREFIX . "threads\r\n\t\t\t\tWHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'\r\n\t\t\t\tORDER BY lastpost DESC\r\n\t\t\t\tLIMIT 0, 1\r\n\t\t\t");
            $lastpost = $db->fetch_array($query2);
            if ($post['lastpost'] > $lastpost['lastpost']) {
                $lastpost['lastpost'] = $post['lastpost'];
                $lastpost['lastposter'] = $post['lastposter'];
                $lastpost['lastposteruid'] = $post['lastposteruid'];
                $lastpost['subject'] = $post['subject'];
                $lastpost['tid'] = $post['tid'];
            }
            $update_count = array("lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']));
            $db->update_query("forums", $update_count, "fid='{$post['fid']}'");
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}' AND p.visible='1' OR p.pid = '{$post['pid']}'\r\n\t\t\t\tORDER BY p.dateline DESC\r\n\t\t\t\tLIMIT 1");
            $lastpost = $db->fetch_array($query2);
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}'\r\n\t\t\t\tORDER BY p.dateline ASC\r\n\t\t\t\tLIMIT 0,1\r\n\t\t\t");
            $firstpost = $db->fetch_array($query2);
            if (!$firstpost['username']) {
                $firstpost['username'] = $firstpost['postusername'];
            }
            if (!$lastpost['username']) {
                $lastpost['username'] = $lastpost['postusername'];
            }
            if (!$lastpost['dateline']) {
                $lastpost['username'] = $firstpost['username'];
                $lastpost['uid'] = $firstpost['uid'];
                $lastpost['dateline'] = $firstpost['dateline'];
            }
            $lastpost['username'] = $db->escape_string($lastpost['username']);
            $firstpost['username'] = $db->escape_string($firstpost['username']);
            $query2 = $db->simple_select("users", "akismetstopped", "uid='{$post['uid']}'");
            $akismetstopped = $db->fetch_field($query2, "akismetstopped") - 1;
            if ($akismetstopped < 0) {
                $akismetstopped = 0;
            }
            $db->update_query("users", array('akismetstopped' => $akismetstopped), "uid='{$post['uid']}'");
            $update_array = array('username' => $firstpost['username'], 'uid' => intval($firstpost['uid']), 'lastpost' => intval($lastpost['dateline']), 'lastposter' => $lastpost['username'], 'lastposteruid' => intval($lastpost['uid']));
            $db->update_query("threads", $update_array, "tid='{$post['tid']}'");
            if ($post['usepostcounts'] != 0) {
                $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum+1 WHERE uid = '{$post['uid']}'");
            }
            $newthreads = $newreplies = 0;
            if ($post['replyto'] == 0) {
                ++$newthreads;
            } else {
                ++$newreplies;
            }
            update_thread_counters($post['tid'], array('replies' => '+' . $newreplies));
            update_forum_counters($post['fid'], array('threads' => '+' . $newthreads, 'posts' => '+1'));
        }
        $approve = array("visible" => 1);
        if ($thread_list) {
            $db->update_query("threads", $approve, "tid IN ({$thread_list})");
        }
        $db->update_query("posts", $approve, "pid IN ({$posts_in})");
        // Log admin action
        log_admin_action();
        flash_message($lang->success_unmarked, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if ($mybb->input['delete'] && $mybb->request_method == "post") {
        $deletepost = $mybb->input['akismet'];
        if (empty($deletepost)) {
            flash_message($lang->error_deletepost, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($deletepost as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[$post['pid']] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        require_once MYBB_ROOT . "inc/functions_upload.php";
        foreach ($deletepost as $pid => $val) {
            if (array_key_exists($pid, $threadp)) {
                $db->delete_query("posts", "pid IN ({$posts_in})");
                $db->delete_query("attachments", "pid IN ({$posts_in})");
                // Get thread info
                $query = $db->simple_select("threads", "poll", "tid='" . $threadp[$pid] . "'");
                $poll = $db->fetch_field($query, 'poll');
                // Delete threads, redirects, favorites, polls, and poll votes
                $db->delete_query("threads", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("threads", "closed='moved|" . $threadp[$pid] . "'");
                $db->delete_query("threadsubscriptions", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("polls", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("pollvotes", "pid='{$poll}'");
            }
            // Remove attachments
            remove_attachments($pid);
            // Delete the post
            $db->delete_query("posts", "pid='{$pid}'");
        }
        // Log admin action
        log_admin_action();
        flash_message($lang->success_spam_deleted, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if (!$mybb->input['action']) {
        require MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
        $page->output_header($lang->akismet);
        $form = new Form("index.php?module=forum-akismet", "post");
        $table = new Table();
        $table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')), array('width' => '5%'));
        $table->construct_header("Title / Username / Post", array('class' => 'align_center'));
        $mybb->input['page'] = intval($mybb->input['page']);
        if ($mybb->input['page'] > 0) {
            $start = $mybb->input['page'] * 20;
        } else {
            $start = 0;
        }
        $query = $db->simple_select("posts", "COUNT(pid) as spam", "visible = '-4'");
        $total_rows = $db->fetch_field($query, 'spam');
        if ($start > $total_rows) {
            $start = $total_rows - 20;
        }
        if ($start < 0) {
            $start = 0;
        }
        $query = $db->simple_select("posts", "*", "visible = '-4'", array('limit_start' => $start, 'limit' => '20', 'order_by' => 'dateline', 'order_dir' => 'desc'));
        while ($post = $db->fetch_array($query)) {
            if ($post['uid'] != 0) {
                $username = "******"../" . str_replace("{uid}", $post['uid'], PROFILE_URL) . "\" target=\"_blank\">" . format_name($post['username'], $post['usergroup'], $post['displaygroup']) . "</a>";
            } else {
                $username = $post['username'];
            }
            $table->construct_cell($form->generate_check_box("akismet[{$post['pid']}]", 1, ''));
            $table->construct_cell("<span style=\"float: right;\">{$lang->username} {$username}</span> <span style=\"float: left;\">{$lang->title}: " . htmlspecialchars_uni($post['subject']) . " <strong>(" . my_date($mybb->settings['dateformat'], $post['dateline']) . ", " . my_date($mybb->settings['timeformat'], $post['dateline']) . ")</strong></span>");
            $table->construct_row();
            $parser_options = array("allow_html" => 0, "allow_mycode" => 0, "allow_smilies" => 0, "allow_imgcode" => 0, "me_username" => $post['username'], "filter_badwords" => 1);
            $post['message'] = $parser->parse_message($post['message'], $parser_options);
            $table->construct_cell($post['message'], array("colspan" => 2));
            $table->construct_row();
        }
        $num_rows = $table->num_rows();
        if ($num_rows == 0) {
            $table->construct_cell($lang->no_spam_found, array("class" => "align_center", "colspan" => 2));
            $table->construct_row();
        }
        $table->output($lang->detected_spam_messages);
        echo "<br />" . draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum-akismet&amp;page={page}");
        $buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark'));
        $buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));
        if ($num_rows > 0) {
            $buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));
        }
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    }
    exit;
}
function restfulapi_admin_load()
{
    global $mybb, $db, $page, $lang, $cache;
    if ($page->active_action == RESTFULAPI_URL) {
        $page->add_breadcrumb_item($lang->restfulapi_title);
        $page->output_header($lang->restfulapi_title);
        $result = $db->simple_select("apisettings");
        $action = "config";
        if (isset($mybb->input["action"]) && in_array($mybb->input["action"], array("manage-keys", "add-key"))) {
            $action = $mybb->input["action"];
        }
        $navs = array("config" => array("link" => "index.php?module=config-" . RESTFULAPI_URL, "title" => $lang->restfulapi_config, "description" => $lang->restfulapi_config_description), "manage-keys" => array("link" => "index.php?module=config-" . RESTFULAPI_URL . "&amp;action=manage-keys", "title" => $lang->restfulapi_manage_api_keys, "description" => $lang->restfulapi_manage_api_keys_description), "add-key" => array("link" => "index.php?module=config-" . RESTFULAPI_URL . "&amp;action=add-key", "title" => $lang->restfulapi_add_api_key, "description" => $lang->restfulapi_add_api_key_description));
        $page->output_nav_tabs($navs, $action);
        switch ($action) {
            case "manage-keys":
                if (isset($mybb->input["do"]) && in_array($mybb->input["do"], array("regenerate", "edit", "delete"))) {
                    $do = $mybb->input["do"];
                    if ($do == "edit" && isset($mybb->input["key_id"]) && is_string($mybb->input["key_id"])) {
                        $key_id = (int) $db->escape_string($mybb->input["key_id"]);
                        $result = $db->simple_select("apikeys", "*", "id='{$key_id}'");
                        if ($result->num_rows != 1) {
                            flash_message($lang->restfulapi_key_not_found, "error");
                            admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                            exit;
                        }
                        if ($mybb->request_method == "post" && isset($mybb->input["apicustomer"]) && is_string($mybb->input["apicustomer"]) && isset($mybb->input["apicomment"]) && is_string($mybb->input["apicomment"]) && isset($mybb->input["maxreq"]) && is_numeric($mybb->input["maxreq"]) && isset($mybb->input["maxreqrate"]) && in_array($mybb->input["maxreqrate"], array("m", "w", "d", "h"))) {
                            $update = array("apicustomer" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicustomer"])), "apicomment" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicomment"])), "maxreq" => (int) $mybb->input["maxreq"], "maxreqrate" => $db->escape_string(htmlspecialchars_uni($mybb->input["maxreqrate"])));
                            $db->update_query("apikeys", $update, "id='{$key_id}'");
                            $db->delete_query("apipermissions", "apikey='{$key_id}'");
                            if (isset($mybb->input["apinames"]) && is_array($mybb->input["apinames"])) {
                                $insert_allowed = array();
                                foreach ($mybb->input["apinames"] as $apiname) {
                                    $insert_allowed[] = array("apikey" => $key_id, "apiname" => $db->escape_string($apiname));
                                }
                                $db->insert_query_multiple("apipermissions", $insert_allowed);
                            }
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_edited_successfully, "success");
                            admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                        } else {
                            $keyset = $result->fetch_array();
                            $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&amp;action=manage-keys&amp;do=edit&amp;key_id={$key_id}", "post", "edit");
                            $form_container = new FormContainer($lang->restfulapi_edit_api_key);
                            $form_container->output_row($lang->restfulapi_customer_name . " <em>*</em>", $lang->restfulapi_customer_name_description, $form->generate_text_box('apicustomer', htmlspecialchars_uni($keyset["apicustomer"]), array('id' => 'apicustomer')), 'apicustomer');
                            $rate_types = array("h" => $lang->restfulapi_per_hour, "d" => $lang->restfulapi_per_day, "w" => $lang->restfulapi_per_week, "m" => $lang->restfulapi_per_month);
                            $form_container->output_row($lang->restfulapi_max_requests . " <em>*</em>", $lang->restfulapi_max_requests_description, $form->generate_text_box('maxreq', htmlspecialchars_uni($keyset["maxreq"]), array('id' => 'maxreq')) . " " . $form->generate_select_box('maxreqrate', $rate_types, htmlspecialchars_uni($keyset["maxreqrate"]), array('id' => 'maxreqrate')), 'maxreq');
                            $form_container->output_row($lang->restfulapi_comment, $lang->restfulapi_comment_description, $form->generate_text_area('apicomment', htmlspecialchars_uni($keyset["apicomment"]), array('id' => 'apicomment')), 'apicomment');
                            $apis = glob(RESTFULAPI_PATH . "api/*api.class.php");
                            $presentable_apis = array();
                            foreach ($apis as $key => $value) {
                                $value = htmlspecialchars_uni(str_replace(array(RESTFULAPI_PATH . "api/", "api.class.php"), "", $value));
                                $presentable_apis[$value] = $value;
                            }
                            $selected = array();
                            // reminder, $key_id has already been escaped!
                            $result = $db->simple_select("apipermissions", "*", "apikey='{$key_id}'");
                            while ($apipermission = $db->fetch_array($result)) {
                                $selected[] = $apipermission["apiname"];
                            }
                            $form_container->output_row($lang->restfulapi_select_allowed_apis, $lang->restfulapi_select_allowed_apis_description, $form->generate_select_box('apinames[]', $presentable_apis, $selected, array('id' => 'apinames', 'multiple' => true, 'size' => 10)), 'apinames');
                            $form_container->end();
                            $buttons[] = $form->generate_submit_button($lang->restfulapi_edit_api_key);
                            $form->output_submit_wrapper($buttons);
                            $form->end();
                        }
                    } elseif ($do == "delete" && isset($mybb->input["key_id"]) && isset($mybb->input["my_post_key"]) && verify_post_check($mybb->input["my_post_key"])) {
                        $key_id = $db->escape_string($mybb->input["key_id"]);
                        if ($db->simple_select("apikeys", "*", "id='{$key_id}'")->num_rows == 1) {
                            $db->delete_query("apipermissions", "apikey='{$key_id}'");
                            $db->delete_query("apikeys", "id='{$key_id}'");
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_deleted_successfully, "success");
                        } else {
                            flash_message($lang->restfulapi_key_not_found, "error");
                        }
                        admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                    } elseif ($do == "regenerate" && isset($mybb->input["key_id"]) && isset($mybb->input["my_post_key"]) && verify_post_check($mybb->input["my_post_key"])) {
                        $key_id = $db->escape_string($mybb->input["key_id"]);
                        if ($db->simple_select("apikeys", "*", "id='{$key_id}'")->num_rows == 1) {
                            $apikey = restfulapi_generate_key();
                            /* can't figure out a better way to generate a random yet never-generated-before API key than this one */
                            while ($db->simple_select("apikeys", "*", "apikey='{$apikey}'")->num_rows != 0) {
                                $apikey = restfulapi_generate_key();
                            }
                            $update = array("apikey" => $db->escape_string(htmlspecialchars_uni($apikey)));
                            $db->update_query("apikeys", $update, "id='{$key_id}'");
                            restfulapi_cache_rebuild();
                            flash_message($lang->restfulapi_key_regenerated_successfully, "success");
                        } else {
                            flash_message($lang->restfulapi_key_not_found, "error");
                        }
                        admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                    }
                } else {
                    $restfulapi_cache = $cache->read("restfulapi");
                    $apikeysets = $restfulapi_cache["keys"];
                    $table = new Table();
                    $table->construct_header($lang->restfulapi_customer, array("width" => "15%"));
                    $table->construct_header($lang->restfulapi_api_key, array("class" => "align_center", "width" => "29%"));
                    $table->construct_header($lang->restfulapi_comment, array("class" => "align_center", "width" => "30%"));
                    $table->construct_header($lang->restfulapi_usage, array("class" => "align_center", "width" => "5%"));
                    $table->construct_header($lang->restfulapi_controls, array("class" => "align_center", "width" => "21%", "colspan" => 3));
                    if (count($apikeysets) == 0) {
                        $table->construct_cell($lang->sprintf($lang->restfulapi_no_api_key, '<a href="index.php?module=config-restfulapi&action=add-key">', '</a>'), array("class" => "first", "colspan" => 5));
                        $table->construct_row();
                    } else {
                        // TODO : pagination maybe ?
                        foreach ($apikeysets as $key => $keyset) {
                            $table->construct_cell("<b>" . htmlspecialchars_uni($keyset['apicustomer']) . "</b>");
                            $table->construct_cell(htmlspecialchars_uni($keyset['apikey']));
                            $table->construct_cell(htmlspecialchars_uni($keyset['apicomment']));
                            $table->construct_cell(htmlspecialchars_uni($keyset['access']), array("class" => "align_center"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=regenerate&amp;key_id={$keyset['id']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->restfulapi_regenerate_api_key_confirmation}')\">{$lang->restfulapi_regenerate_api_key}</a>", array("class" => "align_center", "width" => "9%"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=edit&amp;key_id={$keyset['id']}\">{$lang->restfulapi_edit}</a>", array("class" => "align_center", "width" => "6%"));
                            $table->construct_cell("<a href=\"index.php?module=config-restfulapi&amp;action=manage-keys&amp;do=delete&amp;key_id={$keyset['id']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->restfulapi_delete_confirm}')\">{$lang->restfulapi_delete}</a>", array("class" => "align_center", "width" => "6%"));
                            $table->construct_row();
                        }
                    }
                    $table->output($lang->restfulapi_manage_api_keys);
                }
                break;
            case "add-key":
                if ($mybb->request_method == "post" && isset($mybb->input["apicustomer"]) && is_string($mybb->input["apicustomer"]) && isset($mybb->input["apicomment"]) && is_string($mybb->input["apicomment"]) && isset($mybb->input["maxreq"]) && is_numeric($mybb->input["maxreq"]) && isset($mybb->input["maxreqrate"]) && in_array($mybb->input["maxreqrate"], array("m", "w", "d", "h"))) {
                    $apikey = restfulapi_generate_key();
                    /* can't figure out a better way to generate a random yet never-generated-before API key than this one */
                    while ($db->simple_select("apikeys", "*", "apikey='{$db->escape_string($apikey)}'")->num_rows != 0) {
                        $apikey = restfulapi_generate_key();
                    }
                    $insert = array("apicustomer" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicustomer"])), "apicomment" => $db->escape_string(htmlspecialchars_uni($mybb->input["apicomment"])), "access" => 0, "maxreq" => (int) $mybb->input["maxreq"], "maxreqrate" => $db->escape_string(htmlspecialchars_uni($mybb->input["maxreqrate"])), "apikey" => $db->escape_string(htmlspecialchars_uni($apikey)));
                    $apikeyid = $db->insert_query("apikeys", $insert);
                    if (isset($mybb->input["apinames"]) && is_array($mybb->input["apinames"])) {
                        $insert_allowed = array();
                        foreach ($mybb->input["apinames"] as $apiname) {
                            $insert_allowed[] = array("apikey" => $db->escape_string($apikeyid), "apiname" => $db->escape_string($apiname));
                        }
                        $db->insert_query_multiple("apipermissions", $insert_allowed);
                    }
                    restfulapi_cache_rebuild();
                    flash_message($lang->sprintf($lang->restfulapi_generated_successfully, $apikey, $mybb->input["apicustomer"]), 'success');
                    admin_redirect("index.php?module=config-restfulapi&amp;action=manage-keys");
                } else {
                    $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&amp;action=add-key", "post", "add");
                    $form_container = new FormContainer($lang->restfulapi_add_api_key);
                    $form_container->output_row($lang->restfulapi_customer_name . " <em>*</em>", $lang->restfulapi_customer_name_description, $form->generate_text_box('apicustomer', '', array('id' => 'apicustomer')), 'apicustomer');
                    $rate_types = array("h" => $lang->restfulapi_per_hour, "d" => $lang->restfulapi_per_day, "w" => $lang->restfulapi_per_week, "m" => $lang->restfulapi_per_month);
                    $form_container->output_row($lang->restfulapi_max_requests . " <em>*</em>", $lang->restfulapi_max_requests_description, $form->generate_text_box('maxreq', '0', array('id' => 'maxreq')) . " " . $form->generate_select_box('maxreqrate', $rate_types, "m", array('id' => 'maxreqrate')), 'maxreq');
                    $form_container->output_row($lang->restfulapi_comment, $lang->restfulapi_comment_description, $form->generate_text_area('apicomment', '', array('id' => 'apicomment')), 'apicomment');
                    $apis = glob(RESTFULAPI_PATH . "api/*api.class.php");
                    $presentable_apis = array();
                    foreach ($apis as $key => $value) {
                        $value = htmlspecialchars_uni(str_replace(array(RESTFULAPI_PATH . "api/", "api.class.php"), "", $value));
                        $presentable_apis[$value] = $value;
                    }
                    $form_container->output_row($lang->restfulapi_select_allowed_apis . " <em>*</em>", $lang->restfulapi_select_allowed_apis_description, $form->generate_select_box('apinames[]', $presentable_apis, array_keys($presentable_apis), array('id' => 'apinames', 'multiple' => true, 'size' => 10)), 'apinames');
                    $form_container->end();
                    $buttons[] = $form->generate_submit_button($lang->restfulapi_generate_api_key);
                    $form->output_submit_wrapper($buttons);
                    $form->end();
                }
                break;
            default:
                $apilist = $cache->read("restfulapilist");
                // routine to install newly detected APIs, and activate them if needed
                restfulapi_apilist_activate();
                if ($mybb->request_method == "post") {
                    // we delete all the previously-deactivated options
                    $db->delete_query("apisettings", "apiaction='deactivate'");
                    $inserts = array();
                    foreach ($mybb->input as $key => $input) {
                        if (substr($key, 0, 7) == "option_" && $input == "1") {
                            // replace first occurrence of 'option_' with '' in case the option name is 'option_', so that 'option_option_' won't be all replaced into an empty string
                            // yeah I know, probably would never happen but we never know
                            $option = preg_replace('/option\\_/', '', $key, 1);
                            restfulapi_api_activate($option);
                        } elseif (substr($key, 0, 7) == "option_" && $input == "0") {
                            $option = preg_replace('/option\\_/', '', $key, 1);
                            restfulapi_api_deactivate($option);
                        }
                    }
                    flash_message($lang->restfulapi_saved_config, "success");
                    admin_redirect("index.php?module=config-restfulapi");
                } else {
                    $result = $db->simple_select("apisettings", "*", "apiaction='deactivate'");
                    $deactivatedapis = array();
                    while ($apiarray = $db->fetch_array($result)) {
                        $deactivatedapis[] = $apiarray["apivalue"];
                    }
                    if (count($apilist) == 0) {
                        echo '<div class="notice">' . $lang->sprintf($lang->restfulapi_no_api, '<a href="index.php?module=config-restfulapi&action=add-key">', '</a>') . '</div>';
                    } else {
                        $form = new Form("index.php?module=config-" . RESTFULAPI_URL, "post", "config");
                        $form_container = new FormContainer($lang->restfulapi_config);
                        $table = new Table();
                        foreach ($apilist as $api => $info_array) {
                            require_once RESTFULAPI_PATH . "api/" . $api . "api.class.php";
                            $api = htmlspecialchars_uni($api);
                            $apiclass = $api . "api";
                            $api_instance = new $apiclass();
                            $info_array = $api_instance->info();
                            $name = isset($info_array["name"]) && is_string($info_array["name"]) ? htmlspecialchars_uni($info_array["name"]) . " : " . $api : $api;
                            $description = isset($info_array["description"]) && is_string($info_array["description"]) ? htmlspecialchars_uni($info_array["description"]) : $lang->restfulapi_config_on_off_description;
                            $setting_code = $form->generate_on_off_radio("option_" . $api, in_array($api, $deactivatedapis) ? 0 : 1, true, array('id' => $api . '_yes'), array('id' => $api . '_no'));
                            $form_container->output_row($name, $description, $setting_code, '', array(), array('id' => 'row_' . $api));
                        }
                        $form_container->end();
                        $buttons[] = $form->generate_submit_button($lang->restfulapi_save_config);
                        $form->output_submit_wrapper($buttons);
                        $form->end();
                    }
                }
                break;
        }
        $page->output_footer();
    }
}
Example #9
0
    }
    $table = new Table();
    $table->construct_header($lang->image, array("class" => "align_center", "width" => 1));
    $table->construct_header($lang->name, array("width" => "35%"));
    $table->construct_header($lang->text_replace, array("width" => "35%"));
    $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
    $query = $db->simple_select("smilies", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'disporder'));
    while ($smilie = $db->fetch_array($query)) {
        $smilie['image'] = str_replace("{theme:imgdir}", $theme['imgdir'], $smilie['image']);
        if (my_strpos($smilie['image'], "p://") || substr($smilie['image'], 0, 1) == "/") {
            $image = $smilie['image'];
        } else {
            $image = "../" . $smilie['image'];
        }
        $table->construct_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center"));
        $table->construct_cell(htmlspecialchars_uni($smilie['name']));
        $table->construct_cell(htmlspecialchars_uni($smilie['find']));
        $table->construct_cell("<a href=\"index.php?module=config-smilies&amp;action=edit&amp;sid={$smilie['sid']}\">{$lang->edit}</a>", array("class" => "align_center"));
        $table->construct_cell("<a href=\"index.php?module=config-smilies&amp;action=delete&amp;sid={$smilie['sid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_smilie_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_smilies, array('colspan' => 5));
        $table->construct_row();
    }
    $table->output($lang->manage_smilies);
    $query = $db->simple_select("smilies", "COUNT(sid) as smilies");
    $total_rows = $db->fetch_field($query, "smilies");
    echo "<br />" . draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-smilies&amp;page={page}");
    $page->output_footer();
}
Example #10
0
function newpoints_shop_admin_stats()
{
    global $form, $db, $lang, $mybb;
    newpoints_lang_load("newpoints_shop");
    echo "<br />";
    // table
    $table = new Table();
    $table->construct_header($lang->newpoints_shop_item, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_username, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_price, array('width' => '20%', 'class' => 'align_center'));
    $table->construct_header($lang->newpoints_shop_date, array('width' => '20%', 'class' => 'align_center'));
    $query = $db->simple_select('newpoints_log', '*', 'action=\'shop_purchase\'', array('order_by' => 'date', 'order_dir' => 'DESC', 'limit' => intval($mybb->settings['newpoints_shop_lastpurchases'])));
    while ($stats = $db->fetch_array($query)) {
        $data = explode('-', $stats['data']);
        $item = newpoints_shop_get_item($data[0]);
        $table->construct_cell(htmlspecialchars_uni($item['name']));
        $link = build_profile_link(htmlspecialchars_uni($stats['username']), intval($stats['uid']));
        $table->construct_cell($link);
        $table->construct_cell(newpoints_format_points($data[1]), array('class' => 'align_center'));
        $table->construct_cell(my_date($mybb->settings['dateformat'], intval($stats['date']), '', false) . ", " . my_date($mybb->settings['timeformat'], intval($stats['date'])), array('class' => 'align_center'));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->newpoints_error_gathering, array('colspan' => 4));
        $table->construct_row();
    }
    $table->output($lang->newpoints_stats_lastpurchases);
}
        $basic = '';
        $simplified = 'selected=selected';
        $agg = '';
    } elseif (cloudflare_cache_lvl_setting() == 'agg') {
        $basic = '';
        $simplified = '';
        $agg = 'selected=selected';
    }
    $table->construct_cell('
	<strong>Adjust your caching level to modify CloudFlare\'s caching behavior.</strong><br /><br />
	<form action="index.php?module=cloudflare-cache_lvl&action=change" method="post">
	<input type="hidden" value="' . $mybb->post_code . '" name="my_post_key">
	Level: <select name="type">
  	<option name="agg"' . $agg . '>Aggressive</option> 
  	<option name="simplified"' . $simplified . '>Simplified</option> 
  	<option name="basic"' . $basic . '>Basic</option>
</select><br /><br />
The <strong>basic</strong> setting will cache most static resources (i.e., css, images, and JavaScript). The <strong>aggressive</strong> setting will cache all static resources, including ones with a query string.<br /><br />

<strong>Basic:</strong> http://' . $mybb->settings['cloudflare_domain'] . '/images/logo.gif<br /><br />
<strong>Simplified:</strong> http://' . $mybb->settings['cloudflare_domain'] . '/images/logo.gif<s>?ignore=this-query-string</s><br /><br />
<strong>Aggressive:</strong> http://' . $mybb->settings['cloudflare_domain'] . '/images/logo.gif?with=query 
<br /><br />
	<input type="submit" name="submit" value="Change">
	</form>

	');
    $table->construct_row();
    $table->output("Change Cache Level");
    $page->output_footer();
}
     $updated_cache['latest_version_code'] = $latest_code;
 } else {
     $version_warn = 0;
     $latest_version = "<span style=\"color: green;\">" . $latest_version . "</span>";
 }
 $cache->update("update_check", $updated_cache);
 require_once MYBB_ROOT . "inc/class_feedparser.php";
 $feed_parser = new FeedParser();
 $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
 $table = new Table();
 $table->construct_header($lang->your_version);
 $table->construct_header($lang->latest_version);
 $table->construct_cell("<strong>" . $mybb->version . "</strong> (" . $mybb->version_code . ")");
 $table->construct_cell($latest_version);
 $table->construct_row();
 $table->output($lang->version_check);
 if ($version_warn) {
     $page->output_error("<p><em>{$lang->error_out_of_date}</em> {$lang->update_forum}</p>");
 } else {
     $page->output_success("<p><em>{$lang->success_up_to_date}</em></p>");
 }
 if ($feed_parser->error == '') {
     foreach ($feed_parser->items as $item) {
         if ($item['date_timestamp']) {
             $stamp = my_date($mybb->settings['dateformat'], $item['date_timestamp']) . ", " . my_date($mybb->settings['timeformat'], $item['date_timestamp']);
         } else {
             $stamp = '';
         }
         if ($item['content']) {
             $content = $item['content'];
         } else {
            if ($doc['hid'] > 7) {
                $icon = "<img src=\"styles/default/images/icons/custom.gif\" title=\"{$lang->custom_doc_sec}\" alt=\"{$lang->custom_doc_sec}\" style=\"vertical-align: middle;\" />";
            } else {
                $icon = "<img src=\"styles/default/images/icons/default.gif\" title=\"{$lang->default_doc_sec}\" alt=\"{$lang->default_doc_sec}\" style=\"vertical-align: middle;\" />";
            }
            $table->construct_cell("<div style=\"padding-left: 40px;\"><div class=\"float_right\">{$icon}</div><div><strong><a href=\"index.php?module=config-help_documents&amp;action=edit&amp;hid={$doc['hid']}\">{$doc['name']}</a></strong><br /><small>{$doc['description']}</small></div></div>");
            $table->construct_cell("<a href=\"index.php?module=config-help_documents&amp;action=edit&amp;hid={$doc['hid']}\">{$lang->edit}</a>", array("class" => "align_center", "width" => '60'));
            // Only show delete if not a default document
            if ($doc['hid'] > 7) {
                $table->construct_cell("<a href=\"index.php?module=config-help_documents&amp;action=delete&amp;hid={$doc['hid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_document_deletion}')\">{$lang->delete}</a>", array("class" => "align_center", "width" => '90'));
            } else {
                $table->construct_cell("&nbsp;", array("width" => '90'));
            }
            $table->construct_row();
        }
    }
    // No documents message
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_help_documents, array('colspan' => 3));
        $table->construct_row();
    }
    $table->output($lang->help_documents);
    echo <<<LEGEND
\t<fieldset>
<legend>{$lang->legend}</legend>
<img src="styles/default/images/icons/custom.gif" alt="{$lang->custom_doc_sec}" style="vertical-align: middle;" /> {$lang->custom_doc_sec}<br />
<img src="styles/default/images/icons/default.gif" alt="{$lang->default_doc_sec}" style="vertical-align: middle;" /> {$lang->default_doc_sec}
</fieldset>
LEGEND;
    $page->output_footer();
}
Example #14
0
         $last_use = my_date($mybb->settings['dateformat'], $filter['lastuse']) . ", " . my_date($mybb->settings['timeformat'], $filter['lastuse']);
     } else {
         $last_use = $lang->never;
     }
     $date = my_date($mybb->settings['dateformat'], $filter['dateline']) . ", " . my_date($mybb->settings['timeformat'], $filter['dateline']);
     $table->construct_cell($filter['filter']);
     $table->construct_cell($date, array("class" => "align_center"));
     $table->construct_cell($last_use, array("class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=config/banning&amp;action=delete&amp;fid={$filter['fid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_ban_deletion}');\"><img src=\"styles/{$page->style}/images/icons/delete.gif\" title=\"{$lang->delete}\" alt=\"{$lang->delete}\" /></a>", array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_bans, array("colspan" => 4));
     $table->construct_row();
 }
 $table->output($title);
 $form = new Form("index.php?module=config/banning&amp;action=add", "post", "add");
 if ($errors) {
     $page->output_inline_error($errors);
 }
 if ($mybb->input['type'] == "usernames") {
     $form_container = new FormContainer($lang->add_disallowed_username);
     $form_container->output_row($lang->username . " <em>*</em>", $lang->username_desc, $form->generate_text_box('filter', $mybb->input['filter'], array('id' => 'filter')), 'filter');
     $buttons[] = $form->generate_submit_button($lang->disallow_username);
 } else {
     if ($mybb->input['type'] == "emails") {
         $form_container = new FormContainer($lang->add_disallowed_email_address);
         $form_container->output_row($lang->email_address . " <em>*</em>", $lang->email_address_desc, $form->generate_text_box('filter', $mybb->input['filter'], array('id' => 'filter')), 'filter');
         $buttons[] = $form->generate_submit_button($lang->disallow_email_address);
     } else {
         $form_container = new FormContainer($lang->ban_ip_address);
Example #15
0
         $popup->add_item($lang->downloads_dlmngr_delete, "index.php?module=dlmngr/manage&amp;action=delete&amp;dlid={$dlid}");
         if ($dlitem['public'] == 1) {
             $popup->add_item($lang->downloads_dlmngr_reject, "index.php?module=dlmngr/manage&amp;action=reject&amp;dlid={$dlid}");
         } else {
             $popup->add_item($lang->downloads_dlmngr_accept, "index.php?module=dlmngr/manage&amp;action=accept&amp;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();
     }
     // display the table with our title
     $table->output($lang->downloads_dlmngr_manage);
     // wrap up the page with the standard footer
     $page->output_footer();
 } else {
     if ($mybb->input['action'] == "edit") {
         // we're editing a project download
         // get the project ID
         $dlid = $mybb->input['dlid'];
         // check if the user just saved
         // DONE; refused; Add a function for save and exit
         if ($mybb->input['save'] == "save") {
             // error checking
             // TODO Change into several checks and set an boolean var / array for errors
             // FIXME extend check for external files
             // TODO Add a file browser here like in typolight to choose the file we want to
             if ((!file_exists(MYBB_ROOT . "/uploads/downloads/" . $mybb->input['filename']) or $mybb->input['filename'] == "") and (substr($mybb->input['filename'], 0, 6) != 'ftp://' and substr($mybb->input['filename'], 0, 7) != 'http://')) {
Example #16
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();
}
Example #17
0
    } else {
        $start = 0;
        $pagenum = 1;
    }
    $table = new Table();
    $table->construct_header($lang->image, array('class' => "align_center", 'width' => 1));
    $table->construct_header($lang->name, array('width' => "70%"));
    $table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
    $query = $db->simple_select("icons", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'name'));
    while ($icon = $db->fetch_array($query)) {
        if (my_strpos($icon['path'], "p://") || substr($icon['path'], 0, 1) == "/") {
            $image = $icon['path'];
        } else {
            $image = "../" . $icon['path'];
        }
        $table->construct_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center"));
        $table->construct_cell("{$icon['name']}");
        $table->construct_cell("<a href=\"index.php?module=config/post_icons&amp;action=edit&amp;iid={$icon['iid']}\">{$lang->edit}</a>", array("class" => "align_center"));
        $table->construct_cell("<a href=\"index.php?module=config/post_icons&amp;action=delete&amp;iid={$icon['iid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_post_icon_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_post_icons, array('colspan' => 4));
        $table->construct_row();
    }
    $table->output($lang->manage_post_icons);
    $query = $db->simple_select("icons", "COUNT(iid) AS icons");
    $total_rows = $db->fetch_field($query, "icons");
    echo "<br />" . draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config/post_icons&amp;page={page}");
    $page->output_footer();
}
Example #18
0
             $ban['adminuser'] = $ban['admin'];
         }
     }
     $table->construct_cell($lang->sprintf($lang->bannedby_x_on_x, $profile_link, htmlspecialchars_uni($ban['adminuser']), $ban_date, $ban_period));
     $table->construct_cell($lifts_on, array("class" => "align_center"));
     $table->construct_cell($time_remaining, array("class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=user-banning&amp;action=edit&amp;uid={$ban['uid']}\">{$lang->edit}</a>", array("class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=user-banning&amp;action=lift&amp;uid={$ban['uid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_lift_ban}');\">{$lang->lift}</a>", array("class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=user-banning&amp;action=prune&amp;uid={$ban['uid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_prune}');\">{$lang->prune_threads_and_posts}</a>", array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_banned_users, array("colspan" => "6"));
     $table->construct_row();
 }
 $table->output($lang->banned_accounts);
 echo $pagination;
 $form = new Form("index.php?module=user-banning", "post");
 if ($errors) {
     $page->output_inline_error($errors);
 }
 if ($mybb->input['uid'] && !$mybb->input['username']) {
     $user = get_user($mybb->input['uid']);
     $mybb->input['username'] = $user['username'];
 }
 $form_container = new FormContainer($lang->ban_a_user);
 $form_container->output_row($lang->ban_username, $lang->autocomplete_enabled, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
 $form_container->output_row($lang->ban_reason, "", $form->generate_text_box('reason', $mybb->input['reason'], array('id' => 'reason')), 'reason');
 if (count($banned_groups) > 1) {
     $form_container->output_row($lang->ban_group, $lang->add_ban_group_desc, $form->generate_select_box('usergroup', $banned_groups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
 }
Example #19
0
        $table = new Table();
        $table->construct_header($lang->announcement);
        $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 150));
        // Get the global announcements
        foreach ($global_announcements as $aid => $announcement) {
            if ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0) {
                $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"(Expired)\" title=\"Expired Announcement\"  style=\"vertical-align: middle;\" /> ";
            } else {
                $icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"(Active)\" title=\"Active Announcement\"  style=\"vertical-align: middle;\" /> ";
            }
            $table->construct_cell($icon . "<a href=\"index.php?module=forum-announcements&amp;action=edit&amp;aid={$aid}\">" . htmlspecialchars_uni($announcement['subject']) . "</a>");
            $table->construct_cell("<a href=\"index.php?module=forum-announcements&amp;action=edit&amp;aid={$aid}\">{$lang->edit}</a>", array("class" => "align_center", "width" => 75));
            $table->construct_cell("<a href=\"index.php?module=forum-announcements&amp;action=delete&amp;aid={$aid}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_announcement_deletion}')\">{$lang->delete}</a>", array("class" => "align_center", "width" => 75));
            $table->construct_row();
        }
        $table->output($lang->global_announcements);
    }
    $table = new Table();
    $table->construct_header($lang->announcement);
    $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
    fetch_forum_announcements($table);
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_forums, array("colspan" => "3"));
        $table->construct_row();
    }
    $table->output($lang->forum_announcements);
    $page->output_footer();
}
/**
 * @param DefaultTable $table
 * @param int $pid
Example #20
0
if (!$mybb->input['action']) {
    $page->output_header($lang->manage_calendars);
    $page->output_nav_tabs($sub_tabs, 'manage_calendars');
    $form = new Form("index.php?module=config-calendars&amp;action=update_order", "post");
    $table = new Table();
    $table->construct_header($lang->calendar);
    $table->construct_header($lang->order, array('width' => '5%', 'class' => 'align_center'));
    $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3, "width" => 300));
    $query = $db->simple_select("calendars", "*", "", array('order_by' => 'disporder'));
    while ($calendar = $db->fetch_array($query)) {
        $calendar['name'] = htmlspecialchars_uni($calendar['name']);
        $table->construct_cell("<a href=\"index.php?module=config-calendars&amp;action=edit&amp;cid={$calendar['cid']}\"><strong>{$calendar['name']}</strong></a>");
        $table->construct_cell($form->generate_numeric_field("disporder[{$calendar['cid']}]", $calendar['disporder'], array('id' => 'disporder', 'style' => 'width: 80%', 'class' => 'align_center', 'min' => 0)));
        $table->construct_cell("<a href=\"index.php?module=config-calendars&amp;action=edit&amp;cid={$calendar['cid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
        $table->construct_cell("<a href=\"index.php?module=config-calendars&amp;action=permissions&amp;cid={$calendar['cid']}\">{$lang->permissions}</a>", array("width" => 100, "class" => "align_center"));
        $table->construct_cell("<a href=\"index.php?module=config-calendars&amp;action=delete&amp;cid={$calendar['cid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_calendar_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_calendars, array('colspan' => 5));
        $table->construct_row();
        $no_results = true;
    }
    $table->output($lang->manage_calendars);
    if (!$no_results) {
        $buttons[] = $form->generate_submit_button($lang->save_calendar_orders);
        $form->output_submit_wrapper($buttons);
    }
    $form->end();
    $page->output_footer();
}
Example #21
0
        admin_redirect("index.php?module=tools-cache");
    } else {
        flash_message($lang->error_cannot_rebuild, 'error');
        admin_redirect("index.php?module=tools-cache");
    }
}
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_tools_cache_start");
    $page->output_header($lang->cache_manager);
    $sub_tabs['cache_manager'] = array('title' => $lang->cache_manager, 'link' => "index.php?module=tools-cache", 'description' => $lang->cache_manager_description);
    $page->output_nav_tabs($sub_tabs, 'cache_manager');
    $table = new Table();
    $table->construct_header($lang->name);
    $table->construct_header($lang->size, array("class" => "align_center", "width" => 100));
    $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));
    $query = $db->simple_select("datacache");
    while ($cacheitem = $db->fetch_array($query)) {
        $table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=" . urlencode($cacheitem['title']) . "\">{$cacheitem['title']}</a></strong>");
        $table->construct_cell(get_friendly_size(strlen($cacheitem['cache'])), array("class" => "align_center"));
        if (method_exists($cache, "update_" . $cacheitem['title'])) {
            $table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=rebuild&amp;title=" . urlencode($cacheitem['title']) . "&amp;my_post_key={$mybb->post_code}\">" . $lang->rebuild_cache . "</a>", array("class" => "align_center"));
        } elseif (method_exists($cache, "reload_" . $cacheitem['title'])) {
            $table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=reload&amp;title=" . urlencode($cacheitem['title']) . "&amp;my_post_key={$mybb->post_code}\">" . $lang->reload_cache . "</a>", array("class" => "align_center"));
        } else {
            $table->construct_cell("");
        }
        $table->construct_row();
    }
    $table->output($lang->cache_manager);
    $page->output_footer();
}
Example #22
0
     } else {
         $caninvitemembers = $lang->no;
     }
     $table->construct_cell("<strong>" . build_profile_link($leader['username'], $leader['uid'], "_blank") . "</strong>");
     $table->construct_cell($canmanagemembers, array("class" => "align_center"));
     $table->construct_cell($canmanagerequests, array("class" => "align_center"));
     $table->construct_cell($caninvitemembers, array("class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=user-groups&amp;action=edit_leader&lid={$leader['lid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
     $table->construct_cell("<a href=\"index.php?module=user-groups&amp;action=delete_leader&amp;lid={$leader['lid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_group_leader_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_assigned_leaders, array("colspan" => 5));
     $table->construct_row();
 }
 $table->output($lang->group_leaders_for . ' ' . htmlspecialchars_uni($group['title']));
 $form = new Form("index.php?module=user-groups&amp;action=add_leader&amp;gid={$group['gid']}", "post");
 if ($errors) {
     $page->output_inline_error($errors);
 } else {
     $mybb->input = array_merge($mybb->input, array("canmanagemembers" => 1, "canmanagerequests" => 1, "caninvitemembers" => 1, "makeleadermember" => 0));
 }
 $form_container = new FormContainer($lang->add_group_leader . ' ' . htmlspecialchars_uni($group['title']));
 $form_container->output_row($lang->username . " <em>*</em>", "", $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
 $form_container->output_row($lang->can_manage_group_members, $lang->can_manage_group_members_desc, $form->generate_yes_no_radio('canmanagemembers', $mybb->input['canmanagemembers']));
 $form_container->output_row($lang->can_manage_group_join_requests, $lang->can_manage_group_join_requests_desc, $form->generate_yes_no_radio('canmanagerequests', $mybb->input['canmanagerequests']));
 $form_container->output_row($lang->can_invite_group_members, $lang->can_invite_group_members_desc, $form->generate_yes_no_radio('caninvitemembers', $mybb->input['caninvitemembers']));
 $form_container->output_row($lang->make_user_member, $lang->make_user_member_desc, $form->generate_yes_no_radio('makeleadermember', $mybb->input['makeleadermember']));
 $form_container->end();
 // Autocompletion for usernames
 echo '
Example #23
0
        $table->construct_cell($lang->no_credits);
        $table->construct_row();
    } else {
        $largest_count = $i = 0;
        $team_max = array();
        foreach ($mybb_credits['credits'] as $team) {
            $count = count($team['members']);
            $team_max[$i++] = $count;
            if ($largest_count < $count) {
                $largest_count = $count;
            }
        }
        $largest_count -= 1;
        $table = new Table();
        foreach ($mybb_credits['credits'] as $team) {
            $table->construct_header($team['title'], array('width' => '16%'));
        }
        for ($i = 0; $i <= $largest_count; $i++) {
            foreach ($team_max as $team => $max) {
                if ($max < $i) {
                    $table->construct_cell("&nbsp;");
                } else {
                    $table->construct_cell("<a href=\"{$mybb_credits['credits'][$team]['members'][$i]['profile']}\" title=\"{$mybb_credits['credits'][$team]['members'][$i]['username']}\" target=\"_blank\">{$mybb_credits['credits'][$team]['members'][$i]['name']}</a>");
                }
            }
            $table->construct_row();
        }
    }
    $table->output($lang->mybb_credits);
    $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();
                }
            }
        }
    }
}
Example #25
0
            $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)
{
    $array = array();
    $array['actual'] = @preg_replace("#" . str_replace("", "", $regex) . "#si", $replacement, $test);
    $array['html'] = htmlspecialchars($array['actual']);
    return $array;
}
Example #26
0
        }
        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();
}
     $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
     $logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank");
     $logitem['data'] = unserialize($logitem['data']);
     // Get detailed information from meta
     $information = get_admin_log_action($logitem);
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], array('class' => 'align_center'));
     $table->construct_cell($information);
     $table->construct_cell($logitem['ipaddress'], array('class' => 'align_center'));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_adminlogs, array('colspan' => '4'));
     $table->construct_row();
 }
 $table->output($lang->admin_logs);
 // Do we need to construct the pagination?
 if ($rescount > $perpage) {
     echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools-adminlog&amp;perpage={$perpage}&amp;uid={$mybb->input['uid']}&amp;fid={$mybb->input['fid']}&amp;sortby={$mybb->input['sortby']}&amp;order={$order}&amp;filter_module=" . htmlspecialchars_uni($mybb->input['filter_module'])) . "<br />";
 }
 // Fetch filter options
 $sortbysel[$mybb->input['sortby']] = 'selected="selected"';
 $ordersel[$mybb->input['order']] = 'selected="selected"';
 $user_options[''] = $lang->all_administrators;
 $user_options['0'] = '----------';
 $query = $db->query("\n\t\tSELECT DISTINCT l.uid, u.username\n\t\tFROM " . TABLE_PREFIX . "adminlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (l.uid=u.uid)\n\t\tORDER BY u.username ASC\n\t");
 while ($user = $db->fetch_array($query)) {
     $user_options[$user['uid']] = $user['username'];
 }
 $module_options = array();
 $module_options[''] = $lang->all_modules;
            $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 #29
0
    $form_container->end();
    $buttons[] = $form->generate_submit_button($lang->save_post_tool);
    $form->output_submit_wrapper($buttons);
    $form->end();
    $page->output_footer();
}
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_config_mod_tools_start");
    $page->output_header($lang->mod_tools . " - " . $lang->thread_tools);
    $sub_tabs['thread_tools'] = array('title' => $lang->thread_tools, 'link' => "index.php?module=config-mod_tools", 'description' => $lang->thread_tools_desc);
    $sub_tabs['add_thread_tool'] = array('title' => $lang->add_new_thread_tool, 'link' => "index.php?module=config-mod_tools&amp;action=add_thread_tool");
    $sub_tabs['post_tools'] = array('title' => $lang->post_tools, 'link' => "index.php?module=config-mod_tools&amp;action=post_tools");
    $sub_tabs['add_post_tool'] = array('title' => $lang->add_new_post_tool, 'link' => "index.php?module=config-mod_tools&amp;action=add_post_tool");
    $page->output_nav_tabs($sub_tabs, 'thread_tools');
    $table = new Table();
    $table->construct_header($lang->title);
    $table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
    $query = $db->simple_select('modtools', 'tid, name, description, type', "type='t'", array('order_by' => 'name'));
    while ($tool = $db->fetch_array($query)) {
        $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_thread_tool&amp;tid={$tool['tid']}\"><strong>" . htmlspecialchars_uni($tool['name']) . "</strong></a><br /><small>" . htmlspecialchars_uni($tool['description']) . "</small>");
        $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_thread_tool&amp;tid={$tool['tid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center"));
        $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=delete_thread_tool&amp;tid={$tool['tid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_thread_tool_deletion}')\">{$lang->delete}</a>", array('width' => 100, 'class' => "align_center"));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->no_thread_tools, array('colspan' => 3));
        $table->construct_row();
    }
    $table->output($lang->thread_tools);
    $page->output_footer();
}
Example #30
0
     if ($row['points'] > 0) {
         $points = '+' . $row['points'];
     }
     $table->construct_cell($username_link);
     $table->construct_cell("{$title} ({$points})");
     $table->construct_cell($issued_date, array("class" => "align_center"));
     $table->construct_cell($expire_date . $revoked_text, array("class" => "align_center"));
     $table->construct_cell($mod_username_link);
     $table->construct_cell("<a href=\"index.php?module=tools-warninglog&amp;action=view&amp;wid={$row['wid']}\">{$lang->view}</a>", array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_warning_logs, array("colspan" => "6"));
     $table->construct_row();
 }
 $table->output($lang->warning_logs);
 // Do we need to construct the pagination?
 if ($total_warnings > $per_page) {
     echo draw_admin_pagination($view_page, $per_page, $total_warnings, $url) . "<br />";
 }
 $sort_by = array('expires' => $lang->expiry_date, 'dateline' => $lang->issued_date, 'username' => $lang->warned_user, 'issuedby' => $lang->issued_by);
 $order_array = array('asc' => $lang->asc, 'desc' => $lang->desc);
 $form = new Form("index.php?module=tools-warninglog", "post");
 $form_container = new FormContainer($lang->filter_warning_logs);
 $form_container->output_row($lang->filter_warned_user, "", $form->generate_text_box('filter[username]', $mybb->input['filter']['username'], array('id' => 'filter_username')), 'filter_username');
 $form_container->output_row($lang->filter_issued_by, "", $form->generate_text_box('filter[mod_username]', $mybb->input['filter']['mod_username'], array('id' => 'filter_mod_username')), 'filter_mod_username');
 $form_container->output_row($lang->filter_reason, "", $form->generate_text_box('filter[reason]', $mybb->input['filter']['reason'], array('id' => 'filter_reason')), 'filter_reason');
 $form_container->output_row($lang->sort_by, "", $form->generate_select_box('filter[sortby]', $sort_by, $mybb->input['filter']['sortby'], array('id' => 'filter_sortby')) . " {$lang->in} " . $form->generate_select_box('filter[order]', $order_array, $order, array('id' => 'filter_order')) . " {$lang->order}", 'filter_order');
 $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('filter[per_page]', $per_page, array('id' => 'filter_per_page')), 'filter_per_page');
 $form_container->end();
 $buttons[] = $form->generate_submit_button($lang->filter_warning_logs);