国内流行的内容管理系统(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.

97 lines
5.0KB

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