示例#1
0
function Dwoo_plugin_cmsplink(Dwoo $dwoo, $page)
{
    // remove all but numbers
    preg_match('/(\\d+)/', $page, $match);
    if (!count($match)) {
        return '';
    }
    return CAT_Helper_Page::getLink($match[1]);
}
示例#2
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();
    }
}
示例#3
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);
}
示例#4
0
function cmsplink(&$content)
{
    $regexp = array('/\\[cmsplink([0-9]+)\\]/isU');
    // for backward compatibility with WB
    if (defined('WB_PREPROCESS_PREG')) {
        $regexp[] = WB_PREPROCESS_PREG;
    }
    foreach ($regexp as $preg) {
        if (preg_match_all($preg, $content, $ids)) {
            $new_ids = array_unique($ids[1]);
            foreach ($new_ids as $key => &$page_id) {
                $link = CAT_Helper_Page::properties($page_id, 'link');
                if (!is_null($link)) {
                    $content = str_replace($ids[0][$key], CAT_Helper_Page::getLink($link), $content);
                }
            }
        }
    }
}
示例#5
0
    print json_encode($ajax);
    exit;
}
$visibility = $page['visibility'];
$use_trash = false;
// Check if we should delete it or just set the visibility to 'deleted'
if (PAGE_TRASH !== false && $visibility != 'deleted') {
    $ajax_status = 1;
    // Page trash is enabled and page has not yet been deleted
    $result = CAT_Helper_Page::deletePage($page_id, true);
    $use_trash = true;
} else {
    $ajax_status = 0;
    $result = CAT_Helper_Page::deletePage($page_id);
}
if (!$result) {
    $ajax = array('message' => $backend->lang()->translate('An error occured (using trash: {{trash}})', array('trash' => $use_trash ? $backend->lang()->translate('Yes') : $backend->lang()->translate('No'))) . ($backend->db()->isError() ? ' (DB error: ' . $backend->db()->getError() . ')' : ''), 'success' => false);
    print json_encode($ajax);
    exit;
} else {
    // delete empty parent dir
    $directory = CAT_PATH . PAGES_DIRECTORY . CAT_Helper_Page::properties($page_id, 'link');
    $directory = pathinfo($directory, PATHINFO_DIRNAME);
    if (is_dir($directory) && rtrim($directory, '/') != CAT_PATH . PAGES_DIRECTORY && CAT_Helper_Directory::is_empty($directory, true)) {
        CAT_Helper_Directory::removeDirectory($directory);
    }
    $ajax = array('message' => $backend->lang()->translate('Page(s) deleted successfully'), 'status' => $ajax_status, 'success' => true);
    print json_encode($ajax);
    exit;
}
exit;
示例#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);
    }
}
// this one is only used for the frontend!
if (!FRONTEND_LOGIN) {
    // no frontend login, no preferences
    if (INTRO_PAGE) {
        die(header('Location: ' . CAT_URL . PAGES_DIRECTORY . '/index.php'));
    } else {
        die(header('Location: ' . CAT_URL . '/index.php'));
    }
}
CAT_Helper_Page::getVirtualPage('Please login');
// Set the page content include file
define('PAGE_CONTENT', CAT_PATH . '/account/login_form.php');
// Include the index (wrapper) file
require CAT_PATH . '/index.php';
示例#7
0
$page_id = $val->sanitizePost('page_id', 'numeric');
if (!$page_id) {
    $backend->print_error('Missing page ID!');
}
// Include the WB functions file
require_once CAT_PATH . '/framework/functions.php';
// get form data
$language = $val->sanitizePost('map_language', NULL, true);
$link_page_id = $val->sanitizePost('link_page_id', 'numeric', true);
if (!$link_page_id) {
    $backend->print_error('No page to link to!', CAT_ADMIN_URL . '/pages/lang_settings.php?page_id=' . $page_id);
}
// =====================================
// ! check if linked page has given lang
// =====================================
$page = CAT_Helper_Page::getPage($link_page_id);
// page to be linked to
if ($page['language'] !== $language) {
    $backend->print_error("The page you've chosen does not have the right language! (" . $page['language'] . " !== {$language})");
}
// ===============================================
// ! check if there's already a page for this lang
// ===============================================
$results = $backend->db()->query('SELECT * FROM `' . CAT_TABLE_PREFIX . 'page_langs` WHERE page_id = "' . $page_id . '" AND lang = "' . $language . '"');
if ($backend->db()->isError()) {
    $backend->print_error($backend->db()->getError());
}
if ($results->numRows()) {
    $backend->print_error('There is already a page for this language!');
}
// =========================================
示例#8
0
 /**
  *
  * @access public
  * @return
  **/
 private static function listbuilder($list, $root_id = 0, $type = 'ul', $selected = NULL)
 {
     if (empty($list) || !is_array($list) || !count($list)) {
         return NULL;
     }
     // initialize
     $self = self::getInstance(false);
     $output = array();
     $hidden = isset($self->_config['__hidden_key']) ? $self->_config['__hidden_key'] : '';
     $p_key = $self->_config['__parent_key'];
     $id_key = $self->_config['__id_key'];
     $title_key = $self->_config['__title_key'];
     $level_key = $self->_config['__level_key'];
     $isopen_key = $self->_config['__is_open_key'];
     $link_key = $self->_config['__link_key'];
     $auto_link = $self->_config['__auto_link'];
     $current = $self->_config['__is_current_key'];
     $space = $self->_config['space'];
     $is_first = true;
     $is_last = false;
     $is_open = false;
     // create a list of children for each item
     foreach ($list as $item) {
         // sort out hidden items
         if (isset($item[$hidden])) {
             continue;
         }
         $children[$item[$p_key]][] = $item;
     }
     // loop will be false if the root has no children
     $loop = !empty($children[$root_id]);
     // initializing $parent as the root
     $parent = $root_id;
     $parent_stack = array();
     while ($loop && (($option = each($children[$parent])) || $parent > $root_id)) {
         $is_current = isset($option['value'][$current]) && $option['value'][$current] == true || isset($selected) && $selected == $option['value'][$id_key] ? true : false;
         if ($option === false) {
             $parent = array_pop($parent_stack);
             if ($type != 'select') {
                 // close list item
                 $output[] = str_repeat("\t", (count($parent_stack) + 1) * 2) . $self->closeUL();
                 $output[] = str_repeat("\t", (count($parent_stack) + 1) * 2 - 1) . $self->closeLI();
             }
         } elseif (!empty($children[$option['value'][$id_key]])) {
             $level = isset($option['value'][$level_key]) && $option['value'][$level_key] >= 0 ? $option['value'][$level_key] : 0;
             $tab = str_repeat($space, $level);
             $text = $option['value'][$title_key];
             $is_open = $selected ? $selected : $option['value'][$isopen_key];
             // mark selected
             if ($type == 'select') {
                 $sel = NULL;
                 if (isset($selected) && $selected == $option['value'][$id_key]) {
                     $sel = ' selected="selected"';
                 }
                 $output[] = $self->getOption($option['value'][$id_key], $sel, $tab, $text);
             } else {
                 // HTML for menu item containing children (open)
                 $output[] = $tab . $self->startLI($option['value'][$id_key], $level, true, $is_first, $is_last, $is_open, $is_current) . ($auto_link && $link_key ? '<a href="' . CAT_Helper_Page::getLink($option['value'][$id_key]) . '">' : '') . $text . ($auto_link && $link_key ? '</a>' : '');
                 // open sub list
                 $output[] = $tab . "\t" . $self->startUL($space, '', $option['value'][$level_key]);
                 #$output[] = '-'.$option['value'][$id_key].'-';
             }
             array_push($parent_stack, $option['value'][$p_key]);
             $parent = $option['value'][$id_key];
         } else {
             $level = isset($option['value'][$level_key]) && $option['value'][$level_key] >= 0 ? $option['value'][$level_key] : 0;
             $tab = str_repeat($space, $level);
             $text = $option['value'][$title_key];
             if ($type == 'select') {
                 // mark selected
                 $sel = NULL;
                 if ($is_current) {
                     $sel = ' selected="selected"';
                 }
                 $output[] = $self->getOption($option['value'][$id_key], $sel, $tab, $text);
             } else {
                 $output[] = $tab . $self->startLI($option['value'][$id_key], $level, false, $is_first, $is_last, false, $is_current) . ($auto_link && $link_key ? '<a href="' . CAT_Helper_Page::getLink($option['value'][$id_key]) . '">' : '') . $text . ($auto_link && $link_key ? '</a>' : '') . $self->closeLI();
             }
         }
         $is_first = false;
     }
     // end while
     if (isset($self->_config['__li_last_item_class']) && !empty($self->_config['__li_last_item_class'])) {
         // get the very last element
         $last = array_splice($output, -1, 1);
         // add last item css
         $last = str_ireplace('class="', 'class="' . $self->_config['__li_last_item_class'] . ' ', $last);
         $output[] = is_array($last) && count($last) ? $last[0] : '';
     }
     return $output;
 }
