示例#1
0
// load old language file
include CAT_PATH . '/languages/old/' . LANGUAGE . '.php';
global $database, $wb, $admin;
require_once CAT_PATH . '/framework/class.database.php';
$database = new database();
// old template engine
require_once CAT_PATH . "/include/phplib/template.inc";
// old language definitions - needed for some older modules, like Code2
define('ENABLE_OLD_LANGUAGE_DEFINITIONS', true);
// map new date and time formats to old ones
$wb2compat_format_map = array('%A, %d. %B %Y' => 'l, jS F, Y', '%e %B, %Y' => 'jS F, Y', '%d %m %Y' => 'd M Y', '%b %d %Y' => 'M d Y', '%a %b %d, %Y' => 'D M d, Y', '%d-%m-%Y' => 'd-m-Y', '%m-%d-%Y' => 'm-d-Y', '%d.%m.%Y' => 'd.m.Y', '%m.%d.%Y' => 'm.d.Y', '%d/%m/%Y' => 'd/m/Y', '%m/%d/%Y' => 'm/d/Y', '%a, %d %b %Y %H:%M:%S %z' => 'r', '%A, %d. %B %Y' => 'l, jS F Y', '%H:%M' => 'H:i', '%H:%M:%S' => 'H:i:s', '%I:%M %p' => 'g:i a');
// global settings
if (defined('CAT_DATE_FORMAT') && !defined('DATE_FORMAT') && array_key_exists(CAT_DATE_FORMAT, $wb2compat_format_map)) {
    define('DATE_FORMAT', $wb2compat_format_map[CAT_DATE_FORMAT]);
}
if (defined('CAT_DEFAULT_DATE_FORMAT') && !defined('DEFAULT_DATE_FORMAT') && array_key_exists(CAT_DEFAULT_DATE_FORMAT, $wb2compat_format_map)) {
    define('DEFAULT_DATE_FORMAT', $wb2compat_format_map[CAT_DEFAULT_DATE_FORMAT]);
}
if (defined('CAT_TIME_FORMAT') && !defined('TIME_FORMAT') && array_key_exists(CAT_TIME_FORMAT, $wb2compat_format_map)) {
    define('TIME_FORMAT', $wb2compat_format_map[CAT_TIME_FORMAT]);
}
if (defined('CAT_DEFAULT_TIME_FORMAT') && !defined('DEFAULT_TIME_FORMAT') && array_key_exists(CAT_DEFAULT_TIME_FORMAT, $wb2compat_format_map)) {
    define('DEFAULT_TIME_FORMAT', $wb2compat_format_map[CAT_DEFAULT_TIME_FORMAT]);
}
CAT_Registry::set('WB2COMPAT_FORMAT_MAP', $wb2compat_format_map);
if (!function_exists('show_menu')) {
    function show_menu()
    {
        return show_menu2();
    }
}
示例#2
0
/**
 * installs additional modules (located in ./optional subfolder)
 **/
function install_optional_modules()
{
    global $admin, $bundled, $config, $lang, $dirh;
    write2log('> [install_optional_modules()]');
    if (!isset($_REQUEST['installer_optional_addon']) || !is_array($_REQUEST['installer_optional_addon']) || !count($_REQUEST['installer_optional_addon'])) {
        fwrite($logh, 'no additional addons to install');
        fclose($logh);
        return array(true, array());
    } else {
        $config['optional_addon'] == $_REQUEST['installer_optional_addon'];
    }
    write2log('------------------------------------');
    write2log('-----installing optional addons-----');
    write2log('------------------------------------');
    write2log(print_r($config['optional_addon'], 1));
    $cat_path = $dirh->sanitizePath(dirname(__FILE__) . '/..');
    $errors = array();
    // try to set max_execution_time
    ini_set('max_execution_time', CAT_INST_EXEC_TIME);
    // set installed CMS version for precheck.php
    CAT_Registry::set('CAT_VERSION', $config['installed_version'], true);
    // set other constants
    init_constants($cat_path);
    include $cat_path . '/framework/class.database.php';
    $database = new database();
    foreach ($config['optional_addon'] as $file) {
        if (!file_exists($dirh->sanitizePath(dirname(__FILE__) . '/optional/' . $file))) {
            write2log('file not found: ' . $dirh->sanitizePath(dirname(__FILE__) . '/optional/' . $file));
            $errors[] = $lang->translate('No such file: [{{file}}]', array('file' => $file));
        } else {
            write2log('installing optional addon [' . $file . ']');
            if (!CAT_Helper_Addons::installModule($dirh->sanitizePath(dirname(__FILE__) . '/optional/' . $file), true)) {
                write2log('-> installation failed! ' . CAT_Helper_Addons::getError());
                if (CAT_Helper_Addons::getError() != 'already installed') {
                    $errors[] = $lang->translate('-> Unable to install {{module}}! {{error}}', array('module' => $file, 'error' => CAT_Helper_Addons::getError()));
                }
            } else {
                write2log('-> installation succeeded');
            }
        }
    }
    write2log('< [install_optional_modules()]');
    return array(count($errors) ? false : true, $errors);
}
示例#3
0
 /**
  * enable csrf-magic by including csrf-magic.php
  * will throw a fatal error if the lib is not available!
  *
  * @access public
  * @return void
  **/
 public function enableCSRFMagic()
 {
     if (is_object(self::$csrf)) {
         return self::$csrf;
     }
     if (!function_exists('csrf_ob_handler')) {
         $path = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/lib_csrfmagic/csrf-magic.php');
         if (!file_exists($path)) {
             $this->printFatalError('Missing library CSRF-Magic!');
         }
         include $path;
         CAT_Registry::set('CSRF_PROTECTION_ENABLED', true, true);
     }
 }
示例#4
0
 /**
  * initializes template search paths for backend
  *
  * @access public
  * @return
  **/
 public static function initPaths()
 {
     global $parser;
     // ===================================
     // ! initialize template search path
     // ===================================
     $parser->setPath(CAT_THEME_PATH . '/templates/default', 'backend');
     $parser->setFallbackPath(CAT_THEME_PATH . '/templates/default', 'backend');
     if (file_exists(CAT_THEME_PATH . '/templates/default')) {
         $parser->setPath(CAT_THEME_PATH . '/templates/default', 'backend');
         if (!CAT_Registry::exists('DEFAULT_THEME_VARIANT') || CAT_Registry::get('DEFAULT_THEME_VARIANT') == '') {
             CAT_Registry::set('DEFAULT_THEME_VARIANT', 'default');
             $parser->setGlobals('DEFAULT_THEME_VARIANT', 'default');
         }
     }
     if (CAT_Registry::get('DEFAULT_THEME_VARIANT') != '' && file_exists(CAT_THEME_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT'))) {
         $parser->setPath(CAT_THEME_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT'), 'backend');
     }
 }