Rev 228 Rev 229
1 <?php 1 <?php
2   2  
3 /** 3 /**
4 * Performs necessary actions to uninstall singapore. 4 * Performs necessary actions to uninstall singapore.
5 * 5 *
6 * @author Tamlyn Rhodes <tam at zenology dot co dot uk> 6 * @author Tamlyn Rhodes <tam at zenology dot co dot uk>
7 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License 7 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
8 * @copyright (c)2003, 2004 Tamlyn Rhodes 8 * @copyright (c)2003, 2004 Tamlyn Rhodes
9 * @version $Id: uninstall.php,v 1.3 2006/01/20 12:31:08 tamlyn Exp $ 9 * @version $Id: uninstall.php,v 1.3 2006/01/20 12:31:08 tamlyn Exp $
10 */ 10 */
11   11  
12 //path to singapore root 12 //path to singapore root
13 $basePath = "../"; 13 $basePath = "../";
14   14  
15 require_once "uninstall.inc.php"; 15 require_once "uninstall.inc.php";
16 require_once $basePath."includes/config.class.php"; 16 require_once $basePath."includes/config.class.php";
17   17  
18 //determine current step in setup process 18 //determine current step in setup process
19 $setupStep = isset($_REQUEST["step"]) ? $_REQUEST["step"] : "reset"; 19 $setupStep = isset($_REQUEST["step"]) ? $_REQUEST["step"] : "reset";
20   20  
21 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 21 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
22 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 22 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23   23  
24 <html xmlns="http://www.w3.org/1999/xhtml"> 24 <html xmlns="http://www.w3.org/1999/xhtml">
25 <head> 25 <head>
26 <title>singapore setdown</title> 26 <title>singapore setdown</title>
27 <link rel="stylesheet" type="text/css" href="../docs/docstyle.css" /> 27 <link rel="stylesheet" type="text/css" href="../docs/docstyle.css" />
28 </head> 28 </head>
29   29  
30 <body> 30 <body>
31   31  
32 <?php 32 <?php
33   33  
34 switch($setupStep) { 34 switch($setupStep) {
35 case "reset" : 35 case "reset" :
36 setupHeader("Step 1 of 2: Reset permissions"); 36 setupHeader("Step 1 of 2: Reset permissions");
37 setupMessage("Resetting file permissions on server-generated content"); 37 setupMessage("Resetting file permissions on server-generated content");
38 setupMessage("Nothing is deleted at this time"); 38 setupMessage("Nothing is deleted at this time");
39 39
40 makeWritable($basePath); 40 makeWritable($basePath);
41 setupHeader("OK"); 41 setupHeader("OK");
42 setupMessage("This step completed successfully"); 42 setupMessage("This step completed successfully");
43 setupHeader("WARNING!"); 43 setupHeader("WARNING!");
44 setupMessage("The following step will delete all gallery, image and user information from the currently selected database. Gallery directories and image files will not be deleted but all extended information (e.g. name, artist, copyright etc.) will be irretrievably lost"); 44 setupMessage("The following step will delete all gallery, image and user information from the currently selected database. Gallery directories and image files will not be deleted but all extended information (e.g. name, artist, copyright etc.) will be irretrievably lost");
45 echo '<br /><a href="index.html">Finish</a>'; 45 echo '<br /><a href="index.html">Finish</a>';
46 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>'; 46 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>';
47 break; 47 break;
48 48
49 case "database" : 49 case "database" :
50 setupHeader("Step 2 of 2: Delete database information"); 50 setupHeader("Step 2 of 2: Delete database information");
51 51
52 //create config object 52 //create config object
53 $config =& sgConfig::getInstance(); 53 $config =& sgConfig::getInstance();
54 $config->loadConfig($basePath."singapore.ini"); 54 $config->loadConfig($basePath."singapore.ini");
55 $config->base_path = $basePath; 55 $config->base_path = $basePath;
56 56
57 switch($config->io_handler) { 57 switch($config->io_handler) {
58 case "csv" : 58 case "csv" :
59 setupMessage("The default CSV file database does not require uninstalling"); 59 setupMessage("The default CSV file database does not require uninstalling");
60 setupHeader("OK"); 60 setupHeader("OK");
61 setupMessage("This step completed successfully"); 61 setupMessage("This step completed successfully");
62 break; 62 break;
63 63
64 case "mysql" : 64 case "mysql" :
65 $config->loadConfig($basePath."secret.ini.php"); 65 $config->loadConfig($basePath."secret.ini.php");
66 include_once $basePath."includes/io_mysql.class.php"; 66 include_once $basePath."includes/io_mysql.class.php";
67 setupMessage("Setup will now delete all gallery, image and user information"); 67 setupMessage("Setup will now delete all gallery, image and user information");
68 setupHeader("Connecting to MySQL database"); 68 setupHeader("Connecting to MySQL database");
69 $io = new sgIO_mysql($config); 69 $io = new sgIO_mysql($config);
70 if(!$io) { 70 if(!$io) {
71 setupError("Error connecting to database. Please ensure database settings are correct"); 71 setupError("Error connecting to database. Please ensure database settings are correct");
72 break; 72 break;
73 } else setupMessage("Connected"); 73 } else setupMessage("Connected");
74 if(sqlDropTables($io)) { 74 if(sqlDropTables($io)) {
75 setupHeader("OK"); 75 setupHeader("OK");
76 setupMessage("This step completed successfully"); 76 setupMessage("This step completed successfully");
77 } else { 77 } else {
78 setupHeader("Oops!"); 78 setupHeader("Oops!");
79 setupError('There was a problem. Please fix it and <a href="uninstall.php?step=database">retry this step</a>'); 79 setupError('There was a problem. Please fix it and <a href="uninstall.php?step=database">retry this step</a>');
80 } 80 }
81 break; 81 break;
82 82
83 case "sqlite" : 83 case "sqlite" :
84 $config->loadConfig($basePath."secret.ini.php"); 84 $config->loadConfig($basePath."secret.ini.php");
85 setupMessage("Setup will now delete all gallery, image and user information"); 85 setupMessage("Setup will now delete all gallery, image and user information");
86 setupHeader("Deleting SQLite database file"); 86 setupHeader("Deleting SQLite database file");
87 if(unlink($basePath.$config->pathto_data_dir."sqlite.dat")) { 87 if(unlink($basePath.$config->pathto_data_dir."sqlite.dat")) {
88 setupMessage("Deleted database file '".$basePath.$config->pathto_data_dir."sqlite.dat'"); 88 setupMessage("Deleted database file '".$basePath.$config->pathto_data_dir."sqlite.dat'");
89 setupHeader("OK"); 89 setupHeader("OK");
90 setupMessage("This step completed successfully"); 90 setupMessage("This step completed successfully");
91 } else { 91 } else {
92 setupError("Unable to delete database file '".$basePath.$config->pathto_data_dir."sqlite.dat'"); 92 setupError("Unable to delete database file '".$basePath.$config->pathto_data_dir."sqlite.dat'");
93 setupHeader("Oops!"); 93 setupHeader("Oops!");
94 setupError('There was a problem. Please fix it and <a href="uninstall.php?step=database">retry this step</a>'); 94 setupError('There was a problem. Please fix it and <a href="uninstall.php?step=database">retry this step</a>');
95 } 95 }
96 break; 96 break;
97 default : 97 default :
98 setupError("Unrecognised io_handler"); 98 setupError("Unrecognised io_handler");
99 } 99 }
100 echo '<br /><a href="uninstall.php?step=reset">&lt;&lt; Previous: Reset permissions</a>'; 100 echo '<br /><a href="uninstall.php?step=reset">&lt;&lt; Previous: Reset permissions</a>';
101 echo ' | <a href="index.html">Finish</a>'; 101 echo ' | <a href="index.html">Finish</a>';
102 break; 102 break;
103 } 103 }
104 ?> 104 ?>
105   105  
106 </body> 106 </body>
107 </html> 107 </html>