1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-19 17:28:41 +01:00
This commit is contained in:
8chan 2014-09-25 20:47:37 +00:00
commit c42e2d1993
13 changed files with 226 additions and 22 deletions

View File

@ -3,13 +3,33 @@
include "inc/functions.php";
include "inc/lib/ayah/ayah.php";
include "inc/mod/auth.php";
$cbRecaptcha = false;
//don't load recaptcha LIB unless its enabled!
if ($config['cbRecaptcha']){
$cbRecaptcha = true;
include "inc/lib/recaptcha/recaptchalib.php";
}
checkBan('*');
$bannedWords = array('/^cake$/', '8ch', '/^cp$/', 'child', '/^inc$/', '/^static$/', '/^templates$/', '/^js$/', '/^stylesheets$/', '/^tools$/');
$ayah = new AYAH();
$ayah = (($config['ayah_enabled']) ? new AYAH() : false);
if (!isset($_POST['uri'], $_POST['title'], $_POST['subtitle'], $_POST['username'], $_POST['password'])) {
$publisher_html = $ayah->getPublisherHTML();
if (!$ayah){
$game_html = '';
} else {
$game_html = '<tr><th>Game</th><td>' . $ayah->getPublisherHTML() . '</td></tr>';
}
if (!$cbRecaptcha){
$recapcha_html = '';
} else {
$recapcha_html = '<tr><th>reCaptcha</th><td>' . recaptcha_get_html($config['recaptcha_public']) . '</td></tr>';
}
$password = base64_encode(openssl_random_pseudo_bytes(9));
$body = <<<EOT
@ -21,7 +41,8 @@ $body = <<<EOT
<tr><th>Subtitle</th><td><input name="subtitle" type="text"> <span class="unimportant">(must be < 200 chars)</td></tr>
<tr><th>Username</th><td><input name="username" type="text"> <span class="unimportant">(must contain only alphanumeric, periods and underscores)</span></td></tr>
<tr><th>Password</th><td><input name="password" type="text" value="{$password}" readonly> <span class="unimportant">(write this down)</span></td></tr>
<tr><th>Game</th><td>{$publisher_html}</td></tr>
{$game_html}
{$recapcha_html}
</tbody>
</table>
<ul style="padding:0;text-align:center;list-style:none"><li><input type="submit" value="Create board"></li></ul>
@ -38,8 +59,27 @@ $title = $_POST['title'];
$subtitle = $_POST['subtitle'];
$username = $_POST['username'];
$password = $_POST['password'];
$score = $ayah->scoreResult();
$resp = ($cbRecaptcha) ? recaptcha_check_answer ($config['recaptcha_private'],
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]):false;
if ($resp != false){
$passedCaptcha = $resp->is_valid;
} else {
$passedCaptcha = true;
}
if (!$ayah){
$score = true;
} else {
$score = $ayah->scoreResult();
}
if (!$score)
error('You failed the game');
if (!$passedCaptcha)
error('You failed to enter the reCaptcha correctly');
if (!preg_match('/^[a-z0-9]{1,10}$/', $uri))
error('Invalid URI');
if (!(strlen($title) < 40))
@ -48,8 +88,7 @@ if (!(strlen($subtitle) < 200))
error('Invalid subtitle');
if (!preg_match('/^[a-zA-Z0-9._]{1,30}$/', $username))
error('Invalid username');
if (!$score)
error('You failed the game');
foreach (listBoards() as $i => $board) {
if ($board['uri'] == $uri)
error('Board already exists!');
@ -64,12 +103,13 @@ foreach ($bannedWords as $i => $w) {
error("Cannot create board matching banned pattern $w");
}
}
$query = prepare('SELECT * FROM ``mods``');
$query = prepare('SELECT ``username`` FROM ``mods`` WHERE ``username`` = :username');
$query->bindValue(':username', $username);
$query->execute() or error(db_error($query));
$users = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($users as $i => $user) {
if ($user['username'] == $username)
error('Username taken!');
if (sizeof($users) > 0){
error('The username you\'ve tried to enter already exists!');
}
$salt = generate_salt();
@ -112,9 +152,10 @@ $body = <<<EOT
<p>Make sure you don't forget your password, <tt>{$_POST['password']}</tt>!</p>
<p>You can manage your site at <a href="http://8chan.co/mod.php?/">http://8chan.co/mod.php?/</a>.</p>
<p>You can manage your board at <a href="http://8chan.co/mod.php?/">http://8chan.co/mod.php?/</a>.</p>
EOT;
echo Element("page.html", array("config" => $config, "body" => $body, "title" => "Success", "subtitle" => "This was a triumph"));
}
?>