示例#9
0
 function print_under_construction()
 {
     return CAT_Helper_Page::printUnderConstruction();
 }
示例#10
0
 function get_page_trail($id)
 {
     return CAT_Helper_Page::getPageTrail($id);
 }
示例#11
0
    // find JS files
    $js = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin, true, true, CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin);
    // find CSS files
    $css = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin, true, true, CAT_PATH . '/modules/lib_jquery/plugins/' . $plugin);
    foreach ($js as $file) {
        CAT_Helper_Page::adminDelHeaderComponent('js', '/modules/lib_jquery/plugins/' . $plugin . $file, $page_id);
    }
    foreach ($css as $file) {
        CAT_Helper_Page::adminDelHeaderComponent('css', '/modules/lib_jquery/plugins/' . $plugin . $file, $page_id);
    }
    print json_encode(array('success' => true, 'message' => 'ok'));
    exit;
} elseif ($val->sanitizePost('order') != '') {
    if (is_array($val->sanitizePost('order'))) {
        $type = $val->sanitizePost('type');
        $q = sprintf('UPDATE `%spages_headers` SET `page_%s_files` = \'%s\' WHERE `page_id`="%d"', CAT_TABLE_PREFIX, $type, serialize($val->sanitizePost('order')), $page_id);
        $database->query($q);
        print json_encode(array('success' => $database->is_error() ? false : true, 'message' => $database->is_error() ? $database->get_error() : 'Success'));
        exit;
    }
} elseif ($val->sanitizePost('save') != '') {
    $data = CAT_Helper_Page::getExtraHeaderFiles($page_id);
    if (count($data)) {
        $q = 'UPDATE `:prefix:pages_headers` SET `use_core`=:use_core, `use_ui`=:use_ui WHERE `page_id`=:page_id';
    } else {
        $q = 'INSERT INTO `:prefix:pages_headers` ( `page_id`, `use_core`, `use_ui` ) VALUES ( :page_id, :use_core, :use_ui )';
    }
    $database->query($q, array('use_core' => $val->sanitizePost('use_core') == 'true' ? 'Y' : 'N', 'use_ui' => $val->sanitizePost('use_ui') == 'true' ? 'Y' : 'N', 'page_id' => $page_id));
    print json_encode(array('success' => $database->is_error() ? false : true, 'message' => $database->is_error() ? $database->get_error() : 'Success'));
    exit;
}
示例#12
0
 /**
  *
  * @access public
  * @return
  **/
 public static function uninstallModule($type, $addon_name)
 {
     // keep old modules happy
     global $wb, $admin, $database;
     switch ($type) {
         case 'languages':
             // is default or used by current user
             if ($addon_name == DEFAULT_LANGUAGE || $addon_name == LANGUAGE) {
                 $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_LANGUAGE ? self::getInstance()->lang()->translate('standard language') : self::getInstance()->lang()->translate('current language'));
                 return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp);
             }
             // used by other users
             $query_users = self::getInstance()->db()->query("SELECT `user_id` FROM `:prefix:users` WHERE language=:lang LIMIT 1", array('lang' => $addon_name));
             if ($query_users->rowCount() > 0) {
                 return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is in use!', array('name' => $addon_name));
             }
             break;
         case 'modules':
             // check if the module is still in use
             $info = self::getInstance()->db()->query("SELECT `section_id`, `page_id` FROM `:prefix:sections` WHERE module=:mod", array('mod' => $addon_name));
             if ($info->rowCount() > 0) {
                 $temp = explode(";", self::getInstance()->lang()->translate('this page;these pages'));
                 $add = $info->rowCount() == 1 ? $temp[0] : $temp[1];
                 $values = array('type' => self::getInstance()->lang()->translate('Module'), 'type_name' => $type, 'pages_string' => $add, 'count' => $info->rowCount(), 'name' => $addon_name);
                 $pages = array();
                 while (false != ($data = $info->fetchRow(MYSQL_ASSOC))) {
                     // skip negative page id's
                     if (substr($data['page_id'], 0, 1) == '-') {
                         continue;
                     }
                     $pages[] = sprintf('<a href="%s">%s</a>', CAT_Helper_Page::getLink($data['page_id']), CAT_Helper_Page::properties($data['page_id'], 'menu_title'));
                 }
                 $values['pages'] = implode('<br />', $pages);
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is in use on {{pages_string}}:<br /><br />{{pages}}', $values);
             }
             //  some modules cannot be removed (used by system)
             if (!self::isRemovable($addon_name)) {
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is marked as mandatory!', array('name' => $addon_name));
             }
             if (defined('WYSIWYG_EDITOR') && $addon_name == WYSIWYG_EDITOR) {
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is the standard WYSWIWYG editor!', array('name' => $addon_name));
             }
             break;
         case 'templates':
             if ($addon_name == DEFAULT_THEME || $addon_name == DEFAULT_TEMPLATE) {
                 $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_TEMPLATE ? self::getInstance()->lang()->translate('default template') : self::getInstance()->lang()->translate('default backend theme'));
                 return self::getInstance()->lang()->translate('Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp);
             }
             $info = self::getInstance()->db()->query("SELECT `page_id`, `page_title` FROM `:prefix:pages` WHERE template=:name order by page_title", array('name' => $addon_name));
             if ($info->rowCount() > 0) {
                 $msg_template_str = 'Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is still in use on {{pages}}:';
                 $temp = explode(';', self::getInstance()->lang()->translate('this page;these pages'));
                 $add = $info->rowCount() == 1 ? $temp[0] : $temp[1];
                 $page_template_str = "<li><a href='../pages/settings.php?page_id={{id}}'>{{title}}</a></li>";
                 $values = array('pages' => $add, 'name' => $addon_name);
                 $msg = self::getInstance()->lang()->translate($msg_template_str, $values);
                 $page_names = '<ul>';
                 while ($data = $info->fetchRow()) {
                     $page_info = array('id' => $data['page_id'], 'title' => $data['page_title']);
                     $page_names .= self::getInstance()->lang()->translate($page_template_str, $page_info);
                 }
                 $page_names .= '</ul>';
                 return $msg . $page_names;
             }
             break;
         default:
             break;
     }
     // end switch
     // all checks succeeded, try to uninstall
     if (file_exists(CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php')) {
         require CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php';
     }
     // Remove entry from DB
     if ($type != 'languages') {
         self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1)));
         if (self::getInstance()->db()->isError()) {
             return self::getInstance()->db()->getError();
         }
         $stmt = self::getInstance()->db()->query('SELECT * FROM `:prefix:groups` WHERE group_id <> 1');
         if ($stmt->rowCount() > 0) {
             while ($row = $stmt->fetchRow(MYSQL_ASSOC)) {
                 $gid = $row['group_id'];
                 $file = $addon_name;
                 // get current value
                 $permissions = explode(',', $row[substr($type, 0, -1) . '_permissions']);
                 // remove uninstalled module
                 if (in_array($file, $permissions)) {
                     $i = array_search($file, $permissions);
                     array_splice($permissions, $i, 1);
                     $permissions = array_unique($permissions);
                     asort($permissions);
                     // Update the database
                     $addon_permissions = implode(',', $permissions);
                     self::getInstance()->db()->query(sprintf("UPDATE `:prefix:groups` SET %s_permissions=:perm WHERE group_id=:id", substr($type, 0, -1)), array('perm' => $addon_permissions, 'id' => $gid));
                 }
             }
         }
         // Try to delete the module dir
         if (!CAT_Helper_Directory::removeDirectory(CAT_PATH . '/' . $type . '/' . $addon_name)) {
             return self::getInstance()->lang()->translate('Cannot uninstall - unable to delete the directory!');
         }
     } else {
         self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1)));
         if (self::getInstance()->db()->isError()) {
             return self::getInstance()->db()->getError();
         }
         unlink(CAT_PATH . '/languages/' . $addon_name . '.php');
     }
     return true;
 }
