diff --git a/boards.php b/boards.php index 22a76816..f38c0185 100644 --- a/boards.php +++ b/boards.php @@ -9,31 +9,6 @@ if (php_sapi_name() == 'fpm-fcgi' && !$admin) { } $boards = listBoards(); -$body = << -th.header { - background-image: url(/static/bg.gif); - cursor: pointer; - background-repeat: no-repeat; - background-position: center right; - padding-left: 20px; - margin-left: -1px; -} -th.headerSortUp { - background-image: url(/static/asc.gif); -} -th.headerSortDown { - background-image: url(/static/desc.gif); -} -.flag-eo { - background-image: url(/static/eo.png); -} -.flag-en { - background-image: url(/static/en.png); -} - -CSS; -$body .= ''; $total_posts_hour = 0; $total_posts = 0; @@ -69,6 +44,7 @@ function ($a, $b) { }); $hidden_boards_total = 0; +$rows = array(); foreach ($boards as $i => &$board) { $board_config = @file_get_contents($board['uri'].'/config.php'); $boardCONFIG = array(); @@ -86,7 +62,7 @@ foreach ($boards as $i => &$board) { $locale_short = str_replace('.utf-8', '', $locale_short); if ($board['uri'] === 'int') {$locale_short = 'eo'; $locale = 'eo';} - $img = "\"$locale\""; + $board['img'] = "\"$locale\""; if ($showboard || $admin) { if (!$showboard) { @@ -95,58 +71,18 @@ foreach ($boards as $i => &$board) { $lock = ''; } $board['ago'] = human_time_diff(strtotime($board['time'])); - $body .= ""; - $body .= ""; - $body .= ""; - $body .= ""; - $body .= ""; - $body .= ""; - $body .= ""; } else { unset($boards[$i]); $hidden_boards_total += 1; } } -$body .= <<
LBoardBoard titlePosts in last hourTotal postsCreated
$img/{$board['uri']}/$lock{$board['title']}{$board['pph']}{$board['max']}{$board['time']} ({$board['ago']} ago)
-FOOTER; - $n_boards = sizeof($boards); $t_boards = $hidden_boards_total + $n_boards; -$body = "

There are currently {$n_boards} boards + $hidden_boards_total unindexed boards = $t_boards total boards. Site-wide, {$total_posts_hour} posts have been made in the last hour, with {$total_posts} being made on all active boards since October 23, 2013.

" . $body; - -//date_default_timezone_set('UTC'); -$body .= "

Page last updated: ".date('r')."

"; -$body .= "

".shell_exec('uptime -p')." without interruption

"; - $config['additional_javascript'] = array('js/jquery.min.js', 'js/jquery.tablesorter.min.js'); +$body = Element("8chan/boards.html", array("config" => $config, "n_boards" => $n_boards, "t_boards" => $t_boards, "hidden_boards_total" => $hidden_boards_total, "total_posts" => $total_posts, "total_posts_hour" => $total_posts_hour, "boards" => $boards, "last_update" => date('r'), "uptime_p" => shell_exec('uptime -p'))); + $html = Element("page.html", array("config" => $config, "body" => $body, "title" => "Boards on ∞chan")); if ($admin) { echo $html; diff --git a/create.php b/create.php index 41efa666..88f3952e 100644 --- a/create.php +++ b/create.php @@ -20,7 +20,7 @@ if (!isset($_POST['uri'], $_POST['title'], $_POST['subtitle'], $_POST['username' if (!$ayah){ $game_html = ''; } else { - $game_html = 'Game' . $ayah->getPublisherHTML() . ''; + $game_html = ''._('Game').'' . $ayah->getPublisherHTML() . ''; } if (!$cbRecaptcha){ @@ -32,25 +32,9 @@ if (!$cbRecaptcha){ $password = base64_encode(openssl_random_pseudo_bytes(9)); -$body = << - - - - - - - -{$game_html} -{$recapcha_html} - -
URI// (must be all lowercase or numbers and < 10 chars)
Title (must be < 40 chars)
Subtitle (must be < 200 chars)
Username (must contain only alphanumeric, periods and underscores)
Password (write this down)
- - +$body = Element("8chan/create.html", array("config" => $config, "password" => $password, "game_html" => $game_html, "recapcha_html" => $recapcha_html)); -EOT; - -echo Element("page.html", array("config" => $config, "body" => $body, "title" => "Create your board", "subtitle" => "before someone else does")); +echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Create your board"), "subtitle" => _("before someone else does"))); } else { @@ -77,30 +61,30 @@ $score = true; $score = $ayah->scoreResult(); } if (!$score) - error('You failed the game'); + error(_('You failed the game')); if (!$passedCaptcha) - error('You failed to enter the reCaptcha correctly'); + error(_('You failed to enter the reCaptcha correctly')); if (!preg_match('/^[a-z0-9]{1,10}$/', $uri)) - error('Invalid URI'); + error(_('Invalid URI')); if (!(strlen($title) < 40)) - error('Invalid title'); + error(_('Invalid title')); if (!(strlen($subtitle) < 200)) - error('Invalid subtitle'); + error(_('Invalid subtitle')); if (!preg_match('/^[a-zA-Z0-9._]{1,30}$/', $username)) - error('Invalid username'); + error(_('Invalid username')); foreach (listBoards() as $i => $board) { if ($board['uri'] == $uri) - error('Board already exists!'); + error(_('Board already exists!')); } foreach ($bannedWords as $i => $w) { if ($w[0] !== '/') { if (strpos($uri,$w) !== false) - error("Cannot create board with banned word $w"); + error(_("Cannot create board with banned word $w")); } else { if (preg_match($w,$uri)) - error("Cannot create board matching banned pattern $w"); + error(_("Cannot create board matching banned pattern $w")); } } $query = prepare('SELECT ``username`` FROM ``mods`` WHERE ``username`` = :username'); @@ -109,7 +93,7 @@ $query->execute() or error(db_error($query)); $users = $query->fetchAll(PDO::FETCH_ASSOC); if (sizeof($users) > 0){ -error('The username you\'ve tried to enter already exists!'); +error(_('The username you\'ve tried to enter already exists!')); } $salt = generate_salt(); @@ -142,20 +126,14 @@ buildIndex(); rebuildThemes('boards'); -query("INSERT INTO ``board_create``(uri) VALUES('$uri')") or error(db_error()); +$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 = << $config, "password" => $_POST['password'], "uri" => $uri)); -

Your new board is created and is live at /{$uri}/.

- -

Make sure you don't forget your password, {$_POST['password']}!

- -

You can manage your board at http://8chan.co/mod.php?/.

- -EOT; - -echo Element("page.html", array("config" => $config, "body" => $body, "title" => "Success", "subtitle" => "This was a triumph")); +echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Success"), "subtitle" => _("This was a triumph"))); } ?> diff --git a/index.php b/index.php index 83a6451b..1aa350c6 100644 --- a/index.php +++ b/index.php @@ -1,323 +1,4 @@ +include 'inc/functions.php'; - - - - - ∞chan - - - - - -
- -
- - - -
- Welcome to ∞chan, the infinitely expanding imageboard. -
- Featured boards: - [ v / a / tg / fit / pol / tech / mu / co / sp / boards ] -
-
- - - -
- - - -
-
-

On ∞chan, you can create your own imageboard for free with no experience or programming knowledge needed. As long as the admin logs in once per week and it gets one new post every 72 hours, the board will be hosted forever.

- -
- - - -
-
- -
- - - - -
- - - - - +echo Element("8chan/index.html", array("config" => $config)); diff --git a/templates/8chan/boards.html b/templates/8chan/boards.html new file mode 100644 index 00000000..3e7c402d --- /dev/null +++ b/templates/8chan/boards.html @@ -0,0 +1,55 @@ + + +

{% trans %}There are currently {{n_boards}} boards + {{hidden_boards_total}} unindexed boards = {{t_boards}} total boards. Site-wide, {{total_posts_hour}} posts have been made in the last hour, with {{total_posts}} being made on all active boards since October 23, 2013.{% endtrans %}

+ + +{% for board in boards %} + + + + + + + +{% endfor %} +
L{% trans %}Board{% endtrans %}{% trans %}Board title{% endtrans %}{% trans %}Posts in last hour{% endtrans %}{% trans %}Total posts{% endtrans %}{% trans %}Created{% endtrans %}
{{ board.img|raw }}/{{board['uri']}}/{{lock|raw}}{{ board['title'] }}{{board['pph']}}{{board['max']}}{{board['time']}} ({{board['ago']}} ago)
+

Page last updated: {{last_update}}

+

{{uptime_p}} without interruption

+ + diff --git a/templates/8chan/create.html b/templates/8chan/create.html new file mode 100644 index 00000000..668d165a --- /dev/null +++ b/templates/8chan/create.html @@ -0,0 +1,15 @@ +
+ + + + + + + +{{ game_html }} +{{ recapcha_html }} + +
URI// {% trans %}(must be all lowercase or numbers and < 10 chars){% endtrans %}
Title {% trans %}(must be < 40 chars){% endtrans %}
Subtitle {% trans %}(must be < 200 chars){% endtrans %}
{% trans %}Username{% endtrans %} {% trans %}(must contain only alphanumeric, periods and underscores){% endtrans %}
{% trans %}Password{% endtrans %} {% trans %}(write this down){% endtrans %}
+
+
+ diff --git a/templates/8chan/create_success.html b/templates/8chan/create_success.html new file mode 100644 index 00000000..b129787c --- /dev/null +++ b/templates/8chan/create_success.html @@ -0,0 +1,5 @@ +

{% trans %}Your new board is created and is live at{% endtrans %} /{{ uri }}/.

+ +

{% trans %}Make sure you don't forget your password, {{ password }}!{% endtrans %}

+ +

{% trans %}You can manage your board at http://8chan.co/mod.php?/.{% endtrans %}

diff --git a/templates/8chan/index.html b/templates/8chan/index.html new file mode 100644 index 00000000..54ceae28 --- /dev/null +++ b/templates/8chan/index.html @@ -0,0 +1,311 @@ + + + + + ∞chan + + + + + +
+ +
+ + + +
+ {% trans %}Welcome to ∞chan, the infinitely expanding imageboard.{% endtrans %} +
+ {% trans %}Featured boards:{% endtrans %} + [ v / a / tg / fit / pol / tech / mu / co / sp / boards ] +
+
+ + + +
+ + + +
+
+

{% trans %}On ∞chan, you can create your own imageboard for free with no experience or programming knowledge needed. As long as the admin logs in once per week and it gets one new post every 72 hours, the board will be hosted forever.{% endtrans %}

+ +
+ + + +
+
+ +
+ + + +