forked from matamouros/cintient
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
730 lines (685 loc) · 25.8 KB
/
index.php
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
<?php
if (false) {
?>
Cintient requires a PHP environment in order to run. Please install PHP and try again.
<!--
<?php
}
/*
*
* Cintient, Continuous Integration made simple.
* Copyright (c) 2010-2012, Pedro Mata-Mouros <[email protected]>
*
* This file is part of Cintient.
*
* Cintient is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cintient 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 Cintient. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
*
* This is Cintient's installation script. The only way to make it past
* installation is to delete this, which should be done automatically at
* the very end of this script, if install is successful.
*
* @author Pedro Mata-Mouros <[email protected]>
*
*/
error_reporting(-1);
ini_set('display_errors', 'off');
// Control var, so that we can guess if we're exiting because of an
// error or because of normal script execution.
$exited = false;
//
// Make sure no previous .htaccess file is present here and refuse to
// run if we can't delete it. If present, our DOCUMENT_ROOT and
// SCRIPT_FILENAME might become poluted, breaking Cintient afterwards.
//
if (is_file(dirname(__FILE__) . DIRECTORY_SEPARATOR . '.htaccess')) {
if (!@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . '.htaccess')) {
die("An .htaccess file is present in Cintient's directory and couldn't be removed. Please remove it manually and try again.");
}
}
//
// Following are default values for the installation script
//
// All cases considered (all with and without trailing slash):
// . /a/b/c/index.php
// . /a/b/c/index.php?a=1&b=1
// . /a/b/c/
// . /a
// . /
$uriPathInfo = pathinfo(strtok($_SERVER['REQUEST_URI'], '?'));
$reqUri = $uriPathInfo['dirname'];
if ($uriPathInfo['basename'] != 'index.php') {
if ($reqUri != '/') {
$reqUri .= '/';
}
$reqUri .= $uriPathInfo['basename'];
}
$reqUri = str_replace("\\", '/', $reqUri); // Windows is reported putting '\' in this string. This could break some location style paths though... Check it later.
$reqUri = str_replace('//', '/', $reqUri);
$defaults = array();
$defaults['appWorkDir'] = ''; //;realpath(dirname(__FILE__) . '/..') . '/.cintient/';
$defaults['baseUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . ($reqUri != '/' ? $reqUri : ''); # No trailing slash
$defaults['configurationDir'] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'src/config/';
$defaults['configurationSampleFile'] = $defaults['configurationDir'] . 'cintient.conf.sample';
$defaults['configurationNewFile'] = $defaults['configurationDir'] . 'cintient.conf.php';
$defaults['htaccessFile'] = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.htaccess';
define('CINTIENT_INSTALLER_VERSION', '1.0.0-RC1');
//
// Utility functions
//
// Returns a modified configuration file, given a directive and value
//
function directiveValueUpdate($str, $directive, $directiveValue)
{
return preg_replace('/(define\s*\(\s*(?:\'|")' . $directive . '(?:\'|")\s*,\s*(?:\'|")).*((?:\'|")\s*\);)/', '$1' . $directiveValue . '$2', $str);
}
//
// The response generator. Will terminate execution promptly.
//
function sendResponse($ok, $msg)
{
global $exited;
$exited = true;
echo htmlspecialchars(
json_encode(
array(
'ok' => $ok,
'msg' => $msg,
)
),
ENT_NOQUOTES
);
exit;
}
/**
* A shutdown function to be registered in all AJAX calls. This ensures
* that a default error message is always sent to the client, in case of
* unexpected error.
*
* Basically the mechanism is: if a response wasn't sent back by
* sendResponse(), then takeover and send a generic error, asking the
* user to check the PHP error log. We know that all AJAX calls should
* terminate on sendResponse(), so any unexpected errors will fallback
* to this callback.
*/
function cleanup()
{
global $exited;
if (!$exited) {
// Assume error
sendResponse(false, 'Sorry, but there was an unknown error. Please check your PHP error log.');
}
}
//
// Following are function definitions for all checkable items
//
function phpInstallationVersion()
{
$msg[0] = "Version 5.3.3 or higher is required.";
$ok = false;
if (function_exists('phpversion') && function_exists('version_compare')) {
$msg[0] .= " Version " . phpversion() . " detected.";
$msg[1] = "Detected version " . phpversion() . ".";
$ok = version_compare(phpversion(), '5.3.3', '>=');
}
return array($ok, $msg[(int)$ok]);
}
function phpWithSqlite()
{
$msg[0] = "PHP with SQLite3 required.";
$ok = false;
if (extension_loaded('sqlite3')) {
// TODO: require >= 3.3.0 for CREATE TABLE IF NOT EXISTS support
$version = SQLite3::version();
$msg[0] .= " Please enable PHP with SQLite3.";
$msg[1] = "Detected version " . $version['versionString'] . ".";
$ok = extension_loaded('sqlite3');
}
return array($ok, $msg[(int)$ok]);
}
function apacheModRewrite()
{
$msg[0] = "Apache mod_rewrite is required.";
$msg[1] = "Detected.";
$ok = false;
if (function_exists('apache_get_modules')) {
$ok = in_array("mod_rewrite", apache_get_modules());
}
return array($ok, $msg[(int)$ok]);
}
function baseUrl($url)
{
$msg[0] = "Check that you have specified a valid URL.";
$msg[1] = "Ready.";
$ok = true; // TODO!
return array($ok, $msg[(int)$ok]);
}
function appWorkDir($dir)
{
$msg[0] = "Check dir exists and enable write permissions.";
$msg[1] = "Ready.";
if (!empty($dir) && substr($dir, -1) != DIRECTORY_SEPARATOR) {
$dir .= DIRECTORY_SEPARATOR;
}
//
// Test for upgrade or clean install
//
if (empty($dir)) {
$ok = false;
} elseif (is_file($dir . 'cintient.sqlite')) {
$msg[2] = $msg[1];
$ok = 2;
} else {
$testDir = $dir . '.install';
$ok = (@mkdir($testDir, 0777, true) != false);
@rmdir($testDir);
}
return array($ok, $msg[(int)$ok]);
}
function htaccessFile($dir)
{
$msg[0] = "You cannot change the dir, just enable write permissions there.";
$msg[1] = "Ready.";
$fd = @fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . '.htaccess', 'a+');
if ($fd === false) {
$ok = false;
} else {
$ok = true;
}
@fclose($fd);
return array($ok, $msg[(int)$ok]);
}
function configurationDir($dir)
{
global $defaults;
$msg[0] = "You cannot change the dir, just enable write permissions there.";
$msg[1] = "Ready.";
// Must be able to read the sample file provided and either create the
// unexisting new one, or backup an existing one and change the original
$testFilename = $defaults['configurationNewFile'] . uniqid();
$fd1 = @fopen($defaults['configurationSampleFile'], 'r');
$fd2 = @fopen($testFilename, 'a');
if ($fd1 === false || $fd2 === false) {
$ok = false;
} else {
$ok = true;
}
@fclose($fd1);
@fclose($fd2);
@unlink($testFilename);
return array($ok, $msg[(int)$ok]);
}
//
// AJAX check requests
//
if (!empty($_GET['c'])) {
register_shutdown_function('cleanup'); // If an error occurs, this will show the user some info
$ok = false;
$msg = 'Invalid request';
// TODO: Sanatize input
$c = $_GET['c'];
$v = (empty($_GET['v'])?null:$_GET['v']);
if (function_exists($c)) {
list($ok, $msg) = $c($v);
}
sendResponse($ok, $msg);
//
// Final form submission
//
} elseif (!empty($_GET['s'])) {
register_shutdown_function('cleanup'); // If an error occurs, this will show the user some info
$ok = false;
$msg = "Invalid request";
sleep(3); # Avoids a race condition at the end of the installation process while updating UI elements
define('CINTIENT_INSTALLER_DEFAULT_DIR_MASK', 0700);
// A date marker to be used in backup filenames and such
$dateMarker = date("Ymd") . '_' . time();
//
// Extract all sent inputs into key/value pairs
//
$get = array();
foreach ($_POST as $key => $value) {
// TODO: filter everything
if ($key != '_' && $key != 's') {
if ($key == 'appWorkDir') {
if (substr($value, -1) != DIRECTORY_SEPARATOR) {
$value .= DIRECTORY_SEPARATOR;
}
//
// Major issue in Windows platforms, where the '\' character escapes
// the $2 in the directiveValueUpdate() call, thus never replacing it
// with the proper "');" string and thus creating a syntax error.
// That's why we're forced to make sure on the appWorkDir only
// '/' are feeded to Cintient, and that this str_replace is *after*
// the DIRECTORY_SEPARATOR add above (since in Windows it will end
// the appWorkDir value with '\' again).
//
$value = str_replace('\\', '/', $value);
$value = str_replace('//', '/', $value); // Just making sure the first str_replace doesn't add a / to an already existing /.
} elseif ($key == 'baseUrl' && substr($value, -1) == '/') {
$value = substr($value, 0, -1);
}
$get[$key] = $value;
}
}
//
// Write the .htaccess file
//
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.htaccess';
$fd = @fopen($file, 'w');
if ($fd !== false) {
fwrite($fd, "RewriteEngine on" . PHP_EOL);
fwrite($fd, "RewriteBase {$reqUri}" . (substr($reqUri, -1)=='/'?'':'/') . PHP_EOL); # Insert a trailing slash here, it's needed!
fwrite($fd, "RewriteRule (fonts|imgs|js|css)/(.*) www/\$1/\$2 [L]" . PHP_EOL);
fwrite($fd, "RewriteRule ajax src/handlers/ajaxHandler.php [L]" . PHP_EOL);
fwrite($fd, "RewriteRule favicon\\.ico www/imgs/favicon.ico [L]" . PHP_EOL);
fwrite($fd, "RewriteRule .* src/handlers/webHandler.php [L]" . PHP_EOL);
fclose($fd);
} else {
$ok = false;
$msg = "Couldn't create the .htaccess file in " . dirname(__FILE__) . DIRECTORY_SEPARATOR;
sendResponse($ok, $msg);
}
//
// The configuration file
//
if (($fdSample = fopen($defaults['configurationSampleFile'], 'r')) === false) {
$ok = false;
$msg = "Couldn't read the sample configuration file {$defaults['configurationSampleFile']}. Check dir permissions.";
sendResponse($ok, $msg);
}
$originalConfFile = fread($fdSample, filesize($defaults['configurationSampleFile']));
$modifiedConfFile = $originalConfFile;
// Replacements:
$modifiedConfFile = directiveValueUpdate($modifiedConfFile, 'CINTIENT_WORK_DIR', $get['appWorkDir']);
$modifiedConfFile = directiveValueUpdate($modifiedConfFile, 'CINTIENT_BASE_URL', $get['baseUrl']);
fclose($fdSample);
// If the configuration file already exists, back it up
if (file_exists($defaults['configurationNewFile'])) {
if (!@copy($defaults['configurationNewFile'], $defaults['configurationNewFile'] . '_' . $dateMarker)) {
$ok = false;
$msg = "Couldn't backup an existing configuration file {$defaults['configurationNewFile']}. Check dir permissions.";
sendResponse($ok, $msg);
}
@unlink($defaults['configurationNewFile']);
}
file_put_contents($defaults['configurationNewFile'], $modifiedConfFile);
//
// From here on Cintient itself will handle the rest of the installation
//
require $defaults['configurationNewFile'];
error_reporting(-1);
ini_set('display_errors', 'off');
SystemEvent::setSeverityLevel(SystemEvent::INFO);
//
// Check for upgrade or clean install
//
$upgrade = false;
list ($ok, $_) = appWorkDir($get['appWorkDir']);
if ($ok === 2) {
$upgrade = true;
}
//
// Authentication (user must be root)
//
if ($upgrade) {
$_POST = array();
$_POST['authenticationForm'] = array();
$_POST['authenticationForm']['username'] = array();
$_POST['authenticationForm']['username']['value'] = 'root';
$_POST['authenticationForm']['password'] = array();
$_POST['authenticationForm']['password']['value'] = $get['password'];
if (!Auth_Local::authenticate()) {
$ok = false;
$msg = "The password you specified for the root account was invalid.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_INFO, $msg, "Installer");
sendResponse($ok, $msg);
}
}
//
// Create necessary dirs
//
if (!file_exists(CINTIENT_WORK_DIR) && !@mkdir(CINTIENT_WORK_DIR, DEFAULT_DIR_MASK, true)) {
$ok = false;
$msg = "Could not create working dir. Check your permissions.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
if (!file_exists(CINTIENT_PROJECTS_DIR) && !@mkdir(CINTIENT_PROJECTS_DIR, CINTIENT_INSTALLER_DEFAULT_DIR_MASK, true)) {
$ok = false;
$msg = "Could not create projects dir. Check your permissions.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
if (!file_exists(CINTIENT_ASSETS_DIR) && !@mkdir(CINTIENT_ASSETS_DIR, CINTIENT_INSTALLER_DEFAULT_DIR_MASK, true)) {
$ok = false;
$msg = "Could not create assets dir. Check your permissions.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
if (!file_exists(CINTIENT_AVATARS_DIR) && !@mkdir(CINTIENT_AVATARS_DIR, CINTIENT_INSTALLER_DEFAULT_DIR_MASK, true)) {
$ok = false;
$msg = "Could not create avatars dir. Check your permissions.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
//
// Backup a previous version database, if found, and if possible
//
if ($upgrade && !@copy($get['appWorkDir'] . 'cintient.sqlite', $get['appWorkDir'] . "cintient_{$dateMarker}.sqlite")) {
$msg = "Could not backup your previous version database. Continuing the upgrade, nevertheless.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
}
//
// Force an exclusive database transaction
//
if (!Database::beginTransaction(Database::EXCLUSIVE_TRANSACTION)) {
$ok = false;
$msg = "Problems obtaining an exclusive lock on the database.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
//
// Setup all objects
//
if (!User::install()) {
$ok = false;
$msg = "Could not setup User object.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
if (!Project::install()) {
$ok = false;
$msg = "Could not setup Project object.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
if (!SystemSettings::install()) {
$ok = false;
$msg = "Could not setup SystemSettings object.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
//
// Everything ok!!!
//
if (!Database::endTransaction()) {
Database::rollbackTransaction();
$ok = false;
$msg = "Problems commiting all changes to the database.";
SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer");
sendResponse($ok, $msg);
}
$settings = SystemSettings::load();
$settings->setSetting(SystemSettings::VERSION, CINTIENT_INSTALLER_VERSION);
if (!$upgrade) {
//
// Root user account
//
$user = new User();
$user->setEmail($get['email']);
$user->setNotificationEmails($get['email'] . ',');
$user->setName('Administrative Account');
$user->setUsername('root');
$user->setCos(/*UserCos::ROOT*/ 2);
$user->init();
$user->setPassword($get['password']);
}
// Just to make sure everything's neat and tidy, especially after
// an upgrade.
Database::execute('VACUUM');
//
// Last step: remove the installation file
//
if (!@unlink(__FILE__)) {
$ok = false;
$msg = "Couldn't remove the installation 'index.php' file. You need "
. "to remove this manually before refreshing this page, or else"
. " Cintient won't be able to start";
sendResponse($ok, $msg);
}
//
// Set a special cookie "one-time" cookie so that right after the
// installation we can show a message. This is just temporary until
// system-user messages are implemented. This cookie will be imediately
// erased by webHandler, after a GLOBAL flag is set. Right now a modal
// is being shown in header.inc.tpl and this cookie is there removed.
//
setcookie('cintientInstalled', time());
$ok = true;
if ($upgrade) {
$msg = "Cintient was successfully updated. Please refresh this page when you're ready.";
} else {
$msg = "Use 'root' and the password you provided to login. Please refresh this page when you're ready.";
}
SystemEvent::raise(CINTIENT_LOG_SEVERITY_INFO, "Installation successful.", "Installer");
sendResponse($ok, $msg);
}
//
// Ok ready to start installation!
//
$greetings = array(
'Greetings human.',
"I'm sorry, Dave, I'm afraid I can't do that.",
"They'll fix you. They fix everything.",
'Looking for me?',
'Stay out of trouble.',
"This will all end in tears.",
"Danger, Will Robinson!",
"Thank you for a very enjoyable game.",
"Shall we play a game?",
"Wouldn't you prefer a nice game of chess?",
"Greetings, Professor Falken.",
"I've seen things you people wouldn't believe.",
"Do... or do not. There is no try.",
"Live long and prosper.",
"The beginning is a very delicate time.",
"Tell me of your homeworld, Usul.",
);
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Cintient Installation</title>
<link rel="stylesheet" href="www/css/reset.css" />
<link rel="stylesheet" href="www/css/font_anonymouspro.css" />
<link rel="stylesheet" href="www/css/font_orbitron.css" />
<link rel="stylesheet" href="www/css/font_syncopate.css" />
<link rel="stylesheet" href="www/css/lib/bootstrap-1.3.0.min.css" />
<link rel="stylesheet" href="www/css/cintient.css">
<link rel="stylesheet" href="www/css/installer.css" />
<link rel="icon" href="www/imgs/favicon.ico">
<link rel="apple-touch-icon" href="www/imgs/favicon.ico" />
<!--[if lt IE 9]>
<script src="www/js/lib/html5.js"></script>
<![endif]-->
<meta name="generator" content="Cintient Engine" />
<script type="text/javascript" src="www/js/lib/jquery-1.7.min.js"></script>
<script type="text/javascript" src="www/js/lib/bootstrap/bootstrap-alerts.js"></script>
<script type="text/javascript" src="www/js/cintient.js"></script>
<script type="text/javascript" src="www/js/installer.js"></script>
</head>
<body>
<div id="welcomeScreen" title="Welcome screen" class="nodisplay">
<div class="cintientLettering">Cintient</div>
<div class="greetings" style="display: none;"><?php echo $greetings[rand(0, count($greetings)-1)]; ?></div>
</div>
<div id="installer" class="nodisplay">
<div class="topbar">
<div class="fill">
<div class="container">
<ul class="nav">
<li><div class="cintientLettering" id="logoLettering">Cintient</div></li>
</ul>
</div>
</div>
</div>
<div id="alertPane"></div>
<div class="container">
<div class="mainContent">
<div class="page-header">
<h1></h1>
</div>
<div id="sectionContent">
<div id="step-0" class="installerStep" title="Minimum requirements">
<form action class="form-stacked">
<fieldset>
<?php
list ($ok, $msg) = phpInstallationVersion();
?>
<div class="item clearfix<?php echo ($ok ? ' success' : ' fail'); ?>">
<label for="phpInstallationVersion">PHP 5.3.x</label>
<div id="phpInstallationVersion" class="input">
<span class="help-block"><?php echo $msg; ?></span>
</div>
</div>
<?php
list ($ok, $msg) = phpWithSqlite();
?>
<div class="item clearfix<?php echo ($ok ? ' success' : ' fail'); ?>">
<label for="phpWithSqlite">PHP with SQLite3</label>
<div id="phpWithSqlite" class="input">
<span class="help-block"><?php echo $msg; ?></span>
</div>
</div>
<?php
list ($ok, $msg) = apacheModRewrite();
?>
<div class="item clearfix<?php echo ($ok ? ' success' : ' fail'); ?>">
<label for="apacheModRewrite">Apache mod_rewrite</label>
<div id="apacheModRewrite" class="input">
<span class="help-block"><?php echo $msg; ?></span>
</div>
</div>
<div class="actions"><span id="actionNext"></span></div>
</fieldset>
</form>
</div>
<div id="step-1" class="installerStep" title="Basic setup">
<form action class="form-stacked">
<fieldset>
<?php
list ($ok, $msg) = appWorkDir($defaults['appWorkDir']);
?>
<div class="item clearfix inputCheckOnChange<?php echo ($ok ? ' success' : ' fail'); ?>" id="appWorkDir">
<label for="appWorkDir">Data dir</label>
<div class="input">
<input class="span6" type="text" name="appWorkDir" value="<?php echo $defaults['appWorkDir']; ?>" />
<span class="help-inline">An update will be performed instead, if a previous installation is detected.</span>
<span class="help-block"><?php echo $msg; ?></span>
</div>
<!--div class="help-block">Place for working files and databases, independent from the installation dir.</div-->
</div>
<?php
list ($ok, $msg) = baseUrl($defaults['baseUrl']);
?>
<div class="item clearfix inputCheckOnChange<?php echo ($ok ? ' success' : ' fail'); ?>" id="baseUrl">
<label for="baseUrl">Base URL where Cintient will run from</label>
<div class="input">
<input class="span6" type="text" name="baseUrl" value="<?php echo $defaults['baseUrl']; ?>" />
<span class="help-block"><?php echo $msg; ?></span>
</div>
<!--div class="help-block">Cintient tried to guess it. If you are not sure, just go with its suggestion.</div-->
</div>
<?php
list ($ok, $msg) = htaccessFile($defaults['htaccessFile']);
?>
<div class="item clearfix inputCheckOnChange<?php echo ($ok ? ' success' : ' fail'); ?>" id="htaccessFile">
<label for="htaccessFile">.htaccess</label>
<div class="input">
<input class="span6" type="text" name="htaccessFile" value="<?php echo $defaults['htaccessFile']; ?>" disabled="disabled" />
<span class="help-block"><?php echo $msg; ?></span>
</div>
</div>
<?php
list ($ok, $msg) = configurationDir($defaults['configurationDir']);
?>
<div class="item clearfix inputCheckOnChange<?php echo ($ok ? ' success' : ' fail'); ?>" id="configurationDir">
<label for="configurationDir">Configuration dir</label>
<div class="input">
<input class="span6" type="text" name="configurationDir" value="<?php echo $defaults['configurationDir']; ?>" disabled="disabled" />
<span class="help-block"><?php echo $msg; ?></span>
</div>
</div>
<div class="actions"><span id="actionNext"></span></div>
</fieldset>
</form>
</div>
<div id="step-2" class="installerStep" title="Administration account">
<form action class="form-stacked">
<fieldset>
<div class="item clearfix inputCheckOnChange fail freshOnly" id="email">
<label for="email">Email</label>
<!--div class="fineprintLabel">(for administration notifications)</div-->
<div class="input">
<input class="span6" type="text" name="email" value="" />
<span class="help-block">Email field is empty or invalid.</span>
</div>
</div>
<div class="item clearfix inputCheckOnChange fail" id="password">
<label for="password">Password</label>
<div class="input">
<input class="span6" type="password" name="password" value="" />
<span class="help-inline upgradeOnly">You are performing an update. Authenticate yourself as root, to continue.</span>
</div>
<label for="passwordr">Re-type password</label>
<div class="input">
<input class="span6" type="password" name="passwordr" value="" />
<span class="help-block">Passwords are empty.</span>
</div>
</div>
<div class="actions"><span id="actionNext"></span></div>
</fieldset>
</form>
</div>
</div>
</div>
<footer>
<p>Cintient is free software distributed under the GNU General Public License version 3 or later terms.</p>
</footer>
</div>
</div>
<div id="finished" class="nodisplay">
<h1>Almost there, just a few more seconds...</h1>
<div><img src="www/imgs/loading-3.gif" /></div>
</div>
<script type="text/javascript">
// <![CDATA[
//inputLocalCheckOnChange validation function
function inputCheckOnChangeEmail()
{
var input = $("#step-2 #email input").val();
var msg = ['Email field is empty or invalid', 'Ready.'];
var ok = (input.length > 1);
return {ok: ok, msg: msg[Number(ok)]}; // TODO: check email better
}
//inputLocalCheckOnPassword validation function
function inputCheckOnChangePassword()
{
var input1 = $('#step-2 #password input[name="password"]').val();
var input2 = $('#step-2 #password input[name="passwordr"]').val();
var msg = ["Passwords are empty or don't match.", 'Ready.'];
var ok = (input1.length > 0 && input1 == input2);
return {ok: ok, msg: msg[Number(ok)]};
}
$(document).ready(function() {
CintientInstaller.init();
});
// ]]>
</script>
</body>
</html>