function __construct() {

		global $itsec_globals;

		//make sure the log file info is there or generate it. This should only affect beta users.
		if ( ! isset( $itsec_globals['settings']['log_info'] ) ) {

			$itsec_globals['settings']['log_info'] = substr( sanitize_title( get_bloginfo( 'name' ) ), 0, 20 ) . '-' . ITSEC_Lib::get_random( mt_rand( 0, 10 ) );

			update_site_option( 'itsec_global', $itsec_globals['settings'] );

		}

		//Make sure the logs directory was created
		if ( ! is_dir( $itsec_globals['ithemes_log_dir'] ) ) {
			@mkdir( trailingslashit( $itsec_globals['ithemes_dir'] ) . 'logs' );
		}

		//don't create a log file if we don't need it.
		if ( isset( $itsec_globals['settings']['log_type'] ) && $itsec_globals['settings']['log_type'] !== 0 ) {

			$this->log_file = $itsec_globals['ithemes_log_dir'] . '/event-log-' . $itsec_globals['settings']['log_info'] . '.log';
			$this->start_log(); //create a log file if we don't have one

		}

		$this->logger_modules  = array(); //array to hold information on modules using this feature
		$this->logger_displays = array(); //array to hold metabox information
		$this->module_path     = ITSEC_Lib::get_module_path( __FILE__ );

		add_action( 'plugins_loaded', array( $this, 'register_modules' ) );

		add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) ); //enqueue scripts for admin page

		//Run database cleanup daily with cron
		if ( ! wp_next_scheduled( 'itsec_purge_logs' ) ) {
			wp_schedule_event( time(), 'daily', 'itsec_purge_logs' );
		}

		add_action( 'itsec_purge_logs', array( $this, 'purge_logs' ) );

		if ( is_admin() ) {

			require( trailingslashit( $itsec_globals['plugin_dir'] ) . 'core/lib/class-itsec-wp-list-table.php' ); //used for generating log tables

			add_action( 'itsec_add_admin_meta_boxes', array( $this, 'add_admin_meta_boxes' ) ); //add log meta boxes

		}

		if ( isset( $_POST['itsec_clear_logs'] ) && $_POST['itsec_clear_logs'] === 'clear_logs' ) {

			global $itsec_clear_all_logs;

			$itsec_clear_all_logs = true;

			add_action( 'plugins_loaded', array( $this, 'purge_logs' ) );

		}

	}
예제 #2
0
파일: setup.php 프로젝트: Garth619/Femi9
 /**
  * Execute module upgrade
  *
  * @return void
  */
 public function execute_upgrade($itsec_old_version)
 {
     if ($itsec_old_version < 4000) {
         global $itsec_bwps_options;
         $current_options = get_site_option('itsec_ssl');
         // Don't do anything if settings haven't already been set, defaults exist in the module system and we prefer to use those
         if (false !== $current_options) {
             $current_options['frontend'] = isset($itsec_bwps_options['ssl_frontend']) ? intval($itsec_bwps_options['ssl_frontend']) : 0;
             update_site_option('itsec_ssl', $current_options);
             ITSEC_Response::regenerate_wp_config();
         }
     }
     if ($itsec_old_version < 4041) {
         $current_options = get_site_option('itsec_ssl');
         // If there are no current options, go with the new defaults by not saving anything
         if (is_array($current_options)) {
             // If anything in this module is being used activate it, otherwise deactivate it
             $activate = false;
             foreach ($current_options as $on) {
                 if ($on) {
                     $activate = true;
                     break;
                 }
             }
             if ($activate) {
                 ITSEC_Modules::activate('ssl');
             } else {
                 ITSEC_Modules::deactivate('ssl');
             }
             // remove 'enabled' which isn't used in the new module
             unset($current_options['enabled']);
             ITSEC_Modules::set_settings('ssl', $current_options);
         }
     }
 }
 function update_network_option($optionName, $defaultValue = '')
 {
     if ($this->use_site_option()) {
         return update_site_option($optionName, $defaultValue);
     }
     return update_option($optionName, $defaultValue);
 }
 /**
  *	Process network options
  */
 function process_network_settings()
 {
     if (current_user_can('manage_network')) {
         $opts = array('recaptcha_publickey' => 'trim', 'recaptcha_privatekey' => 'trim', 'recaptcha_enable_comments' => 'intval', 'recaptcha_enable_signup' => 'intval', 'recaptcha_enable_login' => 'intval', 'recaptcha_enable_lostpw' => 'intval', 'recaptcha_enable_wc_order' => 'intval', 'recaptcha_disable_for_known_users' => 'intval', 'recaptcha_noscript' => 'intval', 'recaptcha_comment_use_42_filter' => 'intval');
         if (array_intersect(array_keys($_POST), array_keys($opts))) {
             check_admin_referer('recaptcha-network-settings');
         }
         $updated = false;
         foreach ($opts as $option_name => $sanitize_cb) {
             if (isset($_POST[$option_name])) {
                 $option_value = sanitize_text_field($_POST[$option_name]);
                 if (is_callable($sanitize_cb)) {
                     $option_value = call_user_func($sanitize_cb, $_POST[$option_name]);
                 }
                 update_site_option($option_name, $option_value);
                 $updated = true;
             }
         }
         if ($updated) {
             $redirect = $this->remove_new_apikey_url(add_query_arg(array('updated' => 'true')));
             wp_redirect($redirect);
         }
     } else {
         wp_die('Cheating, uh?');
     }
     // expecting api keys,
 }
