forked from ACCORD5/TrellisDesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·1643 lines (1268 loc) · 84.3 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
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
/**
* Trellis Desk
*
* @copyright Copyright (C) 2009-2012 ACCORD5. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*/
define( 'IN_TD', true );
#=============================
# Lets Play Nice With Output
#=============================
ob_start();
#=============================
# Safe and Secure
#=============================
if ( function_exists('date_default_timezone_get') )
{
date_default_timezone_set( date_default_timezone_get() );
}
ini_set( 'register_globals', 0 );
if ( @ini_get( 'register_globals' ) )
{
foreach ( $_REQUEST as $key => $value )
{
unset( $$key );
}
}
#=============================
# Define Our Paths
#=============================
define( 'TD_INSTALL', "./" );
define( "TD_PATH", "../" );
define( 'TD_INC', TD_PATH ."includes/" );
define( 'TD_CLASS', TD_PATH ."includes/classes/class_" );
define( 'TD_FUNC', TD_PATH ."includes/functions/func_" );
define( 'TD_SRC', TD_PATH ."sources/" );
define( 'TD_SKIN', TD_PATH ."skin/" );
#=============================
# Main Class
#=============================
require_once TD_INC . "trellis.php";
require_once TD_INSTALL . "trellis_install.php";
$trellis = new trellis_install();
$install = new td_install( $trellis );
$install->run();
class td_install {
private $output = '';
private $checks_fatal = 0;
#=======================================
# @ Constructor
#=======================================
public function __construct(&$trellis)
{
$this->trellis = $trellis;
}
#=======================================
# @ Run
#=======================================
function run()
{
#=============================
# Security Checks
#=============================
if ( file_exists( TD_INSTALL .'install.lock' ) && $this->trellis->input['step'] != 'security' ) $this->locked();
if ( $this->trellis->input['step'] && $this->trellis->input['step'] != 'check' )
{
$this->trellis->initialize();
if ( $this->trellis->input['step'] != 'security' ) $this->prechecks();
}
#=============================
# Next Step...
#=============================
switch ( $this->trellis->input['step'] )
{
case 'check':
$this->check();
break;
case 1:
$this->step_1();
break;
case 2:
$this->step_2();
break;
case 3:
$this->step_3();
break;
case 4:
$this->step_4();
break;
case 5:
$this->step_5();
break;
case 6:
$this->step_6();
break;
case 7:
$this->step_7();
break;
case 'adv':
#$this->step_adv();
die( 'Coming in future releases!' ); # TODO: advanced installation
break;
case 'install':
$this->step_install();
break;
case 'security':
$this->security();
break;
default:
$this->welcome();
break;
}
}
#=======================================
# @ Welcome
#=======================================
private function welcome()
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed(); // Trust me, we have to put this in for each function. Trying to include it globally is a mess.
#=============================
# Version Check
#=============================
if ( $vcheck = $this->version_check() )
{
if ( $vcheck > $this->trellis->version_number )
{
$vcheck_msg = '<strong>A more recent release of Trellis Desk is available for download. We highly recommend <a href="http://www.accord5.com/trellis/download">downloading</a> the latest version before continuing.</strong>';
}
else
{
$vcheck_msg = 'You have the latest version of Trellis Desk downloaded and ready to install.';
}
}
else
{
$vcheck_msg = 'We were unable to check for the latest version of Trellis Desk. Please be sure that you have the latest release available before continuing.';
$vcheck = 'Unknown';
}
#=============================
# Do Output
#=============================
$this->output .= "<div id='ticketroll'>
<div class='acpwelcome'><img src='<! IMG_DIR !>/td_welcome_acphome.png' alt='Welcome to Trellis Desk 2' /></div>
". $this->trellis->skin->group_title( 'Begin Installation' ) ."
". $this->trellis->skin->group_row_with_p( '<p>Hello and welcome to the Trellis Desk Install Center. The Install Center will guide you through the Trellis Desk installation process. At any time, you can go back and make changes to previous steps by using the navigation buttons on the bottom of each page. On behalf of ACCORD5, we thank you for choosing and supporting Trellis Desk.</p><p><span class="dotunderline">Downloaded Version ID:</span> '. $this->trellis->version_number .' <span class="dotunderline">Latest Available Version ID:</span> '. $vcheck .'</p><p>'. $vcheck_msg .'</p>' ) ."
". $this->trellis->skin->formtail( '<a href="index.php?step=check" class="button">Next »</a>' ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 0 );
$this->trellis->skin->do_output();
}
#=======================================
# @ Check
#=======================================
private function check()
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Permission Checks
#=============================
$checks_html = '';
$checks_html = "<table width='100%' cellpadding='0' cellspacing='0'>";
$checks_html .= $this->check_row_start( 'PHP Version ('. PHP_VERSION .')' );
$checks_html .= $this->check_row_end( version_compare( PHP_VERSION, '5.3', '>=' ), array( 'fail_msg' => 'Trellis Desk cannot be installed as it requires PHP version <b>5.3.0</b> or later.' ) );
$checks_html .= $this->check_row_start( 'Safe Mode' );
$checks_html .= $this->check_row_end( ( ! ini_get('safe_mode') ), array( 'warn_msg' => 'Safe mode in PHP is enabled. You can continue, however this may result in unexpected behavior from Trellis Desk.' ) );
$memory_limit_bytes = $this->return_bytes( ini_get('memory_limit') );
$memory_limit_ini = ini_get('memory_limit');
if ( $memory_limit_ini == '-1' )
{
$memory_limit = 'No Limit';
}
elseif ( $memory_limit_bytes )
{
$memory_limit = $this->format_size( $memory_limit_bytes );
}
else
{
$memory_limit = 'No Limit';
}
$checks_html .= $this->check_row_start( 'Memory Limit ('. $memory_limit .')' );
$checks_html .= $this->check_row_end( ( ! ( $memory_limit_ini && $memory_limit_ini != '-1' && $memory_limit_bytes < 16777216 ) ), array( 'warn_msg' => 'Your PHP\'s memory limit is set to '. $memory_limit .'. We recommend that this value is set to 16 MB or more.' ) );
$file_uploads = ini_get('file_uploads');
$checks_html .= $this->check_row_start( 'File Uploads' );
$checks_html .= $this->check_row_end( $file_uploads, array( 'warn_msg' => 'File uploads are not enabled in PHP, therefore you will not be able to use attachments in Trellis Desk.' ) );
if ( $file_uploads )
{
$upload_max_filesize_bytes = $this->return_bytes( ini_get('upload_max_filesize') );
$upload_max_filesize = $this->format_size( $upload_max_filesize_bytes );
$checks_html .= $this->check_row_start( 'Maximum Upload Size ('. $upload_max_filesize .')' );
$checks_html .= $this->check_row_end( ( $upload_max_filesize_bytes >= 2097152 ), array( 'warn_msg' => 'PHP\'s maximum file upload size is set to '. $upload_max_filesize .'. For your convenience, we recommend that this value is set to at least 2 MB.' ) );
$post_max_size_bytes = $this->return_bytes( ini_get('post_max_size') );
$checks_html .= $this->check_row_start( 'Maximum POST Size ('. $this->format_size( $post_max_size_bytes ) .')' );
$checks_html .= $this->check_row_end( ( $post_max_size_bytes >= $upload_max_filesize_bytes ), array( 'warn_msg' => 'PHP\'s maximum POST size is less than the maximum file upload size, therefore your file uploads will be limited to '. $this->format_size( $post_max_size_bytes ) .'.' ) );
}
$checks_html .= "</table>
<br />
<div class='groupbox'>File & Folder Permissions</div>
<table width='100%' cellpadding='0' cellspacing='0'>";
if ( ! $config_file = file_exists( TD_PATH .'config.php' ) )
{
if ( ! $config_file_dist = file_exists( TD_PATH .'config.php.dist' ) )
{
$checks_html .= $this->check_row_start( 'Configuration Filea' );
$checks_html .= $this->check_row_end( $config_file_dist, array( 'fail_msg' => 'Trellis Desk could not locate <i>'. TD_PATH .'config.php</i>. Please upload <i>config.php.dist</i> and rename it to <i>config.php</i>.' ) );
}
else
{
if ( ! @rename( TD_PATH .'config.php.dist', TD_PATH .'config.php' ) )
{
$checks_html .= $this->check_row_start( 'Configuration File' );
$checks_html .= $this->check_row_end( 0, array( 'fail_msg' => 'Trellis Desk coult not rename <i>'. TD_PATH .'config.php.dist</i>. Please rename <i>config.php.dist</i> to <i>config.php</i>.' ) );
}
else
{
$config_file = true;
}
}
}
if ( $config_file )
{
if ( ! is_writable( TD_PATH .'config.php' ) ) @chmod( TD_PATH .'config.php', 0777 );
$checks_html .= $this->check_row_start( 'Configuration File' );
$checks_html .= $this->check_row_end( is_writable( TD_PATH .'config.php' ), array( 'fail_msg' => 'Trellis Desk does not have permission to write to <i>'. TD_PATH .'config.php</i>. Please CHMOD this file to 0777.' ) );
}
$check_perms = array(
array( 'title' => 'Cache Folders', 'path' => $this->trellis->config['cache_path'], 'check' => array( $this->trellis->config['cache_path'] .'htmlpurifier', $this->trellis->config['cache_path'] .'trellis' ) ),
array( 'title' => 'Data Folder', 'path' => $this->trellis->config['data_path'] ),
array( 'title' => 'Languages Folder', 'path' => TD_PATH .'languages/' ),
array( 'title' => 'Logs Folder', 'path' => $this->trellis->config['logs_path'] ),
array( 'title' => 'Skins Folder', 'path' => TD_PATH .'skins/' ),
array( 'title' => 'Skin Compile Folder', 'path' => $this->trellis->config['skin_compile_path'] ),
array( 'title' => 'Temp Folder', 'path' => $this->trellis->config['temp_path'] ),
);
if ( $file_uploads ) $check_perms[] = array( 'title' => 'Uploads Folder', 'path' => $this->trellis->config['data_path'] .'uploads/' );
foreach ( $check_perms as &$ck )
{
$checks_html .= $this->check_row_start( $ck['title'] );
if ( ! is_writable( $ck['path'] ) ) @chmod( $ck['path'], 0777 );
if ( ! $path_writeable = is_writable( $ck['path'] ) )
{
$checks_html .= $this->check_row_end( $path_writeable, array( 'fail_msg' => 'Trellis Desk does not have permission to write to <i>'. substr( $ck['path'], 0, -1 ) .'</i>. Please CHMOD this folder to 0777.' ) );
continue;
}
$checks_failed = array();
if ( is_array( $ck['check'] ) )
{
foreach ( $ck['check'] as $path )
{
if ( ! is_writable( $path ) ) @chmod( $path, 0777 );
if ( ! is_writable( $path ) ) $checks_failed[] = $path;
}
if ( ! empty( $checks_failed ) )
{
$checks_html .= $this->check_row_end( false, array( 'fail_msg' => 'Trellis Desk does not have permission to write to <i>'. implode( ', ', $checks_failed ) .'</i>. Please CHMOD '. ( ( count( $checks_failed ) > 1 ) ? 'these files / folders' : 'this file / folder' ) .' to 0777.' ) );
}
}
if ( empty( $checks_failed ) ) $checks_html .= $this->check_row_end( true );
}
# TODO: check for whirlpool hash
$checks_html .= "</table>";
// Write to Install Cache
if ( ! $this->checks_fatal )
{
$this->trellis->initialize();
$this->trellis->cache->add( 'install', array( 'do_checks' => 1 ) );
}
#=============================
# Do Output
#=============================
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->group_title( 'Installed Software & Configuration' ) ."
". $checks_html ."
". $this->trellis->skin->formtail( '<a href="index.php" class="button">« Previous</a> <a href="index.php?step=check" class="button">Check Again</a>'. ( ( ! $this->checks_fatal ) ? ' <a href="index.php?step=1" class="button">Next »</a>' : '' ) ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 'check' );
$this->trellis->skin->set_progress_bar( 3 );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 1
#=======================================
private function step_1()
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Do Output
#=============================
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->group_title( 'Guided or Advanced' ) ."
". $this->trellis->skin->group_row_with_p( '<p>The Install Center offers you two ways to complete your Trellis Desk installation. You can choose to continue with the guided installation, or select the advanced option if you are a more experienced user. The guided installation will take you through a few more steps and allow you to configure common settings and features. The advanced installation will allow you to finish in fewer steps, while only collecting information necessary to complete the installation. We strongly recommend the guided installation for new users.</p>' ) ."
". $this->trellis->skin->formtail( '<a href="index.php?step=check" class="button">« Previous</a> <a href="index.php?step=adv" class="button">Advanced »</a> <a href="index.php?step=2" class="button">Guided »</a>' ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 1 );
$this->trellis->skin->set_progress_bar( 15 );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 2
#=======================================
private function step_2($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Prepopulate
#=============================
$prepopulate = array();
if ( ! isset( $this->trellis->cache->data['install']['config']['db_host'] ) ) ( $this->trellis->config['db_host'] ) ? $prepopulate['db_host'] = $this->trellis->config['db_host'] : $prepopulate['db_host'] = 'localhost';
if ( ! isset( $this->trellis->cache->data['install']['config']['db_port'] ) ) ( $this->trellis->config['db_port'] ) ? $prepopulate['db_port'] = $this->trellis->config['db_port'] : $prepopulate['db_port'] = 3306;
if ( ! isset( $this->trellis->cache->data['install']['config']['db_user'] ) ) if ( $this->trellis->config['db_user'] ) $prepopulate['db_user'] = $this->trellis->config['db_user'];
if ( ! isset( $this->trellis->cache->data['install']['config']['db_pass'] ) ) if ( $this->trellis->config['db_pass'] ) $prepopulate['db_pass'] = $this->trellis->config['db_pass'];
if ( ! isset( $this->trellis->cache->data['install']['config']['db_name'] ) ) if ( $this->trellis->config['db_name'] ) $prepopulate['db_name'] = $this->trellis->config['db_name'];
if ( ! isset( $this->trellis->cache->data['install']['config']['db_prefix'] ) ) ( $this->trellis->config['db_prefix'] ) ? $prepopulate['db_prefix'] = $this->trellis->config['db_prefix'] : $prepopulate['db_prefix'] = 'td_';
if ( ! empty( $prepopulate ) )
{
$prepopulate = array_merge( (array)$this->trellis->cache->data['install']['config'], $prepopulate );
$this->trellis->cache->add( 'install', array( 'config' => $prepopulate ) );
}
#=============================
# Do Output
#=============================
if ( $params['error'] )
{
$this->output .= $this->trellis->skin->error_wrap( $params['error'] );
$this->trellis->skin->preserve_input = 1;
}
# TODO: add help tooltips where necessary (apply to all install pages)
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->start_form( "index.php?step=3", 'db_info', 'post' ) ."
". $this->trellis->skin->start_group_table( 'Database Setup', 'a' ) ."
". $this->trellis->skin->group_table_full_row_with_p( '<p>Trellis Desk requires a MySQL database to store your data such as users and tickets. Please enter your database information below. If you are unsure about this information, contact your hosting provider.', 'a' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Host', $this->trellis->skin->textfield( array( 'name' => 'db_host', 'value' => $this->trellis->cache->data['install']['config']['db_host'] ) ), 'a', '25%', '75%' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Port', $this->trellis->skin->textfield( array( 'name' => 'db_port', 'value' => $this->trellis->cache->data['install']['config']['db_port'], 'length' => 5 ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Username', $this->trellis->skin->textfield( array( 'name' => 'db_user', 'value' => $this->trellis->cache->data['install']['config']['db_user'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Password', $this->trellis->skin->password( array( 'name' => 'db_pass', 'value' => $this->trellis->cache->data['install']['config']['db_pass'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Database', $this->trellis->skin->textfield( array( 'name' => 'db_name', 'value' => $this->trellis->cache->data['install']['config']['db_name'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'MySQL Table Prefix', $this->trellis->skin->textfield( array( 'name' => 'db_prefix', 'value' => $this->trellis->cache->data['install']['config']['db_prefix'], 'length' => 5 ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
". $this->trellis->skin->end_form( '<a href="index.php?step=1" class="button">« Previous</a> '. $this->trellis->skin->submit_button( 'store_db', 'Next »' ) ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 2 );
$this->trellis->skin->set_progress_bar( $this->get_progress() );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 3
#=======================================
private function step_3($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Store Data
#=============================
if ( $this->trellis->input['store_db'] )
{
$config = array(
'db_host' => $_POST['db_host'],
'db_port' => $_POST['db_port'],
'db_user' => $_POST['db_user'],
'db_pass' => $_POST['db_pass'],
'db_name' => $_POST['db_name'],
'db_prefix' => $_POST['db_prefix'],
);
$this->trellis->cache->add( 'install', array( 'config' => $config, 'info_db' => 0 ) );
#=============================
# Check MySQL
#=============================
# CHECK: is db_port working? no matter what port i set it to, it always connects. maybe php always uses a default port?
# TODO: validate db_prefix (not harmful to sql query, etc)
if ( ! @mysql_connect( $this->trellis->cache->data['install']['config']['db_host'] .':'. $this->trellis->cache->data['install']['config']['db_port'], $this->trellis->cache->data['install']['config']['db_user'], $this->trellis->cache->data['install']['config']['db_pass'] ) ) $this->step_2( array( 'error' => 'Could not connect to the MySQL Server. Please check to verify that your MySQL information is correct and try again.' ) );
$mysql_ver = mysql_get_server_info();
if ( strpos( $mysql_ver, '-' ) ) $mysql_ver = substr( $mysql_ver, 0, strpos( $mysql_ver, '-' ) );
if ( version_compare( $mysql_ver, '4.1', '<' ) ) $this->step_2( array( 'error' => 'Sorry, Trellis Desk cannot be installed as it requires MySQL version 4.1 or later.' ) );
if ( ! @mysql_select_db( $this->trellis->cache->data['install']['config']['db_name'] ) ) $this->step_2( array( 'error' => 'Could not connect to the MySQL Database. Please check that your MySQL credentails are correct and try again.' ) );
$this->trellis->cache->add( 'install', array( 'info_db' => 1 ) );
}
#=============================
# Prepopulate
#=============================
$prepopulate = array();
if ( ! isset( $this->trellis->cache->data['install']['admin']['time_dst'] ) ) $prepopulate['time_dst'] = 2;
if ( ! isset( $this->trellis->cache->data['install']['admin']['rte_enable'] ) ) $prepopulate['rte_enable'] = 1;
if ( ! empty( $prepopulate ) )
{
$prepopulate = array_merge( (array)$this->trellis->cache->data['install']['admin'], $prepopulate );
$this->trellis->cache->add( 'install', array( 'admin' => $prepopulate ) );
}
#=============================
# Do Output
#=============================
if ( $params['error'] )
{
$this->output .= $this->trellis->skin->error_wrap( $params['error'] );
$this->trellis->skin->preserve_input = 1;
}
$this->trellis->load_functions('drop_downs');
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->start_form( "index.php?step=4", 'admin_info', 'post' ) ."
". $this->trellis->skin->start_group_table( 'Create Admin User', 'a' ) ."
". $this->trellis->skin->group_table_full_row_with_p( '<p>You will now create your admin user for your Trellis Desk installation. This user has the highest level of access and always overrides any restrictive permissions. Please choose these credentials carefully.', 'a' ) ."
". $this->trellis->skin->group_table_row( 'Username', $this->trellis->skin->textfield( array( 'name' => 'admin_name', 'value' => $this->trellis->cache->data['install']['admin']['name'] ) ), 'a', '25%', '75%' ) ."
". $this->trellis->skin->group_table_row( 'Email', $this->trellis->skin->textfield( array( 'name' => 'admin_email', 'value' => $this->trellis->cache->data['install']['admin']['email'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Password', $this->trellis->skin->password( array( 'name' => 'admin_pass', 'value' => $this->trellis->cache->data['install']['admin']['pass'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Password Confirm', $this->trellis->skin->password( array( 'name' => 'admin_pass_b', 'value' => $this->trellis->cache->data['install']['admin']['pass'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Time Zone', "<select name='admin_time_zone' id='admin_time_zone'>". $this->trellis->func->drop_downs->time_zone_drop( $this->trellis->cache->data['install']['admin']['time_zone'], 0) ."</select>", 'a' ) ."
". $this->trellis->skin->group_table_row( 'Daylight Savings', $this->trellis->skin->custom_radio( 'admin_time_dst', array( 0 => 'Inactive', 1 => 'Active', 2 => 'Auto' ), $this->trellis->cache->data['install']['admin']['time_dst'] ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Rich Text Editor', $this->trellis->skin->enabled_disabled_radio( array( 'name' => 'admin_rte_enable', 'value' => $this->trellis->cache->data['install']['admin']['rte_enable'] ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
". $this->trellis->skin->end_form( '<a href="index.php?step=2" class="button">« Previous</a> '. $this->trellis->skin->submit_button( 'store_admin', 'Next »' ) ) ."
</div>";
$validate_fields = array(
'admin_name' => array( array( 'type' => 'presence' ) ),
'admin_email' => array( array( 'type' => 'presence' ), array( 'type' => 'email' ) ),
'admin_pass' => array( array( 'type' => 'presence' ) ),
'admin_pass_b' => array( array( 'type' => 'presence' ), array( 'type' => 'match', 'params' => array( 'against' => 'admin_pass' ) ) ),
);
$this->output .= $this->trellis->skin->live_validation_js( $validate_fields );
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 3 );
$this->trellis->skin->set_progress_bar( $this->get_progress() );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 4
#=======================================
private function step_4($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Store Data
#=============================
if ( $this->trellis->input['store_admin'] )
{
$admin = array(
'name' => $this->trellis->input['admin_name'],
'email' => $this->trellis->input['admin_email'],
'pass' => $this->trellis->input['admin_pass'],
'time_zone' => $this->trellis->input['admin_time_zone'],
'time_dst' => $this->trellis->input['admin_time_dst'],
'rte_enable' => $this->trellis->input['admin_rte_enable'],
);
$this->trellis->cache->add( 'install', array( 'admin' => $admin, 'info_admin' => 0 ) );
#=============================
# Check Admin
#=============================
if ( ! $this->trellis->cache->data['install']['admin']['name'] ) $this->step_3( array( 'error' => 'Please enter a username.' ) );
if ( ! $this->trellis->cache->data['install']['admin']['email'] ) $this->step_3( array( 'error' => 'Please enter an email address.' ) );
if ( ! $this->trellis->cache->data['install']['admin']['pass'] ) $this->step_3( array( 'error' => 'Please enter a password.' ) );
if ( ! $this->trellis->validate_email( $this->trellis->cache->data['install']['admin']['email'] ) ) $this->step_3( array( 'error' => 'Please enter a valid email address.' ) );
if ( $this->trellis->input['admin_pass'] != $this->trellis->input['admin_pass_b'] ) $this->step_3( array( 'error' => 'Your passwords do not match.' ) );
$this->trellis->cache->add( 'install', array( 'info_admin' => 1 ) );
}
#=============================
# Prepopulate
#=============================
$prepopulate = array();
if ( ! isset( $this->trellis->cache->data['install']['antispam']['port'] ) ) $prepopulate['port'] = 80;
if ( ! isset( $this->trellis->cache->data['install']['antispam']['protect_registration'] ) ) $prepopulate['protect_registration'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['antispam']['protect_tickets'] ) ) $prepopulate['protect_tickets'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['antispam']['protect_forgot_pass'] ) ) $prepopulate['protect_forgot_pass'] = 1;
if ( ! empty( $prepopulate ) )
{
$prepopulate = array_merge( (array)$this->trellis->cache->data['install']['antispam'], $prepopulate );
$this->trellis->cache->add( 'install', array( 'antispam' => $prepopulate ) );
}
#=============================
# Do Output
#=============================
if ( $params['error'] )
{
$this->output .= $this->trellis->skin->error_wrap( $params['error'] );
$this->trellis->skin->preserve_input = 1;
}
# TODO: update More information link
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->start_form( "index.php?step=5", 'antispam_info', 'post' ) ."
". $this->trellis->skin->start_group_table( 'Configure Anti-Spam Settings', 'a' ) ."
". $this->trellis->skin->group_table_full_row_with_p( '<p>Trellis Desk offers three methods to fight spam: <a href="http://akismet.com/">Akismet</a>, <a href="http://www.ejeliot.com/pages/php-captcha">PhpCatpcha</a>, and <a href="http://recaptcha.net/">reCAPTCHA</a>. You can choose to enable and configure one of these methods below. <a href="#">More information.</a></p><p>After you have installed Trellis Desk, please verify that your anti-spam method works correctly (if enabled). You can make any necessary changes to the settings in the ACP.</p>', 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable Anti-Spam', $this->trellis->skin->yes_no_radio( array( 'name' => 'antispam_enable', 'value' => $this->trellis->cache->data['install']['antispam']['enable'] ) ), 'a', '30%', '70%' ) ."
". $this->trellis->skin->group_table_row( 'Method', $this->trellis->skin->drop_down( array( 'name' => 'antispam_method', 'options' => array( 'akismet' => 'Akismet', 'phpcaptcha' => 'PhpCaptcha', 'recaptcha' => 'reCAPTCHA' ), 'value' => $this->trellis->cache->data['install']['antispam']['method'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Akismet Key', $this->trellis->skin->textfield( array( 'name' => 'antispam_akismet_key', 'value' => $this->trellis->cache->data['install']['antispam']['akismet_key'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'reCAPTCHA Public Key', $this->trellis->skin->textfield( array( 'name' => 'antispam_recaptcha_key_public', 'value' => $this->trellis->cache->data['install']['antispam']['recaptcha_key_public'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'reCAPTCHA Private Key', $this->trellis->skin->textfield( array( 'name' => 'antispam_recaptcha_key_private', 'value' => $this->trellis->cache->data['install']['antispam']['recaptcha_key_private'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'API Port', $this->trellis->skin->textfield( array( 'name' => 'antispam_port', 'value' => $this->trellis->cache->data['install']['antispam']['port'], 'length' => 5 ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Use SSL', $this->trellis->skin->yes_no_radio( array( 'name' => 'antispam_ssl', 'value' => $this->trellis->cache->data['install']['antispam']['ssl'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Protect Registration Form', $this->trellis->skin->yes_no_radio( array( 'name' => 'antispam_protect_registration', 'value' => $this->trellis->cache->data['install']['antispam']['protect_registration'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Protect Guest Ticket Form', $this->trellis->skin->yes_no_radio( array( 'name' => 'antispam_protect_tickets', 'value' => $this->trellis->cache->data['install']['antispam']['protect_tickets'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Protect Forgot Password Form', $this->trellis->skin->yes_no_radio( array( 'name' => 'antispam_protect_forgot_pass', 'value' => $this->trellis->cache->data['install']['antispam']['protect_forgot_pass'] ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
". $this->trellis->skin->end_form( '<a href="index.php?step=3" class="button">« Previous</a> '. $this->trellis->skin->submit_button( 'store_antispam', 'Next »' ) ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 4 );
$this->trellis->skin->set_progress_bar( $this->get_progress() );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 5
#=======================================
private function step_5($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Store Data
#=============================
if ( $this->trellis->input['store_antispam'] )
{
$antispam = array(
'enable' => $this->trellis->input['antispam_enable'],
'method' => $this->trellis->input['antispam_method'],
'akismet_key' => $this->trellis->input['antispam_akismet_key'],
'recaptcha_key_public' => $this->trellis->input['antispam_recaptcha_key_public'],
'recaptcha_key_private' => $this->trellis->input['antispam_recaptcha_key_private'],
'port' => $this->trellis->input['antispam_port'],
'ssl' => $this->trellis->input['antispam_ssl'],
'protect_registration' => $this->trellis->input['antispam_protect_registration'],
'protect_tickets' => $this->trellis->input['antispam_protect_tickets'],
'protect_forgot_pass' => $this->trellis->input['antispam_protect_forgot_pass'],
);
$this->trellis->cache->add( 'install', array( 'antispam' => $antispam, 'info_antispam' => 0 ) );
#=============================
# Check Antispam
#=============================
if ( $this->trellis->cache->data['install']['antispam']['enable'] )
{
$this->trellis->load_antispam_from_array( $this->trellis->cache->data['install']['antispam'] );
if ( ! $this->trellis->antispam->check_system() ) $this->step_4( array( 'error' => $this->trellis->antispam->get_error() ) );
}
$this->trellis->cache->add( 'install', array( 'info_antispam' => 1 ) );
}
#=============================
# Prepopulate
#=============================
$prepopulate = array();
if ( ! isset( $this->trellis->cache->data['install']['email']['enable'] ) ) $prepopulate['enable'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['email']['out_address'] ) && $this->trellis->cache->data['install']['admin']['email'] ) $prepopulate['out_address'] = $this->trellis->cache->data['install']['admin']['email'];
if ( ! isset( $this->trellis->cache->data['install']['email']['smtp_host'] ) ) $prepopulate['smtp_host'] = 'localhost';
if ( ! isset( $this->trellis->cache->data['install']['email']['smtp_port'] ) ) $prepopulate['smtp_port'] = 25;
if ( ! isset( $this->trellis->cache->data['install']['email']['smtp_timeout'] ) ) $prepopulate['smtp_timeout'] = 10;
if ( ! isset( $this->trellis->cache->data['install']['email']['html'] ) ) $prepopulate['html'] = 1;
if ( ! empty( $prepopulate ) )
{
$prepopulate = array_merge( (array)$this->trellis->cache->data['install']['email'], $prepopulate );
$this->trellis->cache->add( 'install', array( 'email' => $prepopulate ) );
}
#=============================
# Do Output
#=============================
if ( $params['error'] )
{
$this->output .= $this->trellis->skin->error_wrap( $params['error'] );
$this->trellis->skin->preserve_input = 1;
}
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->start_form( "index.php?step=6", 'email_info', 'post' ) ."
". $this->trellis->skin->start_group_table( 'Configure Email Settings', 'a' ) ."
". $this->trellis->skin->group_table_full_row_with_p( '<p>Configure your outgoing email settings below (used for email notifications, email verification messages, mass emails, etc).</p><p>After you have installed Trellis Desk, please verify that your outgoing emails work correctly (if enabled). You can make any necessary changes to the settings in the ACP.</p>', 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable Outgoing Emails', $this->trellis->skin->yes_no_radio( array( 'name' => 'email_enable', 'value' => $this->trellis->cache->data['install']['email']['enable'] ) ), 'a', '30%', '70%' ) ."
". $this->trellis->skin->group_table_row( 'Outgoing Email Address', $this->trellis->skin->textfield( array( 'name' => 'email_out_address', 'value' => $this->trellis->cache->data['install']['email']['out_address'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Method', $this->trellis->skin->drop_down( array( 'name' => 'email_transport', 'options' => array( 'smtp' => 'SMTP', 'sendmail' => 'Sendmail', 'mail' => 'Mail' ), 'value' => $this->trellis->cache->data['install']['email']['transport'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Host', $this->trellis->skin->textfield( array( 'name' => 'email_smtp_host', 'value' => $this->trellis->cache->data['install']['email']['smtp_host'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Port', $this->trellis->skin->textfield( array( 'name' => 'email_smtp_port', 'value' => $this->trellis->cache->data['install']['email']['smtp_port'], 'length' => 5 ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Username', $this->trellis->skin->textfield( array( 'name' => 'email_smtp_user', 'value' => $this->trellis->cache->data['install']['email']['smtp_user'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Password', $this->trellis->skin->password( array( 'name' => 'email_smtp_pass', 'value' => $this->trellis->cache->data['install']['email']['smtp_pass'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Encryption', $this->trellis->skin->drop_down( array( 'name' => 'email_smtp_encryption', 'options' => array( 0 => 'None', 'ssl' => 'SSL', 'tls' => 'TLS' ), 'value' => $this->trellis->cache->data['install']['email']['smtp_encryption'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'SMTP Timeout', $this->trellis->skin->textfield( array( 'name' => 'email_smtp_timeout', 'value' => $this->trellis->cache->data['install']['email']['smtp_timeout'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Sendmail Path / Command', $this->trellis->skin->textfield( array( 'name' => 'email_sendmail_command', 'value' => $this->trellis->cache->data['install']['email']['sendmail_command'], 'length' => 5 ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable HTML Emails', $this->trellis->skin->yes_no_radio( array( 'name' => 'email_html', 'value' => $this->trellis->cache->data['install']['email']['html'] ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
". $this->trellis->skin->end_form( '<a href="index.php?step=4" class="button">« Previous</a> '. $this->trellis->skin->submit_button( 'store_email', 'Next »' ) ) ."
</div>";
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 5 );
$this->trellis->skin->set_progress_bar( $this->get_progress() );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 6
#=======================================
private function step_6($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Store Data
#=============================
if ( $this->trellis->input['store_email'] )
{
$email = array(
'enable' => $this->trellis->input['email_enable'],
'out_address' => $this->trellis->input['email_out_address'],
'transport' => $this->trellis->input['email_transport'],
'smtp_host' => $this->trellis->input['email_smtp_host'],
'smtp_port' => $this->trellis->input['email_smtp_port'],
'smtp_user' => $this->trellis->input['email_smtp_user'],
'smtp_pass' => $this->trellis->input['email_smtp_pass'],
'smtp_encryption' => $this->trellis->input['email_smtp_encryption'],
'smtp_timeout' => $this->trellis->input['email_smtp_timeout'],
'sendmail_command' => $this->trellis->input['email_sendmail_command'],
'html' => $this->trellis->input['email_html'],
);
$this->trellis->cache->add( 'install', array( 'email' => $email, 'info_email' => 0 ) );
#=============================
# Check Email
#=============================
if ( $this->trellis->cache->data['install']['email']['enable'] && ( $this->trellis->cache->data['install']['email']['transport'] == 'smtp' || $this->trellis->cache->data['install']['email']['transport'] == 'sendmail' ) )
{
$this->trellis->load_email_from_array( $this->trellis->cache->data['install']['email'] );
if ( ! $this->trellis->email->test() )
{
if ( $this->trellis->cache->data['install']['email']['transport'] == 'smtp' )
{
$transports = stream_get_transports();
( $this->trellis->cache->data['install']['email']['smtp_encryption'] ) ? $tp = $this->trellis->cache->data['install']['email']['smtp_encryption'] : $tp = 'tcp';
if ( ! in_array( $tp, $transports ) )
{
if ( $this->trellis->cache->data['install']['email']['smtp_encryption'] == 'tls' )
{
$error_msg = 'Unable to connect to SMTP server. TLS transport is not supported by server.';
}
elseif ( $this->trellis->cache->data['install']['email']['smtp_encryption'] == 'ssl' )
{
$error_msg = 'Unable to connect to SMTP server. SSL transport is not supported by server.';
}
else
{
$error_msg = 'Unable to connect to SMTP server. TCP transport is not supported by server.';
}
}
else
{
$error_msg = 'Unable to connect to SMTP server.';
}
if ( $this->trellis->email->get_exception() ) $error_msg .= ' The following error was returned.<br /><br />'. $this->trellis->email->get_exception();
}
elseif ( $this->trellis->cache->data['install']['email']['transport'] == 'sendmail' )
{
$error_msg = 'Unable to connect to Sendmail transport.';
}
$this->step_5( array( 'error' => $error_msg ) );
}
}
$this->trellis->cache->add( 'install', array( 'info_email' => 1 ) );
}
#=============================
# Prepopulate
#=============================
$prepopulate = array();
if ( ! isset( $this->trellis->cache->data['install']['other']['pass_key'] ) ) if ( $this->trellis->config['pass_key'] ) $prepopulate['pass_key'] = $this->trellis->config['pass_key'];
if ( ! isset( $this->trellis->cache->data['install']['other']['cookie_key'] ) ) if ( $this->trellis->config['cookie_key'] ) $prepopulate['cookie_key'] = $this->trellis->config['cookie_key'];
if ( ! isset( $this->trellis->cache->data['install']['other']['session_key'] ) ) if ( $this->trellis->config['session_key'] ) $prepopulate['session_key'] = $this->trellis->config['session_key'];
if ( ! isset( $this->trellis->cache->data['install']['other']['rss_key'] ) ) if ( $this->trellis->config['rss_key'] ) $prepopulate['rss_key'] = $this->trellis->config['rss_key'];
if ( ! isset( $this->trellis->cache->data['install']['other']['hd_name'] ) ) $prepopulate['hd_name'] = 'Trellis Desk';
if ( ! isset( $this->trellis->cache->data['install']['other']['validation_email'] ) ) $prepopulate['validation_email'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['ticket_mask'] ) ) $prepopulate['ticket_mask'] = '%A%A%A-%n%n%n%n';
if ( ! isset( $this->trellis->cache->data['install']['other']['ticket_suggest'] ) ) $prepopulate['ticket_suggest'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['reply_rating'] ) ) $prepopulate['reply_rating'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['news_comments'] ) ) $prepopulate['news_comments'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['kb_comments'] ) ) $prepopulate['kb_comments'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['kb_rating'] ) ) $prepopulate['kb_rating'] = 1;
if ( ! isset( $this->trellis->cache->data['install']['other']['vcheck_share'] ) ) $prepopulate['vcheck_share'] = 2;
if ( ! isset( $this->trellis->cache->data['install']['other']['hd_url'] ) )
{
$url = str_replace( "/install/index.php", "", $_SERVER['HTTP_REFERER'] );
$url = str_replace( "/install/", "", $url );
$url = str_replace( "/install", "", $url );
$url = str_replace( "index.php", "", $url );
$url = substr( $url, 0, strpos( $url, '?' ) );
$url = str_replace( "?", "", $url );
$prepopulate['hd_url'] = $url;
}
if ( ! empty( $prepopulate ) )
{
$prepopulate = array_merge( (array)$this->trellis->cache->data['install']['other'], $prepopulate );
$this->trellis->cache->add( 'install', array( 'other' => $prepopulate ) );
}
#=============================
# Do Output
#=============================
if ( $params['error'] )
{
$this->output .= $this->trellis->skin->error_wrap( $params['error'] );
$this->trellis->skin->preserve_input = 1;
}
# TODO: without trailing slash on help desk url reminder
# TODO: add absolute path?
# TODO: add option to generate random keys
$this->output .= "<div id='ticketroll'>
". $this->trellis->skin->start_form( "index.php?step=7", 'other_info', 'post' ) ."
". $this->trellis->skin->start_group_table( 'Security', 'a' ) ."
". $this->trellis->skin->group_table_full_row_with_p( '<p>Trellis Desk encryptions sensitive information such as passwords. Keys (salts) are used during encryption to increase security. Please enter a unique string for each security key below. Each key can be a sentence, phrase, random characters / numbers, etc.</p>', 'a' ) ."
". $this->trellis->skin->group_table_row( 'Password Key', $this->trellis->skin->textfield( array( 'name' => 'other_pass_key', 'value' => $this->trellis->cache->data['install']['other']['pass_key'] ) ), 'a', '30%', '70%' ) ."
". $this->trellis->skin->group_table_row( 'Cookie Key', $this->trellis->skin->textfield( array( 'name' => 'other_cookie_key', 'value' => $this->trellis->cache->data['install']['other']['cookie_key'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Session Key', $this->trellis->skin->textfield( array( 'name' => 'other_session_key', 'value' => $this->trellis->cache->data['install']['other']['session_key'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'RSS Key', $this->trellis->skin->textfield( array( 'name' => 'other_rss_key', 'value' => $this->trellis->cache->data['install']['other']['rss_key'] ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
<br />
". $this->trellis->skin->start_group_table( 'Common Settings', 'a' ) ."
". $this->trellis->skin->group_table_row( 'Help Desk Name', $this->trellis->skin->textfield( array( 'name' => 'other_hd_name', 'value' => $this->trellis->cache->data['install']['other']['hd_name'] ) ), 'a', '30%', '70%' ) ."
". $this->trellis->skin->group_table_row( 'Help Desk URL', $this->trellis->skin->textfield( array( 'name' => 'other_hd_url', 'value' => $this->trellis->cache->data['install']['other']['hd_url'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Require Email Validation', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_validation_email', 'value' => $this->trellis->cache->data['install']['other']['validation_email'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Require Admin Validation', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_validation_admin', 'value' => $this->trellis->cache->data['install']['other']['validation_admin'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Ticket Mask', $this->trellis->skin->textfield( array( 'name' => 'other_ticket_mask', 'value' => $this->trellis->cache->data['install']['other']['ticket_mask'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable KB Suggestions', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_ticket_suggest', 'value' => $this->trellis->cache->data['install']['other']['ticket_suggest'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable Reply Rating', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_reply_rating', 'value' => $this->trellis->cache->data['install']['other']['reply_rating'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable News Comments', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_news_comments', 'value' => $this->trellis->cache->data['install']['other']['news_comments'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable KB Comments', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_kb_comments', 'value' => $this->trellis->cache->data['install']['other']['kb_comments'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Enable KB Rating', $this->trellis->skin->yes_no_radio( array( 'name' => 'other_kb_rating', 'value' => $this->trellis->cache->data['install']['other']['kb_rating'] ) ), 'a' ) ."
". $this->trellis->skin->group_table_row( 'Share Statistics with ACCORD5', $this->trellis->skin->custom_radio( array( 'name' => 'other_vcheck_share', 'options' => array( 2 => 'Yes', 1 => 'Yes, Anonymously', 0 => 'No' ), 'value' => $this->trellis->cache->data['install']['other']['vcheck_share'] ) ), 'a' ) ."
". $this->trellis->skin->end_group_table( 'a' ) ."
". $this->trellis->skin->end_form( '<a href="index.php?step=5" class="button">« Previous</a> '. $this->trellis->skin->submit_button( 'store_other', 'Next »' ) ) ."
</div>";
$validate_fields = array(
'other_hd_name' => array( array( 'type' => 'presence' ) ),
'other_ticket_mask' => array( array( 'type' => 'presence' ) ),
);
$this->output .= $this->trellis->skin->live_validation_js( $validate_fields );
$this->trellis->skin->add_output( $this->output );
$this->trellis->skin->set_step( 6 );
$this->trellis->skin->set_progress_bar( $this->get_progress() );
$this->trellis->skin->do_output();
}
#=======================================
# @ Step 7
#=======================================
private function step_7($params=array())
{
$this->output = '';
if ( $this->trellis->config['start'] ) $this->already_installed();
#=============================
# Store Data
#=============================
if ( $this->trellis->input['store_other'] )
{
$other = array(
'pass_key' => $this->trellis->input['other_pass_key'],
'cookie_key' => $this->trellis->input['other_cookie_key'],
'session_key' => $this->trellis->input['other_session_key'],
'rss_key' => $this->trellis->input['other_rss_key'],
'hd_name' => $this->trellis->input['other_hd_name'],
'hd_url' => $this->trellis->input['other_hd_url'],
'validation_email' => $this->trellis->input['other_validation_email'],
'validation_admin' => $this->trellis->input['other_validation_admin'],
'ticket_mask' => $this->trellis->input['other_ticket_mask'],
'ticket_suggest' => $this->trellis->input['other_ticket_suggest'],
'reply_rating' => $this->trellis->input['other_reply_rating'],
'news_comments' => $this->trellis->input['other_news_comments'],
'kb_comments' => $this->trellis->input['other_kb_comments'],
'kb_rating' => $this->trellis->input['other_kb_rating'],
'vcheck_share' => $this->trellis->input['other_vcheck_share'],
);
$this->trellis->cache->add( 'install', array( 'other' => $other, 'info_other' => 0 ) );
#=============================
# Check Other
#=============================
if ( ! $this->trellis->cache->data['install']['other']['hd_name'] ) $this->step_6( array( 'error' => 'Please enter a help desk name.' ) );
if ( ! $this->trellis->cache->data['install']['other']['hd_url'] ) $this->step_6( array( 'error' => 'Please the help desk URL.' ) );
if ( ! $this->trellis->cache->data['install']['other']['ticket_mask'] ) $this->step_6( array( 'error' => 'Please enter a ticket mask.' ) );
# TODO: validate URL (check for appropriate format / characters)
$this->trellis->cache->add( 'install', array( 'info_other' => 1 ) );
}
#=============================
# Check Steps
#=============================
$steps = array( 'info_db' => 2, 'info_admin' => 3, 'info_antispam' => 4, 'info_email' => 5, 'info_other' => 6 );
foreach ( $steps as $sc => $sn )
{
if ( ! $this->trellis->cache->data['install'][ $sc ] )
{
$step_func = 'step_'. $sn;
$this->$step_func( array( 'error' => 'You must complete this step before continuing.' ) );
}