Because cats have 9 lives, but servers don't - so they need backup-restore! Complete backup solution with S3/MinIO support. - Full WordPress backup (files + database) - S3 / MinIO / S3-compatible storage backends - Scheduled automatic backups - Disaster recovery / one-click restore - Backup integrity validation - Cat-themed admin interface Includes build.sh and .distignore for WordPress-installable release ZIPs.
124 lines
3.1 KiB
PHP
124 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* TigerStyle Life9 Sanitizer Class
|
|
*
|
|
* Input sanitization and validation utilities
|
|
*
|
|
* @package TigerStyleLife9
|
|
* @subpackage Security
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* TigerStyle Life9 Input Sanitizer
|
|
*
|
|
* Handles all input sanitization with cat-themed error messages
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
class TigerStyle_Life9_Sanitizer {
|
|
|
|
/**
|
|
* Sanitize text input
|
|
*
|
|
* @param string $input Input to sanitize
|
|
* @return string Sanitized input
|
|
*/
|
|
public static function sanitize_text($input) {
|
|
return sanitize_text_field($input);
|
|
}
|
|
|
|
/**
|
|
* Sanitize email input
|
|
*
|
|
* @param string $email Email to sanitize
|
|
* @return string Sanitized email
|
|
*/
|
|
public static function sanitize_email($email) {
|
|
return sanitize_email($email);
|
|
}
|
|
|
|
/**
|
|
* Sanitize URL input
|
|
*
|
|
* @param string $url URL to sanitize
|
|
* @return string Sanitized URL
|
|
*/
|
|
public static function sanitize_url($url) {
|
|
return esc_url_raw($url);
|
|
}
|
|
|
|
/**
|
|
* Sanitize filename
|
|
*
|
|
* @param string $filename Filename to sanitize
|
|
* @return string Sanitized filename
|
|
*/
|
|
public static function sanitize_filename($filename) {
|
|
return sanitize_file_name($filename);
|
|
}
|
|
|
|
/**
|
|
* Sanitize backup configuration
|
|
*
|
|
* @param array $config Configuration array
|
|
* @return array Sanitized configuration
|
|
*/
|
|
public static function sanitize_backup_config($config) {
|
|
$sanitized = [];
|
|
|
|
// Sanitize each field
|
|
if (isset($config['name'])) {
|
|
$sanitized['name'] = self::sanitize_text($config['name']);
|
|
}
|
|
|
|
if (isset($config['description'])) {
|
|
$sanitized['description'] = sanitize_textarea_field($config['description']);
|
|
}
|
|
|
|
if (isset($config['include_files'])) {
|
|
$sanitized['include_files'] = (bool) $config['include_files'];
|
|
}
|
|
|
|
if (isset($config['include_database'])) {
|
|
$sanitized['include_database'] = (bool) $config['include_database'];
|
|
}
|
|
|
|
if (isset($config['encryption_enabled'])) {
|
|
$sanitized['encryption_enabled'] = (bool) $config['encryption_enabled'];
|
|
}
|
|
|
|
if (isset($config['storage_backend'])) {
|
|
$allowed_backends = ['local', 's3', 'google_drive'];
|
|
$sanitized['storage_backend'] = in_array($config['storage_backend'], $allowed_backends)
|
|
? $config['storage_backend']
|
|
: 'local';
|
|
}
|
|
|
|
return $sanitized;
|
|
}
|
|
|
|
/**
|
|
* Sanitize path input
|
|
*
|
|
* @param string $path Path to sanitize
|
|
* @return string Sanitized path
|
|
*/
|
|
public static function sanitize_path($path) {
|
|
// Remove directory traversal attempts
|
|
$path = str_replace(['../', '..\\'], '', $path);
|
|
|
|
// Remove null bytes
|
|
$path = str_replace("\0", '', $path);
|
|
|
|
// Normalize slashes
|
|
$path = str_replace('\\', '/', $path);
|
|
|
|
return $path;
|
|
}
|
|
} |