mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-12-11 07:16:10 +01:00
New feature: custom board assets
This commit is contained in:
parent
8068099bd5
commit
ca066b0ca8
@ -15,6 +15,7 @@
|
||||
$config['mod']['mod_board_log'] = MOD;
|
||||
$config['mod']['editpost'] = BOARDVOLUNTEER;
|
||||
$config['mod']['edit_banners'] = MOD;
|
||||
$config['mod']['edit_assets'] = MOD;
|
||||
$config['mod']['edit_flags'] = MOD;
|
||||
$config['mod']['edit_settings'] = MOD;
|
||||
$config['mod']['edit_volunteers'] = MOD;
|
||||
@ -51,3 +52,4 @@
|
||||
$config['mod']['custom_pages']['/flags/(\%b)'] = '8_flags';
|
||||
$config['mod']['custom_pages']['/banners/(\%b)'] = '8_banners';
|
||||
$config['mod']['custom_pages']['/settings/(\%b)'] = '8_settings';
|
||||
$config['mod']['custom_pages']['/assets/(\%b)'] = '8_assets';
|
||||
|
@ -303,6 +303,121 @@ FLAGS;
|
||||
mod_page(_('Edit flags'), 'mod/flags.html', array('board'=>$board,'banners'=>$banners,'token'=>make_secure_link_token('banners/'.$board['uri'])));
|
||||
}
|
||||
|
||||
function mod_8_assets($b) {
|
||||
global $config, $mod, $board;
|
||||
require_once 'inc/image.php';
|
||||
|
||||
if (!hasPermission($config['mod']['edit_assets'], $b))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
if (!openBoard($b))
|
||||
error("Could not open board!");
|
||||
|
||||
$dir = 'static/assets/'.$b;
|
||||
|
||||
if (!is_dir($dir)){
|
||||
mkdir($dir, 0777, true);
|
||||
|
||||
symlink(getcwd() . '/' . $config['image_deleted'], "$dir/deleted.png");
|
||||
symlink(getcwd() . '/' . $config['spoiler_image'], "$dir/spoiler.png");
|
||||
symlink(getcwd() . '/' . $config['no_file_image'], "$dir/no-file.png");
|
||||
}
|
||||
|
||||
// "File deleted"
|
||||
if (isset($_FILES['deleted_file']) && !empty($_FILES['deleted_file']['tmp_name'])){
|
||||
$upload = $_FILES['deleted_file']['tmp_name'];
|
||||
$extension = strtolower(mb_substr($_FILES['deleted_file']['name'], mb_strrpos($_FILES['deleted_file']['name'], '.') + 1));
|
||||
var_dump($_FILES);
|
||||
|
||||
if (!is_readable($upload)) {
|
||||
error($config['error']['nomove']);
|
||||
}
|
||||
|
||||
if (filesize($upload) > 512000){
|
||||
error('File too large!');
|
||||
}
|
||||
|
||||
if (!in_array($extension, array('png', 'gif'))) {
|
||||
error('File must be PNG or GIF format.');
|
||||
}
|
||||
|
||||
if (!$size = @getimagesize($upload)) {
|
||||
error($config['error']['invalidimg']);
|
||||
}
|
||||
|
||||
if ($size[0] != 140 or $size[1] != 50){
|
||||
error('Image wrong size!');
|
||||
}
|
||||
|
||||
unlink("$dir/deleted.png");
|
||||
copy($upload, "$dir/deleted.png");
|
||||
purge("$dir/deleted.png");
|
||||
}
|
||||
|
||||
// Spoiler file
|
||||
if (isset($_FILES['spoiler_file']) && !empty($_FILES['spoiler_file']['tmp_name'])){
|
||||
$upload = $_FILES['spoiler_file']['tmp_name'];
|
||||
$extension = strtolower(mb_substr($_FILES['spoiler_file']['name'], mb_strrpos($_FILES['spoiler_file']['name'], '.') + 1));
|
||||
|
||||
if (!is_readable($upload)) {
|
||||
error($config['error']['nomove']);
|
||||
}
|
||||
|
||||
if (filesize($upload) > 512000){
|
||||
error('File too large!');
|
||||
}
|
||||
|
||||
|
||||
if (!in_array($extension, array('png', 'gif'))) {
|
||||
error('File must be PNG or GIF format.');
|
||||
}
|
||||
|
||||
if (!$size = @getimagesize($upload)) {
|
||||
error($config['error']['invalidimg']);
|
||||
}
|
||||
|
||||
if ($size[0] != 128 or $size[1] != 128){
|
||||
error('Image wrong size!');
|
||||
}
|
||||
|
||||
unlink("$dir/spoiler.png");
|
||||
copy($upload, "$dir/spoiler.png");
|
||||
purge("$dir/spoiler.png");
|
||||
}
|
||||
|
||||
// No file
|
||||
if (isset($_FILES['nofile_file']) && !empty($_FILES['nofile_file']['tmp_name'])){
|
||||
$upload = $_FILES['nofile_file']['tmp_name'];
|
||||
$extension = strtolower(mb_substr($_FILES['nofile_file']['name'], mb_strrpos($_FILES['nofile_file']['name'], '.') + 1));
|
||||
|
||||
if (!is_readable($upload)) {
|
||||
error($config['error']['nomove']);
|
||||
}
|
||||
|
||||
if (filesize($upload) > 512000){
|
||||
error('File too large!');
|
||||
}
|
||||
|
||||
if (!in_array($extension, array('png', 'gif'))) {
|
||||
error('File must be PNG or GIF format.');
|
||||
}
|
||||
|
||||
if (!$size = @getimagesize($upload)) {
|
||||
error($config['error']['invalidimg']);
|
||||
}
|
||||
|
||||
if ($size[0] != 500 or $size[1] != 500){
|
||||
error('Image wrong size!');
|
||||
}
|
||||
|
||||
unlink("$dir/no-file.png");
|
||||
copy($upload, "$dir/no-file.png");
|
||||
purge("$dir/no-file.png");
|
||||
}
|
||||
|
||||
mod_page(_('Edit board assets'), 'mod/assets.html', array('board'=>$board,'token'=>make_secure_link_token('assets/'.$board['uri'])));
|
||||
}
|
||||
|
||||
function mod_8_banners($b) {
|
||||
global $config, $mod, $board;
|
||||
require_once 'inc/image.php';
|
||||
@ -431,6 +546,16 @@ FLAGS;
|
||||
$multiimage = '';
|
||||
}
|
||||
|
||||
if (isset($_POST['custom_assets'])) {
|
||||
$assets = "\$config['custom_assets'] = true;
|
||||
\$config['spoiler_image'] = 'static/assets/$b/spoiler.png';
|
||||
\$config['image_deleted'] = 'static/assets/$b/deleted.png';
|
||||
\$config['no_file_image'] = 'static/assets/$b/no-file.png';
|
||||
";
|
||||
} else {
|
||||
$assets = '';
|
||||
}
|
||||
|
||||
$file_board = '';
|
||||
if ($fileboard) {
|
||||
$force_image_op = true;
|
||||
@ -588,7 +713,8 @@ FLAGS;
|
||||
\$config['max_pages'] = $max_pages;
|
||||
\$config['max_newlines'] = $max_newlines;
|
||||
\$config['oekaki'] = $oekaki;
|
||||
$code_tags $katex $replace $multiimage $allow_flash $allow_pdf $user_flags
|
||||
$code_tags $katex $replace $multiimage $allow_flash $allow_pdf $user_flags
|
||||
$assets
|
||||
$locale
|
||||
$anal_filenames
|
||||
$file_board
|
||||
|
@ -839,7 +839,7 @@
|
||||
// Location of thumbnail to use for spoiler images.
|
||||
$config['spoiler_image'] = 'static/spoiler.png';
|
||||
// Location of thumbnail to use for deleted images.
|
||||
// $config['image_deleted'] = 'static/deleted.png';
|
||||
$config['image_deleted'] = 'static/deleted.png';
|
||||
// Location of placeholder image for fileless posts in catalog.
|
||||
$config['no_file_image'] = 'static/no-file.png';
|
||||
|
||||
@ -1784,3 +1784,6 @@
|
||||
|
||||
// Allowed HTML tags in ?/edit_pages.
|
||||
$config['allowed_html'] = 'a[href|title],p,br,li,ol,ul,strong,em,u,h2,b,i,tt,div,img[src|alt|title],hr,h1,h2,h3,h4,h5';
|
||||
|
||||
// Use custom assets? (spoiler file, etc; this is used by ?/settings and ?/assets)
|
||||
$config['custom_assets'] = false;
|
||||
|
@ -30,7 +30,8 @@
|
||||
<option value="fileboard" {% if config.file_board %}selected{% endif %}>File board</option>
|
||||
</select></td></tr>
|
||||
<tr><th>{% trans %}Country flags{% endtrans %}</th><td><input type="checkbox" name="country_flags" {% if config.country_flags %}checked{% endif %}></td></tr>
|
||||
<tr><th>{% trans %}/pol/-style user flags{% endtrans %}<br><span class="unimportant">Enabling this disables country flags<br>Make sure to actually upload some first!</span></th><td><input type="checkbox" name="user_flags" {% if config.user_flag %}checked{% endif %}></td></tr>
|
||||
<tr><th>{% trans %}/pol/-style user flags{% endtrans %}<br><span class="unimportant">Enabling this disables country flags<br>Make sure to actually upload some first on the flags page!</span></th><td><input type="checkbox" name="user_flags" {% if config.user_flag %}checked{% endif %}></td></tr>
|
||||
<tr><th>{% trans %}Custom board assets{% endtrans %}<br><span class="unimportant">Enabling this uses your custom spoiler/deleted/no file images.<br>Make sure to actually upload some first on the assets page or they will 404!</span></th><td><input type="checkbox" name="custom_assets" {% if config.custom_assets %}checked{% endif %}></td></tr>
|
||||
<tr><th>{% trans %}Forced anonymous{% endtrans %}</th><td><input type="checkbox" name="field_disable_name" {% if config.field_disable_name %}checked{% endif %}></td></tr>
|
||||
<tr><th>{% trans %}YouTube/Voocaroo embedding{% endtrans %}</th><td><input type="checkbox" name="enable_embedding" {% if config.enable_embedding %}checked{% endif %}></td></tr>
|
||||
<tr class='imgboard'><th>{% trans %}Require image for OP{% endtrans %}</th><td><input type="checkbox" name="force_image_op" {% if config.force_image_op %}checked{% endif %}></td></tr>
|
||||
|
@ -76,10 +76,10 @@
|
||||
|
||||
if ($files[0]) {
|
||||
if ($files[0]->file == 'deleted') {
|
||||
$post['file'] = $config['image_deleted'];
|
||||
$post['file'] = $config['root'] . $config['image_deleted'];
|
||||
}
|
||||
else if($files[0]->thumb == 'spoiler') {
|
||||
$post['file'] = '/' . $config['spoiler_image'];
|
||||
$post['file'] = $config['root'] . $config['spoiler_image'];
|
||||
}
|
||||
else {
|
||||
if ($files[0]->thumb == 'file') {
|
||||
|
Loading…
Reference in New Issue
Block a user