. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ class Ai1wm_Backups_Controller { public static function index() { $model = new Ai1wm_Backups; Ai1wm_Template::render( 'backups/index', array( 'backups' => $model->get_files(), 'username' => get_option( AI1WM_AUTH_USER ), 'password' => get_option( AI1WM_AUTH_PASSWORD ), ) ); } public static function delete( $params = array() ) { $errors = array(); // Set params if ( empty( $params ) ) { $params = stripslashes_deep( $_POST ); } // Set secret key $secret_key = null; if ( isset( $params['secret_key'] ) ) { $secret_key = trim( $params['secret_key'] ); } // Set archive $archive = null; if ( isset( $params['archive'] ) ) { $archive = trim( $params['archive'] ); } try { // Ensure that unauthorized people cannot access delete action ai1wm_verify_secret_key( $secret_key ); } catch ( Ai1wm_Not_Valid_Secret_Key_Exception $e ) { exit; } $model = new Ai1wm_Backups; try { // Delete file $model->delete_file( $archive ); } catch ( Exception $e ) { $errors[] = $e->getMessage(); } echo json_encode( array( 'errors' => $errors ) ); exit; } }