1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 01:34:31 +01:00
vichan/d

23 KiB

diff --git a/inc/instance-config.php b/inc/instance-config.php
index 699d1a1..475f3ed 100644
--- a/inc/instance-config.php
+++ b/inc/instance-config.php
@@ -18,15 +18,15 @@
$config['db']['user'] = 'root';
$config['db']['password'] = '';
$config['timezone'] = 'UTC';
- $config['cache']['enabled'] = 'apc';
-
-
+ $config['cache']['enabled'] = false;
+
+
$config['cookies']['mod'] = 'mod';
$config['cookies']['salt'] = '';
-
+
$config['spam']['hidden_inputs_max_pass'] = 128;
$config['spam']['hidden_inputs_expire'] = 60 * 60 * 4; // three hours
-
+
$config['flood_time'] = 5;
$config['flood_time_ip'] = 30;
$config['flood_time_same'] = 2;
@@ -46,10 +46,10 @@
$config['thread_subject_in_title'] = true;
$config['spam']['hidden_inputs_max_pass'] = 128;
$config['ayah_enabled'] = true;
-
+
// Load database credentials
require "secrets.php";
-
+
// Image shit
$config['thumb_method'] = 'gm+gifsicle';
$config['thumb_ext'] = '';
diff --git a/install.php b/install.php
index 8b3815a..07e94e7 100644
--- a/install.php
+++ b/install.php
@@ -579,7 +579,8 @@ if ($step == 0) {
</p>';
 
echo Element('page.html', $page);
-} elseif ($step == 1) {
+}
+elseif ($step == 1) {
$page['title'] = 'Pre-installation test';
 
$can_exec = true;
@@ -761,7 +762,8 @@ if ($step == 0) {
'title' => 'Checking environment',
'config' => $config
));
-} elseif ($step == 2) {
+}
+elseif ($step == 2) {
// Basic config
$page['title'] = 'Configuration';
 
@@ -775,7 +777,8 @@ if ($step == 0) {
'title' => 'Configuration',
'config' => $config
));
-} elseif ($step == 3) {
+}
+elseif ($step == 3) {
$instance_config =
'<?php
 
@@ -814,7 +817,8 @@ if ($step == 0) {
 
if (@file_put_contents('inc/instance-config.php', $instance_config)) {
header('Location: ?step=4', true, $config['redirect_http']);
- } else {
+ }
+ else {
$page['title'] = 'Manual installation required';
$page['body'] = '
<p>I couldn\'t write to <strong>inc/instance-config.php</strong> with the new configuration, probably due to a permissions error.</p>
@@ -826,7 +830,8 @@ if ($step == 0) {
';
echo Element('page.html', $page);
}
-} elseif ($step == 4) {
+}
+elseif ($step == 4) {
// SQL installation
 
buildJavascript();
@@ -846,11 +851,15 @@ if ($step == 0) {
 
$sql_errors = '';
foreach ($queries as $query) {
- if ($mysql_version < 50503)
+ if ($mysql_version < 50503) {
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
+ }
+
$query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query);
- if (!query($query))
+
+ if (!query($query)) {
$sql_errors .= '<li>' . db_error() . '</li>';
+ }
}
 
$page['title'] = 'Installation complete';
@@ -858,7 +867,8 @@ if ($step == 0) {
 
if (!empty($sql_errors)) {
$page['body'] .= '<div class="ban"><h2>SQL errors</h2><p>SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a vichan installation; if so, you can probably ignore this.</p><p>The errors encountered were:</p><ul>' . $sql_errors . '</ul><p><a href="?step=5">Ignore errors and complete installation.</a></p></div>';
- } else {
+ }
+ else {
$boards = listBoards();
foreach ($boards as &$_board) {
setupBoard($_board);
@@ -866,13 +876,11 @@ if ($step == 0) {
}
 
file_write($config['has_installed'], VERSION);
- /*if (!file_unlink(__FILE__)) {
- $page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
- }*/
}
 
echo Element('page.html', $page);
-} elseif ($step == 5) {
+}
+elseif ($step == 5) {
$page['title'] = 'Installation complete';
$page['body'] = '<p style="text-align:center">Thank you for using vichan. Please remember to report any bugs you discover.</p>';
 
diff --git a/templates/8chan/index.html b/templates/8chan/index.html
index 459e7e8..4f25473 100644
--- a/templates/8chan/index.html
+++ b/templates/8chan/index.html
@@ -223,7 +223,7 @@
</style>
</head>
 
- <body>
+ <body class="8chan index">
 
<div id="main">
 
diff --git a/templates/generic_page.html b/templates/generic_page.html
index 0fe1f9c..4cd3116 100644
--- a/templates/generic_page.html
+++ b/templates/generic_page.html
@@ -6,7 +6,7 @@
<title>{{ board.url }} - {{ board.name }}</title>
{% endblock %}
</head>
-<body>
+<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
{% if config.url_banner %}<img class="banner" src="{{ config.url_banner }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %}
diff --git a/templates/index.html b/templates/index.html
index aae87c1..5638fd6 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -14,7 +14,7 @@
{% include 'header.html' %}
<title>{{ board.url }} - {{ board.title|e }}</title>
</head>
-<body>
+<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
 
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
diff --git a/templates/main.js b/templates/main.js
index 1ec4d26..d100f93 100644
--- a/templates/main.js
+++ b/templates/main.js
@@ -73,11 +73,6 @@ var saved = {};
 
 
var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0|addslashes }}{% raw %}';
-/*var styles = {
- {% endraw %}
- {% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
- {% endraw %}{% endfor %}{% raw %}
-};*/
var board_name = false;
 
function changeStyle(styleName, link) {
@@ -92,36 +87,78 @@ function changeStyle(styleName, link) {
{% endif %}
{% raw %}
 
- if (!document.getElementById('stylesheet')) {
- var s = document.createElement('link');
- s.rel = 'stylesheet';
- s.type = 'text/css';
- s.id = 'stylesheet';
+ // Find the <dom> for the stylesheet. May be nothing.
+ var domStylesheet = document.getElementById('stylesheet');
+ // Determine if this stylesheet is the default.
+ var setToDefault = ( styles[styleName] == "" || styles[styleName] == "/stylesheets/" );
+ // Turn "Yotsuba B" to "yotsuba_b"
+ var attributeName = styleName.replace(/[^a-z0-9_\-]/gi, '_').toLowerCase();
+
+ if( !domStylesheet && !setToDefault ) {
+ domStylesheet = document.createElement('link');
+ domStylesheet.rel = 'stylesheet';
+ domStylesheet.type = 'text/css';
+ domStylesheet.id = 'stylesheet';
+
var x = document.getElementsByTagName('head')[0];
- x.appendChild(s);
+ x.appendChild(domStylesheet);
}
-
- {% endraw %}
- var root = "{{ config.root }}";
- {% raw %}
- root = root.replace(/\/$/, "");
-
- document.getElementById('stylesheet').href = root + styles[styleName];
- selectedstyle = styleName;
 
- if (document.getElementsByClassName('styles').length != 0) {
- var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
- for (var i = 0; i < styleLinks.length; i++) {
- styleLinks[i].className = '';
+ if( !setToDefault ) {
+ {% endraw %}
+ var root = "{{ config.root }}";
+ {% raw %}
+ root = root.replace(/\/$/, "");
+
+ domStylesheet.href = root + styles[styleName];
+ selectedstyle = styleName;
+
+ if (document.getElementsByClassName('styles').length != 0) {
+ var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
+ for (var i = 0; i < styleLinks.length; i++) {
+ styleLinks[i].className = '';
+ }
}
+
+ if (link) {
+ link.className = 'selected';
+ }
+ }
+ else if( domStylesheet ) {
+ domStylesheet.parentNode.removeChild( domStylesheet );
}
 
- if (link) {
- link.className = 'selected';
+ // Fix the classes on the body tag.
+ var body = document.getElementsByTagName('body')[0];
+
+ if( body ) {
+ var bodyClasses = document.getElementsByTagName('body')[0].getAttribute('class').split(" ");
+ var bodyClassesNew = [];
+
+ for( i = 0; i < bodyClasses.length; ++i ) {
+ var bodyClass = bodyClasses[ i ];
+
+ // null class from a double-space.
+ if( bodyClass == "" ) {
+ continue;
+ }
+
+ if( bodyClass.indexOf( "stylesheet-" ) == 0 ) {
+ continue;
+ }
+
+ bodyClassesNew.push( bodyClass );
+ }
+
+ // Add stylesheet-yotsuba_b at the end.
+ bodyClassesNew.push( "stylesheet-" + attributeName );
+ body.setAttribute( 'class', bodyClassesNew.join(" ") );
+ body.setAttribute( 'data-stylesheet', attributeName );
}
 
- if (typeof $ != 'undefined')
+ if (typeof $ != 'undefined') {
$(window).trigger('stylesheet', styleName);
+ }
}
 
 
@@ -167,7 +204,7 @@ function init_stylechooser() {
}
}
}
- {% endraw%}
+ {% endraw %}
{% else %}
{% raw %}
if (localStorage.stylesheet) {
@@ -185,10 +222,13 @@ function init_stylechooser() {
 
function get_cookie(cookie_name) {
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
- if (results)
+
+ if (results) {
return (unescape(results[2]));
- else
+ }
+ else {
return null;
+ }
}
 
function highlightReply(id) {
diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html
index 4f76625..87e67c8 100644
--- a/templates/mod/dashboard.html
+++ b/templates/mod/dashboard.html
@@ -1,40 +1,5 @@
-<fieldset>
- <legend>{% trans 'Boards' %}</legend>
-
- <ul>
- {% for board in boards %}
- {% if board.uri in mod.boards or mod.boards[0] == '*' %}
- <li>
- <a href="?/{{ config.board_path|sprintf(board.uri) }}{{ config.file_index }}">{{ config.board_abbreviation|sprintf(board.uri) }}</a>
- -
- {{ board.title|e }}
- {% if board.subtitle %}
- <small>&mdash;
- {% if config.allow_subtitle_html %}
- {{ board.subtitle }}
- {% else %}
- {{ board.subtitle|e }}
- {% endif %}
- </small>
-
- {% endif %}
- {% if mod.type == "20" %}
- <a href="?/settings/{{ board.uri }}"><small>[{% trans 'settings' %}]</small></a>
- {% endif %}
- {% if mod|hasPermission(config.mod.manageboards) %}
- <a href="?/edit/{{ board.uri }}"><small>[{% trans 'edit' %}]</small></a>
- {% endif %}
- </li>
- {% endif %}
- {% endfor %}
-
- {% if mod|hasPermission(config.mod.newboard) %}
- <li style="margin-top:15px"><a href="?/new-board"><strong>{% trans 'Create new board' %}</strong></a></li>
- {% endif %}
- </ul>
-</fieldset>
-
-<fieldset>
+<!-- Messages -->
+<fieldset class="mod-dash mod-dash-set mod-dash-messages">
<legend>{% trans 'Messages' %}</legend>
<ul>
{% if mod|hasPermission(config.mod.noticeboard) %}
@@ -78,7 +43,8 @@
</ul>
</fieldset>
 
-<fieldset>
+<!-- Administration -->
+<fieldset class="mod-dash mod-dash-set mod-dash-messages">
<legend>{% trans 'Administration' %}</legend>
 
<ul>
@@ -123,57 +89,99 @@
</ul>
</fieldset>
 
+<!-- Search -->
{% if mod|hasPermission(config.mod.search) %}
- <fieldset>
- <legend>{% trans 'Search' %}</legend>
-
- <ul>
+<fieldset class="mod-dash mod-dash-set mod-dash-search">
+ <legend>{% trans 'Search' %}</legend>
+
+ <ul>
+ <li>
+ {% include 'mod/search_form.html' %}
+ </li>
+ </ul>
+</fieldset>
+{% endif %}
+
+<!-- Boards -->
+<fieldset class="mod-dash mod-dash-set mod-dash-boards">
+ <legend>{% trans 'Boards' %}</legend>
+
+ <ul>
+ {% for board in boards %}
+ {% if board.uri in mod.boards or mod.boards[0] == '*' %}
<li>
- {% include 'mod/search_form.html' %}
+ <a href="?/{{ config.board_path|sprintf(board.uri) }}{{ config.file_index }}">{{ config.board_abbreviation|sprintf(board.uri) }}</a>
+ -
+ {{ board.title|e }}
+ {% if board.subtitle %}
+ <small>&mdash;
+ {% if config.allow_subtitle_html %}
+ {{ board.subtitle }}
+ {% else %}
+ {{ board.subtitle|e }}
+ {% endif %}
+ </small>
+
+ {% endif %}
+ {% if mod.type == "20" %}
+ <a href="?/settings/{{ board.uri }}"><small>[{% trans 'settings' %}]</small></a>
+ {% endif %}
+ {% if mod|hasPermission(config.mod.manageboards) %}
+ <a href="?/edit/{{ board.uri }}"><small>[{% trans 'edit' %}]</small></a>
+ {% endif %}
</li>
- </ul>
- </fieldset>
-{% endif %}
+ {% endif %}
+ {% endfor %}
+
+ {% if mod|hasPermission(config.mod.newboard) %}
+ <li style="margin-top:15px"><a href="?/new-board"><strong>{% trans 'Create new board' %}</strong></a></li>
+ {% endif %}
+ </ul>
+</fieldset>
 
+<!-- Misc -->
{% if config.mod.dashboard_links|count %}
- <fieldset>
- <legend>{% trans 'Other' %}</legend>
-
- <ul>
- {% for label,link in config.mod.dashboard_links %}
- <li><a href="{{ link }}">{{ label }}</a></li>
- {% endfor %}
- </ul>
- </fieldset>
+<fieldset class="mod-dash mod-dash-set mod-dash-misc">
+ <legend>{% trans 'Other' %}</legend>
+
+ <ul>
+ {% for label,link in config.mod.dashboard_links %}
+ <li><a href="{{ link }}">{{ label }}</a></li>
+ {% endfor %}
+ </ul>
+</fieldset>
{% endif %}
 
+<!-- Debug Information -->
{% if config.debug %}
- <fieldset>
- <legend>{% trans 'Debug' %}</legend>
- <ul>
- <li><a href="?/debug/antispam">{% trans 'Anti-spam' %}</a></li>
- <li><a href="?/debug/recent">{% trans 'Recent posts' %}</a></li>
- {% if mod|hasPermission(config.mod.debug_sql) %}
- <li><a href="?/debug/sql">{% trans 'SQL' %}</a></li>
- {% endif %}
- </ul>
- </fieldset>
+<fieldset class="mod-dash mod-dash-set mod-dash-debug">
+ <legend>{% trans 'Debug' %}</legend>
+ <ul>
+ <li><a href="?/debug/antispam">{% trans 'Anti-spam' %}</a></li>
+ <li><a href="?/debug/recent">{% trans 'Recent posts' %}</a></li>
+ {% if mod|hasPermission(config.mod.debug_sql) %}
+ <li><a href="?/debug/sql">{% trans 'SQL' %}</a></li>
+ {% endif %}
+ </ul>
+</fieldset>
{% endif %}
 
+<!-- Update -->
{% if newer_release %}
- <fieldset>
- <legend>Update</legend>
- <ul>
- <li>
- A newer version of Tinyboard
- (<strong>v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}</strong>) is available!
- See <a href="http://tinyboard.org">http://tinyboard.org/</a> for upgrade instructions.
- </li>
- </ul>
- </fieldset>
+<fieldset class="mod-dash mod-dash-set mod-dash-update">
+ <legend>Update</legend>
+ <ul>
+ <li>
+ A newer version of Tinyboard
+ (<strong>v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}</strong>) is available!
+ See <a href="http://tinyboard.org">http://tinyboard.org/</a> for upgrade instructions.
+ </li>
+ </ul>
+</fieldset>
{% endif %}
 
-<fieldset>
+<!-- Account Actions -->
+<fieldset class="mod-dash mod-dash-set mod-dash-account">
<legend>{% trans 'User account' %}</legend>
 
<ul>
diff --git a/templates/page.html b/templates/page.html
index b136566..a3916b6 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -6,9 +6,10 @@
active_page = "page";
</script>
{% include 'header.html' %}
+ {% if mod %}{% include 'mod/header.html' %}{% endif %}
<title>{{ title }}</title>
</head>
-<body>
+<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} stylesheet-{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr>{% endif %}
<header>
<h1>{{ title }}</h1>
diff --git a/templates/themes/basic/index.html b/templates/themes/basic/index.html
index 3376a68..0ec18f9 100644
--- a/templates/themes/basic/index.html
+++ b/templates/themes/basic/index.html
@@ -11,7 +11,7 @@
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
{% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %}
</head>
-<body>
+<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
<header>
<h1>{{ settings.title }}</h1>
diff --git a/templates/thread.html b/templates/thread.html
index af2a6e0..a3ace9b 100644
--- a/templates/thread.html
+++ b/templates/thread.html
@@ -10,7 +10,7 @@
{% include 'header.html' %}
<title>{{ board.url }} - {% if config.thread_subject_in_title and thread.subject %}{{ thread.subject }}{% else %}{{ board.title|e }}{% endif %}</title>
</head>
-<body>
+<body class="8chan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' and not mod %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
{{ boardlist.top }}
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
{% if config.url_banner %}<img class="board_image" src="{{ config.url_banner }}?board={{ board.uri }}" {% if config.banner_width or config.banner_height %}style="{% if config.banner_width %}width:{{ config.banner_width }}px{% endif %};{% if config.banner_width %}height:{{ config.banner_height }}px{% endif %}" {% endif %}alt="" />{% endif %}