Rev 228 Rev 229
1 <?php 1 <?php
2   2  
3 //permissions bit flags 3 //permissions bit flags
4 define("SG_GRP_READ", 1); 4 define("SG_GRP_READ", 1);
5 define("SG_GRP_EDIT", 2); 5 define("SG_GRP_EDIT", 2);
6 define("SG_GRP_ADD", 4); 6 define("SG_GRP_ADD", 4);
7 define("SG_GRP_DELETE", 8); 7 define("SG_GRP_DELETE", 8);
8 define("SG_WLD_READ", 16); 8 define("SG_WLD_READ", 16);
9 define("SG_WLD_EDIT", 32); 9 define("SG_WLD_EDIT", 32);
10 define("SG_WLD_ADD", 64); 10 define("SG_WLD_ADD", 64);
11 define("SG_WLD_DELETE", 128); 11 define("SG_WLD_DELETE", 128);
12   12  
13 $basePath = "../"; 13 $basePath = "../";
14   14  
15 //determine current step in setup process 15 //determine current step in setup process
16 $setupStep = isset($_REQUEST["step"]) ? $_REQUEST["step"] : "choose"; 16 $setupStep = isset($_REQUEST["step"]) ? $_REQUEST["step"] : "choose";
17   17  
18 ?> 18 ?>
19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
20 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 20 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
21   21  
22 <html xmlns="http://www.w3.org/1999/xhtml"> 22 <html xmlns="http://www.w3.org/1999/xhtml">
23 <head> 23 <head>
24 <title>singapore database migration</title> 24 <title>singapore database migration</title>
25 <link rel="stylesheet" type="text/css" href="../docs/docstyle.css" /> 25 <link rel="stylesheet" type="text/css" href="../docs/docstyle.css" />
26 </head> 26 </head>
27   27  
28 <body> 28 <body>
29   29  
30 <?php 30 <?php
31   31  
32 require_once $basePath."includes/config.class.php"; 32 require_once $basePath."includes/config.class.php";
33 require_once $basePath."includes/gallery.class.php"; 33 require_once $basePath."includes/gallery.class.php";
34 require_once $basePath."includes/image.class.php"; 34 require_once $basePath."includes/image.class.php";
35 $config = new sgConfig($basePath."singapore.ini"); 35 $config = new sgConfig($basePath."singapore.ini");
36   36  
37   37  
38 switch($setupStep) { 38 switch($setupStep) {
39 case "select" : 39 case "select" :
40 setupHeader("Step 1 of 2: Select databases"); 40 setupHeader("Step 1 of 2: Select databases");
41 setupMessage("Nothing is deleted at this time"); 41 setupMessage("Nothing is deleted at this time");
42 42
43 makeWritable($basePath); 43 makeWritable($basePath);
44 setupHeader("OK"); 44 setupHeader("OK");
45 setupMessage("This step completed successfully"); 45 setupMessage("This step completed successfully");
46 setupHeader("WARNING!"); 46 setupHeader("WARNING!");
47 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"); 47 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");
48 echo '<br /><a href="index.html">Finish</a>'; 48 echo '<br /><a href="index.html">Finish</a>';
49 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>'; 49 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>';
50 break; 50 break;
51 51
52 case "defaults" : 52 case "defaults" :
53 setupHeader("Step 2 of 3: Select default permissions"); 53 setupHeader("Step 2 of 3: Select default permissions");
54 setupMessage("Nothing is deleted at this time"); 54 setupMessage("Nothing is deleted at this time");
55 55
56 makeWritable($basePath); 56 makeWritable($basePath);
57 setupHeader("OK"); 57 setupHeader("OK");
58 setupMessage("This step completed successfully"); 58 setupMessage("This step completed successfully");
59 setupHeader("WARNING!"); 59 setupHeader("WARNING!");
60 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"); 60 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");
61 echo '<br /><a href="index.html">Finish</a>'; 61 echo '<br /><a href="index.html">Finish</a>';
62 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>'; 62 echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information &gt;&gt;</a>';
63 break; 63 break;
64 64
65 case "convert" : 65 case "convert" :
66 setupHeader("Step 2 of 2: Delete database information"); 66 setupHeader("Step 2 of 2: Delete database information");
67 67
68 //create config object 68 //create config object
69 $config = new sgConfig($basePath."singapore.ini"); 69 $config = new sgConfig($basePath."singapore.ini");
70 $config->loadConfig($basePath."secret.ini.php"); 70 $config->loadConfig($basePath."secret.ini.php");
71 $config->base_path = $basePath; 71 $config->base_path = $basePath;
72 //include base classes 72 //include base classes
73 require_once $basePath."includes/io.class.php"; 73 require_once $basePath."includes/io.class.php";
74 require_once $basePath."includes/io_sql.class.php"; 74 require_once $basePath."includes/io_sql.class.php";
75 75
76 switch($config->io_handler) { 76 switch($config->io_handler) {
77 case "csv" : 77 case "csv" :
78 setupMessage("The default CSV file database does not require uninstalling"); 78 setupMessage("The default CSV file database does not require uninstalling");
79 setupHeader("OK"); 79 setupHeader("OK");
80 setupMessage("This step completed successfully"); 80 setupMessage("This step completed successfully");
81 break; 81 break;
82 82
83 case "mysql" : 83 case "mysql" :
84 require_once $basePath."includes/io_mysql.class.php"; 84 require_once $basePath."includes/io_mysql.class.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("Connecting to MySQL database"); 86 setupHeader("Connecting to MySQL database");
87 $io = new sgIO_mysql($config); 87 $io = new sgIO_mysql($config);
88 if(!$io) { 88 if(!$io) {
89 setupError("Error connecting to database. Please ensure database settings are correct"); 89 setupError("Error connecting to database. Please ensure database settings are correct");
90 break; 90 break;
91 } else setupMessage("Connected"); 91 } else setupMessage("Connected");
92 if(sqlDropTables($io)) { 92 if(sqlDropTables($io)) {
93 setupHeader("OK"); 93 setupHeader("OK");
94 setupMessage("This step completed successfully"); 94 setupMessage("This step completed successfully");
95 } else { 95 } else {
96 setupHeader("Oops!"); 96 setupHeader("Oops!");
97 setupError('There was a problem. Please fix it and <a href="migrate.php?step=database">retry this step</a>'); 97 setupError('There was a problem. Please fix it and <a href="migrate.php?step=database">retry this step</a>');
98 } 98 }
99 break; 99 break;
100 100
101 case "sqlite" : 101 case "sqlite" :
102 setupMessage("Setup will now delete all gallery, image and user information"); 102 setupMessage("Setup will now delete all gallery, image and user information");
103 setupHeader("Deleting SQLite database file"); 103 setupHeader("Deleting SQLite database file");
104 if(unlink($basePath.$config->pathto_data_dir."sqlite.dat")) { 104 if(unlink($basePath.$config->pathto_data_dir."sqlite.dat")) {
105 setupMessage("Deleted database file '".$basePath.$config->pathto_data_dir."sqlite.dat'"); 105 setupMessage("Deleted database file '".$basePath.$config->pathto_data_dir."sqlite.dat'");
106 setupHeader("OK"); 106 setupHeader("OK");
107 setupMessage("This step completed successfully"); 107 setupMessage("This step completed successfully");
108 } else { 108 } else {
109 setupError("Unable to delete database file '".$basePath.$config->pathto_data_dir."sqlite.dat'"); 109 setupError("Unable to delete database file '".$basePath.$config->pathto_data_dir."sqlite.dat'");
110 setupHeader("Oops!"); 110 setupHeader("Oops!");
111 setupError('There was a problem. Please fix it and <a href="migrate.php?step=database">retry this step</a>'); 111 setupError('There was a problem. Please fix it and <a href="migrate.php?step=database">retry this step</a>');
112 } 112 }
113 break; 113 break;
114 default : 114 default :
115 setupError("Unrecognised io_handler"); 115 setupError("Unrecognised io_handler");
116 } 116 }
117 echo '<br /><a href="uninstall.php?step=reset">&lt;&lt; Previous: Reset permissions</a>'; 117 echo '<br /><a href="uninstall.php?step=reset">&lt;&lt; Previous: Reset permissions</a>';
118 echo ' | <a href="index.html">Finish</a>'; 118 echo ' | <a href="index.html">Finish</a>';
119 break; 119 break;
120 } 120 }
121   121  
122 if(isset($_REQUEST["convertType"])) { 122 if(isset($_REQUEST["convertType"])) {
123   123  
124 require_once $basePath."includes/config.class.php"; 124 require_once $basePath."includes/config.class.php";
125 require_once $basePath."includes/gallery.class.php"; 125 require_once $basePath."includes/gallery.class.php";
126 require_once $basePath."includes/image.class.php"; 126 require_once $basePath."includes/image.class.php";
127 require_once $basePath."includes/io.class.php"; 127 require_once $basePath."includes/io.class.php";
128 require_once $basePath."includes/io_sql.class.php"; 128 require_once $basePath."includes/io_sql.class.php";
129 $config = new sgConfig($basePath."singapore.ini"); 129 $config = new sgConfig($basePath."singapore.ini");
130 130
131 $config->base_path = $basePath; 131 $config->base_path = $basePath;
132 132
133 //echo "<ul>\n"; 133 //echo "<ul>\n";
134 convertDirectory($config->base_path.$config->pathto_galleries); 134 convertDirectory($config->base_path.$config->pathto_galleries);
135 //echo "</ul>\n"; 135 //echo "</ul>\n";
136 136
137 echo "<p>All operations complete.</p>\n"; 137 echo "<p>All operations complete.</p>\n";
138   138  
139 } else { ?> 139 } else { ?>
140 <p>This will convert all your metadata files from singapore 0.9.6, 0.9.7, 0.9.8 or 0.9.9 to 0.9.10.</p> 140 <p>This will convert all your metadata files from singapore 0.9.6, 0.9.7, 0.9.8 or 0.9.9 to 0.9.10.</p>
141   141  
142 <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>"> 142 <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
143 <h3>summary field</h3> 143 <h3>summary field</h3>
144 <p>There is a new gallery summary field that is displayed instead of the 144 <p>There is a new gallery summary field that is displayed instead of the
145 description in the parent gallery. You can choose to either copy or move the 145 description in the parent gallery. You can choose to either copy or move the
146 old description field to the summary field or leave both untouched:</p> 146 old description field to the summary field or leave both untouched:</p>
147   147  
148 <p><input type="radio" class="radio" name="convertType" value="copy" checked="true" /> Copy<br /> 148 <p><input type="radio" class="radio" name="convertType" value="copy" checked="true" /> Copy<br />
149 <input type="radio" class="radio" name="convertType" value="move" /> Move<br /> 149 <input type="radio" class="radio" name="convertType" value="move" /> Move<br />
150 <input type="radio" class="radio" name="convertType" value="none" /> Neither<br /> 150 <input type="radio" class="radio" name="convertType" value="none" /> Neither<br />
151   151  
152 <p>By default only empty summary fields will be written to. Check this option to 152 <p>By default only empty summary fields will be written to. Check this option to
153 allow the summary field to be overwritten <input type="checkbox" class="checkbox" name="convertOverwrite" /></p> 153 allow the summary field to be overwritten <input type="checkbox" class="checkbox" name="convertOverwrite" /></p>
154   154  
155 <h3>permissions</h3> 155 <h3>permissions</h3>
156   156  
157 <p>This version introduces multiple authorised users and image &amp; gallery 157 <p>This version introduces multiple authorised users and image &amp; gallery
158 permissions. Please choose the default permissions that you would like all 158 permissions. Please choose the default permissions that you would like all
159 objects to be set to. The default permissions selected below are recommended as 159 objects to be set to. The default permissions selected below are recommended as
160 they will make all images &amp; galleries readable by everyone but only 160 they will make all images &amp; galleries readable by everyone but only
161 modifiable by administrators. See the readme for more information on the 161 modifiable by administrators. See the readme for more information on the
162 permissions model used by singapore.</p> 162 permissions model used by singapore.</p>
163 <table> 163 <table>
164 <tr> 164 <tr>
165 <td>Owner</td> 165 <td>Owner</td>
166 <td><input type="text" name="sgOwner" value="__nobody__" /></td> 166 <td><input type="text" name="sgOwner" value="__nobody__" /></td>
167 </tr> 167 </tr>
168 <tr> 168 <tr>
169 <td>Groups</td> 169 <td>Groups</td>
170 <td><input type="text" name="sgGroups" value="" /></td> 170 <td><input type="text" name="sgGroups" value="" /></td>
171 </tr> 171 </tr>
172 <tr> 172 <tr>
173 <td>Group permissions</td> 173 <td>Group permissions</td>
174 <td><div class="inputbox"> 174 <td><div class="inputbox">
175 <input type="checkbox" class="checkbox" name="sgGrpRead" checked="true"/> Read 175 <input type="checkbox" class="checkbox" name="sgGrpRead" checked="true"/> Read
176 <input type="checkbox" class="checkbox" name="sgGrpEdit" /> Edit 176 <input type="checkbox" class="checkbox" name="sgGrpEdit" /> Edit
177 <input type="checkbox" class="checkbox" name="sgGrpAdd" /> Add 177 <input type="checkbox" class="checkbox" name="sgGrpAdd" /> Add
178 <input type="checkbox" class="checkbox" name="sgGrpDelete" /> Delete 178 <input type="checkbox" class="checkbox" name="sgGrpDelete" /> Delete
179 </div></td> 179 </div></td>
180 </tr> 180 </tr>
181 <tr> 181 <tr>
182 <td>World permissions</td> 182 <td>World permissions</td>
183 <td><div class="inputbox"> 183 <td><div class="inputbox">
184 <input type="checkbox" class="checkbox" name="sgWldRead" checked="true"/> Read 184 <input type="checkbox" class="checkbox" name="sgWldRead" checked="true"/> Read
185 <input type="checkbox" class="checkbox" name="sgWldEdit" /> Edit 185 <input type="checkbox" class="checkbox" name="sgWldEdit" /> Edit
186 <input type="checkbox" class="checkbox" name="sgWldAdd" /> Add 186 <input type="checkbox" class="checkbox" name="sgWldAdd" /> Add
187 <input type="checkbox" class="checkbox" name="sgWldDelete" /> Delete 187 <input type="checkbox" class="checkbox" name="sgWldDelete" /> Delete
188 </div></td> 188 </div></td>
189 </tr> 189 </tr>
190 </table> 190 </table>
191   191  
192   192  
193 <p>Please note that while the script will create backups of your metadata files 193 <p>Please note that while the script will create backups of your metadata files
194 it is highly recommended that you create your own backups for added security.</p> 194 it is highly recommended that you create your own backups for added security.</p>
195   195  
196 <input type="submit" class="button" value="Go" /></p> 196 <input type="submit" class="button" value="Go" /></p>
197 </form> 197 </form>
198 <?php } ?> 198 <?php } ?>
199   199  
200 <p><a href="index.html">Return</a> to tools.</p> 200 <p><a href="index.html">Return</a> to tools.</p>
201   201  
202 </body> 202 </body>
203 </html> 203 </html>