<?php

/*
 * Use it only if in your database annotation stored as html code. Copy this
 * file to Kotoba root directory and execute via browser. Do not forget remove
 * it after apply.
 */
require "config.php";
require_once Config::ABS_PATH . '/lib/exceptions.php';
require_once Config::ABS_PATH . '/lib/errors.php';
require Config::ABS_PATH . '/locale/' . Config::LANGUAGE . '/exceptions.php';
require_once Config::ABS_PATH . '/lib/db.php';
$boards = boards_get_all();
foreach ($boards as $board) {
    boards_edit($board['id'], $board['title'], htmlentities($board['annotation'], ENT_QUOTES, Config::MB_ENCODING), $board['bump_limit'], $board['force_anonymous'], $board['default_name'], $board['with_attachments'], $board['enable_macro'], $board['enable_youtube'], $board['enable_captcha'], $board['same_upload'], $board['popdown_handler'], $board['category']);
}
echo 'Done.';
                 //echo "popdown_handler changed<br>\n";
             }
         }
         // Is board category was changed?
         if (isset($_POST["category_{$board['id']}"])) {
             $new_board['category'] = categories_check_id($_POST["category_{$board['id']}"]);
             if ($new_board['category'] != $board['category']) {
                 $changed = true;
                 //echo "category changed<br>\n";
             }
         }
         // Is something was changed?
         if ($changed) {
             $new_board['id'] = $board['id'];
             //echo "edit {$board['name']}<br>\n";
             boards_edit($new_board);
             $reload_boards = true;
         }
     }
     // Change parameters of existing boards.
     // Delete selected boards.
     foreach ($boards as $board) {
         if (isset($_POST["delete_{$board['id']}"])) {
             //echo "delete {$board['name']}<br>\n";
             boards_delete($board['id']);
             $reload_boards = true;
         }
     }
 }
 if ($reload_boards) {
     $boards = boards_get_all();