@@ -36,8 +36,8 @@ public function getListExecute(Request $request)
3636 'ELOG ' => $ record ['ELOG ' ],
3737 'STAT ' => $ record ['STATS ' ],
3838 'STATS_LOGIN ' => $ record ['STATS_AUTH ' ],
39- 'SSL ' => $ record ['SSL ' ],
40- 'SSL_HOME ' => $ record ['SSL_HOME ' ],
39+ 'SSL ' => $ record ['SSL ' ] == ' yes ' ? ' on ' : ' off ' ,
40+ 'SSL_HOME ' => $ record ['SSL_HOME ' ] == ' tsingle ' ? ' off ' : ' on ' ,
4141 'SSL_CRT ' => '' ,
4242 'SSL_KEY ' => '' ,
4343 'SSL_CA ' => '' ,
@@ -170,29 +170,10 @@ public function addExecute(Request $request)
170170 }
171171 }
172172
173- /* if ($_s['SSL']) {
174- $params = array(
175- 'USER' => $user['uid'],
176- 'DOMAIN' => $_s['DOMAIN'],
177- 'SSL_CERT' => $_s['SSL_CERT']
178- );
179-
180- if ($_s['SSL_HOME']) {
181- $params['SSL_HOME'] = $_s['SSL_HOME'];
182- }
183-
184- $result = 0;
185- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
186-
187- if (!$result['status']) {
188- $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
189- }
190- }
191- if ($_s['SSL_HOME']) {
192-
193- }*/
194-
195- /*if (!empty($_s['DNS'])) {
173+ if (($ _s ['DNS_DOMAIN ' ]) == 'on ' ) {
174+ echo 'adding dns domain ' ;
175+ echo '<br> ' ;
176+
196177 $ params = array (
197178 'USER ' => $ user ['uid ' ],
198179 'DNS_DOMAIN ' => $ _s ['DOMAIN ' ],
@@ -207,7 +188,7 @@ public function addExecute(Request $request)
207188 if (!$ result ['status ' ]) {
208189 $ this ->errors ['DNS_DOMAIN ' ] = array ($ result ['error_code ' ] => $ result ['error_message ' ]);
209190 }
210- }*/
191+ }
211192
212193
213194 /*if (!empty($_s['MAIL'])) {
@@ -277,11 +258,15 @@ public function changeExecute(Request $request)
277258 $ _old ['ELOG ' ] = $ _old ['ELOG ' ] == 'yes ' ? 'on ' : 'off ' ;
278259 $ _old ['CGI ' ] = $ _old ['CGI ' ] == 'yes ' ? 'on ' : 'off ' ;
279260 $ _old ['AUTH ' ] = $ _old ['AUTH ' ] == 'yes ' ? 'on ' : 'off ' ;
280- $ _old ['SSL ' ] = $ _old ['SSL ' ] == 'yes ' ? 'on ' : 'off ' ;
261+ // $_old['SSL'] = $_old['SSL'] == 'yes' ? 'on' : 'off';
262+ // $_new['SSL'] = $_new['SSL'] == 'yes' ? 'on' : 'off';
263+ // $_new['SSL_HOME'] = $_new['SSL_HOME'] == 'no' ? 'shared' : 'single';
281264
282265 $ user = $ this ->getLoggedUser ();
283266 $ _DOMAIN = $ _new ['DOMAIN ' ];
284267
268+ $ result ['status ' ] = TRUE ;
269+
285270 if ($ _old ['SUSPEND ' ] != $ _new ['SUSPEND ' ]) {
286271 if ($ _new ['SUSPEND ' ] == 'on ' ) {
287272 $ result = Vesta::execute (Vesta::V_SUSPEND_WEB_DOMAIN , array ('USER ' => $ user ['uid ' ], 'DOMAIN ' => $ _DOMAIN ));
@@ -451,113 +436,51 @@ public function changeExecute(Request $request)
451436 }
452437 }
453438
454- /*
455- if (!empty($_s['SSL_KEY'])) {
456- $ssl_file = tempnam(sys_get_temp_dir(), 'ssl');
457- file_put_contents($ssl_file, $_s['SSL_KEY']);
458-
459- $params = array(
460- 'USER' => $user['uid'],
461- 'DOMAIN' => $_s['DOMAIN'],
462- 'SSL_KEY' => $ssl_file
463- );
464-
465- if (!empty($_s['SSL_HOME'])) {
466- $params['SSL_HOME'] = $_s['SSL_HOME'];
467- }
468-
469- $result = 0;
470- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
471-
472- if (!$result['status']) {
473- $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
474- }
475- }
476-
477-
478- if (!empty($_s['SSL_CERT'])) {
479- $sslcert_file = tempnam(sys_get_temp_dir(), 'ssl');
480- file_put_contents($sslcert_file, $_s['SSL_CERT']);
481-
482- $params = array(
483- 'USER' => $user['uid'],
484- 'DOMAIN' => $_s['DOMAIN'],
485- 'SSL_CERT' => $sslcert_file
486- );
487-
488- $result = 0;
489- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSLCERT, $params);
490-
491- if (!$result['status']) {
492- $this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
493- }
494- }
495- */
496439
497-
498- if (!empty ($ _new ['SSL_KEY ' ]) && !empty ($ _new ['SSL_CRT ' ])) {
499- // $ssl_dir = sys_get_temp_dir().'/ssl/'.rand();
440+ if (( !empty ($ _new ['SSL_KEY ' ]) && !empty ($ _new ['SSL_CRT ' ]) && $ _new ['SSL ' ] == 'on ' ) || $ _old ['SSL_HOME ' ] != $ _new ['SSL_HOME ' ]) {
500441 $ 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-
506442
507443 $ ssl_crt_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.crt ' ;
508- if (! file_put_contents ($ ssl_crt_file , $ _new ['SSL_CRT ' ]))
444+ file_put_contents ($ ssl_crt_file , $ _new ['SSL_CRT ' ]);
509445
510446 $ ssl_key_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.key ' ;
511447 file_put_contents ($ ssl_key_file , $ _new ['SSL_KEY ' ]);
512448
513449 if (!empty ($ _new ['SSL_CA ' ])) {
514450 $ ssl_ca_file = $ ssl_dir . $ _new ['DOMAIN ' ] . '.ca ' ;
515- // file_put_contents($ssl_ca_file, $_new['SSL_CA']);
451+ file_put_contents ($ ssl_ca_file , $ _new ['SSL_CA ' ]);
516452 }
517453
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-
526454 $ params = array (
527455 'USER ' => $ user ['uid ' ],
528456 'DOMAIN ' => $ _DOMAIN ,
529- 'SSL_DIR ' => $ ssl_dir
530- // 'SSL_DIR' => 'tmp '
457+ 'SSL_DIR ' => $ ssl_dir,
458+ ' SSL_HOME ' => $ _new [ ' SSL_HOME ' ] == ' on ' ? ' shared ' : ' single '
531459 );
532460
533- // if (!empty($_s['SSL_HOME'])) {
534- // $params['SSL_HOME'] = $_s['SSL_HOME'];
535- // }
536-
537461 $ result = 0 ;
538-
539462 if ($ _old ['SSL ' ] == 'on ' ){
540463 $ result = Vesta::execute (Vesta::V_CHANGE_WEB_DOMAIN_SSL , $ params );
541464 }
542465 else {
543466 $ result = Vesta::execute (Vesta::V_ADD_WEB_DOMAIN_SSL , $ params );
544467 }
545468
546- // print_r($result);
547-
548469 if (!$ result ['status ' ]) {
549470 $ this ->errors ['SSL ' ] = array ($ result ['error_code ' ] => $ result ['error_message ' ]);
550471 }
551472
552473 unlink ($ ssl_crt_file );
553474 unlink ($ ssl_key_file );
554475 unlink ($ ssl_ca_file );
555-
556476 }
557477
558- if (empty ($ _new ['SSL_KEY ' ]) && empty ($ _new ['SSL_CRT ' ]) && $ _old ['SSL ' ] == 'on ' ) {
478+ if ( (( empty ($ _new ['SSL_KEY ' ]) || empty ($ _new ['SSL_CRT ' ])) && $ _old ['SSL ' ] == 'on ' ) || ( $ _old [ ' SSL ' ] == ' on ' && $ _new [ ' SSL ' ] == ' off ' ) ) {
559479 $ result = 0 ;
560480 $ result = Vesta::execute (Vesta::V_DEL_WEB_DOMAIN_SSL , array ('USER ' => $ user ['uid ' ], 'DOMAIN ' => $ _DOMAIN ));
481+ if (!$ result ['status ' ]) {
482+ $ this ->errors ['SSL_REMOVING ' ] = array ($ result ['error_code ' ] => $ result ['error_message ' ]);
483+ }
561484 }
562485
563486 return $ this ->reply ($ result ['status ' ], $ result ['data ' ]);
0 commit comments