get.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. //获取article内容
  3. require_once "../path.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../public/function.php';
  6. require_once '../ucenter/function.php';
  7. require_once '../redis/function.php';
  8. require_once "../article/function.php";
  9. if(isset($_GET["id"])){
  10. //查询权限
  11. if(isset($_GET["collection_id"])){
  12. $collectionId = $_GET["collection_id"];
  13. }
  14. else{
  15. $collectionId = "";
  16. }
  17. $redis = redis_connect();
  18. $article = new Article($redis);
  19. $power = $article->getPower($_GET["id"],$collectionId);
  20. if($power<10){
  21. $output = array();
  22. $output["title"]="Sorry对不起";
  23. $output["subtitle"]="No Power For Read<br>没有阅读权限";
  24. $output["summary"]="";
  25. $output["content"]="This is a **private** rescouce, reading need special <guide gid='power_set'><b>power</b></guide>.<br>该资源是**私密**资源,阅读需要<guide gid='power_set'><b>权限</b></guide>。";
  26. $output["owner"]="";
  27. $output["username"]=array("username"=>"","nickname"=>"");
  28. $output["status"]="";
  29. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  30. exit;
  31. }
  32. #查询权限结束
  33. $Fetch = $article->getInfo($_GET["id"]);
  34. if($Fetch){
  35. $Fetch["content"] = $article->getContent($_GET["id"]);
  36. $userinfo = new UserInfo();
  37. $user = $userinfo->getName($Fetch["owner"]);
  38. $Fetch["username"] = $user;
  39. echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
  40. exit;
  41. }
  42. }
  43. echo json_encode(array(), JSON_UNESCAPED_UNICODE);
  44. ?>