国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
5.0KB

  1. <?php
  2. /**
  3. * 关于文档权限设置的说明
  4. * 文档权限设置限制形式:如果指定了会员等级,那么必须到达这个等级才能浏览,如果指定了金币,浏览时会扣指点的点数,并保存记录到用户业务记录中,如果两者同时指定,那么必须同时满足两个条件
  5. *
  6. * @version $Id: view.php$
  7. * @package DedeBIZ.Site
  8. * @copyright Copyright (c) 2022, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__)."/../system/common.inc.php");
  13. require_once(DEDEINC.'/archive/archives.class.php');
  14. $t1 = ExecTime();
  15. if (empty($okview)) $okview = '';
  16. if (isset($arcID)) $aid = $arcID;
  17. if (!isset($dopost)) $dopost = '';
  18. $arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
  19. if ($aid == 0) die("dedebiz");
  20. $arc = new Archives($aid);
  21. if ($arc->IsError) ParamError();
  22. //检查阅读权限
  23. $needMoney = $arc->Fields['money'];
  24. $needRank = $arc->Fields['arcrank'];
  25. require_once(DEDEINC.'/memberlogin.class.php');
  26. $cfg_ml = new MemberLogin();
  27. if ($needRank < 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) {
  28. ShowMsg('文档尚未审核,非作者本人无权查看', 'javascript:;');
  29. exit();
  30. }
  31. //设置了权限限制的文档
  32. //arctitle msgtitle moremsg
  33. if ($needMoney > 0 || $needRank > 1) {
  34. $arctitle = $arc->Fields['title'];
  35. $arclink = $cfg_phpurl.'/view.php?aid='.$arc->ArcID;
  36. $arcLinktitle = "<a href=\"{$arclink}\">".$arctitle."</a>";
  37. $description = $arc->Fields["description"];
  38. $pubdate = GetDateTimeMk($arc->Fields["pubdate"]);
  39. //会员级别不足
  40. if (($needRank > 1 && $cfg_ml->M_Rank < $needRank && $arc->Fields['mid'] != $cfg_ml->M_ID)) {
  41. $dsql->Execute('me', "SELECT * FROM `#@__arcrank` ");
  42. while ($row = $dsql->GetObject('me')) {
  43. $memberTypes[$row->rank] = $row->membername;
  44. }
  45. $memberTypes[0] = "游客或没权限会员";
  46. $msgtitle = "您没有权限浏览文档:{$arctitle} ";
  47. $moremsg = "这篇文档需要 <span class='text-danger'>".$memberTypes[$needRank]."</span> 才能访问,您目前是:<span class='text-danger'>".$memberTypes[$cfg_ml->M_Rank]."</span>";
  48. include_once(DEDETEMPLATE.'/plus/view_msg.htm');
  49. exit();
  50. }
  51. //需要金币的情况
  52. if ($needMoney > 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) {
  53. $sql = "SELECT aid,money FROM `#@__member_operation` WHERE buyid='ARCHIVE".$aid."' AND mid='".$cfg_ml->M_ID."'";
  54. $row = $dsql->GetOne($sql);
  55. //未购买过此文档
  56. if (!is_array($row)) {
  57. if ($cfg_ml->M_Money == '' || $needMoney > $cfg_ml->M_Money) {
  58. $msgtitle = "您没有权限浏览文档:{$arctitle} ";
  59. $moremsg = "这篇文档需要 <span class='text-danger'>".$needMoney." 金币</span> 才能访问,您目前拥有金币:<span class='text-danger'>".$cfg_ml->M_Money." 个</span>";
  60. include_once(DEDETEMPLATE.'/plus/view_msg.htm');
  61. $arc->Close();
  62. exit();
  63. } else {
  64. if ($dopost == 'buy') {
  65. $inquery = "INSERT INTO `#@__member_operation`(mid,oldinfo,money,mtime,buyid,product,pname)
  66. VALUES ('".$cfg_ml->M_ID."','$arctitle','$needMoney','".time()."', 'ARCHIVE".$aid."', 'archive',''); ";
  67. if ($dsql->ExecuteNoneQuery($inquery)) {
  68. $inquery = "UPDATE `#@__member` SET money=money-$needMoney WHERE mid='".$cfg_ml->M_ID."'";
  69. if (!$dsql->ExecuteNoneQuery($inquery)) {
  70. showmsg('购买失败, 请返回', -1);
  71. exit;
  72. }
  73. showmsg('购买成功,购买扣点不会重扣金币,谢谢', '/plus/view.php?aid='.$aid);
  74. exit;
  75. } else {
  76. showmsg('购买失败,请返回', -1);
  77. exit;
  78. }
  79. }
  80. $msgtitle = "扣金币购买阅读";
  81. $moremsg = "阅读该文档内容需要付费<br>这篇文档需要 <span class='text-danger'>".$needMoney." 金币</span> 才能访问,您目前拥有金币 <span class='text-danger'>".$cfg_ml->M_Money." </span>个<br>确认阅读请点 [<a href='/plus/view.php?aid=".$aid."&dopost=buy' target='_blank'>确认付点阅读</a>]";
  82. include_once($cfg_basedir.$cfg_templets_dir."/plus/view_msg.htm");
  83. $arc->Close();
  84. exit();
  85. }
  86. }
  87. } //金币处理付处理
  88. }
  89. $arc->Display();
  90. if (DEBUG_LEVEL === TRUE) {
  91. $queryTime = ExecTime() - $t1;
  92. echo "<div style='width:98%;margin:1rem auto;color:#721c24;background-color:#f8d7da;border-color:#f5c6cb;position: relative;padding:.75rem 1.25rem;border:1px solid transparent;border-radius:.25rem'>页面加载总消耗时间:{$queryTime}</div>\r\n";
  93. }