Source for file index.php

Documentation is available at index.php


1 <?php
2 /**
3 * @author Jan H. Andersen <jha@ipwsystems.dk>
4 * @author Martin R. Larsen <mrl@ipwsystems.dk>
5 * @author Jesper Laursen <jl@ipwsystems.dk>
6 * @copyright {@link http://www.ipwsystems.dk/ IPW Systems a.s}
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @package METAjour
9 * $Id: index.php,v 1.5 2005/02/14 15:19:50 jan Exp $
10 */
11
12 session_start();
13
14 /* Find and include config.php */
15 require('../config.php');
16 require('install_core.php');
17
18 function top() {
19 $string = '
20 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
21 "http://www.w3.org/TR/html4/loose.dtd">
22 <html>
23 <head>
24 <title>IPW METAjour installer</title>
25 <style type="text/css">
26 body td th {
27 font-family: verdana, arial, sans-serif;
28 font-size: 9pt;
29 }
30
31
32 #content {
33 width: 500px;
34 border: 1px solid black;
35 padding: 10px;
36 background-color: #cccccc;
37 }
38
39 .headline {
40 font-weight: bold;
41 }
42
43 .buttonbar {
44 width: 464px;
45 text-align: right;
46 padding: 0px;
47 }
48
49 .returnmsg {
50 color: red;
51 }
52
53 button {
54 font-family: verdana, arial, sans-serif;
55 font-size: 9pt;
56 border: 1px solid #aaaaaa;
57 padding: 2px;
58 margin: 2px 0px 2px 4px;
59
60 }
61
62 input {
63 font-family: verdana, arial, sans-serif;
64 font-size: 9pt;
65 border: 1px solid #aaaaaa;
66 width: 275px;
67 }
68 </style>
69 <script type="text/javascript" src="jsrs/jsrsCore.js"></script>
70
71 </head>
72 <body>
73 <table width="100%">
74 <tr>
75 <td align="center">
76 <div id="content">
77 ';
78
79 return $string;
80 }
81
82 function bottom() {
83 $string = '
84 </div>
85 </td>
86 </tr>
87 </table>
88 </body>
89 </html>
90 ';
91 return $string;
92 }
93
94 function printResult($name, $value, $result) {
95 $html = '<tr>';
96 $html .= '<th align="left">'.$name.':</th>';
97 $html .= '<td align="left">'.$value.'</td>';
98 $html .= sprintf('<td align="left" class="returnmsg">%s</td>', !$result ? 'Error':'<span style="color: green;">OK</span>');
99 $html .= '</tr>';
100 return $html;
101 }
102
103 function makeField($text, $field) {
104 return '<tr><td>'.$text.'</td><td>'.$field.'</td></tr>';
105 }
106
107 function screen1() {
108 global $returnmsg
109
110 $test = new Screen1;
111
112 echo top();
113 $url = $_SERVER['PHP_SELF'] . '?page=2';
114 ?>
115 <p class="headline">Welcome to the installation of IPW METAjour</p>
116 <table width="100%">
117 <?php
118 echo printResult('Configfile exists', '', file_exists('../config.php'));
119 echo printResult('No system tables exists', '', $test->notablesExists());
120 echo printResult('Correct PHP-version', '', $test->correctPHPversion());
121 echo printResult('Correct MySQL-version', '', $test->correctMySQLversion());
122 ?>
123 </table>
124 <?php
125 if (!$test->haserror) {
126 ?>
127 <p class="buttonbar">
128 <button onclick="location.href='<?php echo $url; ?>'; return false;">Next</button></p>
129 <?php
130 }
131 echo bottom();
132 }
133
134 function screen2() {
135 global $system_path $system_url $CONFIG
136 $next = $_SERVER['PHP_SELF'] . '?page=3';
137 $prev = $_SERVER['PHP_SELF'] . '?page=1';
138
139 $test = new Screen2($CONFIG);
140
141 echo top();
142 ?>
143 <p class="headline">Configure path and url</p>
144 <table width="100%">
145 <?php
146 echo printResult('System path', $system_path, $test->checkSystemPath($system_path));
147 echo printResult('System url', $system_url, $test->checkSystemUrl($system_url));
148 ?>
149 </table>
150 <p class="headline">Database</p>
151 <table width="100%">
152 <?php
153 echo printResult('Database program', '', $test->checkadodbexists($system_path));
154 echo printResult('Database connection', '', $test->checkDatabaseConn($system_path));
155 ?>
156 </table>
157 <p class="buttonbar">
158 <button onclick="location.href='<?php echo $prev; ?>'; return false;">Prev</button>
159 <?php if (!$test->haserror) { ?> <button onclick="location.href='<?php echo $next; ?>'; return false;">Next</button><?php } ?>
160 </p>
161 <?php
162 echo bottom();
163 }
164
165 function screen3() {
166 $next = $_SERVER['PHP_SELF'] . '?page=4';
167 $prev = $_SERVER['PHP_SELF'] . '?page=2';
168
169 $test = new Screen3();
170
171 echo top();
172 $test->createsql();
173 ?>
174 <p class="buttonbar">
175 <button onclick="location.href='<?php echo $prev; ?>'; return false;">Prev</button>
176 <?php if (!$test->haserror) { ?> <button onclick="location.href='<?php echo $next; ?>'; return false;">Next</button><?php } ?>
177 </p>
178 <?php
179 echo bottom();
180 }
181
182 function Screen4() {
183 global $system_path $system_url $CONFIG
184 require_once('../ow.php');
185 require_once('createsite.inc.php');
186
187 $test = new Screen4();
188 echo top();
189 print ('<p class="headline">Create site</p>');
190 $data = $_POST;
191 if ($data['step'] == '2') {
192 $failure = false;
193 if ($data['password'] != $data['passwordcheck']) {
194 $result .= "Passwords mismatch<BR>";
195 $failure = true;
196 }
197 if ($data['viewer_path'] == '') {
198 $result .= "You must enter the absolute path to the documentroot<BR>";
199 $failure = true;
200 }
201
202 if ($data['viewer_url'] == '') {
203 $result .= "You must enter the URL to the website<BR>";
204 $failure = true;
205 }
206
207 if ($data['name'] == '') {
208 $result .= "You must enter a descriptive name of the site<BR>";
209 $failure = true;
210 }
211
212 if ($data['username'] == '') {
213 $result .= "You must enter a name for the administrator user account<BR>";
214 $failure = true;
215 }
216
217 if (!$failure) {
218 $site = createSite($data['username'], $data['password'], $data['viewer_path'], $data['viewer_url'], $data['name']);
219 $result .= "<strong>Site has been created with number: ".$site."<BR>";
220 }
221 }
222
223 if ($data['step'] != '2' || $failure) {
224 $result .= '<form name="metaform" method="post" action="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'" enctype="multipart/form-data" style="margin: 0px; padding: 0px;">';
225 $result .= '<input type="hidden" name="step" value="2">';
226 $result .= '<table style="text-align: left;">';
227 $result .= makeField('Name of site','<input type="text" name="name" size=40 value="MyWebsite, Inc.">');
228 $result .= makeField('Absolute path to documentroot','<input type="text" name="viewer_path" size=40 value="'.str_replace('/metajour/','/', $system_path).'">');
229 $result .= makeField('URL to website','<input type="text" name="viewer_url" size=40 value="'.str_replace('/metajour/','/', $system_url).'">');
230 $result .= makeField('Administrator username','<input type="text" name="username" value="administrator">');
231 $result .= makeField('Administrator password','<input type="password" name="password">');
232 $result .= makeField('Repeat password','<input type="password" name="passwordcheck">');
233 $result .= '<tr><td colspan="2" style="text-align: right;"><input id="submit1" name="submit1" type="submit" class="mformsubmit" value="Opret"></td></tr>';
234 $result .= '</table>';
235 $result .= '</form>';
236 }
237
238 echo $result;
239 echo bottom();
240 }
241
242 switch($_GET['page']) {
243 case '2':
244 screen2();
245 break;
246 case '3':
247 screen3();
248 break;
249 case '4':
250 screen4();
251 break;
252 default:
253 screen1();
254 }
255 ?>

Documentation generated on Thu, 9 Jun 2005 06:52:35 +0200 by phpDocumentor 1.2.3