diff options
-rw-r--r-- | README.md | 56 | ||||
-rw-r--r-- | cgi/settings.py | 124 | ||||
-rw-r--r-- | weabot.sql | 268 |
3 files changed, 448 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f7f938 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +weabot +====== +weabot is a Python textboard and imageboard script made for Bienvenido a Internet BBS/IB. It's based on PyIB. + +New features +------------ +- Textboards +- Home page +- Report system +- Thread locking and permasaging +- Mobile website +- IDs +- Noko +- View and delete posts by IP +- Oekaki +- Flexible filetypes (such as Flash) +- Wordfilters +- Proper markdown and HTML +- API +- Many bugfixes and security improvements, and other minor improvements + +Requirements +------------ +* Python 2.x +* MySQL/MariaDB +* MySQL-Python (MySQLdb) +* WSGI/FastCGI (Optional) + +Installation +------------ +1. Set up your web server to run Python scripts as CGI or FastCGI (see .htaccess example) +2. Create a MySQL/MariaDB database and import the `weabot.sql` file +3. Enter your database information and preferences in `cgi/settings.py` +4. Navigate to http://yoursite.com/cgi/weabot.py/manage +5. Log-in with credentials admin/admin - then create your own staff account and delete admin + +Authors +------- +weabot fork by Bienvenido a Internet N.P.O. <burocracia@bienvenidoainternet.org> +Original work by tslocum <tslocum@gmail.com> https://github.com/tslocum/PyIB + +License +------- +weabot is licensed under the AGPLv3, with portions under the GPLv3. +If you run weabot, even on a web server, you must publish any changes of the source code, and under the same license. +Please read the full text of the license for more details (LICENSE file). +If you don't agree with the license terms, please choose one of the alternatives to weabot listed below. + +Alternatives +------------ +Some alternatives to weabot are: + +* [Wakaba/Kareha](http://wakaba.c3.cx/s/web/wakaba_kareha) +* [TinyIB](https://github.com/tslocum/TinyIB) +* [Tinyboard](http://tinyboard.org/) +* [PyIB](https://github.com/tslocum/PyIB) diff --git a/cgi/settings.py b/cgi/settings.py new file mode 100644 index 0000000..dfe3d49 --- /dev/null +++ b/cgi/settings.py @@ -0,0 +1,124 @@ +# coding=utf-8 +import threading + +class SettingsLocal(threading.local): + USING_SQLALCHEMY = False # If SQLAlchemy is installed, set to True to use it + + # Ignore these + BOARD = None + CONN = None + + IS_TOR = None + IS_PROXY = None + HOST = None + +class Settings(object): + LANG = "es" + + # *************** PATH INFORMATION *************** + NAME = "localhost" + DOMAIN = ".localdomain" + ROOT_DIR = "/var/www/" + HOME_DIR = "/var/www/" + IMAGES_DIR = "/var/www/" + STATIC_DIR = "/var/www/static/" + HOME_URL = "http://localhost/" + BOARDS_URL = "/" + CGI_URL = "/cgi/" # URL to folder containing the script + IMAGES_URL = "/" + STATIC_URL = "/static/" + USE_MULTITHREADING = False + MAX_PROGRAM_THREADS = 8 # Maximum threads this Python application can start (must be 2 or greater) + # Setting this too high can cause the program to terminate before finishing + # (Only needed if multithreading is on) + + CONVERT_PATH = "convert" # Location to ImageMagick's convert tool + FFMPEG_PATH = "ffmpeg" + FFPROBE_PATH = "ffprobe" + # CONVERT_PATH = "C:\\Utils\\ImageMagick-6.7.0-Q16\\convert" + + # *************** DATABASE INFORMATION *************** + DATABASE_HOST = "localhost" + DATABASE_USERNAME = "user" + DATABASE_PASSWORD = "pass" + DATABASE_DB = "db" + # The following two entries apply only if USING_SQLALCHEMY is set to True + DATABASE_POOL_SIZE = 5 # Initial number of database connections + DATABASE_POOL_OVERFLOW = 21 # Maximum number of database connections + + # Keys + SECRET = 'CHANGEME' # Random seed for secure tripcodes, change it to something random + GOOGLE_API_KEY = '' + DISCORD_HOOK_URL = '' + + # *************** HOME PAGE INFORMATION *************** + SITE_TITLE = "My site" + SITE_LOGO = Env.STATIC_URL + "logo.png" + SITE_SLOGAN = "My slogan" + MAINTENANCE = False # Set to True if you are making changes to the server so users can't post + FULL_MAINTENANCE = False + ENABLE_RSS = False + ENABLE_DISCORD_HOOK = True + + # *************** BANNER INFORMATION *************** + ENABLE_BANNERS = True + banners_folder = Env.STATIC_URL + "img/" # Folder containing banners + banners = { # filename, width, height + 'default': [("default.png", "500", "81")], + } + + # *************** IMAGES *************** + THUMB_QUALITY = 85 # Image quality for thumbnails (0-100) + + # *************** BANS *************** + HTACCESS_GEN = True # Set to True to use .htaccess for bans (needed for blind bans!) + EXCLUDE_GLOBAL_BANS = [] # Excludes the following boards from global bans (not board specific bans) + + # 'Name': ('Tripcode', 'New BBS name', 'New IB name', 'New ID', Hide Slip[bool]) + CAPCODES = {} + + # *************** BOARDS *************** + MAX_THREADS = 500 # IB + TXT_MAX_THREADS = 10000 # BBS + + TRIM_METHOD = 0 # Which threads are trimmed first: + TXT_TRIM_METHOD = 1 # 0 = oldest (Futaba), 1 = inactive (2ch), 2 = least bumped (4chan) + + CLOSE_THREAD_ON_REPLIES = 1000 + TXT_CLOSE_THREAD_ON_REPLIES = 1000 + + MAX_AGE_ALERT = 0.15 # Multiplier for thread expiration alert + + ALLOW_SECURE_TRIPCODES = False + TRIP_CHAR = '◆' + + HOME_NEWS = 10 # News posts shown on home + HOME_LASTPOSTS = 25 # Last posts shown on home + HOME_NEWTHREADS = 17 # New threads shown on home + HOME_LASTPOSTS_LENGTH = 100 + + MODNEWS_MAX_POSTS = 30 # Max posts in the Manage front page + REPORTS_ENABLE = True # Enable or disable report system + REPORTS_PER_PAGE = 100 + RECYCLEBIN_POSTS_PER_PAGE = 25 + + DELETE_FORBID_LENGTH = 5 # User can't delete own thread if replies exceed this + ARCHIVE_MIN_LENGTH = 5 # Minimum thread length to archive (0 = archive always) + + # *************** STYLES *************** + STYLES = ('Rene', 'Dickgirl', 'Red', 'Photon', 'Cyber', 'Easymodo', 'Guro', 'Night', 'Futaba', 'Buri', 'Kraut', 'VNDB', 'Putaba') + STYLES_DEFAULT = 0 + + TXT_STYLES = ('4am', 'Amber', 'Ayashii', 'Baisano', 'BIOS', 'Blue Moon', 'Ciber', 'Futanari', 'Headline', 'Postal', 'Ventanas') + TXT_STYLES_DEFAULT = 3 + + # *************** MISC *************** + TIME_ZONE = -3 + USE_MARKDOWN = False + USE_HTML = False + VIDEO_THUMBS = False + VIDEO_THUMBS_LIMIT = 5 + + SESSION_TIME = 30 * 60 + + _ = SettingsLocal() # Used when running multiple threads diff --git a/weabot.sql b/weabot.sql new file mode 100644 index 0000000..e91a8f2 --- /dev/null +++ b/weabot.sql @@ -0,0 +1,268 @@ +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `archive` ( + `id` int(10) unsigned NOT NULL, + `boardid` smallint(5) unsigned NOT NULL, + `timestamp` int(20) unsigned NOT NULL, + `subject` varchar(255) CHARACTER SET latin1 NOT NULL, + `length` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`id`,`boardid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bans` ( + `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT, + `ip` int(15) unsigned NOT NULL, + `netmask` int(15) unsigned DEFAULT NULL, + `boards` text NOT NULL, + `added` int(10) unsigned NOT NULL, + `until` int(10) unsigned NOT NULL, + `staff` varchar(50) NOT NULL, + `reason` text NOT NULL, + `note` text NOT NULL, + `blind` tinyint(1) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `ip` (`ip`) +) ENGINE=MyISAM AUTO_INCREMENT=980 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `boards` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `dir` varchar(16) NOT NULL, + `sort` tinyint(3) unsigned NOT NULL DEFAULT '0', + `name` varchar(64) NOT NULL, + `longname` varchar(128) NOT NULL, + `subname` char(3) NOT NULL, + `postarea_desc` text NOT NULL, + `postarea_extra` text NOT NULL, + `force_css` varchar(255) NOT NULL, + `board_type` tinyint(1) unsigned NOT NULL, + `anonymous` varchar(128) NOT NULL DEFAULT 'Sin Nombre', + `subject` varchar(64) NOT NULL DEFAULT 'Sin asunto', + `message` varchar(128) NOT NULL DEFAULT 'Sin mensaje', + `disable_name` tinyint(1) unsigned NOT NULL DEFAULT '0', + `disable_subject` tinyint(1) unsigned NOT NULL DEFAULT '0', + `useid` tinyint(1) unsigned NOT NULL DEFAULT '1', + `slip` tinyint(1) unsigned NOT NULL DEFAULT '0', + `countrycode` tinyint(1) unsigned DEFAULT '0', + `recyclebin` tinyint(1) unsigned NOT NULL DEFAULT '1', + `locked` tinyint(1) unsigned NOT NULL DEFAULT '0', + `secret` tinyint(1) unsigned NOT NULL DEFAULT '0', + `allow_spoilers` tinyint(1) unsigned NOT NULL DEFAULT '0', + `allow_oekaki` tinyint(1) unsigned NOT NULL DEFAULT '0', + `allow_noimage` tinyint(1) unsigned NOT NULL DEFAULT '1', + `allow_images` tinyint(1) unsigned NOT NULL DEFAULT '1', + `allow_image_replies` tinyint(1) unsigned NOT NULL DEFAULT '1', + `maxsize` smallint(5) unsigned NOT NULL DEFAULT '500', + `thumb_px` smallint(3) unsigned NOT NULL DEFAULT '250', + `numthreads` tinyint(2) unsigned NOT NULL DEFAULT '10', + `numcont` tinyint(2) unsigned NOT NULL DEFAULT '10', + `numline` tinyint(3) unsigned NOT NULL DEFAULT '20', + `maxage` smallint(3) unsigned NOT NULL DEFAULT '0', + `maxinactive` smallint(3) unsigned NOT NULL DEFAULT '0', + `archive` tinyint(1) unsigned NOT NULL DEFAULT '0', + `threadsecs` smallint(4) unsigned NOT NULL DEFAULT '600', + `postsecs` tinyint(3) unsigned NOT NULL DEFAULT '30', + PRIMARY KEY (`id`), + KEY `dir` (`dir`) +) ENGINE=MyISAM AUTO_INCREMENT=48 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `boards_filetypes` ( + `boardid` smallint(5) unsigned NOT NULL, + `filetypeid` smallint(5) unsigned NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `filetypes` ( + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, + `ext` varchar(16) COLLATE utf8_unicode_ci NOT NULL, + `mime` varchar(32) COLLATE utf8_unicode_ci NOT NULL, + `image` varchar(32) COLLATE utf8_unicode_ci NOT NULL, + `preserve_name` tinyint(1) NOT NULL, + `ffmpeg_thumb` tinyint(1) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `filters` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `boards` text NOT NULL, + `type` tinyint(1) NOT NULL, + `action` tinyint(1) NOT NULL, + `from` varchar(255) NOT NULL, + `from_trip` varchar(30) NOT NULL, + `to` text NOT NULL, + `reason` varchar(255) NOT NULL, + `seconds` int(20) unsigned NOT NULL, + `blind` tinyint(1) NOT NULL, + `redirect_url` varchar(40) NOT NULL, + `redirect_time` tinyint(3) unsigned NOT NULL, + `staff` varchar(50) NOT NULL, + `added` int(20) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=85 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `last` ( + `id` int(10) unsigned NOT NULL, + `boardid` smallint(5) unsigned NOT NULL, + `board_name` varchar(64) NOT NULL, + `timestamp` int(20) NOT NULL, + `timestamp_formatted` varchar(50) NOT NULL, + `content` varchar(200) NOT NULL, + `url` varchar(64) NOT NULL, + PRIMARY KEY (`id`,`boardid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `logs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `timestamp` int(20) unsigned NOT NULL, + `staff` varchar(75) NOT NULL, + `action` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=4138 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `news` ( + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, + `type` tinyint(1) NOT NULL, + `staffid` tinyint(3) unsigned NOT NULL, + `staff_name` varchar(50) NOT NULL, + `title` varchar(255) NOT NULL, + `message` text NOT NULL, + `name` varchar(255) NOT NULL, + `timestamp_formatted` varchar(255) NOT NULL, + `timestamp` int(20) unsigned NOT NULL, + PRIMARY KEY (`type`,`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `posts` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `boardid` smallint(5) unsigned NOT NULL, + `parentid` mediumint(10) unsigned NOT NULL, + `timestamp` int(20) unsigned DEFAULT NULL, + `timestamp_formatted` varchar(50) NOT NULL, + `name` varchar(255) NOT NULL, + `tripcode` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `subject` varchar(255) NOT NULL, + `message` text NOT NULL, + `password` varchar(255) NOT NULL, + `file` varchar(75) NOT NULL, + `file_hex` varchar(75) NOT NULL, + `file_size` int(20) unsigned NOT NULL, + `image_width` smallint(5) unsigned NOT NULL, + `image_height` smallint(5) unsigned NOT NULL, + `thumb` varchar(255) NOT NULL, + `thumb_width` smallint(5) unsigned NOT NULL, + `thumb_height` smallint(5) unsigned NOT NULL, + `ip` int(15) unsigned NOT NULL, + `IS_DELETED` tinyint(1) NOT NULL, + `bumped` int(20) unsigned NOT NULL, + `last` int(20) unsigned NOT NULL, + `locked` tinyint(1) NOT NULL, + `expires` int(20) unsigned NOT NULL, + `expires_formatted` varchar(30) NOT NULL, + `expires_alert` tinyint(1) NOT NULL, + `length` smallint(4) unsigned NOT NULL, + PRIMARY KEY (`boardid`,`id`), + KEY `parentid` (`parentid`), + KEY `bumped` (`bumped`) +) ENGINE=MyISAM AUTO_INCREMENT=1743 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `reports` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `board` varchar(16) NOT NULL, + `postid` int(10) unsigned NOT NULL, + `parentid` int(10) unsigned NOT NULL, + `link` varchar(64) NOT NULL, + `ip` varchar(15) NOT NULL, + `reason` varchar(255) NOT NULL, + `reporterip` varchar(15) NOT NULL, + `timestamp` int(20) unsigned NOT NULL, + `timestamp_formatted` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=811 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `search` ( + `id` int(10) NOT NULL, + `boardid` smallint(5) NOT NULL, + `timestamp` int(20) NOT NULL, + `subject` varchar(255) CHARACTER SET latin1 NOT NULL, + `message` text CHARACTER SET latin1 NOT NULL, + `parentid` int(10) NOT NULL, + `parenttime` int(20) NOT NULL, + `parentsub` varchar(255) CHARACTER SET latin1 NOT NULL, + `num` smallint(5) NOT NULL, + PRIMARY KEY (`id`,`boardid`), + FULLTEXT KEY `message` (`message`), + FULLTEXT KEY `subject` (`subject`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `search_kako` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `boardid` smallint(5) unsigned NOT NULL, + `pid` int(10) unsigned NOT NULL, + `subject` varchar(255) CHARACTER SET latin1 NOT NULL, + `message` text CHARACTER SET latin1 NOT NULL, + `parentid` int(10) unsigned NOT NULL, + `num` smallint(5) unsigned NOT NULL, + `timestamp_formatted` varchar(50) CHARACTER SET latin1 NOT NULL, + PRIMARY KEY (`id`,`boardid`), + FULLTEXT KEY `kakoindex` (`message`,`subject`) +) ENGINE=MyISAM AUTO_INCREMENT=115631 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `search_log` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `timestamp` int(20) unsigned NOT NULL, + `keyword` varchar(255) CHARACTER SET latin1 NOT NULL, + `ita` varchar(16) CHARACTER SET latin1 NOT NULL, + `ip` int(20) unsigned NOT NULL, + `res` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=3593 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `session` ( + `session_id` varbinary(32) NOT NULL, + `expires` int(32) NOT NULL, + `staff_id` tinyint(3) NOT NULL, + PRIMARY KEY (`session_id`), + KEY `staff_id` (`staff_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `staff` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `username` varchar(50) NOT NULL, + `password` varchar(255) NOT NULL, + `added` int(10) unsigned NOT NULL, + `lastactive` int(10) unsigned NOT NULL, + `rights` tinyint(1) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `username` (`username`,`password`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; +INSERT INTO `filetypes` VALUES (1,'jpg','image/jpeg','',0,0),(2,'png','image/png','',0,0),(3,'gif','image/gif','',0,0),(4,'swf','application/x-shockwave-flash','mime/swf.png',1,0),(5,'webm','video/webm','',0,1),(6,'ogg','audio/ogg','',0,1),(7,'opus','audio/opus','',0,1),(8,'mod','audio/mod','mime/mod.png',0,0),(9,'xm','audio/xm','mime/xm.png',0,0),(10,'s3m','audio/s3m','mime/s3m.png',0,0),(11,'mp3','audio/mpeg','',0,1),(12,'torrent','application/x-bittorrent','mime/torrent.png',1,0),(13,'pdf','application/pdf','mime/pdf.png',1,0),(14,'epub','application/epub+zip','mime/epub.png',1,0); |