@@ -42,7 +42,7 @@ class Install extends Controller {
42
42
private $ account ;
43
43
protected $ min_php_version = MIN_PHP_VERSION ;
44
44
45
- protected $ cache ;
45
+ public $ cache ;
46
46
47
47
public function __construct ()
48
48
{
@@ -52,15 +52,15 @@ public function __construct()
52
52
$ this ->config ->load ('openvbx ' );
53
53
}
54
54
55
- if (file_exists (APPPATH . 'config/database.php ' )
56
- AND version_compare (PHP_VERSION , $ this ->min_php_version , '>= ' ))
55
+ if (file_exists (APPPATH . 'config/database.php ' )
56
+ AND version_compare (PHP_VERSION , $ this ->min_php_version , '>= ' ))
57
57
{
58
58
$ this ->load ->database ();
59
59
redirect ('' );
60
60
}
61
-
62
- // cache is evil when not handled properly, assume the
63
- // possibility that we're being reinstalled so lets clear
61
+
62
+ // cache is evil when not handled properly, assume the
63
+ // possibility that we're being reinstalled so lets clear
64
64
// any possibly lingering cache artifacts
65
65
$ this ->cache = OpenVBX_Cache_Abstract::load ();
66
66
$ this ->cache ->enabled (true );
@@ -84,7 +84,7 @@ private function input_args()
84
84
85
85
$ this ->openvbx_settings = array ();
86
86
$ this ->openvbx = array ();
87
-
87
+
88
88
$ this ->openvbx_settings ['twilio_sid ' ] = trim ($ this ->input ->post ('twilio_sid ' ));
89
89
$ this ->openvbx_settings ['twilio_token ' ] = trim ($ this ->input ->post ('twilio_token ' ));
90
90
$ this ->openvbx_settings ['connect_application_sid ' ] = trim ($ this ->input ->post ('connect_application_sid ' ));
@@ -145,7 +145,7 @@ private function run_tests()
145
145
'supported ' ,
146
146
'missing, but optional ' ,
147
147
false );
148
-
148
+
149
149
$ this ->add_test (extension_loaded ('memcache ' ),
150
150
'Memcache ' ,
151
151
'supported ' ,
@@ -168,7 +168,7 @@ private function run_tests()
168
168
'Config Dir ' ,
169
169
'writable ' ,
170
170
'permission denied: ' .APPPATH .'config ' );
171
-
171
+
172
172
$ this ->add_test (is_writable (APPPATH .'../audio-uploads ' ),
173
173
'Upload Dir ' ,
174
174
'writable ' ,
@@ -203,7 +203,7 @@ private function add_test($pass, $name, $pass_text, $fail_text, $required = true
203
203
'message ' => ($ pass ? $ pass_text : $ fail_text )
204
204
);
205
205
206
- if ($ required )
206
+ if ($ required )
207
207
{
208
208
$ this ->pass = $ this ->pass && $ pass ;
209
209
}
@@ -260,26 +260,26 @@ public function setup()
260
260
}
261
261
262
262
// test for mysqli compat
263
- if (function_exists ('mysqli_connect ' ))
263
+ if (function_exists ('mysqli_connect ' ))
264
264
{
265
265
// server info won't work without first selecting a table
266
266
mysql_select_db ($ database ['default ' ]['database ' ]);
267
267
$ server_version = mysql_get_server_info ($ dbh );
268
268
if (!empty ($ server_version )) {
269
- if (version_compare ($ server_version , '4.1.13 ' , '>= ' )
270
- && version_compare ($ server_version , '5 ' , '< ' ))
269
+ if (version_compare ($ server_version , '4.1.13 ' , '>= ' )
270
+ && version_compare ($ server_version , '5 ' , '< ' ))
271
271
{
272
272
$ database ['default ' ]['dbdriver ' ] = 'mysqli ' ;
273
273
}
274
- elseif (version_compare ($ server_version , '5.0.7 ' , '>= ' ))
274
+ elseif (version_compare ($ server_version , '5.0.7 ' , '>= ' ))
275
275
{
276
276
$ database ['default ' ]['dbdriver ' ] = 'mysqli ' ;
277
277
}
278
278
}
279
279
}
280
280
281
281
$ this ->setup_database ($ database , $ dbh );
282
- $ this ->setup_config ($ database , $ openvbx );
282
+ $ this ->setup_config ($ database , $ openvbx );
283
283
$ this ->setup_openvbx_settings ($ openvbx_settings );
284
284
$ this ->setup_user ($ user );
285
285
@@ -301,21 +301,21 @@ public function setup()
301
301
302
302
$ this ->json_return ($ json );
303
303
}
304
-
305
- private function setup_connect_app ($ settings )
304
+
305
+ private function setup_connect_app ($ settings )
306
306
{
307
307
try {
308
308
$ account = OpenVBX::getAccount ($ settings ['twilio_sid ' ], $ settings ['twilio_token ' ]);
309
309
$ connect_application = $ account ->connect_apps ->get ($ settings ['connect_application_sid ' ]);
310
-
310
+
311
311
if ($ connect_application ->sid == $ settings ['connect_application_sid ' ])
312
312
{
313
313
$ site_url = site_url ();
314
- if ($ settings ['rewrite_enabled ' ])
314
+ if ($ settings ['rewrite_enabled ' ])
315
315
{
316
316
$ site_url = str_replace ('/index.php ' , '' , $ site_url );
317
317
}
318
-
318
+
319
319
$ required_settings = array (
320
320
'HomepageUrl ' => $ site_url ,
321
321
'AuthorizeRedirectUrl ' => $ site_url .'/auth/connect ' ,
@@ -325,19 +325,19 @@ private function setup_connect_app($settings)
325
325
'post-all '
326
326
)
327
327
);
328
-
328
+
329
329
$ updated = false ;
330
- foreach ($ required_settings as $ key => $ setting )
330
+ foreach ($ required_settings as $ key => $ setting )
331
331
{
332
332
$ app_key = Services_Twilio::decamelize ($ key );
333
- if ($ connect_application ->$ app_key != $ setting )
333
+ if ($ connect_application ->$ app_key != $ setting )
334
334
{
335
335
$ connect_application ->$ app_key = $ setting ;
336
336
$ updated = true ;
337
337
}
338
338
}
339
339
340
- if ($ updated )
340
+ if ($ updated )
341
341
{
342
342
$ connect_application ->update (array (
343
343
'FriendlyName ' => $ connect_application ->friendly_name ,
@@ -375,7 +375,7 @@ private function setup_database($database, $dbh)
375
375
376
376
if (!mysql_query ($ sql , $ dbh ))
377
377
{
378
- throw new InstallException ( "Failed to run sql: " .$ sql . " :: " .
378
+ throw new InstallException ( "Failed to run sql: " .$ sql . " :: " .
379
379
mysql_error ($ dbh ), 2 );
380
380
}
381
381
}
@@ -512,38 +512,38 @@ private function setup_openvbx_settings($settings)
512
512
* Create one if necessary
513
513
*
514
514
* @throws InstallException
515
- * @param array $settings
515
+ * @param array $settings
516
516
* @return string Application Sid
517
517
*/
518
- private function get_application ($ settings )
518
+ private function get_application ($ settings )
519
519
{
520
520
try
521
521
{
522
522
$ app_token = md5 ($ _SERVER ['REQUEST_URI ' ]);
523
523
$ app_name = "OpenVBX - {$ app_token }" ;
524
524
525
- if (empty ($ this ->account ))
525
+ if (empty ($ this ->account ))
526
526
{
527
527
$ this ->account = OpenVBX::getAccount ($ settings ['twilio_sid ' ], $ settings ['twilio_token ' ]);
528
528
}
529
529
$ applications = $ this ->account ->applications ->getIterator (0 , 10 , array (
530
530
'FriendlyName ' => $ app_name
531
531
));
532
-
532
+
533
533
$ application = false ;
534
534
535
535
/** @var Services_Twilio_Rest_Application $_application */
536
536
foreach ($ applications as $ _application )
537
537
{
538
- if ($ _application ->friendly_name == $ app_name )
538
+ if ($ _application ->friendly_name == $ app_name )
539
539
{
540
540
$ application = $ _application ;
541
541
break ;
542
542
}
543
543
}
544
544
545
545
$ site_url = site_url ();
546
- if ($ settings ['rewrite_enabled ' ])
546
+ if ($ settings ['rewrite_enabled ' ])
547
547
{
548
548
$ site_url = str_replace ('/index.php ' , '' , $ site_url );
549
549
}
@@ -562,7 +562,7 @@ private function get_application($settings)
562
562
{
563
563
$ application ->update ($ params );
564
564
}
565
- else
565
+ else
566
566
{
567
567
$ application = $ this ->account ->applications ->create ($ app_name , $ params );
568
568
}
@@ -581,8 +581,8 @@ function validate()
581
581
$ json = array (
582
582
'success ' => true
583
583
);
584
-
585
- if ($ step == 1 )
584
+
585
+ if ($ step == 1 )
586
586
{
587
587
$ this ->json_return ($ json );
588
588
}
@@ -612,9 +612,9 @@ function validate()
612
612
function validate_step2 ()
613
613
{
614
614
$ json = array (
615
- 'success ' => true ,
616
- 'step ' => 2 ,
617
- 'message ' =>
615
+ 'success ' => true ,
616
+ 'step ' => 2 ,
617
+ 'message ' =>
618
618
'success '
619
619
);
620
620
@@ -661,10 +661,10 @@ function validate_step2()
661
661
function validate_step3 ()
662
662
{
663
663
$ this ->load ->model ('vbx_settings ' );
664
-
664
+
665
665
$ json = array (
666
- 'success ' => true ,
667
- 'step ' => 3 ,
666
+ 'success ' => true ,
667
+ 'step ' => 3 ,
668
668
'message ' => 'success '
669
669
);
670
670
$ twilio_sid = $ this ->openvbx_settings ['twilio_sid ' ];
@@ -681,20 +681,20 @@ function validate_step3()
681
681
* confident of success.
682
682
*/
683
683
$ status = $ account ->type ;
684
- if (empty ($ status ))
684
+ if (empty ($ status ))
685
685
{
686
686
throw new InstallException ('Unable to access Twilio Account ' );
687
687
}
688
688
689
689
// check the connect app if a sid is provided
690
- if (!empty ($ connect_app ))
690
+ if (!empty ($ connect_app ))
691
691
{
692
692
try {
693
693
$ connect_application = $ account ->connect_apps ->get ($ connect_app );
694
694
$ friendly_name = $ connect_application ->friendly_name ;
695
695
}
696
696
catch (Exception $ e ) {
697
- switch ($ e ->getCode ())
697
+ switch ($ e ->getCode ())
698
698
{
699
699
case 0 :
700
700
// return a better message than "resource not found"
@@ -711,7 +711,7 @@ function validate_step3()
711
711
{
712
712
$ json ['success ' ] = false ;
713
713
714
- switch ($ e ->getCode ())
714
+ switch ($ e ->getCode ())
715
715
{
716
716
case '20003 ' :
717
717
$ json ['message ' ] = 'Authentication Failed. Invalid Twilio SID or Token. ' ;
@@ -729,8 +729,8 @@ function validate_step3()
729
729
function validate_step4 ()
730
730
{
731
731
$ json = array (
732
- 'success ' => true ,
733
- 'step ' => 4 ,
732
+ 'success ' => true ,
733
+ 'step ' => 4 ,
734
734
'message ' => 'success '
735
735
);
736
736
$ this ->openvbx_settings ['from_email ' ] = trim ($ this ->input ->post ('from_email ' ));
@@ -742,7 +742,7 @@ function validate_step4()
742
742
throw new InstallException ('Email address is invalid. Please check the ' .
743
743
'address and try again. ' );
744
744
}
745
-
745
+
746
746
$ required_fields = array (
747
747
'from_email ' => 'Notification Sender Email Address '
748
748
);
@@ -767,8 +767,8 @@ function validate_step5()
767
767
$ ci =& get_instance ();
768
768
$ ci ->load ->model ('vbx_user ' );
769
769
$ json = array (
770
- 'success ' => true ,
771
- 'step ' => 5 ,
770
+ 'success ' => true ,
771
+ 'step ' => 5 ,
772
772
'message ' => 'success '
773
773
);
774
774
@@ -784,17 +784,17 @@ function validate_step5()
784
784
{
785
785
throw new InstallException ('Your administrative password was not typed correctly. ' );
786
786
}
787
-
787
+
788
788
if (strlen ($ this ->user ['password ' ]) < VBX_User::MIN_PASSWORD_LENGTH )
789
789
{
790
790
throw new InstallException ('Password must be at least ' .VBX_User::MIN_PASSWORD_LENGTH .' characters. ' );
791
791
}
792
-
792
+
793
793
if (!filter_var ($ this ->user ['email ' ], FILTER_VALIDATE_EMAIL ))
794
794
{
795
795
throw new InstallException ('Email address is invalid. Please check the address and try again. ' );
796
796
}
797
-
797
+
798
798
$ required_fields = array (
799
799
'email ' => 'Email Address ' ,
800
800
'password ' => 'Password ' ,
@@ -815,9 +815,9 @@ function validate_step5()
815
815
}
816
816
return $ json ;
817
817
}
818
-
818
+
819
819
/**
820
- * If .htaccess file doesn't exist try to preemptively
820
+ * If .htaccess file doesn't exist try to preemptively
821
821
* create one from the htaccess_dist file. Nothing special,
822
822
* just try to make a copy of the file. If it doesn't
823
823
* work it doesn't work.
0 commit comments