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