The deployX update maker is a PHP-based utility designed to manage updates for any web software. It performs the following tasks:
- Verifies the existence of necessary files before proceeding with the update process.
- Compares file changes between an original and modified directory.
- Generates a list of modified or new files.
- Downloads and extracts updates from a remote JSON configuration file.
- Handles patch files, changelogs, and directory cleanup.
- Creates a ZIP archive for the updates.
Configuration
File Structure
- ignore.txt: Contains patterns of files to ignore during processing.
- changelog.html: A file containing details about the update.
- patch.php: A file optionally used for SQL updates.
- updates/: Directory for storing update-related files.
Dependencies
- PHP 7.4 or higher.
- cURL extension for downloading remote files.
- ZipArchive class for handling ZIP operations.
Main Functionalities
File Verification
Ensures that required files (changelog.html
and ignore.txt
) exist before continuing.
File Comparison
Compares files between two directories (phpix-old and phpix) by hashing normalized content. Modified and new files are saved to modified_files.txt.
Update Process
- Downloads update metadata from a remote JSON file.
- Handles patch file processing, including creation if missing.
- Downloads, extracts, and merges updates based on the JSON metadata.
Output Generation
- Creates a phpix-info.php file containing version and metadata details.
- Archives the updates directory into a ZIP file.
- Deletes temporary files to ensure a clean directory structure.
Key Functions
delay
function delay($seconds = 1) { sleep($seconds); }
Simulates a delay to manage output flow.
getNormalizedFileHashes
function getNormalizedFileHashes($dir, $ignorePatterns) { // Logic for hashing files after normalizing content }
Recursively hashes files in a directory while ignoring specified patterns.
shouldIgnore
function shouldIgnore($filePath, $patterns) { // Logic to match file paths against ignore patterns }
Determines if a file should be ignored based on wildcard patterns.
deleteDirectoryContents
function deleteDirectoryContents($dir) { // Recursively deletes all files and directories within the specified folder }
Error Handling
- Displays detailed error messages for missing files, failed operations, or invalid inputs.
- Ensures that the script exits gracefully on critical failures.
Execution Notes
Ensure the following before running the script:
- The phpix-old and phpix directories are correctly structured.
- Permissions are set to allow file read/write operations.
- All dependencies (cURL, ZipArchive) are available.