HEX
Server: nginx/1.28.1
System: Linux iZgw8b5bpgd4jyptfmmmxgZ 6.6.102-5.2.alnx4.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 27 23:11:10 CST 2025 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: 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
Upload Files
File: /www/wwwroot/www.scdc-marine.com/wp-content/plugins/Static-Html-Output/plugin/deployers/FTP.php
<?php

class WP2Static_FTP extends WP2Static_SitePublisher {
    public function __construct() {
        $this->loadSettings( 'ftp' );
        $this->previous_hashes_path = $this->settings[ 'wp_uploads_path' ] . '/WP2STATIC-FTP-PREVIOUS-HASHES.txt';
        if ( defined( 'WP_CLI' ) ) {
            return;
        }
        switch ( $_POST[ 'ajax_action' ] ) {
            case 'ftp_prepare_export': $this->bootstrap();
            $this->loadArchive();
            $this->prepareDeploy();
            break;
            case 'ftp_transfer_files': $this->bootstrap();
            $this->loadArchive();
            $this->upload_files();
            break;
            case 'test_ftp': $this->test_ftp();
            break;
        }
    }

    public function upload_files() {
        $this->files_remaining = $this->getRemainingItemsCount();
        if ( $this->files_remaining < 0 ) {
            echo 'ERROR';
            die();
        }
        $this->initiateProgressIndicator();
        $batch_size = $this->settings[ 'deployBatchSize' ];
        if ( $batch_size > $this->files_remaining ) {
            $batch_size = $this->files_remaining;
        }
        $lines = $this->getItemsToDeploy( $batch_size );
        $this->openPreviousHashesFile();
        require_once __DIR__ . '/../FTP/FtpClient.php';
        require_once __DIR__ . '/../FTP/FtpException.php';
        require_once __DIR__ . '/../FTP/FtpWrapper.php';
        $this->ftp = new \FtpClient\FtpClient();
        $port = isset( $this->settings[ 'ftpPort' ] ) ? $this->settings[ 'ftpPort' ] : 21;
        $use_ftps = isset( $this->settings[ 'ftpTLS' ] );
        $this->ftp->connect( $this->settings[ 'ftpServer' ], $use_ftps, $port );
        $this->ftp->login( $this->settings[ 'ftpUsername' ], $this->settings[ 'ftpPassword' ] );
        if ( isset( $this->settings[ 'activeFTP' ] ) ) {
            $this->ftp->pasv( false );
        } else {
            $this->ftp->pasv( true );
        }
        foreach ( $lines as $line ) {
            list( $this->local_file, $this->target_path ) = explode( ',', $line );
            $this->local_file = $this->archive->path . $this->local_file;
            if ( ! is_file( $this->local_file ) ) {
                continue;
            }
            if ( isset( $this->settings[ 'ftpRemotePath' ] ) ) {
                $this->target_path = $this->settings[ 'ftpRemotePath' ] . '/' . $this->target_path;
            }
            $this->local_file_contents = file_get_contents( $this->local_file );
            $this->hash_key = $this->target_path . basename( $this->local_file );
            if ( isset( $this->file_paths_and_hashes[ $this->hash_key ] ) ) {
                $prev = $this->file_paths_and_hashes[ $this->hash_key ];
                $current = crc32( $this->local_file_contents );
                if ( $prev != $current ) {
                    $this->putFileViaFTP();
                }
            } else {
                $this->putFileViaFTP();
            }
            $this->recordFilePathAndHashInMemory( $this->hash_key, $this->local_file_contents );
            $this->updateProgress();
        }
        unset( $this->ftp );
        $this->writeFilePathAndHashesToFile();
        $this->pauseBetweenAPICalls();
        if ( $this->uploadsCompleted() ) {
            $this->finalizeDeployment();
        }
    }

    public function test_ftp() {
        require_once __DIR__ . '/../FTP/FtpClient.php';
        require_once __DIR__ . '/../FTP/FtpException.php';
        require_once __DIR__ . '/../FTP/FtpWrapper.php';
        $this->ftp = new \FtpClient\FtpClient();
        $port = isset( $this->settings[ 'ftpPort' ] ) ? $this->settings[ 'ftpPort' ] : 21;
        $use_ftps = isset( $this->settings[ 'ftpTLS' ] );
        $this->ftp->connect( $this->settings[ 'ftpServer' ], $use_ftps, $port );
        try {
            $this->ftp->login( $this->settings[ 'ftpUsername' ], $this->settings[ 'ftpPassword' ] );
            if ( ! defined( 'WP_CLI' ) ) {
                echo 'SUCCESS';
            }
            unset( $this->ftp );
            return;
        } catch ( Exception $e ) {
            unset( $this->ftp );
            $this->handleException( $e );
        }
    }

    public function putFileViaFTP() {
        if ( ! $this->ftp->isdir( $this->target_path ) ) {
            $mkdir_result = $this->ftp->mkdir( $this->target_path, true );
        }
        $this->ftp->chdir( $this->target_path );
        $this->ftp->putFromPath( $this->local_file );
        $this->ftp->chdir( '/' );
    }
}
$ftp = new WP2Static_FTP();