function startup_gettext()
{
    # Get locale from Accept-Language header
    $lang = al2gt(array_keys(get_translations()), "text/html");
    if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
        $lang = _TRANSLATION_OVERRIDE_DEFAULT;
    }
    /* In login action of mobile version */
    if ($_POST["language"] && defined('MOBILE_VERSION')) {
        $lang = $_POST["language"];
    } else {
        if ($_SESSION["language"] && $_SESSION["language"] != "auto") {
            $lang = $_SESSION["language"];
        }
    }
    if ($lang) {
        if (defined('LC_MESSAGES')) {
            _setlocale(LC_MESSAGES, $lang);
        } else {
            if (defined('LC_ALL')) {
                _setlocale(LC_ALL, $lang);
            }
        }
        if (defined('MOBILE_VERSION')) {
            _bindtextdomain("messages", "../locale");
        } else {
            _bindtextdomain("messages", "locale");
        }
        _textdomain("messages");
        _bind_textdomain_codeset("messages", "UTF-8");
    }
}
Exemple #2
0
/**
 * Sets a requested locale, if needed emulates it.
 */
function _setlocale($category, $locale)
{
    global $CURRENTLOCALE, $EMULATEGETTEXT;
    if ($locale === 0) {
        // use === to differentiate between string "0"
        if ($CURRENTLOCALE != '') {
            return $CURRENTLOCALE;
        } else {
            // obey LANG variable, maybe extend to support all of LC_* vars
            // even if we tried to read locale without setting it first
            return _setlocale($category, $CURRENTLOCALE);
        }
    } else {
        $ret = 0;
        if (function_exists('setlocale')) {
            // I don't know if this ever happens ;)
            $ret = setlocale(LC_ALL, $locale);
        }
        if ($ret and $locale == '' or $ret == $locale) {
            $EMULATEGETTEXT = 0;
            $CURRENTLOCALE = $ret;
        } else {
            if ($locale == '') {
                // emulate variable support
                $CURRENTLOCALE = getenv('LANG');
            } else {
                $CURRENTLOCALE = $locale;
            }
            $EMULATEGETTEXT = 1;
        }
        return $CURRENTLOCALE;
    }
}
Exemple #3
0
function startup_gettext()
{
    # Get locale from Accept-Language header
    $lang = al2gt(array_keys(get_translations()), "text/html");
    if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
        $lang = _TRANSLATION_OVERRIDE_DEFAULT;
    }
    if ($_SESSION["uid"] && get_schema_version() >= 120) {
        $pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
        if ($pref_lang && $pref_lang != 'auto') {
            $lang = $pref_lang;
        }
    }
    if ($lang) {
        if (defined('LC_MESSAGES')) {
            _setlocale(LC_MESSAGES, $lang);
        } else {
            if (defined('LC_ALL')) {
                _setlocale(LC_ALL, $lang);
            }
        }
        _bindtextdomain("messages", "locale");
        _textdomain("messages");
        _bind_textdomain_codeset("messages", "UTF-8");
    }
}
 public function setUp()
 {
     MoTranslator\Loader::loadFunctions();
     _setlocale(0, 'cs');
     _textdomain('phpmyadmin');
     _bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/');
     _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
 }
Exemple #5
0
 public function test_setlocale_emulation()
 {
     putenv("LC_ALL=");
     // If we set it to a non-existent locale, it still works, but uses
     // emulation.
     _setlocale(LC_MESSAGES, "xxx_XXX");
     $this->assertEquals('xxx_XXX', _setlocale(LC_MESSAGES, 0));
     $this->assertEquals(1, locale_emulation());
 }
Exemple #6
0
function changeLocale($newlocale)
{
    global $CURRENTLOCALE, $EMULATEGETTEXT, $text_domains;
    $CURRENTLOCALE = $newlocale;
    $EMULATEGETTEXT = 1;
    _textdomain('kusaba');
    _setlocale(LC_ALL, $newlocale);
    _bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang', $newlocale);
    _bind_textdomain_codeset('kusaba', KU_CHARSET);
}
 /**
  * Test for setting and parsing locales
  *
  * @param string $locale locale name
  *
  * @return void
  *
  * @group large
  * @dataProvider listLocales
  */
 public function testGettext($locale)
 {
     /* We should be able to set the language */
     $this->assertTrue(PMA_langSet($locale));
     /* Bind locales */
     _setlocale(LC_MESSAGES, $GLOBALS['lang']);
     _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
     _textdomain('phpmyadmin');
     /* Grab some texts */
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 10));
     $this->assertContains('%s', _ngettext('%s table', '%s tables', 1));
 }
