1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-03 07:36:23 -07:00

Hide gochan's root directory if someone tries to make a board when the directory already exists, don't throw an error if a board SQL column doesn't have a default (they all should now, this is for old installations)

This commit is contained in:
Joshua Merrell 2018-02-03 10:21:45 -08:00
parent a04e90e59f
commit ad683a1b34
5 changed files with 21 additions and 19 deletions

View file

@ -40,6 +40,7 @@
"DefaultStyle_txt": "pipes",
"AllowDuplicateImages": true,
"AllowVideoUploads": true,
"NewThreadDelay": 30,
"ReplyDelay": 7,
"MaxLineLength": 150,

View file

@ -61,10 +61,9 @@ CREATE TABLE IF NOT EXISTS `DBPREFIXboards` (
`autosage_after` INT(5) UNSIGNED NOT NULL DEFAULT 200,
`no_images_after` INT(5) UNSIGNED NOT NULL DEFAULT 0,
`max_message_length` INT(10) UNSIGNED NOT NULL DEFAULT 8192,
`embeds_allowed` TINYINT(1) NOT NULL,
`embeds_allowed` TINYINT(1) NOT NULL DEFAULT 1,
`redirect_to_thread` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`require_file` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
`require_file` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`enable_catalog` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=0;

View file

@ -221,7 +221,7 @@ var manage_functions = map[string]ManageFunction{
Permissions: 3,
Callback: func() (html string) {
html = "<img src=\"/css/purge.jpg\" />"
rows, err := db.Query("SELECT `dir` FROM `" + config.DBprefix + "boards`;")
rows, err := db.Query("SELECT `dir` FROM `" + config.DBprefix + "boards`")
if err != nil {
html += err.Error()
return
@ -602,28 +602,28 @@ var manage_functions = map[string]ManageFunction{
err = os.Mkdir(path.Join(config.DocumentRoot, board.Dir), 0777)
if err != nil {
do = ""
board_creation_status = err.Error()
board_creation_status = "ERROR: directory /" + config.DocumentRoot + "/" + board.Dir + "/ already exists!"
break
}
err = os.Mkdir(path.Join(config.DocumentRoot, board.Dir, "res"), 0777)
if err != nil {
do = ""
board_creation_status = err.Error()
board_creation_status = "ERROR: directory /" + config.DocumentRoot + "/" + board.Dir + "/res/ already exists!"
break
}
err = os.Mkdir(path.Join(config.DocumentRoot, board.Dir, "thumb"), 0777)
if err != nil {
do = ""
board_creation_status = err.Error()
board_creation_status = "ERROR: directory /" + config.DocumentRoot + "/" + board.Dir + "/thumb/ already exists!"
break
}
err = os.Mkdir(path.Join(config.DocumentRoot, board.Dir, "src"), 0777)
if err != nil {
do = ""
board_creation_status = err.Error()
board_creation_status = "ERROR: directory /" + config.DocumentRoot + "/" + board.Dir + "/src/ already exists!"
break
}
stmt, err := db.Prepare(
@ -677,24 +677,23 @@ var manage_functions = map[string]ManageFunction{
default:
// put the default column values in the text boxes
rows, err = db.Query("SELECT `column_name`,`column_default` FROM `information_schema`.`columns` WHERE `table_name` = '" + config.DBprefix + "boards'")
defer func() {
if rows != nil {
rows.Close()
}
}()
if err != nil {
html += err.Error()
println(1, err.Error())
println(1, "Error getting column names from boards table:"+err.Error())
return
}
for rows.Next() {
var column_name string
var column_default string
err = rows.Scan(&column_name, &column_default)
if err != nil {
html += err.Error()
println(1, err.Error())
return
}
rows.Scan(&column_name, &column_default)
column_default_int, _ := strconv.Atoi(column_default)
column_default_bool := (column_default_int == 1)
println(1, "Got this far...")
switch column_name {
case "id":
board.ID = column_default_int
@ -745,7 +744,6 @@ var manage_functions = map[string]ManageFunction{
case "enable_catalog":
board.EnableCatalog = column_default_bool
}
println(1, "Done with the switch")
}
}

View file

@ -822,6 +822,7 @@ func createImageThumbnail(image_obj image.Image, size string) image.Image {
func createVideoThumbnail(video, thumb string, size int) error {
sizeStr := strconv.Itoa(size)
outputBytes, err := exec.Command("ffmpeg", "-y", "-itsoffset", "-1", "-i", video, "-vframes", "1", "-filter:v", "scale='min("+sizeStr+"\\, "+sizeStr+"):-1'", thumb).CombinedOutput()
println(2, "ffmpeg output: \n"+string(outputBytes))
if err != nil {
outputStringArr := strings.Split(string(outputBytes), "\n")
if len(outputStringArr) > 1 {

View file

@ -497,7 +497,7 @@ func initConfig() {
}
if config.DBtype == "" {
println(0, "DBtype not set in gochan.json, halting.")
println(0, "DBtype not set in gochan.json, halting (currently supported values: mysql).")
os.Exit(2)
}
@ -548,7 +548,10 @@ func initConfig() {
}
if config.DomainRegex == "" {
config.DomainRegex = "(https|http):\\/\\/(" + config.SiteDomain + ")\\/(.*)"
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_img == nil {