settings.action.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | FANWE 直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class settingsModule extends baseModule
  10. {
  11. /**
  12. * 账号与安全初始化
  13. */
  14. public function security(){
  15. $root = array('status'=>1,'error'=>'');
  16. if(!$GLOBALS['user_info']){
  17. $root['error'] = "用户未登陆,请先登陆.";
  18. $root['status'] = 0;
  19. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  20. }else{
  21. $mobile = $GLOBALS['db']->getOne("SELECT mobile FROM ".DB_PREFIX."user where id=".intval($GLOBALS['user_info']['id']));
  22. //redis 获取数据
  23. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  24. $user_redis = new UserRedisService();
  25. $user_mobile = $user_redis->getRow_db($GLOBALS['user_info']['id'],array('mobile'));
  26. if($mobile){
  27. $root['is_security'] = 1;
  28. $root['mobile'] = $user_mobile['mobile'];
  29. }else{
  30. $root['is_security'] = 0;
  31. $root['mobile'] = '';
  32. }
  33. }
  34. ajax_return($root);
  35. }
  36. /**
  37. * 手机绑定接口
  38. * @param $login_type
  39. */
  40. public function mobile_login($login_type='')
  41. {
  42. $mobile = strim($_REQUEST['mobile']);
  43. $verify = strim($_REQUEST["verify_code"]);
  44. if($login_type==''){
  45. $login_type = strim($_REQUEST['login_type']);
  46. }
  47. $num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "mobile_verify_code where mobile='{$mobile}' and verify_code='{$verify}'");
  48. if ($num <= 0) {
  49. ajax_return(array('status' => 0, 'error' => '验证码错误'));
  50. }
  51. $has_user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where mobile='{$mobile}' and login_type=2");
  52. fanwe_require(APP_ROOT_PATH."system/libs/user.php");
  53. switch ($login_type) {
  54. case 'wx_login' :
  55. $key = "wx_login_{$_REQUEST['openid']}_{$_REQUEST['access_token']}";
  56. $wx_info = $GLOBALS['cache']->get($key);
  57. if (empty($wx_info)) {
  58. return ajax_return(array('status' => 0, 'error' => '操作超时,请重新授权.'));
  59. }
  60. $wx_info['mobile'] = $mobile;
  61. $root = wxxMakeUser($wx_info, $has_user);
  62. break;
  63. case 'qq_login':
  64. $key = "qq_login_{$_REQUEST['openid']}_{$_REQUEST['access_token']}_{$_REQUEST['sdk_type']}";
  65. $qq_info = $GLOBALS['cache']->get($key);
  66. if (empty($qq_info)) {
  67. return ajax_return(array('status' => 0, 'error' => '操作超时,请重新授权.'));
  68. }
  69. $qq_info['mobile'] = $mobile;
  70. $root = qqMakeUser($qq_info, $has_user);
  71. break;
  72. case 'sina_login':
  73. $key = "sina_login_{$_REQUEST['openid']}_{$_REQUEST['access_token']}";
  74. $sina_info = $GLOBALS['cache']->get($key);
  75. if (empty($sina_info)) {
  76. return ajax_return(array('status' => 0, 'error' => '操作超时,请重新授权.'));
  77. }
  78. $sina_info['mobile'] = $mobile;
  79. $root = sinaMakeUser($sina_info, $has_user);
  80. break;
  81. default:
  82. return ajax_return(array('status' => 0, 'error' => '未知参数'));
  83. break;
  84. }
  85. $m_config = load_auto_cache('m_config');
  86. $root['login_send_score'] = intval($m_config['login_send_score']);
  87. ajax_return($root);
  88. }
  89. /**
  90. * 账号与安全保存
  91. */
  92. public function mobile_binding(){
  93. $login_type = strim($_REQUEST['login_type']);
  94. if($login_type) {
  95. return $this->mobile_login($login_type);
  96. }
  97. $root = array('status'=>1,'error'=>'');
  98. if(!$GLOBALS['user_info']){
  99. $root['error'] = "用户未登陆,请先登陆.";
  100. $root['status'] = 0;
  101. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  102. ajax_return($root);
  103. }
  104. $mobile=strim($_REQUEST["mobile"]);
  105. $verify=strim($_REQUEST["verify_code"]);
  106. //该用户为游客时,该手机号若已被绑定过则拒绝绑定
  107. $log_tp = $GLOBALS['db']->getOne("select login_type from " . DB_PREFIX . "user where id=" . $GLOBALS['user_info']['id']);
  108. $mobile_exist = $GLOBALS['db']->getOne("select mobile from " . DB_PREFIX . "user where mobile='{$mobile}'");
  109. if( $log_tp == 4 && $mobile_exist )
  110. {
  111. $root['status'] = 0;
  112. $root['error'] = '该手机号已被绑定!';
  113. ajax_return($root);
  114. }
  115. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  116. $user_redis = new UserRedisService();
  117. if(strlen($verify)< 0 || strlen($verify)== 0){
  118. $root['status'] = 0;
  119. $root['error'] = '请输入手机验证号码';
  120. ajax_return($root);
  121. }
  122. if($mobile){
  123. $old_mobile = $GLOBALS['db']->getOne("SELECT mobile FROM ".DB_PREFIX."user where id=".intval($GLOBALS['user_info']['id']));
  124. //redis 读取
  125. // $old_mobile = $user_redis->getRow_db($GLOBALS['user_info']['id'],array('mobile'));
  126. if($mobile==$old_mobile){
  127. $root['status'] = 0;
  128. $root['error'] = '该手机已绑定';
  129. ajax_return($root);
  130. }
  131. }
  132. if (defined('ONE_MOBILE') && ONE_MOBILE) {
  133. if ($GLOBALS['db']->getOne("select id from ".DB_PREFIX."user where mobile={$mobile}")) {
  134. ajax_return([
  135. 'status'=>0,
  136. 'error'=>'该手机已绑定其它账户',
  137. ]);
  138. }
  139. }
  140. $login_type_sql = "select login_type from ".DB_PREFIX."user where id = '".$GLOBALS['user_info']['id']."'";
  141. $login_type = $GLOBALS['db']->getOne($login_type_sql);
  142. $check_mobile_info =array(
  143. 'mobile'=>$mobile,
  144. 'login_type'=>$login_type,
  145. );
  146. if(OPEN_YPSMS!=1)
  147. check_registor_mobile($check_mobile_info);
  148. if(!$mobile){
  149. $condition="mobile = '".$old_mobile."' and verify_code='".$verify."' ";
  150. }else{
  151. $condition="mobile = '".$mobile."' and verify_code='".$verify."' ";
  152. }
  153. $num=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."mobile_verify_code where $condition ORDER BY id DESC");
  154. if($num<=0){
  155. $root['status'] = 0;
  156. $root['error'] = '验证码错误';
  157. ajax_return($root);
  158. }else{
  159. $GLOBALS['db']->query("update ".DB_PREFIX."user set mobile='".$mobile."' where id=".intval($GLOBALS['user_info']['id']));
  160. //redis 更新
  161. $user_redis->update_db($GLOBALS['user_info']['id'],array('mobile'=>$mobile));
  162. $root['status'] = 1;
  163. $root['error'] = '保存成功';
  164. //微信绑定
  165. $user= $GLOBALS['db']->getRow("select subscribe,wx_openid,mobile from ".DB_PREFIX."user where id=".intval($GLOBALS['user_info']['id']));
  166. //redis 读取
  167. $user = $user_redis->getRow_db($GLOBALS['user_info']['id'],array('subscribe','wx_openid','mobile'));
  168. if($user['subscribe'])
  169. $root['subscribe'] =1;
  170. else
  171. $root['subscribe'] =0;
  172. if($user['wx_openid']!='')
  173. $root['binding_wx'] = 1;
  174. else
  175. $root['binding_wx'] = 0;
  176. if($user['mobile']!='')
  177. $root['mobile_exist'] = 1;
  178. else
  179. $root['mobile_exist'] = 0;
  180. ajax_return($root);
  181. }
  182. }
  183. /**
  184. * 黑名单列表
  185. */
  186. public function black_list(){
  187. $root = array('status'=>1,'error'=>'');
  188. if(!$GLOBALS['user_info']){
  189. $root['error'] = "用户未登陆,请先登陆.";
  190. $root['status'] = 0;
  191. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  192. }else{
  193. $page = intval($_REQUEST['p']);//取第几页数据
  194. if($page==0){
  195. $page = 1;
  196. }
  197. //每次20条
  198. $page_size=20;
  199. $limit = (($page-1)*$page_size).",".$page_size;
  200. $user_id = intval($GLOBALS['user_info']['id']);
  201. $user = $GLOBALS['db']->getAll("select u.id as user_id,u.nick_name,u.signature,u.sex,u.head_image,u.user_level,u.v_icon,b.id as bid from ".DB_PREFIX."user as u left join ".DB_PREFIX."black as b on u.id = b.black_user_id where b.user_id=".$user_id." limit ".$limit);
  202. foreach($user as $k=>$v){
  203. $user[$k]['head_image'] = get_spec_image($v['head_image']);
  204. if($v['signature']==''){
  205. $user[$k]['signature'] = '';
  206. }
  207. $user[$k]['black_url'] = url_app('home',array('podcast_id'=>$v['id']));
  208. $user[$k]['signature'] = htmlspecialchars_decode($user[$k]['signature']);
  209. $user[$k]['nick_name'] = htmlspecialchars_decode($user[$k]['nick_name']);
  210. $user[$k]['nick_name'] = emoji_decode($user[$k]['nick_name']);
  211. $user[$k]['signature'] = emoji_decode($user[$k]['signature']);
  212. }
  213. $root['user'] = $user;
  214. $rs_count = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user as u left join ".DB_PREFIX."black as b on u.id = b.black_user_id where b.user_id=".$user_id." ");
  215. if($page==0){
  216. $root['has_next'] = 0;
  217. }else{
  218. if ($rs_count >= $page*$page_size){
  219. $root['has_next'] = 1;
  220. }
  221. else {
  222. $root['has_next'] = 0;
  223. }
  224. }
  225. $root['page'] = $page;
  226. }
  227. ajax_return($root);
  228. }
  229. /**
  230. * 设置推送
  231. */
  232. public function set_push(){
  233. $root = array('status'=>1,'error'=>'');
  234. if(!$GLOBALS['user_info']){
  235. $root['error'] = "用户未登陆,请先登陆.";
  236. $root['status'] = 0;
  237. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  238. ajax_return($root);
  239. }
  240. $type = strim($_REQUEST['type']);
  241. if($type==1){//设置登录用户推送消息
  242. $user_id = intval($GLOBALS['user_info']['id']);
  243. $is_remind = intval($_REQUEST['is_remind'])?1:0;
  244. $status = $GLOBALS['db']->query("update ".DB_PREFIX."user set is_remind=".$is_remind." where id=".$user_id);
  245. }
  246. /*if($type == 2){//设置登录用户关注人推送消息
  247. $focus_id = strim($_REQUEST['focus_id']);
  248. $is_remind = strim($_REQUEST['is_remind']);
  249. $GLOBALS['db']->query("update ".DB_PREFIX."focus set is_remind=".$is_remind." where id=".$focus_id);
  250. }*/
  251. if($status){
  252. $root['status'] =1;
  253. $root['error']= '设置成功!';
  254. //REDIS 数据
  255. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  256. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  257. $user_redis = new UserRedisService();
  258. $data = array('is_remind'=>$is_remind);
  259. $user_redis->update_db($user_id,$data);
  260. }else{
  261. $root['status'] =0;
  262. $root['error']= '设置失败!';
  263. }
  264. ajax_return($root);
  265. }
  266. /**
  267. * 帮助和反馈
  268. */
  269. public function help(){
  270. $m_config = load_auto_cache("m_config");
  271. $root = array('status'=>1,'error'=>'');
  272. //热门问题,取前6条
  273. //审核期间去除带有支付方式相关字眼的文章
  274. if($m_config['ios_check_version'] != ''){
  275. $hot_sql = "select f.* from ".DB_PREFIX."faq as f where is_effect = 1 and f.group NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' and f.question NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' and f.answer NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' order by f.sort desc, f.click_count desc limit 0,6";
  276. }else{
  277. $hot_sql = "select f.* from ".DB_PREFIX."faq as f where is_effect = 1 order by f.sort desc, f.click_count desc limit 0,6";
  278. }
  279. $hot_faq = $GLOBALS['db']->getAll($hot_sql,true,true);
  280. foreach($hot_faq as $k=>$v){
  281. $hot_faq[$k]['article_url'] = url_app('article',array('id'=>$v['id']));
  282. }
  283. //全部问题分类列表
  284. if($m_config['ios_check_version'] != ''){
  285. $cate_sql = "select f.group from ".DB_PREFIX."faq as f where f.is_effect = 1 and f.group NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' group by (f.group)";
  286. }else{
  287. $cate_sql = "select f.group from ".DB_PREFIX."faq as f where f.is_effect = 1 group by (f.group)";
  288. }
  289. $faq_cates = $GLOBALS['db']->getAll($cate_sql,true,true);;
  290. foreach ($faq_cates as $k=>$v) {
  291. $faq_cates[$k]['articlelist_url'] = url_app('articlelist',array('faq_group'=>urlencode($v['group'])));
  292. }
  293. $root['hot_faq'] = $hot_faq;
  294. $root['faq_cates'] = $faq_cates;
  295. $root['page_title'] = '帮助与反馈';
  296. api_ajax_return($root);
  297. }
  298. /**
  299. * 同一类型问题列表
  300. */
  301. public function faq(){
  302. $m_config = load_auto_cache("m_config");
  303. $root = array('status'=>1,'error'=>'');
  304. $faq_group = strim($_REQUEST['faq_group']);
  305. $faq_group = $faq_group!=''?$faq_group:'充值问题';
  306. if($m_config['ios_check_version'] != ''){
  307. $sql = "select f.* from ".DB_PREFIX."faq as f where is_effect = 1 and f.group = '".$faq_group."' and f.question NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' and f.answer NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' order by f.sort desc, f.click_count desc";
  308. }else{
  309. $sql = "select f.* from ".DB_PREFIX."faq as f where is_effect = 1 and f.group = '".$faq_group."' order by f.sort desc, f.click_count desc";
  310. }
  311. $faq_list = $GLOBALS['db']->getAll($sql,true,true);
  312. foreach($faq_list as $k=>$v){
  313. $faq_list[$k]['article_url'] = url_app('article',array('id'=>$v['id']));
  314. }
  315. $root['faq_list'] = $faq_list;
  316. $root['page_title'] = $faq_group;
  317. api_ajax_return($root);
  318. }
  319. /**
  320. * 问题展示
  321. */
  322. public function faq_show(){
  323. $root = array('status'=>1,'error'=>'');
  324. $id = intval($_REQUEST['id']);
  325. $faq_info = $GLOBALS['db']->getRow("select f.* from ".DB_PREFIX."faq as f where f.id = ".$id,true,true);
  326. if(!empty($faq_info)){
  327. $GLOBALS['db']->query("UPDATE ".DB_PREFIX."faq SET click_count=click_count+1 WHERE id = ".$faq_info['id']);
  328. }
  329. $faq_info['articlelist_url'] = url_app('articlelist',array('faq_group'=>urlencode($faq_info['group'])));
  330. $root['faq_info'] = $faq_info;
  331. $root['page_title'] = $faq_info['question'];
  332. api_ajax_return($root);
  333. }
  334. /**
  335. * 关于我们
  336. */
  337. public function article_cate(){
  338. $m_config = load_auto_cache("m_config");
  339. $root = array('status'=>1,'error'=>'');
  340. if($m_config['ios_check_version'] != ''){
  341. $article_cates = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."article_cate where is_effect = 1 and is_delete = 0 and type_id=0 and title NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' order by sort desc",true,true);
  342. }else{
  343. $article_cates = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."article_cate where is_effect = 1 and is_delete = 0 and type_id=0 order by sort desc",true,true);
  344. }
  345. foreach ($article_cates as $k=>$v) {
  346. if($m_config['ios_check_version'] != ''){
  347. $article = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."article where is_effect = 1 and is_delete = 0 and cate_id=".$v['id']." and title NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' and content NOT REGEXP '.*支付宝.*|.*银行.*|.*信用卡.*|.*银联.*|.*微信充值.*|.*微信支付.*|.*第三方支付.*' order by sort desc",true,true);
  348. }else{
  349. $article = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."article where is_effect = 1 and is_delete = 0 and cate_id=".$v['id']." order by sort desc",true,true);
  350. }
  351. if($article){
  352. $article_cates[$k]['aboutapp_url'] = url_app('aboutappdetail',array('cate_id'=>$v['id']));
  353. }else{
  354. unset($article_cates[$k]);
  355. }
  356. }
  357. $root['page_title'] = '关于';
  358. $root['article_cates'] = $article_cates;
  359. $root['site_license'] = app_conf("SITE_LICENSE");
  360. api_ajax_return($root);
  361. }
  362. /**
  363. * 文章展示
  364. */
  365. public function article_show(){
  366. //输出文章
  367. $root = array('status'=>1,'error'=>'');
  368. $cate_id = intval($_REQUEST['cate_id']);
  369. $cate_id = $cate_id>0?$cate_id:1;
  370. $article = $GLOBALS['db']->getRow("select a.* from ".DB_PREFIX."article as a where is_effect = 1 and is_delete = 0 and cate_id=".$cate_id." order by sort desc",true,true);
  371. $root['page_title'] = $article['title'];
  372. $root['article'] = $article;
  373. api_ajax_return($root);
  374. }
  375. /**
  376. * 意见反馈(预留功能)
  377. */
  378. public function opinion(){
  379. /*$root = array();
  380. $root['status'] = 1;
  381. if(!$GLOBALS['user_info']){
  382. $root['error'] = "用户未登陆,请先登陆.";
  383. $root['status'] = 0;
  384. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  385. }else{
  386. $user_id = intval($GLOBALS['user_info']['id']);//登录用户
  387. $data_info = array();
  388. $data_info['content']=strim($_REQUEST['content']);
  389. if(empty($data_info['content'])){
  390. $root['status'] = 0;
  391. $root['error'] = '请填写反馈内容';
  392. }
  393. $data_info['user_id'] = $user_id;
  394. $data_info['create_time'] = get_gmtime();
  395. $GLOBALS['db']->autoExecute(DB_PREFIX."opinion",$data_info,"INSERT","","SILENT");
  396. $message_id = $GLOBALS['db']->insert_id();
  397. if($message_id>0){
  398. $root['status'] = 1;
  399. $root['error'] = '添加成功';
  400. }else{
  401. $root['status'] = 0;
  402. $root['error'] = '添加失败';
  403. }
  404. }
  405. ajax_return($root);*/
  406. }
  407. }
  408. ?>