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