|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * 手机端文档页
- *
- * @version $id:view.php 10:46 2023年1月10日 xushubieli $
- * @package DedeBIZ.Libraries
- * @copyright Copyright (c) 2022, DedeBIZ.COM
- * @license https://www.dedebiz.com/license
- * @link https://www.dedebiz.com
- */
- define('DEDEMOB', 'Y');
- require_once(dirname(__FILE__)."/../system/common.inc.php");
- require_once(DEDEINC.'/archive/archives.class.php');
- $t1 = ExecTime();
- if (empty($okview)) $okview = '';
- if (isset($arcID)) $aid = $arcID;
- if (!isset($dopost)) $dopost = '';
- $app = (isset($app) && is_numeric($app) ? $app : 0);
- $arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
- if ($aid==0) die(" Request Error! ");
- $arc = new Archives($aid);
- if ($arc->IsError) ParamError();
- //检查阅读权限
- $needMoney = $arc->Fields['money'];
- $needRank = $arc->Fields['arcrank'];
- require_once(DEDEINC.'/memberlogin.class.php');
- $cfg_ml = new MemberLogin();
- if ($needRank < 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) {
- ShowMsg('文档未审核,暂时无法浏览', 'javascript:;');
- exit();
- }
- //设置了权限限制的文章
- //arctitle msgtitle moremsg
- if ($needMoney>0 || $needRank>1) {
- $arctitle = $arc->Fields['title'];
- $arclink = $cfg_phpurl.'/view.php?aid='.$arc->ArcID;
- $arcLinktitle = "<a href=\"{$arclink}\">".$arctitle."</a>";
- $description = $arc->Fields["description"];
- $pubdate = GetDateTimeMk($arc->Fields["pubdate"]);
- //会员级别不足
- if (($needRank>1 && $cfg_ml->M_Rank < $needRank && $arc->Fields['mid']!=$cfg_ml->M_ID)) {
- $dsql->Execute('me' , "SELECT * FROM `#@__arcrank` ");
- while($row = $dsql->GetObject('me'))
- {
- $memberTypes[$row->rank] = $row->membername;
- }
- $memberTypes[0] = "游客或没权限会员";
- $msgtitle = "您没有权限浏览文档:{$arctitle}";
- $moremsg = "该文档需要<span class='text-primary'>".$memberTypes[$needRank]."</span>金币才能浏览,您目前金币".$memberTypes[$cfg_ml->M_Rank]."</span>";
- include_once(DEDETEMPLATE.'/plus/view_msg.htm');
- exit();
- }
- //需要金币的情况
- if ($needMoney > 0 && $arc->Fields['mid'] != $cfg_ml->M_ID) {
- $sql = "SELECT aid,money FROM `#@__member_operation` WHERE buyid='ARCHIVE".$aid."' AND mid='".$cfg_ml->M_ID."'";
- $row = $dsql->GetOne($sql);
- //未购买过此文章
- if (!is_array($row)) {
- if ($cfg_ml->M_Money=='' || $needMoney > $cfg_ml->M_Money) {
- $msgtitle = "您没有权限浏览文档:{$arctitle}";
- $moremsg = "该文档需要<span class='text-primary'>".$needMoney."</span>金币才能浏览,您目前金币".$cfg_ml->M_Money."</span>";
- include_once(DEDETEMPLATE.'/plus/view_msg.htm');
- $arc->Close();
- exit();
- } else {
- if ($dopost=='buy') {
- $inquery = "INSERT INTO `#@__member_operation`(mid,oldinfo,money,mtime,buyid,product,pname) VALUES ('".$cfg_ml->M_ID."','$arctitle','$needMoney','".time()."', 'ARCHIVE".$aid."', 'archive',''); ";
- if ($dsql->ExecuteNoneQuery($inquery)) {
- $inquery = "UPDATE `#@__member` SET money=money-$needMoney WHERE mid='".$cfg_ml->M_ID."'";
- if (!$dsql->ExecuteNoneQuery($inquery)) {
- showmsg('购买失败,请返回', -1);
- exit;
- }
- if (defined('UC_APPID')) {
- include_once DEDEROOT.'/api/uc.func.php';
- $row = $dsql->GetOne("SELECT `scores`,`userid` FROM `#@__member` WHERE `mid`='".$cfg_ml->M_ID."'");
- uc_credit_note($row['userid'],-$needMoney,'money');
- }
- showmsg('购买成功,购买扣点不会重扣金币', '/apps/view.php?aid='.$aid);
- exit;
- } else {
- showmsg('购买失败,请返回', -1);
- exit;
- }
- }
- $msgtitle = "扣金币购买阅读";
- $moremsg = "该文档需要付费<span class='text-primary'>".$needMoney."</span>金币,您目前金币<span class='text-primary'>".$cfg_ml->M_Money."<br><a href='/apps/view.php?aid=".$aid."&dopost=buy' target='_blank'>确认付点阅读</a>" ;
- include_once($cfg_basedir.$cfg_templets_dir."/plus/view_msg.htm");
- $arc->Close();
- exit();
- }
- }
- }//金币处理付处理
- }
- $arc->Display();
- ?>
|