Esempio n. 1
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);
}
Esempio n. 2
0
function bb_register_plugin_deactivation_hook($file, $function)
{
    $file = bb_plugin_basename($file);
    add_action('bb_deactivate_plugin_' . $file, $function);
}
Esempio n. 3
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);
    }
}
Esempio n. 4
0
*/
/**
 * @package Easy Mentions
 * @subpackage Main Section
 * @author Gautam Gupta (www.gaut.am)
 * @link http://gaut.am/bbpress/plugins/easy-mentions/
 * @license GNU General Public License version 3 (GPLv3): http://www.opensource.org/licenses/gpl-3.0.html
 */
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);
}
    $bbdb->query("INSERT INTO {$bbdb->users} (user_login,user_nicename, user_registered) VALUES ('anonymous','Anonymous', '" . bb_current_time('mysql') . "')");
    if ($anon_id = bb_get_option('bb_anon_user_id')) {
        $bbdb->query("UPDATE {$bbdb->users} SET ID = {$anon_id} where ID = " . $bbdb->insert_id);
    } else {
        $anon_id = $bbdb->insert_id;
        bb_update_option('bb_anon_user_id', $anon_id);
    }
    $user = new BP_User($anon_id);
    $user->add_role('anonymous');
    $user->remove_role('member');
    $user->add_cap('anonymous');
    $user->remove_cap('member');
}
// remove user and meta data on deactivation
// do note remove the option in case you activate the plugin again later
add_action('bb_deactivate_plugin_' . bb_plugin_basename(__FILE__), 'bb_anon_deactivate_plugin');
function bb_anon_deactivate_plugin()
{
    global $bbdb;
    $anon_id = bb_get_option('bb_anon_user_id');
    $bbdb->query("DELETE FROM {$bbdb->users} WHERE ID = '{$anon_id}'");
    $bbdb->query("DELETE FROM {$bbdb->usermeta} WHERE user_id = '{$anon_id}'");
}
// fixes the frontpage link to add new post
add_filter('new_topic_url', 'bb_anon_filter_new_topic_url');
function bb_anon_filter_new_topic_url($url)
{
    if (is_front() && bb_get_option('bb_anon_write_topics') == "Y") {
        $url = add_query_arg('new', '1', bb_get_option('uri'));
    }
    return $url;