Пример #1
0
/**
 * execute registered filters
 *
 * @param  reference $content
 * @return void
 **/
function executeFilters(&$content)
{
    // get active filters
    $res = CAT_Helper_Page::getInstance()->db()->query('SELECT * FROM `:prefix:mod_filter` WHERE filter_active=:active', array('active' => 'Y'));
    if (is_object($res) && $res->numRows()) {
        $filter = array();
        while (false !== ($row = $res->fetch())) {
            $filter[] = $row;
        }
        foreach ($filter as $f) {
            if ($f['filter_code'] == '' && $f['module_name'] != '') {
                $inc_file = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $f['module_name'] . '/filter/' . $f['filter_name'] . '.php');
                if (file_exists($inc_file)) {
                    include_once $inc_file;
                    $f['filter_name']($content);
                }
            }
        }
    }
    // if we have some JS registered...
    global $_bc_filter_js;
    if (count($_bc_filter_js)) {
        $js = array();
        $dom = new DOMDocument();
        libxml_use_internal_errors(true);
        @$dom->loadHTML($content);
        $h = $dom->getElementsByTagName('head')->item(0);
        if ($h) {
            foreach ($_bc_filter_js as $file) {
                $element = $dom->createElement('script');
                // Creating an empty text node forces <script></script>
                $element->appendChild($dom->createTextNode(''));
                $element->setAttribute('type', 'text/javascript');
                $element->setAttribute('src', $file);
                $h->appendChild($element);
            }
            $content = $dom->saveHTML();
        }
    }
    // onload events
    global $_bc_filter_onload;
    if (count($_bc_filter_onload)) {
        $attach = NULL;
        $listener = NULL;
        foreach ($_bc_filter_onload as $item) {
            $attach .= "    window.attachEvent('onload','{$item}');\n";
            $listener .= "    window.addEventListener('DOMContentLoaded',{$item},false);\n";
        }
        $h = $dom->getElementsByTagName('body')->item(0);
        $element = $dom->createElement('script');
        $element->appendChild($dom->createTextNode("\nif(window.attachEvent) {\n" . $attach . "\n} else {\n" . $listener . "\n}\n"));
        $element->setAttribute('type', 'text/javascript');
        $h->appendChild($element);
        $content = $dom->saveHTML();
    }
}
Пример #2
0
function Dwoo_Plugin_last_modified(Dwoo $dwoo, $page_id = false)
{
    if (is_numeric($page_id)) {
        $sql = "SELECT `modified_when` FROM `:prefix:pages` WHERE `page_id` = :id";
        $t = CAT_Helper_Page::getInstance()->db()->query($sql, array('id' => intval($page_id)))->fetchColumn();
    } else {
        $sql = "SELECT `modified_when` FROM `:prefix:pages` WHERE `visibility`='public' OR `visibility`='hidden' ORDER BY `modified_when` DESC LIMIT 0,1";
        $t = CAT_Helper_Page::getInstance()->db()->query($sql)->fetchColumn();
    }
    return CAT_Helper_DateTime::getDate($t);
}
Пример #3
0
 /**
  * get additions for page header (css, js, meta)
  *
  * This is a wrapper for CAT_Helper_Page->getHeaders()
  *
  * @access public
  * @param  string  $for - 'frontend' (default) / 'backend'
  * @param  boolean $print_output - echo result (default) or return
  * @param  boolean $individual   - JS for individual section (BE only)
  * @return mixed
  *
  **/
 function get_page_headers($for = 'frontend', $print_output = true, $individual = false)
 {
     if (defined('CAT_HEADERS_SENT')) {
         return false;
     }
     global $page_id;
     $output = CAT_Helper_Page::getInstance()->getHeaders($for, $individual);
     if ($print_output) {
         echo $output;
         define('CAT_HEADERS_SENT', true);
     } else {
         return $output;
     }
 }
