255) { $errors[] = __('🙀 Backup name too long! Keep it shorter than a cat\'s attention span (255 characters).', 'tigerstyle-life9'); } if (preg_match('/[<>:"/\\|?*]/', $name)) { $errors[] = __('🙀 Invalid characters in backup name! Cats prefer simple, clean names.', 'tigerstyle-life9'); } return [ 'valid' => empty($errors), 'errors' => $errors ]; } /** * Validate file path * * @param string $path File path to validate * @return array Validation result */ public static function validate_file_path($path) { $errors = []; if (empty($path)) { $errors[] = __('🙀 File path cannot be empty! Cats need to know where things are.', 'tigerstyle-life9'); } if (strpos($path, '..') !== false) { $errors[] = __('🙀 Path traversal detected! This cat is too clever for such tricks.', 'tigerstyle-life9'); } if (strpos($path, '\0') !== false) { $errors[] = __('🙀 Null bytes detected in path! Sneaky, but this cat sees everything.', 'tigerstyle-life9'); } return [ 'valid' => empty($errors), 'errors' => $errors ]; } /** * Validate email address * * @param string $email Email to validate * @return array Validation result */ public static function validate_email($email) { $errors = []; if (empty($email)) { $errors[] = __('🙀 Email address cannot be empty! How will the cat send notifications?', 'tigerstyle-life9'); } elseif (!is_email($email)) { $errors[] = __('🙀 Invalid email address! Cats are picky about proper formatting.', 'tigerstyle-life9'); } return [ 'valid' => empty($errors), 'errors' => $errors ]; } /** * Validate backup configuration * * @param array $config Configuration to validate * @return array Validation result */ public static function validate_backup_config($config) { $errors = []; // Validate backup name if (isset($config['name'])) { $name_validation = self::validate_backup_name($config['name']); if (!$name_validation['valid']) { $errors = array_merge($errors, $name_validation['errors']); } } // Validate storage backend if (isset($config['storage_backend'])) { $allowed_backends = ['local', 's3', 'google_drive']; if (!in_array($config['storage_backend'], $allowed_backends)) { $errors[] = __('🙀 Invalid storage backend! This cat only knows local, S3, and Google Drive territories.', 'tigerstyle-life9'); } } // Validate that at least one backup type is selected $include_files = isset($config['include_files']) ? (bool) $config['include_files'] : false; $include_database = isset($config['include_database']) ? (bool) $config['include_database'] : false; if (!$include_files && !$include_database) { $errors[] = __('🙀 You must select at least files or database! Cats need something to backup.', 'tigerstyle-life9'); } return [ 'valid' => empty($errors), 'errors' => $errors ]; } }