@@ -42,7 +42,7 @@ class Install extends Controller {
4242 private $ account ;
4343 protected $ min_php_version = MIN_PHP_VERSION ;
4444
45- protected $ cache ;
45+ public $ cache ;
4646
4747 public function __construct ()
4848 {
@@ -52,15 +52,15 @@ public function __construct()
5252 $ this ->config ->load ('openvbx ' );
5353 }
5454
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 , '>= ' ))
5757 {
5858 $ this ->load ->database ();
5959 redirect ('' );
6060 }
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
6464 // any possibly lingering cache artifacts
6565 $ this ->cache = OpenVBX_Cache_Abstract::load ();
6666 $ this ->cache ->enabled (true );
@@ -84,7 +84,7 @@ private function input_args()
8484
8585 $ this ->openvbx_settings = array ();
8686 $ this ->openvbx = array ();
87-
87+
8888 $ this ->openvbx_settings ['twilio_sid ' ] = trim ($ this ->input ->post ('twilio_sid ' ));
8989 $ this ->openvbx_settings ['twilio_token ' ] = trim ($ this ->input ->post ('twilio_token ' ));
9090 $ this ->openvbx_settings ['connect_application_sid ' ] = trim ($ this ->input ->post ('connect_application_sid ' ));
@@ -145,7 +145,7 @@ private function run_tests()
145145 'supported ' ,
146146 'missing, but optional ' ,
147147 false );
148-
148+
149149 $ this ->add_test (extension_loaded ('memcache ' ),
150150 'Memcache ' ,
151151 'supported ' ,
@@ -168,7 +168,7 @@ private function run_tests()
168168 'Config Dir ' ,
169169 'writable ' ,
170170 'permission denied: ' .APPPATH .'config ' );
171-
171+
172172 $ this ->add_test (is_writable (APPPATH .'../audio-uploads ' ),
173173 'Upload Dir ' ,
174174 'writable ' ,
@@ -203,7 +203,7 @@ private function add_test($pass, $name, $pass_text, $fail_text, $required = true
203203 'message ' => ($ pass ? $ pass_text : $ fail_text )
204204 );
205205
206- if ($ required )
206+ if ($ required )
207207 {
208208 $ this ->pass = $ this ->pass && $ pass ;
209209 }
@@ -260,26 +260,26 @@ public function setup()
260260 }
261261
262262 // test for mysqli compat
263- if (function_exists ('mysqli_connect ' ))
263+ if (function_exists ('mysqli_connect ' ))
264264 {
265265 // server info won't work without first selecting a table
266266 mysql_select_db ($ database ['default ' ]['database ' ]);
267267 $ server_version = mysql_get_server_info ($ dbh );
268268 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 ' , '< ' ))
271271 {
272272 $ database ['default ' ]['dbdriver ' ] = 'mysqli ' ;
273273 }
274- elseif (version_compare ($ server_version , '5.0.7 ' , '>= ' ))
274+ elseif (version_compare ($ server_version , '5.0.7 ' , '>= ' ))
275275 {
276276 $ database ['default ' ]['dbdriver ' ] = 'mysqli ' ;
277277 }
278278 }
279279 }
280280
281281 $ this ->setup_database ($ database , $ dbh );
282- $ this ->setup_config ($ database , $ openvbx );
282+ $ this ->setup_config ($ database , $ openvbx );
283283 $ this ->setup_openvbx_settings ($ openvbx_settings );
284284 $ this ->setup_user ($ user );
285285
@@ -301,21 +301,21 @@ public function setup()
301301
302302 $ this ->json_return ($ json );
303303 }
304-
305- private function setup_connect_app ($ settings )
304+
305+ private function setup_connect_app ($ settings )
306306 {
307307 try {
308308 $ account = OpenVBX::getAccount ($ settings ['twilio_sid ' ], $ settings ['twilio_token ' ]);
309309 $ connect_application = $ account ->connect_apps ->get ($ settings ['connect_application_sid ' ]);
310-
310+
311311 if ($ connect_application ->sid == $ settings ['connect_application_sid ' ])
312312 {
313313 $ site_url = site_url ();
314- if ($ settings ['rewrite_enabled ' ])
314+ if ($ settings ['rewrite_enabled ' ])
315315 {
316316 $ site_url = str_replace ('/index.php ' , '' , $ site_url );
317317 }
318-
318+
319319 $ required_settings = array (
320320 'HomepageUrl ' => $ site_url ,
321321 'AuthorizeRedirectUrl ' => $ site_url .'/auth/connect ' ,
@@ -325,19 +325,19 @@ private function setup_connect_app($settings)
325325 'post-all '
326326 )
327327 );
328-
328+
329329 $ updated = false ;
330- foreach ($ required_settings as $ key => $ setting )
330+ foreach ($ required_settings as $ key => $ setting )
331331 {
332332 $ app_key = Services_Twilio::decamelize ($ key );
333- if ($ connect_application ->$ app_key != $ setting )
333+ if ($ connect_application ->$ app_key != $ setting )
334334 {
335335 $ connect_application ->$ app_key = $ setting ;
336336 $ updated = true ;
337337 }
338338 }
339339
340- if ($ updated )
340+ if ($ updated )
341341 {
342342 $ connect_application ->update (array (
343343 'FriendlyName ' => $ connect_application ->friendly_name ,
@@ -375,7 +375,7 @@ private function setup_database($database, $dbh)
375375
376376 if (!mysql_query ($ sql , $ dbh ))
377377 {
378- throw new InstallException ( "Failed to run sql: " .$ sql . " :: " .
378+ throw new InstallException ( "Failed to run sql: " .$ sql . " :: " .
379379 mysql_error ($ dbh ), 2 );
380380 }
381381 }
@@ -512,38 +512,38 @@ private function setup_openvbx_settings($settings)
512512 * Create one if necessary
513513 *
514514 * @throws InstallException
515- * @param array $settings
515+ * @param array $settings
516516 * @return string Application Sid
517517 */
518- private function get_application ($ settings )
518+ private function get_application ($ settings )
519519 {
520520 try
521521 {
522522 $ app_token = md5 ($ _SERVER ['REQUEST_URI ' ]);
523523 $ app_name = "OpenVBX - {$ app_token }" ;
524524
525- if (empty ($ this ->account ))
525+ if (empty ($ this ->account ))
526526 {
527527 $ this ->account = OpenVBX::getAccount ($ settings ['twilio_sid ' ], $ settings ['twilio_token ' ]);
528528 }
529529 $ applications = $ this ->account ->applications ->getIterator (0 , 10 , array (
530530 'FriendlyName ' => $ app_name
531531 ));
532-
532+
533533 $ application = false ;
534534
535535 /** @var Services_Twilio_Rest_Application $_application */
536536 foreach ($ applications as $ _application )
537537 {
538- if ($ _application ->friendly_name == $ app_name )
538+ if ($ _application ->friendly_name == $ app_name )
539539 {
540540 $ application = $ _application ;
541541 break ;
542542 }
543543 }
544544
545545 $ site_url = site_url ();
546- if ($ settings ['rewrite_enabled ' ])
546+ if ($ settings ['rewrite_enabled ' ])
547547 {
548548 $ site_url = str_replace ('/index.php ' , '' , $ site_url );
549549 }
@@ -562,7 +562,7 @@ private function get_application($settings)
562562 {
563563 $ application ->update ($ params );
564564 }
565- else
565+ else
566566 {
567567 $ application = $ this ->account ->applications ->create ($ app_name , $ params );
568568 }
@@ -581,8 +581,8 @@ function validate()
581581 $ json = array (
582582 'success ' => true
583583 );
584-
585- if ($ step == 1 )
584+
585+ if ($ step == 1 )
586586 {
587587 $ this ->json_return ($ json );
588588 }
@@ -612,9 +612,9 @@ function validate()
612612 function validate_step2 ()
613613 {
614614 $ json = array (
615- 'success ' => true ,
616- 'step ' => 2 ,
617- 'message ' =>
615+ 'success ' => true ,
616+ 'step ' => 2 ,
617+ 'message ' =>
618618 'success '
619619 );
620620
@@ -661,10 +661,10 @@ function validate_step2()
661661 function validate_step3 ()
662662 {
663663 $ this ->load ->model ('vbx_settings ' );
664-
664+
665665 $ json = array (
666- 'success ' => true ,
667- 'step ' => 3 ,
666+ 'success ' => true ,
667+ 'step ' => 3 ,
668668 'message ' => 'success '
669669 );
670670 $ twilio_sid = $ this ->openvbx_settings ['twilio_sid ' ];
@@ -681,20 +681,20 @@ function validate_step3()
681681 * confident of success.
682682 */
683683 $ status = $ account ->type ;
684- if (empty ($ status ))
684+ if (empty ($ status ))
685685 {
686686 throw new InstallException ('Unable to access Twilio Account ' );
687687 }
688688
689689 // check the connect app if a sid is provided
690- if (!empty ($ connect_app ))
690+ if (!empty ($ connect_app ))
691691 {
692692 try {
693693 $ connect_application = $ account ->connect_apps ->get ($ connect_app );
694694 $ friendly_name = $ connect_application ->friendly_name ;
695695 }
696696 catch (Exception $ e ) {
697- switch ($ e ->getCode ())
697+ switch ($ e ->getCode ())
698698 {
699699 case 0 :
700700 // return a better message than "resource not found"
@@ -711,7 +711,7 @@ function validate_step3()
711711 {
712712 $ json ['success ' ] = false ;
713713
714- switch ($ e ->getCode ())
714+ switch ($ e ->getCode ())
715715 {
716716 case '20003 ' :
717717 $ json ['message ' ] = 'Authentication Failed. Invalid Twilio SID or Token. ' ;
@@ -729,8 +729,8 @@ function validate_step3()
729729 function validate_step4 ()
730730 {
731731 $ json = array (
732- 'success ' => true ,
733- 'step ' => 4 ,
732+ 'success ' => true ,
733+ 'step ' => 4 ,
734734 'message ' => 'success '
735735 );
736736 $ this ->openvbx_settings ['from_email ' ] = trim ($ this ->input ->post ('from_email ' ));
@@ -742,7 +742,7 @@ function validate_step4()
742742 throw new InstallException ('Email address is invalid. Please check the ' .
743743 'address and try again. ' );
744744 }
745-
745+
746746 $ required_fields = array (
747747 'from_email ' => 'Notification Sender Email Address '
748748 );
@@ -767,8 +767,8 @@ function validate_step5()
767767 $ ci =& get_instance ();
768768 $ ci ->load ->model ('vbx_user ' );
769769 $ json = array (
770- 'success ' => true ,
771- 'step ' => 5 ,
770+ 'success ' => true ,
771+ 'step ' => 5 ,
772772 'message ' => 'success '
773773 );
774774
@@ -784,17 +784,17 @@ function validate_step5()
784784 {
785785 throw new InstallException ('Your administrative password was not typed correctly. ' );
786786 }
787-
787+
788788 if (strlen ($ this ->user ['password ' ]) < VBX_User::MIN_PASSWORD_LENGTH )
789789 {
790790 throw new InstallException ('Password must be at least ' .VBX_User::MIN_PASSWORD_LENGTH .' characters. ' );
791791 }
792-
792+
793793 if (!filter_var ($ this ->user ['email ' ], FILTER_VALIDATE_EMAIL ))
794794 {
795795 throw new InstallException ('Email address is invalid. Please check the address and try again. ' );
796796 }
797-
797+
798798 $ required_fields = array (
799799 'email ' => 'Email Address ' ,
800800 'password ' => 'Password ' ,
@@ -815,9 +815,9 @@ function validate_step5()
815815 }
816816 return $ json ;
817817 }
818-
818+
819819 /**
820- * If .htaccess file doesn't exist try to preemptively
820+ * If .htaccess file doesn't exist try to preemptively
821821 * create one from the htaccess_dist file. Nothing special,
822822 * just try to make a copy of the file. If it doesn't
823823 * work it doesn't work.
0 commit comments