@@ -38,14 +38,26 @@ public function getListExecute(Request $request)
3838 'STATS_LOGIN ' => $ record ['STATS_AUTH ' ],
3939 'SSL ' => $ record ['SSL ' ],
4040 'SSL_HOME ' => $ record ['SSL_HOME ' ],
41- 'SSL_CERT ' => $ record ['SSL_CERT ' ],
42- 'SSL_KEY ' => $ record ['SSL_KEY ' ],
41+ 'SSL_CRT ' => '' ,
42+ 'SSL_KEY ' => '' ,
43+ 'SSL_CA ' => '' ,
4344 'NGINX ' => $ record ['NGINX ' ],
4445 'NGINX_EXT ' => $ record ['NGINX_EXT ' ],
45- 'SUSPEND ' => $ record ['SUSPEND ' ],
46+ 'SUSPEND ' => $ record ['SUSPEND ' ] == ' on ' ? ' on ' : ' off ' ,
4647 'DATE ' => date (Config::get ('ui_date_format ' , strtotime ($ record ['DATE ' ])))
4748 );
4849 $ web_details ['STAT ' ] == '' ? $ web_details ['STAT ' ] = 'none ' : true ;
50+
51+ if ($ record ['SSL ' ] == 'yes ' ){
52+ $ result_ssl = Vesta::execute (Vesta::V_LIST_WEB_DOMAIN_SSL , array ('USER ' => $ user ['uid ' ], 'DOMAIN ' => $ web_domain , self ::JSON ));
53+
54+ if ($ result_ssl ['status ' ]){
55+ foreach ($ result_ssl ['data ' ][$ web_domain ] as $ key => $ value ) {
56+ $ web_details ['SSL_ ' .$ key ] = $ value ;
57+ }
58+ }
59+ }
60+
4961 $ reply [$ web_domain ] = $ web_details ;
5062 }
5163
@@ -439,25 +451,7 @@ public function changeExecute(Request $request)
439451 }
440452 }
441453
442- /*if ($_new['SSL']) {
443- $params = array(
444- 'USER' => $user['uid'],
445- 'DOMAIN' => $_new['DOMAIN'],
446- 'SSL_CERT' => $_new['SSL_CERT']
447- );
448-
449- if ($_new['SSL_HOME']) {
450- $params['SSL_HOME'] = $_new['SSL_HOME'];
451- }
452-
453- $result = 0;
454- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
455-
456- if (!$result['status']) {
457- $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
458- }
459- }*/
460-
454+ /*
461455 if (!empty($_s['SSL_KEY'])) {
462456 $ssl_file = tempnam(sys_get_temp_dir(), 'ssl');
463457 file_put_contents($ssl_file, $_s['SSL_KEY']);
@@ -498,8 +492,74 @@ public function changeExecute(Request $request)
498492 $this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
499493 }
500494 }
501-
502-
495+ */
496+
497+
498+ if (!empty ($ _new ['SSL_KEY ' ]) && !empty ($ _new ['SSL_CRT ' ])) {
499+ // $ssl_dir = sys_get_temp_dir().'/ssl/'.rand();
500+ $ ssl_dir = sys_get_temp_dir ().'/ ' ;
501+ // if(!mkdir($ssl_dir)){
502+ // return $this->reply(FALSE, array('error' => 'can\'t create temp ssl dir: '.$ssl_dir));
503+ // }
504+
505+
506+
507+ $ ssl_crt_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.crt ' ;
508+ if (!file_put_contents ($ ssl_crt_file , $ _new ['SSL_CRT ' ]))
509+
510+ $ ssl_key_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.key ' ;
511+ file_put_contents ($ ssl_key_file , $ _new ['SSL_KEY ' ]);
512+
513+ if (!empty ($ _new ['SSL_CA ' ])) {
514+ $ ssl_ca_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.ca ' ;
515+ // file_put_contents($ssl_ca_file, $_new['SSL_CA']);
516+ }
517+
518+
519+ // echo '<br>';
520+ // echo $ssl_crt_file;
521+ // echo '<br>';
522+ // echo $ssl_key_file;
523+ // echo '<br>';
524+ // echo $ssl_ca_file;
525+
526+ $ params = array (
527+ 'USER ' => $ user ['uid ' ],
528+ 'DOMAIN ' => $ _DOMAIN ,
529+ 'SSL_DIR ' => $ ssl_dir
530+ // 'SSL_DIR' => 'tmp'
531+ );
532+
533+ // if (!empty($_s['SSL_HOME'])) {
534+ // $params['SSL_HOME'] = $_s['SSL_HOME'];
535+ // }
536+
537+ $ result = 0 ;
538+
539+ if ($ _old ['SSL ' ] == 'on ' ){
540+ $ result = Vesta::execute (Vesta::V_CHANGE_WEB_DOMAIN_SSL , $ params );
541+ }
542+ else {
543+ $ result = Vesta::execute (Vesta::V_ADD_WEB_DOMAIN_SSL , $ params );
544+ }
545+
546+ // print_r($result);
547+
548+ if (!$ result ['status ' ]) {
549+ $ this ->errors ['SSL ' ] = array ($ result ['error_code ' ] => $ result ['error_message ' ]);
550+ }
551+
552+ unlink ($ ssl_crt_file );
553+ unlink ($ ssl_key_file );
554+ unlink ($ ssl_ca_file );
555+
556+ }
557+
558+ if (empty ($ _new ['SSL_KEY ' ]) && empty ($ _new ['SSL_CRT ' ]) && $ _old ['SSL ' ] == 'on ' ) {
559+ $ result = 0 ;
560+ $ result = Vesta::execute (Vesta::V_DEL_WEB_DOMAIN_SSL , array ('USER ' => $ user ['uid ' ], 'DOMAIN ' => $ _DOMAIN ));
561+ }
562+
503563 return $ this ->reply ($ result ['status ' ], $ result ['data ' ]);
504564 }
505565
@@ -551,7 +611,7 @@ public function massiveSuspendExecute(Request $request)
551611 $ _entities = $ request ->getParameter ('entities ' );
552612
553613 foreach ($ _entities as $ entity ){
554- $ result = Vesta::execute (Vesta::V_SUSPEND_WEB_DOMAIN , array ('USER ' => $ user , $ entity ['DOMAIN ' ]));
614+ $ result = Vesta::execute (Vesta::V_SUSPEND_WEB_DOMAIN , array ('USER ' => $ user[ ' uid ' ] , $ entity ['DOMAIN ' ]));
555615 }
556616
557617 return $ this ->reply ($ result ['status ' ], $ result ['data ' ]);
@@ -563,7 +623,7 @@ public function massiveUnsuspendExecute(Request $request)
563623 $ _entities = $ request ->getParameter ('entities ' );
564624
565625 foreach ($ _entities as $ entity ){
566- $ result = Vesta::execute (Vesta::V_UNUSPEND_WEB_DOMAIN , array ('USER ' => $ user , $ entity ['DOMAIN ' ]));
626+ $ result = Vesta::execute (Vesta::V_UNSUSPEND_WEB_DOMAIN , array ('USER ' => $ user[ ' uid ' ] , $ entity ['DOMAIN ' ]));
567627 }
568628
569629 return $ this ->reply ($ result ['status ' ], $ result ['data ' ]);
@@ -575,7 +635,7 @@ public function massiveDeleteExecute(Request $request)
575635 $ _entities = $ request ->getParameter ('entities ' );
576636
577637 foreach ($ _entities as $ entity ){
578- $ result = Vesta::execute (Vesta::V_DEL_WEB_DOMAIN , array ('USER ' => $ user , $ entity ['DOMAIN ' ]));
638+ $ result = Vesta::execute (Vesta::V_DEL_WEB_DOMAIN , array ('USER ' => $ user[ ' uid ' ] , $ entity ['DOMAIN ' ]));
579639 }
580640
581641 return $ this ->reply ($ result ['status ' ], $ result ['data ' ]);
0 commit comments