示例#13
0
    CAT_Object::printFatalError(CAT_Object::lang()->translate('No search library installed!'), CAT_Helper_Page::getLink($page_id));
}
// Required page details
$page_id = -1;
$page_description = '';
$page_keywords = '';
// load search library
require_once CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/library.php';
$s = new CATSearch();
$page_id = $s->getSearchPageID();
// load droplets extensions
$h = CAT_Helper_Droplet::getInstance();
$h->register_droplet_css('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.css');
$h->register_droplet_js('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.js');
if (isset($_GET['string'])) {
    CAT_Helper_Page::addCSS(CAT_URL . '/modules/' . SEARCH_LIBRARY . '/templates/default/frontend.css');
}
// add language file
CAT_Helper_I18n::getInstance()->addFile(LANGUAGE . '.php', CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/languages/');
// add template search path
global $parser;
$parser->setPath(CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/templates/custom');
$parser->setFallbackPath(CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/templates/default');
define('PAGE_CONTENT', CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/index.php');
// Get the referrer page ID if it exists
if (isset($_REQUEST['referrer']) && is_numeric($_REQUEST['referrer']) && intval($_REQUEST['referrer']) > 0) {
    define('REFERRER_ID', intval($_REQUEST['referrer']));
} else {
    define('REFERRER_ID', 0);
}
// Include index (wrapper) file
示例#14
0
 function get_page_details($page_id)
 {
     return CAT_Helper_Page::properties($page_id);
 }
示例#15
0
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
$backend = CAT_Backend::getInstance('Pages', 'pages', false);
$users = CAT_Users::getInstance();
$val = CAT_Helper_Validate::getInstance();
header('Content-type: application/json');
if (!$users->checkPermission('Pages', 'pages')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to proceed this action'), 'success' => false);
    print json_encode($ajax);
    exit;
}
$page_id = $val->sanitizePost('page_id', 'numeric');
// Get page id
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('You sent an invalid value'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// load page settings
$page = CAT_Helper_Page::getPage($page_id);
// get file name
$filename = CAT_PATH . PAGES_DIRECTORY . $page['link'] . PAGE_EXTENSION;
// create access file
if (CAT_Helper_Page::createAccessFile($filename, $page_id)) {
    $ajax = array('message' => $backend->lang()->translate('Access file created successfully'), 'success' => true);
} else {
    $ajax = array('message' => $backend->lang()->translate('Unable to re-create the access file!'), 'success' => false);
}
print json_encode($ajax);
exit;
示例#16
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));
}
示例#17
0
 /**
  *
  * @access public
  * @return
  **/
 public static function get_init_pages()
 {
     // frontend pages
     $pages = CAT_Helper_Page::getPages();
     $frontend_pages = array();
     foreach ($pages as $page) {
         $frontend_pages[$page['menu_title']] = 'pages/modify.php?page_id=' . $page['page_id'];
     }
     // admin tools
     $tools = CAT_Helper_Addons::get_addons(NULL, 'module', 'tool');
     $admin_tools = array();
     foreach ($tools as $tool) {
         $admin_tools[$tool['name']] = 'admintools/tool.php?tool=' . $tool['directory'];
     }
     // backend pages
     $backend_pages = CAT_Backend::getPages();
     return array('backend_pages' => $backend_pages, 'frontend_pages' => $frontend_pages, 'admin_tools' => $admin_tools);
 }
示例#18
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.');
}
示例#19
0
 /**
  *
  * @access private
  * @return
  **/
 private static function analyzeLevel($page_id, $max_level = 999)
 {
     $level = CAT_Helper_Page::properties($page_id, 'level');
     // figure out max depth to show
     if ($max_level !== 999) {
         // handle '+X' $max_level value
         if (preg_match('~^\\+(\\d+)$~', $max_level, $m)) {
             $max_level = $level + $m[1];
         }
         return $max_level - $level;
     }
     return 999;
 }
示例#20
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);
    }
}
// this one is only used for the frontend!
if (!FRONTEND_LOGIN) {
    // no frontend login, no forgot form
    if (INTRO_PAGE) {
        die(header('Location: ' . CAT_URL . PAGES_DIRECTORY . '/index.php'));
    } else {
        die(header('Location: ' . CAT_URL . '/index.php'));
    }
}
CAT_Helper_Page::getVirtualPage('Forgot');
// Set the page content include file
define('PAGE_CONTENT', CAT_PATH . '/account/forgot_form.php');
// Set auto authentication to false
$auto_auth = false;
// Include the index (wrapper) file
require CAT_PATH . '/index.php';
示例#21
0
    exit;
}
$page_id = $val->sanitizePost('page_id', 'numeric');
// Get page id
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('You sent an invalid value'), 'success' => false);
    print json_encode($ajax);
    exit;
}
if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to restore this page.'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// Find out more about the page
$page = CAT_Helper_Page::properties($page_id);
if (!$page) {
    $ajax = array('message' => $backend->lang()->translate('Page not found'), 'success' => false);
    print json_encode($ajax);
    exit;
}
$visibility = $page['visibility'];
if (CAT_Registry::get('PAGE_TRASH') !== 'false') {
    if ($visibility == 'deleted') {
        // Function to change all child pages visibility to deleted
        function restore_subs($parent = 0)
        {
            global $backend;
            // Query pages
            $query_menu = $backend->db()->query(sprintf("SELECT page_id FROM `%spages` WHERE parent = '%d' ORDER BY position ASC", CAT_TABLE_PREFIX, $parent));
            // Check if there are any pages to show
示例#22
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);
    }
}
$val = CAT_Helper_Validate::getInstance();
$user = CAT_Users::getInstance();
$id = $user->get_user_id();
// this one is only used for the frontend!
if (!FRONTEND_LOGIN || !FRONTEND_SIGNUP) {
    // no frontend login, no sign up
    if (INTRO_PAGE) {
        die(header('Location: ' . CAT_URL . PAGES_DIRECTORY . '/index.php'));
    } else {
        die(header('Location: ' . CAT_URL . '/index.php'));
    }
}
CAT_Helper_Page::getVirtualPage('Sign-up');
CAT_Helper_Page::addCSS(CAT_URL . '/account/css/preferences.css');
CAT_Registry::register('PAGE_CONTENT', CAT_PATH . '/account/signup_form.php', true);
// Set auto authentication to false
$auto_auth = false;
// Include the index (wrapper) file
require CAT_PATH . '/index.php';
示例#23
0
        $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);
    }
}
// this one is only used for the frontend!
if (!FRONTEND_LOGIN) {
    // no frontend login, no preferences
    if (INTRO_PAGE) {
        die(header('Location: ' . CAT_URL . PAGES_DIRECTORY . '/index.php'));
    } else {
        die(header('Location: ' . CAT_URL . '/index.php'));
    }
}
// check if user is authenticated
if (CAT_Users::getInstance()->is_authenticated() === false) {
    die(header('Location: ' . CAT_URL . '/account/login.php'));
}
CAT_Helper_Page::getVirtualPage('Preferences');
/**
 *	Set the page content include file
 */
