Ejemplo n.º 1
0
    }
}
$backend = CAT_Backend::getInstance('Settings', 'settings', false);
$users = CAT_Users::getInstance();
header('Content-type: application/json');
if (!$users->checkPermission('Settings', 'settings')) {
    $ajax = array('message' => $backend->lang()->translate("Sorry, but you don't have the permissions for this action"), 'success' => false);
    print json_encode($ajax);
    exit;
}
require_once dirname(__FILE__) . '/../../config.php';
require_once dirname(__FILE__) . '/functions.php';
$settings = CAT_Registry::getSettings();
$region = CAT_Helper_Validate::get('_REQUEST', 'template');
$tpl = 'backend_settings_index_' . $region . '.tpl';
$data = getSettingsTable();
$tpl_data = array('values' => $data);
$tpl_data['DISPLAY_ADVANCED'] = $users->checkPermission('Settings', 'settings_advanced');
switch ($region) {
    case 'frontend':
        $tpl_data['templates'] = getTemplateList('frontend');
        $tpl_data['variants'] = array();
        $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_TEMPLATE'));
        if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) {
            $tpl_data['variants'] = $info['module_variants'];
        }
        break;
    case 'backend':
        $tpl_data['backends'] = getTemplateList('backend');
        $tpl_data['wysiwyg'] = CAT_Helper_Addons::get_addons(CAT_Registry::get('WYSIWYG_EDITOR'), 'module', 'wysiwyg');
        $tpl_data['variants'] = array();
Ejemplo n.º 2
0
/**
 *
 **/
function saveSettings($settings)
{
    global $database, $err_msg;
    global $groups, $allow_tags_in_fields, $allow_empty_values, $boolean, $numeric;
    $old_settings = getSettingsTable();
    foreach ($settings as $key => $value) {
        $value = trim($value);
        // allow HTML?
        if (!in_array($key, $allow_tags_in_fields)) {
            $value = strip_tags($value);
        }
        // check boolean
        if (in_array($key, $boolean)) {
            $value = !$value || $value == 'false' || $value == '' ? 'false' : 'true';
        }
        // check numeric
        if (in_array($key, $numeric)) {
            if (!is_numeric($value)) {
                continue;
            }
        }
        // suppress errors if no old setting
        if (!isset($old_settings[$key])) {
            $old_settings[$key] = '';
        }
        // function for this special item?
        if (function_exists('check_' . $key)) {
            $func = 'check_' . $key;
            $value = $func($value, $old_settings[$key]);
        }
        if ($value !== '' || in_array($key, $allow_empty_values)) {
            $check = $database->query('SELECT `value` FROM `:prefix:settings` WHERE `name`=:name', array('name' => $key));
            if (!$check->numRows()) {
                $database->query('INSERT INTO `:prefix:settings` VALUES ( NULL, :name, :value )', array('value' => $value, 'name' => $key));
            } else {
                $database->query('UPDATE `:prefix:settings` SET `value`=:value WHERE `name`=:name', array('value' => $value, 'name' => $key));
            }
            if ($database->is_error()) {
                $err_msg[] = CAT_Users::getInstance()->lang()->translate('Unable to save setting [{{ setting }}] - error {{ error }}', array('setting' => $key, 'error' => $database->get_error()));
            }
        }
    }
}
Ejemplo n.º 3
0
    $root = "../";
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= "../";
        $level += 1;
    }
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
$user = CAT_Users::getInstance();
$backend = CAT_Backend::getInstance('Settings', 'settings_advanced');
global $parser;
$tpl_data = array();
// include local functions file
require_once dirname(__FILE__) . '/functions.php';
// template for default tab (SEO settings)
$tpl = 'backend_settings_index_seo';
// add default form
$tpl_data['INDEX'] = $parser->get($tpl, array('values' => getSettingsTable()));
$tpl_data['MAINTENANCE_MODE'] = CAT_Registry::get('MAINTENANCE_MODE');
// ====================
// ! Parse the site
// ====================
$parser->output('backend_settings_index', $tpl_data);
// ======================
// ! Print admin footer
// ======================
$backend->print_footer();