CheckLevel.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. if(!defined('empirecms'))
  3. {
  4. exit();
  5. }
  6. //是否登陆
  7. function ViewCheckLogin($infor){
  8. global $empire,$public_r,$ecms_config,$toreturnurl,$gotourl;
  9. $userid=(int)getcvar('mluserid');
  10. $username=RepPostVar(getcvar('mlusername'));
  11. $rnd=RepPostVar(getcvar('mlrnd'));
  12. if(!$userid)
  13. {
  14. if(!getcvar('returnurl'))
  15. {
  16. esetcookie("returnurl",$toreturnurl,0);
  17. }
  18. eCheckLevelInfo_ViewInfoMsg($ckuser,$infor,'NotLogin');
  19. }
  20. //ck
  21. $qcklgr=qCheckLoginAuthstr();
  22. if(!$qcklgr['islogin'])
  23. {
  24. EmptyEcmsCookie();
  25. if(!getcvar('returnurl'))
  26. {
  27. esetcookie("returnurl",$toreturnurl,0);
  28. }
  29. eCheckLevelInfo_ViewInfoMsg($ckuser,$infor,'NotLogin');
  30. }
  31. //db
  32. $cr=$empire->fetch1("select ".eReturnSelectMemberF('checked,userid,username,groupid,userfen,userdate,zgroupid,ingid,agid,isern')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' and ".egetmf('username')."='$username' and ".egetmf('rnd')."='$rnd' limit 1");
  33. if(!$cr['userid'])
  34. {
  35. EmptyEcmsCookie();
  36. if(!getcvar('returnurl'))
  37. {
  38. esetcookie("returnurl",$toreturnurl,0);
  39. }
  40. eCheckLevelInfo_ViewInfoMsg($cr,$infor,'SingleLogin');
  41. }
  42. if($cr['checked']==0)
  43. {
  44. EmptyEcmsCookie();
  45. if(!getcvar('returnurl'))
  46. {
  47. esetcookie("returnurl",$toreturnurl,0);
  48. }
  49. eCheckLevelInfo_ViewInfoMsg($cr,$infor,'NotCheckUser');
  50. }
  51. //默认会员组
  52. if(empty($cr['groupid']))
  53. {
  54. $user_groupid=eReturnMemberDefGroupid();
  55. $usql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('groupid')."='$user_groupid' where ".egetmf('userid')."='".$cr[userid]."'");
  56. $cr['groupid']=$user_groupid;
  57. }
  58. //是否过期
  59. if($cr['userdate'])
  60. {
  61. if($cr['userdate']-time()<=0)
  62. {
  63. OutTimeZGroup($cr['userid'],$cr['zgroupid']);
  64. $cr['userdate']=0;
  65. if($cr['zgroupid'])
  66. {
  67. $cr['groupid']=$cr['zgroupid'];
  68. $cr['zgroupid']=0;
  69. }
  70. }
  71. }
  72. $re['userid']=$cr['userid'];
  73. $re['username']=$cr['username'];
  74. $re['userfen']=$cr['userfen'];
  75. $re['groupid']=$cr['groupid'];
  76. $re['userdate']=$cr['userdate'];
  77. $re['zgroupid']=$cr['zgroupid'];
  78. $re['ingid']=$cr['ingid'];
  79. $re['agid']=$cr['agid'];
  80. $re['isern']=$cr['isern'];
  81. $re['checked']=$cr['checked'];
  82. return $re;
  83. }
  84. //查看权限函数
  85. function CheckShowNewsLevel($infor){
  86. global $check_path,$level_r,$empire,$gotourl,$toreturnurl,$public_r,$dbtbpre,$class_r;
  87. $groupid=$infor['groupid'];
  88. $userfen=$infor['userfen'];
  89. $id=$infor['id'];
  90. $classid=$infor['classid'];
  91. //是否登陆
  92. $user_r=ViewCheckLogin($infor);
  93. //验证权限
  94. if($class_r[$infor[classid]]['cgtoinfo'])//栏目设置
  95. {
  96. $checkcr=$empire->fetch1("select cgroupid from {$dbtbpre}enewsclass where classid='$infor[classid]'");
  97. if($checkcr['cgroupid'])
  98. {
  99. if(!strstr($checkcr[cgroupid],','.$user_r[groupid].','))
  100. {
  101. $infor['eclass_cgroupid']=$checkcr[cgroupid];
  102. if(!getcvar('returnurl'))
  103. {
  104. esetcookie("returnurl",$toreturnurl,0);
  105. }
  106. eCheckLevelInfo_ViewInfoMsg($user_r,$infor,'NotLevelClass');
  107. }
  108. }
  109. }
  110. if($groupid)//信息设置
  111. {
  112. if($groupid>0)//会员组
  113. {
  114. if($level_r[$groupid][level]>$level_r[$user_r[groupid]][level])
  115. {
  116. if(!getcvar('returnurl'))
  117. {
  118. esetcookie("returnurl",$toreturnurl,0);
  119. }
  120. eCheckLevelInfo_ViewInfoMsg($user_r,$infor,'NotLevelGroup');
  121. }
  122. }
  123. else//访问组
  124. {
  125. $vgroupid=0-$groupid;
  126. $ckvgresult=eMember_ReturnCheckViewGroup($user_r,$vgroupid);
  127. if($ckvgresult<>'empire.cms')
  128. {
  129. if(!getcvar('returnurl'))
  130. {
  131. esetcookie("returnurl",$toreturnurl,0);
  132. }
  133. eCheckLevelInfo_ViewInfoMsg($user_r,$infor,'NotLevelViewGroup');
  134. }
  135. }
  136. }
  137. //扣点
  138. if(!empty($userfen))
  139. {
  140. //是否有历史记录
  141. $bakr=$empire->fetch1("select id,truetime from {$dbtbpre}enewsdownrecord where id='$id' and classid='$classid' and userid='$user_r[userid]' and online=2 order by truetime desc limit 1");
  142. if($bakr['id']&&(time()-$bakr['truetime']<=$public_r['redoview']*3600))
  143. {}
  144. else
  145. {
  146. if($user_r[userdate]-time()>0)//包月
  147. {}
  148. else
  149. {
  150. if($user_r[userfen]<$userfen)
  151. {
  152. if(!getcvar('returnurl'))
  153. {
  154. esetcookie("returnurl",$toreturnurl,0);
  155. }
  156. eCheckLevelInfo_ViewInfoMsg($user_r,$infor,'NotUserfen');
  157. }
  158. //扣点
  159. $usql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('userfen')."=".egetmf('userfen')."-".$userfen." where ".egetmf('userid')."='$user_r[userid]'");
  160. }
  161. //备份下载记录
  162. $utfusername=$user_r['username'];
  163. BakDown($classid,$id,0,$user_r['userid'],$utfusername,$infor[title],$userfen,2);
  164. }
  165. }
  166. }
  167. $check_infoid=(int)$check_infoid;
  168. $check_classid=(int)$check_classid;
  169. if(!defined('PageCheckLevel'))
  170. {
  171. include_once($check_path.'e/class/connect.php');
  172. if(!defined('InEmpireCMS'))
  173. {
  174. exit();
  175. }
  176. include_once(ECMS_PATH.'e/class/db_sql.php');
  177. include_once(ECMS_PATH.'e/data/dbcache/class.php');
  178. include_once(ECMS_PATH.'e/data/dbcache/MemberLevel.php');
  179. $link=db_connect();
  180. $empire=new mysqlquery();
  181. $check_tbname=RepPostVar($check_tbname);
  182. $checkinfor=$empire->fetch1("select * from {$dbtbpre}ecms_".$check_tbname." where id='$check_infoid' limit 1");
  183. if(!$checkinfor['id']||$checkinfor['classid']!=$check_classid)
  184. {
  185. echo"<script>alert('此信息不存在');history.go(-1);</script>";
  186. exit();
  187. }
  188. //副表
  189. $check_mid=$class_r[$checkinfor[classid]]['modid'];
  190. $checkfinfor=$empire->fetch1("select ".ReturnSqlFtextF($check_mid)." from {$dbtbpre}ecms_".$check_tbname."_data_".$checkinfor[stb]." where id='$checkinfor[id]' limit 1");
  191. $checkinfor=array_merge($checkinfor,$checkfinfor);
  192. }
  193. else
  194. {
  195. $check_tbname=RepPostVar($check_tbname);
  196. }
  197. require_once(ECMS_PATH.'e/member/class/user.php');
  198. //验证IP
  199. eCheckAccessDoIp('showinfo');
  200. if($checkinfor['groupid']||$class_r[$checkinfor['classid']]['cgtoinfo'])
  201. {
  202. include_once(ECMS_PATH.'e/template/public/checklevel/info1.php');
  203. $toreturnurl=eReturnSelfPage(1); //返回页面地址
  204. $gotourl=$ecms_config['member']['loginurl']?$ecms_config['member']['loginurl']:$public_r['newsurl']."e/member/login/"; //登陆地址
  205. CheckShowNewsLevel($checkinfor);
  206. }
  207. if(!defined('PageCheckLevel'))
  208. {
  209. db_close();
  210. $empire=null;
  211. }
  212. ?>