diff options
| author | czaks <marcin@6irc.net> | 2013-07-31 14:54:20 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-07-31 14:54:20 -0400 |
| commit | 55c7146d884005f70d15e991a9e8ea31b7021361 (patch) | |
| tree | 57b6548601dfd1542febe05375efe49d439e1fb4 /inc | |
| parent | ee23ec1e24bb2a0cec24af011012e95652ce85a9 (diff) | |
| parent | 8e4c493a4c5bbff07483fd4a11c44c687c99e441 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts:
inc/config.php
inc/display.php
inc/functions.php
inc/image.php
js/expand.js
js/hide-threads.js
js/local-time.js
js/smartphone-spoiler.js
templates/header.html
templates/index.html
templates/main.js
templates/page.html
templates/post_reply.html
templates/post_thread.html
templates/thread.html
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 21 | ||||
| -rw-r--r-- | inc/display.php | 1 | ||||
| -rw-r--r-- | inc/functions.php | 9 | ||||
| -rw-r--r-- | inc/image.php | 8 | ||||
| -rw-r--r-- | inc/mod/pages.php | 17 | ||||
| -rw-r--r-- | inc/template.php | 144 |
6 files changed, 116 insertions, 84 deletions
diff --git a/inc/config.php b/inc/config.php index f24a035c..38a17e03 100644 --- a/inc/config.php +++ b/inc/config.php @@ -335,9 +335,14 @@ $config['auto_unicode'] = true; // Whether to turn URLs into functional links $config['markup_urls'] = true; + // Prefix those functional links with some other url, for example some service for hiding referers // (eg. 'http://www.nullrefer.com/?', or 'http://anonym.to/?'), a pay-per-view exit page, etc. - $config['url_ads'] = ''; + $config['url_ads'] = &$config['link_prefix']; // leave alias + + // Optional URL prefix for links (eg. "http://anonym.to/?") + $config['link_prefix'] = ''; + // Wordfilters are used to automatically replace certain words/phrases with something else. // For a normal string replacement: @@ -486,7 +491,7 @@ // Display the file's original filename $config['show_filename']= true; - // Image identification buttons using regex.info/exif, tineye and google images + // Image identification links using regex.info/exif, TinEye and Google Images $config['image_identification'] = false; // Redraw the image using GD functions to strip any excess data (commonly ZIP archives) @@ -542,8 +547,8 @@ $config['ban_date'] = '%A %e %B, %Y'; // The names on the post buttons. (On most imageboards, these are both "Post") - $config['button_newtopic'] = 'New Topic'; - $config['button_reply'] = 'New Reply'; + $config['button_newtopic'] = _('New Topic'); + $config['button_reply'] = _('New Reply'); // Assign each poster in a thread a unique ID, shown by "ID: {id}" before the post number. $config['poster_ids'] = false; @@ -554,7 +559,7 @@ $config['thread_subject_in_title'] = false; // Page footer - $config['footer'][] = 'All trademarks, copyrights, comments, and images on this page are owned by and are the responsibility of their respective parties.'; + $config['footer'][] = _('All trademarks, copyrights, comments, and images on this page are owned by and are the responsibility of their respective parties.'); // Characters used to generate a random password (with Javascript) $config['genpassword_chars'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+'; @@ -764,9 +769,9 @@ else $config['root'] = '/'; // CLI mode - // The scheme and domain. This is needed to get absolute URL of some page (for instance image - // identification buttons). If you use the CLI tools, it would be wise to override this setting. - $config['domain'] = (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? "https://" : "http://"; + // The scheme and domain. This is used to get the site's absolute URL (eg. for image identification links). + // If you use the CLI tools, it would be wise to override this setting. + $config['domain'] = (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? "https://" : "http://"; $config['domain'] .= isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; // If for some reason the folders and static HTML index files aren't in the current working direcotry, diff --git a/inc/display.php b/inc/display.php index a2d50f74..3ce8eced 100644 --- a/inc/display.php +++ b/inc/display.php @@ -25,6 +25,7 @@ function doBoardListPart($list, $root) { $body = ''; foreach ($list as $board) { if (is_array($board)) + // $body .= ' [' . doBoardListPart($board, $root) . '] '; $body .= ' <span class="sub">[' . doBoardListPart($board, $root) . ']</span> '; else { if (($key = array_search($board, $list)) && gettype($key) == 'string') { diff --git a/inc/functions.php b/inc/functions.php index 42cdb660..8d1ae920 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1311,6 +1311,13 @@ function buildJavascript() { 'config' => $config, 'stylesheets' => $stylesheets )); + + // Check if we have translation for the javascripts; if yes, we add it to additional javascripts + list($pure_locale) = explode(".", $config['locale']); + if (file_exists ($jsloc = "inc/locale/$pure_locale/LC_MESSAGES/javascript.js")) { + $script = file_get_contents($jsloc) . "\n\n" . $script; + } + if ($config['additional_javascript_compile']) { foreach ($config['additional_javascript'] as $file) { $script .= file_get_contents($file); @@ -1415,7 +1422,7 @@ function markup_url($matches) { $markup_urls[] = $url; - return '<a target="_blank" rel="nofollow" href="'. $config['url_ads'] . $url . '">' . $url . '</a>' . $after; + return '<a target="_blank" rel="nofollow" href="'. $config['link_prefix'] . $url . '">' . $url . '</a>' . $after; } function unicodify($body) { diff --git a/inc/image.php b/inc/image.php index 7aea9bfe..8cc9d69b 100644 --- a/inc/image.php +++ b/inc/image.php @@ -81,9 +81,7 @@ class Image { $height = $max_height; } - if ($gifsicle) { - $thumb->gifsicle = 1; - } + $thumb->gifsicle = $gifsicle; $thumb->_resize($this->image->image, $width, $height); return $thumb; @@ -288,8 +286,12 @@ class ImageConvert extends ImageBase { if (shell_exec("gifsicle --unoptimize -O2 --resize {$this->width}x{$this->height} < " . escapeshellarg($this->src . '') . " > " . escapeshellarg($this->temp)) || !file_exists($this->temp)) error('Failed to resize image!'); +<<<<<<< HEAD } else { +======= + } else { +>>>>>>> 8e4c493a4c5bbff07483fd4a11c44c687c99e441 if (shell_exec("convert -background transparent -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " . escapeshellarg($this->src . '') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) error('Failed to resize image!'); diff --git a/inc/mod/pages.php b/inc/mod/pages.php index ab4cdaaf..08604039 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -446,6 +446,23 @@ function mod_new_board() { if (!preg_match('/^' . $config['board_regex'] . '$/u', $_POST['uri'])) error(sprintf($config['error']['invalidfield'], 'URI')); + $bytes = 0; + $chars = preg_split('//u', $_POST['uri'], -1, PREG_SPLIT_NO_EMPTY); + foreach ($chars as $char) { + $o = 0; + $ord = ordutf8($char, $o); + if ($ord > 0x0080) + $bytes += 5; // @01ff + else + $bytes ++; + } + $bytes + strlen('posts_.frm'); + + if ($bytes > 255) { + error('Your filesystem cannot handle a board URI of that length (' . $bytes . '/255 bytes)'); + exit; + } + if (openBoard($_POST['uri'])) { error(sprintf($config['error']['boardexists'], $board['url'])); } diff --git a/inc/template.php b/inc/template.php index 071fa761..09e27c26 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1,72 +1,72 @@ -<?php
-
-/*
- * Copyright (c) 2010-2013 Tinyboard Development Group
- */
-
-if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
- // You cannot request this file directly.
- exit;
-}
-
-$twig = false;
-
-function load_twig() {
- global $twig, $config;
-
- require 'lib/Twig/Autoloader.php';
- Twig_Autoloader::register();
-
- Twig_Autoloader::autoload('Twig_Extensions_Node_Trans');
- Twig_Autoloader::autoload('Twig_Extensions_TokenParser_Trans');
- Twig_Autoloader::autoload('Twig_Extensions_Extension_I18n');
- Twig_Autoloader::autoload('Twig_Extensions_Extension_Tinyboard');
-
- $loader = new Twig_Loader_Filesystem($config['dir']['template']);
- $loader->setPaths($config['dir']['template']);
- $twig = new Twig_Environment($loader, array(
- 'autoescape' => false,
- 'cache' => "{$config['dir']['template']}/cache",
- 'debug' => $config['debug']
- ));
- $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
- $twig->addExtension(new Twig_Extensions_Extension_I18n());
-}
-
-function Element($templateFile, array $options) {
- global $config, $debug, $twig;
-
- if (!$twig)
- load_twig();
-
- if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) {
- $options['pm'] = create_pm_header();
- }
-
- if (isset($options['body']) && $config['debug']) {
- if (isset($debug['start'])) {
- $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
- unset($debug['start']);
- }
- $debug['included'] = get_included_files();
- $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
- $options['body'] .=
- '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' .
- str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) .
- '</pre>';
- }
-
- // Read the template file
- if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) {
- $body = $twig->render($templateFile, $options);
-
- if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) {
- $body = trim(preg_replace("/[\t\r\n]/", '', $body));
- }
-
- return $body;
- } else {
- throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
- }
-}
-
+<?php + +/* + * Copyright (c) 2010-2013 Tinyboard Development Group + */ + +if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { + // You cannot request this file directly. + exit; +} + +$twig = false; + +function load_twig() { + global $twig, $config; + + require 'lib/Twig/Autoloader.php'; + Twig_Autoloader::register(); + + Twig_Autoloader::autoload('Twig_Extensions_Node_Trans'); + Twig_Autoloader::autoload('Twig_Extensions_TokenParser_Trans'); + Twig_Autoloader::autoload('Twig_Extensions_Extension_I18n'); + Twig_Autoloader::autoload('Twig_Extensions_Extension_Tinyboard'); + + $loader = new Twig_Loader_Filesystem($config['dir']['template']); + $loader->setPaths($config['dir']['template']); + $twig = new Twig_Environment($loader, array( + 'autoescape' => false, + 'cache' => "{$config['dir']['template']}/cache", + 'debug' => $config['debug'] + )); + $twig->addExtension(new Twig_Extensions_Extension_Tinyboard()); + $twig->addExtension(new Twig_Extensions_Extension_I18n()); +} + +function Element($templateFile, array $options) { + global $config, $debug, $twig; + + if (!$twig) + load_twig(); + + if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) { + $options['pm'] = create_pm_header(); + } + + if (isset($options['body']) && $config['debug']) { + if (isset($debug['start'])) { + $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms'; + unset($debug['start']); + } + $debug['included'] = get_included_files(); + $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB'; + $options['body'] .= + '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . + str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) . + '</pre>'; + } + + // Read the template file + if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) { + $body = $twig->render($templateFile, $options); + + if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) { + $body = trim(preg_replace("/[\t\r\n]/", '', $body)); + } + + return $body; + } else { + throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!"); + } +} + |
