Rev Author Line No. Line
228 kaklik 1 <?php
2  
3 /**
4 * Performs necessary actions to install singapore.
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: install.php,v 1.6 2006/02/04 02:12:12 tamlyn Exp $
10 */
11  
12 //path to singapore root
13 $basePath = "../";
14  
15 require_once "install.inc.php";
16 require_once $basePath."includes/config.class.php";
17  
18 //determine current step in setup process
19 $setupStep = isset($_REQUEST["step"]) ? $_REQUEST["step"] : "test";
20  
21 if($setupStep=="phpinfo") {
22 phpinfo();
23 exit;
24 }
25  
26 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
27 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
28  
29 <html xmlns="http://www.w3.org/1999/xhtml">
30 <head>
31 <title>singapore setup</title>
32 <link rel="stylesheet" type="text/css" href="../docs/docstyle.css" />
33 </head>
34  
35 <body>
36  
37 <?php
38 //if file is parsed by php then this block will never be executed
39 if(false) {
40 ?>
41 </p>
42  
43 <h1>Oh dear...</h1>
44  
45 <p>PHP is not installed or is not configured correctly. See the
46 <a href="http://www.php.net/manual/">PHP manual</a> for more information.
47  
48 <?php
49 } //end php test
50  
51 switch($setupStep) {
52 case "test" :
53 setupHeader("Step 1 of 2: Test Server");
54 setupMessage("Attempting to find out if your server is capable of running singapore");
55 setupMessage("No changes are made at this time");
56 if(testServer()) {
57 setupHeader("OK");
58 setupMessage("All tests completed successfully");
59 } else {
60 setupHeader("Oops!");
61 setupError("One or more problems were encountered. You may want to fix them and <a href=\"install.php?step=test\">retry this step</a>");
62 }
63 echo '<br /><a href="index.html">&lt;&lt; Previous: welcome</a>';
64 echo ' | <a href="install.php?step=phpinfo">View PHP configuration</a>';
65 echo ' | <a href="install.php?step=database">Next: setup database &gt;&gt;</a>';
66 //echo ' | <a href="index.html">Finish</a>';
67 //echo ' | <a href="install.php?step=directories">Next: create directories &gt;&gt;</a>';
68 break;
69  
70 case "directories" :
71 setupHeader("Step 2 of 3: Create Directories");
72 setupMessage("Setup will now create the directories necessary to store thumbnails and logs");
73  
74 //create config object
75 $config = new sgConfig($basePath."singapore.ini");
76 $config->pathto_logs = $config->pathto_data_dir."logs/";
77 $config->pathto_cache = $config->pathto_data_dir."cache/";
78 $config->base_path = $basePath;
79  
80 if(createDirectories($config)) {
81 setupHeader("OK");
82 setupMessage("This step completed successfully");
83 } else {
84 setupHeader("Oops!");
85 setupError('There was a problem. Please fix it and <a href="install.php?step=directories">retry this step</a>');
86 }
87 echo '<br /><a href="install.php?step=test">&lt;&lt; Previous: test server</a>';
88 echo ' | <a href="install.php?step=database">Next: setup database &gt;&gt;</a>';
89 break;
90  
91 case "database" :
92 setupHeader("Step 2 of 2: Setup Database");
93  
94 //create config object
95 $config =& sgConfig::getInstance();
96 $config->loadConfig($basePath."singapore.ini");
97 $config->base_path = $basePath;
98  
99 switch($config->io_handler) {
100 case "csv" :
101 setupMessage("The default CSV file database does not require any further setting up");
102 setupHeader("OK");
103 setupMessage("This step completed successfully");
104 break;
105  
106 case "mysql" :
107 include_once $basePath."includes/io_mysql.class.php";
108 $config->loadConfig($basePath."secret.ini.php");
109 setupMessage("Setup will now create the tables necessary to run singapore on a MySQL database");
110 setupHeader("Connecting to database");
111 $io = new sgIO_mysql();
112 if(!$io) setupError("Error connecting to database. Please ensure database settings are correct");
113 if(sqlCreateTables($io)) {
114 setupHeader("OK");
115 setupMessage("This step completed successfully");
116 } else {
117 setupHeader("Oops!");
118 setupError('There was a problem. Please fix it and <a href="install.php?step=database">retry this step</a>');
119 }
120 break;
121  
122 case "sqlite" :
123 include_once $basePath."includes/io_sqlite.class.php";
124 setupMessage("Setup will now create the database and tables necessary to run singapore on SQLite");
125 setupHeader("Opening database file");
126 $io = new sgIO_sqlite();
127 if(!$io) {
128 setupError("Error connecting to database. Please ensure database settings are correct");
129 break;
130 } else setupMessage("Success");
131 if(sqlCreateTables($io)) {
132 setupHeader("OK");
133 setupMessage("This step completed successfully");
134 } else {
135 setupHeader("Oops!");
136 setupError('There was a problem. Please fix it and <a href="install.php?step=database">retry this step</a>');
137 }
138 break;
139 default :
140 setupError("Unrecognised io_handler.");
141 }
142 setupMessage("Don't forget to delete or protect this <code>install</code> directory to prevent unauthorised access");
143 echo '<br /><a href="install.php?step=test">&lt;&lt; Previous: test server</a>';
144 //echo '<br /><a href="install.php?step=directories">&lt;&lt; Previous: create directories</a>';
145 echo ' | <a href="index.html">Finish</a>';
146 break;
147 }
148 ?>
149  
150 </body>
151 </html>