View File

@ -41,8 +41,8 @@ class Api {
);
$this->fileFields = array(
'thumbheight' => 'tn_w',
'thumbwidth' => 'tn_h',
'thumbheight' => 'tn_h',
'thumbwidth' => 'tn_w',
'height' => 'w',
'width' => 'h',
'size' => 'fsize',
@ -113,6 +113,7 @@ class Api {
$apiPost['ext'] = substr($file->file, $dotPos);
$dotPos = strrpos($file->file, '.');
$apiPost['tim'] = substr($file->file, 0, $dotPos);
$apiPost['md5'] = base64_encode(md5_file($file->file_path, true));
}
return $apiPost;

View File

@ -277,8 +277,21 @@
'no_country'
);
/* Uses are you a human to stop automated requests to make boards disabled by default
* if you wish to use 'are you a human' to block automated board creation requests
* to use AYAH you must enter your 'AYAH_PUBLISHER_KEY' and your 'AYAH_SCORING_KEY' in
* the configuration file for AYAH. The config file for AYAH
* is located in the following directory:'/inc/lib/ayah/ayah_config.php'
*/
$config['ayah_enabled'] = false;
// Enable reCaptcha to make spam even harder. Rarely necessary.
$config['recaptcha'] = false;
// Enable reCaptcha on create.php to prevent automated requests.
$config['cbRecaptcha'] = false;
// Public and private key pair from https://www.google.com/recaptcha/admin/create
$config['recaptcha_public'] = '6LcXTcUSAAAAAKBxyFWIt2SO8jwx4W7wcSMRoN3f';

View File

@ -80,6 +80,7 @@
$config['mod']['recent_reports'] = 65535;
// Board shit
$config['ayah_enabled'] = true;
$config['url_banner'] = '/banners.php';
//$config['default_stylesheet'] = array('Notsuba', 'notsuba.css');
$config['additional_javascript'][] = 'js/jquery.min.js';
@ -91,7 +92,8 @@
$config['additional_javascript'][] = 'js/favorites.js';
$config['additional_javascript'][] = 'js/show-op.js';
$config['additional_javascript'][] = 'js/hide-threads.js';
//$config['additional_javascript'][] = 'js/smartphone-spoiler.js';
$config['additional_javascript'][] = 'js/mobile-style.js'
$config['additional_javascript'][] = 'js/smartphone-spoiler.js';
$config['additional_javascript'][] = 'js/inline-expanding.js';
$config['additional_javascript'][] = 'js/show-backlinks.js';
$config['additional_javascript'][] = 'js/catalog-link.js';
@ -116,6 +118,7 @@
$config['additional_javascript'][] = 'js/forced-anon.js';
$config['additional_javascript'][] = 'js/toggle-locked-threads.js';
$config['additional_javascript'][] = 'js/toggle-images.js';
$config['additional_javascript'][] = 'js/threadscroll.js';
$config['font_awesome_css'] = '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css';
@ -127,7 +130,7 @@
$config['markup'][] = array("/\[spoiler\](.+?)\[\/spoiler\]/", "<span class=\"spoiler\">\$1</span>");
$config['markup'][] = array("/~~(.+?)~~/", "<s>\$1</s>");
$config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array('<i class="fa fa-twitter" title="Home"></i>'=>'https://twitter.com/infinitechan'));
$config['boards'] = array(array('<i class="fa fa-home" title="Home"></i>' => '/', '<i class="fa fa-tags" title="Boards"></i>' => '/boards.html', '<i class="fa fa-question" title="FAQ"></i>' => '/faq.html', '<i class="fa fa-random" title="Random"></i>' => '/random.php', '<i class="fa fa-plus" title="New board"></i>' => '/create.php', '<i class="fa fa-search" title="Search"></i>' => '/search.php', '<i class="fa fa-cog" title="Manage board"></i>' => '/mod.php', '<i class="fa fa-quote-right" title="Chat"></i>' => 'https://qchat.rizon.net/?channels=#8chan'), array('b', 'meta', 'int'), array('v', 'a', 'tg', 'fit', 'pol', 'tech', 'mu', 'co', 'sp', 'boards'), array('<i class="fa fa-twitter" title="Twitter"></i>'=>'https://twitter.com/infinitechan'));
$config['footer'][] = 'Contribute to 8chan.co development at <a href="https://github.com/ctrlcctrlv/8chan">github</a>';
$config['footer'][] = 'To make a DMCA request or report illegal content, please email <a href="mailto:admin@8chan.co">admin@8chan.co</a> or use the "Global Report" functionality on every page.';

