text:
<?php

if ( ! class_exists( 'bwps_admin_process' ) ) {

	class bwps_admin_process extends bwps_admin_common {

		function __construct() {

			if (isset( $_POST['bwps_page']) ) {
				add_action( 'admin_init', array( &$this, 'form_dispatcher' ) );
			}

		}

		/**
		 * Form dispacther
		 *
		 * Executes appropriate process function based on post variable
		 *
		 **/
		function form_dispatcher() {
			//verify nonce
			if ( ! wp_verify_nonce( $_POST['wp_nonce'], 'BWPS_admin_save' ) ) {
				die( 'Security error!' );
			}

			switch ( $_POST['bwps_page'] ) {
				case 'adminuser_1':
					$this->adminuser_process_1();
					break;
				case 'adminuser_2':
					$this->adminuser_process_2();
					break;
				case 'awaymode_1':
					$this->awaymode_process_1();
					break;
				case 'banusers_1':
					$this->banusers_process_1();
					break;
				case 'banusers_2':
					$this->banusers_process_2();
					break;
				case 'contentdirectory_1':
					$this->contentdirectory_process_1();
					break;
				case 'dashboard_1':
					$this->dashboard_process_1();
					break;
				case 'dashboard_2':
					$this->dashboard_process_2();
					break;
				case 'dashboard_3':
					$this->dashboard_process_3();
					break;
				case 'dashboard_4':
					$this->dashboard_process_4();
					break;
				case 'dashboard_5':
					$this->dashboard_process_5();
					break;
				case 'databasebackup_1':
					$this->databasebackup_process_1();
					break;
				case 'databasebackup_2':
					$this->databasebackup_process_2();
					break;
				case 'databaseprefix_1':
					$this->databaseprefix_process_1();
					break;
				case 'hidebackend_1':
					$this->hidebackend_process_1();
					break;
				case 'intrusiondetection_1':
					$this->intrusiondetection_process_1();
					break;
				case 'intrusiondetection_2':
					$this->intrusiondetection_process_2();
					break;
				case 'loginlimits_1':
					$this->loginlimits_process_1();
					break;
				case 'log_1':
					$this->log_process_1();
					break;
				case 'log_2':
					$this->log_process_2();
					break;
				case 'ssl_1':
					$this->ssl_process_1();
					break;
				case 'systemtweaks_1':
					$this->systemtweaks_process_1();
					break;
			}
		}

		/**
		 * Process dashboard initial site backup
		 *
		 **/
		function dashboard_process_1() {

			global $bwps, $wpdb, $bwps_backup, $bwpsoptions;

			$errorHandler = __( 'Database Backup Completed.', $this->hook );

			$bwpsoptions['backup_last'] = current_time( 'timestamp' );
			$bwpsoptions['initial_backup'] = 1;

			update_option( $this->primarysettings, $bwpsoptions );

			//execute backup
			$bwps_backup->execute_backup();

			$bwps->clearcache( true );
			$this->showmessages( $errorHandler );

		}

		/**
		 * Process dashboard initial site backup ignore
		 *
		 **/
		function dashboard_process_2() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Database Backup Ignored.', $this->hook );

			$bwpsoptions['initial_backup'] = 1;

			update_option( $this->primarysettings, $bwpsoptions );

			$bwps->clearcache( true );
			$this->showmessages( $errorHandler );

		}

		/**
		 * Process dashboard initial file write confirm
		 *
		 **/
		function dashboard_process_3() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'WordPress Core File Writing confirmed.', $this->hook );

			$bwpsoptions['initial_filewrite'] = 1;
			$bwpsoptions['st_writefiles'] = 1;

			update_option( $this->primarysettings, $bwpsoptions );

			$this->showmessages( $errorHandler );

			$adminurl = is_multisite() ? admin_url() . 'network/' : admin_url();

			header( 'Location: ' . $adminurl . 'admin.php?page=better-wp-security' );

		}

		/**
		 * Process dashboard initial file write deny
		 *
		 **/
		function dashboard_process_4() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'WordPress Core File Writing ignored.', $this->hook );

			$bwpsoptions['initial_filewrite'] = 1;
			$bwpsoptions['st_writefiles'] = 0;

			update_option( $this->primarysettings, $bwpsoptions );

			$this->showmessages( $errorHandler );

			$adminurl = is_multisite() ? admin_url() . 'network/' : admin_url();

			header( 'Location: ' . $adminurl . 'admin.php?page=better-wp-security' );

		}

		/**
		 * Process one-click security form
		 *
		 **/
		function dashboard_process_5() {

			global $bwps, $bwpsoptions, $bwpsmemlimit;

			$errorHandler = __( 'Site Secured.', $this->hook );

			if ( $_POST['oneclick'] == 1 ) {

				//select options for one-click access (enable all sections that don't write to files or are otherwise known to cause conflicts).
				$bwpsoptions['ll_enabled'] = 1;
				$bwpsoptions['id_enabled'] = 1;
				$bwpsoptions['st_generator'] = 1;
				$bwpsoptions['st_manifest'] = 1;
				$bwpsoptions['st_themenot'] = 1;
				$bwpsoptions['st_pluginnot'] = 1;
				$bwpsoptions['st_corenot'] = 1;
				$bwpsoptions['st_enablepassword'] = 1;
				$bwpsoptions['st_loginerror'] = 1;
				$bwpsoptions['oneclickchosen'] = 1;

				update_option( $this->primarysettings, $bwpsoptions );

				$errorHandler = __( 'Settings Saved. Your website is now protected from most attacks.', $this->hook );

				$bwps->clearcache( true );

			} else {

				$bwpsoptions['oneclickchosen'] = 1;
				update_option( $this->primarysettings, $bwpsoptions );

				$errorHandler = __( 'Initial configuration complete. Use the checklist below to enable additional features.', $this->hook );

			}

			$this->showmessages( $errorHandler );

		}

		/**
		 * Process change admin user form
		 *
		 **/
		function adminuser_process_1() {

			global $bwps, $wpdb;
			$errorHandler = __( 'Successfully Changed admin Username. If you are logged in as admin you will have to log in again before continuing.', $this->hook );

			//sanitize the username
			$newuser = sanitize_text_field( $_POST['newuser'] );

			if ( strlen( $newuser ) < 1 ) { //if the field was left blank set an error message

				$errorHandler = new WP_Error();
				$errorHandler->add( '2', $newuser . __( 'You must enter a valid username. Please try again', $this->hook ) );

			} else {

				if ( validate_username( $newuser ) ) { //make sure username is valid

					if ( $this->user_exists( $newuser ) ) { //if the user already exists set an error

						if ( ! is_wp_error( $errorHandler ) ) {
							$errorHandler = new WP_Error();
						}

						$errorHandler->add( '2', $newuser . __( ' already exists. Please try again', $this->hook ) );

					} else {

						//query main user table
						$wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $newuser ) . "' WHERE user_login='admin';" );

						if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation

							$oldAdmins = $wpdb->get_var( "SELECT meta_value FROM `" . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
							$newAdmins = str_replace( '5:"admin"', strlen( $newuser ) . ':"' . esc_sql( $newuser ) . '"', $oldAdmins );
							$wpdb->query( "UPDATE `" . $wpdb->sitemeta . "` SET meta_value = '" . esc_sql( $newAdmins ) . "' WHERE meta_key = 'site_admins'" );

						}

					}

				} else {

					if ( ! is_wp_error( $errorHandler ) ) { //set an error for invalid username
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', $newuser . __( ' is not a valid username. Please try again', $this->hook ) );
				}
			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages //finally show messages

			wp_clear_auth_cookie();

		}

		/**
		 * Process change admin user id form
		 *
		 **/
		function adminuser_process_2() {

			global $bwps;

			$errorHandler = __( 'Successfully Changed user 1 ID.', $this->hook );

			if ( $this->changeuserid() === false ) {

				if ( ! is_wp_error( $errorHandler ) ) { //set an error for invalid username
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'User 1\'s ID was not changed. Please try again', $this->hook ) );

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages //finally show messages

		}

		/**
		 * Process away mode options form
		 *
		 **/
		function awaymode_process_1() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate options
			$bwpsoptions['am_enabled'] = ( isset( $_POST['am_enabled'] ) && $_POST['am_enabled'] == 1  ? 1 : 0 );

			$bwpsoptions['am_type'] = ( isset( $_POST['am_type'] ) && $_POST['am_type'] == 1  ? 1 : 0 );

			//form times
			$startDate = strtotime( $_POST['am_startmonth'] . "/" . $_POST['am_startday'] . "/" . $_POST['am_startyear'] . ' 12:01 am' );
			$endDate = strtotime( $_POST['am_endmonth'] . "/" . $_POST['am_endday'] . "/" . $_POST['am_endyear'] . ' 12:01 am' );

			if ( $bwpsoptions['am_type'] == 0 && $endDate <= $startDate ) { //can't have an ending date before a starting date

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'The ending date must be after the current date.', $this->hook ) );
			}

			$startTime = strtotime( '1/1/1970 ' . $_POST['am_starthour'] . ':' . $_POST['am_startmin'] . ' ' . $_POST['am_starthalf'] );
			$endTime = strtotime( '1/1/1970 ' . $_POST['am_endhour'] . ':' . $_POST['am_endmin'] . ' ' . $_POST['am_endhalf'] );

			if ( $bwpsoptions['am_type'] == 1 && $startTime == $endTime ) { //can't have an ending date before a starting date

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Your current settings would lock you out 24 hours a day. Please make sure start and end times differ.', $this->hook ) );
			}

			$bwpsoptions['am_startdate'] = $startDate;
			$bwpsoptions['am_enddate'] = $endDate;
			$bwpsoptions['am_starttime'] = $startTime;
			$bwpsoptions['am_endtime'] = $endTime;

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( $bwpsoptions['st_writefiles'] == 1  ) {

					$this->writewpconfig(); //save to wp-config.php

				} else {

					if ( ! is_wp_error( $errorHandler ) ) {
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add code to your wp-config.php file See the Better WP Security Dashboard for the code you will need.', $this->hook ) );

				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process options form for ban hosts page
		 *
		 **/
		function banusers_process_1() {

			global $bwps, $bwpsoptions;

			@ini_set( 'auto_detect_line_endings', true );

			$errorHandler = __( 'Settings Saved', $this->hook );

			$bwpsoptions['bu_enabled'] = ( isset( $_POST['bu_enabled'] ) && $_POST['bu_enabled'] == 1  ? 1 : 0 );

			//validate list
			$banhosts = explode( PHP_EOL, $_POST['bu_banlist'] );
			$list = array();

			if( ! empty( $banhosts ) ) {

				foreach( $banhosts as $item ) {

					$item = filter_var( $item, FILTER_SANITIZE_STRING );

					if ( strlen( $item ) > 0 ) {

						$ipParts = explode( '.', $item );
						$isIP = 0;
						$partcount = 1;
						$goodip = true;
						$foundwild = false;

						foreach ( $ipParts as $part ) {

							if ( $goodip == true ) {

								if ( ( is_numeric( trim( $part ) ) && trim( $part ) <= 255 && trim( $part ) >= 0 ) || trim( $part ) == '*' ) {
									$isIP++;
								}

								switch ( $partcount ) {

									case 1:

										if ( trim( $part ) == '*' ) {

											$goodip = false;

											if ( ! is_wp_error( $errorHandler ) ) { //invalid ip
												$errorHandler = new WP_Error();
											}

											$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is note a valid ip.', $this->hook ) );

										}

										break;

									case 2:

										if ( trim( $part ) == '*' ) {

											$foundwild = true;

										}

										break;

									default:

										if ( trim( $part ) != '*' ) {

											if ( $foundwild == true ) {

												$goodip = false;

												if ( ! is_wp_error( $errorHandler ) ) { //invalid ip
													$errorHandler = new WP_Error();
												}

												$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is note a valid ip.', $this->hook ) );

											}

										} else {

											$foundwild = true;

										}

										break;

								}

								$partcount++;

							}

						}

						if ( ip2long( trim( str_replace( '*', '0', $item ) ) ) == false ) { //invalid ip

							if ( ! is_wp_error( $errorHandler ) ) {
								$errorHandler = new WP_Error();
							}

							$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is not a valid ip.', $this->hook ) );

						} elseif ( strlen( $item > 4 && ! in_array( $item, $list ) ) ) {

							$list[] = trim( $item );

						}

					}

				}

			}

			if ( sizeof( $list ) > 1 ) {
				sort( $list );
				$list = array_unique( $list, SORT_STRING );
			}

			$bwpsoptions['bu_banlist'] = implode( PHP_EOL, $list );

			if ( $bwps->checklist( $bwpsoptions['bu_banlist'] ) ) {

				if ( ! is_wp_error( $errorHandler) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '1', __( 'You cannot ban yourself. Please try again.', $this->hook ) );

			}

			//now to process useragents
			$banagents = explode( PHP_EOL, $_POST['bu_banagent'] );
			$agents = array();

			if ( ! empty( $banagents ) ) {

				foreach ( $banagents as $agent ) {

					$text = quotemeta( sanitize_text_field( $agent ) );

					$agents[] = $text;

				}

			}

			if ( sizeof( $agents ) > 1 ) {
				sort( $agents );
				$agents = array_unique( $agents, SORT_STRING );
			}

			$bwpsoptions['bu_banagent'] = implode( PHP_EOL, $agents );

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) || strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'litespeed' ) ) && $bwpsoptions['st_writefiles'] == 1 ) { //if they're using apache write to .htaccess

					$this->writehtaccess();

					$errorHandler = __( 'Settings Saved.', $this->hook );

					define( 'BWPS_GOOD_LIST', true );

				} else { //not on apache to let them know they will have to manually enter rules

					$errorHandler = new WP_Error();

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules you will need.', $this->hook ) );

				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages
		}

		/**
		 * Process away mode options form
		 *
		 **/
		function banusers_process_2() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate options
			$bwpsoptions['bu_blacklist'] = ( isset( $_POST['bu_blacklist'] ) && $_POST['bu_blacklist'] == 1  ? 1 : 0 );

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) || strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'litespeed' ) ) && $bwpsoptions['st_writefiles'] == 1 ) { //if they're using apache write to .htaccess

					$this->writehtaccess();

					$errorHandler = __( 'Settings Saved.', $this->hook );

				} else { //not on apache to let them know they will have to manually enter rules

					$errorHandler = new WP_Error();

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules you will need.', $this->hook ) );

				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process changing of wp-content directory
		 *
		 **/
		function contentdirectory_process_1() {

			global $bwps, $wpdb, $bwpsoptions;
			$errorHandler = __( 'Settings Saved', $this->hook );

			$oldDir = WP_CONTENT_DIR;
			$newDir = trailingslashit( ABSPATH ) . sanitize_text_field( $_POST['dirname'] );

			$renamed = rename( $oldDir, $newDir );

			if ( ! $renamed ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Unable to rename the wp-content folder. Operation cancelled.', $this->hook ) );

			}

			$wpconfig = $this->getConfig(); //get the path for the config file

			if ( ! $f = @fopen( $wpconfig, 'a+' ) ) {

				@chmod( $wpconfig, 0644 );

				if ( ! $f = @fopen( $wpconfig, 'a+' ) ) {

					return -1;

				}

			}

			@fclose( $f );

			$handle = @fopen( $wpconfig, 'r+' ); //open for reading

			if ( $handle && $renamed ) {

				@ini_set( 'auto_detect_line_endings', true );

				$scanText = "<?php";
				$newText = "<?php" . PHP_EOL . PHP_EOL . "define( 'WP_CONTENT_DIR', '" . $newDir . "' );" . PHP_EOL . "define( 'WP_CONTENT_URL', '" . trailingslashit( get_option( 'siteurl' ) ) . sanitize_text_field( $_POST['dirname'] ) . "' );" . PHP_EOL . PHP_EOL;

				//read each line into an array
				while ( $lines[] = fgets( $handle, 4096 ) ) {}

				fclose( $handle ); //close reader

				$handle = @fopen( $wpconfig, 'w+' ); //open writer

				foreach ( $lines as $line ) { //process each line

					if ( strstr( $line, 'WP_CONTENT_DIR' ) || strstr( $line, 'WP_CONTENT_URL' ) ) {

						$line = str_replace( $line, '', $line );

					}

					if (strstr( $line, $scanText ) ) {

						$line = str_replace( $scanText, $newText, $line );

					}

					fwrite( $handle, $line ); //write the line

				}

				fclose( $handle ); //close the config file

				if ( $bwpsoptions['st_fileperm'] == 1 ) {
					@chmod( $wpconfig, 0444 ); //make sure the config file is no longer writable
				}

			}

			$bwps->clearcache( true );
			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages //finally show messages

		}

		/**
		 * Process spot database backup
		 *
		 **/
		function databasebackup_process_1() {

			global $bwps, $bwps_backup, $bwpsoptions;

			$errorHandler = __( 'Database Backup Completed.', $this->hook );

			$bwpsoptions['backup_last'] = current_time( 'timestamp' );

			update_option( $this->primarysettings, $bwpsoptions );

			$bwps_backup->execute_backup();

			$this->showmessages( $errorHandler );

		}

		/**
		 * Process scheduled database backups options form
		 *
		 **/
		function databasebackup_process_2() {

			global $bwps, $bwps_backup, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate options
			$bwpsoptions['backup_enabled'] = ( isset( $_POST['backup_enabled'] ) && $_POST['backup_enabled'] == 1  ? 1 : 0 );
			$bwpsoptions['backup_email'] = ( isset( $_POST['backup_email'] ) && $_POST['backup_email'] == 1  ? 1 : 0 );
			$bwpsoptions['backups_to_retain'] = absint( $_POST['backups_to_retain'] );
			$bwpsoptions['backup_time'] = ( isset( $_POST['backup_time'] ) && absint( $_POST['backup_time'] ) > 0 ? absint( $_POST['backup_time'] ) : 1 );
			$bwpsoptions['backup_interval'] = $_POST['backup_interval'];

			if ( is_email( $_POST['backup_emailaddress'] ) ) {

				$bwpsoptions['backup_emailaddress'] = $_POST['backup_emailaddress'];

			} else {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'The email address you entered is not a valid email address. You must enter a valid email address.', $this->hook ) );

			}

			if ( $bwpsoptions['backup_enabled'] == 1 ) {

				$nextbackup = $bwpsoptions['backup_next']; //get next schedule

				switch ( $bwpsoptions['backup_interval'] ) { //schedule backup at appropriate time
					case '0':
						$next = 60 * 60 * $bwpsoptions['backup_time'];
						break;
					case '1':
						$next = 60 * 60 * 24 * $bwpsoptions['backup_time'];
						break;
					case '2':
						$next = 60 * 60 * 24 * 7  * $bwpsoptions['backup_time'];
						break;
				}

				if ( $bwpsoptions['backup_last'] == '' ) { //don't run a new backup until we need it to reduce load

					$bwpsoptions['backup_next'] = ( current_time( 'timestamp' ) + $next );

				} else {

					$bwpsoptions['backup_next'] = ( $bwpsoptions['backup_last'] + $next );

				}

			} else { //backups aren't scheduled so clear time

				$bwpsoptions['backup_next'] = '';
				$bwpsoptions['backup_last'] = '';

			}

			update_option( $this->primarysettings, $bwpsoptions );

			if ( $bwpsoptions['backup_email'] == 1 ) { //if backups are done by email remove any files saved to the disk

				$files = scandir( BWPS_PP . '/backups/', 1 );

				foreach ( $files as $file ) {
					if ( strstr( $file, 'database-backup' ) ) {
						unlink ( BWPS_PP . '/backups/' . $file );
					}
				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process database prefix change
		 *
		 **/
		function databaseprefix_process_1() {
			global $bwps, $wpdb, $bwpsoptions;
			$errorHandler = __( 'Database Prefix Changed', $this->hook );

			$checkPrefix = true;//Assume the first prefix we generate is unique

			//generate prefixes until we have one that is valid
			while ( $checkPrefix ) {

				$avail = 'abcdefghijklmnopqrstuvwxyz0123456789';

				//first character should be alpha
				$newPrefix = $avail[rand( 0, 25 )];

				//length of new prefix
				$prelength = rand( 4, 9 );

				//generate remaning characters
				for ( $i = 0; $i < $prelength; $i++ ) {
					$newPrefix .= $avail[rand( 0, 35 )];
				}

				//complete with underscore
				$newPrefix .= '_';

				$newPrefix = esc_sql( $newPrefix ); //just be safe

				$checkPrefix = $wpdb->get_results( 'SHOW TABLES LIKE "' . $newPrefix . '%";', ARRAY_N ); //if there are no tables with that prefix in the database set checkPrefix to false

			}

			$tables = $wpdb->get_results( 'SHOW TABLES LIKE "' . $wpdb->base_prefix . '%"', ARRAY_N ); //retrieve a list of all tables in the DB

			//Rename each table
			foreach ( $tables as $table ) {

				$table = substr( $table[0], strlen( $wpdb->base_prefix ), strlen( $table[0] ) ); //Get the table name without the old prefix

				//rename the table and generate an error if there is a problem
				if ( $wpdb->query( 'RENAME TABLE `' . $wpdb->base_prefix . $table . '` TO `' . $newPrefix . $table . '`;' ) === false ) {

					if ( ! is_wp_error( $errorHandler ) ) { //set an error for invalid username
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', __( 'Error: Could not rename table ', $this->hook ) . $wpdb->base_prefix . __( '. You may have to rename the table manually.', $this->hook ) );

				}

			}

			$upOpts = true; //assume we've successfully updated all options to start

			if ( is_multisite() ) { //multisite requires us to rename each blogs' options

				$blogs = $wpdb->get_col( "SELECT blog_id FROM `" . $newPrefix . "blogs` WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ORDER BY blog_id DESC" ); //get list of blog id's

				if ( is_array( $blogs) ) { //make sure there are other blogs to update

					//update each blog's user_roles option
					foreach ( $blogs as $blog ) {

						$results = $wpdb->query( 'UPDATE `' . $newPrefix . $blog . '_options` SET option_name = "' . $newPrefix . $blog . '_user_roles" WHERE option_name = "' . $wpdb->base_prefix . $blog . '_user_roles" LIMIT 1;' );

						if ( $results === false ) { //if there's an error upOpts should equal false
							$upOpts = false;
						}

					}

				}

			}

			$upOpts = $wpdb->query( 'UPDATE `' . $newPrefix . 'options` SET option_name = "' . $newPrefix . 'user_roles" WHERE option_name = "' . $wpdb->base_prefix . 'user_roles" LIMIT 1;' ); //update options table and set flag to false if there's an error

			if ( $upOpts === false ) { //set an error

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Could not update prefix refences in options tables.', $this->hook ) );

			}

			$rows = $wpdb->get_results( 'SELECT * FROM `' . $newPrefix . 'usermeta`' ); //get all rows in usermeta

			//update all prefixes in usermeta
			foreach ( $rows as $row ) {

				if ( substr( $row->meta_key, 0, strlen( $wpdb->base_prefix ) ) == $wpdb->base_prefix ) {

					$pos = $newPrefix . substr( $row->meta_key, strlen( $wpdb->base_prefix ), strlen( $row->meta_key ) );

					$result = $wpdb->query( 'UPDATE `' . $newPrefix . 'usermeta` SET meta_key="' . $pos . '" WHERE meta_key= "' . $row->meta_key . '" LIMIT 1;' );

					if ( $result == false ) {

						if ( ! is_wp_error( $errorHandler ) ) {
							$errorHandler = new WP_Error();
						}

						$errorHandler->add( '2', __( 'Could not update prefix refences in usermeta table.', $this->hook ) );

					}

				}

			}

			$wpconfig = $this->getConfig(); //get the path for the config file

			if ( ! $f = @fopen( $wpconfig, 'a+' ) ) {

				@chmod( $wpconfig, 0644 );

				if ( ! $f = @fopen( $wpconfig, 'a+' ) ) {

					return -1;

				}

			}

			@fclose( $f );

			$handle = @fopen( $wpconfig, "r+" ); //open for reading

			if ( $handle ) {

				//read each line into an array
				while ( $lines[] = fgets( $handle, 4096 ) ){}

				fclose( $handle ); //close reader

				$handle = @fopen( $wpconfig, "w+" ); //open writer

				foreach ( $lines as $line ) { //process each line

					//if the prefix is in the line
					if ( strpos( $line, 'table_prefix' ) ) {

						$line = str_replace( $wpdb->base_prefix, $newPrefix, $line );

					}

					fwrite( $handle, $line ); //write the line

				}

				fclose( $handle ); //close the config file

				if ( $bwpsoptions['st_fileperm'] == 1 ) {
					@chmod( $wpconfig, 0444 ); //make sure the config file is no longer writable
				}

				$wpdb->base_prefix = $newPrefix; //update the prefix

			}

			$bwps->clearcache( true );
			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages //finally show messages

			remove_action( 'admin_notices', 'site_admin_notice' );
			remove_action( 'network_admin_notices', 'site_admin_notice' );

		}

		/**
		 * Process options for hide backend form
		 *
		 **/
		function hidebackend_process_1() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//if they don't have permalinks enabled set an error
			if ( get_option( 'permalink_structure' ) == '' && ! is_multisite() ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'You must enable permalinks in your WordPress settings for this feature to work.', $this->hook ) );

			}

			//calidate options
			$bwpsoptions['hb_enabled'] = ( isset( $_POST['hb_enabled'] ) && $_POST['hb_enabled'] == 1  ? 1 : 0 );
			$bwpsoptions['hb_login'] = sanitize_text_field( $_POST['hb_login'] );
			$bwpsoptions['hb_admin'] = sanitize_text_field( $_POST['hb_admin'] );
			$bwpsoptions['hb_register'] = sanitize_text_field( $_POST['hb_register'] );

			//generate a secret key (if there isn't one already)
			if ( $bwpsoptions['hb_key'] == '' || ( isset( $_POST['hb_getnewkey'] ) && $_POST['hb_getnewkey'] == 1 ) ) {
				$bwpsoptions['hb_key'] = $this->hidebe_genKey();
			}

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) || strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'litespeed' ) ) && $bwpsoptions['st_writefiles'] == 1 ) { //if they're using apache write to .htaccess

					$this->writehtaccess();

					$errorHandler = __( 'Settings Saved.', $this->hook );

				} else { //not on apache to let them know they will have to manually enter rules

					$errorHandler = new WP_Error();

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules you will need.', $this->hook ) );

				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process manual file scan
		 *
		 **/
		function intrusiondetection_process_1() {

			global $bwps, $bwpsoptions, $bwps_filecheck;

			$errorHandler = __( 'File Check Complete.', $this->hook );

			$bwpsoptions['id_filechecktime'] = current_time( 'timestamp' );

			update_option( $this->primarysettings, $bwpsoptions );

			$bwps_filecheck->execute_filecheck( false );

			$this->showmessages( $errorHandler );

		}

		/**
		 * Process options for intrusion detection form
		 *
		 **/
		function intrusiondetection_process_2() {

			global $bwps, $bwpsoptions;

			@ini_set( 'auto_detect_line_endings', true );

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate the input
			$bwpsoptions['id_blacklistipthreshold'] = isset( $_POST['id_blacklistipthreshold'] ) ? absint( $_POST['id_blacklistipthreshold'] ) : 3;
			$bwpsoptions['id_blacklistip'] = ( isset( $_POST['id_blacklistip'] ) && $_POST['id_blacklistip'] == 1  ? 1 : 0 );
			$bwpsoptions['id_enabled'] = ( isset( $_POST['id_enabled'] ) && $_POST['id_enabled'] == 1  ? 1 : 0 );
			$bwpsoptions['id_emailnotify'] = ( isset( $_POST['id_emailnotify'] ) && $_POST['id_emailnotify'] == 1  ? 1 : 0 );
			$bwpsoptions['id_checkinterval'] = absint( $_POST['id_checkinterval'] );
			$bwpsoptions['id_banperiod'] = absint( $_POST['id_banperiod'] );
			$bwpsoptions['id_threshold'] = absint( $_POST['id_threshold'] );
			$bwpsoptions['id_fileenabled'] = ( isset( $_POST['id_fileenabled'] ) && $_POST['id_fileenabled'] == 1  ? 1 : 0 );
			$bwpsoptions['id_fileemailnotify'] = ( isset( $_POST['id_fileemailnotify'] ) && $_POST['id_fileemailnotify'] == 1  ? 1 : 0 );
			$bwpsoptions['id_fileincex'] = ( isset( $_POST['id_fileincex'] ) && $_POST['id_fileincex'] == 1  ? 1 : 0 );
			$bwpsoptions['id_filedisplayerror'] = ( isset( $_POST['id_filedisplayerror'] ) && $_POST['id_filedisplayerror'] == 1  ? 1 : 0 );
			$bwpsoptions['id_filechecktime'] = '';

			if ( is_email( $_POST['id_fileemailaddress'] ) ) {

				$bwpsoptions['id_fileemailaddress'] = $_POST['id_fileemailaddress'];

			} else {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'The email address you entered for the file check email is not a valid email address. You must enter a valid email address.', $this->hook ) );

			}

			if ( is_email( $_POST['id_emailaddress'] ) ) {

				$bwpsoptions['id_emailaddress'] = $_POST['id_emailaddress'];

			} else {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'The email address you entered for the detect 404 email is not a valid email address. You must enter a valid email address.', $this->hook ) );

			}

			$fileWhiteItems = explode( PHP_EOL, $_POST['id_specialfile'] );
			$fileList = array();

			foreach ( $fileWhiteItems as $item ) {

				$fileList[] = sanitize_text_field( $item );

			}

			$bwpsoptions['id_specialfile'] = implode( PHP_EOL, $fileList );

			//if they set an invalid ban period set an error
			if ( $bwpsoptions['id_banperiod'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Lockout time period needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if they set an invalid check interval set an error
			if ( $bwpsoptions['id_checkinterval'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Login time period needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if they set an invalid 404 threshold set an error
			if ( $bwpsoptions['id_threshold'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __('The error threshold needs to be aan integer greater than 0.', $this->hook ) );

			}

			//process the whitelist
			$whiteList = explode( PHP_EOL, $_POST['id_whitelist'] );
			$whiteitems = array();

			if( ! empty( $whiteList ) ) {

				$list = array();

				foreach( $whiteList as $item ) {

					if ( strlen( $item ) > 0 ) {

						$ipParts = explode( '.', $item );
						$isIP = 0;
						$partcount = 1;
						$goodip = true;
						$foundwild = false;

						foreach ( $ipParts as $part ) {

							if ( $goodip == true ) {

								if ( ( is_numeric( trim( $part ) ) && trim( $part ) <= 255 && trim( $part ) >= 0 ) || trim( $part ) == '*' ) {
									$isIP++;
								}

								switch ( $partcount ) {

									case 1:

										if ( trim( $part ) == '*' ) {

											$goodip = false;

											if ( ! is_wp_error( $errorHandler ) ) { //invalid ip
												$errorHandler = new WP_Error();
											}

											$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is note a valid ip.', $this->hook ) );

										}

										break;

									case 2:

										if ( trim( $part ) == '*' ) {

											$foundwild = true;

										}

										break;

									default:

										if ( trim( $part ) != '*' ) {

											if ( $foundwild == true ) {

												$goodip = false;

												if ( ! is_wp_error( $errorHandler ) ) { //invalid ip
													$errorHandler = new WP_Error();
												}

												$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is note a valid ip.', $this->hook ) );

											}

										} else {

											$foundwild = true;

										}

										break;

								}

								$partcount++;

							}

						}

						if ( ip2long( trim( str_replace( '*', '0', $item ) ) ) == false ) { //invalid ip

							if ( ! is_wp_error( $errorHandler ) ) {
								$errorHandler = new WP_Error();
							}

							$errorHandler->add( '1', __( filter_var( $item, FILTER_SANITIZE_STRING ) . ' is not a valid ip.', $this->hook ) );

						} else {

							$list[] = trim( $item );

						}

					}

				}

			}

			$bwpsoptions['id_whitelist'] = implode( PHP_EOL, $list );

			if ( ! is_wp_error( $errorHandler ) ) {
				update_option( $this->primarysettings, $bwpsoptions );

				if ( $bwpsoptions['st_writefiles'] == 1  ) {

					$this->writewpconfig(); //save to wp-config.php

				} else {

					if ( ! is_wp_error( $errorHandler ) ) {
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add code to your wp-config.php file See the Better WP Security Dashboard for the code you will need.', $this->hook ) );

				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process save options for login limits page
		 *
		 **/
		function loginlimits_process_1() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//valitdate input
			$bwpsoptions['ll_blacklistipthreshold'] = isset( $_POST['ll_blacklistipthreshold'] ) ? absint( $_POST['ll_blacklistipthreshold'] ) : 3;
			$bwpsoptions['ll_blacklistip'] = ( isset( $_POST['ll_blacklistip'] ) && $_POST['ll_blacklistip'] == 1  ? 1 : 0 );
			$bwpsoptions['ll_enabled'] = ( isset( $_POST['ll_enabled'] ) && $_POST['ll_enabled'] == 1  ? 1 : 0 );
			$bwpsoptions['ll_emailnotify'] = ( isset( $_POST['ll_emailnotify'] ) && $_POST['ll_emailnotify'] == 1  ? 1 : 0 );
			$bwpsoptions['ll_maxattemptshost'] = absint( $_POST['ll_maxattemptshost'] );
			$bwpsoptions['ll_maxattemptsuser'] = absint( $_POST['ll_maxattemptsuser'] );
			$bwpsoptions['ll_checkinterval'] = absint( $_POST['ll_checkinterval'] );
			$bwpsoptions['ll_banperiod'] = absint( $_POST['ll_banperiod'] );

			if ( is_email( $_POST['ll_emailaddress'] ) ) {

				$bwpsoptions['ll_emailaddress'] = $_POST['ll_emailaddress'];

			} else {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'The email address you entered for lockout notifications is not a valid email address. You must enter a valid email address.', $this->hook ) );

			}

			//if they entered an invalid ban period set an error
			if ( $bwpsoptions['ll_banperiod'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Lockout time period needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if the intered an invalid check interval set an error
			if ( $bwpsoptions['ll_checkinterval'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Login time period needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if they entered invalid max attempts per host set and error
			if ( $bwpsoptions['ll_maxattemptshost'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Max login attempts per host needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if they entered invalid max attempts per user set an error
			if ( $bwpsoptions['ll_maxattemptsuser'] == 0 ) {

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = new WP_Error();
				}

				$errorHandler->add( '2', __( 'Max login attempts per user needs to be aan integer greater than 0.', $this->hook ) );

			}

			//if there are no errors save the options to the database
			if ( ! is_wp_error( $errorHandler ) ) {
				update_option( $this->primarysettings, $bwpsoptions );
			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process clearing old records form from view log page
		 *
		 **/
		function log_process_1() {

			global $bwps, $wpdb, $bwpsoptions;

			$errorHandler = __( 'The selected records have been cleared.', $this->hook );

			if ( isset( $_POST['badlogins'] ) && $_POST['badlogins'] == 1 ) { //delete old bad logins
				$wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "bwps_log` WHERE `type` = 1;" );
			}

			if ( isset( $_POST['404s'] ) && $_POST['404s'] == 1 ) { //delete old 404s
				$wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "bwps_log` WHERE `type` = 2;" );
			}

			if ( isset( $_POST['lockouts'] ) && $_POST['lockouts'] == 1 ) { //delete old or inactive lockouts
				$wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "bwps_lockouts`;" );
			}

			if ( isset( $_POST['changes'] ) && $_POST['changes'] == 1 ) { //delete old file records
				$wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "bwps_log` WHERE `type` = 3;" );
			}

			$bwps->clearcache();
			$this-> showmessages( $errorHandler ); //finally show messages
		}

		/**
		 * Process clearing lockouts on view log page
		 *
		 **/
		function log_process_2() {
			global $bwps, $wpdb;

			$errorHandler = __( 'The selected lockouts have been cleared.', $this->hook );

			foreach ( $_POST as $key => $value ) {

				if ( strstr( $key, "lo_" ) ) { //see if it's a lockout to avoid processings extra post fields

					$wpdb->update(
						$wpdb->base_prefix . 'bwps_lockouts',
						array(
							'active' => 0
						),
						array(
							'id' => $value
						)
					);

				}

			}

			$bwps->clearcache();
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process rewrite tweaks from system tweaks page
		 *
		 **/
		function ssl_process_1() {

			global $bwps, $bwpsoptions;

			@ini_set( 'auto_detect_line_endings', true );

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate options
			$bwpsoptions['ssl_forcelogin'] = ( isset( $_POST['ssl_forcelogin'] ) && $_POST['ssl_forcelogin'] == 1  ? 1 : 0 );
			$bwpsoptions['ssl_forceadmin'] = ( isset( $_POST['ssl_forceadmin'] ) && $_POST['ssl_forceadmin'] == 1  ? 1 : 0 );
			$bwpsoptions['ssl_frontend'] = ( isset( $_POST['ssl_frontend'] ) ? $_POST['ssl_frontend'] : 0 );

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( $bwpsoptions['st_writefiles'] == 1  ) {

					$this->writewpconfig(); //save to wp-config.php

				} else {

					if ( ! is_wp_error( $errorHandler ) ) {
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add code to your wp-config.php file See the Better WP Security Dashboard for the code you will need.', $this->hook ) );

				}

				if ( ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) || strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'litespeed' ) ) && $bwpsoptions['st_writefiles'] == 1 ) { //if they're using apache write to .htaccess

					$this->writehtaccess();

				} else { //if they're not using apache let them know to manually update rules

					if ( is_wp_error( $errorHandler ) ) {

						$errorHandler = new WP_Error();

						$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules and wp-config.php code to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules  and wp-config.php code you will need.', $this->hook ) );

					} else {

						$errorHandler = new WP_Error();

						$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules you will need.', $this->hook ) );

					}

				}

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = __( 'Settings Saved.', $this->hook );
				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

		/**
		 * Process rewrite tweaks from system tweaks page
		 *
		 **/
		function systemtweaks_process_1() {

			global $bwps, $bwpsoptions;

			$errorHandler = __( 'Settings Saved', $this->hook );

			//validate options
			$bwpsoptions['st_ht_files'] = ( isset( $_POST['st_ht_files'] ) && $_POST['st_ht_files'] == 1  ? 1 : 0 );
			$bwpsoptions['st_ht_request'] = ( isset( $_POST['st_ht_request'] ) && $_POST['st_ht_request'] == 1  ? 1 : 0 );
			$bwpsoptions['st_ht_query'] = ( isset( $_POST['st_ht_query'] ) && $_POST['st_ht_query'] == 1  ? 1 : 0 );
			$bwpsoptions['st_ht_foreign'] = ( isset( $_POST['st_ht_foreign'] ) && $_POST['st_ht_foreign'] == 1  ? 1 : 0 );

			//always set directory browsing to 1 on nginx to prevent nag
			if ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) ) {
				$bwpsoptions['st_ht_browsing'] = ( isset( $_POST['st_ht_browsing'] ) && $_POST['st_ht_browsing'] == 1  ? 1 : 0 );
			} else {
				$bwpsoptions['st_ht_browsing'] = 1;
			}

			$bwpsoptions['st_generator'] = ( isset( $_POST['st_generator'] ) && $_POST['st_generator'] == 1  ? 1 : 0 );
			$bwpsoptions['st_manifest'] = ( isset( $_POST['st_manifest'] ) && $_POST['st_manifest'] == 1  ? 1 : 0 );
			$bwpsoptions['st_edituri'] = ( isset( $_POST['st_edituri'] ) && $_POST['st_edituri'] == 1  ? 1 : 0 );
			$bwpsoptions['st_themenot'] = ( isset( $_POST['st_themenot'] ) && $_POST['st_themenot'] == 1  ? 1 : 0 );
			$bwpsoptions['st_pluginnot'] = ( isset( $_POST['st_pluginnot'] ) && $_POST['st_pluginnot'] == 1  ? 1 : 0 );
			$bwpsoptions['st_corenot'] = ( isset( $_POST['st_corenot'] ) && $_POST['st_corenot'] == 1  ? 1 : 0 );
			$bwpsoptions['st_enablepassword'] = ( isset( $_POST['st_enablepassword'] ) && $_POST['st_enablepassword'] == 1  ? 1 : 0 );
			if ( ctype_alpha( wp_strip_all_tags( $_POST['st_passrole'] ) ) ) {
				$bwpsoptions['st_passrole'] = wp_strip_all_tags( $_POST['st_passrole'] );
			}
			$bwpsoptions['st_loginerror'] = ( isset( $_POST['st_loginerror'] ) && $_POST['st_loginerror'] == 1  ? 1 : 0 );
			$bwpsoptions['st_fileperm'] = ( isset( $_POST['st_fileperm'] ) && $_POST['st_fileperm'] == 1  ? 1 : 0 );
			$bwpsoptions['st_randomversion'] = ( isset( $_POST['st_randomversion'] ) && $_POST['st_randomversion'] == 1  ? 1 : 0 );
			$bwpsoptions['st_longurl'] = ( isset( $_POST['st_longurl'] ) && $_POST['st_longurl'] == 1  ? 1 : 0 );
			$bwpsoptions['st_fileedit'] = ( isset( $_POST['st_fileedit'] ) && $_POST['st_fileedit'] == 1  ? 1 : 0 );
			$bwpsoptions['st_writefiles'] = ( isset( $_POST['st_writefiles'] ) && $_POST['st_writefiles'] == 1  ? 1 : 0 );
			$bwpsoptions['st_comment'] = ( isset( $_POST['st_comment'] ) && $_POST['st_comment'] == 1  ? 1 : 0 );

			if ( ! is_wp_error( $errorHandler ) ) {

				update_option( $this->primarysettings, $bwpsoptions );

				if ( $bwpsoptions['st_writefiles'] == 1  ) {

					$this->writewpconfig(); //save to wp-config.php

				} else {

					if ( ! is_wp_error( $errorHandler ) ) {
						$errorHandler = new WP_Error();
					}

					$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add code to your wp-config.php file See the Better WP Security Dashboard for the code you will need.', $this->hook ) );

				}

				if ( ( strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'apache' ) || strstr( strtolower( filter_var( $_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING ) ), 'litespeed' ) ) && $bwpsoptions['st_writefiles'] == 1 ) { //if they're using apache write to .htaccess

					$this->writehtaccess();

				} else { //if they're not using apache let them know to manually update rules

					if ( is_wp_error( $errorHandler ) ) {

						$errorHandler = new WP_Error();

						$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules and wp-config.php code to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules  and wp-config.php code you will need.', $this->hook ) );

					} else {

						$errorHandler = new WP_Error();

						$errorHandler->add( '2', __( 'Settings Saved. You will have to manually add rewrite rules to your configuration. See the Better WP Security Dashboard for a list of the rewrite rules you will need.', $this->hook ) );

					}

				}

				if ( ! is_wp_error( $errorHandler ) ) {
					$errorHandler = __( 'Settings Saved.', $this->hook );
				}

			}

			$bwps->clearcache( true );
			$this-> showmessages( $errorHandler ); //finally show messages

		}

	}

}


text:
/**
 * @author renej
 * NURBS curve object
 *
 * Derives from Curve, overriding getPoint and getTangent.
 *
 * Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight.
 *
 **/

/**************************************************************
 *	NURBS curve
 **************************************************************/

THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */) {

	this.degree = degree;
	this.knots = knots;
	this.controlPoints = [];
	for (var i = 0; i < controlPoints.length; ++ i) { // ensure Vector4 for control points
		var point = controlPoints[i];
		this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
	}

};

THREE.NURBSCurve.prototype = Object.create( THREE.Curve.prototype );
THREE.NURBSCurve.prototype.constructor = THREE.NURBSCurve;

THREE.NURBSCurve.prototype.getPoint = function ( t ) {

	var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]); // linear mapping t->u

	// following results in (wx, wy, wz, w) homogeneous point
	var hpoint = THREE.NURBSUtils.calcBSplinePoint(this.degree, this.knots, this.controlPoints, u);

	if (hpoint.w != 1.0) { // project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
		hpoint.divideScalar(hpoint.w);
	}

	return new THREE.Vector3(hpoint.x, hpoint.y, hpoint.z);
};

THREE.NURBSCurve.prototype.getTangent = function ( t ) {

	var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]);
	var ders = THREE.NURBSUtils.calcNURBSDerivatives(this.degree, this.knots, this.controlPoints, u, 1);
	var tangent = ders[1].clone();
	tangent.normalize();

	return tangent;
};

redpajama_set_name: RedPajamaGithub


text:
package org.batfish.representation.juniper;

import java.util.Objects;
import org.batfish.datamodel.Ip6;
import org.batfish.datamodel.Prefix6;

/** Representation of a route-filter with a IPv6 prefix and an address mask */
public final class Route6FilterLineAddressMask extends Route6FilterLine {

  private final Ip6 _addressMask;

  public Route6FilterLineAddressMask(Prefix6 prefix6, Ip6 addressMask) {
    super(prefix6);
    _addressMask = addressMask;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    } else if (!(o instanceof Route6FilterLineAddressMask)) {
      return false;
    }

    Route6FilterLineAddressMask rhs = (Route6FilterLineAddressMask) o;
    return _prefix6.equals(rhs._prefix6) && _addressMask.equals(rhs._addressMask);
  }

  @Override
  public int hashCode() {
    return Objects.hash(_prefix6, _addressMask);
  }
}


text:
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.ntp.snippets;

import android.content.Context;