예제 #5
0
function update_admin_status()
{
    global $wpdb;
    if (check_ajax_referer('pb-network-managers')) {
        $restricted = $wpdb->get_results('SELECT * FROM wp_sitemeta WHERE meta_key = "pressbooks_network_managers"');
        if ($restricted) {
            $restricted = maybe_unserialize($restricted[0]->meta_value);
        } else {
            $restricted = array();
        }
        $id = absint($_POST['admin_id']);
        if (1 === absint($_POST['status'])) {
            if (!in_array($id, $restricted)) {
                $restricted[] = $id;
            }
        } elseif (0 === absint($_POST['status'])) {
            if (($key = array_search($id, $restricted)) !== false) {
                unset($restricted[$key]);
            }
        }
        if (is_array($restricted) && !empty($restricted)) {
            update_site_option('pressbooks_network_managers', $restricted);
        } else {
            delete_site_option('pressbooks_network_managers');
        }
    }
}
예제 #6
0
function undismiss_core_update( $version, $locale ) {
	$dismissed = get_site_option( 'dismissed_update_core' );
	$key = $version.'|'.$locale;
	if ( !isset( $dismissed[$key] ) ) return false;
	unset( $dismissed[$key] );
	return update_site_option( 'dismissed_update_core', $dismissed );
}
 /**
  * This function actually adds the post to the list of network recent posts when it is published for the first time.
  *
  * If the content on the post is empty then the title will be 'Auto Draft' and so it is not added to the list
  * until it is published with content.  Once a post has made it to the list it is never added back to the beginning.
  * That is, if you update the post it will not come back on to the list, nor would it move to the front if it was
  * already on the list.
  */
 function Add_Post_To_H1_Recent_Posts_From_Network()
 {
     global $post;
     if ($post->post_title == __('Auto Draft')) {
         return;
     }
     if (!get_post_meta($post->ID, 'published_once', true) && ($post->ID != 1 || strpos($post->content, $this->first_post) === false)) {
         global $wpdb;
         $domains = array();
         $blog_id = get_current_blog_id();
         // Ignore main site posts
         if ($blog_id == BLOG_ID_CURRENT_SITE) {
             return;
         }
         $rows = $wpdb->get_results("SELECT * FROM {$wpdb->dmtable} WHERE `blog_id`={$blog_id} ORDER BY id DESC LIMIT 0,1");
         foreach ($rows as $key => $val) {
             $domains[] = 'http://' . $val->domain;
         }
         $orig_blogurl = get_option('home') ? get_option('home') : get_option('siteurl');
         $mapped_blogurl = count($domains) > 0 ? $domains[0] : $orig_blogurl;
         $thumbnail = get_the_post_thumbnail($post->ID, 'medium', array('class' => 'hrpn-alignleft hrpn-thumb'));
         $essential_post_data = array('title' => $post->post_title, 'permalink' => str_replace($orig_blogurl, $mapped_blogurl, get_the_permalink($post->ID)), 'thumbnail' => $thumbnail, 'date' => $post->post_date);
         $current_recent_posts = get_site_option('network_latest_posts');
         if (empty($current_recent_posts)) {
             $current_recent_posts = array();
         }
         array_unshift($current_recent_posts, $essential_post_data);
         $new_recent_posts = array_slice($current_recent_posts, 0, 50);
         update_site_option('network_latest_posts', $new_recent_posts);
         update_post_meta($post->ID, 'published_once', 'true');
     }
 }
예제 #8
0
 function tearDown()
 {
     global $wpdb;
     update_site_option('ms_files_rewriting', 0);
     $wpdb->suppress_errors($this->suppress);
     parent::tearDown();
 }
예제 #9
0
/**
 * Perform database upgrades, create missing tables if necessary
 */
