"Tagging Backup Plugin!",
"description" => "It backup post tags, created with Tagging Plugin!, in a .sql file, it is useful for upgrading with releases which bundles some table layout changes",
"author" => "flash.tato",
"authorsite" => "",
"version" => "1.0",
"compatibility" => "14*"
);
}
$plugins->add_hook("admin_tools_menu", "tagging_backup_admin_menu");
$plugins->add_hook("admin_tools_backupdb_begin", "tagging_backup_admin_page");
function tagging_backup_admin_menu($sub_menu)
{
$sub_menu['11'] = array("id" => "tagging_backup", "title" => "Tagging Backup", "link" => "index.php?module=tools/backupdb&action=tagging_backup");
}
function tagging_backup_admin_page()
{
global $page, $mybb, $db;
if($mybb->input['action'] == "tagging_backup")
{
$page->add_breadcrumb_item("Tagging Backup");
$page->output_header("Tagging Backup");
$table = new Table();
$table->construct_cell("Here you can backup the tags in a .sql file which you can use via phpMyAdmin.
It is useful in case you need to ugprade to a version which makes some database layout changes.");
$table->construct_row();
$table->output("Backup post tags");
if(!is_writable(MYBB_ADMIN_DIR."/backups"))
{
$page->output_alert($lang->alert_not_writable);
$cannot_write = true;
}
elseif(isset($mybb->input['submit']) && !$cannot_write)
{
set_time_limit(0);
$file = MYBB_ADMIN_DIR.'backups/tag_backup_'.substr(md5($mybb->user['uid'].TIME_NOW), 0, 10).random_str(12).'.sql';
$query = $db->simple_select("posts", "pid, tags", "tags != ''");
if($db->num_rows($query))
{
$fp = fopen($file, 'w');
while($post = $db->fetch_array($query))
{
fwrite($fp, "UPDATE {$db->table_prefix}posts SET tags='" . $db->escape_string($post['tags']) . "' WHERE pid='{$post['pid']}';\n");
}
fclose($fp);
$page->output_success("Backup is stored in {$file}");
}
}
$form = new Form("index.php?module=tools/backupdb&action=tagging_backup", "POST");
$buttons[] = $form->generate_submit_button("Backup post tags", array('name' => 'submit'));
$form->output_submit_wrapper($buttons);
$form->end();
$page->output_footer();
}
}
?>