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

96 lines
5.0KB

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