Beispiel #1
0
function mysupport_do_uninstall()
{
    global $mybb, $db, $cache, $mysupport_uninstall_confirm_override;
    // this is a check to make sure we want to uninstall
    // if 'No' was chosen on the confirmation screen, redirect back to the plugins page
    if ($mybb->input['no']) {
        admin_redirect("index.php?module=config-plugins");
    } else {
        // there's a post request so we submitted the form and selected yes
        // or the confirmation is being overridden by the installation function; this is for when mysupport_uninstall() is called at the start of mysupport_install(), we just want to execute the uninstall code at this point
        if ($mybb->request_method == "post" || $mysupport_uninstall_confirm_override === true || $mybb->input['action'] == "delete") {
            mysupport_table_columns(-1);
            if ($db->table_exists("mysupport")) {
                $db->drop_table("mysupport");
            }
            $db->delete_query("settinggroups", "name = 'mysupport'");
            $settings = mysupport_setting_names();
            $settings = "'" . implode("','", array_map($db->escape_string, $settings)) . "'";
            // have to use $db->escape_string above instead of around $settings directly because otherwise it escapes the ' around the names, which are important
            $db->delete_query("settings", "name IN ({$settings})");
            rebuild_settings();
            mysupport_do_templates(0, false);
            mysupport_stylesheet(-1);
            $cache->update_forums();
            $cache->update_usergroups();
            $db->delete_query("datacache", "title = 'mysupport'");
        } else {
            global $lang, $page;
            $lang->load("config_mysupport");
            $page->output_confirm_action("index.php?module=config-plugins&action=deactivate&uninstall=1&plugin=mysupport&my_post_key={$mybb->post_code}", $lang->mysupport_uninstall_warning);
        }
    }
}
function mytwconnect_uninstall()
{
    global $db, $PL, $cache, $lang;
    if (!$lang->mytwconnect) {
        $lang->load('mytwconnect');
    }
    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->mytwconnect_pluginlibrary_missing, "error");
        admin_redirect("index.php?module=config-plugins");
    }
    $PL or (require_once PLUGINLIBRARY);
    // Drop settings
    $PL->settings_delete('mytwconnect');
    // Delete our columns
    $db->query("ALTER TABLE " . TABLE_PREFIX . "users DROP `twavatar`, DROP `twbio`, DROP `twlocation`, DROP `mytw_uid`");
    // Delete the plugin from cache
    $info = mytwconnect_info();
    $shadePlugins = $cache->read('shade_plugins');
    unset($shadePlugins[$info['name']]);
    $cache->update('shade_plugins', $shadePlugins);
    $PL->templates_delete('mytwconnect');
    // Try to update templates
    require_once MYBB_ROOT . 'inc/adminfunctions_templates.php';
    find_replace_templatesets('header_welcomeblock_guest', '#' . preg_quote('&mdash; <a href="{$mybb->settings[\'bburl\']}/mytwconnect.php?action=login">{$lang->mytwconnect_login}</a>') . '#i', '');
}
 private function update()
 {
     global $db, $mybb, $cache, $lang;
     $new_settings = $drop_settings = array();
     // Get the gid
     $query = $db->simple_select("settinggroups", "gid", "name='mytwconnect'");
     $gid = (int) $db->fetch_field($query, "gid");
     // 1.0.2
     if (version_compare($this->old_version, '1.0.1', "<")) {
         require_once MYBB_ROOT . "inc/adminfunctions_templates.php";
         find_replace_templatesets('mytwconnect_usercp_settings', '#' . preg_quote('<input type="submit" value="{$lang->mytwconnect_settings_save}" />') . '#i', '<input type="submit" class=\\"button\\" value="{$lang->mytwconnect_settings_save}" />{$unlink}');
     }
     // 2.0
     if (version_compare($this->old_version, '2.0', "<")) {
         $new_settings[] = array("name" => "mytwconnect_twavatar", "title" => $db->escape_string($lang->setting_mytwconnect_twavatar), "description" => $db->escape_string($lang->setting_mytwconnect_twavatar_desc), "optionscode" => "yesno", "value" => 1, "disporder" => 30, "gid" => $gid);
         $new_settings[] = array("name" => "mytwconnect_tweet", "title" => $db->escape_string($lang->setting_mytwconnect_tweet), "description" => $db->escape_string($lang->setting_mytwconnect_tweet_desc), "optionscode" => "yesno", "value" => 0, "disporder" => 31, "gid" => $gid);
         $new_settings[] = array("name" => "mytwconnect_tweet_message", "title" => $db->escape_string($lang->setting_mytwconnect_tweet_message), "description" => $db->escape_string($lang->setting_mytwconnect_tweet_message_desc), "optionscode" => "textarea", "value" => $lang->mytwconnect_default_tweet, "disporder" => 32, "gid" => $gid);
         // Let's at least try to change that, anyway, 2.0 has backward compatibility so it doesn't matter if this fails
         require_once MYBB_ROOT . "inc/adminfunctions_templates.php";
         find_replace_templatesets('header_welcomeblock_guest', '#' . preg_quote('twlogin') . '#i', 'login');
     }
     if ($new_settings) {
         $db->insert_query_multiple('settings', $new_settings);
     }
     if ($drop_settings) {
         $db->delete_query('settings', "name IN ('mytwconnect_" . implode("','mytwconnect_", $drop_settings) . "')");
     }
     rebuild_settings();
     // Update the current version number and redirect
     $this->plugins[$this->info['name']] = array('title' => $this->info['name'], 'version' => $this->version);
     $cache->update('shade_plugins', $this->plugins);
     flash_message($lang->sprintf($lang->mytwconnect_success_updated, $this->old_version, $this->version), "success");
     admin_redirect($_SERVER['HTTP_REFERER']);
 }
