Rev 229 Rev 237
1 <?php 1 <?php
2   2  
3 /** 3 /**
4 * Contains functions used during the uninstall process. 4 * Contains functions used during the uninstall process.
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.inc.php,v 1.1 2004/12/02 12:01:59 tamlyn Exp $ 9 * @version $Id: uninstall.inc.php,v 1.1 2004/12/02 12:01:59 tamlyn Exp $
10 */ 10 */
11   11  
12 /** 12 /**
13 * Recursively attempts to make all files and directories in $dir writable 13 * Recursively attempts to make all files and directories in $dir writable
14 * 14 *
15 * @param string full directory name (must end with /) 15 * @param string full directory name (must end with /)
16 */ 16 */
17 function makeWritable($dir) 17 function makeWritable($dir)
18 { 18 {
19 if (is_dir($dir)) { 19 if (is_dir($dir)) {
20 $d = dir($dir); 20 $d = dir($dir);
21 while (($file = $d->read()) !== false) { 21 while (($file = $d->read()) !== false) {
22 if ($file == '.' || $file == '..') continue; 22 if ($file == '.' || $file == '..') continue;
23 $fullfile = $d->path . $file; 23 $fullfile = $d->path . $file;
24 if(!is_writable($fullfile) && @chmod($fullfile,0777)) 24 if(!is_writable($fullfile) && @chmod($fullfile,0777))
25 setupMessage("Made $fullfile writable"); 25 setupMessage("Made $fullfile writable");
26 if (is_dir($fullfile)) 26 if (is_dir($fullfile))
27 makeWritable($fullfile."/"); 27 makeWritable($fullfile."/");
28 } 28 }
29 } 29 }
30 } 30 }
31   31  
32   32  
33 /** 33 /**
34 * Drops all tables created by singapore. 34 * Drops all tables created by singapore.
35 * @param sgIO_sql pointer to a singapore SQL backend object 35 * @param sgIO_sql pointer to a singapore SQL backend object
36 */ 36 */
37 function sqlDropTables($io) { 37 function sqlDropTables($io) {
38 $success = true; 38 $success = true;
39 setupHeader("Deleting tables"); 39 setupHeader("Deleting tables");
40 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."galleries")) 40 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."galleries"))
41 setupMessage("'".$io->config->sql_prefix."galleries' table not found - skipped"); 41 setupMessage("'".$io->config->sql_prefix."galleries' table not found - skipped");
42 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."galleries")) 42 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."galleries"))
43 setupMessage("'".$io->config->sql_prefix."galleries' table deleted"); 43 setupMessage("'".$io->config->sql_prefix."galleries' table deleted");
44 else 44 else
45 $success = setupError("Unable to delete '".$io->config->sql_prefix."galleries' table:".$io->error()); 45 $success = setupError("Unable to delete '".$io->config->sql_prefix."galleries' table:".$io->error());
46 46
47 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."images")) 47 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."images"))
48 setupMessage("'".$io->config->sql_prefix."images' table not found - skipped"); 48 setupMessage("'".$io->config->sql_prefix."images' table not found - skipped");
49 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."images")) 49 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."images"))
50 setupMessage("'".$io->config->sql_prefix."images' table deleted"); 50 setupMessage("'".$io->config->sql_prefix."images' table deleted");
51 else 51 else
52 $success = setupError("Unable to delete '".$io->config->sql_prefix."images' table:".$io->error()); 52 $success = setupError("Unable to delete '".$io->config->sql_prefix."images' table:".$io->error());
53 53
54 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."users")) 54 if(!$io->query("SELECT * FROM ".$io->config->sql_prefix."users"))
55 setupMessage("'".$io->config->sql_prefix."users' table not found - skipped"); 55 setupMessage("'".$io->config->sql_prefix."users' table not found - skipped");
56 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."users")) 56 elseif($io->query("DROP TABLE ".$io->config->sql_prefix."users"))
57 setupMessage("'".$io->config->sql_prefix."users' table deleted"); 57 setupMessage("'".$io->config->sql_prefix."users' table deleted");
58 else 58 else
59 $success = setupError("Unable to delete '".$io->config->sql_prefix."users' table:".$io->error()); 59 $success = setupError("Unable to delete '".$io->config->sql_prefix."users' table:".$io->error());
60 60
61 return $success; 61 return $success;
62 } 62 }
63   63  
64   64  
65 //output functions 65 //output functions
66 function setupHeader($var) 66 function setupHeader($var)
67 { 67 {
68 echo "\n</p>\n\n<h2>{$var}</h2>\n\n<p>\n"; 68 echo "\n</p>\n\n<h2>{$var}</h2>\n\n<p>\n";
69 } 69 }
70   70  
71 /** 71 /**
72 * Print an information message. Always returns true. 72 * Print an information message. Always returns true.
73 * @return true 73 * @return true
74 */ 74 */
75 function setupMessage($var) 75 function setupMessage($var)
76 { 76 {
77 echo "{$var}.<br />\n"; 77 echo "{$var}.<br />\n";
78 return true; 78 return true;
79 } 79 }
80   80  
81 /** 81 /**
82 * Print an error message. Always returns false. 82 * Print an error message. Always returns false.
83 * @return false 83 * @return false
84 */ 84 */
85 function setupError($var) 85 function setupError($var)
86 { 86 {
87 echo "<span class=\"error\">{$var}</span>.<br />\n"; 87 echo "<span class=\"error\">{$var}</span>.<br />\n";
88 return false; 88 return false;
89 } 89 }
90   90  
91 ?> 91 ?>