View File

@ -1799,12 +1799,25 @@ function mod_user($uid) {
$log = array();
}
if ($mod['type'] >= ADMIN){
$boards = listBoards();
} else {
$boards2 = explode(',', $user['boards']);
foreach($boards2 as $string){
$boards[] = array("uri"=>$string, "title"=>"MY BOARD");
}
}
$user['boards'] = explode(',', $user['boards']);
mod_page(_('Edit user'), 'mod/user.html', array(
'user' => $user,
'logs' => $log,
'boards' => listBoards(),
'boards' => $boards,
'token' => make_secure_link_token('users/' . $user['id'])
));
}

View File

@ -68,6 +68,11 @@ CREATE TABLE IF NOT EXISTS `boards` (
PRIMARY KEY (`uri`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `board_create` (
`time` text NOT NULL,
`uri` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `boards`
--
@ -220,6 +225,7 @@ CREATE TABLE IF NOT EXISTS `reports` (
`board` varchar(58) CHARACTER SET utf8 DEFAULT NULL,
`post` int(11) NOT NULL,
`reason` text NOT NULL,
`global` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;

View File

@ -16,8 +16,16 @@
*
*/
au = false;
auto_reload_enabled = true; // for watch.js to interop
function makeIcon(){
if(au) return;
au = true;
$("link[rel='icon']").attr("href", "../static/favicon_au.png");
}
$(document).ready(function(){
if($('div.banner').length == 0)
return; // not index
@ -28,7 +36,7 @@ $(document).ready(function(){
var poll_interval;
// Add an update link
$('.boardlist.bottom').prev().after("<a href='#' id='update_thread' style='padding-left:10px'>["+_("Update thread")+"]</a>");
$('.boardlist.bottom').prev().after("<a href='#' id='update_thread' style='padding-left:10px'>["+_("Update thread")+"] (<span id='update_secs'></span>)</a>");
// Grab the settings
var settings = new script_settings('auto-reload');
@ -39,6 +47,7 @@ $(document).ready(function(){
// number of ms to wait before reloading
var poll_interval_delay = poll_interval_mindelay_bottom;
var poll_current_time = poll_interval_delay;
var end_of_page = false;
@ -70,6 +79,14 @@ $(document).ready(function(){
window_active = false;
});
var timer_update = function() {
$('#update_secs').text(poll_current_time/1000);
}
var decrement_timer = function() {
poll_current_time = poll_current_time - 1000;
}
var recheck_activated = function() {
if (new_posts && window_active &&
$(window).scrollTop() + $(window).height() >=
@ -89,6 +106,7 @@ $(document).ready(function(){
if($('#' + id).length == 0) {
if (!new_posts) {
first_new_post = this;
makeIcon();
}
$(this).insertAfter($('div.post:last').next()).after('<br class="clear">');
new_posts++;
@ -117,6 +135,7 @@ $(document).ready(function(){
}
poll_interval = setTimeout(poll, poll_interval_delay);
poll_current_time = poll_interval_delay;
};
$(window).scroll(function() {
@ -130,11 +149,15 @@ $(document).ready(function(){
clearTimeout(poll_interval);
poll_interval = setTimeout(poll, poll_interval_shortdelay);
poll_current_time = poll_interval_shortdelay;
end_of_page = true;
}).trigger('scroll');
$('#update_thread').on('click', poll);
setInterval(timer_update, 1000);
setInterval(decrement_timer, 1000);
poll_interval = setTimeout(poll, poll_interval_delay);
poll_interval = setInterval(poll, poll_interval_delay);
timer_update();
});

98
js/image-hover.js Normal file
View File

@ -0,0 +1,98 @@
/*
Copyright (C) 2014 undido
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
expands images and webm on hover
*/
$(document).ready(function(){
var mouseisOnImage = false;
var mouseexitedImage = false;
var imageHover = (localStorage['imagehover']) ? true:false;
imageHover = !imageHover;
var imageEnter = function(){
if (!imageHover)
return;
mouseexitedImage = false;
mouseisOnImage = false;
isVideo = (($(this).prop("tagName") == "VIDEO") ? true:($(this).parent().attr("href").indexOf("player.php?v=") > -1) ? true:false);
maxWidth = document.body.offsetWidth-(document.body.offsetWidth * 0.25);
maxHeight = document.documentElement.clientHeight;
stylez = "z-index:1000;z-index: 1000;position: fixed;top: 0;right: 0;";
if (!isVideo){
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text();
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false;
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]);
imageWidth = parseInt(imageD.split("x")[0]);
imageHeight = parseInt(imageD.split("x")[1]);
widStyle = "max-width:" + maxWidth + "px;";
heiStyle = ((maxHeight < imageHeight) ? "height:"+maxHeight+"px;":"");
$imgH = $("<img/>", {"src":$(this).parent().attr("href"), "style":stylez + ((imageWidth > maxWidth) ? widStyle:"")+heiStyle, "id":"hover-image"});
} else {
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text();
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false;
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]);
videoWidth = parseInt(imageD.split("x")[0]);
videoHeight = parseInt(imageD.split("x")[1]);
widStyle = "width:" + ((maxWidth > videoWidth) ? videoWidth:maxWidth) + "px;" + "height:" + ((maxHeight < videoHeight) ? "100%": videoHeight+"px;");
$imgH = $("<iframe/>", {"src":$(this).parent().attr("href"), "style":stylez + widStyle, "id":"hover-image"});
}
$(document.body).append($imgH);
$("#hover-image").hover(function(){
mouseisOnImage = true;
}, function(){
mouseisOnImage = false;
if (mouseexitedImage){
$("#hover-image").remove();
}
});
};
imageLeave = function(){
setTimeout(function(){
mouseexitedImage = true;
if (!mouseisOnImage){
$("#hover-image").remove();
}
},50);
};
$("a .post-image").hover(imageEnter,imageLeave);
$mrCheckie = $('<div><label id=\"toggle-image-hover\"><input id="toggle-hover" type=\"checkbox\"> show image on hover</label></div>');
$(".options_tab").append($mrCheckie);
$("#toggle-hover").prop("checked", imageHover);
$("#toggle-hover").on("click", function(){
if ($(this).prop("checked")){
imageHover = true;
delete localStorage['imagehover'];
} else {
imageHover = false;
localStorage['imagehover'] = true;
}
});
$(".options_tab").append();
$(document).on("new_post", function(e, post) {
$(post).hover(imageEnter(),imageLeave());
});
});

View File

@ -34,6 +34,10 @@ $(document).ready(function(){
'<br>' +
'[<input title="Global Report" type="checkbox" name="global" id="global_report" />' +
'<label for="global_report" title="Report rule violation (CP, etc) to global staff">Global</label>' +
']<input type="submit" name="report" value="Report" /> ' +
'<label for="reason_' + id + '">'+_('Reason')+'</label>: ' +
'<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' +
' <input type="submit" name="report" value="'+_('Report')+'">' +

View File

@ -2,7 +2,9 @@
include "inc/functions.php";
$boards = listBoards();
$boards = listBoards(true);
$board = array_rand($boards);
header('Location: /'.$boards[$board]["uri"]);
header('Location: /'.$boards[$board]);
?>

View File

@ -15,7 +15,7 @@
$boards = listBoards(TRUE);
}
$body = Element('search_form.html', Array('boards' => $boards, 'board' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '&quot;', utf8tohtml($_GET['search'])) : false));
$body = Element('search_form.html', Array('boards' => $boards, 'b' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '&quot;', utf8tohtml($_GET['search'])) : false));
if(isset($_GET['search']) && !empty($_GET['search']) && isset($_GET['board']) && in_array($_GET['board'], $boards)) {
$phrase = $_GET['search'];

BIN
static/favicon_au.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

View File

@ -9,6 +9,6 @@
<div class="delete" style="clear:both">
<label for="reason">{% trans %}Reason{% endtrans %}</label>
<input id="reason" type="text" name="reason" size="20" maxlength="30" />
[<input title="Delete file only" type="checkbox" name="global" id="global_report" /><label for="global_report" title="Report rule violation (CP, etc) to global staff">{% trans %}Global{% endtrans %}</label>]
[<input title="Global Report" type="checkbox" name="global" id="global_report" /><label for="global_report" title="Report rule violation (CP, etc) to global staff">{% trans %}Global{% endtrans %}</label>]
<input type="submit" name="report" value="{% trans %}Report{% endtrans %}" />
</div>