示例#1
0
 //**************************************************************************
 if (!defined('CAT_LOGIN_PHASE')) {
     $path = isset($_SERVER['SCRIPT_FILENAME']) ? CAT_Helper_Directory::sanitizePath($_SERVER['SCRIPT_FILENAME']) : NULL;
     if ($path) {
         $check = str_replace('/', '\\/', CAT_Helper_Directory::sanitizePath(CAT_ADMIN_PATH));
         if (preg_match('~^' . $check . '~i', $path)) {
             define('CAT_REQUIRE_ADMIN', true);
             if (!CAT_Users::getInstance()->is_authenticated()) {
                 CAT_Users::getInstance()->handleLogin();
                 exit(0);
             }
             // always enable CSRF protection in backend; does not work with
             // AJAX so scripts called via AJAX should set this constant
             if (!defined('CAT_AJAX_CALL')) {
                 //echo "class.secure is calling enableCSRFMagic<br />";
                 CAT_Helper_Protect::getInstance()->enableCSRFMagic();
             }
             global $parser;
             if (!is_object($parser)) {
                 $parser = CAT_Helper_Template::getInstance('Dwoo');
             }
             // initialize template search path
             $parser->setPath(CAT_THEME_PATH . '/templates');
             $parser->setFallbackPath(CAT_THEME_PATH . '/templates');
         }
     } else {
         define('CAT_REQUIRE_ADMIN', false);
     }
 }
 if (!defined('CAT_INITIALIZED')) {
     require dirname(__FILE__) . '/initialize.php';
示例#2
0
// ! Get perms
// =============
if (CAT_Helper_Page::getPagePermission($page_id, 'admin') !== true) {
    $backend->print_error('You do not have permissions to modify this page!');
}
// =================
// ! Get new content
// =================
$content = $val->sanitizePost('content' . $section_id);
// for non-admins only
if (!CAT_Users::getInstance()->ami_group_member(1)) {
    // if HTMLPurifier is enabled...
    $r = $backend->db()->get_one('SELECT * FROM `' . CAT_TABLE_PREFIX . 'mod_wysiwyg_admin_v2` WHERE set_name="enable_htmlpurifier" AND set_value="1"');
    if ($r) {
        // use HTMLPurifier to clean up the output
        $content = CAT_Helper_Protect::getInstance()->purify($content, array('Core.CollectErrors' => true));
    }
} else {
    $content = $val->add_slashes($content);
}
/**
 *	searching in $text will be much easier this way
 */
$text = umlauts_to_entities(strip_tags($content), strtoupper(DEFAULT_CHARSET), 0);
/**
 *  save
 **/
$query = "REPLACE INTO `" . CAT_TABLE_PREFIX . "mod_wysiwyg` VALUES ( '{$section_id}', {$page_id}, '{$content}', '{$text}' );";
$backend->db()->query($query);
if ($backend->db()->isError()) {
    trigger_error(sprintf('[%s - %s] %s', __FILE__, __LINE__, $backend->db()->getError()), E_USER_ERROR);