Skip to content

Latest commit

Β 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ SuperFast cPanel File Mover (v2.0)

A production-ready, single-file PHP application for secure, high-performance FTP file transfers with real-time progress tracking and a modern web interface.

Transfer files directly from one cPanel to another using FTP - no need to zip, download, upload, and extract!

✨ What's New in v2.0

  • πŸ—„οΈ SQLite Storage - All data stored in embedded SQLite database (no external JSON files)
  • πŸ“ Simplified Login - Only 3 fields: FTP Host, Username, Password
  • πŸ“ Working File Browser - Fixed file listing after login
  • 🎯 Clear Transfer Button - Shows count of selected files
  • πŸ” Real-time Search - Filter files as you type
  • πŸ“Š Better Logs - View transfer logs directly in the UI
  • ❌ Better Errors - Specific, actionable error messages

✨ Features

πŸ—„οΈ Storage

  • SQLite Database - All data stored in cpanel_data.db (single file)
  • No External Files - No more users.json, encryption.key, transfers.log
  • Automatic Setup - Database created automatically on first run

πŸ”’ Security

  • HTTPS Enforcement - Strict HTTPS requirement for all connections
  • Session-based Authentication - Secure session management with 30-minute timeout
  • CSRF Protection - Token-based CSRF prevention
  • Path Traversal Prevention - Comprehensive path sanitization and validation
  • Encrypted Credentials - AES-256-CBC encryption for stored credentials
  • Input Validation - Strict validation for all user inputs

πŸš„ Performance

  • Non-blocking Transfers - Uses ftp_nb_fget() for asynchronous operations
  • Parallel Processing - Up to 3 concurrent transfers (when pcntl available)
  • Chunked Streaming - 2MB chunks to minimize memory usage
  • Persistent Connections - Reuse FTP connections for multiple operations
  • Memory Efficient - Operates under 128MB memory limit

πŸ“Š Progress Tracking

  • Real-time Updates - Live progress bars with 2-second polling
  • Speed Calculation - Accurate transfer speed in MB/s
  • ETA Display - Intelligent time-remaining estimates
  • Overall Statistics - Track total, completed, in-progress, and pending files
  • Per-file Status - Individual progress for each transfer

πŸ“ Logging

  • JSON Format - Structured logs with timestamps (ISO 8601)
  • Comprehensive Data - Tracks paths, sizes, duration, checksums, errors
  • Automatic Rotation - Rotates logs when exceeding 10MB
  • Web Viewer - View recent logs directly in the UI

🎨 Modern UI

  • Responsive Design - Mobile-first, works on all devices
  • Tree View Browser - Expandable folder structure
  • Cascade Selection - Select folders to auto-select all children
  • Search Functionality - Filter files in real-time
  • Toast Notifications - Non-intrusive status messages
  • Smooth Animations - Professional transitions and effects

πŸ“‹ Requirements

  • PHP 7.4+ (PHP 8.0+ recommended)
  • FTP Extension - ext-ftp enabled
  • OpenSSL Extension - For encryption
  • Optional: pcntl extension for parallel transfers

πŸš€ Quick Start

  1. Download the file:

    git clone https://github.com/yourusername/cpanel_web_transfer.git
    cd cpanel_web_transfer
  2. Upload to your web server (via FTP, SCP, or control panel)

  3. Set permissions:

    chmod 644 cpanel.php
  4. Access via browser:

    https://your-domain.com/path/to/cpanel.php
    
  5. First-time setup:

    • On first access, you'll see a setup form
    • Create your admin username and password
    • This account will be used to access the application
  6. Login and transfer:

    • Enter your application credentials (username/password)
    • Enter FTP credentials for the source server
    • Select destination path on current server
    • Browse files, select what you want
    • Click "Start Transfer"!

πŸ”§ Configuration

Automatic Setup

The application now uses session-based authentication with automatic setup:

  • No manual configuration required - credentials are set up on first use
  • Encryption key is automatically generated and stored securely
  • User accounts are stored in users.json with Argon2ID password hashing

Performance Settings

define('MAX_PARALLEL', 3); // Number of concurrent transfers
define('CHUNK_SIZE', 2097152); // Transfer chunk size (2MB default)
define('SESSION_TIMEOUT', 1800); // Session timeout in seconds (30 minutes)

File Paths