import com.google.android.gms.gcm.GcmNetworkManager;
import com.google.android.gms.gcm.PeriodicTask;
import com.google.android.gms.gcm.Task;

import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.ChromeBackgroundService;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;

/**
 * The {@link SnippetsLauncher} singleton is created and owned by the C++ browser.
 *
 * Thread model: This class is to be run on the UI thread only.
 */
public class SnippetsLauncher {
    private static final String TAG = "SnippetsLauncher";

    public static final String TASK_TAG_WIFI_CHARGING = "FetchSnippetsWifiCharging";
    public static final String TASK_TAG_WIFI = "FetchSnippetsWifi";
    public static final String TASK_TAG_FALLBACK = "FetchSnippetsFallback";

    // The instance of SnippetsLauncher currently owned by a C++ SnippetsLauncherAndroid, if any.
    // If it is non-null then the browser is running.
    private static SnippetsLauncher sInstance;

    private GcmNetworkManager mScheduler;

    private boolean mGCMEnabled = true;

    /**
     * Create a SnippetsLauncher object, which is owned by C++.
     * @param context The app context.
     */
    @VisibleForTesting
    @CalledByNative
    public static SnippetsLauncher create(Context context) {
        if (sInstance != null) {
            throw new IllegalStateException("Already instantiated");
        }

        sInstance = new SnippetsLauncher(context);
        return sInstance;
    }