define('PAGE_CONTENT', CAT_PATH . '/account/preferences_form.php');
/**
 *	Include the index (wrapper) file
 */
require CAT_PATH . '/index.php';
示例#24
0
 *   @copyright       2013, Black Cat Development
 *   @link            http://blackcat-cms.org
 *   @license         http://www.gnu.org/licenses/gpl.html
 *   @category        CAT_Core
 *   @package         mojito
 *
 */
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);
    }
}
$mod_headers = array('frontend' => array('meta' => array(array()), 'css' => array(array('media' => 'all', 'file' => 'templates/mojito/css/default/template.css')), 'jquery' => array(array('core' => true)), 'js' => array('/js/frontend.js', '/js/modernizr.custom.62906.js')));
global $page_id;
$variant = CAT_Helper_Page::getPageSettings($page_id, 'internal', 'template_variant');
if (!$variant) {
    $variant = defined('DEFAULT_TEMPLATE_VARIANT') && DEFAULT_TEMPLATE_VARIANT != '' ? DEFAULT_TEMPLATE_VARIANT : 'default';
}
if ($variant != 'default' && file_exists(CAT_PATH . '/templates/mojito/css/' . $variant . '/template.css')) {
    $mod_headers['frontend']['css'] = array(array('media' => 'all', 'file' => 'templates/mojito/css/' . $variant . '/template.css'));
}
示例#25
0
if (MANAGE_SECTIONS != 'enabled') {
    header('Location: ' . CAT_ADMIN_URL);
    exit(0);
}
$backend = CAT_Backend::getInstance('Pages', 'pages_modify');
$addons = CAT_Helper_Addons::getInstance();
$val = CAT_Helper_Validate::getInstance();
$page_id = $val->get('_REQUEST', 'page_id', 'numeric');
if (!$page_id) {
    header("Location: index.php");
    exit(0);
}
if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) {
    $backend->print_error('You do not have permissions to modify this page');
}
$page_details = CAT_Helper_Page::properties($page_id);
if (!count($page_details)) {
    $backend->print_error('Page not found');
}
// ==========================
// ! Set module permissions
// ==========================
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
// =========================
// ! Get delete_section_id
// =========================
$delete_section_id = $val->sanitizeGet('delete_section_id', 'numeric');
$update_section_id = $val->sanitizeGet('update_section_id', 'numeric');
$add_module = $val->sanitizePost('add_module', NULL, true);
$add_to_block = $val->sanitizePost('add_to_block', 'numeric');
// add section
示例#26
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'];
}
示例#27
0
 function page_link($link)
 {
     return CAT_Helper_Page::getLink($link);
 }
