ArticleController.class.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class ArticleController extends CommonController {
  16. public function get_article_list()
  17. {
  18. $gpc = I('request.');
  19. $pageNum = $gpc['page'];
  20. $pageNum = $pageNum > 0 ? $pageNum : 1;
  21. $per_page = 30;
  22. $offset = ($pageNum - 1) * $per_page;
  23. $limit = "{$offset},{$per_page}";
  24. $list = M('lionfish_comshop_article')->where( array('enabled' => 1))->order('displayorder desc')->limit($limit)->select();
  25. if( empty($list) )
  26. {
  27. echo json_encode(array('code' => 1));
  28. die();
  29. }else{
  30. echo json_encode( array('code' =>0, 'data' => $list) );
  31. die();
  32. }
  33. }
  34. public function get_article()
  35. {
  36. $gpc = I('request.');
  37. $uniacid = $_W['uniacid'];
  38. $token = $gpc['token'];
  39. $id = $gpc['id'];
  40. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  41. $member_id = $weprogram_token['member_id'];
  42. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  43. if( empty($member_info) )
  44. {
  45. // echo json_encode( array('code' => 1) );
  46. // die();
  47. }
  48. $list = M('lionfish_comshop_article')->where( array('id' => $id,'enabled' => 1) )->find();
  49. //htmlspecialchars_decode
  50. $list["content"] = htmlspecialchars_decode($list["content"]);
  51. if( empty($list) )
  52. {
  53. echo json_encode(array('code' => 1));
  54. die();
  55. }else{
  56. echo json_encode( array('code' =>0, 'data' => $list) );
  57. die();
  58. }
  59. }
  60. }