Beispiel #4
0
function tslink_install()
{
    global $db, $PL, $lang, $mybb;
    if (!$lang->tslink) {
        $lang->load('tslink');
    }
    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->tslink_pluginlibrary_missing, 'error');
        admin_redirect('index.php?module=config-plugins');
    }
    $PL or (require_once PLUGINLIBRARY);
    $PL->settings('tslink_settings', $lang->setting_group_tslink, $lang->setting_group_tslink_desc, ['enabled' => ['title' => $lang->setting_tslink_enable, 'description' => $lang->setting_tslink_enable_desc, 'value' => '1'], 'onregister' => ['title' => $lang->setting_tslink_onregister, 'description' => $lang->setting_tslink_onregister_desc, 'value' => '1'], 'admincp' => ['title' => $lang->setting_tslink_admincp, 'description' => $lang->setting_tslink_admincp_desc, 'value' => '1'], 'modcp' => ['title' => $lang->setting_tslink_modcp, 'description' => $lang->setting_tslink_modcp_desc, 'value' => '1'], 'usercp' => ['title' => $lang->setting_tslink_usercp, 'description' => $lang->setting_tslink_usercp_desc, 'value' => '1']]);
    if ($db->field_exists('memberstatus', 'users')) {
        // Don't do anything
    } else {
        // Insert our memberstatus column into the database.
        $db->query('ALTER TABLE ' . TABLE_PREFIX . 'users ADD (`memberstatus` int(10) NOT NULL DEFAULT 0)');
    }
    $db->query('CREATE TABLE IF NOT EXISTS ' . TABLE_PREFIX . 'tslink_uids (
          uid int(10) NOT NULL,
          ts_uid varchar(50) NOT NULL,
          ts_cldbid int(10) DEFAULT NULL,
          UNIQUE KEY (uid)
        ) ');
}
Beispiel #5
0
function loginconvert_activate()
{
    global $db;
    // Don't activate the plugin if it isn't needed
    if (!$db->field_exists("passwordconvert", "users")) {
        flash_message("There's no need to activate this plugin as there aren't any passwords which need to be converted", "error");
        admin_redirect("index.php?module=config-plugins");
    }
}
Beispiel #6
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();
    }
}
function ApprovePicture()
{
    global $db, $lang;
    $id = intval($_REQUEST['id']);
    if (empty($id)) {
        fatal_error($lang['gallery_error_no_pic_selected']);
    }
    // Update the approval
    $db->query("UPDATE " . TABLE_PREFIX . "gallery_pic SET approved = 1 WHERE ID_PICTURE = {$id} LIMIT 1");
    // Redirect to approval list
    admin_redirect('index.php?module=config/ezgallery&action=approvelist');
}
function cloudflare_install()
{
    global $mybb, $db, $config;
    $setting_group = array("name" => "cloudflare", "title" => "CloudFlare Manager", "description" => "Configures options for the CloudFlare Manager plugin.", "disporder" => "1");
    $gid = $db->insert_query("settinggroups", $setting_group);
    $dispnum = 0;
    $parse = parse_url($mybb->settings['bburl']);
    $domain = $parse['host'];
    $domain = str_replace('www.', '', $domain);
    $settings = array("cloudflare_domain" => array("title" => "Domain", "description" => "The domain (of this forum) that is active under CloudFlare", "optionscode" => "text", "value" => $domain, "disporder" => ++$dispnum), "cloudflare_email" => array("title" => "Email", "description" => "Your email address linked to your CloudFlare account", "optionscode" => "text", "value" => $mybb->user['email'], "disporder" => ++$dispnum), "cloudflare_api" => array("title" => "API Key", "description" => "Your CloudFlare API key. You can get this key <a href=\"https://www.cloudflare.com/a/account/my-account\">here</a>", "optionscode" => "text", "value" => "", "disporder" => ++$dispnum), "cloudflare_showdns" => array("title" => "Show DNS?", "description" => "Do you want to show the IP address host on Recent Visitors? *May slow down process if enabled.", "optionscode" => "yesno", "value" => "0", "disporder" => ++$dispnum), "cloudflare_backlink" => array("title" => "Show \"Enhanced By CloudFlare\" message?", "description" => "Do you want to show the enchanced by CloudFlare message in your board footer? It helps to expand the CloudFlare network and speed up more websites on the internet.", "optionscode" => "yesno", "value" => "1", "disporder" => ++$dispnum));
    foreach ($settings as $name => $setting) {
        $setting['gid'] = $gid;
        $setting['name'] = $name;
        $db->insert_query("settings", $setting);
    }
    rebuild_settings();
    admin_redirect("index.php?module=config-settings&action=change&gid={$gid}");
}
Beispiel #9
0
function myprofile_uninstall()
{
    global $mybb;
    if ($mybb->request_method == 'post') {
        if (!verify_post_check($mybb->input['my_post_key'])) {
            global $lang;
            flash_message($lang->invalid_post_verify_key2, 'error');
            admin_redirect("index.php?module=config-plugins");
        }
        if (isset($mybb->input['no'])) {
            admin_redirect('index.php?module=config-plugins');
        }
        myprofile_bundles_propagate_call("uninstall");
        $mybb->cache->delete("myprofile");
        return true;
    }
    global $page;
    $page->output_confirm_action("index.php?module=config-plugins&action=deactivate&uninstall=1&plugin=myprofile");
}
function cloudflare_meta()
{
    global $mybb, $page, $plugins, $cache;
    if ($mybb->input['module'] == 'cloudflare') {
        if (cloudflare_is_installed() == false) {
            flash_message('CloudFlare Manager hasn\'t been installed. Please install it before continuing.', 'error');
            admin_redirect("index.php?module=config-plugins");
            exit;
        }
    }
    if (!$cache->read("cloudflare_zone_id")) {
        get_cloudflare_zone_id();
    }
    $sub_menu = array();
    $sub_menu['10'] = array("id" => "overview", "title" => "CloudFlare Overview", "link" => "index.php?module=cloudflare-overview");
    $sub_menu['20'] = array("id" => "dev_mode", "title" => "Development Mode", "link" => "index.php?module=cloudflare-dev_mode");
    $sub_menu = $plugins->run_hooks("admin_cloudflare_menu", $sub_menu);
    $page->add_menu_item("CloudFlare Manager", "cloudflare", "index.php?module=cloudflare", 60, $sub_menu);
    return true;
}
Beispiel #11
0
function recentthread_install()
{
    global $db, $mybb;
    if ($mybb->version_code < 1801) {
        flash_message("Sorry, but this plugin requires you to update to 1.8.1 or higher.", "error");
        admin_redirect("index.php?module=config-plugins");
    }
    // Add some settings
    $new_setting_group = array("name" => "recentthreads", "title" => "Recent Threads Settings", "description" => "Customize various aspects of recent threads", "disporder" => 77, "isdefault" => 0);
    $gid = $db->insert_query("settinggroups", $new_setting_group);
    $new_setting[] = array("name" => "recentthread_threadcount", "title" => "Number of Threads", "description" => "How many threads are shown.", "optionscode" => "numeric", "disporder" => 1, "value" => 15, "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_threadavatar", "title" => $db->escape_string("Show thread starter's avatar"), "description" => $db->escape_string("If set to yes, the thread starter's avatar will be shown."), "optionscode" => "yesno", "disporder" => 2, "value" => 0, "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_lastavatar", "title" => $db->escape_string("Show last poster's avatar"), "description" => $db->escape_string("If set to yes, the last poster's avatar will be shown."), "optionscode" => "yesno", "disporder" => 3, "value" => 0, "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_forumskip", "title" => "Forums To Ignore", "description" => "The forums threads should not be pulled from.", "optionscode" => "forumselect", "disporder" => 4, "value" => "", "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_subject_length", "title" => "Max Title Length", "description" => "The amount of characters before the rest of the title is truncated. Enter 0 for no limit.", "optionscode" => "numeric", "disporder" => 5, "value" => 0, "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_subject_breaker", "title" => "Word Breaking", "description" => "If selected, the title will be kept to full words only in cut off.", "optionscode" => "yesno", "disporder" => 6, "value" => 0, "gid" => $gid);
    $new_setting[] = array("name" => "recentthread_which_groups", "title" => "Permissions", "description" => "These groups cannot view the reccent threads on index.", "optionscode" => "groupselect", "disporder" => 7, "value" => 7, "gid" => $gid);
    $db->insert_query_multiple("settings", $new_setting);
    rebuild_settings();
}
function minecraftconnect_install()
{
    global $db, $mybb, $lang;
    if (!$lang->mcc) {
        $lang->load('minecraftconnect');
    }
    // Check if cURL is enabled before we do anything...
    if (!function_exists('curl_version')) {
        flash_message($lang->mcc_curl_disabled, 'error');
        admin_redirect('index.php?module=config-plugins');
        exit;
    } else {
        // Now check if cURL can connect using SSL
        $v = curl_version();
        if (($v['features'] & CURL_VERSION_SSL) != 4) {
            flash_message($lang->mcc_curl_ssl, 'error');
            admin_redirect('index.php?module=config-plugins');
            exit;
        }
        // Now check if cURL Certificate Authority is valid
        $cainfo = ini_get('curl.cainfo');
        if (empty($cainfo) or strlen($cainfo) < 4) {
            flash_message($lang->mcc_curl_ca, 'error');
            admin_redirect('index.php?module=config-plugins');
            exit;
        }
    }
    $mcc_group = array('name' => 'mcc', 'title' => 'Minecraft Connect', 'description' => 'Edit the settings for Minecraft Connect here.', 'disporder' => '1', 'isdefault' => 'no');
    $db->insert_query('settinggroups', $mcc_group);
    $gid = intval($db->insert_id());
    $psettings[] = array('name' => 'mcc_enabled', 'title' => 'Enabled', 'description' => 'Do you want to enable Minecraft Connect?', 'optionscode' => 'yesno', 'value' => '1', 'disporder' => '1', 'gid' => $gid);
    foreach ($psettings as $setting) {
        $db->insert_query('settings', $setting);
    }
    // Add new columns to user table
    $db->add_column('users', 'mcc_username', 'varchar(65)');
    $db->add_column('users', 'mcc_accesstoken', 'varchar(32)');
    $db->add_column('users', 'mcc_id', 'varchar(32)');
    // ID == Client token
    rebuild_settings();
}
Beispiel #13
0
/**
 * @param string $codename
 * @param array  $register
 * @param int    $core_minimum
 * @param int    $mybb_minimum
 * @param string $php_minimum
 */
