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

136 lines
5.7KB

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