Пример #4
0
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 *   @author          Black Cat Development
 *   @copyright       2013, Black Cat Development
 *   @link            http://blackcat-cms.org
 * @license         http://www.gnu.org/licenses/gpl.html
 *   @category        CAT_Core
 *   @package         CAT_Core
 *
 */
if (defined('CAT_PATH')) {
    include CAT_PATH . '/framework/class.secure.php';
} else {
    $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);
    }
}
// Get content
$result = CAT_Helper_Page::getInstance()->db()->query("SELECT `content` FROM `" . CAT_TABLE_PREFIX . "mod_wysiwyg` WHERE `section_id` = '" . $section_id . "'");
if ($result && $result->numRows() > 0) {
    $fetch = $result->fetchRow(MYSQL_ASSOC);
    echo $fetch['content'];
}
Пример #5
0
/**
 * this only saves the jQuery core and UI settings, as the plugins are saved
 * at once via AJAX
 **/
function saveHeaderfiles($backend)
{
    $data = CAT_Helper_Page::getExtraHeaderFiles(0);
    if (CAT_Helper_Validate::sanitizePost('use_core') == 'on') {
        $use_core = 'Y';
    } else {
        $use_core = 'N';
    }
    if (CAT_Helper_Validate::sanitizePost('use_ui') == 'on') {
        $use_ui = 'Y';
    } else {
        $use_ui = 'N';
    }
    if (count($data)) {
        $query = 'UPDATE `:prefix:pages_headers` SET `use_core`=:value1, `use_ui`=:value2 WHERE `page_id`=:page_id';
    } else {
        $query = 'INSERT INTO `:prefix:pages_headers` ( `page_id`, `use_core`, `use_ui` ) VALUES ( :page_id, :value1, :value2 )';
    }
    CAT_Helper_Page::getInstance(1)->db()->query($query, array('page_id' => 0, 'value1' => $use_core, 'value2' => $use_ui));
}
Пример #6
0
 *
 */
