Пример #1
0
 public function lang()
 {
     if (!is_object($this->lang)) {
         $this->lang = CAT_Helper_I18n::getInstance(LANGUAGE);
     }
     return $this->lang;
 }
Пример #2
0
function Dwoo_Plugin_translate(Dwoo $dwoo, $msg, $args = array())
{
    global $__dwoo_plugin_lang;
    // just to be sure
    if (!is_object($__dwoo_plugin_lang)) {
        if (!class_exists('CAT_Helper_I18n', false)) {
            require dirname(__FILE__) . '/../../../../../framework/CAT/Helper/I18n.php';
        }
        $__dwoo_plugin_lang = CAT_Helper_I18n::getInstance();
    }
    return $__dwoo_plugin_lang->translate($msg, $args);
}
Пример #3
0
 /**
  *
  *
  *
  *
  **/
 public function checkFile($file, $check_var, $check_only = false)
 {
     $this->log()->logDebug(sprintf('checking file [%s] for var [%s], check_only [%s]', $file, $check_var, $check_only));
     // require the language file
     require $file;
     // check if the var is defined now
     if (isset(${$check_var})) {
         $this->log()->logDebug('found $check_var');
         $isIndexed = array_values(${$check_var}) === ${$check_var};
         if ($isIndexed) {
             $this->log()->logDebug('indexed, returning false');
             return false;
         }
         if ($check_only) {
             return ${$check_var};
         } else {
             self::$_lang = array_merge(self::$_lang, ${$check_var});
             if (preg_match("/(\\w+)\\.php/", $file, $matches)) {
                 self::$_current_lang = $matches[1];
             }
             $this->_loaded[$file] = 1;
             $this->log()->logDebug('loaded language file: ', $file);
             return true;
         }
     } else {
         $this->log()->logInfo(sprintf('invalid lang file [%s], var [%s] is not set', $file, $check_var));
         return false;
     }
 }
