人人商城

bind-domain.ctrl.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $dos = array('bind_domain', 'delete', 'default_module');
  8. $do = in_array($do, $dos) ? $do : 'bind_domain';
  9. $_W['page']['title'] = '域名访问设置';
  10. if ($do == 'bind_domain') {
  11. if (checksubmit('submit')) {
  12. $bind_domain = safe_gpc_string($_GPC['bind_domain']);
  13. if (!starts_with($bind_domain, 'http')) {
  14. iajax(-1, '要绑定的域名请以http://或以https://开头');
  15. }
  16. $special_domain = array('.com.cn', '.net.cn', '.gov.cn', '.org.cn', '.com.hk', '.com.tw');
  17. $bind_domain = str_replace($special_domain, '.com', $bind_domain);
  18. $domain_array = explode('.', $bind_domain);
  19. if (count($domain_array) > 3 || count($domain_array) <2) {
  20. iajax(-1, '只支持一级域名和二级域名!');
  21. }
  22. $domain = preg_replace('/^https?/', '', $bind_domain);
  23. $uniacid = pdo_getcolumn('uni_settings', array('bind_domain' => array('http' . $domain, 'https' . $domain)), 'uniacid');
  24. if (empty($uniacid) || $uniacid == $_W['uniacid']) {
  25. uni_setting_save('bind_domain', $bind_domain);
  26. iajax(0, '绑定成功!', referer());
  27. } else {
  28. $account_name = pdo_getcolumn('uni_account', array('uniacid' => $uniacid), 'name');
  29. iajax(-1, "绑定失败, 该域名已被 {$account_name} 绑定!", referer());
  30. }
  31. }
  32. $modulelist = uni_modules();
  33. if (!empty($modulelist)) {
  34. foreach ($modulelist as $key => $module_val) {
  35. if (!empty($module_val['issystem']) || $module_val['webapp_support'] != MODULE_SUPPORT_WEBAPP) {
  36. unset($modulelist[$key]);
  37. continue;
  38. }
  39. }
  40. }
  41. template('webapp/bind-domain');
  42. }
  43. if ($do == 'delete') {
  44. uni_setting_save('bind_domain', '');
  45. itoast('删除成功!', referer(), 'success');
  46. }
  47. if ($do == 'default_module') {
  48. $module_name = safe_gpc_string($_GPC['module_name']);
  49. if (empty($module_name)) {
  50. iajax(-1, '请选择一个模块!');
  51. }
  52. $modulelist = array_keys(uni_modules());
  53. if (!in_array($module_name, $modulelist)) {
  54. iajax(-1, '模块不可用!');
  55. }
  56. uni_setting_save('default_module', $module_name);
  57. iajax(0, '修改成功!', referer());
  58. }