function wptouch_backup_settings()
{
    global $wptouch_pro;
    $backup_domains = $wptouch_pro->get_active_setting_domains();
    if (is_array($backup_domains) && count($backup_domains)) {
        $settings_to_save = array();
        foreach ($backup_domains as $domain) {
            $settings_notused = wptouch_get_settings($domain);
            $settings = $wptouch_pro->settings_objects[$domain];
            if (isset($settings->domain)) {
                unset($settings->domain);
            }
            $settings_to_save[$domain] = apply_filters('wptouch_backup_settings', $settings, $domain);
        }
        ksort($settings_to_save);
        $backup_string = base64_encode(gzcompress(serialize($settings_to_save), 9));
        $backup_base_name = 'wptouch-backup-' . date('Ymd-His') . '.txt';
        $backup_file_name = WPTOUCH_BACKUP_DIRECTORY . '/' . $backup_base_name;
        $backup_file = fopen($backup_file_name, 'w+t');
        if ($backup_file) {
            fwrite($backup_file, $backup_string);
            fclose($backup_file);
        }
    }
    wptouch_prune_backup_files();
    return $backup_base_name;
}
function wptouch_backup_settings()
{
    global $wptouch_pro;
    $backup_domains = $wptouch_pro->get_active_setting_domains();
    if (is_array($backup_domains) && count($backup_domains)) {
        $settings_to_save = array();
        foreach ($backup_domains as $domain) {
            $settings_notused = wptouch_get_settings($domain);
            $settings = clone $wptouch_pro->settings_objects[$domain];
            if (isset($settings->domain)) {
                unset($settings->domain);
            }
            $settings_to_save[$domain] = apply_filters('wptouch_backup_settings', $settings, $domain);
        }
        if (isset($settings_to_save['bncid'])) {
            if (isset($settings_to_save['bncid']->wptouch_license_key)) {
                //unset( $settings_to_save[ 'bncid' ]->wptouch_license_key );
            }
            if (isset($settings_to_save['bncid']->bncid)) {
                //unset( $settings_to_save[ 'bncid' ]->bncid );
            }
        }
        ksort($settings_to_save);
        $backup_string = base64_encode(gzcompress(serialize($settings_to_save), 9));
        $unique_key = '';
        if (isset($bnc_settings->license_key)) {
            $unique_key = $bnc_settings->license;
        } else {
            if (defined('AUTH_KEY')) {
                $unique_key = AUTH_KEY;
            }
        }
        $backup_base_name = 'wptouch-backup-' . md5($unique_key) . '-' . date('Ymd-His') . '.txt';
        $backup_file_name = WPTOUCH_BACKUP_DIRECTORY . '/' . $backup_base_name;
        $backup_file = fopen($backup_file_name, 'w+t');
        if ($backup_file) {
            fwrite($backup_file, $backup_string);
            fclose($backup_file);
        }
    }
    wptouch_prune_backup_files();
    return $backup_base_name;
}