function bp_links_upgrade()
{
    global $wpdb, $bp;
    // make sure globals are set up
    $bp->links->setup_globals();
    // get db version
    $db_version = get_site_option('bp-links-db-version');
    // the sql to exec
    $sql = array();
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    $sql[] = "CREATE TABLE `{$bp->links->table_name}` (\n\t\t\t\t`id` bigint unsigned NOT NULL auto_increment,\n\t\t\t\t`cloud_id` char(32) NOT NULL,\n\t\t\t\t`user_id` bigint unsigned NOT NULL,\n\t\t\t\t`category_id` tinyint NOT NULL,\n\t\t\t\t`url` varchar(255) NOT NULL default '',\n\t\t\t\t`url_hash` char(32) NOT NULL,\n\t\t\t\t`target` varchar(25) default NULL,\n\t\t\t\t`rel` varchar(25) default NULL,\n\t\t\t\t`slug` varchar(255) NOT NULL,\n\t\t\t\t`name` varchar(255) NOT NULL,\n\t\t\t\t`description` text,\n\t\t\t\t`status` tinyint(1) NOT NULL default '1',\n\t\t\t\t`vote_count` smallint NOT NULL default '0',\n\t\t\t\t`vote_total` smallint NOT NULL default '0',\n\t\t\t\t`popularity` mediumint UNSIGNED NOT NULL default '0',\n\t\t\t\t`embed_service` char(32) default null,\n\t\t\t\t`embed_status` tinyint(1) default '0',\n\t\t\t\t`embed_data` text,\n\t\t\t\t`date_created` datetime NOT NULL,\n\t\t\t\t`date_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`id`),\n\t\t\tUNIQUE `cloud_id` (`cloud_id`),\n\t\t\tKEY `user_id` (`user_id`),\n\t\t\tKEY `category_id` (`category_id`),\n\t\t\tKEY `url_hash` (`url_hash`),\n\t\t\tKEY `slug` (`slug`),\n\t\t\tKEY `name` (`name`(20)),\n\t\t\tKEY `status` (`status`),\n\t\t\tKEY `vote_count` (`vote_count`),\n\t\t\tKEY `vote_total` (`vote_total`),\n\t\t\tKEY `popularity` (`popularity`),\n\t\t\tKEY `date_created` (`date_created`),\n\t\t\tKEY `date_updated` (`date_updated`)\n\t\t\t) {$charset_collate};";
    $sql[] = "CREATE TABLE `{$bp->links->table_name_categories}` (\n\t\t\t\t`id` tinyint(4) NOT NULL auto_increment,\n\t\t\t\t`slug` varchar(50) NOT NULL,\n\t\t\t\t`name` varchar(50) NOT NULL,\n\t\t\t\t`description` varchar(255) default NULL,\n\t\t\t\t`priority` smallint NOT NULL,\n\t\t\t\t`date_created` datetime NOT NULL,\n\t\t\t\t`date_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`id`),\n\t\t\tKEY `slug` (`slug`),\n\t\t\tKEY `priority` (`priority`)\n\t\t\t) {$charset_collate};";
    // if initial install, add default categories
    if (empty($db_version)) {
        $sql[] = "INSERT INTO `{$bp->links->table_name_categories}`\n\t\t\t\t\t( slug, name, description, priority, date_created )\n\t\t\t\t\tVALUES  ( 'news', 'News', NULL, 10, NOW() ),\n\t\t\t\t\t\t\t( 'humor', 'Humor', NULL, 20, NOW() ),\n\t\t\t\t\t\t\t( 'other', 'Other', NULL, 30, NOW() );";
    }
    $sql[] = "CREATE TABLE `{$bp->links->table_name_votes}` (\n\t\t\t\t`link_id` bigint unsigned NOT NULL,\n\t\t\t\t`user_id` bigint unsigned NOT NULL,\n\t\t\t\t`vote` tinyint(1) NOT NULL,\n\t\t\t\t`date_created` datetime NOT NULL,\n\t\t\t\t`date_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`user_id`,`link_id`),\n\t\t\tKEY `link_id` (`link_id`),\n\t\t\tKEY `date_created` (`date_created`)\n\t\t\t) {$charset_collate};";
    $sql[] = "CREATE TABLE `{$bp->links->table_name_linkmeta}` (\n\t\t\t\t`id` bigint NOT NULL auto_increment,\n\t\t\t\t`link_id` bigint unsigned NOT NULL,\n\t\t\t\t`meta_key` varchar(255) default NULL,\n\t\t\t\t`meta_value` longtext,\n\t\t\tPRIMARY KEY  (`id`),\n\t\t\tKEY `meta_key` (`meta_key`),\n\t\t\tKEY `link_id` (`link_id`)\n\t\t\t) {$charset_collate};";
    require_once ABSPATH . 'wp-admin/upgrade-functions.php';
    dbDelta($sql);
    // get a db version?
    if ($db_version) {
        // upgrades!
        bp_links_upgrade_04($db_version);
        bp_links_upgrade_08($db_version);
        bp_links_upgrade_082($db_version);
    }
    // update db version to current
    update_site_option('bp-links-db-version', BP_LINKS_DB_VERSION);
}
예제 #10
0
파일: setup.php 프로젝트: Garth619/Femi9
 /**
  * Execute module upgrade
  *
  * @return void
  */
 public function execute_upgrade($itsec_old_version)
 {
     if ($itsec_old_version < 4000) {
         global $itsec_bwps_options;
         $current_options = get_site_option('itsec_brute_force');
         // Don't do anything if settings haven't already been set, defaults exist in the module system and we prefer to use those
         if (false !== $current_options) {
             $current_options['enabled'] = isset($itsec_bwps_options['ll_enabled']) && $itsec_bwps_options['ll_enabled'] == 1 ? true : false;
             $current_options['max_attempts_host'] = isset($itsec_bwps_options['ll_maxattemptshost']) ? intval($itsec_bwps_options['ll_maxattemptshost']) : 5;
             $current_options['max_attempts_user'] = isset($itsec_bwps_options['ll_maxattemptsuser']) ? intval($itsec_bwps_options['ll_maxattemptsuser']) : 10;
             $current_options['check_period'] = isset($itsec_bwps_options['ll_checkinterval']) ? intval($itsec_bwps_options['ll_checkinterval']) : 5;
             update_site_option('itsec_brute_force', $current_options);
         }
     }
     if ($itsec_old_version < 4041) {
         $current_options = get_site_option('itsec_brute_force');
         // If there are no current options, go with the new defaults by not saving anything
         if (is_array($current_options)) {
             // Make sure the new module is properly activated or deactivated
             if ($current_options['enabled']) {
                 ITSEC_Modules::activate('brute-force');
             } else {
                 ITSEC_Modules::deactivate('brute-force');
             }
             // remove 'enabled' which isn't use in the new module
             unset($current_options['enabled']);
             ITSEC_Modules::set_settings('brute-force', $current_options);
         }
     }
 }
 function save()
 {
     global $wpdb;
     $defaults = array('ID' => null, 'blog_id' => is_network_admin() ? 0 : get_current_blog_id(), 'author' => wp_get_current_user()->ID, 'summary' => null, 'visibility' => 'inactive', 'type' => 'notfication_rule', 'created' => current_time('mysql', 1));
     $data = $this->to_array();
     $record = array_intersect_key($data, $defaults);
     if ($this->exists()) {
         $before = new WP_Stream_Notification_Rule($this->ID);
         // update `created` to current date if needed
         if ($before->visibility === 'inactive' || $this->visibility === 'inactive') {
             $record['created'] = $defaults['created'];
         }
         $result = $wpdb->update($wpdb->stream, $record, array('ID' => $this->ID));
         // cache ok, db call ok
         $success = false !== $result;
     } else {
         if (!$record['created']) {
             unset($record['created']);
         }
         $record = wp_parse_args($record, $defaults);
         $result = $wpdb->insert($wpdb->stream, $record);
         // cache ok, db call ok
         $success = is_int($result);
         if ($success) {
             $this->ID = $wpdb->insert_id;
             // cache ok, db call ok
         }
     }
     if ($this->ID) {
         $meta_keys = array('triggers', 'groups', 'alerts');
         $meta = array_intersect_key($data, array_flip($meta_keys));
         update_site_option('stream_notifications_' . $this->ID, $meta);
     }
     return $success;
 }
