I use cwppro with a custom codeEditor.php I created: https://github.com/JosephChuks/cwp-codeEditor
as I find the default codeEditor not up to what I want.
I changed it for admin and user respectively: /usr/local/cwpsrv/htdocs/admin/admin/codeEditor.php
and /usr/local/cwpsrv/var/services/users/codeEditor.php
and it has been working fine until the recent cwppro update. Although I created a script to overwrite the default cwppro codeEditor.php any time there's an update:
#!/bin/bash
# Paths
ORIGINAL_FILES_ADMIN="/usr/local/cwpsrv/htdocs/admin/admin/codeEditor.php"
ORIGINAL_FILES_USER="/usr/local/cwpsrv/var/services/users/codeEditor.php"
CUSTOM_FILE="/root/codeEditor.php"
# Log file
LOG_FILE="/var/log/code_editor_restore.log"
# Function to restore admin file
restore_admin_file() {
local original_file="$1"
if [ ! -f "$original_file" ] || [ "$(stat -c%s "$original_file")" -ne "$(stat -c%s "$CUSTOM_FILE")" ]; then
echo "$(date) - $original_file was overwritten. Restoring custom version." >> "$LOG_FILE"
cp "$CUSTOM_FILE" "$original_file"
chown root:root "$original_file"
chmod 644 "$original_file"
fi
}
# Function to restore user file
restore_user_file() {
local original_file="$1"
if [ ! -f "$original_file" ] || [ "$(stat -c%s "$original_file")" -ne "$(stat -c%s "$CUSTOM_FILE")" ]; then
echo "$(date) - $original_file was overwritten. Restoring custom version." >> "$LOG_FILE"
cp "$CUSTOM_FILE" "$original_file"
chown cwpsvc:cwpsvc "$original_file"
chmod 644 "$original_file"
fi
}
# Restore files
restore_admin_file "$ORIGINAL_FILES_ADMIN"
restore_user_file "$ORIGINAL_FILES_USER"
The script works fine as it did the job of overwriting the default codeEditor after the update for user: /usr/local/cwpsrv/var/services/users/codeEditor.php
but throws a permission error for the admin:
cp: cannot create regular file '/usr/local/cwpsrv/htdocs/admin/admin/codeEditor.php': Operation not permitted
chown: changing ownership of '/usr/local/cwpsrv/htdocs/admin/admin/codeEditor.php': Operation not permitted
chmod: changing permissions of '/usr/local/cwpsrv/htdocs/admin/admin/codeEditor.php': Operation not permitted