人人商城

common.ctrl.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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('uc_setting', 'upload_file');
  8. $do = in_array($do, $dos) ? $do : 'uc_setting';
  9. permission_check_account_user('profile_setting');
  10. $_W['page']['title'] = '系统 - 参数设置';
  11. if ($do == 'uc_setting') {
  12. $_W['page']['title'] = 'uc站点整合';
  13. $setting = uni_setting_load('uc');
  14. $uc = $setting['uc'];
  15. if(!is_array($uc)) {
  16. $uc = array();
  17. }
  18. if(checksubmit('submit')) {
  19. $rec = array();
  20. $uc['status'] = intval($_GPC['status']);
  21. $uc['connect'] = trim($_GPC['connect']);
  22. if($uc['status'] == '1' && in_array($uc['connect'], array('mysql','http'))) {
  23. $uc['title'] = empty($_GPC['title']) ? itoast('请填写正确的站点名称!', referer(), 'error') : trim($_GPC['title']);
  24. $uc['appid'] = empty($_GPC['appid']) ? itoast('请填写正确的应用id!', referer(), 'error') : intval($_GPC['appid']);
  25. $uc['key'] = empty($_GPC['key']) ? itoast('请填写与UCenter的通信密钥!', referer(), 'error') : trim($_GPC['key']);
  26. $uc['charset'] = empty($_GPC['charset']) ? itoast('请填写UCenter的字符集!', referer(), 'error') : trim($_GPC['charset']);
  27. if($uc['connect'] == 'mysql') {
  28. $uc['dbhost'] = empty($_GPC['dbhost']) ? itoast('请填写UCenter数据库主机地址!', referer(), 'error') : trim($_GPC['dbhost']);
  29. $uc['dbuser'] = empty($_GPC['dbuser']) ? itoast('请填写UCenter数据库用户名!', referer(), 'error') : trim($_GPC['dbuser']);
  30. $uc['dbpw'] = empty($_GPC['dbpw']) ? itoast('请填写UCenter数据库密码!', referer(), 'error') : trim($_GPC['dbpw']);
  31. $uc['dbname'] = empty($_GPC['dbname']) ? itoast('请填写UCenter数据库名称!', referer(), 'error') : trim($_GPC['dbname']);
  32. $uc['dbcharset'] = empty($_GPC['dbcharset']) ? itoast('请填写UCenter数据库字符集!', referer(), 'error') : trim($_GPC['dbcharset']);
  33. $uc['dbtablepre'] = empty($_GPC['dbtablepre']) ? itoast('请填写UCenter数据表前缀!', referer(), 'error') : trim($_GPC['dbtablepre']);
  34. $uc['dbconnect'] = intval($_GPC['dbconnect']);
  35. $uc['api'] = trim($_GPC['api']);
  36. $uc['ip'] = trim($_GPC['ip']);
  37. } elseif($uc['connect'] == 'http') {
  38. $uc['dbhost'] = trim($_GPC['dbhost']);
  39. $uc['dbuser'] = trim($_GPC['dbuser']);
  40. $uc['dbpw'] = trim($_GPC['dbpw']);
  41. $uc['dbname'] = trim($_GPC['dbname']);
  42. $uc['dbcharset'] = trim($_GPC['dbcharset']);
  43. $uc['dbtablepre'] = trim($_GPC['dbtablepre']);
  44. $uc['dbconnect'] = intval($_GPC['dbconnect']);
  45. $uc['api'] = empty($_GPC['api']) ? itoast('请填写UCenter 服务端的URL地址!', referer(), 'error') : trim($_GPC['api']);
  46. $uc['ip'] = empty($_GPC['ip']) ? itoast('请填写UCenter的IP!', referer(), 'error') : trim($_GPC['ip']);
  47. }
  48. }
  49. $uc = iserializer($uc);
  50. if(uni_setting_save('uc', $uc)){
  51. itoast('设置UC参数成功!', referer(), 'success');
  52. }else {
  53. itoast('设置UC参数失败,请核对内容重新提交!', referer(), 'error');
  54. }
  55. }
  56. }
  57. if ($do == 'upload_file') {
  58. if (checksubmit('submit')) {
  59. if (empty($_FILES['file']['tmp_name'])) {
  60. itoast('请选择文件', url('profile/common/upload_file'), 'error');
  61. }
  62. if ($_FILES['file']['type'] != 'text/plain') {
  63. itoast('文件类型错误', url('profile/common/upload_file'), 'error');
  64. }
  65. $file = file_get_contents($_FILES['file']['tmp_name']);
  66. $file_name = 'MP_verify_'. $file. ".txt";
  67. if ($file_name != $_FILES['file']['name'] || !preg_match("/^[A-Za-z0-9]+$/", $file)) {
  68. itoast('上传文件不合法,请重新上传', url('profile/common/upload_file'), 'error');
  69. }
  70. file_put_contents(IA_ROOT. "/". $_FILES['file']['name'], $file);
  71. itoast('上传成功', url('profile/common/upload_file'), 'success');
  72. }
  73. }
  74. template('profile/uc');