editor.ctrl.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. load()->model('site');
  8. load()->model('module');
  9. load()->library('qrcode');
  10. $do = !empty($do) ? $do : 'uc';
  11. $do = in_array($do, array('quickmenu', 'uc', 'qrcode')) ? $do : 'uc';
  12. permission_check_account_user('mc_member');
  13. if ($do == 'uc') {
  14. $_W['page']['title'] = '会员中心 - 微站功能';
  15. if (!empty($_GPC['wapeditor'])) {
  16. $params = $_GPC['wapeditor']['params'];
  17. if (empty($params)) {
  18. itoast('请您先设计手机端页面.', '', 'error');
  19. }
  20. $params = json_decode(ihtml_entity_decode($params), true);
  21. if (empty($params)) {
  22. itoast('请您先设计手机端页面.', '', 'error');
  23. }
  24. $page = $params[0];
  25. $html = htmlspecialchars_decode($_GPC['wapeditor']['html'], ENT_QUOTES);
  26. $html = str_replace(array('<?', '<%', '<?php', '{php'), '_', $html);
  27. $html = preg_replace('/<\s*?script.*(src|language)+/i', '_', $html);
  28. $data = array(
  29. 'uniacid' => $_W['uniacid'],
  30. 'multiid' => '0',
  31. 'title' => $page['params']['title'],
  32. 'description' => $page['params']['description'],
  33. 'type' => 3,
  34. 'status' => 1,
  35. 'params' => stripslashes(ijson_encode($params, JSON_UNESCAPED_UNICODE)),
  36. 'html' => $html,
  37. 'createtime' => TIMESTAMP,
  38. );
  39. $id = pdo_fetchcolumn("SELECT id FROM ".tablename('site_page')." WHERE uniacid = :uniacid AND type = '3'", array(':uniacid' => $_W['uniacid']));
  40. if (empty($id)) {
  41. pdo_insert('site_page', $data);
  42. $id = pdo_insertid();
  43. } else {
  44. pdo_update('site_page', $data, array('id' => $id));
  45. }
  46. if (!empty($page['params']['keyword'])) {
  47. $cover = array(
  48. 'uniacid' => $_W['uniacid'],
  49. 'title' => $page['params']['title'],
  50. 'keyword' => $page['params']['keyword'],
  51. 'url' => murl('mc/home', array(), true, false),
  52. 'description' => $page['params']['description'],
  53. 'thumb' => $page['params']['cover'],
  54. 'module' => 'mc',
  55. );
  56. site_cover($cover);
  57. }
  58. $nav = json_decode(ihtml_entity_decode($_GPC['wapeditor']['nav']), true);
  59. $ids = array(0);
  60. if (!empty($nav)) {$nav['id'] = intval($nav['id']);foreach ($nav as $row) {
  61. $data = array(
  62. 'uniacid' => $_W['uniacid'],
  63. 'name' => $row['name'],
  64. 'position' => 2,
  65. 'url' => $row['url'],
  66. 'icon' => '',
  67. 'css' => iserializer($row['css']),
  68. 'status' => $row['status'],
  69. 'displayorder' => 0,
  70. );
  71. if (!empty($row['id'])) {
  72. pdo_update('site_nav', $data, array('id' => $row['id']));
  73. } else {
  74. $data['status'] = 1;
  75. pdo_insert('site_nav', $data);
  76. $row['id'] = pdo_insertid();
  77. }
  78. $ids[] = $row['id'];
  79. }
  80. }
  81. $ids_str = implode(',', $ids);
  82. pdo_query('DELETE FROM ' . tablename('site_nav') . " WHERE uniacid = :uniacid AND position = '2' AND id NOT IN ($ids_str)", array(':uniacid' => $_W['uniacid']));
  83. itoast('个人中心保存成功.', url('site/editor/uc'), 'success');
  84. }
  85. $navs = pdo_fetchall("SELECT id, icon, css, name, module, status, url FROM ".tablename('site_nav')." WHERE uniacid = :uniacid AND position = '2' ORDER BY displayorder DESC, id ASC", array(':uniacid' => $_W['uniacid']));
  86. if (!empty($navs)) {
  87. foreach ($navs as &$nav) {
  88. if (!empty($nav['module'])) {
  89. $nav['module_info'] = module_fetch($nav['module']);
  90. }
  91. if (!empty($nav['icon'])) {
  92. $nav['icon'] = tomedia($nav['icon']);
  93. }
  94. if (is_serialized($nav['css'])) {
  95. $nav['css'] = iunserializer($nav['css']);
  96. }
  97. if (empty($nav['css']['icon']['icon'])) {
  98. $nav['css']['icon']['icon'] = 'fa fa-external-link';
  99. }
  100. }
  101. unset($nav);
  102. }
  103. $page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE uniacid = :uniacid AND type = '3'", array(':uniacid' => $_W['uniacid']));
  104. template('site/editor');
  105. } elseif ($do == 'quickmenu') {
  106. $_W['page']['title'] = '快捷菜单 - 站点管理 - 微站功能';
  107. $multiid = intval($_GPC['multiid']);
  108. $type = intval($_GPC['type']) ? intval($_GPC['type']) : 2;
  109. if ($_GPC['wapeditor']) {
  110. $params = $_GPC['wapeditor']['params'];
  111. if (empty($params)) {
  112. itoast('请您先设计手机端页面.', '', 'error');
  113. }
  114. $params = json_decode(html_entity_decode(urldecode($params)), true);
  115. if (empty($params)) {
  116. itoast('请您先设计手机端页面.', '', 'error');
  117. }
  118. $html = htmlspecialchars_decode($_GPC['wapeditor']['html'], ENT_QUOTES);
  119. $html = str_replace(array('<?', '<%', '<?php', '{php'), '_', $html);
  120. $html = preg_replace('/<\s*?script.*(src|language)+/i', '_', $html);
  121. $html = preg_replace('/background\-image\:(\s)*url\(\"(.*)\"\)/U', 'background-image: url($2)', $html);
  122. $data = array(
  123. 'uniacid' => $_W['uniacid'],
  124. 'multiid' => $multiid,
  125. 'title' => '快捷菜单',
  126. 'description' => '',
  127. 'status' => intval($_GPC['status']),
  128. 'type' => $type,
  129. 'params' => json_encode($params),
  130. 'html' => $html,
  131. 'createtime' => TIMESTAMP,
  132. );
  133. if ($type == '4') {
  134. $id = pdo_fetchcolumn("SELECT id FROM ".tablename('site_page')." WHERE uniacid = :uniacid AND type = :type", array(':uniacid' => $_W['uniacid'], ':type' => $type));
  135. } else {
  136. $id = pdo_fetchcolumn("SELECT id FROM ".tablename('site_page')." WHERE multiid = :multiid AND type = :type", array(':multiid' => $multiid, ':type' => $type));
  137. }
  138. if (!empty($id)) {
  139. pdo_update('site_page', $data, array('id' => $id));
  140. } else {
  141. if ($type == 4) {
  142. $data['status'] = 1;
  143. }
  144. pdo_insert('site_page', $data);
  145. $id = pdo_insertid();
  146. }
  147. itoast('快捷菜单保存成功.', url('site/editor/quickmenu', array('multiid' => $multiid, 'type' => $type)), 'success');
  148. }
  149. if ($type == '4') {
  150. $page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE type = :type AND uniacid = :uniacid", array(':type' => $type, ':uniacid' => $_W['uniacid']));
  151. } else {
  152. $page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE multiid = :multiid AND type = :type", array(':multiid' => $multiid, ':type' => $type));
  153. }
  154. $modules = uni_modules();
  155. template('site/editor');
  156. } elseif ($do == 'qrcode') {
  157. $error_correction_level = "L";
  158. $matrix_point_size = "8";
  159. $text = trim($_GPC['text']);
  160. QRcode::png($text, false, $error_correction_level, $matrix_point_size);
  161. }