diff options
Diffstat (limited to 'cgi/manage.py')
-rw-r--r-- | cgi/manage.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/cgi/manage.py b/cgi/manage.py index 71ed647..9ac2006 100644 --- a/cgi/manage.py +++ b/cgi/manage.py @@ -775,8 +775,8 @@ def manage(self, path_split): board['anonymous'] = self.formdata['anonymous'] board['subject'] = self.formdata['subject'] board['message'] = self.formdata['message'] - if board['dir'] != 'anarkia': - board['board_type'] = self.formdata['type'] + switchBoard(self.formdata['type']) + board['board_type'] = self.formdata['type'] board['useid'] = self.formdata['useid'] board['slip'] = self.formdata['slip'] board['countrycode'] = self.formdata['countrycode'] @@ -1828,6 +1828,36 @@ def manage(self, path_split): }) self.output += renderTemplate("manage/" + template_filename, template_values) + +def switchBoard(new_type): + board = Settings._.BOARD + + if new_type == board['board_type']: + return + + kako_dir = os.path.join(Settings.ROOT_DIR, board['dir'], 'kako') + + if new_type == '0': + # Switching to Imageboard + old_res_dir = os.path.join(Settings.ROOT_DIR, board['dir'], 'read') + new_res_dir = os.path.join(Settings.ROOT_DIR, board['dir'], 'res') + + # Delete kako if empty + if os.path.exists(kako_dir) and not os.listdir(kako_dir): + os.rmdir(kako_dir) + elif new_type == '1': + # Switching to Textboard + old_res_dir = os.path.join(Settings.ROOT_DIR, board['dir'], 'res') + new_res_dir = os.path.join(Settings.ROOT_DIR, board['dir'], 'read') + + # Make kako dir + if not os.path.exists(kako_dir): + os.mkdir(kako_dir) + + os.rename(old_res_dir, new_res_dir) + + # Clean res dir + cleanDir(new_res_dir, ext="html") def logAction(staff, action): InsertDb("INSERT INTO `logs` (`timestamp`, `staff`, `action`) VALUES (" + str(timestamp()) + ", '" + _mysql.escape_string(staff) + "\', \'" + _mysql.escape_string(action) + "\')") |