-
Notifications
You must be signed in to change notification settings - Fork 19
/
types.go
734 lines (634 loc) · 22.7 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
package main
import (
"encoding/json"
"html"
"io/ioutil"
"log"
"os"
"path"
"strconv"
"time"
"github.com/frustra/bbcode"
)
var (
config GochanConfig
accessLog *log.Logger
errorLog *log.Logger
modLog *log.Logger
readBannedIPs []string
bbcompiler bbcode.Compiler
version GochanVersion
)
type RecentPost struct {
BoardName string
BoardID int
PostID int
ParentID int
Name string
Tripcode string
Message string
Filename string
ThumbW int
ThumbH int
IP string
Timestamp time.Time
}
func (p *RecentPost) GetURL(includeDomain bool) string {
postURL := ""
if includeDomain {
postURL += config.SiteDomain
}
idStr := strconv.Itoa(p.PostID)
postURL += config.SiteWebfolder + p.BoardName + "/res/"
if p.ParentID == 0 {
postURL += idStr + ".html#" + idStr
} else {
postURL += strconv.Itoa(p.ParentID) + ".html#" + idStr
}
return postURL
}
type Thread struct {
OP PostTable
NumReplies int
NumImages int
OmittedImages int
BoardReplies []PostTable
Stickied bool
ThreadPage int
}
// SQL Table structs
type AnnouncementsTable struct {
ID uint
Subject string
Message string
Poster string
Timestamp time.Time
}
type AppealsTable struct {
ID int
Ban int
Message string
Denied bool
StaffResponse string
}
func (a *AppealsTable) GetBan() (BanlistTable, error) {
var ban BanlistTable
var err error
err = queryRowSQL("SELECT * FROM `"+config.DBprefix+"banlist` WHERE `id` = ? LIMIT 1",
[]interface{}{a.ID}, []interface{}{
&ban.ID, &ban.AllowRead, &ban.IP, &ban.Name, &ban.NameIsRegex, &ban.SilentBan,
&ban.Boards, &ban.Staff, &ban.Timestamp, &ban.Expires, &ban.Permaban, &ban.Reason,
&ban.StaffNote, &ban.AppealAt},
)
return ban, err
}
type BanlistTable struct {
ID uint
AllowRead bool
IP string
Name string
NameIsRegex bool
SilentBan uint8
Boards string
Staff string
Timestamp time.Time
Expires time.Time
Permaban bool
Reason string
Type int
StaffNote string
AppealAt time.Time
CanAppeal bool
}
type BannedHashesTable struct {
ID uint
Checksum string
Description string
}
type BoardsTable struct {
ID int
CurrentPage int
NumPages int
Order int
Dir string
Type int
UploadType int
Title string
Subtitle string
Description string
Section int
MaxImageSize int
MaxPages int
Locale string
DefaultStyle string
Locked bool
CreatedOn time.Time
Anonymous string
ForcedAnon bool
MaxAge int
AutosageAfter int
NoImagesAfter int
MaxMessageLength int
EmbedsAllowed bool
RedirectToThread bool
ShowID bool
RequireFile bool
EnableCatalog bool
EnableSpoileredImages bool
EnableSpoileredThreads bool
EnableNSFW bool
ThreadPage int
}
type BoardSectionsTable struct {
ID int
Order int
Hidden bool
Name string
Abbreviation string
}
// EmbedsTable represents the embedable media on different sites.
// It's held over from Kusaba X and may be removed in the future
type EmbedsTable struct {
ID uint8
Filetype string
Name string
URL string
Width uint16
Height uint16
EmbedCode string
}
// FrontTable represents the information (News, rules, etc) on the front page
type FrontTable struct {
ID int
Page int
Order int
Subject string
Message string
Timestamp time.Time
Poster string
Email string
}
// FrontLinksTable is used for linking to sites that the admin likes
type FrontLinksTable struct {
ID uint8
Title string
URL string
}
type LoginAttemptsTable struct {
ID uint
IP string
Timestamp time.Time
}
type ModLogTable struct {
IP uint
Entry string
User string
Category uint8
Timestamp time.Time
}
// PollResultsTable may or may not be used in the future for user polls
type PollResultsTable struct {
ID uint
IP string
Selection string
Timestamp time.Time
}
// PostTable represents each post in the database
type PostTable struct {
ID int
CurrentPage int
NumPages int
BoardID int
ParentID int
Name string
Tripcode string
Email string
Subject string
MessageHTML string
MessageText string
Password string
Filename string
FilenameOriginal string
FileChecksum string
Filesize int
ImageW int
ImageH int
ThumbW int
ThumbH int
IP string
Tag string
Timestamp time.Time
Autosage int
PosterAuthority int
DeletedTimestamp time.Time
Bumped time.Time
Stickied bool
Locked bool
Reviewed bool
Sillytag bool
}
func (p *PostTable) GetURL(includeDomain bool) string {
postURL := ""
if includeDomain {
postURL += config.SiteDomain
}
board, err := getBoardFromID(p.BoardID)
if err != nil {
return postURL
}
idStr := strconv.Itoa(p.ID)
postURL += config.SiteWebfolder + board.Dir + "/res/"
if p.ParentID == 0 {
postURL += idStr + ".html#" + idStr
} else {
postURL += strconv.Itoa(p.ParentID) + ".html#" + idStr
}
return postURL
}
// Sanitize escapes HTML strings in a post. This should be run immediately before
// the post is inserted into the database
func (p *PostTable) Sanitize() {
p.Name = html.EscapeString(p.Name)
p.Email = html.EscapeString(p.Email)
p.Subject = html.EscapeString(p.Subject)
p.Password = html.EscapeString(p.Password)
}
type ReportsTable struct {
ID uint
Board string
PostID uint
Timestamp time.Time
IP string
Reason string
Cleared bool
IsTemp bool
}
type SessionsTable struct {
ID uint
Data string
Expires string
}
// StaffTable represents a single staff member's info stored in the database
type StaffTable struct {
ID int
Username string
PasswordChecksum string
Salt string
Rank int
Boards string
AddedOn time.Time
LastActive time.Time
}
type WordFiltersTable struct {
ID int
From string
To string
Boards string
RegEx bool
}
// Types for the JSON files we generate as a sort of "API"
type BoardJSONWrapper struct {
Boards []BoardJSON `json:"boards"`
}
type BoardJSON struct {
BoardName string `json:"board"`
Title string `json:"title"`
WorkSafeBoard int `json:"ws_board"`
ThreadsPerPage int `json:"per_page"`
Pages int `json:"pages"`
MaxFilesize int `json:"max_filesize"`
MaxMessageLength int `json:"max_comment_chars"`
BumpLimit int `json:"bump_limit"`
ImageLimit int `json:"image_limit"`
Cooldowns BoardCooldowns `json:"cooldowns"`
Description string `json:"meta_description"`
IsArchived int `json:"is_archived"`
}
type BoardCooldowns struct {
NewThread int `json:"threads"`
Reply int `json:"replies"`
ImageReply int `json:"images"`
}
type ThreadJSONWrapper struct {
Posts []PostJSON `json:"posts"`
}
type PostJSON struct {
ID int `json:"no"`
ParentID int `json:"resto"`
Subject string `json:"sub"`
Message string `json:"com"`
Name string `json:"name"`
Tripcode string `json:"trip"`
Timestamp int64 `json:"time"`
Bumped int64 `json:"last_modified"`
ThumbWidth int `json:"tn_w"`
ThumbHeight int `json:"tn_h"`
ImageWidth int `json:"w"`
ImageHeight int `json:"h"`
FileSize int `json:"fsize"`
OrigFilename string `json:"filename"`
Extension string `json:"ext"`
Filename string `json:"tim"`
FileChecksum string `json:"md5"`
}
type BoardPageJSON struct {
Threads []ThreadJSON `json:"threads"`
Page int `json:"page"`
}
type ThreadJSON struct {
*PostJSON
OmittedPosts int `json:"omitted_posts"`
OmittedImages int `json:"omitted_images"`
Replies int `json:"replies"`
ImagesOnArchive int `json:"images"`
Sticky int `json:"sticky"`
Locked int `json:"locked"`
}
// ErrorJSON and PostInfoJSON are mostly used for AJAX requests
type ErrorJSON struct {
Message string `json:"error"`
}
type Style struct {
Name string
Filename string
}
// GochanConfig stores crucial info and is read from/written to gochan.json
type GochanConfig struct {
ListenIP string
Port int
FirstPage []string
Error404Path string
Error500Path string
Username string
UseFastCGI bool
DocumentRoot string
TemplateDir string
LogDir string
DBtype string
DBhost string
DBname string
DBusername string
DBpassword string
DBprefix string
DBkeepalive bool
Lockdown bool `description:"Disables posting." default:"unchecked"`
LockdownMessage string `description:"Message displayed when someone tries to post while the site is on lockdown."`
Sillytags []string `description:"List of randomly selected staff tags separated by line, e.g. <span style=\"color: red;\">## Mod</span>, to be randomly assigned to posts if UseSillytags is checked. Don't include the \"## \""`
UseSillytags bool `description:"Use Sillytags" default:"unchecked"`
Modboard string `description:"A super secret clubhouse board that only staff can view/post to." default:"staff"`
SiteName string `description:"The name of the site that appears in the header of the front page." default:"Gochan"`
SiteSlogan string `description:"The text that appears below SiteName on the home page"`
SiteHeaderURL string `description:"To be honest, I'm not even sure what this does. It'll probably be removed later."`
SiteWebfolder string `description:"The HTTP root appearing in the browser (e.g. https://gochan.org/<SiteWebFolder>" default:"/"`
SiteDomain string `description:"The server's domain (duh). Do not edit this unless you know what you are doing or BAD THINGS WILL HAPPEN!" default:"127.0.0.1" critical:"true"`
DomainRegex string `description:"Regular expression used for incoming request validation. Do not edit this unless you know what you are doing or BAD THINGS WILL HAPPEN!" default:"(https|http):\\\\/\\\\/(gochan\\\\.lunachan\\.net|gochan\\\\.org)\\/(.*)" critical:"true"`
Styles []Style `description:"List of styles (one per line) that should be accessed online at <SiteWebFolder>/css/<Style>/"`
DefaultStyle string `description:"Filename of the default Style. This should appear in the list above or bad things might happen."`
AllowDuplicateImages bool `description:"Disabling this will cause gochan to reject a post if the image has already been uploaded for another post.<br />This may end up being removed or being made board-specific in the future." default:"checked"`
AllowVideoUploads bool `description:"Allows users to upload .webm videos. <br />This may end up being removed or being made board-specific in the future."`
NewThreadDelay int `description:"The amount of time in seconds that is required before an IP can make a new thread.<br />This may end up being removed or being made board-specific in the future." default:"30"`
ReplyDelay int `description:"Same as the above, but for replies." default:"7"`
MaxLineLength int `description:"Any line in a post that exceeds this will be split into two (or more) lines.<br />I'm not really sure why this is here, so it may end up being removed." default:"150"`
ReservedTrips []string `description:"Secure tripcodes (!!Something) can be reserved here.<br />Each reservation should go on its own line and should look like this:<br />TripPassword1##Tripcode1<br />TripPassword2##Tripcode2"`
ThumbWidth int `description:"OP thumbnails use this as their max width.<br />To keep the aspect ratio, the image will be scaled down to the ThumbWidth or ThumbHeight, whichever is larger." default:"200"`
ThumbHeight int `description:"OP thumbnails use this as their max height.<br />To keep the aspect ratio, the image will be scaled down to the ThumbWidth or ThumbHeight, whichever is larger." default:"200"`
ThumbWidth_reply int `description:"Same as ThumbWidth and ThumbHeight but for reply images." default:"125"`
ThumbHeight_reply int `description:"Same as ThumbWidth and ThumbHeight but for reply images." default:"125"`
ThumbWidth_catalog int `description:"Same as ThumbWidth and ThumbHeight but for catalog images." default:"50"`
ThumbHeight_catalog int `description:"Same as ThumbWidth and ThumbHeight but for catalog images." default:"50"`
ThreadsPerPage int `default:"15"`
PostsPerThreadPage int `description:"Max number of replies to a thread to show on each thread page." default:"50"`
RepliesOnBoardPage int `description:"Number of replies to a thread to show on the board page." default:"3"`
StickyRepliesOnBoardPage int `description:"Same as above for stickied threads." default:"1"`
BanColors []string `description:"Colors to be used for public ban messages (e.g. USER WAS BANNED FOR THIS POST).<br />Each entry should be on its own line, and should look something like this:<br />username1:#FF0000<br />username2:#FAF00F<br />username3:blue<br />Invalid entries/nonexistent usernames will show a warning and use the default red."`
BanMsg string `description:"The default public ban message." default:"USER WAS BANNED FOR THIS POST"`
EmbedWidth int `description:"The width for inline/expanded webm videos." default:"200"`
EmbedHeight int `description:"The height for inline/expanded webm videos." default:"164"`
ExpandButton bool `description:"If checked, adds [Embed] after a Youtube, Vimeo, etc link to toggle an inline video frame." default:"checked"`
ImagesOpenNewTab bool `description:"If checked, thumbnails will open the respective image/video in a new tab instead of expanding them." default:"unchecked"`
MakeURLsHyperlinked bool `description:"If checked, URLs in posts will be turned into a hyperlink. If unchecked, ExpandButton and NewTabOnOutlinks are ignored." default:"checked"`
NewTabOnOutlinks bool `description:"If checked, links to external sites will open in a new tab." default:"checked"`
EnableQuickReply bool `description:"If checked, an optional quick reply box is used. This may end up being removed." default:"checked"`
DateTimeFormat string `description:"The format used for dates. See <a href=\"https://golang.org/pkg/time/#Time.Format\">here</a> for more info."`
AkismetAPIKey string `description:"The API key to be sent to Akismet for post spam checking. If the key is invalid, Akismet won't be used."`
EnableGeoIP bool `description:"If checked, this enables the usage of GeoIP for posts." default:"checked"`
GeoIPDBlocation string `description:"Specifies the location of the GeoIP database file. If you're using CloudFlare, you can set it to cf to rely on CloudFlare for GeoIP information." default:"/usr/share/GeoIP/GeoIP.dat"`
MaxRecentPosts int `description:"The maximum number of posts to show on the Recent Posts list on the front page." default:"3"`
RecentPostsWithNoFile bool `description:"If checked, recent posts with no image/upload are shown on the front page (as well as those with images" default:"unchecked"`
// Verbosity = 0 for no debugging info. Critical errors and general output only
// Verbosity = 1 for non-critical warnings and important info
// Verbosity = 2 for all debugging/benchmarks/warnings
Verbosity int `description:"The level of verbosity to use in error/warning messages. 0 = critical errors/startup messages, 1 = warnings, 2 = benchmarks/notices." default:"0"`
EnableAppeals bool `description:"If checked, allow banned users to appeal their bans.<br />This will likely be removed (permanently allowing appeals) or made board-specific in the future." default:"checked"`
MaxLogDays int `description:"The maximum number of days to keep messages in the moderation/staff log file."`
RandomSeed string `critical:"true"`
}
func initConfig() {
jfile, err := ioutil.ReadFile("gochan.json")
if err != nil {
printf(0, "Error reading \"gochan.json\": %s\n", err.Error())
os.Exit(2)
}
if err = json.Unmarshal(jfile, &config); err != nil {
switch err.Error() {
case "json: cannot unmarshal string into Go struct field GochanConfig.Styles of type main.Style":
printf(0, `Error parsing gochan.json. config.Styles has been changed from a string array to an object.
Each Style in gochan.json must have a Name field that will appear in the style dropdowns and a Filename field. For example
{
"Styles": [
{"Name": "Pipes", "Filename": "pipes.css"},
{"Name": "Burichan", "Filename": "burichan.css"}
],
}
DefaultStyle must refer to a given Style's Filename field. If DefaultStyle does not appear in gochan.json, the first element in Styles will be used.
`)
default:
printf(0, "Error parsing \"gochan.json\": %s\n", err.Error())
}
os.Exit(2)
}
if config.ListenIP == "" {
println(0, "ListenIP not set in gochan.json, halting.")
os.Exit(2)
}
if config.Port == 0 {
config.Port = 80
}
if len(config.FirstPage) == 0 {
config.FirstPage = []string{"index.html", "board.html"}
}
if config.Error404Path == "" {
println(0, "Error404Path not set in gochan.json, halting.")
os.Exit(2)
}
if config.Error500Path == "" {
println(0, "Error500Path not set in gochan.json, halting.")
os.Exit(2)
}
if config.Username == "" {
config.Username = "gochan"
}
if config.DocumentRoot == "" {
println(0, "DocumentRoot not set in gochan.json, halting.")
os.Exit(2)
}
wd, wderr := os.Getwd()
if wderr == nil {
_, staterr := os.Stat(path.Join(wd, config.DocumentRoot, "css"))
if staterr == nil {
config.DocumentRoot = path.Join(wd, config.DocumentRoot)
}
}
if config.TemplateDir == "" {
println(0, "TemplateDir not set in gochan.json, halting.")
os.Exit(2)
}
if config.LogDir == "" {
println(0, "LogDir not set in gochan.json, halting.")
os.Exit(2)
}
accessLogFile, err := os.OpenFile(path.Join(config.LogDir, "access.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
if err != nil {
println(0, "Couldn't open access log. Returned error: "+err.Error())
os.Exit(1)
} else {
accessLog = log.New(accessLogFile, "", log.Ltime|log.Ldate)
}
errorLogFile, err := os.OpenFile(path.Join(config.LogDir, "error.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
if err != nil {
println(0, "Couldn't open error log. Returned error: "+err.Error())
os.Exit(1)
} else {
errorLog = log.New(errorLogFile, "", log.Ltime|log.Ldate)
}
modLogFile, err := os.OpenFile(path.Join(config.LogDir, "mod.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
if err != nil {
println(0, "Couldn't open mod log. Returned error: "+err.Error())
} else {
modLog = log.New(modLogFile, "", log.Ltime|log.Ldate)
}
if config.DBtype == "" {
println(0, "DBtype not set in gochan.json, halting (currently supported values: mysql).")
os.Exit(2)
}
if config.DBhost == "" {
println(0, "DBhost not set in gochan.json, halting.")
os.Exit(2)
}
if config.DBname == "" {
config.DBname = "gochan"
}
if config.DBusername == "" {
config.DBusername = "gochan"
}
if config.DBpassword == "" {
println(0, "DBpassword not set in gochan.json, halting.")
os.Exit(2)
}
if config.LockdownMessage == "" {
config.LockdownMessage = "This imageboard has temporarily disabled posting. We apologize for the inconvenience"
}
if config.Modboard == "" {
config.Modboard = "staff"
}
if config.SiteName == "" {
config.SiteName = "An unnamed imageboard"
}
if config.SiteDomain == "" {
println(0, "SiteDomain not set in gochan.json, halting.")
os.Exit(2)
}
if config.SiteWebfolder == "" {
println(0, "SiteWebFolder not set in gochan.json, using / as default.")
} else if string(config.SiteWebfolder[0]) != "/" {
config.SiteWebfolder = "/" + config.SiteWebfolder
}
if config.SiteWebfolder[len(config.SiteWebfolder)-1:] != "/" {
config.SiteWebfolder += "/"
}
if config.DomainRegex == "" {
println(0, "DomainRegex not set in gochan.json, consider using (https|http):\\/\\/("+config.SiteDomain+")\\/(.*)")
println(0, "This should work in most cases. Halting")
os.Exit(2)
//config.DomainRegex = "(https|http):\\/\\/(" + config.SiteDomain + ")\\/(.*)"
}
if config.Styles == nil {
println(0, "Styles not set in gochan.json, halting.")
os.Exit(2)
}
if config.DefaultStyle == "" {
config.DefaultStyle = config.Styles[0].Filename
}
if config.NewThreadDelay == 0 {
config.NewThreadDelay = 30
}
if config.ReplyDelay == 0 {
config.ReplyDelay = 7
}
if config.MaxLineLength == 0 {
config.MaxLineLength = 150
}
//ReservedTrips string //eventually this will be map[string]string
if config.ThumbWidth == 0 {
config.ThumbWidth = 200
}
if config.ThumbHeight == 0 {
config.ThumbHeight = 200
}
if config.ThumbWidth_reply == 0 {
config.ThumbWidth_reply = 125
}
if config.ThumbHeight_reply == 0 {
config.ThumbHeight_reply = 125
}
if config.ThumbWidth_catalog == 0 {
config.ThumbWidth_catalog = 50
}
if config.ThumbHeight_catalog == 0 {
config.ThumbHeight_catalog = 50
}
if config.ThreadsPerPage == 0 {
config.ThreadsPerPage = 10
}
if config.PostsPerThreadPage == 0 {
config.PostsPerThreadPage = 4
}
if config.RepliesOnBoardPage == 0 {
config.PostsPerThreadPage = 3
}
if config.StickyRepliesOnBoardPage == 0 {
config.StickyRepliesOnBoardPage = 1
}
/*config.BanColors, err = c.GetString("threads", "ban_colors") //eventually this will be map[string] string
if err != nil {
config.BanColors = "admin:#CC0000"
}*/
if config.BanMsg == "" {
config.BanMsg = "(USER WAS BANNED FOR THIS POST)"
}
if config.DateTimeFormat == "" {
config.DateTimeFormat = "Mon, January 02, 2006 15:04 PM"
}
if config.EnableGeoIP {
if config.GeoIPDBlocation == "" {
println(0, "GeoIPDBlocation not set in gochan.json, disabling EnableGeoIP.")
config.EnableGeoIP = false
}
}
if config.MaxLogDays == 0 {
config.MaxLogDays = 15
}
if config.RandomSeed == "" {
println(0, "RandomSeed not set in gochan.json, halting.")
os.Exit(2)
}
bbcompiler = bbcode.NewCompiler(true, true)
bbcompiler.SetTag("center", nil)
bbcompiler.SetTag("code", nil)
bbcompiler.SetTag("color", nil)
bbcompiler.SetTag("img", nil)
bbcompiler.SetTag("quote", nil)
bbcompiler.SetTag("size", nil)
version = ParseVersion(versionStr)
version.Normalize()
}