if (defined('CAT_PATH')) {
    include CAT_PATH . '/framework/class.secure.php';
} else {
    $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);
    }
}
// protect
$backend = CAT_Backend::getInstance('Start', 'start', false, false);
if (!CAT_Users::is_authenticated()) {
    exit;
}
// just to be _really_ sure...
// there's no real need to protect this widget, just to handle all widgets...
$pg = CAT_Helper_Page::getInstance();
$widget_name = $pg->lang()->translate('Maintenance mode');
if (CAT_Registry::get('MAINTENANCE_MODE') == true) {
    echo '<span style="color:#c00;font-weight:900;">', '<span class="icon icon-warning" style="font-size:2em;margin-right:5px;"></span>', $pg->lang()->translate('Please note: The system is in maintenance mode!'), '</span><br /><span style="font-style:italic;margin-left:2.5em;font-size:0.9em;">', $pg->lang()->translate('To disable, go to Settings -> System settings -> Maintenance mode -> set to "off".'), '</span>';
} else {
    echo '<span class="icon icon-checkmark" style="font-size:1.2em;margin-right:5px;"></span>', $pg->lang()->translate('Maintenance mode is off.');
}
Пример #7
0
                // update trail
                $database->query(sprintf("UPDATE `%spages` SET page_trail='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, CAT_Helper_Page::getPageTrail($sub['page_id']), $sub['page_id']));
                // Re-write the access file for this page
                $old_subpage_file = CAT_PATH . PAGES_DIRECTORY . $new_sub_link . PAGE_EXTENSION;
                // remove old file
                if (file_exists($old_subpage_file)) {
                    unlink($old_subpage_file);
                }
                // create new
                CAT_Helper_Page::createAccessFile($new_sub_link, $sub['page_id']);
            }
        }
    }
    // check if source directory is empty now
    $source_dir = pathinfo(CAT_PATH . PAGES_DIRECTORY . $old_link, PATHINFO_DIRNAME);
    if (CAT_Helper_Directory::is_empty($source_dir, true)) {
        CAT_Helper_Directory::removeDirectory($source_dir);
    }
}
// ==============================
// ! Check if there is a db error
// ==============================
if (CAT_Helper_Page::getInstance()->db()->isError()) {
    $ajax = array('message' => CAT_Helper_Page::getInstance()->db()->getError(), 'success' => false);
    print json_encode($ajax);
    exit;
} else {
    $ajax = array('message' => $backend->lang()->translate('Page settings saved successfully'), 'menu_title' => htmlspecialchars_decode($options['menu_title'], ENT_QUOTES), 'page_title' => htmlspecialchars_decode($options['page_title'], ENT_QUOTES), 'visibility' => $options['visibility'], 'parent' => $options['parent'], 'position' => $options['position'], 'success' => true);
    print json_encode($ajax);
    exit;
}
Пример #8
0
            $config[$row['set_name']] = $row['set_value'];
        }
    }
    if (!defined('WYSIWYG_EDITOR') || WYSIWYG_EDITOR == "none" || !file_exists(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php')) {
        function show_wysiwyg_editor($name, $id, $content, $width = '100%', $height = '250px', $print = true)
        {
            $editor = '<textarea name="' . $name . '" id="' . $id . '" style="width: ' . $width . '; height: ' . $height . ';">' . $content . '</textarea>';
            if ($print) {
                echo $editor;
            } else {
                return $editor;
            }
        }
    } else {
        $id_list = array();
        $result = CAT_Helper_Page::getInstance()->db()->query(sprintf("SELECT `section_id` FROM `%ssections` " . "WHERE `page_id`= '%d' AND `module`= 'wysiwyg' " . "ORDER BY position", CAT_TABLE_PREFIX, $page_id));
        if ($result->numRows() > 0) {
            while (!false == ($wysiwyg_section = $result->fetchRow(MYSQL_ASSOC))) {
                $temp_id = abs(intval($wysiwyg_section['section_id']));
                $id_list[] = 'content' . $temp_id;
            }
            require_once CAT_PATH . "/modules/wysiwyg/classes/pathfinder.php";
            $wb_path_info = new c_pathfinder($database);
            require_once CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php';
        }
    }
}
if (isset($preview) && $preview == true) {
    return false;
}
$parser->setPath(dirname(__FILE__) . '/templates/default');
Пример #9
0
 /**
  * creates a menu of linked pages in other languages
  **/
 public function getLanguageMenu()
 {
     global $parser, $page_id;
     if (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) {
         $items = CAT_Helper_Page::getInstance()->getLinkedByLanguage($page_id);
     }
     if (isset($items) && count($items)) {
         // initialize template search path
         $parser->setPath(CAT_PATH . '/templates/' . TEMPLATE . '/templates');
         $parser->setFallbackPath(CAT_THEME_PATH . '/templates');
         if ($parser->hasTemplate('languages')) {
             $parser->output('languages', array('items' => $items));
         }
     }
 }
Пример #10
0
}
if (!$in_old_group && !is_numeric(array_search($users->get_user_id(), $old_admin_users))) {
    $backend->print_error('You do not have permissions to modify this page');
}
//
// ! delete link
//
if ($val->sanitizeGet('del')) {
    list($lang, $page_id) = explode('_', $val->sanitizeGet('del'));
    CAT_Helper_Page::deleteLanguageLink($page_id, $lang);
}
$arrh = CAT_Helper_Array::getInstance();
// ===========================
// ! find already linked pages
// ===========================
$items = CAT_Helper_Page::getInstance($page_id)->getLinkedByLanguage($page_id);
// =========================
// ! get installed languages
// =========================
$addons = CAT_Helper_Addons::getInstance();
$avail = $addons->get_addons($page['language'], 'language');
// skip current lang
foreach ($avail as $i => &$l) {
    if ($l['VALUE'] == $page['language']) {
        unset($avail[$i]);
        break;
    }
}
// remove already linked languages
if (is_array($items) && count($items)) {
    foreach ($items as $item) {