Exemplo n.º 1
0
$options['board'] = isset($opts['board']) ? $opts['board'] : (isset($opts['b']) ? $opts['b'] : false);
$options['quiet'] = isset($opts['q']) || isset($opts['quiet']);
$options['quick'] = isset($opts['quick']);
$options['full'] = isset($opts['full']) || isset($opts['f']);
if (!$options['quiet']) {
    echo "== Tinyboard + vichan {$config['version']} ==\n";
}
if (!$options['quiet']) {
    echo "Clearing template cache...\n";
}
load_twig();
$twig->clearCacheFiles();
if (!$options['quiet']) {
    echo "Regenerating theme files...\n";
}
rebuildThemes('all');
if (!$options['quiet']) {
    echo "Generating Javascript file...\n";
}
buildJavascript();
$main_js = $config['file_script'];
$boards = listBoards();
foreach ($boards as &$board) {
    if ($options['board'] && $board['uri'] != $options['board']) {
        continue;
    }
    if (!$options['quiet']) {
        echo "Opening board /{$board['uri']}/...\n";
    }
    // Reset locale to global locale
    $config['locale'] = $global_locale;
Exemplo n.º 2
0
    $query = prepare('INSERT INTO ``mods`` VALUES (NULL, :username, :password, :salt, :type, :boards, :email)');
    $query->bindValue(':username', $username);
    $query->bindValue(':password', $password);
    $query->bindValue(':salt', $salt);
    $query->bindValue(':type', 20);
    $query->bindValue(':boards', $uri);
    $query->bindValue(':email', $email);
    $query->execute() or error(db_error($query));
    $query = prepare('INSERT INTO ``boards`` (`uri`, `title`, `subtitle`) VALUES (:uri, :title, :subtitle)');
    $query->bindValue(':uri', $_POST['uri']);
    $query->bindValue(':title', $_POST['title']);
    $query->bindValue(':subtitle', $_POST['subtitle']);
    $query->execute() or error(db_error($query));
    $query = Element('posts.sql', array('board' => $uri));
    query($query) or error(db_error());
    if (!openBoard($_POST['uri'])) {
        error(_("Couldn't open board after creation."));
    }
    if ($config['cache']['enabled']) {
        cache::delete('all_boards');
    }
    // Build the board
    buildIndex();
    rebuildThemes('boards');
    $query = prepare("INSERT INTO ``board_create``(uri) VALUES(:uri)");
    $query->bindValue(':uri', $uri);
    $query->execute() or error(db_error());
    _syslog(LOG_NOTICE, "New board: {$uri}");
    $body = Element("8chan/create_success.html", array("config" => $config, "password" => $_POST['password'], "uri" => $uri));
    echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Success"), "subtitle" => _("This was a triumph")));
}
Exemplo n.º 3
0
 public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
 {
     global $mod, $pdo, $board;
     if ($mod_id === false) {
         $mod_id = isset($mod['id']) ? $mod['id'] : -1;
     }
     $range = self::parse_range($mask);
     $mask = self::range_to_string($range);
     $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
     $query->bindValue(':ipstart', $range[0]);
     if ($range[1] !== false && $range[1] != $range[0]) {
         $query->bindValue(':ipend', $range[1]);
     } else {
         $query->bindValue(':ipend', null, PDO::PARAM_NULL);
     }
     $query->bindValue(':mod', $mod_id);
     $query->bindValue(':time', time());
     if ($reason !== '') {
         $reason = escape_markup_modifiers($reason);
         markup($reason);
         $query->bindValue(':reason', $reason);
     } else {
         $query->bindValue(':reason', null, PDO::PARAM_NULL);
     }
     if ($length) {
         if (is_int($length) || ctype_digit($length)) {
             $length = time() + $length;
         } else {
             $length = self::parse_time($length);
         }
         $query->bindValue(':expires', $length);
     } else {
         $query->bindValue(':expires', null, PDO::PARAM_NULL);
     }
     if ($ban_board) {
         $query->bindValue(':board', $ban_board);
     } else {
         $query->bindValue(':board', null, PDO::PARAM_NULL);
     }
     if ($post) {
         $post['board'] = $board['uri'];
         $query->bindValue(':post', json_encode($post));
     } else {
         $query->bindValue(':post', null, PDO::PARAM_NULL);
     }
     $query->execute() or error(db_error($query));
     if (isset($mod['id']) && $mod['id'] == $mod_id) {
         modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
     }
     rebuildThemes('bans');
     return $pdo->lastInsertId();
 }
