WEB_DOMAIN.class.php 24 KB

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