    /**
     * Called when the C++ counterpart is deleted.
     */
    @VisibleForTesting
    @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
    @CalledByNative
    public void destroy() {
        assert sInstance == this;
        sInstance = null;
    }

    /**
     * Returns true if the native browser has started and created an instance of {@link
     * SnippetsLauncher}.
     */
    public static boolean hasInstance() {
        return sInstance != null;
    }

    protected SnippetsLauncher(Context context) {
        checkGCM(context);
        mScheduler = GcmNetworkManager.getInstance(context);
    }

    private boolean canUseGooglePlayServices(Context context) {
        return ExternalAuthUtils.getInstance().canUseGooglePlayServices(
                context, new UserRecoverableErrorHandler.Silent());
    }

    private void checkGCM(Context context) {
        // Check to see if Play Services is up to date, and disable GCM if not.
        if (!canUseGooglePlayServices(context)) {
            mGCMEnabled = false;
            Log.i(TAG, "Disabling SnippetsLauncher because Play Services is not up to date.");
        }
    }

    private static PeriodicTask buildTask(
            String tag, long periodSeconds, int requiredNetwork, boolean requiresCharging) {
        return new PeriodicTask.Builder()
                .setService(ChromeBackgroundService.class)
                .setTag(tag)
                .setPeriod(periodSeconds)
                .setRequiredNetwork(requiredNetwork)
                .setRequiresCharging(requiresCharging)
                .setPersisted(true)
                .setUpdateCurrent(true)
                .build();
    }

