WEB_DOMAIN.class.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <?php
  2. /**
  3. * DOMAIN
  4. *
  5. * @author vesta, http://vestacp.com/
  6. * @author Dmitry Malishev <dima.malishev@gmail.com>
  7. * @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
  8. * @copyright vesta 2010-2011
  9. */
  10. class WEB_DOMAIN extends AjaxHandler
  11. {
  12. public function getListExecute(Request $request)
  13. {
  14. $user = $this->getLoggedUser();
  15. $reply = array();
  16. $result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
  17. $stat = array();
  18. $result_stat = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS_STATS, array('USER' => $user['uid']), self::JSON);
  19. foreach ($result_stat['data'] as $w_d => $w_d_details) {
  20. $stat[$w_d] = $w_d_details;
  21. }
  22. foreach($result['data'] as $web_domain => $record)
  23. {
  24. $web_details = array(
  25. 'IP' => $record['IP'],
  26. 'U_DISK' => (int)$record['U_DISK'],
  27. 'U_BANDWIDTH' => (int)$record['U_BANDWIDTH'],
  28. 'TPL' => $record['TPL'],
  29. 'ALIAS' => @str_replace(",", ", ", $record['ALIAS']),
  30. 'PHP' => $record['PHP'],
  31. 'CGI' => $record['CGI'],
  32. 'ELOG' => $record['ELOG'],
  33. 'STAT' => $record['STATS'],
  34. 'STATS_LOGIN' => $record['STATS_AUTH'],
  35. 'SSL' => $record['SSL'] == 'yes' ? 'on' : 'off',
  36. 'SSL_HOME' => $record['SSL_HOME'] == 'same' ? 'off' : 'on',
  37. 'SSL_CRT' => '',
  38. 'SSL_KEY' => '',
  39. 'SSL_CA' => '',
  40. 'NGINX' => $record['NGINX'],
  41. 'NGINX_EXT' => $record['NGINX_EXT'],
  42. 'SUSPEND' => $record['SUSPEND'], // == 'yes' ? 'on' : 'off',
  43. 'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE'])))
  44. );
  45. $web_details['STAT'] == '' ? $web_details['STAT'] = 'none' : true;
  46. if($record['SSL'] == 'yes'){
  47. $result_ssl = Vesta::execute(Vesta::V_LIST_WEB_DOMAIN_SSL, array('USER' => $user['uid'], 'DOMAIN' => $web_domain, self::JSON));
  48. if($result_ssl['status']){
  49. foreach ($result_ssl['data'][$web_domain] as $key => $value) {
  50. $web_details['SSL_'.$key] = $value;
  51. }
  52. }
  53. }
  54. $reply[$web_domain] = $web_details;
  55. }
  56. if (!$result['status']) {
  57. $this->errors[] = array($result['error_code'] => $result['error_message']);
  58. }
  59. return $this->reply($result['status'], $reply);
  60. }
  61. public function addExecute(Request $request)
  62. {
  63. $_s = $request->getParameter('spell');
  64. $user = $this->getLoggedUser();
  65. $params = array(
  66. 'USER' => $user['uid'],
  67. 'DOMAIN' => $_s['DOMAIN'],
  68. 'IP' => $_s['IP']
  69. );
  70. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
  71. if (!$result['status']) {
  72. $this->errors[] = array($result['error_code'] => $result['error_message']);
  73. return $this->reply($result['status'], $result['data']);
  74. }
  75. if (!empty($_s['TPL'])) {
  76. $params = array(
  77. 'USER' => $user['uid'],
  78. 'DOMAIN' => $_s['DOMAIN'],
  79. 'TPL' => $_s['TPL']
  80. );
  81. $result = 0;
  82. $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, $params);
  83. if (!$result['status']) {
  84. $this->errors['CHANGE_TPL'] = array($result['error_code'] => $result['error_message']);
  85. }
  86. }
  87. if (!empty($_s['ALIAS'])) {
  88. $alias_arr = explode(',', str_replace("\n", "", $_s['ALIAS']));
  89. foreach ($alias_arr as $alias) {
  90. $params = array(
  91. 'USER' => $user['uid'],
  92. 'DOMAIN' => $_s['DOMAIN'],
  93. 'ALIAS' => trim($alias)
  94. );
  95. $result = 0;
  96. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, $params);
  97. if (!$result['status']) {
  98. $this->errors['ALIAS'] = array($result['error_code'] => $result['error_message']);
  99. }
  100. }
  101. }
  102. if (!empty($_s['STAT']) && @$_s['STAT'] != 'none') {
  103. $params = array(
  104. 'USER' => $user['uid'],
  105. 'DOMAIN' => $_s['DOMAIN'],
  106. 'STAT' => $_s['STAT']);
  107. $result = 0;
  108. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
  109. if (!$result['status']) {
  110. $this->errors['STATS'] = array($result['error_code'] => $result['error_message']);
  111. }
  112. }
  113. if (!empty($_s['STAT_AUTH']) && @Utils::getCheckboxBooleanValue($_s['STATS_AUTH'])) {
  114. $params = array(
  115. 'USER' => $user['uid'],
  116. 'DOMAIN' => $_s['DOMAIN'],
  117. 'STAT_USER' => $_s['STAT_USER'],
  118. 'STAT_PASSWORS' => $_s['STAT_PASSWORD']
  119. );
  120. $result = 0;
  121. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
  122. if(!$result['status'])
  123. $this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
  124. }
  125. if (!empty($_s['CGI'])) {
  126. if (Utils::getCheckboxBooleanValue($_s['CGI'])) {
  127. /* removed due to CGI is set by default at WEB DOMAIN creation
  128. $result = array();
  129. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_s['DOMAIN']));
  130. if (!$result['status']) {
  131. $this->status = FALSE;
  132. $this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
  133. }
  134. */
  135. }
  136. else{
  137. $result = array();
  138. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_s['DOMAIN']));
  139. if (!$result['status']) {
  140. $this->status = FALSE;
  141. $this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
  142. }
  143. }
  144. }
  145. if (!empty($_s['ELOG'])) {
  146. if (Utils::getCheckboxBooleanValue($_s['ELOG'])) {
  147. $result = array();
  148. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_s['DOMAIN']));
  149. if (!$result['status']) {
  150. $this->status = FALSE;
  151. $this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
  152. }
  153. }
  154. }
  155. if (Utils::getCheckboxBooleanValue($_s['DNS_DOMAIN'])) {
  156. echo 'adding dns domain';
  157. echo '<br>';
  158. /*
  159. require_once V_ROOT_DIR . 'api/DNS.class.php';
  160. $dns = new DNS();
  161. $result = 0;
  162. $result = $dns->addExecute($params);
  163. if (!$result['status']) {
  164. $this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
  165. }
  166. */
  167. $_GET['debug'] = 2;
  168. $params = array(
  169. 'USER' => $user['uid'],
  170. 'DNS_DOMAIN' => $_s['DOMAIN'],
  171. 'IP' => $_s['IP']
  172. );
  173. $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params);
  174. if (!$result['status']) {
  175. $this->errors[] = array($result['error_code'] => $result['error_message']);
  176. }
  177. if (@Utils::getCheckboxBooleanValue($_s['SUSPEND'])) {
  178. if($result['status']){
  179. $result = array();
  180. $result = Vesta::execute(Vesta::V_SUSPEND_DNS_DOMAIN, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_s['DOMAIN']));
  181. if (!$result['status']) {
  182. $this->status = FALSE;
  183. $this->errors['DNS_SUSPEND'] = array($result['error_code'] => $result['error_message']);
  184. }
  185. }
  186. }
  187. }
  188. /*if (!empty($_s['MAIL'])) {
  189. $params = array(
  190. 'USER' => $_user,
  191. 'MAIL_DOMAIN' => $_s['DOMAIN'],
  192. 'IP' => $_s['IP']
  193. );
  194. require_once V_ROOT_DIR . 'api/MAIL.class.php';
  195. $mail = new MAIL();
  196. $result = 0;
  197. $result = $mail->addExecute($params);
  198. if (!$result['status'])
  199. $this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
  200. }*/
  201. if (!empty($_s['SSL_KEY']) && !empty($_s['SSL_CRT']) && $_s['SSL'] == 'on' ) {
  202. $ssl_dir = sys_get_temp_dir().'/';
  203. $ssl_crt_file = $ssl_dir . $_s['DOMAIN'] . '.crt';
  204. file_put_contents($ssl_crt_file, $_s['SSL_CRT']);
  205. $ssl_key_file = $ssl_dir . $_s['DOMAIN'] . '.key';
  206. file_put_contents($ssl_key_file, $_s['SSL_KEY']);
  207. if (!empty($_s['SSL_CA'])) {
  208. $ssl_ca_file = $ssl_dir . $_s['DOMAIN'] . '.ca';
  209. file_put_contents($ssl_ca_file, $_s['SSL_CA']);
  210. }
  211. // $_GET['debug'] = 2;
  212. $params = array(
  213. 'USER' => $user['uid'],
  214. 'DOMAIN' => $_s['DOMAIN'],
  215. 'SSL_DIR' => $ssl_dir,
  216. 'SSL_HOME' => $_s['SSL_HOME'] == 'on' ? 'single' : 'same'
  217. );
  218. $result = 0;
  219. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
  220. if (!$result['status']) {
  221. $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
  222. }
  223. unlink($ssl_crt_file);
  224. unlink($ssl_key_file);
  225. unlink($ssl_ca_file);
  226. }
  227. if (@Utils::getCheckboxBooleanValue($_s['SUSPEND'])) {
  228. if($result['status']){
  229. $result = array();
  230. $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'JOB' => $_s['DOMAIN']));
  231. if (!$result['status']) {
  232. $this->status = FALSE;
  233. $this->errors['SUSPEND'] = array($result['error_code'] => $result['error_message']);
  234. }
  235. }
  236. }
  237. return $this->reply($result['status'], $result['data']);
  238. }
  239. public function deleteExecute(Request $request)
  240. {
  241. $_s = $request->getParameter('spell');
  242. $user = $this->getLoggedUser();
  243. $params = array(
  244. 'USER' => $user['uid'],
  245. 'DOMAIN' => $_s['DOMAIN']
  246. );
  247. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
  248. if (!$result['status']) {
  249. $this->errors[] = array($result['error_code'] => $result['error_message']);
  250. }
  251. $params = array(
  252. 'USER' => $_user,
  253. 'DNS_DOMAIN' => $_s['DOMAIN']
  254. );
  255. return $this->reply($result['status'], $result['data']);
  256. }
  257. public function changeExecute(Request $request)
  258. {
  259. $_s = $request->getParameter('spell');
  260. $_old = $request->getParameter('old');
  261. $_new = $request->getParameter('new');
  262. $_old['ELOG'] = $_old['ELOG'] == 'yes' ? 'on' : 'off';
  263. $_old['CGI'] = $_old['CGI'] == 'yes' ? 'on' : 'off';
  264. $_old['AUTH'] = $_old['AUTH'] == 'yes' ? 'on' : 'off';
  265. // $_old['SSL'] = $_old['SSL'] == 'yes' ? 'on' : 'off';
  266. // $_new['SSL'] = $_new['SSL'] == 'yes' ? 'on' : 'off';
  267. // $_new['SSL_HOME'] = $_new['SSL_HOME'] == 'no' ? 'shared' : 'single';
  268. $user = $this->getLoggedUser();
  269. $_DOMAIN = $_new['DOMAIN'];
  270. $result['status'] = TRUE;
  271. if(@Utils::getCheckboxBooleanValue($_new['SUSPEND'])){
  272. $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  273. return $this->reply($result['status'], $result['error_message']);
  274. }
  275. elseif(@Utils::getCheckboxBooleanValue($_old['SUSPEND'])){
  276. $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  277. if (!$result['status']) {
  278. $this->status = FALSE;
  279. $this->errors['UNSUSPEND'] = array($result['error_code'] => $result['error_message']);
  280. return $this->reply($result['status'], $result['error_message']);
  281. }
  282. }
  283. if ($_old['IP'] != $_new['IP']) {
  284. $result = array();
  285. $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
  286. if (!$result['status']) {
  287. $this->status = FALSE;
  288. $this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
  289. }
  290. }
  291. if ($_old['TPL'] != $_new['TPL']) {
  292. $result = array();
  293. $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
  294. if (!$result['status']) {
  295. $this->status = FALSE;
  296. $this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
  297. }
  298. }
  299. if ($_old['ALIAS'] != $_new['ALIAS']) {
  300. $result = array();
  301. $old_arr_raw = preg_split('/[,\s]/', $_old['ALIAS']);
  302. $new_arr_raw = preg_split('/[,\s]/', $_new['ALIAS']);
  303. $old_arr = array();
  304. $new_arr = array();
  305. foreach ($old_arr_raw as $alias) {
  306. if ('' != trim($alias)) {
  307. $old_arr[] = $alias;
  308. }
  309. }
  310. foreach ($new_arr_raw as $alias) {
  311. if ('' != trim($alias)) {
  312. $new_arr[] = $alias;
  313. }
  314. }
  315. $added = array_diff($new_arr, $old_arr);
  316. $deleted = array_diff($old_arr, $new_arr);
  317. foreach ($deleted as $alias) {
  318. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
  319. if (!$result['status']) {
  320. $this->status = FALSE;
  321. $this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
  322. }
  323. }
  324. foreach ($added as $alias) {
  325. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
  326. if (!$result['status']) {
  327. $this->status = FALSE;
  328. $this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
  329. }
  330. }
  331. }
  332. if (($_old['STAT_AUTH'] != $_new['STAT_AUTH']) && !empty($_s['STAT_AUTH']) && @Utils::getCheckboxBooleanValue($_s['STATS_AUTH'])) {
  333. $params = array(
  334. 'USER' => $user['uid'],
  335. 'DOMAIN' => $_DOMAIN,
  336. 'STAT_USER' => $_new['STAT_USER'],
  337. 'STAT_PASSWORS' => $_new['STAT_PASSWORD']
  338. );
  339. $result = 0;
  340. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
  341. if(!$result['status']) {
  342. $this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
  343. }
  344. }
  345. if (($_old['STAT'] != $_new['STAT'])) {
  346. if ($_new['STAT'] != 'none') {
  347. $result = array();
  348. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
  349. if (!$result['status']) {
  350. $this->status = FALSE;
  351. $this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
  352. }
  353. }
  354. else {
  355. $result = array();
  356. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  357. if (!$result['status']) {
  358. $this->status = FALSE;
  359. $this->errors['DEL_STAT'] = array($result['error_code'] => $result['error_message']);
  360. }
  361. $result = array();
  362. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT_USER' => $_new['STAT_USER']));
  363. if (!$result['status']) {
  364. $this->status = FALSE;
  365. $this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
  366. }
  367. }
  368. }
  369. if (($_old['CGI'] != $_new['CGI'])) {
  370. if (Utils::getCheckboxBooleanValue($_new['CGI'])) {
  371. $result = array();
  372. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  373. if (!$result['status']) {
  374. $this->status = FALSE;
  375. $this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
  376. }
  377. }
  378. else {
  379. $result = array();
  380. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  381. if (!$result['status']) {
  382. $this->status = FALSE;
  383. $this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
  384. }
  385. }
  386. }
  387. if (($_old['ELOG'] != $_new['ELOG'])) {
  388. if (Utils::getCheckboxBooleanValue($_new['ELOG'])) {
  389. $result = array();
  390. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  391. if (!$result['status']) {
  392. $this->status = FALSE;
  393. $this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
  394. }
  395. }
  396. else {
  397. $result = array();
  398. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  399. if (!$result['status']) {
  400. $this->status = FALSE;
  401. $this->errors['DEL_ELOG'] = array($result['error_code'] => $result['error_message']);
  402. }
  403. }
  404. }
  405. if ( ( $_old['SSL_KEY'] != $_new['SSL_KEY']
  406. || $_old['SSL_CRT'] != $_new['SSL_CRT']
  407. || $_old['SSL_CA'] != $_new['SSL_CA']
  408. || $_old['SSL_HOME'] != $_new['SSL_HOME']
  409. )
  410. && !empty($_new['SSL_KEY'])
  411. && !empty($_new['SSL_CRT'])
  412. && $_new['SSL'] == 'on'
  413. ) {
  414. $ssl_dir = sys_get_temp_dir().'/';
  415. $ssl_crt_file = $ssl_dir . $_new['DOMAIN'] . '.crt';
  416. file_put_contents($ssl_crt_file, $_new['SSL_CRT']);
  417. $ssl_key_file = $ssl_dir . $_new['DOMAIN'] . '.key';
  418. file_put_contents($ssl_key_file, $_new['SSL_KEY']);
  419. if (!empty($_new['SSL_CA'])) {
  420. $ssl_ca_file = $ssl_dir . $_new['DOMAIN'] . '.ca';
  421. file_put_contents($ssl_ca_file, $_new['SSL_CA']);
  422. }
  423. $params = array(
  424. 'USER' => $user['uid'],
  425. 'DOMAIN' => $_DOMAIN,
  426. 'SSL_DIR' => $ssl_dir,
  427. 'SSL_HOME' => $_new['SSL_HOME'] == 'on' ? 'single' : 'same'
  428. );
  429. $result = 0;
  430. // updating ssl
  431. if($_old['SSL'] == 'on'){
  432. $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSL, $params);
  433. if (!$result['status']) {
  434. $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
  435. }
  436. // if ssl home dir changed, updating it
  437. if($_old['SSL_HOME'] != $_new['SSL_HOME']){
  438. $params = array(
  439. 'USER' => $user['uid'],
  440. 'DOMAIN' => $_DOMAIN,
  441. 'SSL_HOME' => $_new['SSL_HOME'] == 'on' ? 'single' : 'same'
  442. );
  443. $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSLHOME, $params);
  444. if (!$result['status']) {
  445. $this->errors['SSL_HOME'] = array($result['error_code'] => $result['error_message']);
  446. }
  447. }
  448. }
  449. // adding new ssl
  450. else{
  451. $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
  452. if (!$result['status']) {
  453. $this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
  454. }
  455. }
  456. unlink($ssl_crt_file);
  457. unlink($ssl_key_file);
  458. unlink($ssl_ca_file);
  459. }
  460. if ( ((empty($_new['SSL_KEY']) || empty($_new['SSL_CRT'])) && $_old['SSL'] == 'on') || ( $_old['SSL'] == 'on' && $_new['SSL'] == 'off') ){
  461. $result = 0;
  462. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_SSL, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
  463. if (!$result['status']) {
  464. $this->errors['SSL_REMOVING'] = array($result['error_code'] => $result['error_message']);
  465. }
  466. }
  467. return $this->reply($result['status'], $result['data']);
  468. }
  469. public function suspendExecute(Request $request)
  470. {
  471. $_s = $request->getParameter('spell');
  472. $user = $this->getLoggedUser();
  473. $params = array(
  474. 'USER' => $user['uid'],
  475. 'DOMAIN' => $_s['DOMAIN']
  476. );
  477. $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
  478. if (!$result['status']) {
  479. $this->errors[] = array($result['error_code'] => $result['error_message']);
  480. }
  481. return $this->reply($result['status'], $result['data']);
  482. }
  483. public function unsuspendExecute(Request $request)
  484. {
  485. $_s = $request->getParameter('spell');
  486. $user = $this->getLoggedUser();
  487. $params = array(
  488. 'USER' => $user['uid'],
  489. 'DOMAIN' => $_s['DOMAIN']
  490. );
  491. $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
  492. if (!$result['status']) {
  493. $this->errors[] = array($result['error_code'] => $result['error_message']);
  494. }
  495. return $this->reply($result['status'], $result['data']);
  496. }
  497. public function massiveSuspendExecute(Request $request)
  498. {
  499. $user = $this->getLoggedUser();
  500. $_entities = $request->getParameter('entities');
  501. foreach($_entities as $entity){
  502. $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
  503. }
  504. return $this->reply($result['status'], $result['data']);
  505. }
  506. public function massiveUnsuspendExecute(Request $request)
  507. {
  508. $user = $this->getLoggedUser();
  509. $_entities = $request->getParameter('entities');
  510. foreach($_entities as $entity){
  511. $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
  512. }
  513. return $this->reply($result['status'], $result['data']);
  514. }
  515. public function massiveDeleteExecute(Request $request)
  516. {
  517. $user = $this->getLoggedUser();
  518. $_entities = $request->getParameter('entities');
  519. foreach($_entities as $entity){
  520. $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, array('USER' => $user['uid'], $entity['DOMAIN']));
  521. }
  522. return $this->reply($result['status'], $result['data']);
  523. }
  524. }