Exemple #1
0
/**
 * Makes a settings page for the plugin
 * 
 * @uses bb_option_form_element() to generate the page
 */
function em_options()
{
    global $em_plugopts;
    if ($_POST['em_opts_submit'] == 1) {
        /* Settings have been received, now save them! */
        bb_check_admin_referer('em-save-chk');
        /* Security Check */
        /* Checks on options, and then save them */
        $em_plugopts['link-tags'] = intval($_POST['link-tags']) == 1 ? 1 : 0;
        $em_plugopts['link-users'] = intval($_POST['link-users']) == 1 ? 1 : 0;
        $em_plugopts['link-user-to'] = $_POST['link-user-to'] == 'website' ? 'website' : 'profile';
        $em_plugopts['reply-link'] = intval($_POST['reply-link']) == 1 ? 1 : 0;
        $em_plugopts['reply-text'] = esc_attr($_POST['reply-text']);
        bb_update_option(EM_OPTIONS, $em_plugopts);
        bb_admin_notice(__('The options were successfully saved!', 'easy-mentions'));
    }
    if ($ver = em_update_check()) {
        /* Check for Updates and if available, then notify */
        bb_admin_notice(sprintf(__('New version (%1$s) of Easy Mentions is available! Please download the latest version from <a href="%2$s">here</a>.', 'easy-mentions'), $ver, 'http://bbpress.org/plugins/topic/easy-mentions/'));
    }
    /* Options in an array to be printed */
    $options = array('link-tags' => array('title' => __('Link the Tags?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['link-tags'] == 1 ? '1' : '0', 'note' => sprintf(__('Check this option if you want the tags to be linked (by using %s) in the posts.', 'easy-mentions'), '<code>#tag</code>'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'link-users' => array('title' => __('Link the Users?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['link-users'] == 1 ? '1' : '0', 'note' => sprintf(__('Check this option if you want the users to be linked (by using %s) in the posts.', 'easy-mentions'), '<code>@user</code>'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'link-user-to' => array('title' => __('Link the user to profile or website?', 'easy-mentions'), 'type' => 'radio', 'value' => $em_plugopts['link-user-to'] == 'website' ? 'website' : 'profile', 'note' => __('If you selected the website option and the user\'s website does not exist, then the user will be linked to his or her profile page.', 'easy-mentions'), 'options' => array('profile' => __('Profile', 'easy-mentions'), 'website' => __('Website', 'easy-mentions'))), 'reply-link' => array('title' => __('Add a reply link below each post?', 'easy-mentions'), 'type' => 'checkbox', 'value' => $em_plugopts['reply-link'] == 1 ? '1' : '0', 'note' => sprintf(__('Before checking this option, please verify that there is a post form below the topic on each page. (<a href="%s">Help</a>)', 'easy-mentions'), 'http://bbpress.org/plugins/topic/easy-mentions/faq/'), 'options' => array('1' => __('Yes', 'easy-mentions'))), 'reply-text' => array('title' => __('Reply Text', 'easy-mentions'), 'class' => array('long'), 'value' => $em_plugopts['reply-text'] ? stripslashes($em_plugopts['reply-text']) : '<em>Replying to @%%USERNAME%%\'s <a href="%%POSTLINK%%">post</a>:</em>', 'after' => '<div style="clear:both;"></div>' . sprintf(__('Some HTML is allowed. The following keys can also be used:%1$s - Post\'s author\'s name%2$s - Post\'s link', 'after-the-deadline'), '<br /><strong>%%USERNAME%%</strong>', '<br /><strong>%%POSTLINK%%</strong>') . '<br />'));
    if ($em_plugopts['link-users'] != 1) {
        $options['link-user-to']['attributes'] = array('disabled' => 'disabled');
    }
    if ($em_plugopts['reply-link'] != 1) {
        $options['reply-text']['attributes'] = array('disabled' => 'disabled');
    }
    ?>
	
	<h2><?php 
    _e('Easy Mentions', 'easy-mentions');
    ?>
</h2>
	<?php 
    do_action('bb_admin_notices');
    ?>
	<form method="post" class="settings options">
		<fieldset>
			<?php 
    foreach ($options as $option => $args) {
        bb_option_form_element($option, $args);
    }
    ?>
		</fieldset>
		<fieldset class="submit">
			<?php 
    bb_nonce_field('em-save-chk');
    ?>
			<input type="hidden" name="em_opts_submit" value="1"></input>
			<input class="submit" type="submit" name="submit" value="Save Changes" />
		</fieldset>
		<p><?php 
    printf(__('Happy with the plugin? Why not <a href="%1$s">buy the author a cup of coffee or two</a> or get him something from his <a href="%2$s">wishlist</a>?', 'easy-mentions'), 'http://gaut.am/donate/EM/', 'http://gaut.am/wishlist/');
    ?>
</p>
	</form>
<?php 
}
function topic_icons_admin_page_process()
{
    if (isset($_POST['topic-icons-submit'])) {
        bb_update_option('topic-icons-active-icon-set', $_POST['icon-set']);
        bb_update_option('topic-icons-active-status-interpreter', $_POST['status-interpreter']);
        bb_update_option('topic-icons-active-status-renderer', $_POST['status-renderer']);
    }
}
function recaptcha_bbpress_admin_page_process()
{
    if (isset($_POST['submit'])) {
        if ('rcpbbp_update' == $_POST['action']) {
            bb_update_option('recaptcha_bbpress_public_key', $_POST['rcpbbp_public']);
            bb_update_option('recaptcha_bbpress_private_key', $_POST['rcpbbp_private']);
        }
    }
}
function bb_language_switcher_update()
{
    // reads the .mo files and looks for the formal language name automagically
    if (!bb_current_user_can('administrate')) {
        return;
    }
    $bb_language_switcher_iso639 = array('aa' => 'Afar', 'ab' => 'Abkhazian', 'ae' => 'Avestan', 'af' => 'Afrikaans', 'ak' => 'Akan', 'am' => 'Amharic', 'an' => 'Aragonese', 'ar' => 'Arabic', 'as' => 'Assamese', 'av' => 'Avaric', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'be' => 'Belarusian', 'bg' => 'Bulgarian', 'bh' => 'Bihari', 'bi' => 'Bislama', 'bm' => 'Bambara', 'bn' => 'Bengali', 'bo' => 'Tibetan', 'br' => 'Breton', 'bs' => 'Bosnian', 'ca' => 'Catalan', 'ca' => 'Valencian', 'ce' => 'Chechen', 'ch' => 'Chamorro', 'co' => 'Corsican', 'cr' => 'Cree', 'cs' => 'Czech', 'cu' => 'Church Slavic', 'cv' => 'Chuvash', 'cy' => 'Welsh', 'da' => 'Danish', 'de' => 'German', 'dv' => 'Dhivehi', 'dv' => 'Divehi', 'dv' => 'Maldivian', 'dz' => 'Dzongkha', 'ee' => 'Ewe', 'el' => 'Greek', 'en' => 'English', 'eo' => 'Esperanto', 'es' => 'Castilian', 'es' => 'Spanish', 'et' => 'Estonian', 'eu' => 'Basque', 'fa' => 'Persian', 'ff' => 'Fulah', 'fi' => 'Finnish', 'fj' => 'Fijian', 'fo' => 'Faroese', 'fr' => 'French', 'fy' => 'Western Frisian', 'ga' => 'Irish', 'gd' => 'Gaelic', 'gd' => 'Scottish Gaelic', 'gl' => 'Galician', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'gv' => 'Manx', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hr' => 'Croatian', 'ht' => 'Haitian Creole', 'hu' => 'Hungarian', 'hy' => 'Armenian', 'hz' => 'Herero', 'id' => 'Indonesian', 'ie' => 'Interlingue', 'ie' => 'Occidental', 'ig' => 'Igbo', 'ii' => 'Nuosu', 'ii' => 'Sichuan Yi', 'ik' => 'Inupiaq', 'io' => 'Ido', 'is' => 'Icelandic', 'it' => 'Italian', 'iu' => 'Inuktitut', 'ja' => 'Japanese', 'jv' => 'Javanese', 'ka' => 'Georgian', 'kg' => 'Kongo', 'ki' => 'Gikuyu', 'ki' => 'Kikuyu', 'kj' => 'Kuanyama', 'kk' => 'Kazakh', 'kl' => 'Greenlandic', 'kl' => 'Kalaallisut', 'km' => 'Central Khmer', 'kn' => 'Kannada', 'ko' => 'Korean', 'kr' => 'Kanuri', 'ks' => 'Kashmiri', 'ku' => 'Kurdish', 'kv' => 'Komi', 'kw' => 'Cornish', 'ky' => 'Kirghiz', 'ky' => 'Kyrgyz', 'la' => 'Latin', 'lb' => 'Letzeburgesch', 'lb' => 'Luxembourgish', 'lg' => 'Ganda', 'li' => 'Limburgan', 'li' => 'Limburger', 'li' => 'Limburgish', 'ln' => 'Lingala', 'lo' => 'Lao', 'lt' => 'Lithuanian', 'lu' => 'Luba-Katanga', 'lv' => 'Latvian', 'mg' => 'Malagasy', 'mh' => 'Marshallese', 'mi' => 'Maori', 'mk' => 'Macedonian', 'ml' => 'Malayalam', 'mn' => 'Mongolian', 'mr' => 'Marathi', 'ms' => 'Malay', 'mt' => 'Maltese', 'my' => 'Burmese', 'na' => 'Nauru', 'nb' => 'Norwegian Bokmål', 'nd' => 'North Ndebele', 'ne' => 'Nepali', 'ng' => 'Ndonga', 'nl' => 'Dutch', 'nl' => 'Flemish', 'nn' => 'Norwegian Nynorsk', 'no' => 'Norwegian', 'nr' => 'South Ndebele', 'nv' => 'Navajo', 'ny' => 'Chewa', 'ny' => 'Chichewa', 'ny' => 'Nyanja', 'oc' => 'Occitan', 'oj' => 'Ojibwa', 'om' => 'Oromo', 'or' => 'Oriya', 'os' => 'Ossetian', 'os' => 'Ossetic', 'pa' => 'Panjabi', 'pi' => 'Pali', 'pl' => 'Polish', 'ps' => 'Pushto', 'pt' => 'Portuguese', 'qu' => 'Quechua', 'rm' => 'Romansh', 'rn' => 'Rundi', 'ro' => 'Moldavian', 'ro' => 'Moldovan', 'ro' => 'Romanian', 'ru' => 'Russian', 'rw' => 'Kinyarwanda', 'sa' => 'Sanskrit', 'sc' => 'Sardinian', 'sd' => 'Sindhi', 'se' => 'Northern Sami', 'sg' => 'Sango', 'si' => 'Sinhala', 'si' => 'Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'sm' => 'Samoan', 'sn' => 'Shona', 'so' => 'Somali', 'sq' => 'Albanian', 'sr' => 'Serbian', 'ss' => 'Swati', 'st' => 'Sotho, Southern', 'su' => 'Sundanese', 'sv' => 'Swedish', 'sw' => 'Swahili', 'ta' => 'Tamil', 'te' => 'Telugu', 'tg' => 'Tajik', 'th' => 'Thai', 'ti' => 'Tigrinya', 'tk' => 'Turkmen', 'tl' => 'Tagalog', 'tn' => 'Tswana', 'to' => 'Tonga', 'tr' => 'Turkish', 'ts' => 'Tsonga', 'tt' => 'Tatar', 'tw' => 'Twi', 'ty' => 'Tahitian', 'ug' => 'Uighur', 'ug' => 'Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Chuang', 'za' => 'Zhuang', 'zh' => 'Chinese', 'zu' => 'Zulu');
    $languages = bb_glob(BB_LANG_DIR . '*.mo');
    // might have problem in safe mode
    if (empty($languages)) {
        return;
    }
    // no .mo files?
    foreach ($languages as $language) {
        if (BB_LANG_USE_FILE_META) {
            unset($match);
            $content = "";
            $handle = fopen($language, "rb");
            // should work even under windows
            while (!feof($handle)) {
                $content .= fread($handle, 8192);
                if (preg_match("/X\\-Poedit\\-Language\\:(.+?)\n/i", $content, $match)) {
                    continue;
                }
                // language name in English from poedit meta data
                if (strlen($content) > 81920) {
                    $content = substr($content, -8192);
                }
                // trim buffer size
            }
            unset($content);
            fclose($handle);
        }
        preg_match("/.*[\\/](.+?)\\.mo\$/i", $language, $lang);
        // filename becomes key
        $lang = trim($lang[1]);
        if (strlen($lang) == 5) {
            $cn = " (" . strtoupper(substr($lang, -2)) . ") ";
        } else {
            $cn = "";
        }
        if (!empty($match[1])) {
            $list[$lang] = ucwords(trim($match[1])) . $cn;
        } elseif (BB_LANG_USE_FILE_META != 'only' && BB_LANG_USE_FILE_META != 'force') {
            $list[$lang] = utf8_encode($bb_language_switcher_iso639[strtolower(substr($lang, 0, 2))]) . $cn;
            // fallback if name can't be found in meta
        }
    }
    if (!empty($list)) {
        $list[' '] = "English";
        // add default
        asort($list);
        // make alphabetical
        bb_update_option('bb_language_switcher', $list);
    }
}
Exemple #5
0
function thanks_admin_page_process()
{
    global $_POST;
    if (isset($_POST['thanks_option_submit'])) {
        bb_update_option('thanks_voting', $_POST['thanks_voting']);
        bb_update_option('thanks_output_none', $_POST['thanks_output_none']);
        bb_update_option('thanks_output_one', $_POST['thanks_output_one']);
        bb_update_option('thanks_output_many', $_POST['thanks_output_many']);
        bb_update_option('thanks_position', $_POST['thanks_position']);
        bb_update_option('thanks_voters', $_POST['thanks_voters']);
        bb_update_option('thanks_voters_prefix', $_POST['thanks_voters_prefix']);
        bb_update_option('thanks_voters_suffix', $_POST['thanks_voters_suffix']);
    }
    if (isset($_POST['thanks_option_reset'])) {
        bb_delete_option('thanks_voting');
        bb_delete_option('thanks_output_none');
        bb_delete_option('thanks_output_one');
        bb_delete_option('thanks_output_many');
        bb_delete_option('thanks_success');
        bb_delete_option('thanks_position');
        bb_delete_option('thanks_voters');
        bb_delete_option('thanks_voters_prefix');
        bb_delete_option('thanks_voters_suffix');
    }
    if (isset($_POST['thanks_remove_all'])) {
        $opt = bb_get_option("thanks_posts");
        for ($i = 0; $i < count($opt); $i++) {
            $post_id = $opt[$i];
            bb_delete_postmeta($post_id, "thanks");
        }
        bb_delete_option("thanks_posts");
        bb_delete_option('thanks_voting');
        bb_delete_option('thanks_output_none');
        bb_delete_option('thanks_output_one');
        bb_delete_option('thanks_output_many');
        bb_delete_option('thanks_success');
        bb_delete_option('thanks_position');
        bb_delete_option('thanks_voters');
        bb_delete_option('thanks_voters_prefix');
        bb_delete_option('thanks_voters_suffix');
    }
}
function blocklist_process_post()
{
    if (!bb_current_user_can('administrate')) {
        return;
    }
    global $blocklist;
    if (isset($_POST['submit']) && isset($_POST['blocklist'])) {
        $options = array('data', 'email');
        foreach ($options as $option) {
            if (!empty($_POST[$option])) {
                (array) ($data = explode("\n", trim($_POST[$option])));
                array_walk($data, create_function('&$arr', '$arr=trim($arr);'));
                $blocklist[$option] = implode("\r\n", $data) . "\r\n";
            } else {
                $blocklist[$option] = "";
            }
        }
        bb_update_option('blocklist', $blocklist);
    }
}
/**
 * Bootstrap bbPress 1.x, and manipulate globals to integrate with BuddyPress.
 *
 * @return bool|null Returns false on failure.
 */
function bp_forums_load_bbpress()
{
    global $wpdb, $wp_roles, $current_user, $wp_users_object;
    global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
    global $bb_roles, $wp_taxonomy_object, $bb_queries;
    // Return if we've already run this function.
    if (is_object($bbdb)) {
        return;
    }
    if (!bp_forums_is_installed_correctly()) {
        return false;
    }
    $bp = buddypress();
    define('BB_PATH', $bp->plugin_dir . '/bp-forums/bbpress/');
    define('BACKPRESS_PATH', $bp->plugin_dir . '/bp-forums/bbpress/bb-includes/backpress/');
    define('BB_URL', $bp->plugin_url . 'bp-forums/bbpress/');
    define('BB_INC', 'bb-includes/');
    require BB_PATH . BB_INC . 'class.bb-query.php';
    require BB_PATH . BB_INC . 'class.bb-walker.php';
    require BB_PATH . BB_INC . 'functions.bb-core.php';
    require BB_PATH . BB_INC . 'functions.bb-forums.php';
    require BB_PATH . BB_INC . 'functions.bb-topics.php';
    require BB_PATH . BB_INC . 'functions.bb-posts.php';
    require BB_PATH . BB_INC . 'functions.bb-topic-tags.php';
    require BB_PATH . BB_INC . 'functions.bb-capabilities.php';
    require BB_PATH . BB_INC . 'functions.bb-meta.php';
    require BB_PATH . BB_INC . 'functions.bb-pluggable.php';
    require BB_PATH . BB_INC . 'functions.bb-formatting.php';
    require BB_PATH . BB_INC . 'functions.bb-template.php';
    require BACKPRESS_PATH . 'class.wp-taxonomy.php';
    require BB_PATH . BB_INC . 'class.bb-taxonomy.php';
    require BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
    $bb = new stdClass();
    require bp_get_option('bb-config-location');
    // Setup the global database connection
    $bbdb = new BPDB(BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST);
    // Set the table names
    $bbdb->forums = $bb_table_prefix . 'forums';
    $bbdb->meta = $bb_table_prefix . 'meta';
    $bbdb->posts = $bb_table_prefix . 'posts';
    $bbdb->terms = $bb_table_prefix . 'terms';
    $bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
    $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
    $bbdb->topics = $bb_table_prefix . 'topics';
    if (isset($bb->custom_user_table)) {
        $bbdb->users = $bb->custom_user_table;
    } else {
        $bbdb->users = $wpdb->users;
    }
    if (isset($bb->custom_user_meta_table)) {
        $bbdb->usermeta = $bb->custom_user_meta_table;
    } else {
        $bbdb->usermeta = $wpdb->usermeta;
    }
    $bbdb->prefix = $bb_table_prefix;
    define('BB_INSTALLING', false);
    if (is_object($wp_roles)) {
        $bb_roles = $wp_roles;
        bb_init_roles($bb_roles);
    }
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_got_roles');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('bb_init');
    /**
     * Fires during the bootstrap setup for bbPress 1.x.
     *
     * @since 1.1.0
     */
    do_action('init_roles');
    $bb_current_user = $current_user;
    $wp_users_object = new BP_Forums_BB_Auth();
    if (!isset($wp_taxonomy_object)) {
        $wp_taxonomy_object = new BB_Taxonomy($bbdb);
    }
    $wp_taxonomy_object->register_taxonomy('bb_topic_tag', 'bb_topic');
    // Set a site id if there isn't one already
    if (!isset($bb->site_id)) {
        $bb->site_id = bp_get_root_blog_id();
    }
    // Check if the tables are installed, if not, install them
    if (!($tables_installed = (bool) $bbdb->get_results('DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A))) {
        require BB_PATH . 'bb-admin/includes/defaults.bb-schema.php';
        // Backticks and "IF NOT EXISTS" break the dbDelta function.
        bp_bb_dbDelta(str_replace(' IF NOT EXISTS', '', str_replace('`', '', $bb_queries)));
        require BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php';
        bb_update_db_version();
        // Set the site admins as the keymasters
        $site_admins = get_site_option('site_admins', array('admin'));
        foreach ((array) $site_admins as $site_admin) {
            bp_update_user_meta(bp_core_get_userid($site_admin), $bb_table_prefix . 'capabilities', array('keymaster' => true));
        }
        // Create the first forum.
        bb_new_forum(array('forum_name' => 'Default Forum'));
        // Set the site URI
        bb_update_option('uri', BB_URL);
    }
    /**
     * Fires inside an anonymous function that is run on bbPress shutdown.
     *
     * @since 1.1.0
     */
    register_shutdown_function(create_function('', 'do_action("bb_shutdown");'));
}
 /**
  * Finalises the installation by creating the database and writing all the supplied data to the database.
  *
  * @return void
  **/
 function process_form_finalise_installation()
 {
     require_once BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php';
     require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php';
     $this->inject_form_values_into_data(2);
     $this->inject_form_values_into_data(3);
     $data2 =& $this->data[2]['form'];
     $data3 =& $this->data[3]['form'];
     $data4 =& $this->data[4]['form'];
     $error_log = array();
     $installation_log = array();
     // Check the referer
     bb_check_admin_referer('bbpress-installer');
     $installation_log[] = __('Referrer is OK, beginning installation&hellip;');
     global $bbdb;
     // Setup user table variables and constants if available
     if ($data2['toggle_2_2']['value']) {
         $installation_log[] = '>>> ' . __('Setting up custom user table constants');
         global $bb;
         global $bb_table_prefix;
         if (!empty($data2['wp_table_prefix']['value'])) {
             $bb->wp_table_prefix = $data2['wp_table_prefix']['value'];
         }
         if (!empty($data2['user_bbdb_name']['value'])) {
             $bb->user_bbdb_name = $data2['user_bbdb_name']['value'];
         }
         if (!empty($data2['user_bbdb_user']['value'])) {
             $bb->user_bbdb_user = $data2['user_bbdb_user']['value'];
         }
         if (!empty($data2['user_bbdb_password']['value'])) {
             $bb->user_bbdb_password = $data2['user_bbdb_password']['value'];
         }
         if (!empty($data2['user_bbdb_host']['value'])) {
             $bb->user_bbdb_host = $data2['user_bbdb_host']['value'];
         }
         if (!empty($data2['user_bbdb_charset']['value'])) {
             $bb->user_bbdb_charset = preg_replace('/[^a-z0-9_-]/i', '', $data2['user_bbdb_charset']['value']);
         }
         if (!empty($data2['user_bbdb_collate']['value'])) {
             $bb->user_bbdb_collate = preg_replace('/[^a-z0-9_-]/i', '', $data2['user_bbdb_collate']['value']);
         }
         bb_set_custom_user_tables();
         // Add custom user database if required
         if (isset($bb->custom_databases['user'])) {
             $bbdb->add_db_server('user', $bb->custom_databases['user']);
         }
         // Add custom tables if required
         if (isset($bb->custom_tables)) {
             $bbdb->tables = array_merge($bbdb->tables, $bb->custom_tables);
             if (is_wp_error($bbdb->set_prefix($bb_table_prefix))) {
                 die(__('Your user table prefix may only contain letters, numbers and underscores.'));
             }
         }
     }
     // Create the database
     $installation_log[] = "\n" . __('Step 1 - Creating database tables');
     if (!$this->database_tables_are_installed()) {
         // Hide db errors
         $bbdb->hide_errors();
         // Install the database
         $alterations = bb_install();
         // Show db errors
         $bbdb->show_errors();
         if (isset($alterations['errors']) && is_array($alterations['errors'])) {
             $error_log = array_merge($error_log, $alterations['errors']);
         }
         if (isset($alterations['messages']) && is_array($alterations['messages'])) {
             $installation_log = array_merge($installation_log, $alterations['messages']);
         }
         if (!$this->database_tables_are_installed()) {
             $installation_log[] = '>>> ' . __('Database installation failed!!!');
             $installation_log[] = '>>>>>> ' . __('Halting installation!');
             $error_log[] = __('Database installation failed!!!');
             $this->step_status[4] = 'incomplete';
             $this->strings[4]['h2'] = __('Installation failed!');
             $this->strings[4]['messages']['error'][] = __('The database failed to install. You may need to replace bbPress with a fresh copy and start again.');
             $data4['installation_log']['value'] = join("\n", $installation_log);
             $data4['error_log']['value'] = join("\n", $error_log);
             return 'incomplete';
         }
     } else {
         $installation_log[] = '>>> ' . __('Database is already installed!!!');
     }
     // Integration settings passed from step 2
     // These are already validated provided that the referer checks out
     $installation_log[] = "\n" . __('Step 2 - WordPress integration (optional)');
     if ($data2['toggle_2_0']['value']) {
         if ($data2['toggle_2_1']['value']) {
             bb_update_option('wp_siteurl', $data2['wp_siteurl']['value']);
             $installation_log[] = '>>> ' . __('WordPress address (URL):') . ' ' . $data2['wp_siteurl']['value'];
             bb_update_option('wp_home', $data2['wp_home']['value']);
             $installation_log[] = '>>> ' . __('Blog address (URL):') . ' ' . $data2['wp_home']['value'];
             $config_result = $this->write_lines_to_file(BB_PATH . 'bb-config.php', false, array("define( 'BB_AUTH_KEY" => array("'" . BB_AUTH_KEY . "'", "'" . $data2['wp_auth_key']['value'] . "'"), "define( 'BB_SECURE_A" => array("'" . BB_SECURE_AUTH_KEY . "'", "'" . $data2['wp_secure_auth_key']['value'] . "'"), "define( 'BB_LOGGED_I" => array("'" . BB_LOGGED_IN_KEY . "'", "'" . $data2['wp_logged_in_key']['value'] . "'")));
             switch ($config_result) {
                 case 1:
                     $installation_log[] = '>>> ' . __('WordPress cookie keys set.');
                     break;
                 default:
                     $error_log[] = '>>> ' . __('WordPress cookie keys not set.');
                     $error_log[] = '>>>>>> ' . __('Your "bb-config.php" file was not writable.');
                     $error_log[] = '>>>>>> ' . __('You will need to manually re-define "BB_AUTH_KEY", "BB_SECURE_AUTH_KEY" and "BB_LOGGED_IN_KEY" in your "bb-config.php" file.');
                     $installation_log[] = '>>> ' . __('WordPress cookie keys not set.');
                     break;
             }
             if (!empty($data2['wp_auth_salt']['value'])) {
                 bb_update_option('bb_auth_salt', $data2['wp_auth_salt']['value']);
                 $installation_log[] = '>>> ' . __('WordPress "auth" cookie salt set from input.');
             }
             if (!empty($data2['wp_secure_auth_salt']['value'])) {
                 bb_update_option('bb_secure_auth_salt', $data2['wp_secure_auth_salt']['value']);
                 $installation_log[] = '>>> ' . __('WordPress "secure auth" cookie salt set from input.');
             }
             if (!empty($data2['wp_logged_in_salt']['value'])) {
                 bb_update_option('bb_logged_in_salt', $data2['wp_logged_in_salt']['value']);
                 $installation_log[] = '>>> ' . __('WordPress "logged in" cookie salt set from input.');
             }
         }
         if ($data2['toggle_2_2']['value']) {
             if (!bb_get_option('bb_auth_salt') || !bb_get_option('bb_secure_auth_salt') || !bb_get_option('bb_logged_in_salt')) {
                 $installation_log[] = '>>> ' . __('Fetching missing WordPress cookie salts.');
                 $_prefix = $bb->wp_table_prefix;
                 if (!empty($data2['wordpress_mu_primary_blog_id']['value'])) {
                     $_prefix .= $data2['wordpress_mu_primary_blog_id']['value'] . '_';
                 }
                 if (isset($bb->custom_databases['user'])) {
                     $bbdb->tables['options'] = array('user', $_prefix . 'options');
                 } else {
                     $bbdb->tables['options'] = $_prefix . 'options';
                 }
                 unset($_prefix);
                 $bbdb->set_prefix($bb_table_prefix);
                 if (!bb_get_option('bb_auth_salt')) {
                     $wp_auth_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'auth_salt' LIMIT 1");
                     if ($wp_auth_salt) {
                         bb_update_option('bb_auth_salt', $wp_auth_salt);
                         $installation_log[] = '>>>>>> ' . __('WordPress "auth" cookie salt set.');
                     } else {
                         $error_log[] = '>>> ' . __('WordPress "auth" cookie salt not set.');
                         $error_log[] = '>>>>>> ' . __('Could not fetch "auth" cookie salt from the WordPress options table.');
                         $error_log[] = '>>>>>> ' . __('You will need to manually define the "auth" cookie salt in your database.');
                         $installation_log[] = '>>>>>> ' . __('WordPress "auth" cookie salt not set.');
                     }
                 }
                 if (!bb_get_option('bb_secure_auth_salt')) {
                     $wp_secure_auth_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'secure_auth_salt' LIMIT 1");
                     if ($wp_secure_auth_salt) {
                         bb_update_option('bb_secure_auth_salt', $wp_secure_auth_salt);
                         $installation_log[] = '>>>>>> ' . __('WordPress "secure auth" cookie salt set.');
                     } else {
                         // This cookie salt is sometimes empty so don't error
                         $installation_log[] = '>>>>>> ' . __('WordPress "secure auth" cookie salt not set.');
                     }
                 }
                 if (!bb_get_option('bb_logged_in_salt')) {
                     $wp_logged_in_salt = $bbdb->get_var("SELECT `option_value` FROM {$bbdb->options} WHERE `option_name` = 'logged_in_salt' LIMIT 1");
                     if ($wp_logged_in_salt) {
                         bb_update_option('bb_logged_in_salt', $wp_logged_in_salt);
                         $installation_log[] = '>>>>>> ' . __('WordPress "logged in" cookie salt set.');
                     } else {
                         $error_log[] = '>>> ' . __('WordPress "logged in" cookie salt not set.');
                         $error_log[] = '>>>>>> ' . __('Could not fetch "logged in" cookie salt from the WordPress options table.');
                         $error_log[] = '>>>>>> ' . __('You will need to manually define the "logged in" cookie salt in your database.');
                         $installation_log[] = '>>>>>> ' . __('WordPress "logged in" cookie salt not set.');
                     }
                 }
             }
             if (!empty($data2['wp_table_prefix']['value'])) {
                 bb_update_option('wp_table_prefix', $data2['wp_table_prefix']['value']);
                 $installation_log[] = '>>> ' . __('User database table prefix:') . ' ' . $data2['wp_table_prefix']['value'];
             }
             if (!empty($data2['wordpress_mu_primary_blog_id']['value'])) {
                 bb_update_option('wordpress_mu_primary_blog_id', $data2['wordpress_mu_primary_blog_id']['value']);
                 $installation_log[] = '>>> ' . __('WordPress MU primary blog ID:') . ' ' . $data2['wordpress_mu_primary_blog_id']['value'];
             }
             if ($data2['toggle_2_3']['value']) {
                 if (!empty($data2['user_bbdb_name']['value'])) {
                     bb_update_option('user_bbdb_name', $data2['user_bbdb_name']['value']);
                     $installation_log[] = '>>> ' . __('User database name:') . ' ' . $data2['user_bbdb_name']['value'];
                 }
                 if (!empty($data2['user_bbdb_user']['value'])) {
                     bb_update_option('user_bbdb_user', $data2['user_bbdb_user']['value']);
                     $installation_log[] = '>>> ' . __('User database user:'******' ' . $data2['user_bbdb_user']['value'];
                 }
                 if (!empty($data2['user_bbdb_password']['value'])) {
                     bb_update_option('user_bbdb_password', $data2['user_bbdb_password']['value']);
                     $installation_log[] = '>>> ' . __('User database password:'******' ' . $data2['user_bbdb_password']['value'];
                 }
                 if (!empty($data2['user_bbdb_host']['value'])) {
                     bb_update_option('user_bbdb_host', $data2['user_bbdb_host']['value']);
                     $installation_log[] = '>>> ' . __('User database host:') . ' ' . $data2['user_bbdb_host']['value'];
                 }
                 if (!empty($data2['user_bbdb_charset']['value'])) {
                     bb_update_option('user_bbdb_charset', $data2['user_bbdb_charset']['value']);
                     $installation_log[] = '>>> ' . __('User database character set:') . ' ' . $data2['user_bbdb_charset']['value'];
                 }
                 if (!empty($data2['user_bbdb_collate']['value'])) {
                     bb_update_option('user_bbdb_collate', $data2['user_bbdb_collate']['value']);
                     $installation_log[] = '>>> ' . __('User database collation:') . ' ' . $data2['user_bbdb_collate']['value'];
                 }
                 if (!empty($data2['custom_user_table']['value'])) {
                     bb_update_option('custom_user_table', $data2['custom_user_table']['value']);
                     $installation_log[] = '>>> ' . __('User database "user" table:') . ' ' . $data2['custom_user_table']['value'];
                 }
                 if (!empty($data2['custom_user_meta_table']['value'])) {
                     bb_update_option('custom_user_meta_table', $data2['custom_user_meta_table']['value']);
                     $installation_log[] = '>>> ' . __('User database "user meta" table:') . ' ' . $data2['custom_user_meta_table']['value'];
                 }
             }
         }
     } else {
         $installation_log[] = '>>> ' . __('Integration not enabled');
     }
     // Site settings passed from step 3
     // These are already validated provided that the referer checks out
     $installation_log[] = "\n" . __('Step 3 - Site settings');
     bb_update_option('name', $data3['name']['value']);
     $installation_log[] = '>>> ' . __('Site name:') . ' ' . $data3['name']['value'];
     bb_update_option('uri', $data3['uri']['value']);
     $installation_log[] = '>>> ' . __('Site address (URL):') . ' ' . $data3['uri']['value'];
     bb_update_option('from_email', $data3['keymaster_user_email']['value']);
     $installation_log[] = '>>> ' . __('From email address:') . ' ' . $data3['keymaster_user_email']['value'];
     // Create the key master
     $keymaster_created = false;
     switch ($data3['keymaster_user_type']['value']) {
         case 'new':
             // Check to see if the user login already exists
             if ($keymaster_user = bb_get_user($data3['keymaster_user_login']['value'], array('by' => 'login'))) {
                 // The keymaster is an existing bbPress user
                 $installation_log[] = '>>> ' . __('Key master could not be created!');
                 $installation_log[] = '>>>>>> ' . __('That login is already taken!');
                 $error_log[] = __('Key master could not be created!');
                 if ($keymaster_user->bb_capabilities['keymaster']) {
                     // The existing user is a key master - continue
                     $bb_current_user = bb_set_current_user($keymaster_user->ID);
                     $installation_log[] = '>>>>>> ' . __('Existing key master entered!');
                     $data4['keymaster_user_password']['value'] = __('Your bbPress password');
                     $data3['keymaster_user_email']['value'] = $keymaster_user->user_email;
                     bb_update_option('from_email', $keymaster_user->user_email);
                     $installation_log[] = '>>>>>> ' . __('Re-setting admin email address.');
                     $keymaster_created = true;
                 } else {
                     // The existing user is a non-key master user - halt installation
                     $installation_log[] = '>>>>>> ' . __('Existing user without key master role entered!');
                     $installation_log[] = '>>>>>>>>> ' . __('Halting installation!');
                     $this->step_status[4] = 'incomplete';
                     $this->strings[4]['h2'] = __('Installation failed!');
                     $this->strings[4]['messages']['error'][] = __('The key master could not be created. An existing user was found with that user login.');
                     $data4['installation_log']['value'] = join("\n", $installation_log);
                     $data4['error_log']['value'] = join("\n", $error_log);
                     return 'incomplete';
                 }
                 break;
             }
             // Helper function to let us know the password that was created
             global $keymaster_password;
             function bb_get_keymaster_password($user_id, $pass)
             {
                 global $keymaster_password;
                 $keymaster_password = $pass;
             }
             add_action('bb_new_user', 'bb_get_keymaster_password', 10, 2);
             // Create the new user (automattically given key master role when BB_INSTALLING is true)
             if ($keymaster_user_id = bb_new_user($data3['keymaster_user_login']['value'], $data3['keymaster_user_email']['value'], '')) {
                 $bb_current_user = bb_set_current_user($keymaster_user_id);
                 $data4['keymaster_user_password']['value'] = $keymaster_password;
                 $installation_log[] = '>>> ' . __('Key master created');
                 $installation_log[] = '>>>>>> ' . __('Username:'******' ' . $data3['keymaster_user_login']['value'];
                 $installation_log[] = '>>>>>> ' . __('Email address:') . ' ' . $data3['keymaster_user_email']['value'];
                 $installation_log[] = '>>>>>> ' . __('Password:'******' ' . $data4['keymaster_user_password']['value'];
                 $keymaster_created = true;
             } else {
                 $installation_log[] = '>>> ' . __('Key master could not be created!');
                 $installation_log[] = '>>>>>> ' . __('Halting installation!');
                 $error_log[] = __('Key master could not be created!');
                 $this->step_status[4] = 'incomplete';
                 $this->strings[4]['h2'] = __('Installation failed!');
                 $this->strings[4]['messages']['error'][] = __('The key master could not be created. You may need to replace bbPress with a fresh copy and start again.');
                 $data4['installation_log']['value'] = join("\n", $installation_log);
                 $data4['error_log']['value'] = join("\n", $error_log);
                 return 'incomplete';
             }
             break;
         case 'old':
             if ($keymaster_user = bb_get_user($data3['keymaster_user_login']['value'], array('by' => 'login'))) {
                 // The keymaster is an existing bbPress or WordPress user
                 $bb_current_user = bb_set_current_user($keymaster_user->ID);
                 $bb_current_user->set_role('keymaster');
                 $data4['keymaster_user_password']['value'] = __('Your existing password');
                 $installation_log[] = '>>> ' . __('Key master role assigned to existing user');
                 $installation_log[] = '>>>>>> ' . __('Username:'******' ' . $data3['keymaster_user_login']['value'];
                 $installation_log[] = '>>>>>> ' . __('Email address:') . ' ' . $data3['keymaster_user_email']['value'];
                 $installation_log[] = '>>>>>> ' . __('Password:'******' ' . $data4['keymaster_user_password']['value'];
                 $keymaster_created = true;
             } else {
                 $installation_log[] = '>>> ' . __('Key master role could not be assigned to existing user!');
                 $installation_log[] = '>>>>>> ' . __('Halting installation!');
                 $error_log[] = __('Key master could not be created!');
                 $this->step_status[4] = 'incomplete';
                 $this->strings[4]['h2'] = __('Installation failed!');
                 $this->strings[4]['messages']['error'][] = __('The key master could not be assigned. You may need to replace bbPress with a fresh copy and start again.');
                 $data4['installation_log']['value'] = join("\n", $installation_log);
                 $data4['error_log']['value'] = join("\n", $error_log);
                 return 'incomplete';
             }
             break;
     }
     // Don't create an initial forum if any forums already exist
     if (!$bbdb->get_results('SELECT `forum_id` FROM `' . $bbdb->forums . '` LIMIT 1;')) {
         if ($this->language != BB_LANG) {
             global $locale, $l10n;
             $locale = BB_LANG;
             unset($l10n['default']);
             bb_load_default_textdomain();
         }
         $description = __('Just another bbPress community');
         bb_update_option('description', $description);
         if ($this->language != BB_LANG) {
             $locale = $this->language;
             unset($l10n['default']);
             bb_load_default_textdomain();
         }
         $installation_log[] = '>>> ' . __('Description:') . ' ' . $description;
         if ($forum_id = bb_new_forum(array('forum_name' => $data3['forum_name']['value']))) {
             $installation_log[] = '>>> ' . __('Forum name:') . ' ' . $data3['forum_name']['value'];
             if ($this->language != BB_LANG) {
                 $locale = BB_LANG;
                 unset($l10n['default']);
                 bb_load_default_textdomain();
             }
             $topic_title = __('Your first topic');
             $topic_id = bb_insert_topic(array('topic_title' => $topic_title, 'forum_id' => $forum_id, 'tags' => 'bbPress'));
             $post_text = __('First Post!  w00t.');
             bb_insert_post(array('topic_id' => $topic_id, 'post_text' => $post_text));
             if ($this->language != BB_LANG) {
                 $locale = $this->language;
                 unset($l10n['default']);
                 bb_load_default_textdomain();
             }
             $installation_log[] = '>>>>>> ' . __('Topic:') . ' ' . $topic_title;
             $installation_log[] = '>>>>>>>>> ' . __('Post:') . ' ' . $post_text;
         } else {
             $installation_log[] = '>>> ' . __('Forum could not be created!');
             $error_log[] = __('Forum could not be created!');
         }
     } else {
         $installation_log[] = '>>> ' . __('There are existing forums in this database.');
         $installation_log[] = '>>>>>> ' . __('No new forum created.');
         $error_log[] = __('Forums already exist!');
     }
     if (defined('BB_PLUGIN_DIR') && BB_PLUGIN_DIR && !file_exists(BB_PLUGIN_DIR)) {
         // Just suppress errors as this is not critical
         if (@mkdir(BB_PLUGIN_DIR, 0750)) {
             $installation_log[] = '>>> ' . sprintf(__('Making plugin directory at %s.'), BB_PLUGIN_DIR);
         }
     }
     if (defined('BB_THEME_DIR') && BB_THEME_DIR && !file_exists(BB_THEME_DIR)) {
         // Just suppress errors as this is not critical
         if (@mkdir(BB_THEME_DIR, 0750)) {
             $installation_log[] = '>>> ' . sprintf(__('Making theme directory at %s.'), BB_THEME_DIR);
         }
     }
     if ($keymaster_created) {
         $keymaster_email_message = sprintf(__("Your new bbPress site has been successfully set up at:\n\n%1\$s\n\nYou can log in to the key master account with the following information:\n\nUsername: %2\$s\nPassword: %3\$s\n\nWe hope you enjoy your new forums. Thanks!\n\n--The bbPress Team\nhttp://bbpress.org/"), bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), $data3['keymaster_user_login']['value'], $data4['keymaster_user_password']['value']);
         if (bb_mail($data3['keymaster_user_email']['value'], __('New bbPress installation'), $keymaster_email_message)) {
             $installation_log[] = '>>> ' . __('Key master email sent');
         } else {
             $installation_log[] = '>>> ' . __('Key master email not sent!');
             $error_log[] = __('Key master email not sent!');
         }
     }
     if (count($error_log)) {
         $this->strings[4]['h2'] = __('Installation completed with some errors!');
         $this->strings[4]['messages']['error'][] = __('Your installation completed with some minor errors. See the error log below for more specific information.');
         $installation_log[] = "\n" . __('There were some errors encountered during installation!');
     } else {
         $this->strings[4]['messages']['message'][] = __('Your installation completed successfully.');
         $installation_log[] = "\n" . __('Installation complete!');
     }
     $this->step_status[4] = 'complete';
     $data4['installation_log']['value'] = join("\n", $installation_log);
     $data4['error_log']['value'] = join("\n", $error_log);
     return 'complete';
 }
Exemple #9
0
// Get plugin counts
extract(bb_get_plugin_counts());
// Get requested plugins
$requested_plugins = bb_get_plugins('all', $_plugin_type, $_plugin_status);
// Get currently active
$active_plugins = (array) bb_get_option('active_plugins');
// Check for missing plugin files and remove them from the active plugins array
$update = false;
foreach ($active_plugins as $index => $plugin) {
    if (!file_exists(bb_get_plugin_path($plugin))) {
        $update = true;
        unset($active_plugins[$index]);
    }
}
if ($update) {
    bb_update_option('active_plugins', $active_plugins);
}
unset($update, $index, $plugin);
// Set the action
$action = '';
if (isset($_GET['action']) && !empty($_GET['action'])) {
    $action = trim($_GET['action']);
}
// Set the plugin
$plugin = isset($_GET['plugin']) ? trim(stripslashes($_GET['plugin'])) : '';
// Deal with user actions
if (!empty($action)) {
    switch ($action) {
        case 'activate':
            // Activation
            bb_check_admin_referer('activate-plugin_' . $plugin);
Exemple #10
0
 */
bb_load_plugin_textdomain('easy-mentions', dirname(__FILE__) . '/languages');
/* Create Text Domain For Translations */
/* Defines */
define('EM_VER', '0.2');
/* Version */
define('EM_OPTIONS', 'Easy-Mentions');
/* Option Name */
define('EM_PLUGPATH', bb_get_plugin_uri(bb_plugin_basename(__FILE__)));
/* Plugin URL */
/* Get the options, if not found then set them */
$em_plugopts = bb_get_option(EM_OPTIONS);
if (!is_array($em_plugopts)) {
    $em_plugopts = array('link-tags' => 1, 'link-users' => 1, 'link-user-to' => 'profile', 'reply-link' => 0, 'reply-text' => "<em>Replying to @%%USERNAME%%\\'s <a href=\"%%POSTLINK%%\">post</a>:</em>");
    bb_update_option(EM_OPTIONS, $em_plugopts);
}
if ($em_plugopts['link-to']) {
    /* Update the old options, will be removed in v0.4 */
    unset($em_plugopts['link-to']);
    $em_plugopts['link-users'] = 1;
    $em_plugopts['link-tags'] = 1;
    $em_plugopts['link-user-to'] = $em_plugopts['link-to'] == 'website' ? 'website' : 'profile';
    bb_update_option(EM_OPTIONS, $em_plugopts);
}
if (bb_is_admin()) {
    /* Load admin.php file if it is the admin area */
    require_once 'includes/admin.php';
} else {
    /* Else load public.php file if it is the public area */
    require_once 'includes/public.php';
}
            echo $bbdb->usermeta;
            ?>
. Please check and re-run the script or duplicate the table yourself.</li></ol>
                <?php 
            break;
        }
        ?>
            </li>

            <?php 
        // Set the wp table prefix for sometime
        bb_update_option('wp_table_prefix', $wpdb->prefix);
        // Why don't people follow docs
        // Map the user roles, only admin = keymaster, rest = members
        if (!bb_get_option('wp_roles_map')) {
            bb_update_option('wp_roles_map', array('administrator' => 'keymaster', 'editor' => 'member', 'author' => 'member', 'contributor' => 'member', 'subscriber' => 'member'));
            ?>

                <li>User role mapping options have been automatically set. The WordPress administrator is now the keymaster, rest all WordPress roles are bbPress members.</li>

            <?php 
        }
        // Apply the bbPress roles to the new users based on their WordPress roles
        bb_apply_wp_role_map_to_orphans();
        // Get a keymaster
        $users = bb_user_search(array('roles' => 'keymaster', 'users_per_page' => 1));
        $user = $users[0];
        if (defined('W2BC_DEBUG') && W2BC_DEBUG == true) {
            ?>
                <li>Logging in as the following user:
                    <pre><?php 
Exemple #12
0
if ($socialit_plugopts['shortyapi'] == "1") {
    //means that 1.2 ver was installed, and we have to fix some issues
    $socialit_plugopts['shortyapi'] = array('snip' => array('user' => '', 'key' => ''), 'bitly' => array('user' => '', 'key' => ''), 'supr' => array('chk' => 0, 'user' => '', 'key' => ''), 'trim' => array('chk' => 0, 'user' => '', 'pass' => ''), 'tinyarrow' => array('chk' => 0, 'user' => ''), 'cligs' => array('chk' => 0, 'key' => ''));
    bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
    //update with edited options
}
if ($socialit_plugopts['shorty'] == 'e7t') {
    $socialit_plugopts['shorty'] = 'b2l';
    //now, no more e7t, instead b2l.me
    bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
    //update with edited options
}
//fix for Social It 1.3, will be removed after the release of 1.5
if (!is_array($socialit_plugopts['bookmark'])) {
    $socialit_plugopts['bookmark'] = array_keys($socialit_bookmarks_data);
    bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
    //update with edited options
}
//add actions/filters
add_action('bb_admin_menu_generator', 'socialit_menu_link', -998);
//link in settings
add_action('bb_admin_head', 'socialit_admin', 997);
//admin css
add_action('bb_head', 'socialit_public', 997);
//public css
if (bb_is_topic() && $_GET['socialit_hide_show'] == "1") {
    add_action('bb_init', 'socialit_hide_show_do', 997);
    //do the function of hide/show socialit
}
add_filter('post_text', 'socialit_insert_in_post', 997);
//to insert social it automatically below the first post of every topic
Exemple #13
0
function li_configuration_page_process()
{
    if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update-li-settings') {
        bb_check_admin_referer('options-liconnect-update');
        $li_app_id = trim($_POST['li_app_id']);
        $li_secret = trim($_POST['li_secret']);
        bb_update_option('li_app_id', $li_app_id);
        bb_update_option('li_secret', $li_secret);
        if (!isset($_POST['li_displayname_from']) || $_POST['li_displayname_from'] < 0 || $_POST['li_displayname_from'] > 2) {
            $_POST['li_displayname_from'] = 0;
        }
        bb_update_option('li_displayname_from', intval($_POST['li_displayname_from']));
        if (!isset($_POST['li_get_jquery']) || true !== (bool) $_POST['li_get_jquery']) {
            bb_delete_option('li_get_jquery');
        } else {
            bb_update_option('li_get_jquery', 1);
        }
        if (!isset($_POST['li_allow_useredit']) || true !== (bool) $_POST['li_allow_useredit']) {
            bb_delete_option('li_allow_useredit');
        } else {
            bb_update_option('li_allow_useredit', 1);
        }
        if (!isset($_POST['li_request_email']) || true !== (bool) $_POST['li_request_email']) {
            bb_delete_option('li_request_email');
        } else {
            bb_update_option('li_request_email', 1);
        }
        if (!isset($_POST['li_hide_post_login']) || true !== (bool) $_POST['li_hide_post_login']) {
            bb_delete_option('li_hide_post_login');
        } else {
            bb_update_option('li_hide_post_login', 1);
        }
        bb_admin_notice(__('Configuration saved.'));
    }
}
Exemple #14
0
function socialit_get_fetch_url()
{
    global $socialit_plugopts;
    $perms = trim(socialit_get_current_url());
    //check if the link is already genereted or not, if yes, then return the link
    $fetch_url = trim($socialit_plugopts['shorturls'][md5($perms)]);
    if ($fetch_url) {
        return $fetch_url;
    }
    $url_more = "";
    $use_POST_method = false;
    $POST_data = null;
    // which short url service should be used?
    if ($socialit_plugopts['shorty'] == "e7t") {
        $first_url = "http://b2l.me/api.php?alias=&url=" . $perms;
        //now no e7t, instead b2l
    } elseif ($socialit_plugopts['shorty'] == "b2l") {
        $first_url = "http://b2l.me/api.php?alias=&url=" . $perms;
    } elseif ($socialit_plugopts['shorty'] == "tiny") {
        $first_url = "http://tinyurl.com/api-create.php?url=" . $perms;
    } elseif ($socialit_plugopts['shorty'] == "snip") {
        $first_url = "http://snipr.com/site/getsnip";
        $use_POST_method = true;
        $POST_data = "snipformat=simple&sniplink=" . rawurlencode($perms) . "&snipuser="******"&snipapi=" . $socialit_plugopts['shortyapi']['snip']['key'];
    } elseif ($socialit_plugopts['shorty'] == "cligs") {
        $first_url = "http://cli.gs/api/v1/cligs/create?url=" . urlencode($perms) . "&appid=SocialIt";
        if ($socialit_plugopts['shortyapi']['cligs']['chk'] == 1) {
            $first_url .= "&key=" . $socialit_plugopts['shortyapi']['cligs']['key'];
        }
    } elseif ($socialit_plugopts['shorty'] == "supr") {
        $first_url = "http://su.pr/api/simpleshorten?url=" . $perms;
        if ($socialit_plugopts['shortyapi']['supr']['chk'] == 1) {
            $first_url .= "&login="******"&apiKey=" . $socialit_plugopts['shortyapi']['supr']['key'];
        }
    } elseif ($socialit_plugopts['shorty'] == "bitly") {
        $first_url = "http://api.bit.ly/shorten?version=2.0.1&longUrl=" . $perms . "&history=1&login="******"&apiKey=" . $socialit_plugopts['shortyapi']['bitly']['key'] . "&format=json";
    } elseif ($socialit_plugopts['shorty'] == "trim") {
        if ($socialit_plugopts['shortyapi']['trim']['chk'] == 1) {
            $first_url = "http://api.tr.im/api/trim_url.json?url=" . $perms . "&username="******"&password="******"http://api.tr.im/api/trim_simple?url=" . $perms;
        }
    } elseif ($socialit_plugopts['shorty'] == "tinyarrow") {
        $first_url = "http://tinyarro.ws/api-create.php?";
        if ($socialit_plugopts['shortyapi']['tinyarrow']['chk'] == 1) {
            $first_url .= "&userid=" . $socialit_plugopts['shortyapi']['tinyarrow']['user'];
        }
        $first_url .= "&url=" . $perms;
    } else {
        //default is e7t.us
        $first_url = "http://b2l.me/api.php?alias=&url=" . $perms;
    }
    // retrieve the shortened URL
    $fetch_url = socialit_nav_browse($first_url, $use_POST_method, $POST_data);
    if ($socialit_plugopts['shorty'] == "trim" && $socialit_plugopts['shortyapi']['trim']['chk'] == 1) {
        $fetch_array = json_decode($fetch_url, true);
        $fetch_url = $fetch_array['url'];
    }
    if ($socialit_plugopts['shorty'] == "bitly") {
        $fetch_array = json_decode($fetch_url, true);
        $fetch_url = $fetch_array['results'][$perms]['shortUrl'];
    }
    if ($fetch_url) {
        // remote call made and was successful
        $fetch_url = trim($fetch_url);
        $socialit_plugopts['shorturls'][md5($perms)] = $fetch_url;
        bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
        // update values for future use
    } else {
        //return the permalink, getting the short url was not successful
        $fetch_url = $perms;
    }
    return $fetch_url;
}
if (in_array($action, array('update-users', 'update-options'))) {
    bb_check_admin_referer('options-nxtclass-' . $action);
    // Deal with advanced user database checkbox when it isn't checked
    if (!isset($_POST['user_bbdb_advanced'])) {
        $_POST['user_bbdb_advanced'] = false;
    }
    foreach ((array) $_POST as $option => $value) {
        if (!in_array($option, array('_nxtnonce', '_nxt_http_referer', 'action', 'submit'))) {
            $option = trim($option);
            $value = is_array($value) ? $value : trim($value);
            $value = stripslashes_deep($value);
            if (($option == 'nxt_siteurl' || $option == 'nxt_home') && !empty($value)) {
                $value = rtrim($value, " \t\n\r\v/") . '/';
            }
            if ($value) {
                bb_update_option($option, $value);
            } else {
                bb_delete_option($option);
            }
        }
    }
    if ($action == 'update-users') {
        bb_apply_nxt_role_map_to_orphans();
    }
    $goback = add_query_arg('updated', $action, nxt_get_referer());
    bb_safe_redirect($goback);
    exit;
}
switch (@$_GET['updated']) {
    case 'update-users':
        bb_admin_notice(__('<strong>User role mapping saved.</strong>'));
Exemple #16
0
        wp_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
        exit;
    }
    bb_check_admin_referer('switch-theme');
    do_action('bb_deactivate_theme_' . $activetheme);
    $theme = stripslashes($_GET['theme']);
    $theme_data = bb_get_theme_data($theme);
    if ($theme_data['Name']) {
        $name = $theme_data['Name'];
    } else {
        $name = preg_replace('/^([a-z0-9_-]+#)/i', '', $theme);
    }
    if ($theme == BB_DEFAULT_THEME) {
        bb_delete_option('bb_active_theme');
    } else {
        bb_update_option('bb_active_theme', $theme);
    }
    do_action('bb_activate_theme_' . $theme);
    wp_redirect(bb_get_uri('bb-admin/themes.php', array('activated' => 1, 'name' => urlencode($name)), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN));
    exit;
}
if (isset($_GET['activated'])) {
    $theme_notice = bb_admin_notice(sprintf(__('<strong>Theme "%s" activated</strong>'), esc_attr($_GET['name'])));
}
if (!in_array($activetheme, $themes)) {
    if ($activetheme == BB_DEFAULT_THEME) {
        remove_action('bb_admin_notices', $theme_notice);
        bb_admin_notice(__('<strong>Default theme is missing.</strong>'), 'error');
    } else {
        bb_delete_option('bb_active_theme');
        remove_action('bb_admin_notices', $theme_notice);
Exemple #17
0
function bp_forums_load_bbpress() {
	global $bp, $wpdb, $wp_roles, $current_user, $wp_users_object;
	global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
	global $bb_roles, $wp_taxonomy_object;

	/* Return if we've already run this function. */
	if ( is_object( $bbdb ) && is_object( $bb_roles ) )
		return;

	if ( !bp_forums_is_installed_correctly() )
		return false;

	define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' );
	define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' );
	define( 'BB_URL', BP_PLUGIN_URL . '/bp-forums/bbpress/' );
	define( 'BB_INC', 'bb-includes/' );

	require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
	require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );

	require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-posts.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-capabilities.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-meta.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
	require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );

	require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
	require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );

	$bb = new stdClass();
	require_once( $bp->forums->bbconfig );

	// Setup the global database connection
	$bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );

	/* Set the table names */
	$bbdb->forums = $bb_table_prefix . 'forums';
	$bbdb->meta = $bb_table_prefix . 'meta';
	$bbdb->posts = $bb_table_prefix . 'posts';
	$bbdb->terms = $bb_table_prefix . 'terms';
	$bbdb->term_relationships = $bb_table_prefix . 'term_relationships';
	$bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
	$bbdb->topics = $bb_table_prefix . 'topics';

	if ( isset( $bb->custom_user_table ) )
		$bbdb->users = $bb->custom_user_table;
	else
		$bbdb->users = $wpdb->users;

	if ( isset( $bb->custom_user_meta_table ) )
		$bbdb->usermeta = $bb->custom_user_meta_table;
	else
		$bbdb->usermeta = $wpdb->usermeta;

	$bbdb->prefix = $bb_table_prefix;

	define( 'BB_INSTALLING', false );

	/* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
	if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

	require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );

	if ( is_object( $wp_roles ) ) {
		$bb_roles = $wp_roles;
		bb_init_roles( $bb_roles );
	}

	do_action( 'bb_got_roles' );
	do_action( 'bb_init' );
	do_action( 'init_roles' );

	$bb_current_user = $current_user;
	$wp_users_object = new BP_Forums_BB_Auth;

	if ( !isset( $wp_taxonomy_object ) )
		$wp_taxonomy_object = new BB_Taxonomy( $bbdb );

	$wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );

	// Set a site id if there isn't one already
	if ( !isset( $bb->site_id ) )
		$bb->site_id = BP_ROOT_BLOG;

	/* Check if the tables are installed, if not, install them */
	if ( !$tables_installed ) {
		require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );

		/* Backticks and "IF NOT EXISTS" break the dbDelta function. */
		dbDelta( str_replace( ' IF NOT EXISTS', '', str_replace( '`', '', $bb_queries ) ) );

		require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
		bb_update_db_version();

		/* Set the site admins as the keymasters */
		$site_admins = get_site_option( 'site_admins', array('admin') );
		foreach ( (array)$site_admins as $site_admin )
			update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );

		// Create the first forum.
		bb_new_forum( array( 'forum_name' => 'Default Forum' ) );

		// Set the site URI
		bb_update_option( 'uri', BB_URL );
	}

	register_shutdown_function( create_function( '', 'do_action("bb_shutdown");' ) );
}
function private_forums_process_post()
{
    if (isset($_POST['submit'])) {
        $private_forums_options = bb_get_option('private_forums_options');
        $private_forums_options['private_forums'] = isset($_POST['private_forums']) ? $_POST['private_forums'] : array();
        $private_forums_options['failure_msg'] = $_POST['failure_msg'];
        $private_forums_options['hide_show_flag'] = $_POST['hide_show_flag'];
        if ('SHOW_PRIVATE' == $private_forums_options['hide_show_flag']) {
            $private_forums_options['private_text'] = empty($_POST['private_text']) ? 'private' : $_POST['private_text'];
        }
        bb_update_option('private_forums_options', $private_forums_options);
        unset($GLOBALS['private_forums_options']);
    }
}
/**
 * Set/update the value of a transient
 *
 * You do not need to serialize values, if the value needs to be serialize, then
 * it will be serialized before it is set.
 *
 * @since 1.0
 * @package bbPress
 * @subpackage Transient
 *
 * @param string $transient Transient name. Expected to not be SQL-escaped
 * @param mixed $value Transient value.
 * @param int $expiration Time until expiration in seconds, default 0
 * @return bool False if value was not set and true if value was set.
 */
function bb_set_transient($transient, $value, $expiration = 0)
{
    global $_bb_using_ext_object_cache, $bbdb;
    if ($_bb_using_ext_object_cache) {
        return nxt_cache_set($transient, $value, 'transient', $expiration);
    } else {
        $transient_timeout = '_transient_timeout_' . $bbdb->escape($transient);
        $transient = '_transient_' . $bbdb->escape($transient);
        if (0 != $expiration) {
            bb_update_option($transient_timeout, time() + $expiration);
        }
        return bb_update_option($transient, $value);
    }
}
function _bb_get_salt($constants, $option = false)
{
    if (!is_array($constants)) {
        $constants = array($constants);
    }
    foreach ($constants as $constant) {
        if (defined($constant)) {
            return constant($constant);
        }
    }
    if (!defined('BB_INSTALLING') || !BB_INSTALLING) {
        if (!$option) {
            $option = strtolower($constants[0]);
        }
        $salt = bb_get_option($option);
        if (empty($salt)) {
            $salt = bb_generate_password();
            bb_update_option($option, $salt);
        }
        return $salt;
    }
    return '';
}
        }
    }
    $file_target_rules = join("\n", $_kept_rules) . "\n" . $file_source_rules;
    $file_target_written = 0;
    if ($file_target_writable) {
        // Open the file for writing - rewrites the whole file
        if ($file_target_handle = fopen($file_target, 'w')) {
            if (fwrite($file_target_handle, $file_target_rules)) {
                $file_target_written = 1;
            }
            // Close the file
            fclose($file_target_handle);
            @chmod($file_target, 0666);
        }
    }
    bb_update_option('mod_rewrite_writable', $file_target_writable);
    $goback = add_query_arg('updated', 'true', $goback);
    bb_safe_redirect($goback);
    exit;
}
if ($is_apache && bb_get_option('mod_rewrite') && !bb_get_option('mod_rewrite_writable')) {
    $manual_instructions = true;
}
if (!empty($_GET['notmodrewrite'])) {
    $manual_instructions = false;
    bb_admin_notice(__('<strong>It appears that your server does not support custom permalink structures.</strong>'), 'error');
}
if (!empty($_GET['notapache'])) {
    $manual_instructions = false;
    bb_admin_notice(__('<strong>Rewriting on webservers other than Apache using mod_rewrite is currently unsupported, but we won&#8217;t stop you from trying.</strong>'), 'error');
}
Exemple #22
0
function nospamuser_block($type, $data, $noway)
{
    $settings = bb_get_option('nospamuser-settings');
    bb_update_option('nospamuser-blocks', bb_get_option('nospamuser-blocks') + 1);
    $types = array('email' => __('email address', 'nospamuser'), 'ip' => __('IP address', 'nospamuser'), 'username' => __('username', 'nospamuser'));
    if ($noway) {
        bb_die(sprintf(__('Your %1$s (%2$s) is listed in <a href="%3$s">Stop Forum Spam</a>\'s database. You have been automatically blocked. If you are not a spammer, you may <a href="http://www.stopforumspam.com/removal">appeal this listing</a>.', 'nospamuser'), $types[$type], $data, 'http://www.stopforumspam.com/' . ($type == 'ip' ? 'ipcheck/' : 'search?q=') . $data), 'Registration forbidden', 403);
    }
    if (!isset($_COOKIE['nospamuser_override']) || !bb_verify_nonce($_COOKIE['nospamuser_override'], 'nospamuser-override-' . $_SERVER['REMOTE_ADDR'])) {
        if (!function_exists('recaptcha_check_answer')) {
            // Compatibility with anything else that uses reCAPTCHA
            require_once dirname(__FILE__) . '/recaptchalib.php';
        }
        bb_die(sprintf(__('Your %1$s (%2$s) is listed in <a href="%3$s">Stop Forum Spam</a>\'s database. You have been automatically blocked. If you are not a spammer, you may <a href="http://www.stopforumspam.com/removal">appeal this listing</a> or solve the CAPTCHA below.', 'nospamuser'), $types[$type], $data, 'http://www.stopforumspam.com/' . ($type == 'ip' ? 'ipcheck/' : 'search?q=') . $data) . '<form method="post" action="' . bb_get_plugin_uri(bb_plugin_basename(__FILE__)) . '/bb-nospamuser.php"><script type="text/javascript">var RecaptchaOptions={theme:\'clean\'}</script>' . recaptcha_get_html($settings['recaptcha_pub']) . '<br/><input type="submit" value="' . esc_attr__('Submit', 'nospamuser') . '"/></form>', 'Registration forbidden', 401);
    }
}
Exemple #23
0
 /**
  * Sets the specified site options to the specified values
  *
  * @since 1.0
  * @return array|object An array containing the specified options when successfully executed or an IXR_Error object on failure
  * @param array $args Arguments passed by the XML-RPC call
  * @param string $args[0] The username for authentication
  * @param string $args[1] The password for authentication
  * @param array $args[2] The options to be updated along with the new value of the option
  *
  * XML-RPC request to set the site name and site description
  * <methodCall>
  *     <methodName>bb.setOptions</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><struct>
  *             <member>
  *                 <name>site_name</name>
  *                 <value><string>Awesome forums</string></value>
  *             </member>
  *             <member>
  *                 <name>site_description</name>
  *                 <value><string>My totally awesome forums will kick your butt</string></value>
  *             </member>
  *         </struct></value></param>
  *     </params>
  * </methodCall>
  */
 function bb_setOptions($args)
 {
     do_action('bb_xmlrpc_call', 'bb.setOptions');
     // Escape args
     $this->escape($args);
     // Get the login credentials
     $username = $args[0];
     $password = (string) $args[1];
     // Check the user is valid
     $user = $this->authenticate($username, $password, 'manage_options', __('You are not allowed to manage options.'));
     do_action('bb_xmlrpc_call_authenticated', 'bb.setOptions');
     // If an error was raised by authentication or by an action then return it
     if ($this->error) {
         return $this->error;
     }
     // Make sure there is something for us to do
     if (!$args[2] || !is_array($args[2]) || !count($args[2])) {
         $this->error = new IXR_Error(400, __('The options data is invalid.'));
         return $this->error;
     }
     $options = (array) $args[2];
     // Update the requested options
     foreach ($options as $o_name => $o_value) {
         $option_names[] = $o_name;
         // If there is no value set skip it
         if (empty($o_value)) {
             continue;
         }
         // If the option doesn't exist skip it
         if (!array_key_exists($o_name, $this->site_options)) {
             continue;
         }
         // If the option is readonly skip it
         if ($this->site_options[$o_name]['readonly'] == true) {
             continue;
         }
         // Everything is good, update the option
         bb_update_option($this->site_options[$o_name]['option'], $o_value);
     }
     $_options = $this->_getOptions($option_names);
     do_action('bb_xmlrpc_call_return', 'bb.setOptions');
     // Now return the updated values
     return $_options;
 }
Exemple #24
0
<?php

require_once '../../bb-load.php';
require_once "thanks-output.php";
$post_id = $_POST['post_id'];
$user_id = $_POST['user_id'];
$meta = bb_get_post_meta("thanks", $post_id);
if (!isset($meta)) {
    $meta = array();
}
$tmp = array();
for ($i = 0; $i < count($meta); $i++) {
    $tmp[$meta[$i]] = "X";
}
$tmp[$user_id] = "X";
$meta = array_keys($tmp);
bb_update_postmeta($post_id, "thanks", $meta);
$opt = bb_get_option("thanks_posts");
if (!isset($opt)) {
    $opt = array();
}
$tmp = array();
for ($i = 0; $i < count($opt); $i++) {
    $tmp[$opt[$i]] = "X";
}
$tmp[$post_id] = "X";
$opt = array_keys($tmp);
bb_update_option('thanks_posts', $opt);
echo thanks_output_details($post_id, $user_id, true);
Exemple #25
0
function bb_ksd_configuration_page_process()
{
    if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && $_POST['action'] == 'update-akismet-settings') {
        bb_check_admin_referer('options-akismet-update');
        $goback = remove_query_arg(array('invalid-akismet', 'updated-akismet'), wp_get_referer());
        if (!isset($_POST['akismet_stats'])) {
            $_POST['akismet_stats'] = false;
        }
        if (true === (bool) $_POST['akismet_stats']) {
            bb_update_option('akismet_stats', 1);
        } else {
            bb_delete_option('akismet_stats');
        }
        if ($_POST['akismet_key']) {
            $value = stripslashes_deep(trim($_POST['akismet_key']));
            if ($value) {
                if (bb_akismet_verify_key($value)) {
                    bb_update_option('akismet_key', $value);
                } else {
                    $goback = add_query_arg('invalid-akismet', 'true', $goback);
                    bb_safe_redirect($goback);
                    exit;
                }
            } else {
                bb_delete_option('akismet_key');
            }
        } else {
            bb_delete_option('akismet_key');
        }
        $goback = add_query_arg('updated-akismet', 'true', $goback);
        bb_safe_redirect($goback);
        exit;
    }
    if (!empty($_GET['updated-akismet'])) {
        bb_admin_notice(__('<strong>Settings saved.</strong>'));
    }
    if (!empty($_GET['invalid-akismet'])) {
        bb_admin_notice(__('<strong>The key you attempted to enter is invalid. Reverting to previous setting.</strong>'), 'error');
    }
    global $bb_admin_body_class;
    $bb_admin_body_class = ' bb-admin-settings';
}
Exemple #26
0
require_once './bb-load.php';
if ($_GET['check'] != backpress_get_option('cron_check')) {
    exit;
}
if (bb_get_option('doing_cron') > time()) {
    exit;
}
bb_update_option('doing_cron', time() + 30);
$crons = _get_cron_array();
$keys = array_keys($crons);
if (!is_array($crons) || $keys[0] > time()) {
    return;
}
foreach ($crons as $timestamp => $cronhooks) {
    if ($timestamp > time()) {
        break;
    }
    foreach ($cronhooks as $hook => $keys) {
        foreach ($keys as $key => $args) {
            $schedule = $args['schedule'];
            if ($schedule != false) {
                $new_args = array($timestamp, $schedule, $hook, $args['args']);
                call_user_func_array('wp_reschedule_event', $new_args);
            }
            wp_unschedule_event($timestamp, $hook, $args['args']);
            do_action_ref_array($hook, $args['args']);
        }
    }
}
bb_update_option('doing_cron', 0);
/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since unknown
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
 */
function bb_deactivate_plugins($plugins, $silent = false)
{
    $active_plugins = (array) bb_get_option('active_plugins');
    if (!is_array($plugins)) {
        $plugins = array($plugins);
    }
    foreach ($plugins as $plugin) {
        $plugin = bb_plugin_basename(trim($plugin));
        if (!in_array($plugin, $active_plugins)) {
            continue;
        }
        // Remove the deactivated plugin
        array_splice($active_plugins, array_search($plugin, $active_plugins), 1);
        if (!$silent) {
            do_action('bb_deactivate_plugin_' . $plugin);
        }
    }
    bb_update_option('active_plugins', $active_plugins);
}
function approve_user_registration_settings_page_process()
{
    if (isset($_POST['approve_user_registration'])) {
        $options = $_POST['approve_user_registration'] ? $_POST['approve_user_registration'] : array();
        bb_update_option('approve_user_registration_options', $options);
    }
}
function bb_update_db_version()
{
    bb_update_option('bb_db_version', bb_get_option('bb_db_version'));
}
 function update($option, $value)
 {
     return bb_update_option(BP_Options::prefix() . $option, $value);
 }