| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/admin-columns-pro.5.1.3/classes/Export/ |
Upload File : |
<?php
namespace ACP\Export;
use AC;
use AC\Registrable;
use ACP\Export\HideOnScreen;
use ACP\Settings\ListScreen\HideOnScreenCollection;
use Exception;
/**
* Handles general functionality for admin screens
* @since 1.0
*/
class Admin implements Registrable {
/**
* @var ExportDirectory
*/
private $export_dir;
public function __construct( ExportDirectory $export_dir ) {
$this->export_dir = $export_dir;
}
public function register() {
add_action( 'admin_init', [ $this, 'maybe_download_export' ] );
add_action( 'acp/admin/settings/hide_on_screen', [ $this, 'add_hide_on_screen' ], 10, 2 );
}
public function add_hide_on_screen( HideOnScreenCollection $collection, AC\ListScreen $list_screen ) {
if ( $list_screen instanceof ListScreen ) {
$collection->add( new HideOnScreen\Export(), 60 );
}
}
/**
* Check whether a request was sent for downloading an export file, and if so, offer it for
* download (if the user has permission to download it)
* @since 1.0
*/
public function maybe_download_export() {
$export_download = filter_input( INPUT_GET, 'acp-export-download' );
if ( ! $export_download ) {
return;
}
// Base directory for the export file
$fname = md5( get_current_user_id() . $export_download ) . '.csv';
// Final file CSV contents
$content = '';
// Counter for merging the decrypted value of multiple files
$counter = 0;
while ( true ) {
// Construct full file path
$fpath = $this->export_dir->get_path() . $fname;
$fpath .= '-' . $counter . '.csv';
// Check whether the file to load exists
if ( ! file_exists( $fpath ) ) {
if ( $counter === 0 ) {
wp_die( __( 'The requested file does not exist.', 'codepress-admin-columns' ) );
}
break;
}
// Get contents of file
$file_content = file_get_contents( $fpath );
// Decrypt the file contents
try {
$cryptor = new Cryptor();
$key = Utility\Users::get_user_encryption_key();
$result = $cryptor->decrypt( $file_content, $key );
$content .= $result;
} catch ( Exception $e ) {
wp_die( __( 'The requested file could not be processed.', 'codepress-admin-columns' ) );
}
$counter++;
}
$file = new DownloadableFile();
$file->load_content_string( $content );
$prefix = filter_input( INPUT_GET, 'acp-export-filename-prefix', FILTER_SANITIZE_STRING );
if ( $prefix ) {
$prefix .= '-';
}
$file->export( $prefix . 'export-' . current_time( 'Y-m-d' ) . '.csv' );
}
}