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