예제 #12
0
/**
 * Activate the plugin
 */
function activate_leadin($network_wide)
{
    // Check activation on entire network or one blog
    if (is_multisite() && $network_wide) {
        global $wpdb;
        // Get this so we can switch back to it later
        $current_blog = $wpdb->blogid;
        // For storing the list of activated blogs
        $activated = array();
        // Get all blogs in the network and activate plugin on each one
        $q = "SELECT blog_id FROM {$wpdb->blogs}";
        $blog_ids = $wpdb->get_col($q);
        foreach ($blog_ids as $blog_id) {
            switch_to_blog($blog_id);
            add_leadin_defaults();
            $activated[] = $blog_id;
        }
        // Switch back to the current blog
        switch_to_blog($current_blog);
        // Store the array for a later function
        update_site_option('leadin_activated', $activated);
    } else {
        add_leadin_defaults();
    }
}
 function licence_deactivation_check()
 {
     if (!$this->licence_key_verify() || $this->is_local_instance() === TRUE) {
         return;
     }
     $license_data = get_site_option('apto_license');
     if (isset($license_data['last_check'])) {
         if (time() < $license_data['last_check'] + 86400) {
             return;
         }
     }
     $license_key = $license_data['kye'];
     $args = array('sl_action' => 'status-check', 'licence_key' => $license_key, 'product_id' => APTO_PRODUCT_ID, 'secret_key' => APTO_SECRET_KEY, 'sl_instance' => APTO_INSTANCE);
     $request_uri = APTO_APP_API_URL . '?' . http_build_query($args, '', '&');
     $data = wp_remote_get($request_uri);
     if (is_wp_error($data) || $data['response']['code'] != 200) {
         return;
     }
     $data_body = json_decode($data['body']);
     if (isset($data_body->status)) {
         if ($data_body->status == 'success') {
             if ($data_body->status_code == 's203' || $data_body->status_code == 's204') {
                 $license_data['kye'] = '';
             }
         }
         if ($data_body->status == 'error') {
             $license_data['kye'] = '';
         }
     }
     $license_data['last_check'] = time();
     update_site_option('apto_license', $license_data);
 }
예제 #14
0
 public static function zws_filter_install()
 {
     // set up options array
     self::$new_stored_options = array('zws_api_consumer_plugin_table_name' => self::$table_name_no_prefix, 'zws_api_consumer_memcached_active' => self::$use_memcached, 'zws_api_consumer_memcached_period' => self::$memcached_period, 'zws_api_consumer_memcached_ip' => self::$default_memcached_IP, 'zws_api_consumer_memcached_port' => self::$default_memcached_port, 'zws_api_consumer_api_base_url' => self::$default_api_base_url, 'zws_api_consumer_api_path' => self::$default_api_url_path, 'zws_api_consumer_proto' => self::$default_proto, 'zws_api_consumer_plugin_db_version' => self::$db_version, 'zws_api_consumer_use_oauth' => self::$default_use_oath, 'zws_api_consumer_oauth_consumer_key' => '', 'zws_api_consumer_oauth_consumer_secret' => '', 'zws_api_consumer_oauth_token' => '', 'zws_api_consumer_oauth_token_secret' => '', 'zws_api_consumer_content_display_module' => self::$default_display_module);
     // set options array if does not exist
     if (!get_site_option(self::$plugin_options_name)) {
         add_site_option(self::$plugin_options_name, self::$new_stored_options);
     } else {
         // update array with new key/values if do not exist
         self::$existing_stored_options = get_site_option(self::$plugin_options_name);
         foreach (self::$new_stored_options as $new_key => $new_value) {
             // if option and/or option value does not exist ...
             if (!self::check_exists($new_key)) {
                 // update existing options with the non-existent new key/value
                 self::$existing_stored_options[$new_key] = $new_value;
             }
         }
         // update the options with the newly updated existing_stored_options array
         update_site_option(self::$plugin_options_name, self::$existing_stored_options);
     }
     /* Uncomment below to initiate a database upon first install. Configure table in db.php.
      *         
      * require_once(__DIR__ . '/db.php');  
      * ZwsApiConsumerDatabaseAdmin::update_database();
      * 
      */
 }
 /**
  * Check some thinks on plugin activation
  *
  * @since   0.0.1
  * @access  public
  * @static
  * @return  void
  */
 public static function on_activate()
 {
     // check WordPress version
     if (!version_compare($GLOBALS['wp_version'], '4.0', '>=')) {
         deactivate_plugins(RW_Distributed_Profile_Server::$plugin_filename);
         die(wp_sprintf('<strong>%s:</strong> ' . __('This plugin requires WordPress 4.0 or newer to work', RW_Site_Config::get_textdomain()), RW_Site_Config::get_plugin_data('Name')));
     }
     // check php version
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         deactivate_plugins(RW_Site_Config::$plugin_filename);
         die(wp_sprintf('<strong>%1s:</strong> ' . __('This plugin requires PHP 5.3 or newer to work. Your current PHP version is %1s, please update.', RW_Site_Config::get_textdomain()), RW_Site_Config::get_plugin_data('Name'), PHP_VERSION));
     }
     if (defined('RW_SITE_CONFIG_PLUGINS_CONFIG')) {
         if (false === get_site_option('rw_site_config_plugins')) {
             $plugins = unserialize(RW_SITE_CONFIG_PLUGINS_CONFIG);
             update_site_option('rw_site_config_plugins', $plugins);
         }
     }
     if (defined('RW_SITE_CONFIG_OPTIONS_CONFIG')) {
         if (false === get_site_option('rw_site_config_options')) {
             $options = unserialize(RW_SITE_CONFIG_OPTIONS_CONFIG);
             update_site_option('rw_site_config_options', $options);
         }
     }
 }
