editor.ctrl.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. if (in_array($do, array('quickmenu', 'uc'))) {
  13. permission_check_account_user('mc_member_' . $do);
  14. }
  15. if ($do == 'uc') {
  16. if (!empty($_GPC['wapeditor'])) {
  17. $params = $_GPC['wapeditor']['params'];
  18. if (empty($params)) {
  19. itoast('请您先设计手机端页面.', '', 'error');
  20. }
  21. $params = json_decode(ihtml_entity_decode($params), true);
  22. if (empty($params)) {
  23. itoast('请您先设计手机端页面.', '', 'error');
  24. }
  25. $page = $params[0];
  26. $html = safe_gpc_html(htmlspecialchars_decode($_GPC['wapeditor']['html'], ENT_QUOTES));
  27. $html = preg_replace('/background\-image\:(\s)*url\(\"(.*)\"\)/U', 'background-image: url($2)', $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, 'uniacid' => $_W['uniacid']));
  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)) {
  61. foreach ($nav as $row) {
  62. $data = array(
  63. 'uniacid' => $_W['uniacid'],
  64. 'name' => $row['name'],
  65. 'position' => 2,
  66. 'url' => $row['url'],
  67. 'icon' => '',
  68. 'css' => iserializer($row['css']),
  69. 'status' => $row['status'],
  70. 'displayorder' => 0,
  71. );
  72. if (!empty($row['id'])) {
  73. pdo_update('site_nav', $data, array('id' => $row['id'], 'uniacid' => $_W['uniacid']));
  74. } else {
  75. $data['status'] = 1;
  76. pdo_insert('site_nav', $data);
  77. $row['id'] = pdo_insertid();
  78. }
  79. $ids[] = $row['id'];
  80. }
  81. }
  82. pdo_delete('site_nav', array('uniacid' => $_W['uniacid'], 'position' => '2', 'id <>' => $ids));
  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. $multiid = intval($_GPC['multiid']);
  107. $type = intval($_GPC['type']) ? intval($_GPC['type']) : 2;
  108. if ($_GPC['wapeditor']) {
  109. $params = $_GPC['wapeditor']['params'];
  110. if (empty($params)) {
  111. itoast('请您先设计手机端页面.', '', 'error');
  112. }
  113. $params = json_decode(html_entity_decode(urldecode($params)), true);
  114. if (empty($params)) {
  115. itoast('请您先设计手机端页面.', '', 'error');
  116. }
  117. $html = safe_gpc_html(htmlspecialchars_decode($_GPC['wapeditor']['html'], ENT_QUOTES));
  118. $html = preg_replace('/background\-image\:(\s)*url\(\"(.*)\"\)/U', 'background-image: url($2)', $html);
  119. $data = array(
  120. 'uniacid' => $_W['uniacid'],
  121. 'multiid' => $multiid,
  122. 'title' => '快捷菜单',
  123. 'description' => '',
  124. 'status' => intval($_GPC['status']),
  125. 'type' => $type,
  126. 'params' => json_encode($params),
  127. 'html' => $html,
  128. 'createtime' => TIMESTAMP,
  129. );
  130. if ($type == '4') {
  131. $id = pdo_fetchcolumn("SELECT id FROM ".tablename('site_page')." WHERE uniacid = :uniacid AND type = :type", array(':uniacid' => $_W['uniacid'], ':type' => $type));
  132. } else {
  133. $id = pdo_fetchcolumn("SELECT id FROM ".tablename('site_page')." WHERE multiid = :multiid AND type = :type", array(':multiid' => $multiid, ':type' => $type));
  134. }
  135. if (!empty($id)) {
  136. pdo_update('site_page', $data, array('id' => $id, 'uniacid' => $_W['uniacid']));
  137. } else {
  138. if ($type == 4) {
  139. $data['status'] = 1;
  140. }
  141. pdo_insert('site_page', $data);
  142. $id = pdo_insertid();
  143. }
  144. itoast('快捷菜单保存成功.', url('site/editor/quickmenu', array('multiid' => $multiid, 'type' => $type)), 'success');
  145. }
  146. if ($type == '4') {
  147. $page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE type = :type AND uniacid = :uniacid", array(':type' => $type, ':uniacid' => $_W['uniacid']));
  148. } else {
  149. $page = pdo_fetch("SELECT * FROM ".tablename('site_page')." WHERE multiid = :multiid AND type = :type", array(':multiid' => $multiid, ':type' => $type));
  150. }
  151. $modules = uni_modules();
  152. template('site/editor');
  153. } elseif ($do == 'qrcode') {
  154. $error_correction_level = "L";
  155. $matrix_point_size = "8";
  156. $text = trim($_GPC['text']);
  157. QRcode::png($text, false, $error_correction_level, $matrix_point_size);
  158. }