Exemplo n.º 4
0
         $clone($post['file_thumb'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']);
     }
     foreach ($post['tracked_cites'] as $cite) {
         $query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
         $query->bindValue(':board', $board['uri']);
         $query->bindValue(':post', $newPostID, PDO::PARAM_INT);
         $query->bindValue(':target_board', $cite[0]);
         $query->bindValue(':target', $cite[1], PDO::PARAM_INT);
         $query->execute() or error(db_error($query));
     }
 }
 // build thread
 buildThread($newID);
 buildIndex();
 // trigger themes
 rebuildThemes('post');
 openBoard($boardName);
 if ($shadow) {
     // lock thread
     $query = prepare(sprintf("UPDATE `posts_%s` SET `locked` = 1 WHERE `id` = :id", $board['uri']));
     $query->bindValue(':id', $postID, PDO::PARAM_INT);
     $query->execute() or error(db_error($query));
     $post = array('mod' => true, 'subject' => '', 'email' => '', 'name' => $config['mod']['shadow_name'], 'capcode' => $config['mod']['shadow_capcode'], 'trip' => '', 'body' => sprintf($config['mod']['shadow_mesage'], '>>>/' . $targetBoard . '/' . $newID), 'password' => '', 'has_file' => false, 'thread' => $postID, 'op' => false);
     markup($post['body']);
     $botID = post($post);
     buildThread($postID);
     header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['dir']['res'] . sprintf($config['file_page'], $postID) . '#' . $botID, true, $config['redirect_http']);
 } else {
     deletePost($postID);
     buildIndex();
     openBoard($targetBoard);
Exemplo n.º 5
0
    if ($config['try_smarter'] && $post['op']) {
        $build_pages = range(1, $config['max_pages']);
    }
    if ($post['op']) {
        clean();
    }
    event('post-after', $post);
    // We are already done, let's continue our heavy-lifting work in the background (if we run off FastCGI)
    if (function_exists('fastcgi_finish_request')) {
        @fastcgi_finish_request();
    }
    buildIndex();
    if ($post['op']) {
        rebuildThemes('post-thread', $board['uri']);
    } else {
        rebuildThemes('post', $board['uri']);
    }
} elseif (isset($_POST['appeal'])) {
    if (!isset($_POST['ban_id'])) {
        error($config['error']['bot']);
    }
    $ban_id = (int) $_POST['ban_id'];
    $bans = Bans::find($_SERVER['REMOTE_ADDR']);
    foreach ($bans as $_ban) {
        if ($_ban['id'] == $ban_id) {
            $ban = $_ban;
            break;
        }
    }
    if (!isset($ban)) {
        error(_("That ban doesn't exist or is not for you."));
Exemplo n.º 6
0
function mod_theme_configure($theme_name)
{
    global $config;
    if (!hasPermission($config['mod']['themes'])) {
        error($config['error']['noaccess']);
    }
    if (!($theme = loadThemeConfig($theme_name))) {
        error($config['error']['invalidtheme']);
    }
    if (isset($_POST['install'])) {
        // Check if everything is submitted
        foreach ($theme['config'] as &$conf) {
            if (!isset($_POST[$conf['name']]) && $conf['type'] != 'checkbox') {
                error(sprintf($config['error']['required'], $c['title']));
            }
        }
        // Clear previous settings
        $query = prepare("DELETE FROM ``theme_settings`` WHERE `theme` = :theme");
        $query->bindValue(':theme', $theme_name);
        $query->execute() or error(db_error($query));
        foreach ($theme['config'] as &$conf) {
            $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, :name, :value)");
            $query->bindValue(':theme', $theme_name);
            $query->bindValue(':name', $conf['name']);
            if ($conf['type'] == 'checkbox') {
                $query->bindValue(':value', isset($_POST[$conf['name']]) ? 1 : 0);
            } else {
                $query->bindValue(':value', $_POST[$conf['name']]);
            }
            $query->execute() or error(db_error($query));
        }
        $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, NULL, NULL)");
        $query->bindValue(':theme', $theme_name);
        $query->execute() or error(db_error($query));
        $result = true;
        $message = false;
        if (isset($theme['install_callback'])) {
            $ret = $theme['install_callback'](themeSettings($theme_name));
            if ($ret && !empty($ret)) {
                if (is_array($ret) && count($ret) == 2) {
                    $result = $ret[0];
                    $message = $ret[1];
                }
            }
        }
        if (!$result) {
            // Install failed
            $query = prepare("DELETE FROM ``theme_settings`` WHERE `theme` = :theme");
            $query->bindValue(':theme', $theme_name);
            $query->execute() or error(db_error($query));
        }
        // Build themes
        rebuildThemes('all');
        mod_page(sprintf(_($result ? 'Installed theme: %s' : 'Installation failed: %s'), $theme['name']), 'mod/theme_installed.html', array('theme_name' => $theme_name, 'theme' => $theme, 'result' => $result, 'message' => $message));
        return;
    }
    $settings = themeSettings($theme_name);
    mod_page(sprintf(_('Configuring theme: %s'), $theme['name']), 'mod/theme_config.html', array('theme_name' => $theme_name, 'theme' => $theme, 'settings' => $settings, 'token' => make_secure_link_token('themes/' . $theme_name)));
}
Exemplo n.º 7
0
 public static function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false)
 {
     global $config, $mod, $pdo, $board;
     if ($mod_id === false) {
         $mod_id = isset($mod['id']) ? $mod['id'] : -1;
     }
     if (!in_array($ban_board, $mod['boards']) && $mod['boards'][0] != '*') {
         error($config['error']['noaccess']);
     }
     $range = self::parse_range($mask);
     $mask = self::range_to_string($range);
     $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
     $query->bindValue(':ipstart', $range[0]);
     if ($range[1] !== false && $range[1] != $range[0]) {
         $query->bindValue(':ipend', $range[1]);
     } else {
         $query->bindValue(':ipend', null, PDO::PARAM_NULL);
     }
     $query->bindValue(':mod', $mod_id);
     $query->bindValue(':time', time());
     if ($reason !== '') {
         $reason = escape_markup_modifiers($reason);
         markup($reason);
         $query->bindValue(':reason', $reason);
     } else {
         $query->bindValue(':reason', null, PDO::PARAM_NULL);
     }
     if ($length) {
         if (is_int($length) || ctype_digit($length)) {
             $length = time() + $length;
         } else {
             $length = self::parse_time($length);
         }
         $query->bindValue(':expires', $length);
     } else {
         $query->bindValue(':expires', null, PDO::PARAM_NULL);
     }
     if ($ban_board) {
         $query->bindValue(':board', $ban_board);
     } else {
         $query->bindValue(':board', null, PDO::PARAM_NULL);
     }
     if ($post) {
         $post['board'] = $board['uri'];
         $match_urls = '(?xi)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))';
         $matched = array();
         preg_match_all("#{$match_urls}#im", $post['body_nomarkup'], $matched);
         if (isset($matched[0]) && $matched[0]) {
             $post['body'] = str_replace($matched[0], '###Link-Removed###', $post['body']);
             $post['body_nomarkup'] = str_replace($matched[0], '###Link-Removed###', $post['body_nomarkup']);
         }
         $query->bindValue(':post', json_encode($post));
     } else {
         $query->bindValue(':post', null, PDO::PARAM_NULL);
     }
     $query->execute() or error(db_error($query));
     if (isset($mod['id']) && $mod['id'] == $mod_id) {
         modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : $mask) . ' (<small>#' . $pdo->lastInsertId() . '</small>)' . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
     }
     if (!$config['cron_bans']) {
         rebuildThemes('bans');
     }
     return $pdo->lastInsertId();
 }