예제 #16
0
/**
 * Registers a plugin function to be run when the plugin is activated.
 */
function sr_activate()
{
    global $wpdb, $blog_id;
    if (false === get_site_option('sr_is_auto_refresh')) {
        update_site_option('sr_is_auto_refresh', 'no');
        update_site_option('sr_what_to_refresh', 'all');
        update_site_option('sr_refresh_duration', '5');
    }
    if (is_multisite()) {
        $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}", 0);
    } else {
        $blog_ids = array($blog_id);
    }
    foreach ($blog_ids as $blog_id) {
        if (file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php') && is_plugin_active('woocommerce/woocommerce.php')) {
            $wpdb_obj = clone $wpdb;
            $wpdb->blogid = $blog_id;
            $wpdb->set_prefix($wpdb->base_prefix);
            $create_table_order_items_query = "\n\t\t\t\tCREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sr_woo_order_items` (\n\t\t\t\t  `product_id` bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t  `order_id` bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t  `order_date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t\t\t  `order_status` text NOT NULL,\n\t\t\t\t  `product_name` text NOT NULL,\n\t\t\t\t  `sku` text NOT NULL,\n\t\t\t\t  `category` text NOT NULL,\n\t\t\t\t  `quantity` int(10) unsigned NOT NULL default '0',\n\t\t\t\t  `sales` decimal(11,2) NOT NULL default '0.00',\n\t\t\t\t  `discount` decimal(11,2) NOT NULL default '0.00',\n\t\t\t\t  KEY `product_id` (`product_id`),\n\t\t\t\t  KEY `order_id` (`order_id`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8;\n\t\t\t";
            $create_table_abandoned_items_query = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}sr_woo_abandoned_items` (\n\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `user_id` bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t  `product_id` bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t  `quantity` int(10) unsigned NOT NULL default '0',\n\t\t\t\t  `cart_id` bigint(20),\n\t\t\t\t  `abandoned_cart_time` int(11) unsigned NOT NULL,\n\t\t\t\t  `product_abandoned` int(1) unsigned NOT NULL default '0',\n\t\t\t\t  `order_id` bigint(20),\n\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t  KEY `product_id` (`product_id`),\n\t\t\t\t  KEY `user_id` (`user_id`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
            dbDelta($create_table_order_items_query);
            dbDelta($create_table_abandoned_items_query);
            add_action('load_sr_woo_order_items', 'load_sr_woo_order_items');
            do_action('load_sr_woo_order_items', $wpdb);
            $wpdb = clone $wpdb_obj;
        }
    }
}
예제 #17
0
 function activate_wpts()
 {
     global $default_tab_settings, $wpts_db_version;
     $installed_ver = get_site_option('wpts_db_version');
     if ($installed_ver != $wpts_db_version) {
         $wpts_opts1 = get_option('wpts_options');
         $speed = isset($wpts_opts1['speed']) ? $wpts_opts1['speed'] : '';
         if (isset($wpts_opts1) and $speed == '1') {
             $pages = $wpts_opts1['pages'];
             $posts = $wpts_opts1['posts'];
             if (empty($pages) or !isset($pages)) {
                 $wpts_opts1['pages'] = '0';
             }
             if (empty($posts) or !isset($posts)) {
                 $wpts_opts1['posts'] = '0';
             }
         }
         $wpts_opts2 = $default_tab_settings;
         if ($wpts_opts1) {
             $wpts = $wpts_opts1 + $wpts_opts2;
             update_option('wpts_options', $wpts);
         } else {
             $wpts_opts1 = array();
             $wpts = $wpts_opts1 + $wpts_opts2;
             add_option('wpts_options', $wpts);
         }
         update_site_option('wpts_db_version', $wpts_db_version);
     }
 }
예제 #18
0
 private function install()
 {
     global $wpdb;
     $sql = array();
     $charset_collate = '';
     //check if tables exist,
     //just update one table in that case
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     /* BuddyPress component DB schema */
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     $bp_prefix = bp_core_get_table_prefix();
     $bp_chat = bp_chat();
     //install
     $sql_table_exists_check = "SHOW TABLES LIKE '" . $bp_prefix . "_bp_chat_%'";
     if ($wpdb->get_col($sql_table_exists_check)) {
         ////just update the user table
         $sql[] = "ALTER TABLE {$bp_chat->table_name_users} MODIFY last_active_time DATETIME ";
     } else {
         //if tables do not exist
         $sql[] = "CREATE TABLE {$bp_chat->table_name_users} (\r\n\t\t\t\t\t\tuser_id bigint(20) NOT NULL,\r\n\t\t\t\t\t\tis_online tinyint(4) NOT NULL,\r\n\t\t\t\t\t\tlast_active_time datetime NOT NULL,\r\n\t\t\t\t\t\tstatus_message varchar(255) NOT NULL,\r\n\t\t\t\t\t\tlast_fetch_time datetime NOT NULL ,\r\n\t\t\t\t\t\tfriends_only tinyint(1) NOT NULL DEFAULT '0',\r\n\t\t\t\t\t\tPRIMARY KEY (user_id)\r\n\t\t\t\t\t  ) {$charset_collate};";
         $sql[] = "CREATE TABLE {$bp_chat->table_name_channels} (\r\n\t\t\t\t\t\tid bigint(20) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t\tlast_message_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n\t\t\t\t\t\ttime_created datetime NOT NULL,\r\n\t\t\t\t\t\tstatus tinyint(3) unsigned NOT NULL,\r\n\t\t\t\t\t\tis_multichat tinyint(3) NOT NULL,\r\n\t\t\t\t\t\tis_open tinyint(4) NOT NULL,\r\n\t\t\t\t\t\tPRIMARY KEY (id)\r\n\t\t\t\t\t ) {$charset_collate};";
         $sql[] = "CREATE TABLE {$bp_chat->table_name_channel_users} (\r\n\t\t\t\t\t\tchannel_id bigint(20) NOT NULL,\r\n\t\t\t\t\t\tuser_id bigint(20) NOT NULL,\r\n\t\t\t\t\t\tstatus varchar(32) NOT NULL,\r\n\t\t\t\t\t\thas_initiated tinyint(4) NOT NULL,\r\n\t\t\t\t\t\tKEY channel_id (channel_id,user_id)\r\n\t\t\t\t   ) {$charset_collate};";
         //meta data
         $sql[] = "CREATE TABLE {$bp_chat->table_name_messages} (\r\n\t\t\t\t\t\t\tid bigint(20) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t\t\tsender_id bigint(20) NOT NULL,\r\n\t\t\t\t\t\t\tchannel_id bigint(20) NOT NULL,\r\n\t\t\t\t\t\t\tmessage text NOT NULL,\r\n\t\t\t\t\t\t\tsent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n\t\t\t\t\t\t\tPRIMARY KEY (id),\r\n\t\t\t\t\t\t\tKEY channel_id (channel_id)\r\n\t\t\t\t\t ) {$charset_collate};";
     }
     //execute sql
     dbDelta($sql);
     update_site_option('bp-chat-db-version', BP_CHAT_DB_VERSION);
 }
/**
 * Get admin bar items from frontend view.
 *
 * @since 2015-07-03
 * @return null
 */
function _mw_adminimize_get_admin_bar_frontend_nodes()
{
    if (is_admin()) {
        return NULL;
    }
    global $wp_admin_bar;
    // @see: http://codex.wordpress.org/Function_Reference/get_nodes
    $all_toolbar_nodes = $wp_admin_bar->get_nodes();
    if ($all_toolbar_nodes) {
        // get all options
        if (is_multisite() && is_plugin_active_for_network(MW_ADMIN_FILE)) {
            $adminimizeoptions = get_site_option('mw_adminimize');
        } else {
            $adminimizeoptions = get_option('mw_adminimize');
        }
        // add admin bar array
        $adminimizeoptions['mw_adminimize_admin_bar_frontend_nodes'] = $all_toolbar_nodes;
        // update options
        if (is_multisite() && is_plugin_active_for_network(MW_ADMIN_FILE)) {
            update_site_option('mw_adminimize', $adminimizeoptions);
        } else {
            update_option('mw_adminimize', $adminimizeoptions);
        }
    }
}
 public static function install()
 {
     // set up options array
     $new_stored_options = array('zws_contacts_database_plugin_table_name' => self::TABLE_NAME_NO_PREFIX, 'zws_contacts_database_memcached_active' => self::USE_MEMCACHED, 'zws_contacts_database_memcached_period' => self::MEMCACHED_PERIOD, 'zws_contacts_database_memcached_ip' => self::DEFAULT_MEMCACHED_IP, 'zws_contacts_database_memcached_port' => self::DEFAULT_MEMCACHED_PORT, 'zws_contacts_database_plugin_db_version' => self::DB_VERSION, 'zws_contacts_database_plugin_privacy_policy_url' => self::DEFAULT_PRIVACY_POLICY_URL, 'zws_contacts_database_google_server_api_key' => self::DEFAULT_GOOGLE_SERVER_API_KEY, 'zws_contacts_database_plugin_map_contact_icon_url' => self::DEFAULT_MAP_CONTACT_ICON, 'zws_contacts_database_plugin_map_target_icon_url' => self::DEFAULT_MAP_TARGET_ICON, 'zws_contacts_database_plugin_map_base_icon_url' => self::DEFAULT_MAP_BASE_ICON, 'zws_contacts_database_plugin_memcached_keybase' => self::MEMCACHED_KEY_BASE . '_' . rand(), 'zws_contacts_database_plugin_google_map_zoom' => self::GOOGLE_MAP_ZOOM, 'zws_contacts_database_plugin_base_name' => '', 'zws_contacts_database_plugin_base_postcode' => '', 'zws_contacts_database_plugin_base_coordinates' => array(), 'zws_contacts_database_plugin_admin_email_active' => self::ADMIN_EMAIL_ACTIVE, 'zws_contacts_database_plugin_admin_email' => array(), 'zws_contacts_database_plugin_reg_email_active' => self::REG_EMAIL_ACTIVE, 'zws_contacts_database_plugin_reg_email_from' => array(get_site_option('blogname'), get_site_option('admin_email')), 'zws_contacts_database_plugin_reg_email_subject' => self::REG_EMAIL_SUBJECT, 'zws_contacts_database_plugin_country_of_use' => self::COUNTRY_CODE);
     // set options array if does not exist
     if (!get_site_option(self::OPTIONS_LABEL)) {
         add_site_option(self::OPTIONS_LABEL, $new_stored_options);
     } else {
         // update array with new key/values if do not exist
         self::$existing_stored_options = get_site_option(self::OPTIONS_LABEL);
         foreach ($new_stored_options as $new_key => $new_value) {
             // if option and/or option value does not exist ...
             if (!self::check_exists($new_key)) {
                 // update existing options with the non-existent new key/value
                 self::$existing_stored_options[$new_key] = $new_value;
             }
         }
         // update the options with the newly updated existing_stored_options array
         update_site_option(self::OPTIONS_LABEL, self::$existing_stored_options);
     }
     // the special option for removal of data on uninstall
     if (!get_site_option('zws_contact_database_remove_data')) {
         add_site_option('zws_contacts_database_remove_data', self::DEFAULT_FULL_REMOVAL);
     }
     // create or update the database
     require_once __DIR__ . '/Database.php';
     \ZwsContactsDatabase\Database::update_database();
     // return true when successful
     return True;
 }
예제 #21
0
/**
 * xprofile_install()
 *
 * Set up the database tables needed for the xprofile component.
 * 
 * @package BuddyPress XProfile
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses dbDelta() Takes SQL statements and compares them to any existing tables and creates/updates them.
 * @uses add_site_option() adds a value for a meta_key into the wp_sitemeta table
 */
function xprofile_install()
{
    global $bp, $wpdb;
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    if ('' == get_site_option('bp-xprofile-base-group-name')) {
        update_site_option('bp-xprofile-base-group-name', 'Base');
    }
    if ('' == get_site_option('bp-xprofile-fullname-field-name')) {
        update_site_option('bp-xprofile-fullname-field-name', 'Name');
    }
    $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} (\n\t\t\t  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t  name varchar(150) NOT NULL,\n\t\t\t  description mediumtext NOT NULL,\n\t\t\t  can_delete tinyint(1) NOT NULL,\n\t\t\t  KEY can_delete (can_delete)\n\t) {$charset_collate};";
    $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} (\n\t\t\t  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t  group_id bigint(20) unsigned NOT NULL,\n\t\t\t  parent_id bigint(20) unsigned NOT NULL,\n\t\t\t  type varchar(150) NOT NULL,\n\t\t\t  name varchar(150) NOT NULL,\n\t\t\t  description longtext NOT NULL,\n\t\t\t  is_required tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t  is_default_option tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t  field_order bigint(20) NOT NULL DEFAULT '0',\n\t\t\t  option_order bigint(20) NOT NULL DEFAULT '0',\n\t\t\t  order_by varchar(15) NOT NULL,\n\t\t\t  is_public int(2) NOT NULL DEFAULT '1',\n\t\t\t  can_delete tinyint(1) NOT NULL DEFAULT '1',\n\t\t\t  KEY group_id (group_id),\n\t\t\t  KEY parent_id (parent_id),\n\t\t\t  KEY is_public (is_public),\n\t\t\t  KEY can_delete (can_delete),\n\t\t\t  KEY is_required (is_required)\n\t) {$charset_collate};";
    $sql[] = "CREATE TABLE {$bp->profile->table_name_data} (\n\t\t\t  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t  field_id bigint(20) unsigned NOT NULL,\n\t\t\t  user_id bigint(20) unsigned NOT NULL,\n\t\t\t  value longtext NOT NULL,\n\t\t\t  last_updated datetime NOT NULL,\n\t\t\t  KEY field_id (field_id),\n\t\t\t  KEY user_id (user_id)\n\t) {$charset_collate};";
    if ('' == get_site_option('bp-xprofile-db-version')) {
        $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option('bp-xprofile-base-group-name') . "', '', 0 );";
        $sql[] = "INSERT INTO {$bp->profile->table_name_fields} ( \n\t\t\t\t\tid, group_id, parent_id, type, name, description, is_required, field_order, option_order, order_by, is_public, can_delete\n\t\t\t\t  ) VALUES (\n\t\t\t\t\t1, 1, 0, 'textbox', '" . get_site_option('bp-xprofile-fullname-field-name') . "', '', 1, 1, 0, '', 1, 0\n\t\t\t\t  );";
    }
    require_once ABSPATH . 'wp-admin/upgrade-functions.php';
    dbDelta($sql);
    if (function_exists('bp_wire_install')) {
        xprofile_wire_install();
    }
    update_site_option('bp-xprofile-db-version', BP_XPROFILE_DB_VERSION);
}
예제 #22
0
function googlefontmgr_check_api_key($google_api_key)
{
    global $is_networkactive;
    $message = "";
    $api_url = "https://www.googleapis.com/webfonts/v1/webfonts?key=";
    $api_data = wp_remote_get($api_url . $google_api_key);
    //return codes if valid or not
    if (200 === $api_data['response']['code']) {
        if ($is_networkactive) {
            update_site_option('wp_googlefontmgr_globalkey', $google_api_key);
        } else {
            update_option('wp_googlefontmgr_apikey', $google_api_key);
        }
        echo "<div class='updated message'><p><strong>Success!</strong> Valid Google API Key...</p></div>";
        return true;
    } else {
        $body = json_decode($api_data['body'], true);
        $response = $api_data['response'];
        $headers = $api_data['headers'];
        foreach ($body['error']['errors'] as $error) {
            if ("keyInvalid" == $error['reason']) {
                $message = "<div class='error message'><p><strong>ERROR:</strong> Invalid Google API Key</p></div>";
            }
        }
        if ($message) {
            delete_site_option('wp_googlefontmgr_apikey');
            delete_option('wp_googlefontmgr_apikey');
            echo $message;
            return false;
        }
    }
}
예제 #23
0
 private function the_data()
 {
     $usage = get_site_option('wpe_upload_space_usage');
     $ttl = get_site_option('wpe_upload_space_usage_ttl');
     // If TTL is more then interval from now, it's bogus, so kill it.
     if ($ttl > time() + self::CACHE_TTL) {
         $ttl = false;
     }
     // If have from cache and it's within TTL, then do nothing else.
     // If TTL has not expired, leave
     if ($ttl && $ttl >= time()) {
         return $usage;
     }
     // Get the value and save it in the cache
     $usage_remote = $this->from_remote();
     $expire = time() + self::CACHE_TTL;
     // If did not have an initial value
     if (false === $usage) {
         add_site_option('wpe_upload_space_usage', $usage_remote);
         add_site_option('wpe_upload_space_usage_ttl', $expire);
     } else {
         update_site_option('wpe_upload_space_usage', $usage_remote);
         update_site_option('wpe_upload_space_usage_ttl', $expire);
     }
     return $usage_remote;
 }
function onp_updates_324_set_site_transient($transient, $value, $expiration = 0, $actions = false)
{
    global $_wp_using_ext_object_cache;
    if ($actions) {
        $value = apply_filters('pre_set_site_transient_' . $transient, $value);
    }
    if ($_wp_using_ext_object_cache) {
        $result = wp_cache_set($transient, $value, 'site-transient', $expiration);
    } else {
        $transient_timeout = '_site_transient_timeout_' . $transient;
        $transient = '_site_transient_' . $transient;
        if (false === get_site_option($transient)) {
            if ($expiration) {
                add_site_option($transient_timeout, time() + $expiration);
            }
            $result = add_site_option($transient, $value);
        } else {
            if ($expiration) {
                update_site_option($transient_timeout, time() + $expiration);
            }
            delete_site_option($transient);
            $result = update_site_option($transient, $value);
        }
    }
    if ($result && $actions) {
        do_action('set_site_transient_' . $transient);
        do_action('setted_site_transient', $transient);
    }
    return $result;
}
	public function test_should_fail_for_emails_from_non_whitelisted_domains() {
		$domains = array( 'foo.com', 'bar.org' );
		update_site_option( 'limited_email_domains', $domains );

		$v = wpmu_validate_user_signup( 'foo123', '*****@*****.**' );
		$this->assertContains( 'user_email', $v['errors']->get_error_codes() );
	}
 public function updateOption($aOptions = null)
 {
     if ($this->_bDisableSavingOptions) {
         return;
     }
     return update_site_option($this->sOptionKey, $aOptions !== null ? $aOptions : $this->aOptions);
 }
 /**
  * Called on plugin activation and checks to see if the correct 
  * WordPress version is installed and multisite is supported. If 
  * all checks are passed the install method is called.
  *
  * @since 1.0
  * @return void
  */
 public static function activate()
 {
     global $wp_version;
     // Check for WordPress 3.5 and above.
     if (version_compare($wp_version, '3.5', '>=')) {
         // Check for multisite.
         if (is_multisite()) {
             // Init multisite support.
             self::init_classes();
             self::init_multisite();
             // This version has multisite support.
             if (class_exists('FLBuilderMultisite')) {
                 if (is_network_admin()) {
                     FLBuilderMultisite::install();
                 } else {
                     self::install();
                 }
             } else {
                 $url = FLBuilderModel::get_upgrade_url(array('utm_source' => 'external', 'utm_medium' => 'builder', 'utm_campaign' => 'no-multisite-support'));
                 self::show_activate_error(sprintf(__('This version of the <strong>Page Builder</strong> plugin is not compatible with WordPress Multisite. <a%s>Please upgrade</a> to the Multisite version of this plugin.', 'fl-builder'), ' href="' . $url . '" target="_blank"'));
             }
         } else {
             self::install();
         }
     } else {
         self::show_activate_error(__('The <strong>Page Builder</strong> plugin requires WordPress version 3.5 or greater. Please update WordPress before activating the plugin.', 'fl-builder'));
     }
     // Success! Trigger the activation notice.
     if (FL_BUILDER_LITE !== true) {
         update_site_option('_fl_builder_activation_admin_notice', true);
     }
 }
 /** 
  * Checks to see if an update should be run. If it should,
  * the appropriate update method is run and the version
  * number is updated in the database.
  *
  * @since 1.2.8
  * @return void
  */
 public static function init()
 {
     // Make sure the user is logged in.
     if (!is_user_logged_in()) {
         return;
     }
     // Don't update for dev copies.
     if (FL_BUILDER_VERSION == '{FL_BUILDER_VERSION}') {
         return;
     }
     // Get the saved version.
     $saved_version = get_site_option('_fl_builder_version');
     // No saved version number. This must be a fresh install.
     if (!$saved_version) {
         update_site_option('_fl_builder_version', FL_BUILDER_VERSION);
         return;
     } else {
         if (!version_compare($saved_version, FL_BUILDER_VERSION, '=')) {
             if (is_multisite()) {
                 self::run_multisite($saved_version);
             } else {
                 self::run($saved_version);
             }
             update_site_option('_fl_builder_version', FL_BUILDER_VERSION);
         }
     }
 }
/**
 * This function used to install required tables in the database on time of activation.
 * @author Flipper Code <*****@*****.**>
 * @version 1.0.0
 * @package Maps
 */
function wpgmp_network_propagate($network_wide)
{
    if (is_multisite() && $network_wide) {
        // See if being activated on the entire network or one blog
        global $wpdb;
        // Get this so we can switch back to it later
        $currentblog = $wpdb->blogid;
        // For storing the list of activated blogs
        $activated = array();
        // Get all blogs in the network and activate plugin on each one
        $sql = "SELECT blog_id FROM {$wpdb->blogs}";
        $blog_ids = $wpdb->get_col($wpdb->prepare($sql, null));
        foreach ($blog_ids as $blog_id) {
            switch_to_blog($blog_id);
            wpgmp_activation();
        }
        // Switch back to the current blog
        switch_to_blog($currentblog);
        // Store the array for a later function
        update_site_option('wpgmp_activated', $activated);
    } else {
        // Running on a single blog
        wpgmp_activation();
    }
}
예제 #30
0
 public static function install($force = false)
 {
     $db_version = 1.2;
     // this is the version of the database we're moving to
     $old_db_version = get_site_option('frmpro_copies_db_version');
     global $wpdb;
     if ($db_version != $old_db_version || $force) {
         $force = true;
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         $frmdb = new FrmDb();
         $charset_collate = $frmdb->collation();
         /* Create/Upgrade Display Table */
         $sql = 'CREATE TABLE ' . self::table_name() . ' (
                 id int(11) NOT NULL auto_increment,
                 type varchar(255) default NULL,
                 copy_key varchar(255) default NULL,
                 form_id int(11) default NULL,
                 blog_id int(11) default NULL,
                 created_at datetime NOT NULL,
                 PRIMARY KEY id (id),
                 KEY form_id (form_id),
                 KEY blog_id (blog_id)
         ) ' . $charset_collate . ';';
         dbDelta($sql);
         update_site_option('frmpro_copies_db_version', $db_version);
     }
     self::copy_forms($force);
 }