2013-10-31 23:14:19 +01:00
< ? php
/*
* Instance Configuration
* ----------------------
* Edit this file and not config . php for imageboard configuration .
*
* You can copy values from config . php ( defaults ) and paste them here .
*/
2014-09-24 22:19:58 +02:00
require_once " lib/htmlpurifier-4.5.0/library/HTMLPurifier.auto.php " ;
require_once " 8chan-functions.php " ;
2013-10-31 23:14:19 +01:00
2014-10-04 22:44:42 +02:00
// Note - you may want to change some of these in secrets.php instead of here
// See the secrets.example.php file
2013-10-31 23:14:19 +01:00
$config [ 'db' ][ 'server' ] = 'localhost' ;
$config [ 'db' ][ 'database' ] = '8chan' ;
$config [ 'db' ][ 'prefix' ] = '' ;
$config [ 'db' ][ 'user' ] = 'root' ;
2014-09-24 22:14:02 +02:00
$config [ 'db' ][ 'password' ] = '' ;
2014-05-17 22:01:14 +02:00
$config [ 'timezone' ] = 'UTC' ;
$config [ 'cache' ][ 'enabled' ] = 'apc' ;
2013-10-31 23:14:19 +01:00
$config [ 'cookies' ][ 'mod' ] = 'mod' ;
2014-09-24 22:14:02 +02:00
$config [ 'cookies' ][ 'salt' ] = '' ;
2013-10-31 23:14:19 +01:00
2014-09-27 01:54:53 +02:00
$config [ 'spam' ][ 'hidden_inputs_max_pass' ] = 128 ;
$config [ 'spam' ][ 'hidden_inputs_expire' ] = 60 * 60 * 4 ; // three hours
2014-09-24 22:14:02 +02:00
$config [ 'flood_time' ] = 5 ;
2014-10-05 19:07:59 +02:00
$config [ 'flood_time_ip' ] = 30 ;
2014-09-23 03:29:06 +02:00
$config [ 'flood_time_same' ] = 2 ;
2014-05-17 22:01:14 +02:00
$config [ 'max_body' ] = 5000 ;
2014-10-08 02:33:32 +02:00
$config [ 'reply_limit' ] = 300 ;
2013-10-31 23:14:19 +01:00
$config [ 'thumb_width' ] = 255 ;
$config [ 'thumb_height' ] = 255 ;
$config [ 'max_width' ] = 10000 ;
$config [ 'max_height' ] = 10000 ;
2014-09-20 17:21:09 +02:00
$config [ 'threads_per_page' ] = 15 ;
2014-10-08 02:33:32 +02:00
$config [ 'max_pages' ] = 15 ;
2013-10-31 23:14:19 +01:00
$config [ 'threads_preview' ] = 5 ;
$config [ 'root' ] = '/' ;
2014-09-24 22:14:02 +02:00
$config [ 'secure_trip_salt' ] = '' ;
2014-09-20 17:21:09 +02:00
$config [ 'always_noko' ] = true ;
$config [ 'allow_no_country' ] = true ;
2014-09-21 19:51:42 +02:00
$config [ 'thread_subject_in_title' ] = true ;
$config [ 'spam' ][ 'hidden_inputs_max_pass' ] = 128 ;
2014-09-26 00:53:56 +02:00
$config [ 'ayah_enabled' ] = true ;
2013-10-31 23:14:19 +01:00
2014-10-04 22:33:48 +02:00
// Load database credentials
require " secrets.php " ;
2014-09-24 22:19:58 +02:00
2013-10-31 23:14:19 +01:00
// Image shit
2014-05-17 22:01:14 +02:00
$config [ 'thumb_method' ] = 'gm+gifsicle' ;
$config [ 'thumb_ext' ] = '' ;
$config [ 'thumb_keep_animation_frames' ] = 100 ;
2013-10-31 23:14:19 +01:00
$config [ 'show_ratio' ] = true ;
2014-09-21 19:51:42 +02:00
//$config['allow_upload_by_url'] = true;
2014-10-08 02:33:32 +02:00
$config [ 'max_filesize' ] = 1024 * 1024 * 8 ; // 8MB
2013-10-31 23:14:19 +01:00
$config [ 'disable_images' ] = false ;
$config [ 'spoiler_images' ] = true ;
2014-09-24 06:25:55 +02:00
$config [ 'image_reject_repost' ] = true ;
2014-05-17 22:01:14 +02:00
$config [ 'allowed_ext_files' ][] = 'webm' ;
2014-09-21 19:51:42 +02:00
$config [ 'webm' ][ 'use_ffmpeg' ] = true ;
$config [ 'webm' ][ 'allow_audio' ] = true ;
$config [ 'webm' ][ 'max_length' ] = 60 * 15 ;
2013-10-31 23:14:19 +01:00
// Mod shit
$config [ 'mod' ][ 'groups' ][ 25 ] = 'Supermod' ;
define_groups ();
2014-09-23 03:29:06 +02:00
$config [ 'mod' ][ 'capcode' ][ MOD ] = array ( 'Board Volunteer' );
$config [ 'mod' ][ 'capcode' ][ SUPERMOD ] = array ( 'Global Volunteer' );
2014-05-17 22:01:14 +02:00
$config [ 'custom_capcode' ][ 'Admin' ] = array (
'<span class="capcode" style="color:blue;font-weight:bold"> <i class="fa fa-wheelchair"></i> %s</span>' ,
);
$config [ 'custom_capcode' ][ 'Bear' ] = array (
'<span class="capcode" style="color:brown;font-weight:bold"> <img src="/static/paw.svg" height="12" width="12"> %s</span>' ,
);
2013-10-31 23:14:19 +01:00
//$config['mod']['view_banlist'] = SUPERMOD;
$config [ 'mod' ][ 'manageusers' ] = SUPERMOD ;
$config [ 'mod' ][ 'noticeboard_post' ] = SUPERMOD ;
$config [ 'mod' ][ 'search' ] = SUPERMOD ;
$config [ 'mod' ][ 'debug_recent' ] = ADMIN ;
$config [ 'mod' ][ 'debug_antispam' ] = ADMIN ;
2014-09-24 06:25:55 +02:00
$config [ 'mod' ][ 'modlog' ] = SUPERMOD ;
2014-10-08 02:33:32 +02:00
$config [ 'mod' ][ 'editpost' ] = MOD ;
2014-09-23 17:31:52 +02:00
$config [ 'mod' ][ 'recent_reports' ] = 65535 ;
2014-10-08 02:33:32 +02:00
$config [ 'ban_show_post' ] = true ;
2013-10-31 23:14:19 +01:00
// Board shit
2014-10-01 01:06:48 +02:00
$config [ 'max_links' ] = 40 ;
2014-09-27 23:23:51 +02:00
$config [ 'poster_id_length' ] = 6 ;
2014-09-25 22:14:00 +02:00
$config [ 'ayah_enabled' ] = true ;
2014-05-17 22:01:14 +02:00
$config [ 'url_banner' ] = '/banners.php' ;
2013-10-31 23:14:19 +01:00
//$config['default_stylesheet'] = array('Notsuba', 'notsuba.css');
$config [ 'additional_javascript' ][] = 'js/jquery.min.js' ;
$config [ 'additional_javascript' ][] = 'js/jquery.tablesorter.min.js' ;
2014-09-23 03:29:06 +02:00
$config [ 'additional_javascript' ][] = 'js/options.js' ;
$config [ 'additional_javascript' ][] = 'js/style-select.js' ;
$config [ 'additional_javascript' ][] = 'js/options/general.js' ;
2014-05-17 22:01:14 +02:00
$config [ 'additional_javascript' ][] = 'js/post-hover.js' ;
2014-10-07 03:01:01 +02:00
$config [ 'additional_javascript' ][] = 'js/update_boards.js' ;
2014-09-20 17:21:09 +02:00
$config [ 'additional_javascript' ][] = 'js/favorites.js' ;
2014-05-17 22:01:14 +02:00
$config [ 'additional_javascript' ][] = 'js/show-op.js' ;
$config [ 'additional_javascript' ][] = 'js/hide-threads.js' ;
2014-09-25 23:35:17 +02:00
$config [ 'additional_javascript' ][] = 'js/smartphone-spoiler.js' ;
2014-05-17 22:01:14 +02:00
$config [ 'additional_javascript' ][] = 'js/inline-expanding.js' ;
$config [ 'additional_javascript' ][] = 'js/show-backlinks.js' ;
$config [ 'additional_javascript' ][] = 'js/webm-settings.js' ;
$config [ 'additional_javascript' ][] = 'js/expand-video.js' ;
$config [ 'additional_javascript' ][] = 'js/treeview.js' ;
2014-10-07 16:00:40 +02:00
$config [ 'additional_javascript' ][] = 'js/download-all.js' ;
$config [ 'additional_javascript' ][] = 'js/jszip.min.js' ;
2014-05-17 22:01:14 +02:00
$config [ 'additional_javascript' ][] = 'js/quick-post-controls.js' ;
$config [ 'additional_javascript' ][] = 'js/expand-too-long.js' ;
$config [ 'additional_javascript' ][] = 'js/settings.js' ;
$config [ 'additional_javascript' ][] = 'js/fix-report-delete-submit.js' ;
$config [ 'additional_javascript' ][] = 'js/hide-images.js' ;
$config [ 'additional_javascript' ][] = 'js/expand-all-images.js' ;
$config [ 'additional_javascript' ][] = 'js/local-time.js' ;
2014-06-10 19:57:37 +02:00
$config [ 'additional_javascript' ][] = 'js/no-animated-gif.js' ;
2014-09-13 18:36:40 +02:00
$config [ 'additional_javascript' ][] = 'js/expand.js' ;
2014-09-24 22:14:02 +02:00
$config [ 'additional_javascript' ][] = 'js/titlebar-notifications.js' ;
2014-09-20 17:21:09 +02:00
$config [ 'additional_javascript' ][] = 'js/auto-reload.js' ;
$config [ 'additional_javascript' ][] = 'js/quick-reply.js' ;
2014-09-23 03:29:06 +02:00
$config [ 'additional_javascript' ][] = 'js/options/user-css.js' ;
$config [ 'additional_javascript' ][] = 'js/options/user-js.js' ;
$config [ 'additional_javascript' ][] = 'js/forced-anon.js' ;
$config [ 'additional_javascript' ][] = 'js/toggle-locked-threads.js' ;
$config [ 'additional_javascript' ][] = 'js/toggle-images.js' ;
2014-09-25 23:35:17 +02:00
$config [ 'additional_javascript' ][] = 'js/mobile-style.js' ;
2014-09-27 22:08:18 +02:00
$config [ 'additional_javascript' ][] = 'js/id_highlighter.js' ;
$config [ 'additional_javascript' ][] = 'js/id_colors.js' ;
2014-10-07 03:36:19 +02:00
$config [ 'additional_javascript' ][] = 'js/inline.js' ;
2014-10-09 03:20:47 +02:00
$config [ 'additional_javascript' ][] = 'js/infinite-scroll.js' ;
2014-05-17 22:01:14 +02:00
2014-10-05 19:07:59 +02:00
$config [ 'font_awesome_css' ] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ;
2013-10-31 23:14:19 +01:00
2014-09-20 17:21:09 +02:00
$config [ 'stylesheets' ][ 'Dark' ] = 'dark.css' ;
2014-09-23 03:29:06 +02:00
$config [ 'stylesheets' ][ 'Photon' ] = 'photon.css' ;
2014-09-20 17:21:09 +02:00
2013-10-31 23:14:19 +01:00
$config [ 'stylesheets_board' ] = true ;
$config [ 'markup' ][] = array ( " /^[ | \t ]*==(.+?)==[ | \t ]* $ /m " , " <span class= \" heading \" > \$ 1</span> " );
$config [ 'markup' ][] = array ( " / \ [spoiler \ ](.+?) \ [ \ /spoiler \ ]/ " , " <span class= \" spoiler \" > \$ 1</span> " );
2014-05-17 22:01:14 +02:00
$config [ 'markup' ][] = array ( " /~~(.+?)~~/ " , " <s> \$ 1</s> " );
2014-10-07 03:01:01 +02:00
$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 ( '<i class="fa fa-twitter" title="Twitter"></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'));
2013-10-31 23:14:19 +01:00
2014-09-24 06:27:14 +02:00
$config [ 'footer' ][] = 'Contribute to 8chan.co development at <a href="https://github.com/ctrlcctrlv/8chan">github</a>' ;
2014-05-17 22:01:14 +02:00
$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.' ;
$config [ 'search' ][ 'enable' ] = true ;
2013-10-31 23:14:19 +01:00
2014-06-12 05:07:16 +02:00
//$config['debug'] = true;
$config [ 'syslog' ] = true ;
2013-10-31 23:14:19 +01:00
2014-09-23 17:31:52 +02:00
$config [ 'wordfilters' ][] = array ( '\rule' , '' ); // 'true' means it's a regular expression
2013-10-31 23:14:19 +01:00
if ( ! function_exists ( 'prettify_textarea' )){
function prettify_textarea ( $s ){
2014-05-17 22:01:14 +02:00
return str_replace ( " \t " , '	' , str_replace ( " \n " , ' ' , htmlentities ( $s )));
2013-10-31 23:14:19 +01:00
}
}
if ( ! function_exists ( 'purify' )){
function purify ( $s ){
$config = HTMLPurifier_Config :: createDefault ();
$purifier = new HTMLPurifier ( $config );
$clean_html = $purifier -> purify ( $s );
return $clean_html ;
}
}
2014-05-17 22:01:14 +02:00
$config [ 'mod' ][ 'custom_pages' ][ '/banners/(\%b)' ] = function ( $b ) {
global $config , $mod , $board ;
require_once 'inc/image.php' ;
if ( ! in_array ( $b , $mod [ 'boards' ]) and $mod [ 'boards' ][ 0 ] != '*' )
error ( $config [ 'error' ][ 'noaccess' ]);
if ( ! openBoard ( $b ))
error ( " Could not open board! " );
$dir = 'static/banners/' . $b ;
if ( ! is_dir ( $dir )){
mkdir ( $dir , 0777 , true );
}
if ( isset ( $_FILES [ 'file' ])){
$upload = $_FILES [ 'file' ][ 'tmp_name' ];
$banners = array_diff ( scandir ( $dir ), array ( '..' , '.' ));
if ( ! is_readable ( $upload ))
error ( $config [ 'error' ][ 'nomove' ]);
$id = time () . substr ( microtime (), 2 , 3 );
$extension = strtolower ( mb_substr ( $_FILES [ 'file' ][ 'name' ], mb_strrpos ( $_FILES [ 'file' ][ 'name' ], '.' ) + 1 ));
if ( ! in_array ( $extension , array ( 'jpg' , 'jpeg' , 'png' , 'gif' ))){
error ( 'Not an image extension.' );
}
if ( filesize ( $upload ) > 512000 ){
error ( 'File too large!' );
}
if ( ! $size = @ getimagesize ( $upload )) {
error ( $config [ 'error' ][ 'invalidimg' ]);
}
if ( $size [ 0 ] != 300 or $size [ 1 ] != 100 ){
error ( 'Image wrong size!' );
}
2014-10-08 02:33:32 +02:00
if ( sizeof ( $banners ) >= 50 ) {
2014-05-17 22:01:14 +02:00
error ( 'Too many banners.' );
}
copy ( $upload , " $dir / $id . $extension " );
}
if ( isset ( $_POST [ 'delete' ])){
foreach ( $_POST [ 'delete' ] as $i => $d ){
if ( ! preg_match ( '/[0-9+]\.(png|jpeg|jpg|gif)/' , $d )){
error ( 'Nice try.' );
}
unlink ( " $dir / $d " );
}
}
$banners = array_diff ( scandir ( $dir ), array ( '..' , '.' ));
mod_page ( _ ( 'Edit banners' ), 'mod/banners.html' , array ( 'board' => $board , 'banners' => $banners , 'token' => make_secure_link_token ( 'banners/' . $board [ 'uri' ])));
};
2013-10-31 23:14:19 +01:00
$config [ 'mod' ][ 'custom_pages' ][ '/settings/(\%b)' ] = function ( $b ) {
global $config , $mod ;
if ( ! in_array ( $b , $mod [ 'boards' ]) and $mod [ 'boards' ][ 0 ] != '*' )
error ( $config [ 'error' ][ 'noaccess' ]);
if ( ! openBoard ( $b ))
error ( " Could not open board! " );
2014-05-17 22:01:14 +02:00
$possible_languages = array_diff ( scandir ( 'inc/locale/' ), array ( '..' , '.' , '.tx' , 'README.md' ));
2013-10-31 23:14:19 +01:00
if ( $_SERVER [ 'REQUEST_METHOD' ] == 'POST' ) {
$title = $_POST [ 'title' ];
$subtitle = $_POST [ 'subtitle' ];
$country_flags = isset ( $_POST [ 'country_flags' ]) ? 'true' : 'false' ;
$field_disable_name = isset ( $_POST [ 'field_disable_name' ]) ? 'true' : 'false' ;
$enable_embedding = isset ( $_POST [ 'enable_embedding' ]) ? 'true' : 'false' ;
$force_image_op = isset ( $_POST [ 'force_image_op' ]) ? 'true' : 'false' ;
$disable_images = isset ( $_POST [ 'disable_images' ]) ? 'true' : 'false' ;
$poster_ids = isset ( $_POST [ 'poster_ids' ]) ? 'true' : 'false' ;
2014-05-17 22:01:14 +02:00
$show_sages = isset ( $_POST [ 'show_sages' ]) ? 'true' : 'false' ;
$auto_unicode = isset ( $_POST [ 'auto_unicode' ]) ? 'true' : 'false' ;
2014-09-20 17:21:09 +02:00
$allow_roll = isset ( $_POST [ 'allow_roll' ]) ? 'true' : 'false' ;
2014-09-24 06:25:55 +02:00
$image_reject_repost = isset ( $_POST [ 'image_reject_repost' ]) ? 'true' : 'false' ;
2014-09-23 17:31:52 +02:00
$allow_flash = isset ( $_POST [ 'allow_flash' ]) ? '$config[\'allowed_ext_files\'][] = \'swf\';' : '' ;
2013-10-31 23:14:19 +01:00
$code_tags = isset ( $_POST [ 'code_tags' ]) ? '$config[\'additional_javascript\'][] = \'js/code_tags/run_prettify.js\';$config[\'markup\'][] = array("/\[code\](.+?)\[\/code\]/ms", "<code><pre class=\'prettyprint\' style=\'display:inline-block\'>\$1</pre></code>");' : '' ;
2014-09-21 19:51:42 +02:00
$katex = isset ( $_POST [ 'katex' ]) ? '$config[\'katex\'] = true;$config[\'additional_javascript\'][] = \'js/katex/katex.min.js\'; $config[\'markup\'][] = array("/\[tex\](.+?)\[\/tex\]/ms", "<span class=\'tex\'>\$1</span>"); $config[\'additional_javascript\'][] = \'js/katex-enable.js\';' : '' ;
2014-05-17 22:01:14 +02:00
$oekaki_js = <<< OEKAKI
\ $config [ 'additional_javascript' ][] = 'js/jquery-ui.custom.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/ajax.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/lib/wColorPicker.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/wPaint.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/plugins/main/wPaint.menu.main.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/plugins/text/wPaint.menu.text.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/plugins/shapes/wPaint.menu.main.shapes.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wPaint/plugins/file/wPaint.menu.main.file.min.js' ;
\ $config [ 'additional_javascript' ][] = 'js/wpaint.js' ;
\ $config [ 'additional_javascript' ][] = 'js/upload-selection.js' ;
OEKAKI ;
$oekaki = isset ( $_POST [ 'oekaki' ]) ? $oekaki_js : '' ;
if ( $_POST [ 'locale' ] !== 'en' && in_array ( $_POST [ 'locale' ], $possible_languages )) {
$locale = " \$ config['locale'] = ' { $_POST [ 'locale' ] } .UTF-8';
\ $config [ 'file_script' ] = '$b/main.js' ; " ;
} else {
$locale = '' ;
}
if ( isset ( $_POST [ 'max_images' ]) && ( int ) $_POST [ 'max_images' ] && ( int ) $_POST [ 'max_images' ] <= 5 ) {
$_POST [ 'max_images' ] = ( int ) $_POST [ 'max_images' ];
$multiimage = " \$ config['max_images'] = { $_POST [ 'max_images' ] } ;
\ $config [ 'file_script' ] = '$b/main.js' ;
2014-06-05 16:35:51 +02:00
\ $config [ 'additional_javascript' ][] = 'js/multi-image.js' ; " ;
2014-05-17 22:01:14 +02:00
} else {
$multiimage = '' ;
}
2013-10-31 23:14:19 +01:00
$anonymous = base64_encode ( $_POST [ 'anonymous' ]);
$blotter = base64_encode ( purify ( html_entity_decode ( $_POST [ 'blotter' ])));
2014-05-17 22:01:14 +02:00
$add_to_config = @ file_get_contents ( $b . '/extra_config.php' );
$replace = '' ;
if ( isset ( $_POST [ 'replace' ])) {
if ( count ( $_POST [ 'replace' ]) == count ( $_POST [ 'with' ])) {
foreach ( $_POST [ 'replace' ] as $i => $r ) {
if ( $r !== '' ) {
$w = $_POST [ 'with' ][ $i ];
$replace .= '$config[\'wordfilters\'][] = array(base64_decode(\'' . base64_encode ( $r ) . '\'), base64_decode(\'' . base64_encode ( $w ) . '\'));' ;
}
}
}
}
2013-10-31 23:14:19 +01:00
if ( ! ( strlen ( $title ) < 40 ))
error ( 'Invalid title' );
if ( ! ( strlen ( $subtitle ) < 200 ))
error ( 'Invalid subtitle' );
2014-10-09 03:10:47 +02:00
$query = prepare ( 'UPDATE ``boards`` SET `title` = :title, `subtitle` = :subtitle, `indexed` = :indexed, `public_bans` = :public_bans WHERE `uri` = :uri' );
2013-10-31 23:14:19 +01:00
$query -> bindValue ( ':title' , $title );
$query -> bindValue ( ':subtitle' , $subtitle );
$query -> bindValue ( ':uri' , $b );
2014-10-08 05:54:00 +02:00
$query -> bindValue ( ':indexed' , ! isset ( $_POST [ 'meta_noindex' ]));
2014-10-09 03:10:47 +02:00
$query -> bindValue ( ':public_bans' , isset ( $_POST [ 'public_bans' ]));
2013-10-31 23:14:19 +01:00
$query -> execute () or error ( db_error ( $query ));
2014-05-17 22:01:14 +02:00
2013-10-31 23:14:19 +01:00
$config_file = <<< EOT
< ? php
\ $config [ 'country_flags' ] = $country_flags ;
\ $config [ 'field_disable_name' ] = $field_disable_name ;
\ $config [ 'enable_embedding' ] = $enable_embedding ;
\ $config [ 'force_image_op' ] = $force_image_op ;
\ $config [ 'disable_images' ] = $disable_images ;
\ $config [ 'poster_ids' ] = $poster_ids ;
2014-05-17 22:01:14 +02:00
\ $config [ 'show_sages' ] = $show_sages ;
\ $config [ 'auto_unicode' ] = $auto_unicode ;
2014-09-20 17:21:09 +02:00
\ $config [ 'allow_roll' ] = $allow_roll ;
2014-09-24 06:25:55 +02:00
\ $config [ 'image_reject_repost' ] = $image_reject_repost ;
2013-10-31 23:14:19 +01:00
\ $config [ 'anonymous' ] = base64_decode ( '$anonymous' );
\ $config [ 'blotter' ] = base64_decode ( '$blotter' );
\ $config [ 'stylesheets' ][ 'Custom' ] = 'board/$b.css' ;
\ $config [ 'default_stylesheet' ] = array ( 'Custom' , \ $config [ 'stylesheets' ][ 'Custom' ]);
2014-09-23 17:31:52 +02:00
$code_tags $katex $oekaki $replace $multiimage $allow_flash
2013-10-31 23:14:19 +01:00
if ( \ $config [ 'disable_images' ])
\ $config [ 'max_pages' ] = 10000 ;
2014-05-17 22:01:14 +02:00
$locale
$add_to_config
2013-10-31 23:14:19 +01:00
EOT ;
file_write ( $b . '/config.php' , $config_file );
file_write ( 'stylesheets/board/' . $b . '.css' , $_POST [ 'css' ]);
file_write ( $b . '/rules.html' , Element ( 'page.html' , array ( 'title' => 'Rules' , 'subtitle' => '' , 'config' => $config , 'body' => '<div class="ban">' . purify ( $_POST [ 'rules' ]) . '</div>' )));
file_write ( $b . '/rules.txt' , $_POST [ 'rules' ]);
2014-05-17 22:01:14 +02:00
openBoard ( $b );
buildIndex ();
buildJavascript ();
$query = query ( sprintf ( " SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL " , $b )) or error ( db_error ());
while ( $post = $query -> fetch ( PDO :: FETCH_ASSOC )) {
buildThread ( $post [ 'id' ]);
}
modLog ( 'Edited board settings' , $b );
2013-10-31 23:14:19 +01:00
}
$query = prepare ( 'SELECT * FROM boards WHERE uri = :board' );
$query -> bindValue ( ':board' , $b );
$query -> execute () or error ( db_error ( $query ));
$board = $query -> fetchAll ()[ 0 ];
$rules = @ file_get_contents ( $board [ 'uri' ] . '/rules.txt' );
$css = @ file_get_contents ( 'stylesheets/board/' . $board [ 'uri' ] . '.css' );
openBoard ( $b );
2014-10-09 03:10:47 +02:00
rebuildThemes ( 'bans' );
2014-05-17 22:01:14 +02:00
if ( $config [ 'cache' ][ 'enabled' ])
cache :: delete ( 'board_' . $board [ 'uri' ]);
cache :: delete ( 'all_boards' );
2013-10-31 23:14:19 +01:00
2014-05-17 22:01:14 +02:00
mod_page ( _ ( 'Board configuration' ), 'mod/settings.html' , array ( 'board' => $board , 'rules' => prettify_textarea ( $rules ), 'css' => prettify_textarea ( $css ), 'token' => make_secure_link_token ( 'settings/' . $board [ 'uri' ]), 'languages' => $possible_languages ));
2013-10-31 23:14:19 +01:00
};
2014-05-18 21:37:22 +02:00
$config [ 'embedding' ] = array (
array (
'/^https?:\/\/(\w+\.)?youtube\.com\/watch\?v=([a-zA-Z0-9\-_]{10,11})(&.+)?$/i' ,
'<iframe style="float: left;margin: 10px 20px;" width="%%tb_width%%" height="%%tb_height%%" frameborder="0" id="ytplayer" type="text/html" src="https://www.youtube.com/embed/$2"></iframe>'
),
array (
'/^https?:\/\/(\w+\.)?vimeo\.com\/(\d{2,10})(\?.+)?$/i' ,
'<object style="float: left;margin: 10px 20px;" width="%%tb_width%%" height="%%tb_height%%"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="https://vimeo.com/moogaloop.swf?clip_id=$2&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=0&loop=0" /><embed src="https://vimeo.com/moogaloop.swf?clip_id=$2&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="%%tb_width%%" height="%%tb_height%%"></embed></object>'
),
array (
'/^https?:\/\/(\w+\.)?dailymotion\.com\/video\/([a-zA-Z0-9]{2,10})(_.+)?$/i' ,
'<object style="float: left;margin: 10px 20px;" width="%%tb_width%%" height="%%tb_height%%"><param name="movie" value="https://www.dailymotion.com/swf/video/$2"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><param name="wmode" value="transparent"></param><embed type="application/x-shockwave-flash" src="https://www.dailymotion.com/swf/video/$2" width="%%tb_width%%" height="%%tb_height%%" wmode="transparent" allowfullscreen="true" allowscriptaccess="always"></embed></object>'
),
array (
'/^https?:\/\/(\w+\.)?metacafe\.com\/watch\/(\d+)\/([a-zA-Z0-9_\-.]+)\/(\?.+)?$/i' ,
'<div style="float:left;margin:10px 20px;width:%%tb_width%%px;height:%%tb_height%%px"><embed flashVars="playerVars=showStats=no|autoPlay=no" src="https://www.metacafe.com/fplayer/$2/$3.swf" width="%%tb_width%%" height="%%tb_height%%" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_$2" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>'
),
array (
'/^https?:\/\/video\.google\.com\/videoplay\?docid=(\d+)([&#](.+)?)?$/i' ,
'<embed src="https://video.google.com/googleplayer.swf?docid=$1&hl=en&fs=true" style="width:%%tb_width%%px;height:%%tb_height%%px;float:left;margin:10px 20px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>'
),
array (
'/^https?:\/\/(\w+\.)?vocaroo\.com\/i\/([a-zA-Z0-9]{2,15})$/i' ,
'<object style="float: left;margin: 10px 20px;" width="148" height="44"><param name="movie" value="https://vocaroo.com/player.swf?playMediaID=$2&autoplay=0"></param><param name="wmode" value="transparent"></param><embed src="https://vocaroo.com/player.swf?playMediaID=$2&autoplay=0" width="148" height="44" wmode="transparent" type="application/x-shockwave-flash"></embed></object>'
)
);
2014-07-19 20:40:06 +02:00
$config [ 'gzip_static' ] = false ;