function jb_install_plugin($codename, $register = array(), $core_minimum = false, $mybb_minimum = false, $php_minimum = "5.3")
{
    $installed = false;
    if (JB_CORE_INSTALLED === false) {
        $installed = jb_install_core();
    }
    // In case we installed the core and this plugin needs to register itself we need to do this here. Otherwise the installer can't find its files
    if ($installed === true && isset($register['vendor']) && isset($register['prefix'])) {
        JB_Core::i();
        // Needed to register the autoloader
        JB_Packages::i()->register($register['prefix'], $register['vendor'], $codename);
    }
    // Don't use an else as the function above might change the value
    if (JB_CORE_INSTALLED === true || $installed === true) {
        JB_Core::i()->install($codename, $core_minimum, $mybb_minimum, $php_minimum);
    } else {
        // This message should normally never appear as "jb_install_core" should already throw an error
        flash_message("Couldn't install", 'error');
        admin_redirect('index.php?module=config-plugins');
    }
}
/**
 * Install function for the plugin.
 *
 * Creates <code>captcha_captchapack</code> table in the database. Add
 * cleanup task.
 */
function captchapack_install()
{
    global $db, $PL, $cache;
    // PluginLibrary dependency check
    if (!file_exists(PLUGINLIBRARY)) {
        flash_message("The selected plugin could not be installed because <a href=\"http://mods.mybb.com/view/pluginlibrary\">PluginLibrary</a> is missing.", "error");
        admin_redirect("index.php?module=config-plugins");
    }
    // Load PluginLibrary
    $PL or (require_once PLUGINLIBRARY);
    // PluginLibrary version check
    if ($PL->version < 11) {
        flash_message("PluginLibrary is too old.", "error");
        admin_redirect("index.php?module=config-plugins");
    }
    // Create table
    $tbl_name = TABLE_PREFIX . 'captcha_captchapack';
    $db->write_query("create table `{$tbl_name}` (\n    `hash`      binary(20)    not null,\n    `ip`        int unsigned  not null  default '0',\n    `dateline`  bigint(30)    not null  default '0',\n    `answer`    char(255)     not null  default '',\n    primary key (`hash`, `ip`)\n  );");
    // Add index to dateline to accelerate CAPTCHA cleanup
    $db->write_query("alter table `{$tbl_name}` add index (`dateline`);");
    // Insert task
    captchapack_task_add(array("title" => 'CAPTCHA Pack Cleanup', "description" => 'Clean up old CAPTCHA entries.', "file" => 'captchapack', "minute" => '0'));
}
function cloudflare_meta()
{
    global $mybb, $page, $plugins, $cache, $db;
    if ($mybb->input['module'] == 'cloudflare') {
        $query = $db->simple_select("settinggroups", "gid", "name='cloudflare'", array("order_by" => 'name', "order_dir" => 'DESC', "limit" => 1));
        $gid = $db->fetch_array($query);
        if (!$gid['gid']) {
            flash_message('Your settings are not set correctly. Please double check they are correct.', 'error');
            admin_redirect("index.php?module=config-settings&action=change&gid=" . intval($gid['gid']));
            exit;
        } elseif (cloudflare_is_installed() == false) {
            flash_message('CloudFlare Manager hasn\'t been installed. Please install it before continuing.', 'error');
            admin_redirect("index.php?module=config-plugins");
            exit;
        }
    }
    $sub_menu = array();
    $sub_menu['10'] = array("id" => "overview", "title" => "CloudFlare Overview", "link" => "index.php?module=cloudflare-overview");
    $sub_menu['20'] = array("id" => "dev_mode", "title" => "Development Mode", "link" => "index.php?module=cloudflare-dev_mode");
    $sub_menu = $plugins->run_hooks("admin_cloudflare_menu", $sub_menu);
    $page->add_menu_item("CloudFlare Manager", "cloudflare", "index.php?module=cloudflare", 60, $sub_menu);
    return true;
}
Beispiel #16
0
function chatcat_add_chat_options()
{
    //    global $mybb, $lang, $form, $forum_data;
    //    if($mybb->request_method == "post") {
    //        if(strlen($mybb->input['upsetting']['chatcat_enable_api']) == 0  || (strlen($mybb->input['upsetting']['chatcat_enable_api']) == 40 )){
    //
    //        }
    //        else{
    //			flash_message('API Key Invalid', 'error');
    //			admin_redirect("index.php?module=config-settings");
    //		}
    //	}
    $mybb_login_url = $mybb->input['upsetting']['chatcat_enable_login'];
    $mybb_register_url = $mybb->input['upsetting']['chatcat_enable_register'];
    if (!filter_var($mybb_login_url, FILTER_VALIDATE_URL) && strlen($mybb_login_url) > 0) {
        flash_message('Missing http:// prefix in Login URL', 'error');
        admin_redirect("index.php?module=config-settings&action=" . $mybb_action . "&gid=" . $mybb_gid);
    }
    if (!filter_var($mybb_register_url, FILTER_VALIDATE_URL) && strlen($mybb_register_url) > 0) {
        flash_message('Missing http:// prefix in Registration URL', 'error');
        admin_redirect("index.php?module=config-settings&action=" . $mybb_action . "&gid=" . $mybb_gid);
    }
}
function cloudflare_meta()
{
    global $mybb, $page, $plugins, $cache, $cloudflare;
    require_once MYBB_ROOT . "inc/plugins/cloudflare.php";
    if ($mybb->input['module'] == 'cloudflare') {
        if (!cloudflare_is_installed()) {
            flash_message('CloudFlare Manager hasn\'t been installed. Please install it before continuing.', 'error');
            admin_redirect("index.php?module=config-plugins");
            exit;
        }
    }
    if (!$cache->read("cloudflare_zone_id")) {
        $cloudflare->get_cloudflare_zone_id();
    }
    $sub_menu = array();
    $sub_menu['10'] = array("id" => "overview", "title" => "CloudFlare Overview", "link" => "index.php?module=cloudflare-overview");
    $sub_menu['20'] = array("id" => "dev_mode", "title" => "Development Mode", "link" => "index.php?module=cloudflare-dev_mode");
    $sub_menu = $plugins->run_hooks("admin_cloudflare_menu", $sub_menu);
    if (cloudflare_is_installed() && (!isset($mybb->settings['cloudflare_domain']) || !empty($mybb->settings['cloudflare_api']))) {
        $page->add_menu_item("CloudFlare Manager", "cloudflare", "index.php?module=cloudflare", 60, $sub_menu);
        return true;
    }
    return false;
}
Beispiel #18
0
         $new_tool['name'] = $db->escape_string($mybb->input['title']);
         $new_tool['description'] = $db->escape_string($mybb->input['description']);
         $new_tool['forums'] = '';
         if (is_array($mybb->input['forum_1_forums'])) {
             foreach ($mybb->input['forum_1_forums'] as $fid) {
                 $checked[] = intval($fid);
             }
             $new_tool['forums'] = implode(',', $checked);
         }
         $tid = $db->insert_query("modtools", $new_tool);
         $plugins->run_hooks("admin_config_mod_tools_add_post_tool_commit");
         // Log admin action
         log_admin_action($tid, $mybb->input['title']);
         $cache->update_forumsdisplay();
         flash_message($lang->success_mod_tool_created, 'success');
         admin_redirect("index.php?module=config-mod_tools&action=post_tools");
     }
 }
 $page->add_breadcrumb_item($lang->add_new_post_tool);
 $page->output_header($lang->mod_tools . " - " . $lang->add_new_post_tool);
 $sub_tabs['thread_tools'] = array('title' => $lang->thread_tools, 'link' => "index.php?module=config-mod_tools");
 $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", 'description' => $lang->add_post_tool_desc);
 $page->output_nav_tabs($sub_tabs, 'add_post_tool');
 $form = new Form("index.php?module=config-mod_tools&amp;action=add_post_tool", 'post');
 if ($errors) {
     $page->output_inline_error($errors);
 } else {
     $mybb->input['title'] = '';
     $mybb->input['description'] = '';
$page->output_header("CloudFlare Manager - Purge Cache");
function main_page()
{
    $form = new Form('index.php?module=cloudflare-purge_cache&amp;action=purge', 'post');
    $form_container = new FormContainer('Purge Cache');
    $form_container->output_row('Purge Entire Cache', 'Remove ALL files from CloudFlare\'s cache. This will include javascript, stylesheets and images. CloudFlare can take up to 3 hours to recache resources again<br /><b>Note: </b>This may have dramatic affects on your origin server load after performing this action.', $form->generate_yes_no_radio('purge_input', 0));
    $form_container->output_row('Purge by URL', 'Granularly remove one or more files from CloudFlare\'s cache either by specifying the URL<br /><b>Note: </b><u>One</u> URL per line (max: 30)', $form->generate_text_area('urls'));
    $form_container->end();
    $buttons[] = $form->generate_submit_button('Submit');
    $form->output_submit_wrapper($buttons);
    $form->end();
}
if ($mybb->input['action'] == "purge") {
    if (!verify_post_check($mybb->input['my_post_key'])) {
        flash_message($lang->invalid_post_verify_key2, 'error');
        admin_redirect("index.php?module=cloudflare-purge_cache");
    }
    if ($mybb->input['purge_input'] == "1") {
        $request = $cloudflare->purge_cache();
        if ($request->success) {
            $page->output_success('The entire cache has been purged');
        } else {
            $page->output_error($request->errors[0]->message);
        }
    } elseif (!empty($mybb->input['urls'])) {
        $urls = explode("\n", $mybb->input['urls']);
        if (sizeof($urls) > 30) {
            $urls = array_splice($urls, 0, 30);
        }
        $request = $cloudflare->purge_cache($urls);
        if ($request->success) {
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;
}
     $where = 'dateline < ' . (TIME_NOW - intval($mybb->input['older_than']) * 86400);
     // Searching for entries by a particular user
     if ($mybb->input['uid']) {
         $where .= " AND uid='" . intval($mybb->input['uid']) . "'";
     }
     // Searching for entries in a specific module
     if ($mybb->input['filter_module']) {
         $where .= " AND module='" . $db->escape_string($mybb->input['filter_module']) . "'";
     }
     $query = $db->delete_query("adminlog", $where);
     $num_deleted = $db->affected_rows();
     $plugins->run_hooks("admin_tools_adminlog_prune_commit");
     // Log admin action
     log_admin_action($mybb->input['older_than'], $mybb->input['uid'], $mybb->input['filter_module'], $num_deleted);
     flash_message($lang->success_pruned_admin_logs, 'success');
     admin_redirect("index.php?module=tools-adminlog");
 }
 $page->add_breadcrumb_item($lang->prune_admin_logs, "index.php?module=tools-adminlog&amp;action=prune");
 $page->output_header($lang->prune_admin_logs);
 $page->output_nav_tabs($sub_tabs, 'prune_admin_logs');
 // 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;
Beispiel #22
0
    while ($view = $db->fetch_array($query)) {
        $popup->add_item(htmlspecialchars_uni($view['title']), "index.php?module=user-users&amp;vid={$view['vid']}");
    }
    $popup->add_item("<em>{$lang->manage_views}</em>", "index.php?module=user-users&amp;action=views");
    $admin_view['popup'] = $popup->fetch();
    if (isset($mybb->input['type'])) {
        $admin_view['view_type'] = $mybb->input['type'];
    }
    $results = build_users_view($admin_view);
    if (!$results) {
        // If we came from the home page and clicked on the "Activate Users" link, send them back to here
        if ($admin_session['data']['from'] == "home") {
            flash_message($admin_session['data']['flash_message2']['message'], $admin_session['data']['flash_message2']['type']);
            update_admin_session('flash_message2', '');
            update_admin_session('from', '');
            admin_redirect("index.php");
            exit;
        } else {
            $errors[] = $lang->error_no_users_found;
        }
    }
    // If we have any error messages, show them
    if ($errors) {
        if ($inline != true) {
            echo "<div style=\"display: inline; float: right;\">{$admin_view['popup']}</div><br />\n";
        }
        $page->output_inline_error($errors);
    }
    echo $results;
    $page->output_footer();
}
Beispiel #23
0
    if (!$mycode['cid']) {
        flash_message($lang->error_invalid_mycode, 'error');
        admin_redirect("index.php?module=config/mycode");
    }
    // User clicked no
    if ($mybb->input['no']) {
        admin_redirect("index.php?module=config/mycode");
    }
    if ($mybb->request_method == "post") {
        $db->delete_query("mycode", "cid='{$mycode['cid']}'");
        $cache->update_mycode();
        $plugins->run_hooks("admin_config_mycode_delete_commit");
        // Log admin action
        log_admin_action($mycode['cid'], $mycode['title']);
        flash_message($lang->success_deleted_mycode, 'success');
        admin_redirect("index.php?module=config/mycode");
    } else {
        $page->output_confirm_action("index.php?module=config/mycode&amp;action=delete&amp;cid={$mycode['cid']}", $lang->confirm_mycode_deletion);
    }
}
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_config_mycode_start");
    $page->output_header($lang->custom_mycode);
    $sub_tabs['mycode'] = array('title' => $lang->mycode, 'link' => "index.php?module=config/mycode", 'description' => $lang->mycode_desc);
    $sub_tabs['add_new_mycode'] = array('title' => $lang->add_new_mycode, 'link' => "index.php?module=config/mycode&amp;action=add");
    $page->output_nav_tabs($sub_tabs, 'mycode');
    $table = new Table();
    $table->construct_header($lang->title);
    $table->construct_header($lang->controls, array('class' => 'align_center', 'width' => 150));
    $query = $db->simple_select("mycode", "*", "", array('order_by' => 'parseorder'));
    while ($mycode = $db->fetch_array($query)) {
Beispiel #24
0
             $smilie = array("name" => $db->escape_string($mybb->input['name'][$sid]), "find" => $db->escape_string($mybb->input['find'][$sid]), "showclickable" => $db->escape_string($mybb->input['showclickable'][$sid]));
             // $test contains all disporders except the actual one so we can check whether we have multiple disporders
             $test = $mybb->input['disporder'];
             unset($test[$sid]);
             if (!in_array($disporder, $test)) {
                 $smilie['disporder'] = $disporder;
             }
             $db->update_query("smilies", $smilie, "sid = '{$sid}'");
         }
     }
     $cache->update_smilies();
     $plugins->run_hooks("admin_config_smilies_mass_edit_commit");
     // Log admin action
     log_admin_action();
     flash_message($lang->success_multiple_smilies_updated, 'success');
     admin_redirect("index.php?module=config-smilies");
 }
 $page->add_breadcrumb_item($lang->mass_edit);
 $page->output_header($lang->smilies . " - " . $lang->mass_edit);
 $sub_tabs['manage_smilies'] = array('title' => $lang->manage_smilies, 'link' => "index.php?module=config-smilies");
 $sub_tabs['add_smilie'] = array('title' => $lang->add_smilie, 'link' => "index.php?module=config-smilies&amp;action=add");
 $sub_tabs['add_multiple_smilies'] = array('title' => $lang->add_multiple_smilies, 'link' => "index.php?module=config-smilies&amp;action=add_multiple");
 $sub_tabs['mass_edit'] = array('title' => $lang->mass_edit, 'link' => "index.php?module=config-smilies&amp;action=mass_edit", 'description' => $lang->mass_edit_desc);
 $page->output_nav_tabs($sub_tabs, 'mass_edit');
 $form = new Form("index.php?module=config-smilies&amp;action=mass_edit", "post", "mass_edit");
 if ($errors) {
     $page->output_inline_error($errors);
 } else {
     $mybb->input['path'] = 'images/smilies/';
     $mybb->input['showclickable'] = 1;
 }