    @CalledByNative
    private boolean schedule(
            long periodWifiChargingSeconds, long periodWifiSeconds, long periodFallbackSeconds) {
        if (!mGCMEnabled) return false;
        Log.d(TAG, "Scheduling: " + periodWifiChargingSeconds + " " + periodWifiSeconds + " "
                        + periodFallbackSeconds);
        // Google Play Services may not be up to date, if the application was not installed through
        // the Play Store. In this case, scheduling the task will fail silently.
        try {
            mScheduler.schedule(buildTask(TASK_TAG_WIFI_CHARGING, periodWifiChargingSeconds,
                    Task.NETWORK_STATE_UNMETERED, true));
            mScheduler.schedule(buildTask(
                    TASK_TAG_WIFI, periodWifiSeconds, Task.NETWORK_STATE_UNMETERED, false));
            mScheduler.schedule(buildTask(
                    TASK_TAG_FALLBACK, periodFallbackSeconds, Task.NETWORK_STATE_CONNECTED, false));
        } catch (IllegalArgumentException e) {
            // Disable GCM for the remainder of this session.
            mGCMEnabled = false;
            // Return false so that the failure will be logged.
            return false;
        }
        return true;
    }

    @CalledByNative
    private boolean unschedule() {
        if (!mGCMEnabled) return false;
        Log.i(TAG, "Unscheduling");
        try {
            mScheduler.cancelTask(TASK_TAG_WIFI_CHARGING, ChromeBackgroundService.class);
            mScheduler.cancelTask(TASK_TAG_WIFI, ChromeBackgroundService.class);
            mScheduler.cancelTask(TASK_TAG_FALLBACK, ChromeBackgroundService.class);
        } catch (IllegalArgumentException e) {
            // This occurs when SnippetsLauncherService is not found in the application
            // manifest. Disable GCM for the remainder of this session.
            mGCMEnabled = false;
            // Return false so that the failure will be logged.
            return false;
        }
        return true;
    }
}