Exemple #8
0
 public function __construct($language_locale_uri)
 {
     $this->language_locale_uri = $language_locale_uri;
     // include php-gettext.php file.
     // @link https://launchpad.net/php-gettext
     if (is_file(SYSTEM_PATH . DS . 'Packages' . DS . 'php-gettext' . DS . 'php-gettext.php')) {
         require_once SYSTEM_PATH . DS . 'Packages' . DS . 'php-gettext' . DS . 'php-gettext.php';
     }
     if (function_exists('_setlocale')) {
         _setlocale(LC_MESSAGES, $language_locale_uri);
     }
 }
Exemple #9
0
 public function test_setlocale()
 {
     // _setlocale defaults to a locale name from environment variable LANG.
     putenv("LANG=sr_RS");
     $this->assertEquals('sr_RS', _setlocale(LC_MESSAGES, 0));
     // For an existing locale, it never needs emulation.
     putenv("LANG=C");
     _setlocale(LC_MESSAGES, "");
     $this->assertEquals(0, locale_emulation());
     // If we set it to a non-existent locale, it still works, but uses
     // emulation.
     _setlocale(LC_MESSAGES, "xxx_XXX");
     $this->assertEquals('xxx_XXX', _setlocale(LC_MESSAGES, 0));
     $this->assertEquals(1, locale_emulation());
 }
Exemple #10
0
function init_locale($locale, $error = 'error')
{
    if (_setlocale(LC_ALL, $locale) === false) {
        $error('The specified locale (' . $locale . ') does not exist on your platform!');
    }
    if (extension_loaded('gettext')) {
        bindtextdomain('tinyboard', './inc/locale');
        bind_textdomain_codeset('tinyboard', 'UTF-8');
        textdomain('tinyboard');
    } else {
        _bindtextdomain('tinyboard', './inc/locale');
        _bind_textdomain_codeset('tinyboard', 'UTF-8');
        _textdomain('tinyboard');
    }
}
Exemple #11
0
function init_locale($locale, $error = 'error')
{
    if ($locale === 'en') {
        $locale = 'en_US.utf8';
    }
    if (extension_loaded('gettext')) {
        setlocale(LC_ALL, $locale);
        bindtextdomain('tinyboard', './inc/locale');
        bind_textdomain_codeset('tinyboard', 'UTF-8');
        textdomain('tinyboard');
    } else {
        _setlocale(LC_ALL, $locale);
        _bindtextdomain('tinyboard', './inc/locale');
        _bind_textdomain_codeset('tinyboard', 'UTF-8');
        _textdomain('tinyboard');
    }
}
function T_setlocale($category, $locale)
{
    return _setlocale($category, $locale);
}
Exemple #13
0
function loadConfig()
{
    global $board, $config, $__ip, $debug, $__version, $microtime_start;
    $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet';
    reset_events();
    if (!isset($_SERVER['REMOTE_ADDR'])) {
        $_SERVER['REMOTE_ADDR'] = '0.0.0.0';
    }
    $arrays = array('db', 'api', 'cache', 'cookies', 'error', 'dir', 'mod', 'spam', 'filters', 'wordfilters', 'custom_capcode', 'custom_tripcode', 'dnsbl', 'dnsbl_exceptions', 'remote', 'allowed_ext', 'allowed_ext_files', 'file_icons', 'footer', 'stylesheets', 'additional_javascript', 'markup', 'custom_pages', 'dashboard_links');
    $config = array();
    foreach ($arrays as $key) {
        $config[$key] = array();
    }
    require 'inc/config.php';
    if (!file_exists('inc/instance-config.php')) {
        $error('Tinyboard is not configured! Create inc/instance-config.php.');
    }
    require 'inc/instance-config.php';
    if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) {
        require $board['dir'] . '/config.php';
    }
    if (!isset($__version)) {
        $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false;
    }
    $config['version'] = $__version;
    date_default_timezone_set($config['timezone']);
    if (!isset($config['global_message'])) {
        $config['global_message'] = false;
    }
    if (!isset($config['post_url'])) {
        $config['post_url'] = $config['root'] . $config['file_post'];
    }
    if (!isset($config['referer_match'])) {
        if (isset($_SERVER['HTTP_HOST'])) {
            $config['referer_match'] = '/^' . (preg_match('@^https?://@', $config['root']) ? '' : 'https?:\\/\\/' . $_SERVER['HTTP_HOST']) . preg_quote($config['root'], '/') . '(' . str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . '(' . preg_quote($config['file_index'], '/') . '|' . str_replace('%d', '\\d+', preg_quote($config['file_page'])) . ')?' . '|' . str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . preg_quote($config['dir']['res'], '/') . str_replace('%d', '\\d+', preg_quote($config['file_page'], '/')) . '|' . preg_quote($config['file_mod'], '/') . '\\?\\/.+' . ')([#?](.+)?)?$/ui';
        } else {
            // CLI mode
            $config['referer_match'] = '//';
        }
    }
    if (!isset($config['cookies']['path'])) {
        $config['cookies']['path'] =& $config['root'];
    }
    if (!isset($config['dir']['static'])) {
        $config['dir']['static'] = $config['root'] . 'static/';
    }
    if (!isset($config['image_sticky'])) {
        $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
    }
    if (!isset($config['image_locked'])) {
        $config['image_locked'] = $config['dir']['static'] . 'locked.gif';
    }
    if (!isset($config['image_bumplocked'])) {
        $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
    }
    if (!isset($config['image_deleted'])) {
        $config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
    }
    if (!isset($config['uri_thumb'])) {
        $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb'];
    } elseif (isset($board['dir'])) {
        $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']);
    }
    if (!isset($config['uri_img'])) {
        $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img'];
    } elseif (isset($board['dir'])) {
        $config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
    }
    if (!isset($config['uri_stylesheets'])) {
        $config['uri_stylesheets'] = $config['root'] . 'stylesheets/';
    }
    if (!isset($config['url_stylesheet'])) {
        $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css';
    }
    if (!isset($config['url_javascript'])) {
        $config['url_javascript'] = $config['root'] . $config['file_script'];
    }
    if (!isset($config['additional_javascript_url'])) {
        $config['additional_javascript_url'] = $config['root'];
    }
    if (!isset($config['uri_flags'])) {
        $config['uri_flags'] = $config['root'] . 'static/flags/%s.png';
    }
    if ($config['root_file']) {
        chdir($config['root_file']);
    }
    if ($config['verbose_errors']) {
        set_error_handler('verbose_error_handler');
        error_reporting(E_ALL);
        ini_set('display_errors', true);
        ini_set('html_errors', false);
    }
    // Keep the original address to properly comply with other board configurations
    if (!isset($__ip)) {
        $__ip = $_SERVER['REMOTE_ADDR'];
    }
    // ::ffff:0.0.0.0
    if (preg_match('/^\\:\\:(ffff\\:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', $__ip, $m)) {
        $_SERVER['REMOTE_ADDR'] = $m[2];
    }
    if ($config['locale'] != 'en') {
        if (_setlocale(LC_ALL, $config['locale']) === false) {
            $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!');
        }
        if (extension_loaded('gettext')) {
            bindtextdomain('tinyboard', './inc/locale');
            bind_textdomain_codeset('tinyboard', 'UTF-8');
            textdomain('tinyboard');
        } else {
            _bindtextdomain('tinyboard', './inc/locale');
            _bind_textdomain_codeset('tinyboard', 'UTF-8');
            _textdomain('tinyboard');
        }
    }
    if ($config['syslog']) {
        openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG);
    }
    // open a connection to sysem logger
    if ($config['recaptcha']) {
        require_once 'inc/lib/recaptcha/recaptchalib.php';
    }
    if ($config['cache']['enabled']) {
        require_once 'inc/cache.php';
    }
    event('load-config');
    if ($config['debug']) {
        if (!isset($debug)) {
            $debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array(), 'time' => array('db_queries' => 0, 'exec' => 0), 'start' => $microtime_start, 'start_debug' => microtime(true));
            $debug['start'] = $microtime_start;
        }
    }
}
Exemple #14
0
<?php

require_once 'config.php';
$locale = LANG;
$textdomain = "multi_lang";
$locales_dir = dirname(__FILE__) . '/lang';
if (isset($_GET['lang']) && !empty($_GET['lang'])) {
    $locale = $_GET['lang'];
}
putenv('LANGUAGE=' . $locale);
putenv('LANG=' . $locale);
putenv('LC_ALL=' . $locale);
putenv('LC_MESSAGES=' . $locale);
require_once 'lib/gettext.inc';
_setlocale(LC_ALL, $locale);
_setlocale(LC_CTYPE, $locale);
_bindtextdomain($textdomain, $locales_dir);
_bind_textdomain_codeset($textdomain, 'UTF-8');
_textdomain($textdomain);
/*
 * This function is an helper that should be
 * used to avoid some repetitions. Use "_e"
 * instead of "echo __".
 */
function _e($string)
{
    echo __($string);
}
/**
 * Sets the defined locale
 *
 * @param string $category The category of the locale to set
 * @param mixed $locale The locale, or an array of locales to try and set
 * @access public
 */
function _setlocale($category, $locale)
{
    if (version_compare(PHP_VERSION, '4.3', '<')) {
        if (is_array($locale)) {
            foreach ($locale as $l) {
                if (($result = _setlocale($category, $l)) !== false) {
                    return $result;
                }
            }
            return false;
        } else {
            return _setlocale($category, $locale);
        }
    } else {
        return _setlocale($category, $locale);
    }
}
Exemple #16
0
/** Initilializes the chosen locales-module. */
function knjlocales_setmodule($domain, $dir, $module = "ext", $language = "auto"){
	global $functions_knjlocales;
	
	$functions_knjlocales["dir"] = $dir;
	$functions_knjlocales["module"] = $module;
	
	if ($language == "auto"){
		if (array_key_exists("HTTP_ACCEPT_LANGUAGE", $_SERVER) and $_SERVER["HTTP_ACCEPT_LANGUAGE"]){
			$accept = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
			foreach(explode(",", $accept) AS $value){
				$value = explode(";", $value);
				$language = $value[0];
				break;
			}
		}elseif($_SERVER["LANG"]){
			if (preg_match("/^([a-z]{2}_[A-Z]{2})/", $_SERVER["LANG"], $match)){
			$language = $match[1];
			}else{
				//Language could not be matched - default english.
				$language = "en_GB";
			}	
		}
		
		if ($language == "da"){
			$language = "da_DK";
		}elseif($language == "de"){
			$language = "de_DE";
		}elseif($language == "en"){
			$language = "en_GB";
		}
	}
	
	$language = strtr($language, array(
		"-" => "_"
	));
	if (preg_match("/^([A-z]{2})_([A-z]{2})$/", $language, $match)){
		$language = strtolower($match[1]) . "_" . strtoupper($match[2]);
	}
	
	$functions_knjlocales["language"] = $language;
	
	if (!file_exists($dir)){
		throw new exception("Dir does not exist: " . $dir);
	}
	
	if ($module == "php-gettext"){
		require_once "php-gettext/gettext.inc";
		$functions_knjlocales["module"] = "php-gettext";
		
		_setlocale(LC_ALL, $language);// or die("Locales error 5\n");
		_setlocale(LC_MESSAGES, $language);// or die("Locales error 6\n");
		_bindtextdomain($domain, $dir);
		_bind_textdomain_codeset($domain, "UTF-8");
		_textdomain($domain);
	}elseif($module == "ext"){
		require_once "knj/functions_knj_extensions.php";
		if (!knj_dl("gettext")){
			throw new exception("gettext-module could not be loaded.");
		}
		
		$functions_knjlocales["module"] = "ext";
		
		putenv("LANGUAGE=" . $language); 
		putenv("LC_ALL=" . $language);
		putenv("LC_MESSAGE=" . $language);
		putenv("LANG=" . $language); 
		
		$locales_language_real = $language . ".utf8";
		setlocale(LC_ALL, $locales_language_real);
		setlocale(LC_MESSAGES, $locales_language_real);
		
		bindtextdomain($domain, $dir);
		bind_textdomain_codeset($domain, "UTF-8");
		textdomain($domain);
	}else{
		throw new exception("knjlocales (" . __FILE__ . ":" . __LINE__ . "): No such module: " . $module . "\n");
	}
}
Exemple #17
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include_once dirname(__FILE__) . '/php-gettext/gettext.inc';
include_once dirname(__FILE__) . '/iso-set.php';
if (!defined('SESSION_DISABLE')) {
    LoadObjectDependency('net.php.pear.HTTP_Session2');
    $lang = HTTP_Session2::get('language', DEFAULT_LANGUAGE);
} else {
    $lang = DEFAULT_LANGUAGE;
}
$locale_dir = dirname(dirname(__FILE__)) . '/locale';
$__domains = array('freemed', UI);
_setlocale(LC_MESSAGES, $lang);
$GLOBALS['ISOSET'] = language2isoset($lang);
foreach ($__domains as $_v) {
    _bindtextdomain($_v, $locale_dir);
    _bind_textdomain_codeset($_v, language2isoset($lang));
    _textdomain($_v);
}
function get_translation_matrix($domain)
{
    global $default_domain;
    $default_domain = $domain;
    $l10n = _get_reader();
    return $l10n->cache_translations;
}
// end method get_translation_matrix
Exemple #18
0
        define($key, $value);
    }
    unset($cf);
}
// DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING OR ELSE BAD THINGS MAY HAPPEN
$modules_loaded = array();
$required = array(KU_ROOTDIR, KU_WEBFOLDER, KU_WEBPATH);
if (in_array('CHANGEME', $required) || in_array('', $required)) {
    echo 'You must set KU_ROOTDIR, KU_WEBFOLDER, and KU_WEBPATH before installation will finish!';
    die;
}
require KU_ROOTDIR . 'lib/gettext/gettext.inc.php';
require KU_ROOTDIR . 'lib/adodb/adodb.inc.php';
// Gettext
_textdomain('kusaba');
_setlocale(LC_ALL, KU_LOCALE);
_bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang');
_bind_textdomain_codeset('kusaba', KU_CHARSET);
// SQL  database
if (!isset($tc_db) && !isset($preconfig_db_unnecessary)) {
    $tc_db =& NewADOConnection(KU_DBTYPE);
    if (KU_DBUSEPERSISTENT) {
        $tc_db->PConnect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
        mysql_query('SET NAMES utf8');
    } else {
        $tc_db->Connect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
        mysql_query('SET NAMES utf8');
    }
    // SQL debug
    if (KU_DEBUG) {
        $tc_db->debug = true;
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    print "This script must be run from the command line\n";
    exit;
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
define('GNUSOCIAL', true);
define('STATUSNET', true);
// compatibility
require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/extlib/php-gettext/gettext.inc';
common_init_locale("en_US");
common_init_locale('fr');
putenv("LANG=fr");
putenv("LANGUAGE=fr");
setlocale('fr.utf8');
_setlocale('fr.utf8');
_bindtextdomain("statusnet", INSTALLDIR . '/locale');
_bindtextdomain("FeedSub", INSTALLDIR . '/plugins/FeedSub/locale');
$times = 10000;
$delta = array();
$start = microtime(true);
for ($i = 0; $i < $times; $i++) {
    $result = _("Send");
}
$delta["_"] = array((microtime(true) - $start) / $times, $result);
$start = microtime(true);
for ($i = 0; $i < $times; $i++) {
    $result = __("Send");
}
$delta["__"] = array((microtime(true) - $start) / $times, $result);
$start = microtime(true);
Exemple #20
0
 /**
  * Activates given translation
  *
  * @return bool
  */
 public function activate()
 {
     $GLOBALS['lang'] = $this->code;
     // Set locale
     _setlocale(LC_MESSAGES, $this->code);
     _bindtextdomain('phpmyadmin', LOCALE_PATH);
     _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
     _textdomain('phpmyadmin');
     /* Text direction for language */
     if ($this->isRTL()) {
         $GLOBALS['text_dir'] = 'rtl';
     } else {
         $GLOBALS['text_dir'] = 'ltr';
     }
     /* TCPDF */
     $GLOBALS['l'] = array();
     /* TCPDF settings */
     $GLOBALS['l']['a_meta_charset'] = 'UTF-8';
     $GLOBALS['l']['a_meta_dir'] = $GLOBALS['text_dir'];
     $GLOBALS['l']['a_meta_language'] = $this->code;
     /* TCPDF translations */
     $GLOBALS['l']['w_page'] = __('Page number:');
     /* Show possible warnings from langauge selection */
     LanguageManager::getInstance()->showWarnings();
 }
Exemple #21
0
 /**
  * Sets active language for for the application.
  * Returns false if locale is invalid or cannot be used.
  *
  * @return  boolean
  */
 public static function set($locale)
 {
     // XXX do not append charset to en_US locale
     if ($locale != 'en_US') {
         $locale = $locale . '.' . APP_CHARSET;
     }
     $res = _setlocale(LC_TIME, $locale);
     if ($res === false) {
         return false;
     }
     $res = _setlocale(LC_MESSAGES, $locale);
     if ($res === false) {
         return false;
     }
     // XXX do not require translations for en_US locale
     if ($locale != 'en_US') {
         // get translator info
         $res = _gettext('');
         // if empty gettext is returned then the mo catalog is not installed.
         if (empty($res)) {
             return false;
         }
     }
     User::resetLocalizedRoles();
     return true;
 }
Exemple #22
0
$arr = array('core', 'mysql');
for ($i = 0; $i < count($arr); $i++) {
    require PHPDISK_ROOT . 'includes/class/' . $arr[$i] . '.class.php';
}
require PHPDISK_ROOT . 'includes/phpdisk_version.inc.php';
$C['gz']['open'] = $settings['gzipcompress'];
phpdisk_core::gzcompress_open();
$db = phpdisk_core::init_db_connect();
$setting_file = PHPDISK_ROOT . 'system/settings.inc.php';
file_exists($setting_file) ? require_once $setting_file : settings_cache();
$arr = phpdisk_core::init_lang_tpl();
$user_tpl_dir = 'templates/default/';
$admin_tpl_dir = $arr['admin_tpl_dir'];
$C['lang_type'] = $arr['lang_name'];
require PHPDISK_ROOT . 'includes/lib/php-gettext/gettext.inc.php';
_setlocale(LC_MESSAGES, $C['lang_type']);
_bindtextdomain('phpdisk', 'languages');
_bind_textdomain_codeset('phpdisk', $charset);
_textdomain('phpdisk');
if (!@get_magic_quotes_gpc()) {
    $_GET = addslashes_array($_GET);
    $_POST = addslashes_array($_POST);
    $_COOKIE = addslashes_array($_COOKIE);
}
$group_settings_file = PHPDISK_ROOT . 'system/global/group_settings.inc.php';
file_exists($group_settings_file) ? require_once $group_settings_file : group_settings_cache();
list($pd_uid, $pd_gid, $pd_username, $pd_pwd, $pd_email) = gpc('phpdisk_zcore_info', 'C', '') ? explode("\t", pd_encode(gpc('phpdisk_zcore_info', 'C', ''), 'DECODE')) : array('', '', '', '', '');
$pd_uid = (int) $pd_uid;
if (!$pd_uid || !$pd_pwd) {
    $pd_uid = 0;
} else {
Exemple #23
0
/*
 * Do the work!
 */
if (!PMA_langCheck()) {
    // fallback language
    $fall_back_lang = 'en';
    $line = __LINE__;
    if (!PMA_langSet($fall_back_lang)) {
        trigger_error('phpMyAdmin-ERROR: invalid lang code: ' . __FILE__ . '#' . $line . ', check hard coded fall back language.', E_USER_WARNING);
        // stop execution
        // and tell the user that his chosen language is invalid
        PMA_fatalError('Could not load any language, ' . 'please check your language settings and folder.');
    }
}
// Set locale
_setlocale(LC_MESSAGES, $GLOBALS['lang']);
_bindtextdomain('phpmyadmin', $GLOBALS['lang_path']);
_bind_textdomain_codeset('phpmyadmin', 'UTF-8');
_textdomain('phpmyadmin');
/**
 * Messages for phpMyAdmin.
 *
 * These messages are here for easy transition to Gettext.
 * You should not add any messages here, use instead gettext directly
 * in your template/PHP file.
 */
if (!function_exists('__')) {
    PMA_fatalError('Bad invocation!');
}
/* Text direction for language */
if (in_array($GLOBALS['lang'], array('ar', 'fa', 'he', 'ur'))) {
Exemple #24
0
function loadConfig()
{
    global $board, $config, $__ip, $debug, $__version;
    if (!isset($_SERVER['REMOTE_ADDR'])) {
        $_SERVER['REMOTE_ADDR'] = '0.0.0.0';
    }
    require 'inc/config.php';
    if (file_exists('inc/instance-config.php')) {
        require 'inc/instance-config.php';
    }
    if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) {
        require $board['dir'] . '/config.php';
    }
    if (!isset($__version)) {
        $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false;
    }
    $config['version'] = $__version;
    if ($config['debug']) {
        if (!isset($debug)) {
            $debug = array('sql' => array(), 'purge' => array(), 'cached' => array());
            $debug['start'] = microtime(true);
        }
    }
    date_default_timezone_set($config['timezone']);
    if (!isset($config['blotter'])) {
        $config['blotter'] = false;
    }
    if (!isset($config['post_url'])) {
        $config['post_url'] = $config['root'] . $config['file_post'];
    }
    if (!isset($config['referer_match'])) {
        $config['referer_match'] = '/^' . (preg_match($config['url_regex'], $config['root']) ? '' : 'https?:\\/\\/' . $_SERVER['HTTP_HOST']) . preg_quote($config['root'], '/') . '(' . str_replace('%s', '\\w+', preg_quote($config['board_path'], '/')) . '(' . preg_quote($config['file_index'], '/') . '|' . str_replace('%d', '\\d+', preg_quote($config['file_page'])) . ')?' . '|' . str_replace('%s', '\\w+', preg_quote($config['board_path'], '/')) . preg_quote($config['dir']['res'], '/') . str_replace('%d', '\\d+', preg_quote($config['file_page'], '/')) . '|' . preg_quote($config['file_mod'], '/') . '\\?\\/.+' . ')([#?](.+)?)?$/i';
    }
    if (!isset($config['cookies']['path'])) {
        $config['cookies']['path'] =& $config['root'];
    }
    if (!isset($config['dir']['static'])) {
        $config['dir']['static'] = $config['root'] . 'static/';
    }
    if (!isset($config['image_sticky'])) {
        $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif';
    }
    if (!isset($config['image_locked'])) {
        $config['image_locked'] = $config['dir']['static'] . 'locked.gif';
    }
    if (!isset($config['image_bumplocked'])) {
        $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif';
    }
    if (!isset($config['image_deleted'])) {
        $config['image_deleted'] = $config['dir']['static'] . 'deleted.png';
    }
    if (!isset($config['image_zip'])) {
        $config['image_zip'] = $config['dir']['static'] . 'zip.png';
    }
    if (!isset($config['uri_thumb'])) {
        $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb'];
    } elseif (isset($board['dir'])) {
        $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']);
    }
    if (!isset($config['uri_img'])) {
        $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img'];
    } elseif (isset($board['dir'])) {
        $config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
    }
    if (!isset($config['uri_stylesheets'])) {
        $config['uri_stylesheets'] = $config['root'] . 'stylesheets/';
    }
    if (!isset($config['url_stylesheet'])) {
        $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css';
    }
    if (!isset($config['url_javascript'])) {
        $config['url_javascript'] = $config['root'] . 'main.js';
    }
    if ($config['root_file']) {
        chdir($config['root_file']);
    }
    if ($config['verbose_errors']) {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
    }
    // Keep the original address to properly comply with other board configurations
    if (!isset($__ip)) {
        $__ip = $_SERVER['REMOTE_ADDR'];
    }
    // ::ffff:0.0.0.0
    if (preg_match('/^\\:\\:(ffff\\:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', $__ip, $m)) {
        $_SERVER['REMOTE_ADDR'] = $m[2];
    }
    if (_setlocale(LC_ALL, $config['locale']) === false) {
        $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet';
        $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!');
    }
    if (extension_loaded('gettext')) {
        bindtextdomain('tinyboard', './inc/locale');
        bind_textdomain_codeset('tinyboard', 'UTF-8');
        textdomain('tinyboard');
    } else {
        _bindtextdomain('tinyboard', './inc/locale');
        _bind_textdomain_codeset('tinyboard', 'UTF-8');
        _textdomain('tinyboard');
    }
    if ($config['syslog']) {
        openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG);
    }
    // open a connection to sysem logger
    if ($config['recaptcha']) {
        require_once 'inc/contrib/recaptcha/recaptchalib.php';
    }
    if ($config['cache']['enabled']) {
        require_once 'inc/cache.php';
    }
}