1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-24 23:50:11 +01:00
This commit is contained in:
8chan 2014-11-22 00:15:42 -08:00
commit 2228d2f511
8 changed files with 105 additions and 13 deletions

View File

@ -1,5 +1,61 @@
<?php
include 'inc/functions.php';
if (php_sapi_name() == 'fpm-fcgi') {
error('Cannot be run directly.');
}
function last_activity($board) {
// last post
$query = prepare(sprintf("SELECT MAX(time) AS time FROM posts_%s", $board));
$query->execute();
$row = $query->fetch();
$ago = (new DateTime)->sub(new DateInterval('P1W'));
$mod_ago = (new DateTime)->sub(new DateInterval('P2W'));
error('Automatic claiming is no longer available. To claim a board, send your request to admin@8chan.co along with the IP you used to post on that board.');
$last_activity_date = new DateTime();
$last_mod_date = new DateTime();
$last_activity_date->setTimestamp($row['time']);
$query = query("SELECT id, username FROM mods WHERE boards = '$board'");
$mods = $query->fetchAll();
if ($mods) {
$mod = $mods[0]['id'];
$query = query("SELECT MAX(time) AS time FROM modlogs WHERE `mod` = $mod");
$a = $query->fetchAll(PDO::FETCH_COLUMN);
if ($a[0]) {
$last_mod_date->setTimestamp($a[0]);
if (!$row['time'])
$last_activity_date->setTimestamp($a[0]);
} else {// no one ever logged in, try board creation time
$query = query("SELECT UNIX_TIMESTAMP(time) AS time FROM board_create WHERE uri = '$board'");
$crt = $query->fetchAll(PDO::FETCH_COLUMN);
$last_activity_date->setTimestamp($crt[0]);
$last_mod_date = false;
}
}
if ($mods and ($last_activity_date < $ago or ($last_mod_date and $last_mod_date < $mod_ago))) {
return array($last_activity_date, $last_mod_date, $mods);
}
else {
return false;
}
}
$q = query("SELECT uri FROM boards");
$boards = $q->fetchAll(PDO::FETCH_COLUMN);
$delete = array();
foreach($boards as $board) {
$last_activity = last_activity($board);
if ($last_activity) {
list($last_activity_date, $last_mod_date, $mods) = $last_activity;
$last_mod_f = $last_mod_date ? $last_mod_date->format('Y-m-d H:i:s') : '<em>never</em>';
$last_activity_f = $last_activity_date ? $last_activity_date->format('Y-m-d H:i:s') : '<em>never</em>';
$delete[] = array('board' => $board, 'last_activity_date' => $last_activity_f, 'last_mod' => $last_mod_date, 'last_mod_f' => $last_mod_f);
}
}
$body = Element("8chan/claim.html", array("config" => $config, "delete" => $delete));
echo Element("page.html", array("config" => $config, "body" => $body, "title" => _("Claim"), "subtitle" => _("Take deserted boards back from their owners")));

View File

@ -34,9 +34,9 @@ $body = <<<EOT
<p>The admin can be reached at <tt>admin at 8chan dot co</tt>.</p>
<h2>Help! My board has been deleted!</h2>
<p>Were you inactive for longer than one week? Were there no posts on the board for 72 hours?</p>
<p>As of November 13th, 2014, board expiration no longer occurs.</p>
<p>If either of those is true, the board was deleted automatically. You are free to recreate it. I cannot restore it, so don't bother emailing me about it.</p>
<p>You still may lose access to your board, however, if you fail to log in for two weeks or it receives no posts for a week. See <a href="/claim.html">here</a> for a list of boards that are available for reclaiming.</p>
<h2>How do I post as a volunteer on my board?</h2>
<p>Make sure you are using the volunteer interface to view your board. The URL of your browser should be <a href="https://8chan.co/mod.php?/yourboard"><tt>https://8chan.co/mod.php?/yourboard</tt></a>.</p>
@ -47,7 +47,7 @@ $body = <<<EOT
<p>If they are doing something illegal, email me.</p>
<h2>Can you give me X board?</h2>
<p>If the owner of the board is inactive or the board is broken due to bad CSS, sure. Send me an email.</p>
<p>If the owner of the board is inactive or the board is broken due to bad CSS, sure. Send me an email. You can see a list of boards that qualify for being taken over <a href="/claim.html">here</a>.</p>
<h2>Can you add some new feature?</h2>
<p>Open a <a href="https://github.com/ctrlcctrlv/8chan/issues">Github issue</a>. Better yet, write it yourself and open a pull request.

View File