define('LOG_FILE', __DIR__ . '/transfers.log'); // Log file location
define('PROGRESS_FILE', __DIR__ . '/progress.json'); // Progress tracking file
define('MAX_LOG_SIZE', 10485760); // Log rotation threshold (10MB)
define('USERS_FILE', __DIR__ . '/users.json'); // User accounts storage
define('ENCRYPTION_KEY_FILE', __DIR__ . '/encryption.key'); // Encryption key storage

πŸ“– Usage Guide

1. First-Time Setup

  • On first access, you'll be prompted to create an admin account
  • Enter a username (at least 3 characters, letters/numbers/underscores)
  • Enter a strong password (at least 8 characters)
  • This account will be used to access the application

2. Login

  • If first time, create admin account with username and password
  • FTP Host: Your FTP server address (e.g., ftp.example.com)
  • FTP Username: Your FTP account username
  • FTP Password: Your FTP account password
  • Remote path is always / (FTP root)
  • Local path is automatically set to where cpanel.php is located

3. Browse Files

  • Files are loaded immediately after successful FTP login
  • Click folder names to navigate into directories
  • Use search box to filter files in real-time
  • Check boxes to select files for transfer
  • Selecting a folder selects that folder (not contents automatically)

4. Start Transfer

  • Click "Copy X Selected File(s)" button after selecting files
  • Monitor real-time progress in the Progress section
  • View transfer status and completion percentage
  • Check logs for completed transfers and any errors

5. View Logs

  • All transfers are logged to the SQLite database
  • Click "Refresh Logs" to see the latest activity
  • Logs include timestamp, action, file path, size, and status

πŸ›‘οΈ Security Best Practices

  1. Strong Passwords

    • Use a strong application password (8+ characters minimum)
    • Passwords are hashed using Argon2ID (industry standard)
  2. HTTPS Only

    • Always use HTTPS in production
    • The application enforces HTTPS (except on localhost)
  3. File Permissions

    chmod 644 cpanel.php       # Read-only for web server
    chmod 600 cpanel_data.db   # Private database file

πŸ› Troubleshooting

"HTTPS required for security"

  • Ensure you're accessing via https:// protocol
  • Check SSL certificate is valid
  • Localhost/127.0.0.1 are exempt from this check

"Could not connect to FTP server"

  • Verify FTP host address is correct
  • Check firewall rules allow outbound FTP (port 21)
  • Ensure FTP server is accessible from web server

"FTP login failed"

  • Verify FTP username and password
  • Check account hasn't been locked
  • Ensure FTP service is running

"Insufficient disk space"

  • Free up space on the destination drive
  • Check available space: df -h
  • Verify write permissions on destination directory

πŸ“Š Performance Tuning

For Faster Transfers

define('MAX_PARALLEL', 5); // Increase concurrent transfers
define('CHUNK_SIZE', 4194304); // Use 4MB chunks

For Limited Memory

define('MAX_PARALLEL', 1); // Sequential transfers only
define('CHUNK_SIZE', 1048576); // Use 1MB chunks

Enable Parallel Processing

Install the pcntl extension for true parallel transfers:

# Ubuntu/Debian
sudo apt-get install php-pcntl

# CentOS/RHEL
sudo yum install php-pcntl

# Verify
php -m | grep pcntl

πŸ” API Endpoints

The application provides several JSON API endpoints:

POST ?action=login

Authenticate and establish FTP connection.

GET ?action=browse&path=/

List directory contents.

POST ?action=transfer

Start file transfer.

GET ?action=progress

Get transfer progress.

GET ?action=logs

Retrieve transfer logs.

POST ?action=logout

End session and clear credentials.

🌟 Features Summary

βœ… Single-file application (no dependencies)
βœ… Production-ready security
βœ… Real-time progress tracking
βœ… Parallel transfers (up to 3 concurrent)
βœ… Non-blocking operations
βœ… Atomic file writes
βœ… SHA256 checksums
βœ… Automatic log rotation
βœ… Responsive modern UI
βœ… Mobile-friendly
βœ… Search and filter
βœ… Cascade selection
βœ… Toast notifications
βœ… Comprehensive error handling
βœ… Retry logic with exponential backoff
βœ… Memory efficient (< 128MB)
βœ… CSRF protection
βœ… Encrypted session storage
βœ… Path traversal prevention
βœ… Session timeout

πŸ“„ License

MIT License - Free to use and modify for personal and commercial projects.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Made with ❀️ for the PHP community

About

Direct cPanel-to-cPanel FTP file transfer tool with real-time progress tracking and secure streaming.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages