post.ctrl.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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('module');
  8. load()->model('miniapp');
  9. $dos = array('post', 'get_wxapp_modules', 'module_binding');
  10. $do = in_array($do, $dos) ? $do : 'post';
  11. $type = intval($_GPC['type']);
  12. if (!in_array($type, array_keys($account_all_type))) {
  13. itoast('账号类型不存在,请重试.');
  14. }
  15. $account_info = permission_user_account_num($_W['uid']);
  16. $type_sign = $account_all_type[$type]['type_sign'];
  17. if ($do == 'post') {
  18. $uniacid = intval($_GPC['uniacid']);
  19. $miniapp_info = miniapp_fetch($uniacid);
  20. if (empty($miniapp_info)) {
  21. itoast('参数有误');
  22. }
  23. if (checksubmit('submit')) {
  24. if (!preg_match('/^[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2})?$/', trim($_GPC['version']))) {
  25. iajax(-1, '版本号错误,只能是数字、点,数字最多2位,例如 1.1.1 或1.2');
  26. }
  27. $version = array(
  28. 'uniacid' => $uniacid,
  29. 'multiid' => '0',
  30. 'description' => safe_gpc_string($_GPC['description']),
  31. 'version' => safe_gpc_string($_GPC['version']),
  32. 'modules' => '',
  33. 'createtime' => TIMESTAMP,
  34. );
  35. if ($type_sign == WXAPP_TYPE_SIGN) {
  36. $version['design_method'] = WXAPP_MODULE;
  37. }
  38. $module = module_fetch($_GPC['choose_module']['name']);
  39. if (!empty($module)) {
  40. $select_modules[$module['name']] = array(
  41. 'name' => $module['name'],
  42. 'version' => $module['version']
  43. );
  44. $version['modules'] = serialize($select_modules);
  45. }
  46. pdo_insert('wxapp_versions', $version);
  47. $version_id = pdo_insertid();
  48. if (empty($version_id)) {
  49. iajax(-1, '创建失败');
  50. } else {
  51. cache_delete(cache_system_key('user_accounts', array('type' => $account_all_type[$type]['type_sign'], 'uid' => $_W['uid'])));
  52. iajax(0, '创建成功', url('account/display/switch', array('uniacid' => $uniacid, 'version_id' => $version_id, 'type' => $type)));
  53. }
  54. }
  55. template('miniapp/post');
  56. }