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,21 +43,30 @@ class AdminPage extends Extension {
 | 
				
			|||||||
		if(is_a($event, 'PageRequestEvent') && ($event->page_name == "admin_utils")) {
 | 
							if(is_a($event, 'PageRequestEvent') && ($event->page_name == "admin_utils")) {
 | 
				
			||||||
			if($event->user->is_admin()) {
 | 
								if($event->user->is_admin()) {
 | 
				
			||||||
				set_time_limit(0);
 | 
									set_time_limit(0);
 | 
				
			||||||
 | 
									$redirect = false;
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
				switch($_POST['action']) {
 | 
									switch($_POST['action']) {
 | 
				
			||||||
					case 'lowercase all tags':
 | 
										case 'lowercase all tags':
 | 
				
			||||||
						$this->lowercase_all_tags();
 | 
											$this->lowercase_all_tags();
 | 
				
			||||||
 | 
											$redirect = true;
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
					case 'recount tag use':
 | 
										case 'recount tag use':
 | 
				
			||||||
						$this->recount_tag_use();
 | 
											$this->recount_tag_use();
 | 
				
			||||||
 | 
											$redirect = true;
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
					case 'purge unused tags':
 | 
										case 'purge unused tags':
 | 
				
			||||||
						$this->purge_unused_tags();
 | 
											$this->purge_unused_tags();
 | 
				
			||||||
 | 
											$redirect = true;
 | 
				
			||||||
 | 
											break;
 | 
				
			||||||
 | 
										case 'database dump':
 | 
				
			||||||
 | 
											$this->dbdump($event->page);
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				$event->page->set_mode("redirect");
 | 
									if($redirect) {
 | 
				
			||||||
				$event->page->set_redirect(make_link("admin"));
 | 
										$event->page->set_mode("redirect");
 | 
				
			||||||
 | 
										$event->page->set_redirect(make_link("admin"));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -96,6 +105,29 @@ class AdminPage extends Extension {
 | 
				
			|||||||
		$database->Execute("DELETE FROM tags WHERE count=0");
 | 
							$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() {
 | 
						private function check_for_orphanned_images() {
 | 
				
			||||||
		$orphans = array();
 | 
							$orphans = array();
 | 
				
			||||||
		foreach(glob("images/*") as $dir) {
 | 
							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='lowercase all tags'>All tags to lowercase</option>
 | 
				
			||||||
					<option value='recount tag use'>Recount tag use</option>
 | 
										<option value='recount tag use'>Recount tag use</option>
 | 
				
			||||||
					<option value='purge unused tags'>Purge unused tags</option>
 | 
										<option value='purge unused tags'>Purge unused tags</option>
 | 
				
			||||||
 | 
										<option value='database dump'>Download database contents</option>
 | 
				
			||||||
				</select>
 | 
									</select>
 | 
				
			||||||
				<input type='submit' value='Go'>
 | 
									<input type='submit' value='Go'>
 | 
				
			||||||
			</form>
 | 
								</form>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user