Uname:Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64

403WebShell
403Webshell
Server IP : 188.114.96.2  /  Your IP : 104.23.197.231
Web Server : Apache/2.4.59 (Debian)
System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : edlftp ( 1002)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/nicolasj/www/blog.ecoledelangues.be/wp-content/plugins/redirection/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/nicolasj/www/blog.ecoledelangues.be/wp-content/plugins/redirection/models/flusher.php
<?php

class Red_Flusher {
	const DELETE_HOOK = 'redirection_log_delete';
	const DELETE_FREQ = 'daily';
	const DELETE_MAX = 3000;
	const DELETE_KEEP_ON = 10;  // 10 minutes

	public function flush() {
		$options = red_get_options();

		$total  = $this->expire_logs( 'redirection_logs', $options['expire_redirect'] );
		$total += $this->expire_logs( 'redirection_404', $options['expire_404'] );

		if ( $total >= self::DELETE_MAX ) {
			$next = time() + ( self::DELETE_KEEP_ON * 60 );

			// There are still more logs to clear - keep on doing until we're clean or until the next normal event
			if ( $next < wp_next_scheduled( self::DELETE_HOOK ) ) {
				wp_schedule_single_event( $next, self::DELETE_HOOK );
			}
		}

		$this->optimize_logs();
	}

	private function optimize_logs() {
		global $wpdb;

		$rand = wp_rand( 1, 5000 );

		if ( $rand === 11 ) {
			$wpdb->query( "OPTIMIZE TABLE {$wpdb->prefix}redirection_logs" );
		} elseif ( $rand === 12 ) {
			$wpdb->query( "OPTIMIZE TABLE {$wpdb->prefix}redirection_404" );
		}
	}

	private function expire_logs( $table, $expiry_time ) {
		global $wpdb;

		if ( $expiry_time > 0 ) {
			$logs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}{$table} WHERE created < DATE_SUB(NOW(), INTERVAL %d DAY)", $expiry_time ) );

			if ( $logs > 0 ) {
				$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}{$table} WHERE created < DATE_SUB(NOW(), INTERVAL %d DAY) LIMIT %d", $expiry_time, self::DELETE_MAX ) );
				return min( self::DELETE_MAX, $logs );
			}
		}

		return 0;
	}

	public static function schedule() {
		$options = red_get_options();

		if ( $options['expire_redirect'] > 0 || $options['expire_404'] > 0 ) {
			if ( ! wp_next_scheduled( self::DELETE_HOOK ) ) {
				wp_schedule_event( time(), self::DELETE_FREQ, self::DELETE_HOOK );
			}
		} else {
			Red_Flusher::clear();
		}
	}

	public static function clear() {
		wp_clear_scheduled_hook( self::DELETE_HOOK );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit