From cbf44d4d75db5c12fdc694aa321c12a3f9eec403 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 18 Feb 2014 20:42:19 +0100 Subject: cleanup: don't trigger rebuild code; fail silently (boardlink race fix; I will test it a bit) --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 4c3f6a4e..d26abcb7 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1057,7 +1057,7 @@ function clean() { $query->execute() or error(db_error($query)); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - deletePost($post['id']); + deletePost($post['id'], false, false); } } -- cgit v1.3 From 0354b9a5e37a63c4984c7e466e2099f7649a36d8 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 23 Feb 2014 18:49:04 +0100 Subject: finally fix i18n strings in config.php --- inc/functions.php | 63 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 17 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index d26abcb7..7cae3266 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -28,8 +28,25 @@ register_shutdown_function('fatal_error_handler'); mb_internal_encoding('UTF-8'); loadConfig(); +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'); + } +} +$current_locale = 'en'; + + function loadConfig() { - global $board, $config, $__ip, $debug, $__version, $microtime_start; + global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale; $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; @@ -70,16 +87,43 @@ function loadConfig() { $config[$key] = array(); } - require 'inc/config.php'; if (!file_exists('inc/instance-config.php')) $error('Tinyboard is not configured! Create inc/instance-config.php.'); + // Initialize locale as early as possible + + $config['locale'] = 'en'; + + $configstr = file_get_contents('inc/instance-config.php'); + + if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { + $configstr .= file_get_contents($board['dir'] . '/config.php'); + } + $matches = array(); + preg_match_all('/$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); + if ($matches && isset ($matches[2]) && $matches[2]) { + $matches = $matches[2]; + $config['locale'] = $matches[count($matches)-1]; + } + + if ($config['locale'] != $current_locale) { + $current_locale = $config['locale']; + init_locale($config['locale'], $error); + } + + require 'inc/config.php'; + require 'inc/instance-config.php'; if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { require $board['dir'] . '/config.php'; } + if ($config['locale'] != $current_locale) { + $current_locale = $config['locale']; + init_locale($config['locale'], $error); + } + if (!isset($__version)) $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; $config['version'] = $__version; @@ -174,21 +218,6 @@ function loadConfig() { 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 -- cgit v1.3 From 9c30e380d81789df990b8c58faccae5a5067a856 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 23 Feb 2014 18:54:31 +0100 Subject: actually fix prevous commit --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 7cae3266..b62b41da 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -100,7 +100,7 @@ function loadConfig() { $configstr .= file_get_contents($board['dir'] . '/config.php'); } $matches = array(); - preg_match_all('/$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); + preg_match_all('/\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); if ($matches && isset ($matches[2]) && $matches[2]) { $matches = $matches[2]; $config['locale'] = $matches[count($matches)-1]; -- cgit v1.3 From 58615845adcb69346ef8628928a989f31efbb54b Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 23 Feb 2014 19:01:41 +0100 Subject: allow basic commenting of locale string --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index b62b41da..5b5f5bdd 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -100,7 +100,7 @@ function loadConfig() { $configstr .= file_get_contents($board['dir'] . '/config.php'); } $matches = array(); - preg_match_all('/\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); + preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); if ($matches && isset ($matches[2]) && $matches[2]) { $matches = $matches[2]; $config['locale'] = $matches[count($matches)-1]; -- cgit v1.3 From 75cca1ffb2a41a2381f5287fd9bb8ea292a9c281 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 24 Feb 2014 15:29:26 +0100 Subject: fix previous commit --- inc/config.php | 2 +- inc/functions.php | 3 +++ templates/post_reply.html | 10 +++++----- templates/post_thread.html | 16 +++++++++++++--- 4 files changed, 22 insertions(+), 9 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/config.php b/inc/config.php index 2af0f391..6c7247b4 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1074,7 +1074,7 @@ $config['dir']['home'] = ''; // Location of a blank 1x1 gif file. Only used when country_flags_condensed is enabled - $config['uri_blank'] = $config['root'] . 'static/blank.gif'; + // $config['image_blank'] = 'static/blank.gif'; // Static images. These can be URLs OR base64 (data URI scheme). These are only used if // $config['font_awesome'] is false (default). diff --git a/inc/functions.php b/inc/functions.php index 5b5f5bdd..a65bf720 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -168,6 +168,9 @@ function loadConfig() { if (!isset($config['dir']['static'])) $config['dir']['static'] = $config['root'] . 'static/'; + if (!isset($config['image_blank'])) + $config['image_blank'] = $config['dir']['static'] . 'blank.gif'; + if (!isset($config['image_sticky'])) $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; if (!isset($config['image_locked'])) diff --git a/templates/post_reply.html b/templates/post_reply.html index fb240511..713ddac9 100644 --- a/templates/post_reply.html +++ b/templates/post_reply.html @@ -31,17 +31,17 @@ {% if config.display_flags and post.modifiers.flag %} + {% if post.modifiers['flag alt'] %} alt="{{ post.modifiers['flag alt'] | e('html_attr') }}" + title="{{ post.modifiers['flag alt'] | e('html_attr') }}"{% endif %}> {% endif %} diff --git a/templates/post_thread.html b/templates/post_thread.html index d922dabd..113444be 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -83,9 +83,19 @@ [{{ post.ip }}] {% endif %} {% if config.display_flags and post.modifiers.flag %} - + {{ post.modifiers['flag alt'] | e('html_attr') }} {% endif %} -- cgit v1.3 From 2a41c37feef23d9027c9852b2646dba6d03291b1 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 13 Mar 2014 22:39:32 +0100 Subject: fix link_prefix. thanks to anon on http://tinyboard.org/demo/mod.php?/sup/res/1210.html --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index a65bf720..488a4117 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1590,7 +1590,7 @@ function markup_url($matches) { $markup_urls[] = $url; $link = (object) array( - 'href' => $url, + 'href' => $config['link_prefix'] . $url, 'text' => $url, 'rel' => 'nofollow', 'target' => '_blank', -- cgit v1.3