This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.php
1554 lines (1262 loc) · 67.8 KB
/
install.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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?PHP
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// An array of the tables to install
$install_sql['directus_media'] = "CREATE TABLE IF NOT EXISTS `directus_media` (
`id` int(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`user` varchar(255) NOT NULL default '',
`uploaded` datetime NOT NULL default '0000-00-00 00:00:00',
`title` varchar(255) NOT NULL default '',
`source` varchar(255) NOT NULL default '',
`file_name` varchar(255) NOT NULL default '',
`type` varchar(50) NOT NULL default '',
`extension` varchar(10) NOT NULL default '',
`caption` text NOT NULL,
`location` varchar(255) NOT NULL default '',
`tags` varchar(255) NOT NULL default '',
`date_created` datetime NOT NULL default '0000-00-00 00:00:00',
`width` int(5) NOT NULL default '0',
`height` int(5) NOT NULL default '0',
`file_size` int(20) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['directus_messages'] = "CREATE TABLE IF NOT EXISTS `directus_messages` (
`id` int(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`subject` varchar(255) NOT NULL default '',
`message` text NOT NULL,
`datetime` datetime NOT NULL default '0000-00-00 00:00:00',
`reply` int(10) NOT NULL default '0',
`from` int(10) NOT NULL default '0',
`to` varchar(255) NOT NULL default '',
`viewed` varchar(255) NOT NULL default ',',
`archived` varchar(255) NOT NULL default ',',
`table` varchar(255) NOT NULL default '',
`row` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['directus_preferences'] = "CREATE TABLE IF NOT EXISTS `directus_preferences` (
`id` int(10) NOT NULL auto_increment,
`user` int(10) NOT NULL default '0',
`type` varchar(250) NOT NULL default '',
`name` varchar(250) NOT NULL default '',
`value` varchar(250) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['directus_activity'] = "CREATE TABLE IF NOT EXISTS `directus_activity` (
`id` int(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`table` varchar(100) NOT NULL default '',
`row` varchar(100) NOT NULL default '',
`type` varchar(100) NOT NULL default '',
`datetime` datetime NOT NULL default '0000-00-00 00:00:00',
`user` int(10) NOT NULL default '0',
`sql` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['directus_settings'] = "CREATE TABLE IF NOT EXISTS `directus_settings` (
`id` int(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`type` varchar(255) NOT NULL default '',
`option` varchar(255) NOT NULL default '',
`value` varchar(255) NOT NULL default '',
`option_2` varchar(255) NOT NULL default '',
`value_2` tinytext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['directus_users'] = "CREATE TABLE IF NOT EXISTS `directus_users` (
`id` tinyint(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`first_name` varchar(50) NOT NULL default '',
`last_name` varchar(50) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`token` varchar(255) NOT NULL default '',
`reset_token` varchar(255) NOT NULL default '',
`reset_expiration` datetime NOT NULL default '0000-00-00 00:00:00',
`email` varchar(255) NOT NULL default '',
`description` text NOT NULL,
`admin` tinyint(1) NOT NULL default '0',
`media` tinyint(1) NOT NULL default '1',
`notes` tinyint(1) NOT NULL default '1',
`editable` tinyint(1) NOT NULL default '1',
`email_messages` tinyint(1) NOT NULL default '1',
`view` text NOT NULL,
`add` text NOT NULL,
`edit` text NOT NULL,
`reorder` text NOT NULL,
`delete` text NOT NULL,
`last_login` datetime NOT NULL default '0000-00-00 00:00:00',
`last_page` varchar(255) NOT NULL default '',
`ip` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
$install_sql['demo_table'] = "CREATE TABLE `demo_table` (
`id` int(10) NOT NULL auto_increment,
`active` tinyint(1) NOT NULL default '1',
`sort` int(10) NOT NULL default '0',
`text_field` varchar(255) NOT NULL default '',
`text` text NOT NULL,
`checkbox` tinyint(1) NOT NULL default '0',
`date` date NOT NULL default '0000-00-00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Save terms acceptance as cookie
if($_POST['terms'] == 'accepted'){
setcookie("terms", "accepted", time()+36000);
header( 'location: install.php' );
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Attempt to set requirements (Server API: apache can use htaccess / cgi can use php.ini)
ini_set('session.auto_start', 0);
// Reverse the effects of Magic Quotes
@ini_set('magic_quotes_runtime', 0);
@ini_set('magic_quotes_sybase', 0);
if( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) ){
$_POST = array_map( 'stripslashes', $_POST );
$_GET = array_map( 'stripslashes', $_GET );
$_COOKIE = array_map( 'stripslashes', $_COOKIE );
}
// Trim all POSTs (doesn't work with arrays)
$_POST = array_map( 'trim', $_POST );
// Get this path
$directus_path = dirname("http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']) . '/';
// Set the timezone for datetimes
if(function_exists('date_default_timezone_set')){
date_default_timezone_set( 'UTC' );
}
// Error logging
$errors = array();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Run the server requirements test on every page!
// Check PHP version:
if(version_compare(phpversion(), '5.1.0', '<')){ $errors[] = '<b>PHP 5.1 or greater</b> (You: PHP '. phpversion() .')'; }
// Check MySQL exists:
if(!extension_loaded('mysql')){ $errors[] = '<b>MySQL</b> - You don\'t seem to have MySQL installed'; } // Can't check version since we arent connected yet
// Check if file uploads are on
if(!ini_get('file_uploads')){ $errors[] = '<b>File Uploads</b> - You don\'t seem to have file uploads enabled'; } // Entry can be set in php.ini or httpd.conf
// Check session autostart
if(ini_get('session.auto_start')){ $errors[] = '<b>Session Auto Start</b> - This needs to be off'; } // Entry can be set anywhere
// Check register globals
if(ini_get('register_globals')){ $errors[] = '<b>Register Globals</b> - This needs to be off'; } // Entry can be set in php.ini, .htaccess or httpd.conf
// Check Safe Mode
if(ini_get('safe_mode')){ $errors[] = '<b>Safe Mode</b> - This needs to be off'; } // Entry can be set in php.ini or httpd.conf
// Check Magic Quotes
//if(ini_get('magic_quotes_gpc')){ $errors[] = '<b>Magic Quotes</b> - This needs to be off'.get_magic_quotes_gpc(); } // Unsure how to turn off since server API (CGI or Apache) is unknown
// Check GD Library
if(!extension_loaded('gd')){ $errors[] = '<b>GD Library</b> - You\'ll need this for media'; }
// Check cURL
if(!function_exists('curl_init')){ $errors[] = '<b>cURL</b> - You\'ll need this for media'; }
// Set permissions (attempt)
@chmod("inc/config.php", 0755);
@chmod("inc/backups/", 0755);
@chmod("media/cms_thumbs/", 0755);
@chmod("media/temp/", 0755);
@chmod("media/users/", 0755);
if(file_exists('../media/files/')){
@chmod("../media/files/", 0755);
} else {
@mkdir("../media/files/", 0755, true);
@chmod("../media/files/", 0755);
}
// Check permissions
if(!is_writable('media/temp/')){ $errors[] = '<b><u>directus</u>/media/temp/ Folder</b> - Must be writable'; }
if(!is_writable('media/cms_thumbs/')){ $errors[] = '<b><u>directus</u>/media/cms_thumbs/ Folder</b> - Must be writable'; }
if(!is_writable('media/users/')){ $errors[] = '<b><u>directus</u>/media/users/ Folder</b> - Must be writable'; }
if(!is_writable('inc/backups/')){ $errors[] = '<b><u>directus</u>/inc/backups/ Folder</b> - Must be writable'; }
// Did the server pass all the requirements?
$meets_requirements = (count($errors) == 0)? true : false;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Run the database test and/or connect to database
if($meets_requirements && $_COOKIE['terms'] == 'accepted'){
// Check if config file already exists
if(file_exists("inc/config.php")){
// Connect to existing config file
require_once("inc/config.php");
// Get the values from the existing config file
$config_data = file_get_contents("inc/config.php");
$config_array = explode('"',$config_data);
$db_server = $config_array[1];
$db_username = $config_array[3];
$db_password = $config_array[5];
$db_database = $config_array[7];
$db_prefix = $config_array[9];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If server fails let's set it up!
if(!$server_success){
// Get variables from user
if($_POST['save_config']){
$db_server = addslashes($_POST['db_server']);
$db_username = addslashes($_POST['db_username']);
$db_password = addslashes($_POST['db_password']);
$db_database = addslashes($_POST['db_database']);
$db_prefix = addslashes($_POST['db_prefix']);
}
// Test server and database connection
try{
$dbh = new PDO("mysql:host=$db_server;dbname=$db_database;charset=UTF8", $db_username, $db_password);
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
} catch(PDOException $e) {
// Log the error
@file_put_contents(realpath(dirname(__FILE__)) . '/inc/directus_log.txt', date("Y-m-d H:i:s", time()-date("Z",time())) . ' - INSTALL: ' . $e->getMessage() . "\n", FILE_APPEND);
$errors[] = "Couldn't connect to server";
}
if($db_server == ""){
$errors[] = "Please enter a database host";
}
if($db_username == ""){
$errors[] = "Please enter a database username";
}
if($db_database == ""){
$errors[] = "Please enter a database name";
}
// If connection worked, let's save it
if(count($errors) == 0){
// Create random session name
srand((double)microtime()*1000000);
$i = 0;
$session_key = '';
while ($i < 4) {
$num = rand() % 33;
$tmp = substr("ABCDEFGHIJKMNOPQRSTUVWXYZ023456789", $num, 1);
$session_key = $session_key . $tmp;
$i++;
}
//////////////////////////////////////////////////////////////////////////////
// The new config file content (could be \ns but this is easier to read)
$install_config = '<?PHP
$db_server = "' . $db_server . '";
$db_username = "' . $db_username . '";
$db_password = "' . $db_password . '";
$db_database = "' . $db_database . '";
$db_prefix = "' . $db_prefix . '";
$directus_path = "' . $directus_path . '";
$cms_debug = false;
session_name("DIRECTUS_'.$session_key.'");
session_start();
header("Content-Type: text/html; charset=utf-8");
try{
$dbh = new PDO("mysql:host=$db_server;dbname=$db_database;charset=UTF8", $db_username, $db_password);
$dbh->exec("SET CHARACTER SET utf8");
$dbh->query("SET NAMES utf8");
if($cms_debug){
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); // Dev
} else {
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT ); // Live
}
// Tell other files we have connected
$server_success = true;
} catch(PDOException $e) {
// Log the error
file_put_contents(substr(realpath(dirname(__FILE__)), 0, -3) . "inc/directus_log.txt", date("Y-m-d H:i:s", time()-date("Z",time())) . " - " . $e->getMessage() . "\n", FILE_APPEND);
}
?>';
//////////////////////////////////////////////////////////////////////////////
// Save the details into the config file
if(!file_put_contents("inc/config.php", $install_config)){
$errors[] = "Couldn't save your config file, ensure directus/inc/ write permissions";
} else {
$server_success = true;
}
//////////////////////////////////////////////////////////////////////////////
// Update the CHARSET for the database to UTF8
$dbh->query("alter database $db_database charset=utf8 COLLATE utf8_general_ci");
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If server doesn't fail then let's add to it
if($server_success){
// Check if tables exist and are empty, otherwise create them
foreach($install_sql as $key => $value){
// Check if table already exists
$sth = $dbh->query("SHOW TABLES LIKE '$key'");
if($sth->rowCount() > 0){
// Check if table has rows already
$sth_inner = $dbh->query("SELECT * FROM `$key`");
$rows = $sth_inner->rowCount();
if($rows>0){
//$s = ($rows==1)?'':'s';
//$errors[] = "<b>$key</b> already exists with $rows item$s";
}
} else {
// Add the demo table only if the user wants it
if($key != "demo_table" || $_POST['demo_table']){
// If there's a custom prefix we need to add it to the demo_table
if($key == "demo_table" && $db_prefix){
$value = str_replace("`demo_table`", "`".$db_prefix."demo_table`", $value);
}
// Add the table
if(!$dbh->query($value)){
$errors[] = "<b>$key</b> could not be installed";
}
}
}
}
// If we now have all the tables we can continue
if(count($errors) == 0){
$requires_settings = false;
// Check if there is at least a full admin and basic settings
$sth_inner = $dbh->query("SELECT * FROM `directus_settings` WHERE `active` = '1' AND `type` = 'cms' AND (`option` = 'site_name' OR `option` = 'site_url') ");
$rows = $sth_inner->rowCount();
if($rows < 2){
$requires_settings = true;
}
$sth_inner = $dbh->query("SELECT * FROM `directus_users` WHERE `active` = '1' AND `admin` = '1' AND `email` != '' AND `password` != '' ");
$rows = $sth_inner->rowCount();
if($rows == 0){
$requires_settings = true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Requires Settings
if($requires_settings && $_POST['save_info']){
// Validate input
if(!$_POST['site_name'] || !$_POST['site_url']){
$errors[] = "Site name and URL are required";
}
if(!$_POST["first_name"] || !preg_match("/^[A-Za-z]+(?:[ -][A-Za-z]+)*$/", $_POST["first_name"])){
$errors[] = 'First name is required';
}
if(!$_POST["last_name"] || !preg_match("/^[A-Za-z]+(?:[ -][A-Za-z]+)*$/", $_POST["last_name"])){
$errors[] = 'Last name is required';
}
if($_POST["password"] != $_POST["password_confirm"]){
$errors[] = 'Passwords must match';
}
if(!$_POST["password"] || strlen($_POST["password"]) < 3){ // !preg_match("/^[A-Za-z0-9_@!#$%^&*]{3,}$/", $_POST["password"])
$errors[] = 'Password must be at least 3 characters';
}
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $_POST["email"])){
$errors[] = 'Email is not a valid address';
}
if(count($errors) == 0){
require_once("inc/functions.php");
//////////////////////////////////////////////////////////////////////////////
// Save basic settings (WILL HAVE TO SAVE SETTINGS PAGE AT LEAST ONCE TO FINISH INSTALL)
if(!$dbh->query("UPDATE `directus_settings` SET `active` = active+2 ")){
$errors[] = "Couldn't backup settings";
}
$sth = $dbh->prepare("INSERT INTO `directus_settings` (`type`, `option`, `value`, `option_2`, `value_2`) VALUES ('cms', 'site_name', :site_name, '', ''), ('cms', 'site_url', :site_url, '', '') ");
$sth->bindParam(':site_name', $_POST['site_name']);
$sth->bindParam(':site_url', $_POST["site_url"]);
if(!$sth->execute()){
$errors[] = "Couldn't save settings";
}
//////////////////////////////////////////////////////////////////////////////
// Add first user to database
if(!$dbh->query("TRUNCATE `directus_users` ")){
$errors[] = "Couldn't reset users";
}
$hasher = new PasswordHash(8, FALSE);
$sth = $dbh->prepare("INSERT INTO `directus_users` (`id`, `active`, `first_name`, `last_name`, `password`, `email`, `description`, `admin`, `media`, `notes`, `editable`, `email_messages`, `view`, `add`, `edit`, `reorder`, `delete`, `last_login`, `last_page`, `ip`) VALUES (1, 1, :first_name, :last_name, :password, :email, 'Admin', 1, 1, 1, 1, 1, 'all', 'all', 'all', 'all', 'all', '', '', '') ");
$sth->bindParam(':first_name', $_POST['first_name']);
$sth->bindParam(':last_name', $_POST['last_name']);
$sth->bindParam(':password', $hasher->HashPassword($_POST["password"]));
$sth->bindParam(':email', $_POST["email"]);
if(!$sth->execute()){
$errors[] = "Couldn't save user";
}
//////////////////////////////////////////////////////////////////////////////
// Add install date to activity
$sth = $dbh->prepare("INSERT INTO directus_activity (`active`,`type`, `datetime`, `user`) VALUES ('1', 'installed', :datetime, '1') ");
$sth->bindValue(':datetime', date("Y-m-d H:i:s", time()-date("Z",time())) );
if(!$sth->execute()){
$errors[] = "Couldn't save activity";
}
if(count($errors) == 0){
//////////////////////////////////////////////////////////////////////////////
// Send account creation email here
$body = "Congratulations on installing Directus!\n\nPassword for ".$_POST["first_name"]." ".$_POST["last_name"].":\n".$_POST["password"]."\n\nLogin for ".addslashes($_POST['site_name']).":\n".$directus_path."\n\n\n--\nDirectus";
$sent = send_email($subject = "Directus Setup Complete!", $body, $to = $_POST['email'], $from = false, $bcc = false);
if(!$sent) {
$errors[] = "Error sending setup email";
}
// Everything is all set!
$requires_settings = false;
}
} // End of "Input Validation"
} // End of "Requires Settings"
} // End of "Tables All Exist"
} // End of "Server Doesn't Fail"
} // End of "Meet Requirements"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Directus — Install</title>
<link rel="shortcut icon" href="<?PHP echo $directus_path;?>media/site/favicon.ico">
<script type="text/javascript" src="inc/js/jquery.js"></script>
<script type="text/javascript" src="inc/js/jquery-ui.js"></script>
<script type="text/javascript" src="inc/js/directus.js"></script>
<script>
$(document).ready(function(){
$('#install_terms').change(function(){
if($(this).attr('checked')){
$("#install_terms_button").addClass('color').removeClass('disabled');
} else {
$("#install_terms_button").addClass('disabled').removeClass('color');
}
});
$("#install_terms_button").click(function(event){
if( $('#install_terms').is(":checked") ){
$("#terms_form").submit();
} else {
alert('You must agree to the terms of this agreement to continue');
}
return false;
});
$('#try_again').click(function(event){
window.location.reload(true);
return false;
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Check password strength
$('#check_strength').keyup(function(e) {
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{7,}).*", "g");
if (false == enoughRegex.test($(this).val())) {
$('#password_strength').attr('class', 'weak');
$('#password_strength').html('More Characters');
} else if (strongRegex.test($(this).val())) {
$('#password_strength').attr('class', 'strong');
$('#password_strength').html('Strong');
} else if (mediumRegex.test($(this).val())) {
$('#password_strength').attr('class', 'medium');
$('#password_strength').html('Medium');
} else {
$('#password_strength').attr('class', 'weak');
$('#password_strength').html('Weak');
}
return true;
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Check that passwords match
$('#check_strength, #password_confirm').keyup(function(e) {
if($('#password_confirm').val() != ""){
if($('#check_strength').val() != $('#password_confirm').val()){
$('#password_match').text("Passwords do not match");
$('#password_match').attr('class', 'no_match');
} else {
$('#password_match').text("Password confirmed");
$('#password_match').attr('class', 'match');
}
} else {
$('#password_match').text("");
$('#password_match').attr('class', '');
}
return true;
});
});
</script>
<link rel="stylesheet" href="inc/css/directus.css" type="text/css" media="screen" title="" charset="utf-8">
<link rel="stylesheet" href="inc/css/cms_colors/green.css" type="text/css" media="screen" title="" charset="utf-8">
<style type="text/css">
body,html {
background: #ededed;
}
#page_install {
display: block;
background: #fff;
padding: 24px;
border: 1px solid #c9c9c9;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
box-shadow: rgba(0, 0, 0, 0.25) 0px 0px 9px;
-webkit-box-shadow: rgba(0, 0, 0, 0.25) 0px 0px 9px;
-moz-box-shadow: rgba(0, 0, 0, 0.25) 0px 0px 9px;
width: 700px;
margin: 48px auto;
}
.server_errors {
list-style: none;
padding: 0;
margin-bottom: 18px;
}
.server_errors li {
padding: 4px 7px;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
margin: 0 0 4px 0;
background: #fbe3e4;
color: #8a1f11;
}
.large {
margin-bottom: 18px;
}
#install_logo {
height: 121px;
text-indent: -9999px;
background: url(media/site/install_logo.jpg) no-repeat 0px 0px;
}
.install_table {
width: 100%;
padding-bottom: 18px;;
}
.install_table tr td {
background: #f8f8f8;
padding: 3px 9px;
border-bottom: 4px solid #fff;
font-size: 11px;
}
.install_table tr td input[type="text"],
.install_table tr td input[type="password"]{
width: 95%;
}
.weak, .medium, .strong, .match, .no_match {
padding: 4px 7px;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
}
.weak, .no_match {
background: #fbe3e4;
color: #8a1f11;
}
.medium {
background: #fff6bf;
color: #514721;
}
.strong, .match {
background: #e6efc2;
color: #264409;
}
.directus_terms {
overflow: auto;
height: 320px;
background-color: #fff;
border: 1px solid #dcdcdc;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
padding: 9px;
margin-bottom: 18px;
font-size: 12px;
}
.directus_terms p {
margin-bottom: 30px;
}
.directus_terms ul {
margin-bottom: 30px;
margin-left: 40px;
}
.directus_terms_agree {
margin-bottom: 18px;
}
</style>
</head>
<body>
<div id="page_install">
<h1 id="install_logo" title=":<?PHP echo $_COOKIE['terms']; ?>">Directus</h1>
<hr>
<?PHP
if($_COOKIE['terms'] != 'accepted'){
?>
<h2>License Agreement</h2>
<p class="large">
You must accept the terms of this agreement before continuing with the installation.
</p>
<div class="directus_terms" dir="ltr">
<h3>GNU GENERAL PUBLIC LICENSE</h3>
<p>Version 3, 29 June 2007<br>
Copyright © 2007 Free Software Foundation, Inc.
<a href="http://fsf.org/">http://fsf.org/</a></p>
<p>Everyone is permitted to copy and distribute verbatim copies
of this license document,<br> but changing it is not allowed.</p>
<h3><a name="preamble"></a>Preamble</h3>
<p>The GNU General Public License is a free, copyleft license for
software and other kinds of works.</p>
<p>The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.</p>
<p>When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.</p>
<p>To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.</p>
<p>For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.</p>
<p>Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.</p>
<p>For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.</p>
<p>Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.</p>
<p>Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.</p>
<p>The precise terms and conditions for copying, distribution and
modification follow.</p>
<h3><a name="terms"></a>TERMS AND CONDITIONS</h3>
<h4><a name="section0"></a>0. Definitions.</h4>
<p>“This License” refers to version 3 of the GNU General Public License.</p>
<p>“Copyright” also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.</p>
<p>“The Program” refers to any copyrightable work licensed under this
License. Each licensee is addressed as “you”. “Licensees” and
“recipients” may be individuals or organizations.</p>
<p>To “modify” a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a “modified version” of the
earlier work or a work “based on” the earlier work.</p>
<p>A “covered work” means either the unmodified Program or a work based
on the Program.</p>
<p>To “propagate” a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.</p>
<p>To “convey” a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.</p>
<p>An interactive user interface displays “Appropriate Legal Notices”
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.</p>
<h4><a name="section1"></a>1. Source Code.</h4>
<p>The “source code” for a work means the preferred form of the work
for making modifications to it. “Object code” means any non-source
form of a work.</p>
<p>A “Standard Interface” means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.</p>
<p>The “System Libraries” of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
“Major Component”, in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.</p>
<p>The “Corresponding Source” for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.</p>
<p>The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.</p>
<p>The Corresponding Source for a work in source code form is that
same work.</p>
<h4><a name="section2"></a>2. Basic Permissions.</h4>
<p>All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.</p>
<p>You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.</p>
<p>Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.</p>
<h4><a name="section3"></a>3. Protecting Users' Legal Rights From Anti-Circumvention Law.</h4>
<p>No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.</p>
<p>When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.</p>
<h4><a name="section4"></a>4. Conveying Verbatim Copies.</h4>
<p>You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.</p>
<p>You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.</p>
<h4><a name="section5"></a>5. Conveying Modified Source Versions.</h4>
<p>You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:</p>
<ul>
<li>a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.</li>
<li>b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
“keep intact all notices”.</li>
<li>c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.</li>
<li>d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.</li>
</ul>
<p>A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
“aggregate” if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.</p>
<h4><a name="section6"></a>6. Conveying Non-Source Forms.</h4>
<p>You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:</p>
<ul>
<li>a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.</li>
<li>b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.</li>