text:
//---------------------------------------------------------------------
// <copyright file="SingleValueOpenPropertyAccessNode.cs" company="Microsoft">
//      Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
// </copyright>
//---------------------------------------------------------------------

namespace Microsoft.OData.Core.UriParser.Semantic
{
    using Microsoft.OData.Core.UriParser.TreeNodeKinds;
    using Microsoft.OData.Core.UriParser.Visitors;
    using Microsoft.OData.Edm;

    /// <summary>
    /// Semantic node that represents a single-value open property access, which is not bound to an EDM model.
    /// </summary>
    public sealed class SingleValueOpenPropertyAccessNode : SingleValueNode
    {
        /// <summary>
        /// The value containing this property.
        /// </summary>
        private readonly SingleValueNode source;

        /// <summary>
        /// The name of the open property to be bound outside the EDM model.
        /// </summary>
        private readonly string name;

        /// <summary>
        /// Constructs a <see cref="SingleValueOpenPropertyAccessNode"/>.
        /// </summary>
        /// <param name="source">The value containing this property.</param>
        /// <param name="openPropertyName">The name of the open property to be bound outside the EDM model.</param>
        /// <exception cref="System.ArgumentNullException">Throws if the input source or openPropertyName is null.</exception>
        public SingleValueOpenPropertyAccessNode(SingleValueNode source, string openPropertyName)
        {
            ExceptionUtils.CheckArgumentNotNull(source, "source");
            ExceptionUtils.CheckArgumentStringNotNullOrEmpty(openPropertyName, "openPropertyName");

            this.name = openPropertyName;
            this.source = source;
        }

