platform.ctrl.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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()->classs('weixin.platform');
  8. setting_load('platform');
  9. $founders = explode(',', $_W['config']['setting']['founder']);
  10. if($_W['isajax'] && $_W['ispost']) {
  11. $data = array();
  12. $token = trim($_GPC['token']);
  13. $encodingaeskey =trim($_GPC['encodingaeskey']);
  14. $appid = trim($_GPC['appid']);
  15. $appsecret = trim($_GPC['appsecret']);
  16. $authstate = isset($_GPC['authstate']) ? intval($_GPC['authstate']) : $_W['setting']['platform']['authstate'];
  17. $data['token'] = !empty($token) ? $token : $_W['setting']['platform']['token'];
  18. $data['encodingaeskey'] = !empty($encodingaeskey) ? $encodingaeskey : $_W['setting']['platform']['encodingaeskey'];
  19. $data['appid'] = !empty($appid) ? $appid : $_W['setting']['platform']['appid'];
  20. $data['appsecret'] = !empty($appsecret) ? $appsecret : $_W['setting']['platform']['appsecret'];
  21. $data['authstate'] = !empty($authstate) ? 1 : 0;
  22. $result = setting_save($data,'platform');
  23. if($result) {
  24. iajax(0, '修改成功!', '');
  25. }else {
  26. iajax(1, '修改失败!', '');
  27. }
  28. }
  29. if(empty($_W['setting']['platform'])) {
  30. $_W['setting']['platform'] = array(
  31. 'token' => random(32),
  32. 'encodingaeskey' => random(43),
  33. 'appsecret' => '',
  34. 'appid' => '',
  35. 'authstate' => 1
  36. );
  37. setting_save($_W['setting']['platform'],'platform');
  38. }
  39. $siteroot_parse_array = parse_url($_W['siteroot']);
  40. $account_platform = new WeixinPlatform();
  41. $authurl = $account_platform->getAuthLoginUrl();
  42. template('system/platform');