~swishcms/swishcontent/swishcontent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php

/*
    This file is part of SwishCONTENT.

    SwishCONTENT is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License v2 as published by
    the Free Software Foundation.

    SwishCONTENT is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SwishCONTENT; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--[if lt IE 7.]>
<script defer type="text/javascript" src="../pngfix.js"></script>
<![endif]-->
  <title>SwishCONTENT Installation</title>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <style type="text/css">

body {
	font-family: Arial, Helvetica, sans-serif;
	margin: 0px;
}

#header {
	background-image: url("logograd.png");
	background-color: #CCCCCC;
	height: 70px;
}

#buttonbox {
	display: inline;
	top: 15px;
	right: 15px;
	position: absolute;
	font-size: xx-large;
	font-weight: bold;
	color: #ffffff;
}

#content {
	padding: 5px;
	background-image: url("headbkg.png");
	background-position: top;
	background-repeat: repeat-x;
	color: #000000;
}

#footer {
	padding: 5px;
	background-image: url("footbkg.png");
	background-position: top;
	background-repeat: repeat-x;
	font-size: 12px;
	color: #666666;
}

#logobox {
	background: #ffffff;
	height: 70px;
	width: 180px;
}

#curve {
	background-image: url("curve.png");
	background-repeat: no-repeat;
	height: 70px;
	width: 40px;
	position: absolute;
	left: 180px;
	top: 0px;
}

.logo {
	padding: 5px;
	left: 4px;
	position: absolute;
}

.button {
	background-color: #FFFFFF;
	border: 1px solid #666666;
	padding: 5px;
}

.button img {
	border: 0;
}

a {
	text-decoration: none;
}

input, textarea {
	border: 1px solid gray;
}
.code {
	border: 1px dashed gray;
	padding: 2px;
	background-color: rgb(255, 255, 204);
	font-family: "Courier New",Courier,monospace;
	font-size: larger;
}
  </style>
   <link rel="shortcut icon" href="../favicon.ico">
</head>
<body>
<div id="header"><div id="curve"> </div><div id="logobox"><img src="logo.png" border="0" alt="SwishCONTENT Installation" class="logo"/></div></div>
<div id="buttonbox">Installation</div>
<div id="content">
<?php

	if(!isset($_POST['page'])) {
		$_POST['page'] = "";
	}

	switch($_POST['page']) {
		case page1:
			// Set database password etc.
			setting1();
			break;
		case page2:
			// Write/display config file.
			setting2();
			break;
		case page3:
			// Populate database.
			popdb();
			break;
		case page4:
			// Set admin password.
			adminpass();
			break;
		case page5:
			// Insert password into database.
			poppass();
			break;
		case page6:
			// And we are done!
			finaltext();
			break;
		default:
			// Introduction page.
			intro();
			break;
	}

	function intro() {
		echo('<h1>Installation</h1>Welcome to the SwishCONTENT Installer. This tool will set up the configuration file and database for you. Write access to the config file is not required, but write access to the database, including credentials, is required. Your admin password will also be set.<br /><br /><form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page1"><input type="submit" value="Next">');
	}

	function setting1() {
		echo('<h1>Database Configuration</h1>Please set your database details. Please note that the database must be created beforehand, and you do not need the root account, though the accound will need write access to the database. Please note that if you are adding this Swish product to another one, you can use the same database as a previously installed one.<br /><br />If you are planning to install other SwishCMS components, or already have them installed, use the same database for all, there will be no conflicts, plus it will allow the components to link together.<br /><br />For Database Type, please ensure the right (type here).php file exists for the admin cp, main site and the installer, then write the filename, minus path and .php here (e.g. mysql).<br /><br /><form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page2"><table><tr><td><b>Database Host:</b></td><td><input type="text" name="host" value="localhost" /></td></tr><tr><td><b>Database Username:</b></td><td><input type="text" name="username" value="" /></td></tr><tr><td><b>Database Password:</b></td><td><input type="password" name="password" value="" /></td></tr><tr><td><b>Database Name:</b></td><td><input type="text" name="name" value="" /></td></tr><tr><td><b>Database Type:</b></td><td><input type="text" name="type" value="mysql" /></td></tr></table><br /><input type="submit" value="Next"></form>');
	}

	function setting2() {

		$var = 0;

		echo('<h1>Configuration File</h1>');

		echo('We are now attempting to write the config file. If this fails, you will be given an option to enter it by hand.<br /><br /><b>Write config file: </b>');

		if(!is_writable("../config.php")) {
			echo 'Failed! Access denied. Please change the config.php file permissions to allow write access.<br />';
			echo '<form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page2"><input type="hidden" name="host" value="'.$_POST['host'].'"><input type="hidden" name="username" value="'.$_POST['username'].'"><input type="hidden" name="password" value="'.$_POST['password'].'"><input type="hidden" name="name" value="'.$_POST['name'].'"><input type="hidden" name="type" value="'.$_POST['type'].'"><br /><input type="submit" value="Retry"></form>';
			showconf();

			$var = 1;

		}

		if($var == 0) {

		$handle = fopen("../config.php", "w+");

		$host = '$GLOBALS[\'db_host\'] = \'' . $_POST['host'];
		$username = '$GLOBALS[\'db_username\'] = \'' . $_POST['username'];
		$password = '$GLOBALS[\'db_password\'] = \'' . $_POST['password'];
		$database = '$GLOBALS[\'db_database\'] = \'' . $_POST['name'];
		$type = '$GLOBALS[\'db_type\'] = \'' . $_POST['type'];


		fwrite($handle, "<?php\n");
		fwrite($handle, $host."';\n");
		fwrite($handle, $username."';\n");
		fwrite($handle, $password."';\n");
		fwrite($handle, $database."';\n");
		fwrite($handle, $type."';\n");
		fwrite($handle, '$GLOBALS[\'db_debug\'] = \'0\'; // Set to 1 for SQL debug info.'."\n");
		fwrite($handle, '$GLOBALS[\'sc_mainfile\'] = \'index.php\'; // If you rename index.php, set the new name here.'."\n");
		fwrite($handle, "?>\n");

		fclose($handle);

		echo('Done!<br /><br />');

		}

		echo('<form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page3"><input type="submit" value="Next"></form>');

	}

	function showconf() {
		echo('Below is the correct settings for config.php. Please copy these into the config.php in the installation, then click Next to continue. If you are adding this Swish product to another one, copy the old config into the folder with this product. Then, add the bottom line about mainfile to the config file. Do the same to the old copy, but ajusting it (it can include a path) if needed.<br /><br /><b>File contents:</b><br /><textarea rows="10" cols="80"><?php
');
?>
$GLOBALS['db_host'] = '<?php echo($_POST['host']) ?>';
$GLOBALS['db_username'] = '<?php echo($_POST['username']) ?>';
$GLOBALS['db_password'] = '<?php echo($_POST['password']) ?>';
$GLOBALS['db_database'] = '<?php echo($_POST['name']) ?>';
$GLOBALS['db_type'] = '<?php echo($_POST['type']) ?>';
$GLOBALS['db_debug'] = '1'; // Change to 0 for no SQL Debugging info.
$GLOBALS['sc_mainfile'] = 'index.php'; // If you rename index.php, reflect the change here.
<?php
echo('?></textarea><br /><br /><b>Do not press next until you updated config.php</b><br /><br />');
	}

	function popdb() {
		require("../config.php");
		$IN_SCi = 1;
		require("install/".$GLOBALS['db_type'].".php");
		$IN_SCu = 1;
		require("../drivers/".$GLOBALS['db_type']."/master.php");
		dbconnect();
		echo("<h1>Populating Database</h1>The database is currently being populated.<br /><br /><b>Populate database:</b> ");
		doinstall();
		dbdisconnect();
	}

	function adminpass() {
		echo('<h1>Administrator Password</h1>Please set the password used for accessing the admin panel. Do not forget what you enter here. The Secondary and Tertiary accounts passwords can be set in the admin panel once the install has finished. You should do this as soon as possible.<br /><br /><form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page5"><table><tr><td><b>Password:</b></td><td><input type="password" name="pass1" value="" /></td></tr><tr><td><b>Repeat:</b></td><td><input type="password" name="pass2" value="" /></td></tr></table><br /><input type="submit" value="Next"></form>');
	}

	function poppass() {
		require("../config.php");
		$IN_SCi = 1;
		require("install/".$GLOBALS['db_type'].".php");
		$IN_SCu = 1;
		require("../drivers/".$GLOBALS['db_type']."/master.php");
		dbconnect();
		echo("<h1>Setting Password</h1>The password is being set.<br /><br /><b>Set Password:</b> ");
		if($_POST['pass1'] != $_POST['pass2'])
		{
			echo('Failed - passwords were not the same.<br /><br /><form name="input" action="install.php" method="post"><input type="hidden" name="page" value="page4"><input type="submit" value="Back"></form>');
			return;
		}
		setpass($_POST['pass1']);
		dbdisconnect();
	}

	function finaltext() {
		echo('<h1>Installation Complete</h1>Thank you for installing SwishCONTENT. Your new site is now ready for use. Below are a set of suggested post-install tasks:<ul><li>Remove the entire install directory.</li><li>Set some content on the pages.</li><li>Read the documentation.</li><li>Set the secondary and tertiary admin passwords in the Admin CP</li></ul>If you have any issues with SwishCONTENT, please contact us at our <a href="http://swishcms.berlios.de">website</a>. <h2>Credits</h2><ul><li>lsproc - Project Leader and coding</li><li>Alex Smith - Testing</li><li>Durand - Images</li><li>Elliot Hughes - Testing</li></ul><a href="../">Proceed to your new site</a>.');
	}
?>

</div>
<div id="footer"><br style="font-size: 7px;" />&copy; 2008 SwishCMS Development Team - <a href="http://swishcms.exclaim-project.org">SwishCMS Homepage</a> - <a href="http://validator.w3.org/check?uri=referer"> Valid HTML</a></div>
<br />
</body>
</html>