        /// <summary>
        ///  Gets the value containing this property.
        /// </summary>
        public SingleValueNode Source
        {
            get { return this.source; }
        }

        /// <summary>
        /// Gets the name of the open property to be bound outside the EDM model.
        /// </summary>
        public string Name
        {
            get { return this.name; }
        }

        /// <summary>
        /// Gets the type of the single value this node represents.
        /// </summary>
        /// <remarks>
        /// The value of this property will always be null for open properties.
        /// </remarks>
        public override IEdmTypeReference TypeReference
        {
            get { return null; }
        }

        /// <summary>
        /// Gets the kind of this query node.
        /// </summary>
        internal override InternalQueryNodeKind InternalKind
        {
            get
            {
                return InternalQueryNodeKind.SingleValueOpenPropertyAccess;
            }
        }

        /// <summary>
        /// Accept a <see cref="QueryNodeVisitor{T}"/> that walks a tree of <see cref="QueryNode"/>s.
        /// </summary>
        /// <typeparam name="T">Type that the visitor will return after visiting this token.</typeparam>
        /// <param name="visitor">An implementation of the visitor interface.</param>
        /// <returns>An object whose type is determined by the type parameter of the visitor.</returns>
        /// <exception cref="System.ArgumentNullException">Throws if the input visitor is null.</exception>
        public override T Accept<T>(QueryNodeVisitor<T> visitor)
        {
            ExceptionUtils.CheckArgumentNotNull(visitor, "visitor");
            return visitor.Visit(this);
        }
    }
}


text:
extern "Java"
{
  namespace gnu
  {
    namespace java
    {
      namespace awt
      {
        namespace java2d
        {
            class TexturePaintContext;
        }
      }
    }
  }
  namespace java
  {
    namespace awt
    {
        class Rectangle;
        class TexturePaint;
      namespace geom
      {
          class AffineTransform;
          class Rectangle2D;
      }
      namespace image
      {
          class BufferedImage;
          class ColorModel;
          class Raster;
          class WritableRaster;
      }
    }
  }
}

class gnu::java::awt::java2d::TexturePaintContext : public ::java::lang::Object
{

public:
  TexturePaintContext(::java::awt::TexturePaint *, ::java::awt::Rectangle *, ::java::awt::geom::Rectangle2D *, ::java::awt::geom::AffineTransform *);
  virtual void dispose();
  virtual ::java::awt::image::ColorModel * getColorModel();
  virtual ::java::awt::image::Raster * getRaster(jint, jint, jint, jint);
private:
  void ensureRasterSize(jint, jint);
  ::java::awt::image::BufferedImage * __attribute__((aligned(__alignof__( ::java::lang::Object)))) image;
  ::java::awt::image::WritableRaster * paintRaster;
  ::java::awt::geom::AffineTransform * transform;
public:
  static ::java::lang::Class class$;
};

#endif // __gnu_java_awt_java2d_TexturePaintContext__


text:
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic.Utils;
using System.Linq.Expressions;

namespace System.Dynamic
{
    /// <summary>
    /// Represents the dynamic binding and a binding logic of an object participating in the dynamic binding.
    /// </summary>
    public class DynamicMetaObject
    {
        /// <summary>
        /// Represents an empty array of type <see cref="DynamicMetaObject"/>. This field is read-only.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
        public static readonly DynamicMetaObject[] EmptyMetaObjects = Array.Empty<DynamicMetaObject>();

        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicMetaObject"/> class.
        /// </summary>
        /// <param name="expression">The expression representing this <see cref="DynamicMetaObject"/> during the dynamic binding process.</param>
        /// <param name="restrictions">The set of binding restrictions under which the binding is valid.</param>
        public DynamicMetaObject(Expression expression, BindingRestrictions restrictions)
        {
            ContractUtils.RequiresNotNull(expression, nameof(expression));
            ContractUtils.RequiresNotNull(restrictions, nameof(restrictions));

            Expression = expression;
            Restrictions = restrictions;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicMetaObject"/> class.
        /// </summary>
        /// <param name="expression">The expression representing this <see cref="DynamicMetaObject"/> during the dynamic binding process.</param>
        /// <param name="restrictions">The set of binding restrictions under which the binding is valid.</param>
        /// <param name="value">The runtime value represented by the <see cref="DynamicMetaObject"/>.</param>
        public DynamicMetaObject(Expression expression, BindingRestrictions restrictions, object value)
            : this(expression, restrictions)
        {
            Value = value;
            HasValue = true;
        }

        /// <summary>
        /// The expression representing the <see cref="DynamicMetaObject"/> during the dynamic binding process.
        /// </summary>
        public Expression Expression { get; }

        /// <summary>
        /// The set of binding restrictions under which the binding is valid.
        /// </summary>
        public BindingRestrictions Restrictions { get; }

        /// <summary>
        /// The runtime value represented by this <see cref="DynamicMetaObject"/>.
        /// </summary>
        public object Value { get; }

        /// <summary>
        /// Gets a value indicating whether the <see cref="DynamicMetaObject"/> has the runtime value.
        /// </summary>
        public bool HasValue { get; }

        /// <summary>
        /// Gets the <see cref="Type"/> of the runtime value or null if the <see cref="DynamicMetaObject"/> has no value associated with it.
        /// </summary>
        public Type RuntimeType
        {
            get
            {
                if (HasValue)
                {
                    Type ct = Expression.Type;
                    // valuetype at compile time, type cannot change.
                    if (ct.IsValueType)
                    {
                        return ct;
                    }

                    return Value?.GetType();
                }
                else
                {
                    return null;
                }
            }
        }

        /// <summary>
        /// Gets the limit type of the <see cref="DynamicMetaObject"/>.
        /// </summary>
        /// <remarks>Represents the most specific type known about the object represented by the <see cref="DynamicMetaObject"/>. <see cref="RuntimeType"/> if runtime value is available, a type of the <see cref="Expression"/> otherwise.</remarks>
        public Type LimitType => RuntimeType ?? Expression.Type;

        /// <summary>
        /// Performs the binding of the dynamic conversion operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="ConvertBinder"/> that represents the details of the dynamic operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindConvert(ConvertBinder binder)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackConvert(this);
        }

