HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/cwprads/theme-lang-features-hotfix
#!/bin/bash
# T3O2-10607

function check_arg() {
    ARGNAME=$1
    DEFAULT=$2
    FILE=$3
    if ! grep -qP '^'"$ARGNAME"'="?[^"]+' "$FILE" 2>/dev/null; then
        echo "Fixing $FILE by adding $ARGNAME=$DEFAULT"
        echo "$ARGNAME=$DEFAULT" >> "$FILE"
    fi
}
function panel_hotfixes() {
    # Theme and lang settings missing are causing problems
    (
        check_arg LANGUADMIN en /usr/local/cwp/.conf/cwp.ini
        check_arg LANGUSER en /usr/local/cwp/.conf/cwp.ini
        check_arg ALLUSRLANG 0 /usr/local/cwp/.conf/cwp.ini
        check_arg THEMEADMIN original /usr/local/cwp/.conf/cwp.ini
        check_arg THEME original /usr/local/cwp/.conf/cwp.ini

    )
    # set user language/theme if unset
    for user_conf in /home/*/.conf/cwp.ini; do
    (
        if [[ ! -f "$user_conf" ]]; then
            # empty glob
            continue
        fi
        check_arg LANG en "$user_conf"
        check_arg THEME original "$user_conf"
    )
    done

    if [[ ! -s /usr/local/cwp/.conf/feature.db ]]; then
        # have to do everything ourselves..
        echo "Creating /usr/local/cwp/.conf/feature.db and schema"
        sqlite3 /usr/local/cwp/.conf/feature.db \
        'CREATE TABLE configuration (id INTEGER PRIMARY KEY AUTOINCREMENT,fname STRING,ftype STRING,fmodules STRING,faction STRING);'
    fi
};
panel_hotfixes >> /usr/local/cwp/.conf/.imh-hotfix-T3O2-10607-cwprads