last minute modifications (2.2.0 release)
[phpns.git] / etc.php
blob596bda5935b92d85a8830535eeef25c68ad67d97
1 <?php
3 /* Copyright (c) 2007-08 Alec Henriksen
4 * phpns is free software; you can redistribute it and/or modify it under the
5 * terms of the GNU General Public Licence (GPL) as published by the Free
6 * Software Foundation; either version 2 of the Licence, or (at your option) any
7 * later version.
8 * Please see the GPL at http://www.gnu.org/copyleft/gpl.html for a complete
9 * understanding of what this license means and how to abide by it.
11 include("inc/init.php");
13 include("inc/header.php");
14 $do = $_GET['do'];
15 $return_to = $_GET['return'];
17 if ($do == "backup") { //send backup file to user, header info
18 $file = $databaseinfo['dbname'].'.sql'; //the current dump
19 if (@file_exists($file)) { //get size
20 $size = filesize($file);
22 //send metadata
23 header('Content-Type: application/text');
24 header('Content-Length: '.$size.'');
25 header('Content-disposition: attachment; filename='.$file.'');
26 readfile($file);
27 log_this('backup_download','User <i>'.$_SESSION['username'].'</i> has <strong>downloaded</strong> the system database.');
28 } else {
29 header("Location: preferences.php?do=backup&success=no");
31 } elseif ($do == "rss") { //if it's the system-wide phpns
33 $phpns['mode'] = 'rss';
34 include('shownews.php');
36 } elseif ($do == "news") {
38 //include news for this part of etc.php
39 include("shownews.php");
41 } elseif ($do == "delete_backup") {
43 //attempt to delete sql file
44 @unlink($databaseinfo['dbname'].'.sql');
46 //log
47 log_this('delete_backup','User <i>'.$_SESSION['username'].'</i> has <strong>attempted (successful or not) to delete</strong> the database backup.');
49 //redirect back to page.
50 header("Location: $return_to");
52 } elseif ($do == "delete_install") {
53 //attempt to delete install directory
54 @unlink('install/index.php');
55 @unlink('install/install.inc.php');
56 @unlink('install/install.tmp.php');
57 @unlink('install/upgrade.php');
58 if(@rmdir('install/'))
60 log_this('delete_install','User <i>'.$_SESSION['username'].'</i> has <strong>successfully deleted</strong> the install directory.');;
61 }else{
62 log_this('delete_install','User <i>'.$_SESSION['username'].'</i> has <strong>failed at deleting</strong> the install directory.');
64 header("Location: $return_to");
66 } elseif ($do == "hide_warnings") {
67 //set session var, and redirect to index. If TRUE, all warning messages at the top will be hidden.
68 $_SESSION['hide_sessions'] = TRUE;
69 header("Location: $return_to");
71 } elseif ($globalvars['debug'] == "yes" && $do == "phpinfo") {
72 phpinfo();
73 } else {
74 echo 'Bad $do ('.$do.'), could not find associated action.';
77 if ($do == NULL) {
78 echo "This file is only for special tasks that can't be done on other pages. Go away now. =D";
79 die();