        /// <summary>
        /// Performs the binding of the dynamic get member operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="GetMemberBinder"/> that represents the details of the dynamic operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindGetMember(GetMemberBinder binder)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackGetMember(this);
        }

        /// <summary>
        /// Performs the binding of the dynamic set member operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="SetMemberBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set member operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackSetMember(this, value);
        }

        /// <summary>
        /// Performs the binding of the dynamic delete member operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="DeleteMemberBinder"/> that represents the details of the dynamic operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackDeleteMember(this);
        }

        /// <summary>
        /// Performs the binding of the dynamic get index operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="GetIndexBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the get index operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackGetIndex(this, indexes);
        }

        /// <summary>
        /// Performs the binding of the dynamic set index operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="SetIndexBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the set index operation.</param>
        /// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set index operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackSetIndex(this, indexes, value);
        }

        /// <summary>
        /// Performs the binding of the dynamic delete index operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="DeleteIndexBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="indexes">An array of <see cref="DynamicMetaObject"/> instances - indexes for the delete index operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackDeleteIndex(this, indexes);
        }

        /// <summary>
        /// Performs the binding of the dynamic invoke member operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="InvokeMemberBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackInvokeMember(this, args);
        }

        /// <summary>
        /// Performs the binding of the dynamic invoke operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackInvoke(this, args);
        }

        /// <summary>
        /// Performs the binding of the dynamic create instance operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="CreateInstanceBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the create instance operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackCreateInstance(this, args);
        }

        /// <summary>
        /// Performs the binding of the dynamic unary operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="UnaryOperationBinder"/> that represents the details of the dynamic operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackUnaryOperation(this);
        }

        /// <summary>
        /// Performs the binding of the dynamic binary operation.
        /// </summary>
        /// <param name="binder">An instance of the <see cref="BinaryOperationBinder"/> that represents the details of the dynamic operation.</param>
        /// <param name="arg">An instance of the <see cref="DynamicMetaObject"/> representing the right hand side of the binary operation.</param>
        /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public virtual DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
        {
            ContractUtils.RequiresNotNull(binder, nameof(binder));
            return binder.FallbackBinaryOperation(this, arg);
        }

        /// <summary>
        /// Returns the enumeration of all dynamic member names.
        /// </summary>
        /// <returns>The list of dynamic member names.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
        public virtual IEnumerable<string> GetDynamicMemberNames() => Array.Empty<string>();

        /// <summary>
        /// Returns the list of expressions represented by the <see cref="DynamicMetaObject"/> instances.
        /// </summary>
        /// <param name="objects">An array of <see cref="DynamicMetaObject"/> instances to extract expressions from.</param>
        /// <returns>The array of expressions.</returns>
        internal static Expression[] GetExpressions(DynamicMetaObject[] objects)
        {
            ContractUtils.RequiresNotNull(objects, nameof(objects));

            Expression[] res = new Expression[objects.Length];
            for (int i = 0; i < objects.Length; i++)
            {
                DynamicMetaObject mo = objects[i];
                ContractUtils.RequiresNotNull(mo, nameof(objects));
                Expression expr = mo.Expression;
                Debug.Assert(expr != null, "Unexpected null expression; ctor should have caught this.");
                res[i] = expr;
            }

            return res;
        }

        /// <summary>
        /// Creates a meta-object for the specified object.
        /// </summary>
        /// <param name="value">The object to get a meta-object for.</param>
        /// <param name="expression">The expression representing this <see cref="DynamicMetaObject"/> during the dynamic binding process.</param>
        /// <returns>
        /// If the given object implements <see cref="IDynamicMetaObjectProvider"/> and is not a remote object from outside the current AppDomain,
        /// returns the object's specific meta-object returned by <see cref="IDynamicMetaObjectProvider.GetMetaObject"/>. Otherwise a plain new meta-object
        /// with no restrictions is created and returned.
        /// </returns>
        public static DynamicMetaObject Create(object value, Expression expression)
        {
            ContractUtils.RequiresNotNull(expression, nameof(expression));

            IDynamicMetaObjectProvider ido = value as IDynamicMetaObjectProvider;
            if (ido != null)
            {
                var idoMetaObject = ido.GetMetaObject(expression);

                if (idoMetaObject == null ||
                    !idoMetaObject.HasValue ||
                    idoMetaObject.Value == null ||
                    (object)idoMetaObject.Expression != (object)expression)
                {
                    throw System.Linq.Expressions.Error.InvalidMetaObjectCreated(ido.GetType());
                }

                return idoMetaObject;
            }
            else
            {
                return new DynamicMetaObject(expression, BindingRestrictions.Empty, value);
            }
        }
    }
}


text:
package com.github.cameltooling.idea.completion.header;

import com.github.cameltooling.idea.completion.OptionSuggestion;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.psi.PsiElement;
import org.apache.camel.tooling.model.ComponentModel;

/**
 * The {@link CompletionProvider} that gives the name of potential headers in case of YAML files.
 */
public class CamelYamlHeaderNameCompletion extends CamelHeaderNameCompletion {

    /**
     * Constructs a {@code CamelYamlHeaderNameCompletion} with the given source of endpoints.
     * @param source the source of endpoints from which we extract the name of headers to propose.
     */
    public CamelYamlHeaderNameCompletion(CamelHeaderEndpointSource source) {
        super(source);
    }

    @Override
    protected String extractTextFromElement(final PsiElement element) {
        return getIdeaUtils().extractTextFromElement(element);
    }

    @Override
    protected boolean isStringLiteralExpected(final PsiElement element) {
        return true;
    }

    @Override
    protected LookupElementBuilder createLookupElementBuilder(final PsiElement element,
                                                              final ComponentModel.EndpointHeaderModel header) {
        return LookupElementBuilder.create(new OptionSuggestion(header, header.getName()))
            .withInsertHandler(
                (context, item) -> {
                    final char text = context
                        .getDocument()
                        .getCharsSequence()
                        .charAt(context.getStartOffset() - 1);
                    if (text == ':') {
                        // If the last character is a colon we need to inject the missing space
                        context.getDocument().insertString(context.getStartOffset(), " ");
                    }
                }
            );
    }
}


text:
package toadmess.explosives.events;

import org.bukkit.event.Event.Type;

import toadmess.explosives.config.entity.EntityConf;

public interface Handler {
	void handle(final HEEvent event);

	TippingPoint[] getTippingPointsHandled();

	Type[] getBukkitEventsRequired();

	boolean isNeededBy(final EntityConf thisConfig);
}


text:
<?php

return [
    'password' => [
        'heading' => 'Password reset',
        'text' => 'Someone asked for password recovery on your e-mail address, click on the button below that-be to restore your password.',
        'action' => 'Reset',
    ],
];


text:
class Saveable::ExternalLinkUrlPolicy < ApplicationPolicy
end


text:
package org.apereo.cas.ticket.registry;

import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.util.junit.EnabledIfContinuousIntegration;

import org.junit.jupiter.api.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.test.context.TestPropertySource;

/**
 * This is {@link CassandraTicketRegistryTests}.
 *
 * @author Misagh Moayyed
 * @since 6.1.0
 */
@EnableConfigurationProperties(CasConfigurationProperties.class)
@TestPropertySource(properties = {
    "cas.ticket.registry.cassandra.keyspace=cas"
})
@Tag("Cassandra")
@EnabledIfContinuousIntegration
public class CassandraTicketRegistryTests extends BaseTicketRegistryTests {
    @Autowired
    @Qualifier("ticketRegistry")
    private TicketRegistry ticketRegistry;

    @Override
    public TicketRegistry getNewTicketRegistry() {
        return this.ticketRegistry;
    }
}