WEB_DOMAIN.class.php 24 KB

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