Beispiel #25
0
             $qstring = str_replace('action=logout', '', $qstring);
             $qstring = preg_replace('#&+#', '&', $qstring);
             $qstring = str_replace('?&', '?', $qstring);
             // So what do we do? We know that parameters are devided by ampersands
             // That means we must get to work!
             $parameters = explode('&', $qstring);
             // Remove our first member if it's for the module
             if (substr($parameters[0], 0, 8) == '?module=') {
                 unset($parameters[0]);
             }
             foreach ($parameters as $key => $param) {
                 $params = explode("=", $param);
                 $query_string .= '&' . htmlspecialchars_uni($params[0]) . "=" . htmlspecialchars_uni($params[1]);
             }
         }
         admin_redirect("index.php" . $query_string);
     }
 } else {
     $login_user = get_user_by_username($mybb->input['username'], array('fields' => array('email', 'username')));
     if ($login_user['uid'] > 0) {
         $db->update_query("adminoptions", array("loginattempts" => "loginattempts+1"), "uid='" . (int) $login_user['uid'] . "'", '', true);
     }
     $loginattempts = login_attempt_check_acp($login_user['uid'], true);
     // Have we attempted too many times?
     if ($loginattempts['loginattempts'] > 0) {
         // Have we set an expiry yet?
         if ($loginattempts['loginlockoutexpiry'] == 0) {
             $db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW + (int) $mybb->settings['loginattemptstimeout'] * 60), "uid='" . (int) $login_user['uid'] . "'");
         }
         // Did we hit lockout for the first time? Send the unlock email to the administrator
         if ($loginattempts['loginattempts'] == $mybb->settings['maxloginattempts']) {
Beispiel #26
0
     foreach ($tree['mybbgroup']['team'] as $team) {
         $members = array();
         foreach ($team['member'] as $member) {
             $members[] = array('name' => htmlspecialchars_uni($member['name']['value']), 'username' => htmlspecialchars_uni($member['username']['value']), 'profile' => htmlspecialchars_uni($member['profile']['value']), 'lead' => (bool) $member['attributes']['lead'] or false);
         }
         $mybbgroup[] = array('title' => htmlspecialchars_uni($team['attributes']['title']), 'members' => $members);
     }
     $new_mybb_credits['credits'] = $mybbgroup;
     $cache->update('mybb_credits', $new_mybb_credits);
     if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2) {
         $lang->load('tools_cache');
         flash_message($lang->success_cache_reloaded, 'success');
         admin_redirect('index.php?module=tools-cache');
     } else {
         flash_message($lang->success_credits_updated, 'success');
         admin_redirect('index.php?module=home-credits&amp;fetch_new=-1');
     }
 }
 if (empty($mybb_credits) || is_array($mybb_credits) && empty($mybb_credits['credits'])) {
     $table = new Table();
     $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;
         }
