当前位置: 首页>>代码示例>>PHP>>正文


PHP ITSEC_Lib::get_random方法代码示例

本文整理汇总了PHP中ITSEC_Lib::get_random方法的典型用法代码示例。如果您正苦于以下问题:PHP ITSEC_Lib::get_random方法的具体用法?PHP ITSEC_Lib::get_random怎么用?PHP ITSEC_Lib::get_random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITSEC_Lib的用法示例。

在下文中一共展示了ITSEC_Lib::get_random方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

	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' ) );

		}

	}
开发者ID:helloworld-digital,项目名称:insightvision,代码行数:60,代码来源:class-itsec-logger.php


示例2: force_unique_nicename

 /**
  * Requires a unique nicename on profile update or activate.
  *
  * @since 4.0
  *
  * @return void
  */
 public function force_unique_nicename(&$errors, $update, &$user)
 {
     $display_name = isset($user->display_name) ? $user->display_name : ITSEC_Lib::get_random(14);
     if (!empty($user->nickname)) {
         if ($user->nickname == $user->user_login) {
             $errors->add('user_error', __('Your Nickname must be different than your login name. Please choose a different Nickname.', 'it-l10n-better-wp-security'));
         } else {
             $user->user_nicename = sanitize_title($user->nickname, $display_name);
         }
     } elseif (!empty($user->first_name) && !empty($user->last_name)) {
         $full_name = $user->first_name . ' ' . $user->last_name;
         $user->nickname = $full_name;
         $user->user_nicename = sanitize_title($full_name, $display_name);
     } else {
         $errors->add('user_error', __('A Nickname is required. Please choose a nickname or fill out your first and last name.', 'it-l10n-better-wp-security'));
     }
 }
开发者ID:erikdukker,项目名称:medisom,代码行数:24,代码来源:class-itsec-tweaks.php


示例3: activate_execute

 /**
  * Execute activation.
  *
  * @since 4.0
  *
  * @param boolean $upgrade true if the plugin is updating
  *
  * @return void
  */
 private function activate_execute()
 {
     global $itsec_globals, $itsec_files;
     //if this is multisite make sure they're network activating or die
     if (defined('ITSEC_DO_ACTIVATION') && ITSEC_DO_ACTIVATION == true && is_multisite() && !strpos($_SERVER['REQUEST_URI'], 'wp-admin/network/plugins.php')) {
         die(__('<strong>ERROR</strong>: You must activate this plugin from the network dashboard.', 'it-l10n-better-wp-security'));
     }
     //make sure directories are present and they are not remotely accessible
     if (!is_dir($itsec_globals['ithemes_dir'])) {
         @mkdir($itsec_globals['ithemes_dir']);
         $handle = @fopen($itsec_globals['ithemes_dir'] . '/.htaccess', 'w+');
         @fwrite($handle, 'Deny from all');
         @fclose($handle);
     }
     if (!is_dir($itsec_globals['ithemes_log_dir'])) {
         @mkdir($itsec_globals['ithemes_log_dir']);
         $handle = @fopen($itsec_globals['ithemes_log_dir'] . '/.htaccess', 'w+');
         @fwrite($handle, 'Deny from all');
         @fclose($handle);
     }
     if (!is_dir($itsec_globals['ithemes_backup_dir'])) {
         @mkdir($itsec_globals['ithemes_backup_dir']);
         $handle = @fopen($itsec_globals['ithemes_backup_dir'] . '/.htaccess', 'w+');
         @fwrite($handle, 'Deny from all');
         @fclose($handle);
     }
     if (($site_data = get_site_option('itsec_data')) === false) {
         add_site_option('itsec_data', array(), false);
     }
     if (get_site_option('itsec_initials') === false) {
         add_site_option('itsec_initials', array(), false);
     }
     if (get_site_option('itsec_api_nag') === false) {
         //show the nag to activate an API key
         add_site_option('itsec_api_nag', true, false);
     }
     $options = get_site_option('itsec_global');
     if ($options === false || isset($options['log_info']) && sizeof($options) <= 2) {
         $this->defaults['log_info'] = substr(sanitize_title(get_bloginfo('name')), 0, 20) . '-' . ITSEC_Lib::get_random(mt_rand(0, 10));
         $itsec_globals['settings'] = $this->defaults;
         update_site_option('itsec_global', $this->defaults);
     }
     //load utility functions
     if (!class_exists('ITSEC_Lib')) {
         require trailingslashit($itsec_globals['plugin_dir']) . 'core/class-itsec-lib.php';
     }
     ITSEC_Lib::create_database_tables();
     $this->do_modules();
 }
开发者ID:santikrass,项目名称:apache,代码行数:58,代码来源:class-itsec-setup.php