Пример #4
0
}
// 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
require CAT_PATH . '/index.php';
Пример #5
0
} 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);
    }
}
$backend = CAT_Backend::getInstance('admintools');
$user = CAT_Users::getInstance();
$lang = CAT_Helper_I18n::getInstance();
// this will redirect to the login page if the permission is not set
$user->checkPermission('admintools', 'admintools', false);
global $parser;
// get tools
// ----- TODO: PERMISSIONS -----
$tools = CAT_Helper_Addons::get_addons(0, 'module', 'tool');
if (count($tools)) {
    foreach ($tools as $tool) {
        // check if the user is allowed to see this item
        if (!$user->get_permission($tool['directory'], $tool['type'])) {
            continue;
        }
        // check if a module description exists for the displayed backend language
        $module_description = false;
        $icon = false;
Пример #6
0
/**
 *
 **/
function getCharsets()
{
    $CHARSETS = CAT_Helper_I18n::getInstance()->getCharsets();
    $counter = 0;
    $data = array();
    foreach ($CHARSETS as $code => $title) {
        $data[$counter] = array('NAME' => $title, 'VALUE' => $code, 'SELECTED' => DEFAULT_CHARSET == $code ? true : false);
        $counter++;
    }
    return $data;
}
Пример #7
0
 /**
  * handle user login
  **/
 public static function handleLogin($output = true)
 {
     global $parser;
     if (!is_object($parser)) {
         $parser = CAT_Helper_Template::getInstance('Dwoo');
     }
     CAT_Backend::initPaths();
     $val = CAT_Helper_Validate::getInstance();
     $lang = CAT_Helper_I18n::getInstance();
     $self = self::getInstance();
     $redirect_url = $val->sanitizePost('redirect');
     if (!self::is_authenticated()) {
         // --- login attempt ---
         if ($val->sanitizePost('username_fieldname')) {
             // get input data
             $user = htmlspecialchars($val->sanitizePost($val->sanitizePost('username_fieldname')), ENT_QUOTES);
             $pw = $val->sanitizePost($val->sanitizePost('password_fieldname'));
             $name = preg_match('/[\\;\\=\\&\\|\\<\\> ]/', $user) ? '' : $user;
             $min_length = CAT_Registry::exists('AUTH_MIN_LOGIN_LENGTH', false) ? CAT_Registry::get('AUTH_MIN_LOGIN_LENGTH') : 5;
             $min_pass_length = CAT_Registry::exists('AUTH_MIN_PASS_LENGTH', false) ? CAT_Registry::get('AUTH_MIN_PASS_LENGTH') : 5;
             // check common issues
             // we do not check for too long and don't give too much hints!
             if (!$name) {
                 self::setLoginError($lang->translate('Invalid credentials'));
             }
             if (!self::$loginerror && $user == '' || $pw == '') {
                 self::setLoginError($lang->translate('Please enter your username and password.'));
             }
             if (!self::$loginerror && strlen($user) < $min_length) {
                 self::setLoginError($lang->translate('Invalid credentials'));
             }
             if (!self::$loginerror && !CAT_Registry::defined('ALLOW_SHORT_PASSWORDS') && strlen($pw) < $min_pass_length) {
                 self::setLoginError($lang->translate('Invalid credentials'));
             }
             if (!self::$loginerror) {
                 $query = 'SELECT * FROM `:prefix:users` WHERE `username`=:name AND `password`=:pw';
                 $qAct = 'SELECT `active` FROM `:prefix:users` WHERE `username` = :name AND `password` = :pw';
                 $result = $self->db()->query($query, array('name' => $name, 'pw' => md5($pw)));
                 $active = $self->db()->query($qAct, array('name' => $name, 'pw' => md5($pw)));
                 if ($active && $result->rowCount() == 1) {
                     // get default user preferences
                     $prefs = self::getDefaultUserOptions();
                     // get basic user data
                     $user = $result->fetchRow(MYSQL_ASSOC);
                     // add this user's options
                     $prefs = array_merge($prefs, self::getUserOptions($user['user_id']));
                     foreach (self::$sessioncols as $key) {
                         $_SESSION[strtoupper($key)] = $user[$key];
                     }
                     // ----- preferences -----
                     $_SESSION['LANGUAGE'] = $user['language'] != '' ? $user['language'] : (isset($prefs['language']) ? $prefs['language'] : 'DE');
                     $_SESSION['TIMEZONE_STRING'] = isset($prefs['timezone_string']) && $prefs['timezone_string'] != '' ? $prefs['timezone_string'] : CAT_Registry::get('DEFAULT_TIMEZONE_STRING');
                     $_SESSION['CAT_DATE_FORMAT'] = isset($prefs['date_format']) && $prefs['date_format'] != '' ? $prefs['date_format'] : CAT_Registry::get('CAT_DEFAULT_DATE_FORMAT');
                     $_SESSION['CAT_TIME_FORMAT'] = isset($prefs['time_format']) && $prefs['time_format'] != '' ? $prefs['time_format'] : CAT_Registry::get('CAT_DEFAULT_TIME_FORMAT');
                     if (defined('WB2COMPAT') && WB2COMPAT === true) {
                         $wb2compat_format_map = CAT_Registry::get('WB2COMPAT_FORMAT_MAP');
                         $_SESSION['DATE_FORMAT'] = isset($_SESSION['CAT_DATE_FORMAT']) ? $wb2compat_format_map[$_SESSION['CAT_DATE_FORMAT']] : '';
                         $_SESSION['TIME_FORMAT'] = isset($_SESSION['CAT_TIME_FORMAT']) ? $wb2compat_format_map[$_SESSION['CAT_TIME_FORMAT']] : '';
                     }
                     date_default_timezone_set($_SESSION['TIMEZONE_STRING']);
                     $_SESSION['SYSTEM_PERMISSIONS'] = 0;
                     $_SESSION['MODULE_PERMISSIONS'] = array();
                     $_SESSION['TEMPLATE_PERMISSIONS'] = array();
                     $_SESSION['GROUP_NAME'] = array();
                     $first_group = true;
                     foreach (explode(",", $user['groups_id']) as $cur_group_id) {
                         $query = "SELECT * FROM `:prefix:groups` WHERE group_id=:id";
                         $result = $self->db()->query($query, array('id' => $cur_group_id));
                         $results = $result->fetch();
                         $_SESSION['GROUP_NAME'][$cur_group_id] = $results['name'];
                         // Set system permissions
                         if ($results['system_permissions'] != '') {
                             $_SESSION['SYSTEM_PERMISSIONS'] = $results['system_permissions'];
                         }
                         // Set module permissions
                         if ($results['module_permissions'] != '') {
                             if ($first_group) {
                                 $_SESSION['MODULE_PERMISSIONS'] = explode(',', $results['module_permissions']);
                             } else {
                                 $_SESSION['MODULE_PERMISSIONS'] = array_intersect($_SESSION['MODULE_PERMISSIONS'], explode(',', $results['module_permissions']));
                             }
                         }
                         // Set template permissions
                         if ($results['template_permissions'] != '') {
                             if ($first_group) {
                                 $_SESSION['TEMPLATE_PERMISSIONS'] = explode(',', $results['template_permissions']);
                             } else {
                                 $_SESSION['TEMPLATE_PERMISSIONS'] = array_intersect($_SESSION['TEMPLATE_PERMISSIONS'], explode(',', $results['template_permissions']));
                             }
                         }
                         $first_group = false;
                     }
                     // foreach ( explode(",",$user['groups_id']) as $cur_group_id )
                     // Update the users table with current ip and timestamp
                     $get_ts = time();
                     $get_ip = $_SERVER['REMOTE_ADDR'];
                     $query = "UPDATE `:prefix:users` SET login_when=:when, login_ip=:ip WHERE user_id=:id";
                     $self->db()->query($query, array('when' => $get_ts, 'ip' => $get_ip, 'id' => $user['user_id']));
                     if ($redirect_url) {
                         return $redirect_url;
                     }
                     if (self::getInstance()->checkPermission('start', 'start')) {
                         return CAT_ADMIN_URL . '/start/index.php?initial=true';
                     } else {
                         return CAT_URL . '/index.php';
                     }
                 } else {
                     if (!$active && $result->rowCount() == 1) {
                         self::setLoginError($lang->translate('Your account has been disabled. Please contact the administrator.'));
                     } else {
                         self::setLoginError($lang->translate('Invalid credentials'));
                     }
                 }
             }
             if ($val->fromSession('ATTEMPTS') > CAT_Registry::get('MAX_ATTEMPTS') && CAT_Registry::exists('AUTO_DISABLE_USERS') && CAT_Registry::get('AUTO_DISABLE_USERS') === true) {
                 // if we have a user name
                 if ($name) {
                     self::disableAccount($name);
                 }
                 return CAT_THEME_URL . '/templates/warning.html';
             }
             return false;
         }
         if (!$output) {
             return false;
         }
         $username_fieldname = $val->createFieldname('username_');
         $tpl_data = array('USERNAME_FIELDNAME' => $username_fieldname, 'PASSWORD_FIELDNAME' => $val->createFieldname('password_'), 'USERNAME' => $val->sanitizePost($username_fieldname), 'ACTION_URL' => CAT_ADMIN_URL . '/login/index.php', 'LOGIN_URL' => CAT_ADMIN_URL . '/login/index.php', 'DEFAULT_URL' => CAT_ADMIN_URL . '/start/index.php', 'WARNING_URL' => CAT_THEME_URL . '/templates/warning.html', 'REDIRECT_URL' => ADMIN_URL . '/start/index.php', 'FORGOTTEN_DETAILS_APP' => ADMIN_URL . '/login/forgot/index.php', 'MIN_USERNAME_LEN' => AUTH_MIN_LOGIN_LENGTH, 'MAX_USERNAME_LEN' => AUTH_MAX_LOGIN_LENGTH, 'MIN_PASSWORD_LEN' => AUTH_MIN_PASS_LENGTH, 'MAX_PASSWORD_LEN' => AUTH_MAX_PASS_LENGTH, 'PAGES_DIRECTORY' => PAGES_DIRECTORY, 'ATTEMPTS' => $val->fromSession('ATTEMTPS'), 'MESSAGE' => self::$loginerror);
         $tpl_data['meta']['LANGUAGE'] = strtolower(LANGUAGE);
         $tpl_data['meta']['CHARSET'] = defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : "utf-8";
         $parser->output('login', $tpl_data);
     } else {
         if ($redirect_url) {
             header('Location: ' . $redirect_url);
         }
         if (self::getInstance()->checkPermission('start', 'start')) {
             header('Location: ' . CAT_ADMIN_URL . '/start/index.php');
         } else {
             header('Location: ' . CAT_URL . '/index.php');
         }
     }
 }
Пример #8
0
        /**
         * shows a securImage Captcha; needs lib_securimage module
         *
         * @access public
         * @return
         **/
        private static function securImage()
        {
            echo '
            <div class="captcha_table"><div class="captcha_table_imgcalc">
                <span class="image_captcha">
					<img class="" id="image_captcha" src="' . CAT_URL . '/modules/lib_securimage/view.php" alt="Captcha" />
				</span>
				<input type="text" name="captcha_code" size="10" maxlength="6" />
                <a href="#" onclick="document.getElementById(\'image_captcha\').src = \'' . CAT_URL . '/modules/lib_securimage/view.php?\' + Math.random(); return false">[ ' . CAT_Helper_I18n::getInstance()->translate('Different Image') . ' ]</a>
<object type="application/x-shockwave-flash" data="' . CAT_URL . '/modules/lib_securimage/include/securimage_play.swf?audio_file=' . CAT_URL . '/modules/lib_securimage/include/securimage_play.php&amp;bgColor1=#fff&amp;bgColor2=#fff&amp;iconColor=#777&amp;borderWidth=1&amp;borderColor=#000" width="19" height="19">
  <param name="movie" value="' . CAT_URL . '/modules/lib_securimage/include/securimage_play.swf?audio_file=' . CAT_URL . '/modules/lib_securimage/include/securimage_play.php&amp;bgColor1=#fff&amp;bgColor2=#fff&amp;iconColor=#777&amp;borderWidth=1&amp;borderColor=#000" />
</object>

            </div></div>';
        }
Пример #9
0
 /**
  * virtual pages are used for something like
  *   - user preferences dialog
  *   - search results
  *   - ...
  * This methods sets some defaults for this case
  *
  * @access public
  * @return
  **/
 public static function getVirtualPage($title)
 {
     global $page_id, $page_description, $page_keywords;
     $page_id = 0;
     $page_description = '';
     $page_keywords = '';
     define('PAGE_ID', 0);
     define('ROOT_PARENT', 0);
     define('PARENT', 0);
     define('LEVEL', 0);
     define('PAGE_TITLE', CAT_Helper_I18n::getInstance()->translate($title));
     define('MENU_TITLE', CAT_Helper_I18n::getInstance()->translate($title));
     define('MODULE', '');
     define('VISIBILITY', 'public');
 }
Пример #10
0
 /**
  * accessor to I18n helper
  *
  * @access public
  * @return object
  **/
 public static function lang()
 {
     if (!is_object(CAT_Object::$lang)) {
         CAT_Object::$lang = CAT_Helper_I18n::getInstance(CAT_Registry::get('LANGUAGE', NULL, 'EN'));
     }
     return CAT_Object::$lang;
 }