Esempio n. 1
0
function doboard($board)
{
    global $global_locale, $config, $main_js, $options;
    $config['mask_db_error'] = false;
    if (!$options['api']) {
        $config['api']['enabled'] = false;
    }
    echo "Opening board /{$board['uri']}/...\n";
    // Reset locale to global locale
    $config['locale'] = $global_locale;
    init_locale($config['locale'], 'error');
    openBoard($board['uri']);
    $config['try_smarter'] = false;
    if ($config['file_script'] != $main_js && $options['js']) {
        // different javascript file
        echo "(/{$board['uri']}/) Generating Javascript file...\n";
        buildJavascript();
    }
    if ($options['indexes']) {
        echo "(/{$board['uri']}/) Creating index pages...\n";
        buildIndex();
    }
    if ($options['postmarkup']) {
        $query = query(sprintf("SELECT `id` FROM ``posts_%s``", $board['uri'])) or error(db_error());
        while ($post = $query->fetch()) {
            echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n";
            rebuildPost($post['id']);
        }
    }
    if ($options['threads']) {
        $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
        while ($post = $query->fetch()) {
            echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n";
            @buildThread($post['id']);
        }
    }
}
Esempio n. 2
0
function rebuildThemes($action, $boardname = false)
{
    global $config, $board, $current_locale, $error;
    // Save the global variables
    $_config = $config;
    $_board = $board;
    // List themes
    if ($themes = Cache::get("themes")) {
        // OK, we already have themes loaded
    } else {
        $query = query("SELECT `theme` FROM ``theme_settings`` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
        $themes = array();
        while ($theme = $query->fetch(PDO::FETCH_ASSOC)) {
            $themes[] = $theme;
        }
        Cache::set("themes", $themes);
    }
    foreach ($themes as $theme) {
        // Restore them
        $config = $_config;
        $board = $_board;
        // Reload the locale
        if ($config['locale'] != $current_locale) {
            $current_locale = $config['locale'];
            init_locale($config['locale'], $error);
        }
        rebuildTheme($theme['theme'], $action, $boardname);
    }
    // Restore them again
    $config = $_config;
    $board = $_board;
    // Reload the locale
    if ($config['locale'] != $current_locale) {
        $current_locale = $config['locale'];
        init_locale($config['locale'], $error);
    }
}
Esempio n. 3
0
        $text_dir = $Config['text_dir'];
    }
} else {
    $text_dir = $args['d'];
}
// Formatter options
$opts = array();
if (isset($args['n'])) {
    $opts = array('filters' => array('namumarkup'));
}
// set $text_dir
$DBInfo->text_dir = $text_dir;
$Config['text_dir'] = $text_dir;
// setup locale, $lang
$lang = set_locale('ko_KR', $Config['charset']);
init_locale($lang);
$Config['lang'] = $lang;
$DBInfo->lang = $lang;
// get remain $argv array
foreach ($args as $k => $v) {
    while ($i = array_search('-' . $k, $argv)) {
        if ($i) {
            unset($argv[$i]);
        }
        if (preg_match("/^.*" . $k . ":.*\$/i", $short_opts)) {
            unset($argv[$i + 1]);
        }
    }
}
$argv = array_merge($argv);
function render($pagename, $type, $params = array())
Esempio n. 4
0
function loadConfig()
{
    global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale;
    $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();
    }
    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;
    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'], '/')) . '|' . str_replace('%d', '\\d+', preg_quote($config['file_page50'], '/')) . ')' . '|' . 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_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'])) {
        $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 (!isset($config['user_flag'])) {
        $config['user_flag'] = false;
    }
    if (!isset($config['user_flags'])) {
        $config['user_flags'] = array();
    }
    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);
    } else {
        ini_set('display_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['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';
    }
    if (in_array('webm', $config['allowed_ext_files'])) {
        require_once 'inc/lib/webm/posthandler.php';
        event_handler('post', 'postHandler');
    }
    if (is_array($config['anonymous'])) {
        $config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])];
    }
    if ($config['allow_roll']) {
        event_handler('post', 'diceRoller');
    }
    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;
        }
    }
}
Esempio n. 5
0
require_once dirname(__FILE__) . '/../okdk/locale/class.Locale.php';
require_once dirname(__FILE__) . '/../okdk/utils/class.StringUtils.php';
require_once dirname(__FILE__) . '/../okdk/utils/class.DateUtils.php';
require_once dirname(__FILE__) . '/../okdk/utils/class.ArrayUtils.php';
require_once dirname(__FILE__) . '/../okdk/mail/class.Mail.php';
//Local
require_once dirname(__FILE__) . '/loc.parameters_remote.php';
require_once dirname(__FILE__) . '/loc.parameters.php';
require_once dirname(__FILE__) . '/loc.fonctions.php';
require_once dirname(__FILE__) . '/loc.texts.php';
//-----------------------------------------------------------------------
/* Séquence d'initialisations */
//-----------------------------------------------------------------------
init_session();
init_mysql();
init_locale();
init_locale_text();
//-----------------------------------------------------------------------
/* Fonctions d'initialisations */
//-----------------------------------------------------------------------
function init_mysql()
{
    global $mysql;
    //Variables de connexion
    $mysql = new MySQL();
    $mysql->hostname = DB_HOSTNAME;
    $mysql->bduser = DB_USER;
    $mysql->bdpassword = DB_PASSWORD;
    $mysql->bdname = DB_NAME;
    $mysql->connect_db();
    $mysql->select_db();