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(); } }
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}¤t_mode={$rule->mode}¤t_notes={$rule->notes}\">Modify</a> / <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"); }
$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&action=add_thread_tool"); $sub_tabs['post_tools'] = array('title' => $lang->post_tools, 'link' => "index.php?module=config-mod_tools&action=post_tools"); $sub_tabs['add_post_tool'] = array('title' => $lang->add_new_post_tool, 'link' => "index.php?module=config-mod_tools&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&action=edit_thread_tool&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&action=edit_thread_tool&tid={$tool['tid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center")); $table->construct_cell("<a href=\"index.php?module=config-mod_tools&action=delete_thread_tool&tid={$tool['tid']}&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(); }
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&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&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; }
/** * 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}&action=views", 'description' => $lang->views_desc); $sub_tabs['create_view'] = array('title' => $lang->create_new_view, 'link' => "{$base_url}&action=views&do=add", 'description' => $lang->create_new_view_desc); $page->add_breadcrumb_item($lang->view_manager, 'index.php?module=user-users&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 . "&action=views&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}\">• {$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}\">• {$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 . "&action=views&do=edit&vid={$admin_view['vid']}", "post"); $sub_tabs = array(); $sub_tabs['edit_view'] = array('title' => $lang->edit_view, 'link' => $base_url . "&action=views&do=edit&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}\">• {$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}\">• {$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 . "&action=views&do=delete&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}&action=views&do=edit&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}&action=views&do=edit&vid={$view['vid']}"); if ($view['vid'] != $default_view) { $popup->add_item($lang->set_as_default, "{$base_url}&action=views&do=set_default&vid={$view['vid']}"); } if ($views > 1 && $view['vid'] != 1) { $popup->add_item($lang->delete_view, "{$base_url}&action=views&do=delete&vid={$view['vid']}&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(); } } } } }
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); }
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 . "&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 . "&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&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&action=manage-keys"); } else { $keyset = $result->fetch_array(); $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&action=manage-keys&do=edit&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&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&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&action=manage-keys&do=regenerate&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&action=manage-keys&do=edit&key_id={$keyset['id']}\">{$lang->restfulapi_edit}</a>", array("class" => "align_center", "width" => "6%")); $table->construct_cell("<a href=\"index.php?module=config-restfulapi&action=manage-keys&do=delete&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&action=manage-keys"); } else { $form = new Form("index.php?module=config-" . RESTFULAPI_URL . "&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(); } }
} else { $fids = array_unique(array_map('intval', array_map('trim', explode(',', $tf_forum)))); $fnames = ''; foreach ($fids as &$fid) { if (!isset($forums[$fid]['name'])) { // forum deleted $fname = '<em>' . $lang->sprintf($lang->threadfields_deleted_forum_id, $fid) . '</em>'; } else { $fname = $forums[$fid]['name']; } $fnames .= ($fnames ? ', ' : '') . $fname; } $celldata = $lang->sprintf($lang->threadfields_for_forums, $fnames); } $table->construct_cell($celldata, array('colspan' => 6, 'style' => 'padding: 2px;')); $table->construct_row(); } $tfname = htmlspecialchars_uni($tf['field']); $table->construct_cell('<a href="' . xthreads_admin_url('config', 'threadfields') . '&action=edit&field=' . urlencode($tf['field']) . '"><strong>' . htmlspecialchars_uni($tf['title']) . '</strong></a>'); // ... but generate_check_box doesn't have a "style" thing for the options array ... :( $table->construct_cell($tfname); $inputtype_lang = ''; switch ($tf['inputtype']) { case XTHREADS_INPUT_TEXT: $inputtype_lang = 'threadfields_inputtype_text'; break; case XTHREADS_INPUT_TEXTAREA: $inputtype_lang = 'threadfields_inputtype_textarea'; break; case XTHREADS_INPUT_SELECT: $inputtype_lang = 'threadfields_inputtype_select';
/** * Build a row for the table based form row. * * @param array $extra Array of extra options for the cell (optional). */ function construct_row($extra = array()) { $this->_container->construct_row($extra); }
function asb_admin_manage_modules() { global $lang, $mybb, $db, $page, $html, $min; $page->extra_header .= <<<EOF \t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" /> \t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script> EOF; $page->add_breadcrumb_item($lang->asb, $html->url()); $page->add_breadcrumb_item($lang->asb_manage_modules); $page->output_header("{$lang->asb} - {$lang->asb_manage_modules}"); asb_output_tabs('asb_modules'); $table = new Table(); $table->construct_header($lang->asb_name, array("width" => '22%')); $table->construct_header($lang->asb_description, array("width" => '55%')); $table->construct_header($lang->asb_modules_author, array("width" => '15%')); $table->construct_header($lang->asb_controls, array("width" => '8%')); $addons = asb_get_all_modules(); // if there are installed modules display them if (!empty($addons) && is_array($addons)) { foreach ($addons as $this_module) { $data = $this_module->get(array('title', 'description', 'base_name', 'author', 'author_site', 'module_site', 'version', 'public_version', 'compatibility')); $out_of_date = ''; if (!$data['compatibility'] || version_compare('2.1', $data['compatibility'], '<')) { $out_of_date = <<<EOF <br /><span style="color: red;">{$lang->asb_module_out_of_date}</span> EOF; } $version = $data['version']; if ($data['public_version']) { $version = $data['public_version']; } // title $table->construct_cell($html->link($data['module_site'], $data['title'], array("style" => 'font-weight: bold;')) . " ({$version})"); // description $table->construct_cell($data['description'] . $out_of_date); if ($data['author'] == 'Wildcard') { $data['author'] = 'default'; } $author = $data['author']; if ($data['author_site']) { $author = $html->link($data['author_site'], $data['author'], array("style" => 'font-weight: bold;')); } // author $table->construct_cell($author); // options pop-up $popup = new PopupMenu('module_' . $data['base_name'], $lang->asb_options); // delete $popup->add_item($lang->asb_delete, $html->url(array("action" => 'delete_addon', "addon" => $data['base_name'])), "return confirm('{$lang->asb_modules_del_warning}');"); // pop-up cell $table->construct_cell($popup->fetch(), array("width" => '10%')); // finish row $table->construct_row(); } } else { $table->construct_cell("<span style=\"color: gray;\">{$lang->asb_no_modules_detected}</span>", array("colspan" => 3)); $table->construct_row(); } $table->output($lang->asb_addon_modules); // build link bar and ACP footer asb_output_footer('addons'); }
function automedia_admin() { global $db, $lang, $mybb, $page, $cache, $run_module, $action_file; if (!isset($lang->automedia_modules)) { $lang->load("automedia"); } if ($page->active_action != 'automedia') { return false; } if ($run_module == 'tools' && $action_file == 'automedia') { $page->add_breadcrumb_item($lang->automedia, 'index.php?module=tools-automedia'); // Show site modules if ($mybb->input['action'] == "" || !$mybb->input['action']) { $page->add_breadcrumb_item($lang->automedia_modules); $page->output_header($lang->automedia_modules . ' - ' . $lang->automedia_modules); $sub_tabs['automedia'] = array('title' => $lang->automedia_modules, 'link' => 'index.php?module=tools-automedia', 'description' => $lang->automedia_modules_description1); if ($mybb->settings['av_adultsites'] == 1) { $sub_tabs['special'] = array('title' => $lang->automedia_adult, 'link' => 'index.php?module=tools-automedia&action=adult', 'description' => $lang->automedia_adult_description1); } $page->output_nav_tabs($sub_tabs, 'automedia'); $aotable = new Table(); $aotable->construct_header('#'); $aotable->construct_header($lang->automedia_oembed_desc); if (isset($mybb->settings['av_embera']) && $mybb->settings['av_embera'] == 1) { $aotable->construct_cell('<img src="styles/default/images/icons/success.png" width="16px" height="16px" alt="OK" />'); $aotable->construct_cell($lang->automedia_modules_embera); $aotable->construct_row(); } if (isset($mybb->settings['av_embedly']) && $mybb->settings['av_embedly'] == 1 && !empty($mybb->settings['av_embedly_key']) && $mybb->settings['av_embedly_key'] != "") { $aotable->construct_cell('<img src="styles/default/images/icons/success.png" width="16px" height="16px" alt="' . $lang->automedia_modules_success . '" />'); $aotable->construct_cell($lang->automedia_modules_embedly); $aotable->construct_row(); } $aotable->output($lang->automedia_oembed); $amtable = new Table(); $amtable->construct_header('#'); $amtable->construct_header($lang->automedia_modules_description2); $amtable->construct_header('<div style="text-align: center;">' . $lang->automedia_modules_status . '</div>'); $amtable->construct_header('<div style="text-align: center;">' . $lang->automedia_modules_options . ':</div>'); $folder = MYBB_ROOT . "inc/plugins/automedia/mediasites/"; if (is_dir($folder)) { $mediafiles = scandir($folder); $mediatitles = str_replace(".php", "", $mediafiles); $query = $db->simple_select('automedia', 'name', "class='site'"); // Find missing files for active modules while ($missing = $db->fetch_array($query)) { if (!in_array($missing['name'], $mediatitles)) { $missingfile = ucfirst(htmlspecialchars_uni($missing['name'])); $amtable->construct_cell('<strong>!</strong>'); $amtable->construct_cell('<strong>' . $missingfile . '</strong> (<a href="' . $sub_tabs['automedia']['link'] . '&action=deactivate&site=' . urlencode($missing['name']) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_deactivate . '</strong></a>)'); $amtable->construct_cell($lang->automedia_modules_notfound . ' ' . $folder . '' . htmlspecialchars_uni($missing['name']) . '.php', array('colspan' => '2')); $amtable->construct_row(); } } $i = 1; foreach ($mediafiles as $sites) { // Fetch all files in the folder $siteinfo = pathinfo($folder . "/" . $sites); if ($sites != "." && $sites != "..") { $filetype = "php"; // We need only php files if ($siteinfo['extension'] == $filetype) { $site = str_replace(".php", "", $sites); $media = ucfirst(htmlspecialchars_uni($site)); $check = file_get_contents($folder . $siteinfo['basename']); if (preg_match('"function automedia_"isU', $check)) { $amtable->construct_cell($i); $amtable->construct_cell('<a href="' . $sub_tabs['automedia']['link'] . '&action=showsite&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $media . '</strong></a>'); $query2 = $db->simple_select('automedia', '*', "name='" . htmlspecialchars_uni($site) . "'"); $active = $db->fetch_array($query2); if ($active && $active['class'] == "site") { $amtable->construct_cell('<div style="text-align: center;"><img src="' . $mybb->asset_url . '/images/mod-on.png" width="32" height="32" alt="' . $lang->automedia_modules_success . '" />'); $amtable->construct_cell('<div style="text-align: center;"><a href="' . $sub_tabs['automedia']['link'] . '&action=deactivate&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_deactivate . '</strong></a></div>'); } else { $amtable->construct_cell('<div style="text-align: center;"><img src="' . $mybb->asset_url . '/images/mod-off.png" width="32" height="32" alt="' . $lang->automedia_modules_fail . '" />'); $amtable->construct_cell('<div style="text-align: center;"><a href="' . $sub_tabs['automedia']['link'] . '&action=activate&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_activate . '</strong></a></div>'); } $amtable->construct_row(); $i++; } } } } if ($amtable->num_rows() == 0) { $amtable->construct_cell($lang->automedia_modules, array('colspan' => '4')); $amtable->construct_row(); } } else { $amtable->construct_cell($lang->automedia_modules_missing_sitesfolder, array('colspan' => '4')); $amtable->construct_row(); } $amtable->output($lang->automedia_modules); echo '<div style="text-align: center;"> <a href="' . $sub_tabs['automedia']['link'] . '&action=activateallsites&my_post_key=' . $mybb->post_code . '"><span style="border: 3px double #0F5C8E; padding: 3px; background: #fff url(images/submit_bg.png) repeat-x top; color: #0F5C8E; margin-right: 3px;">' . $lang->automedia_modules_activateall . '</span></a> </div>'; $page->output_footer(); } // Show special modules if ($mybb->input['action'] == "adult" && $mybb->settings['av_adultsites'] == 1) { $page->add_breadcrumb_item($lang->automedia_adult); $page->output_header($lang->automedia_modules . ' - ' . $lang->automedia_adult); $sub_tabs['automedia'] = array('title' => $lang->automedia_modules, 'link' => 'index.php?module=tools-automedia', 'description' => $lang->automedia_modules); if ($mybb->settings['av_adultsites'] == 1) { $sub_tabs['special'] = array('title' => $lang->automedia_adult, 'link' => 'index.php?module=tools-automedia&action=adult', 'description' => $lang->automedia_adult_description1); } $page->output_nav_tabs($sub_tabs, 'special'); $amtable = new Table(); $amtable->construct_header('#'); $amtable->construct_header($lang->automedia_modules_description2); $amtable->construct_header('<div style="text-align: center;">' . $lang->automedia_modules_status . '</div>'); $amtable->construct_header('<div style="text-align: center;">' . $lang->automedia_modules_options . ':</div>'); $folder = MYBB_ROOT . "inc/plugins/automedia/special/"; if (is_dir($folder)) { $mediafiles = scandir($folder); $mediatitles = str_replace(".php", "", $mediafiles); $query = $db->simple_select('automedia', 'name', "class='special'"); // Find missing files for active modules while ($missing = $db->fetch_array($query)) { if (!in_array($missing['name'], $mediatitles)) { $missingfile = ucfirst(htmlspecialchars_uni($missing['name'])); $amtable->construct_cell('<strong>!</strong>'); $amtable->construct_cell('<strong>' . $missingfile . '</strong> (<a href="' . $sub_tabs['automedia']['link'] . '&action=adultdeactivate&site=' . urlencode($missing['name']) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_deactivate . '</strong></a>)'); $amtable->construct_cell($lang->automedia_modules_notfound . ' ' . $folder . '' . htmlspecialchars_uni($missing['name']) . '.php', array('colspan' => '2')); $amtable->construct_row(); } } $i = 1; foreach ($mediafiles as $sites) { // Fetch all files in the folder $siteinfo = pathinfo($folder . "/" . $sites); if ($sites != "." && $sites != "..") { $filetype = "php"; // We need only php files if ($siteinfo['extension'] == $filetype) { $site = str_replace(".php", "", $sites); $media = ucfirst(htmlspecialchars_uni($site)); $check = file_get_contents($folder . $siteinfo['basename']); if (preg_match('"function automedia_"isU', $check)) { $amtable->construct_cell($i); $amtable->construct_cell('<a href="' . $sub_tabs['automedia']['link'] . '&action=showspecial&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $media . '</strong></a>'); $query = $db->simple_select('automedia', '*', "name='" . htmlspecialchars_uni($site) . "'"); $active = $db->fetch_array($query); if ($active && $active['class'] == "special") { $amtable->construct_cell('<div style="text-align: center;"><img src="' . $mybb->asset_url . '/images/mod-on.png" width="32" height="32" alt="' . $lang->automedia_modules_success . '" />'); $amtable->construct_cell('<div style="text-align: center;"><a href="' . $sub_tabs['automedia']['link'] . '&action=adultdeactivate&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_deactivate . '</strong></a></div>'); } else { $amtable->construct_cell('<div style="text-align: center;"><img src="' . $mybb->asset_url . '/images/mod-off.png" width="32" height="32" alt="' . $lang->automedia_modules_fail . '" />'); $amtable->construct_cell('<div style="text-align: center;"><a href="' . $sub_tabs['automedia']['link'] . '&action=adultactivate&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '"><strong>' . $lang->automedia_modules_activate . '</strong></a></div>'); } $amtable->construct_row(); $i++; } } } } if ($amtable->num_rows() == 0) { $amtable->construct_cell($lang->automedia_adult, array('colspan' => '4')); $amtable->construct_row(); } } else { $amtable->construct_cell($lang->automedia_modules_missing_specialfolder, array('colspan' => '4')); $amtable->construct_row(); } $amtable->output($lang->automedia_modules); echo '<div style="text-align: center;"> <a href="' . $sub_tabs['automedia']['link'] . '&action=activateallspecial&my_post_key=' . $mybb->post_code . '"><span style="border: 3px double #0F5C8E; padding: 3px; background: #fff url(images/submit_bg.png) repeat-x top; color: #0F5C8E; margin-right: 3px;">' . $lang->automedia_modules_activateall . '</span></a> </div>'; $page->output_footer(); } // Activate site module if ($mybb->input['action'] == 'activate') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $query_act1 = $db->simple_select('automedia', '*', "name='" . $site . "'"); $active1 = $db->fetch_array($query_act1); if (!$active1) { $automedia_site = array("name" => $site, "class" => "site"); $db->insert_query("automedia", $automedia_site); automedia_cache(); $mybb->input['module'] = $lang->av_plugin_title; $mybb->input['action'] = $lang->automedia_modules_active . " "; log_admin_action(ucfirst($site)); flash_message($lang->automedia_modules_active, 'success'); admin_redirect("index.php?module=tools-automedia"); } else { flash_message($lang->automedia_modules_notfound, 'error'); } } exit; } // Activate special module if ($mybb->input['action'] == 'adultactivate') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia&action=adult"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $query_act2 = $db->simple_select('automedia', '*', "name='" . $site . "'"); $active2 = $db->fetch_array($query_act2); if (!$active2) { $automedia_special = array("name" => $site, "class" => "special"); $db->insert_query("automedia", $automedia_special); automedia_cache(); $mybb->input['module'] = $lang->av_plugin_title; $mybb->input['action'] = $lang->automedia_modules_active . " "; log_admin_action(ucfirst($site)); flash_message($lang->automedia_modules_active, 'success'); admin_redirect("index.php?module=tools-automedia&action=adult"); } else { flash_message($lang->automedia_modules_notfound, 'error'); } } exit; } // Deactivate site module if ($mybb->input['action'] == 'deactivate') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $query_del1 = $db->simple_select('automedia', '*', "name='" . $site . "'"); $delete1 = $db->fetch_array($query_del1); if ($delete1['name'] == $site) { $db->delete_query('automedia', "name='{$site}'"); automedia_cache(); $mybb->input['module'] = $lang->av_plugin_title; $mybb->input['action'] = $lang->automedia_modules_deleted . " "; log_admin_action(ucfirst($site)); flash_message($lang->automedia_modules_deleted, 'success'); admin_redirect("index.php?module=tools-automedia"); } else { flash_message($lang->automedia_modules_notfound, 'error'); } } exit; } // Deactivate special module if ($mybb->input['action'] == 'adultdeactivate') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia&action=adult"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $query_del2 = $db->simple_select('automedia', '*', "name='" . $site . "'"); $delete2 = $db->fetch_array($query_del2); if ($delete2['name'] == $site) { $db->delete_query('automedia', "name='{$site}'"); automedia_cache(); $mybb->input['module'] = $lang->av_plugin_title; $mybb->input['action'] = $lang->automedia_modules_deleted . " "; log_admin_action(ucfirst($site)); flash_message($lang->automedia_modules_deleted, 'success'); admin_redirect("index.php?module=tools-automedia&action=adult"); } else { flash_message($lang->automedia_modules_notfound, 'error'); } } exit; } // Activate all site modules if ($mybb->input['action'] == 'activateallsites') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $folder1 = MYBB_ROOT . "inc/plugins/automedia/mediasites/"; if (is_dir($folder1)) { $mediafiles1 = scandir($folder1); foreach ($mediafiles1 as $sites1) { // Fetch all files in the folder $siteinfo1 = pathinfo($folder1 . "/" . $sites1); if ($sites1 != "." && $sites1 != "..") { $filetype1 = "php"; // We need only php files if ($siteinfo1['extension'] == $filetype1) { $media1 = str_replace(".php", "", $sites1); $check1 = file_get_contents($folder1 . $siteinfo1['basename']); if (preg_match('"function automedia_"isU', $check1)) { $query_ex = $db->simple_select('automedia', 'name', "name='" . htmlspecialchars_uni($media1) . "'"); $modactive = $db->fetch_array($query_ex); if (!$modactive) { // activate site $automedia_site1 = array("name" => htmlspecialchars_uni($media1), "class" => "site"); $db->insert_query("automedia", $automedia_site1); } } } } } automedia_cache(); } } admin_redirect("index.php?module=tools-automedia"); exit; } // Activate all special modules if ($mybb->input['action'] == 'activateallspecial') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $folder2 = MYBB_ROOT . "inc/plugins/automedia/special/"; if (is_dir($folder2)) { $mediafiles2 = scandir($folder2); foreach ($mediafiles2 as $sites2) { // Fetch all files in the folder $siteinfo2 = pathinfo($folder2 . "/" . $sites2); if ($sites2 != "." && $sites2 != "..") { $filetype2 = "php"; // We need only php files if ($siteinfo2['extension'] == $filetype2) { $media2 = str_replace(".php", "", $sites2); $check2 = file_get_contents($folder2 . $siteinfo2['basename']); if (preg_match('"function automedia_"isU', $check2)) { $query_ex2 = $db->simple_select('automedia', 'name', "name='" . htmlspecialchars_uni($media2) . "'"); $modactive2 = $db->fetch_array($query_ex2); if (!$modactive2) { // add site $automedia_site2 = array("name" => htmlspecialchars_uni($media2), "class" => "special"); $db->insert_query("automedia", $automedia_site2); } } } } } automedia_cache(); } } admin_redirect("index.php?module=tools-automedia&action=adult"); exit; } // Show site module code if ($mybb->input['action'] == 'showsite') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $page->add_breadcrumb_item($lang->automedia_modules_embedcode); $page->output_header($lang->automedia_modules_showcode); $sub_tabs['automedia'] = array('title' => $lang->automedia_modules, 'link' => 'index.php?module=tools-automedia', 'description' => $lang->automedia_modules); if ($mybb->settings['av_adultsites'] == 1) { $sub_tabs['special'] = array('title' => $lang->automedia_adult, 'link' => 'index.php?module=tools-automedia&action=adult', 'description' => $lang->automedia_adult_description1); } $sub_tabs['embedcode'] = array('title' => $lang->automedia_modules_embedcode, 'link' => 'index.php?module=tools-automedia&action=showsite&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '', 'description' => $lang->automedia_modules_viewcode); $page->output_nav_tabs($sub_tabs, 'embedcode'); $amtable = new Table(); $amtable->construct_header(ucfirst($site) . ' ' . $lang->automedia_modules_embedcode . ':'); $codefile = MYBB_ROOT . "inc/plugins/automedia/mediasites/" . $site . ".php"; if (is_file($codefile)) { $embedcode = file_get_contents($codefile); $showcode = @highlight_string($embedcode, true); $amtable->construct_cell($showcode); } $amtable->construct_row(); $amtable->output($lang->automedia_modules_showcode); $page->output_footer(); } exit; } // Show special module code if ($mybb->input['action'] == 'showspecial') { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=tools-automedia"); } else { $site = htmlspecialchars_uni($mybb->input['site']); $page->add_breadcrumb_item($lang->automedia_modules_embedcode); $page->output_header($lang->automedia_modules_showcode); $sub_tabs['automedia'] = array('title' => $lang->automedia_modules, 'link' => 'index.php?module=tools-automedia', 'description' => $lang->automedia_modules); if ($mybb->settings['av_adultsites'] == 1) { $sub_tabs['special'] = array('title' => $lang->automedia_adult, 'link' => 'index.php?module=tools-automedia&action=adult', 'description' => $lang->automedia_adult_description1); } $sub_tabs['embedcode'] = array('title' => $lang->automedia_modules_embedcode, 'link' => 'index.php?module=tools-automedia&action=showspecial&site=' . urlencode($site) . '&my_post_key=' . $mybb->post_code . '', 'description' => $lang->automedia_modules_viewcode); $page->output_nav_tabs($sub_tabs, 'embedcode'); $amtable = new Table(); $amtable->construct_header(ucfirst($site) . ' ' . $lang->automedia_modules_embedcode . ':'); $codefile = MYBB_ROOT . "inc/plugins/automedia/special/" . $site . ".php"; if (is_file($codefile)) { $embedcode = file_get_contents($codefile); $showcode = @highlight_string($embedcode, true); $amtable->construct_cell($showcode); } $amtable->construct_row(); $amtable->output($lang->automedia_modules_showcode); $page->output_footer(); } exit; } // Reapply template edits if ($mybb->input['action'] == "templateedits") { if (!verify_post_check($mybb->input['my_post_key'])) { flash_message($lang->invalid_post_verify_key2, 'error'); admin_redirect("index.php?module=config-plugins"); } else { automedia_reapply_template_edits(); admin_redirect("index.php?module=config-plugins"); } exit; } } }
/** * Displays peekers in settings **/ function myfbconnect_settings_footer() { global $mybb, $db, $lang; if ($mybb->input["action"] == "change" and $mybb->request_method != "post") { $gid = myfbconnect_settings_gid(); if ($mybb->input['gid'] == $gid) { // Delete reports if ($mybb->input['delete_report']) { switch ($mybb->input['delete_report']) { case 'all': $db->delete_query('myfbconnect_reports'); break; default: $db->delete_query('myfbconnect_reports', 'id = ' . (int) $mybb->input['delete_report']); } flash_message($lang->myfbconnect_success_deleted_reports, 'success'); admin_redirect('index.php?module=config-settings&action=change&gid=' . $gid); } $reports = array(); $query = $db->simple_select('myfbconnect_reports'); while ($report = $db->fetch_array($query)) { $reports[] = $report; } if ($reports) { $table = new Table(); $table->construct_header($lang->myfbconnect_reports_date, array('width' => '15%')); $table->construct_header($lang->myfbconnect_reports_code, array('width' => '5%')); $table->construct_header($lang->myfbconnect_reports_file); $table->construct_header($lang->myfbconnect_reports_line, array('width' => '5%')); $table->construct_header($lang->options, array('width' => '10%', 'style' => 'text-align: center')); foreach ($reports as $report) { foreach ($report as $k => $val) { if (in_array($k, array('id', 'message', 'trace'))) { continue; } if ($k == 'dateline') { $val = my_date($mybb->settings['dateformat'], $val) . ', ' . my_date($mybb->settings['timeformat'], $val); } $table->construct_cell($val); } $popup = new PopupMenu("item_{$report['id']}", $lang->options); $popup->add_item($lang->myfbconnect_reports_download, 'index.php?module=config-settings&action=change&gid=' . $gid . '&export_id=' . $report['id']); $popup->add_item($lang->myfbconnect_reports_delete, 'index.php?module=config-settings&action=change&gid=' . $gid . '&delete_report=' . $report['id']); $table->construct_cell($popup->fetch(), array('class' => 'align_center')); $table->construct_row(); } $table->construct_cell('<a href="index.php?module=config-settings&action=change&gid=' . $gid . '&delete_report=all" class="button">' . $lang->myfbconnect_reports_delete_all . '</a>', array('colspan' => 5, 'class' => 'align_center')); $table->construct_row(); $table->output($lang->myfbconnect_reports); } } if ($mybb->input["gid"] == $gid or !$mybb->input['gid']) { // 1.8 has jQuery, not Prototype if ($mybb->version_code >= 1700) { echo '<script type="text/javascript"> $(document).ready(function() { loadMyFBConnectPeekers(); loadStars(); }); function loadMyFBConnectPeekers() { new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_subject"), /1/, true); new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_message"), /1/, true); new Peeker($(".setting_myfbconnect_passwordpm"), $("#row_setting_myfbconnect_passwordpm_fromid"), /1/, true); new Peeker($(".setting_myfbconnect_fbbio"), $("#row_setting_myfbconnect_fbbiofield"), /1/, true); new Peeker($(".setting_myfbconnect_fblocation"), $("#row_setting_myfbconnect_fblocationfield"), /1/, true); new Peeker($(".setting_myfbconnect_fbdetails"), $("#row_setting_myfbconnect_fbdetailsfield"), /1/, true); new Peeker($(".setting_myfbconnect_fbsex"), $("#row_setting_myfbconnect_fbsexfield"), /1/, true); new Peeker($(".setting_myfbconnect_postonwall"), $("#row_setting_myfbconnect_postonwall_message"), /1/, true); } function loadStars() { add_star("row_setting_myfbconnect_appid"); add_star("row_setting_myfbconnect_appsecret"); } </script>'; } else { echo '<script type="text/javascript"> Event.observe(window, "load", function() { loadMyFBConnectPeekers(); loadStars(); }); function loadMyFBConnectPeekers() { new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_subject"), /1/, true); new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_message"), /1/, true); new Peeker($$(".setting_myfbconnect_passwordpm"), $("row_setting_myfbconnect_passwordpm_fromid"), /1/, true); new Peeker($$(".setting_myfbconnect_fbbio"), $("row_setting_myfbconnect_fbbiofield"), /1/, true); new Peeker($$(".setting_myfbconnect_fblocation"), $("row_setting_myfbconnect_fblocationfield"), /1/, true); new Peeker($$(".setting_myfbconnect_fbdetails"), $("row_setting_myfbconnect_fbdetailsfield"), /1/, true); new Peeker($$(".setting_myfbconnect_fbsex"), $("row_setting_myfbconnect_fbsexfield"), /1/, true); new Peeker($$(".setting_myfbconnect_postonwall"), $("row_setting_myfbconnect_postonwall_message"), /1/, true); } function loadStars() { add_star("row_setting_myfbconnect_appid"); add_star("row_setting_myfbconnect_appsecret"); } </script>'; } } } }
function PHP_files_cleaner_actions() { global $lang, $mybb, $sub_tabs; $lang->load('PHP_files_cleaner_acp'); $sub_tabs['PHP_files_cleaner'] = array('title' => $lang->PHP_files_cleaner, 'link' => 'index.php?module=tools-system_health&action=clean_PHP_files', 'description' => $lang->PHP_files_cleaner_info); if ($mybb->input['action'] == 'do_clean_PHP_files' && $mybb->request_method == 'post') { $errors = array(); $lead = $mybb->get_input('leading', MyBB::INPUT_ARRAY); $trail = $mybb->get_input('trailing', MyBB::INPUT_ARRAY); if (!$mybb->settings['PHP_files_cleaner_leading'] && !$mybb->settings['PHP_files_cleaner_trailing']) { $errors[] = $lang->PHP_files_cleaner_nothing_enabled; } if (empty($lead) && empty($trail)) { $errors[] = $lang->PHP_files_cleaner_nothing_chosen; } if (!$errors) { $leadandtrail = array_unique(array_merge($lead, $trail)); $nonchangeable = array(); foreach ($leadandtrail as $filename) { $fullfilename = MYBB_ROOT . $filename; if (is_readable($fullfilename) && is_writable($fullfilename)) { $file = file_get_contents($fullfilename); // Remove BOM and leading whitespace if ($mybb->settings['PHP_files_cleaner_leading'] && in_array($filename, $lead)) { $file = preg_replace('/^\\x{FEFF}?\\s*/u', '', $file); } // Remove ending tag and trailing whitespace if ($mybb->settings['PHP_files_cleaner_trailing'] && in_array($filename, $trail)) { $file = preg_replace('/(\\s*\\?>)?\\s*$/', '', $file); } file_put_contents($fullfilename, $file); } else { $nonchangeable[] = htmlspecialchars_uni($filename); } } if ($nonchangeable) { flash_message($lang->sprintf($lang->PHP_files_cleaner_nonchangeable, implode($lang->comma, $nonchangeable)), 'error'); } else { flash_message($lang->PHP_files_cleaner_success, 'success'); } admin_redirect('index.php?module=tools-system_health&action=clean_PHP_files'); } else { $mybb->input['action'] = 'clean_PHP_files'; } } if ($mybb->input['action'] == 'clean_PHP_files') { global $page; $page->add_breadcrumb_item($lang->PHP_files_cleaner); $page->output_header($lang->PHP_files_cleaner); $page->output_nav_tabs($sub_tabs, 'PHP_files_cleaner'); if (!empty($errors)) { $page->output_inline_error($errors); } $table = new Table(); if (!$mybb->settings['PHP_files_cleaner_leading'] && !$mybb->settings['PHP_files_cleaner_trailing']) { $table->construct_cell($lang->PHP_files_cleaner_nothing_enabled); $table->construct_row(); } else { $leading = $trailing = array(); $diriterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(MYBB_ROOT)); $phpfiles = new RegexIterator($diriterator, '/\\.php$/i', RegexIterator::GET_MATCH); foreach ($phpfiles as $filename => $info) { if (is_readable($filename)) { $contents = file_get_contents($filename); if ($mybb->settings['PHP_files_cleaner_leading'] && preg_match('/^\\x{FEFF}?\\s*/u', $contents, $matches) && $matches[0]) { $leading[] = $filename; } if ($mybb->settings['PHP_files_cleaner_trailing'] && preg_match('/(\\s*\\?>)?\\s*$/', $contents, $matches) && $matches[0]) { $trailing[] = $filename; } } } // Filenames sorted by the number of issues $cnt = array_count_values(array_merge($leading, $trailing)); arsort($cnt); $allfiles = array_keys($cnt); if (empty($allfiles)) { $table->construct_cell($lang->PHP_files_cleaner_nothing_found); $table->construct_row(); } else { $form = new Form('index.php?module=tools-system_health&action=do_clean_PHP_files', 'post'); $table->construct_header($lang->PHP_files_cleaner_filename); $table->construct_header($lang->PHP_files_cleaner_leading, array('class' => 'align_center')); $table->construct_header($lang->PHP_files_cleaner_trailing, array('class' => 'align_center')); $table->construct_header($form->generate_check_box('allbox', 1, '', array('class' => 'checkall', 'checked' => 1)), array('style' => 'text-align: right;')); foreach ($allfiles as $filename) { $clean_filename = htmlspecialchars_uni(str_replace(MYBB_ROOT, '', $filename)); $leading_cbox = in_array($filename, $leading) ? $form->generate_check_box('leading[]', $clean_filename, '', array('checked' => 1)) : ''; $trailing_cbox = in_array($filename, $trailing) ? $form->generate_check_box('trailing[]', $clean_filename, '', array('checked' => 1)) : ''; $table->construct_cell($clean_filename); $table->construct_cell($leading_cbox, array('class' => 'align_center')); $table->construct_cell($trailing_cbox, array('class' => 'align_center')); $table->construct_cell(''); $table->construct_row(); } } } $table->output($lang->PHP_files_cleaner); if (!empty($allfiles)) { $buttons[] = $form->generate_submit_button($lang->PHP_files_cleaner_clean, array('name' => 'clean')); $form->output_submit_wrapper($buttons); $form->end(); } $page->output_footer(); } }
function GalleryPermissions() { global $page, $db, $lang, $mybb; $page->output_header($lang->gallery_text_title . ' - ' . $lang->gallery_text_permissions); DoGalleryAdminTabs('ezgallery_permissions'); echo ' <form method="post" name="frmpermissions" action="index.php?module=config/ezgallery&action=permissions2"> '; $table = new Table(); $table->construct_header($lang->gallery_membergroup); $table->construct_header($lang->permissionname_ezgallery_view); $table->construct_header($lang->permissionname_ezgallery_add); $table->construct_header($lang->permissionname_ezgallery_edit); $table->construct_header($lang->permissionname_ezgallery_delete); $table->construct_header($lang->permissionname_ezgallery_comment); $table->construct_header($lang->permissionname_ezgallery_report); $table->construct_header($lang->permissionname_ezgallery_autoapprove); $table->construct_header($lang->permissionname_ezgallery_manage); $dbresult = $db->query("\n\t\t \tSELECT\n\t\t \t\tu.title, p.ID_GROUP, u.gid,\n\t\t \t\tp.view,p.add,p.edit,p.delete,p.comment,p.report,p.autoapprove, p.manage\n\t\t \tFROM " . TABLE_PREFIX . "usergroups AS u\n\t\t \tLEFT JOIN " . TABLE_PREFIX . "gallery_permissions as p ON (p.ID_GROUP = u.gid)\n\t\t \t"); while ($row = $db->fetch_array($dbresult)) { $table->construct_cell($row['title']); $table->construct_cell('<input type="checkbox" name="view_' . $row['gid'] . '" ' . ($row['view'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="add_' . $row['gid'] . '" ' . ($row['add'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="edit_' . $row['gid'] . '" ' . ($row['edit'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="delete_' . $row['gid'] . '" ' . ($row['delete'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="comment_' . $row['gid'] . '" ' . ($row['comment'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="report_' . $row['gid'] . '" ' . ($row['report'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="autoapprove_' . $row['gid'] . '" ' . ($row['autoapprove'] ? ' checked="checked"' : '') . ' />'); $table->construct_cell('<input type="checkbox" name="manage_' . $row['gid'] . '" ' . ($row['manage'] ? ' checked="checked"' : '') . ' />'); $table->construct_row(); } $table->construct_cell('<input type="submit" value="' . $lang->gallery_update_permissions . '" />', array("colspan" => 9)); $table->construct_row(); $table->output($lang->gallery_text_permissions); echo ' <input type="hidden" name="my_post_key" value="' . $mybb->post_code . '" /> </form>'; $page->output_footer(); }