database content download button
git-svn-id: file:///home/shish/svn/shimmie2/trunk@877 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
97b7deb1da
commit
c74bcaf121
@ -43,23 +43,32 @@ class AdminPage extends Extension {
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "admin_utils")) {
|
||||
if($event->user->is_admin()) {
|
||||
set_time_limit(0);
|
||||
$redirect = false;
|
||||
|
||||
switch($_POST['action']) {
|
||||
case 'lowercase all tags':
|
||||
$this->lowercase_all_tags();
|
||||
$redirect = true;
|
||||
break;
|
||||
case 'recount tag use':
|
||||
$this->recount_tag_use();
|
||||
$redirect = true;
|
||||
break;
|
||||
case 'purge unused tags':
|
||||
$this->purge_unused_tags();
|
||||
$redirect = true;
|
||||
break;
|
||||
case 'database dump':
|
||||
$this->dbdump($event->page);
|
||||
break;
|
||||
}
|
||||
|
||||
if($redirect) {
|
||||
$event->page->set_mode("redirect");
|
||||
$event->page->set_redirect(make_link("admin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent')) {
|
||||
global $user;
|
||||
@ -96,6 +105,29 @@ class AdminPage extends Extension {
|
||||
$database->Execute("DELETE FROM tags WHERE count=0");
|
||||
}
|
||||
|
||||
private function dbdump($page) {
|
||||
include "config.php";
|
||||
|
||||
$matches = array();
|
||||
preg_match("#(\w+)://(\w+):(\w+)@([\w\.\-]+)/([\w_]+)(\?.*)?#", $database_dsn, $matches);
|
||||
$software = $matches[1];
|
||||
$username = $matches[2];
|
||||
$password = $matches[3];
|
||||
$hostname = $matches[4];
|
||||
$database = $matches[5];
|
||||
|
||||
switch($software) {
|
||||
case 'mysql':
|
||||
$cmd = "mysqldump -h$hostname -u$username -p$password $database";
|
||||
break;
|
||||
}
|
||||
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/x-unknown");
|
||||
$page->set_filename('shimmie-'.date('Ymd').'.sql');
|
||||
$page->set_data(shell_exec($cmd));
|
||||
}
|
||||
|
||||
private function check_for_orphanned_images() {
|
||||
$orphans = array();
|
||||
foreach(glob("images/*") as $dir) {
|
||||
|
@ -39,6 +39,7 @@ class AdminPageTheme extends Themelet {
|
||||
<option value='lowercase all tags'>All tags to lowercase</option>
|
||||
<option value='recount tag use'>Recount tag use</option>
|
||||
<option value='purge unused tags'>Purge unused tags</option>
|
||||
<option value='database dump'>Download database contents</option>
|
||||
</select>
|
||||
<input type='submit' value='Go'>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user