示例#28
0
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
$backend = CAT_Backend::getInstance('Pages', 'pages_add', false);
$users = CAT_Users::getInstance();
header('Content-type: application/json');
if (!$users->checkPermission('Pages', 'pages_add')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to add a page.'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// note: all pages are listed in the dropdown, even hidden / private AND deleted!
$dropdown_list = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(1), 0);
// template / variant
$template = CAT_Helper_Page::properties($val->sanitizePost('parent_id', 'numeric'), 'template');
$variant = CAT_Helper_Page::getPageSettings($val->sanitizePost('parent_id', 'numeric'), 'internal', 'template_variant');
$variants = array();
$info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($val->sanitizePost('parent_id', 'numeric')));
if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) {
    $variants = $info['module_variants'];
    array_unshift($variants, '');
}
// =============================================
// ! Add result_array to the template variable
// =============================================
$ajax = array('parent_id' => $val->sanitizePost('parent_id', 'numeric'), 'parent_list' => $dropdown_list, 'template' => $template, 'template_variant' => $variant, 'variants' => $variants, 'target' => '_self', 'success' => true);
// ====================
// ! Return values
// ====================
print json_encode($ajax);
exit;
示例#29
0
$val = CAT_Helper_Validate::getInstance();
$user = CAT_Users::getInstance();
$backend = CAT_Backend::getInstance('Pages', 'pages_modify');
// ===============
// ! Get page id
// ===============
$page_id = $val->get('_REQUEST', 'page_id', 'numeric');
$section_id = $val->get('_REQUEST', 'section_id', 'numeric');
if (!$page_id) {
    header("Location: index.php");
    exit(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 {
示例#30
0
        $tpl_data['calc_ttf_image'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/calc_ttf_image.png';
        $tpl_data['old_image'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/old_image.png';
        $tpl_data['calc_text'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/calc_text.png';
        $tpl_data['text'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/text.png';
        break;
    case 'sysinfo':
        // format installation date and time
        $tpl_data['values']['installation_time'] = CAT_Helper_DateTime::getDateTime(INSTALLATION_TIME);
        // get page statistics
        $pg = CAT_Helper_Page::getPagesByVisibility();
        foreach (array_keys($pg) as $key) {
            $tpl_data['values']['pages_count'][] = array('visibility' => $key, 'count' => count($pg[$key]));
        }
        break;
    case 'headers':
        $files = CAT_Helper_Page::getExtraHeaderFiles(0);
        $tpl_data['use_core'] = isset($files['use_core']) ? $files['use_core'] : NULL;
        $tpl_data['use_ui'] = isset($files['use_ui']) ? $files['use_ui'] : NULL;
        $tpl_data['page_js'] = isset($files['js']) ? $files['js'] : '';
        $tpl_data['page_css'] = isset($files['css']) ? $files['css'] : '';
        $tpl_data['jquery_plugins'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', false, false, CAT_PATH . '/modules/lib_jquery/plugins/');
        $tpl_data['js_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins');
        $tpl_data['css_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins');
        break;
}
$result = true;
$message = NULL;
$output = $parser->get($tpl, $tpl_data);
if (!$output || $output == '') {
    $result = false;
    $message = 'Unable to load settings sub page';