Beispiel #27
0
             $group = array_keys($banned_groups);
             $mybb->input['usergroup'] = $group[0];
         }
         $insert_array = array('uid' => $user['uid'], 'gid' => intval($mybb->input['usergroup']), 'oldgroup' => $user['usergroup'], 'oldadditionalgroups' => $user['additionalgroups'], 'olddisplaygroup' => $user['displaygroup'], 'admin' => intval($mybb->user['uid']), 'dateline' => TIME_NOW, 'bantime' => $db->escape_string($mybb->input['bantime']), 'lifted' => $db->escape_string($lifted), 'reason' => $db->escape_string($mybb->input['reason']));
         $db->insert_query('banned', $insert_array);
         // Move the user to the banned group
         $update_array = array('usergroup' => intval($mybb->input['usergroup']), 'displaygroup' => 0, 'additionalgroups' => '');
         $db->update_query('users', $update_array, "uid = '{$user['uid']}'");
         $db->delete_query("forumsubscriptions", "uid = '{$user['uid']}'");
         $db->delete_query("threadsubscriptions", "uid = '{$user['uid']}'");
         $cache->update_banned();
         $plugins->run_hooks("admin_user_banning_start_commit");
         // Log admin action
         log_admin_action($user['uid'], $user['username'], $lifted);
         flash_message($lang->success_banned, 'success');
         admin_redirect("index.php?module=user-banning");
     }
 }
 $page->output_header($lang->banned_accounts);
 $page->output_nav_tabs($sub_tabs, "bans");
 $query = $db->simple_select("banned", "COUNT(*) AS ban_count");
 $ban_count = $db->fetch_field($query, "ban_count");
 $per_page = 20;
 if ($mybb->input['page'] > 0) {
     $current_page = intval($mybb->input['page']);
     $start = ($current_page - 1) * $per_page;
     $pages = $ban_count / $per_page;
     $pages = ceil($pages);
     if ($current_page > $pages) {
         $start = 0;
         $current_page = 1;
Beispiel #28
0
function xthreads_uninstall()
{
    global $db, $cache, $mybb, $plugins;
    if ($mybb->input['no']) {
        admin_redirect(xthreads_admin_url('config', 'plugins'));
        exit;
    }
    if (!$mybb->input['confirm_uninstall']) {
        $link = 'index.php?confirm_uninstall=1&amp;' . htmlspecialchars($_SERVER['QUERY_STRING']);
        $GLOBALS['page']->output_confirm_action($link, $GLOBALS['lang']->xthreads_confirm_uninstall);
        exit;
    } else {
        unset($mybb->input['confirm_uninstall']);
    }
    $plugins->run_hooks('xthreads_uninstall_start');
    $query = $db->simple_select('adminoptions', 'uid,permissions');
    while ($adminopt = $db->fetch_array($query)) {
        $perms = @unserialize($adminopt['permissions']);
        if (empty($perms)) {
            continue;
        }
        // inherited or just messed up
        unset($perms['config']['threadfields']);
        $db->update_query('adminoptions', array('permissions' => $db->escape_string(serialize($perms))), 'uid=' . $adminopt['uid']);
    }
    $db->free_result($query);
    if ($db->table_exists('threadfields_data')) {
        $db->write_query('DROP TABLE ' . $db->table_prefix . 'threadfields_data');
    }
    if ($db->table_exists('threadfields')) {
        $db->write_query('DROP TABLE ' . $db->table_prefix . 'threadfields');
    }
    if ($db->table_exists('xtattachments')) {
        // remove attachments first
        require_once MYBB_ROOT . 'inc/xthreads/xt_updatehooks.php';
        $query = $db->simple_select('xtattachments', 'aid,indir,attachname');
        while ($xta = $db->fetch_array($query)) {
            xthreads_rm_attach_fs($xta);
        }
        $db->free_result($query);
        $db->write_query('DROP TABLE ' . $db->table_prefix . 'xtattachments');
    }
    // remove any indexes added on the threads table
    foreach (array('uid', 'lastposteruid', 'prefix', 'icon') as $afe) {
        if ($afe == 'uid') {
            continue;
        }
        // we won't remove this from the above array
        $db->write_query('ALTER TABLE `' . $db->table_prefix . 'threads` DROP KEY `xthreads_' . $afe . '`', true);
    }
    $fields = array('xthreads_grouping', 'xthreads_firstpostattop', 'xthreads_inlinesearch', 'xthreads_tplprefix', 'xthreads_langprefix', 'xthreads_allow_blankmsg', 'xthreads_nostatcount', 'xthreads_fdcolspan_offset', 'xthreads_settingoverrides', 'xthreads_postsperpage', 'xthreads_hideforum', 'xthreads_hidebreadcrumb', 'xthreads_defaultfilter', 'xthreads_addfiltenable', 'xthreads_wol_announcements', 'xthreads_wol_forumdisplay', 'xthreads_wol_newthread', 'xthreads_wol_attachment', 'xthreads_wol_newreply', 'xthreads_wol_showthread');
    foreach ($fields as $k => &$f) {
        if (!$db->field_exists($f, 'forums')) {
            unset($fields[$k]);
        }
    }
    if (!empty($fields)) {
        switch ($db->type) {
            case 'sqlite3':
            case 'sqlite2':
            case 'sqlite':
                $db->alter_table_parse($db->table_prefix . 'forums', 'DROP ' . implode(', DROP COLUMN ', $fields) . '');
                break;
            case 'pgsql':
                foreach ($fields as &$f) {
                    $db->write_query('ALTER TABLE ' . $db->table_prefix . 'forums
						DROP COLUMN ' . $f);
                }
                break;
            default:
                $db->write_query('ALTER TABLE ' . $db->table_prefix . 'forums
					DROP COLUMN ' . implode(', DROP COLUMN ', $fields));
        }
    }
    // remove any custom default sorts and reduce size of sorting column back to original
    $db->update_query('forums', array('defaultsortby' => ''), 'defaultsortby LIKE "tf_%" OR defaultsortby LIKE "tfa_%"');
    $db->write_query('ALTER TABLE `' . $db->table_prefix . 'forums` MODIFY `defaultsortby` varchar(10) NOT NULL default \'\'');
    $cache->update_forums();
    xthreads_delete_datacache('threadfields');
    @unlink(MYBB_ROOT . 'cache/xthreads.php');
    @unlink(MYBB_ROOT . 'cache/xthreads_evalcache.php');
    $db->delete_query('templates', 'title IN ("' . implode('","', array_keys(xthreads_new_templates())) . '") AND sid=-2');
    // revert QuickThread modification
    if (function_exists('quickthread_uninstall')) {
        $tpl = $db->fetch_array($db->simple_select('templates', 'tid,template', 'title="forumdisplay_quick_thread" AND sid=-1', array('limit' => 1)));
        if ($tpl && strpos($tpl['template'], '{$GLOBALS[\'extra_threadfields\']}') !== false) {
            $newtpl = preg_replace('~\\{\\$GLOBALS\\[\'extra_threadfields\'\\]\\}' . "\r?(\n\t{0,3})?" . '~is', '', $tpl['template'], 1);
            if ($newtpl != $tpl['template']) {
                $db->update_query('templates', array('template' => $db->escape_string($newtpl)), 'tid=' . $tpl['tid']);
            }
        }
    }
    // try to determine and remove stuff added to the custom moderation table
    $query = $db->simple_select('modtools', 'tid,threadoptions');
    while ($tool = $db->fetch_array($query)) {
        $opts = unserialize($tool['threadoptions']);
        if (isset($opts['edit_threadfields'])) {
            unset($opts['edit_threadfields']);
            $db->update_query('modtools', array('threadoptions' => $db->escape_string(serialize($opts))), 'tid=' . $tool['tid']);
        }
    }
    $plugins->run_hooks('xthreads_uninstall_end');
}
Beispiel #29
0
        $plugins->run_hooks("admin_tools_cache_rebuild_commit");
        // Log admin action
        log_admin_action($mybb->input['title']);
        flash_message($lang->success_cache_rebuilt, 'success');
        admin_redirect("index.php?module=tools-cache");
    } elseif (method_exists($cache, "reload_{$mybb->input['title']}")) {
        $func = "reload_{$mybb->input['title']}";
        $cache->{$func}();
        $plugins->run_hooks("admin_tools_cache_rebuild_commit");
        // Log admin action
        log_admin_action($mybb->input['title']);
        flash_message($lang->success_cache_reloaded, 'success');
        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"));
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();
} elseif ($mybb->input['action'] == "change") {
    if (!verify_post_check($mybb->input['my_post_key'])) {
        flash_message($lang->invalid_post_verify_key2, 'error');
        admin_redirect("index.php?module=cloudflare-cache_lvl");
    }
    $page->output_header("CloudFlare Manager - Cache Level");
    if ($mybb->input['type'] == "Basic") {
        $type = "basic";
    } elseif ($mybb->input['type'] == "Aggressive") {
        $type = "agg";
    } elseif ($mybb->input['type'] == "Simplified") {
        $type = "iqs";
    } else {
        $type = "basic";
    }
    $request = cloudflare_request("cache_lvl", $mybb->settings['cloudflare_domain'], $mybb->settings['cloudflare_email'], $mybb->settings['cloudflare_api'], $type);
    if ($request == "success") {
        $page->output_success("<p><em>CloudFlare cache level has sucessfully been changed to  " . $mybb->input['type'] . ".</em></p>");
        log_admin_action('Changed the cache level to  ' . $mybb->input['type'] . ' on ' . $mybb->settings['cloudflare_domain']);