示例4: execute_backup

 /**
  * Executes backup function.
  *
  * Handles the execution of database backups.
  *
  * @since 4.0.0
  *
  * @param bool $one_time whether this is a one-time backup
  *
  * @return void
  */
 private function execute_backup($one_time = false)
 {
     global $wpdb, $itsec_globals, $itsec_logger;
     //get all of the tables
     if (isset($this->settings['all_sites']) && true === $this->settings['all_sites']) {
         $tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
         //retrieve a list of all tables in the DB
     } else {
         $tables = $wpdb->get_results('SHOW TABLES LIKE "' . $wpdb->base_prefix . '%"', ARRAY_N);
         //retrieve a list of all tables for this WordPress installation
     }
     $return = '';
     //cycle through each table
     foreach ($tables as $table) {
         $num_fields = sizeof($wpdb->get_results('DESCRIBE `' . $table[0] . '`;'));
         $return .= 'DROP TABLE IF EXISTS `' . $table[0] . '`;';
         $row2 = $wpdb->get_row('SHOW CREATE TABLE `' . $table[0] . '`;', ARRAY_N);
         $return .= PHP_EOL . PHP_EOL . $row2[1] . ";" . PHP_EOL . PHP_EOL;
         if (!in_array(substr($table[0], strlen($wpdb->prefix)), $this->settings['exclude'])) {
             $result = $wpdb->get_results('SELECT * FROM `' . $table[0] . '`;', ARRAY_N);
             foreach ($result as $row) {
                 $return .= 'INSERT INTO `' . $table[0] . '` VALUES(';
                 for ($j = 0; $j < $num_fields; $j++) {
                     $row[$j] = addslashes($row[$j]);
                     $row[$j] = preg_replace('#' . PHP_EOL . '#', "\n", $row[$j]);
                     if (isset($row[$j])) {
                         $return .= '"' . $row[$j] . '"';
                     } else {
                         $return .= '""';
                     }
                     if ($j < $num_fields - 1) {
                         $return .= ',';
                     }
                 }
                 $return .= ");" . PHP_EOL;
             }
         }
         $return .= PHP_EOL . PHP_EOL;
     }
     $return .= PHP_EOL . PHP_EOL;
     $current_time = current_time('timestamp');
     //save file
     $file = 'backup-' . substr(sanitize_title(get_bloginfo('name')), 0, 20) . '-' . $current_time . '-' . ITSEC_Lib::get_random(mt_rand(5, 10));
     if (!is_dir($itsec_globals['ithemes_backup_dir'])) {
         @mkdir(trailingslashit($itsec_globals['ithemes_dir']) . 'backups');
     }
     $handle = @fopen($itsec_globals['ithemes_backup_dir'] . '/' . $file . '.sql', 'w+');
     @fwrite($handle, $return);
     @fclose($handle);
     //zip the file
     if (true === $this->settings['zip']) {
         if (!class_exists('PclZip')) {
             require ABSPATH . 'wp-admin/includes/class-pclzip.php';
         }
         $zip = new PclZip($itsec_globals['ithemes_backup_dir'] . '/' . $file . '.zip');
         if (0 != $zip->create($itsec_globals['ithemes_backup_dir'] . '/' . $file . '.sql')) {
             //delete .sql and keep zip
             @unlink($itsec_globals['ithemes_backup_dir'] . '/' . $file . '.sql');
             $fileext = '.zip';
         }
     } else {
         $fileext = '.sql';
     }
     if (2 !== $this->settings['method'] || true === $one_time) {
         $option = get_site_option('itsec_global');
         $attachment = array($itsec_globals['ithemes_backup_dir'] . '/' . $file . $fileext);
         $body = __('Attached is the backup file for the database powering', 'it-l10n-better-wp-security') . ' ' . get_option('siteurl') . __(' taken', 'it-l10n-better-wp-security') . ' ' . date('l, F jS, Y \\a\\t g:i a', $itsec_globals['current_time']);
         //Setup the remainder of the email
         $recipients = $option['backup_email'];
         $subject = __('Site Database Backup', 'it-l10n-better-wp-security') . ' ' . date('l, F jS, Y \\a\\t g:i a', $itsec_globals['current_time']);
         $subject = apply_filters('itsec_backup_email_subject', $subject);
         $headers = 'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>' . "\r\n";
         $mail_success = false;
         //Use HTML Content type
         add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
         //Send emails to all recipients
         foreach ($recipients as $recipient) {
             if (is_email(trim($recipient))) {
                 if (defined('ITSEC_DEBUG') && true === ITSEC_DEBUG) {
                     $body .= '<p>' . __('Debug info (source page): ' . esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])) . '</p>';
                 }
                 $mail_success = wp_mail(trim($recipient), $subject, '<html>' . $body . '</html>', $headers, $attachment);
             }
         }
         //Remove HTML Content type
         remove_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
     }
     if (1 === $this->settings['method']) {
         @unlink($itsec_globals['ithemes_backup_dir'] . '/' . $file . $fileext);
//.........这里部分代码省略.........
开发者ID:santikrass,项目名称:apache,代码行数:101,代码来源:class-itsec-backup.php


示例5: generate_salts

 /**
  * Generate Salts
  *
  * Generates a random string using alpha-numeric and special characters with a length of 64 characters.
  *
  * @since  4.6.0
  *
  * @access private
  *
  * @return void
  */
 private function generate_salts()
 {
     $salts = '';
     for ($i = 0; 1 > $i; $i++) {
         $salts .= ITSEC_Lib::get_random(64, false, true) . ' ';
     }
     return $salts;
 }
开发者ID:kraczo,项目名称:pracowniapizzy,代码行数:19,代码来源:class-itsec-salts-admin.php


示例6: wp_ajax_itsec_two_factor_profile_ajax

	/**
	 * Ajax generate new key.
	 *
	 * Generates a new two-factor key via AJAX.
	 *
	 * @since 1.2.0
	 *
	 * @return void
	 */
	public function wp_ajax_itsec_two_factor_profile_ajax() {

		if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'itsec_two_factor_profile' ) ) {
			die( __( 'Security error!', 'it-l10n-ithemes-security-pro' ) );
		}

		die( ITSEC_Lib::get_random( 16, true ) );

	}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:18,代码来源:class-itsec-two-factor.php



注:本文中的ITSEC_Lib::get_random方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。