@ -49,6 +49,38 @@
$config['mod']['ban_appeals'] = BOARDVOLUNTEER;
$config['mod']['view_ban_appeals'] = BOARDVOLUNTEER;
$config['mod']['view_ban'] = BOARDVOLUNTEER;
$config['mod']['reassign_board'] = ADMIN;
$config['mod']['custom_pages']['/reassign/(\%b)'] = function($b) {
global $board, $config;
if (!openBoard($b))
error("Could not open board!");
if (!hasPermission($config['mod']['reassign_board'], $b))
error($config['error']['noaccess']);
$query = query("SELECT id, username FROM mods WHERE boards = '$b' AND type = 20");
$mods = $query->fetchAll();
if (!$mods) {
error('No mods?');
}
$password = base64_encode(openssl_random_pseudo_bytes(9));
$salt = generate_salt();
$hashed = hash('sha256', $salt . sha1($password));
$query = prepare('UPDATE ``mods`` SET `password` = :hashed, `salt` = :salt WHERE BINARY username = :mod');
$query->bindValue(':hashed', $hashed);
$query->bindValue(':salt', $salt);
$query->bindValue(':mod', $mods[0]['username']);
$query->execute();
$body = "Thanks for your interest in this board. Kindly find the username and password below. You can login at 8chan.co/mod.php.<br>Username: {$mods[0]['username']}<br>Password: {$password}<br>Thanks for using 8chan.co!";
mod_page(_('Edit reassign'), 'blank.html', array('board'=>$board,'token'=>make_secure_link_token('reassign/'.$board['uri']),'body'=>$body));
};
$config['mod']['custom_pages']['/volunteers/(\%b)'] = function($b) {
global $board, $config, $pdo;

View File

@ -13,6 +13,8 @@
*/
function unanimate_gif(e) {
if ($(e).closest('.thread').children('.thread-hidden').length > 0) return;
if (active_page === "catalog")
var c = $('<canvas class="thread-image"></canvas>');
else

View File

@ -65,7 +65,7 @@ $(document).ready(function(){
$('#thread_stats_uids').text(size(ids));
}
$.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){
var found, page = 'Pruned or Deleted';
var found, page = '???';
for (var i=0;data[i];i++){
var threads = data[i].threads;
for (var j=0; threads[j]; j++){
@ -86,7 +86,7 @@ $(document).ready(function(){
// uses ajax call so it gets loaded on a delay (depending on network resources available)
var thread_stats_page_timer = setInterval(function(){
$.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){
var found, page = 'Pruned or Deleted';
var found, page = '???';
for (var i=0;data[i];i++){
var threads = data[i].threads;
for (var j=0; threads[j]; j++){

View File

@ -147,15 +147,16 @@ $(document).ready(function(){
}
//Append the watchlist toggle button.
$('.boardlist').append('<span>[ <a id="watchlist-toggle">watchlist</a> ]</span>');
$('.boardlist').append('<span>[ <a class="watchlist-toggle" href="#">watchlist</a> ]</span>');
//Append a watch thread button after every OP.
$('.op>.intro').append('<a class="watchThread">[Watch Thread]</a>');
$('.op>.intro').append('<a class="watchThread" href="#">[Watch Thread]</a>');
//Draw the watchlist, hidden.
watchlist.render();
//Show or hide the watchlist.
$('#watchlist-toggle').on('click', function(e) {
$('.watchlist-toggle').on('click', function(e) {
e.preventDefault();
//if ctrl+click, reset the watchlist.
if (e.ctrlKey) {
watchlist.render(true);
@ -169,7 +170,8 @@ $(document).ready(function(){
//Trigger the watchlist add function.
//The selector is passed as an argument in case the page is not a thread.
$('.watchThread').on('click', function() {
$('.watchThread').on('click', function(e) {
e.preventDefault();
watchlist.add(this).render();
});

View File

@ -1,5 +1,5 @@
<p>{% trans %}Your new board is created and is live at{% endtrans %} <a href="/{{ uri }}">/{{ uri }}/</a>.</p>
<p>{% trans %}Make sure you don't forget your password, <tt>{{ password }}</tt>!{% endtrans %}</p>
<p>{% trans %}Make sure you don't forget your password, <tt>{{ password }}</tt>{% endtrans %}</p>
<p>{% trans %}You can manage your board at <a href="http://8chan.co/mod.php?/">http://8chan.co/mod.php?/</a>.{% endtrans %}</p>

View File

@ -295,7 +295,7 @@
<div class="col col-9 bodyCol">
<div class="content_body">
<p>{% 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 %}</p>
<p>{% trans %}On ∞chan, you can create your own imageboard for free with no experience or programming knowledge needed. As long as the board has unobtrusive CSS, the owner doesn't ban more than half the users, the owner logs in once every two weeks and it gets one new post every week, you will retain the board forever.{% endtrans %}</p>
<p style="color:red">{% trans %}Warning: Some boards on this site might contain content of an adult or offensive nature. Please cease use of this site if it is illegal for you to view such content. The boards on this site are made entirely by the users and do not represent the opinions of the administration of 8chan.co. In the interest of free speech, only content that directly violates the DMCA or other US laws is deleted.{% endtrans %}</p>
<div class="mobileHide">
<a href="create.php" class="button">{% trans %}Create&nbsp;your&nbsp;board{% endtrans %}</a>