spacefun.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. //返回sql语句
  3. function espace_ReturnBqQuery($classid,$line,$enews=0,$do=0,$ewhere='',$eorder=''){
  4. global $empire,$dbtbpre,$public_r,$class_r,$class_zr,$fun_r,$class_tr,$emod_r,$etable_r,$userid,$eyh_r;
  5. $userid=(int)$userid;
  6. if($enews==24)//按sql查询
  7. {
  8. $query_first=substr($classid,0,7);
  9. if(!($query_first=='select '||$query_first=='SELECT '))
  10. {
  11. return "";
  12. }
  13. $classid=RepSqlTbpre($classid);
  14. $sql=$empire->query1($classid);
  15. if(!$sql)
  16. {
  17. echo"SQL Error: ".ReRepSqlTbpre($classid);
  18. }
  19. return $sql;
  20. }
  21. if($enews==0||$enews==1||$enews==2||$enews==9||$enews==12||$enews==15)//栏目
  22. {
  23. if(strstr($classid,','))//多栏目
  24. {
  25. $son_r=sys_ReturnMoreClass($classid,1);
  26. $classid=$son_r[0];
  27. $where=$son_r[1];
  28. }
  29. else
  30. {
  31. if($class_r[$classid][islast])
  32. {
  33. $where="classid='$classid'";
  34. }
  35. else
  36. {
  37. $where=ReturnClass($class_r[$classid][sonclass]);
  38. }
  39. }
  40. $tbname=$class_r[$classid][tbname];
  41. $mid=$class_r[$classid][modid];
  42. $yhid=$class_r[$classid][yhid];
  43. }
  44. elseif($enews==6||$enews==7||$enews==8||$enews==11||$enews==14||$enews==17)//专题
  45. {
  46. echo"Error:Change to use e:indexloop";
  47. return false;
  48. }
  49. elseif($enews==25||$enews==26||$enews==27||$enews==28||$enews==29||$enews==30)//标题分类
  50. {
  51. if(strstr($classid,','))//多标题分类
  52. {
  53. $son_r=sys_ReturnMoreTT($classid);
  54. $classid=$son_r[0];
  55. $where=$son_r[1];
  56. }
  57. else
  58. {
  59. $where="ttid='$classid'";
  60. }
  61. $mid=$class_tr[$classid][mid];
  62. $tbname=$emod_r[$mid][tbname];
  63. $yhid=$class_tr[$classid][yhid];
  64. }
  65. $query=" where userid='$userid' and ismember=1";
  66. if($enews==0)//栏目最新
  67. {
  68. $query.=' and ('.$where.')';
  69. $order='newstime';
  70. $yhvar='bqnew';
  71. }
  72. elseif($enews==1)//栏目热门
  73. {
  74. $query.=' and ('.$where.')';
  75. $order='onclick';
  76. $yhvar='bqhot';
  77. }
  78. elseif($enews==2)//栏目推荐
  79. {
  80. $query.=' and ('.$where.') and isgood>0';
  81. $order='newstime';
  82. $yhvar='bqgood';
  83. }
  84. elseif($enews==9)//栏目评论排行
  85. {
  86. $query.=' and ('.$where.')';
  87. $order='plnum';
  88. $yhvar='bqpl';
  89. }
  90. elseif($enews==12)//栏目头条
  91. {
  92. $query.=' and ('.$where.') and firsttitle>0';
  93. $order='newstime';
  94. $yhvar='bqfirst';
  95. }
  96. elseif($enews==15)//栏目下载排行
  97. {
  98. $query.=' and ('.$where.')';
  99. $order='totaldown';
  100. $yhvar='bqdown';
  101. }
  102. elseif($enews==3)//所有最新
  103. {
  104. $order='newstime';
  105. $tbname=$public_r[tbname];
  106. $mid=$etable_r[$tbname][mid];
  107. $yhvar='bqnew';
  108. $yhid=$etable_r[$tbname][yhid];
  109. }
  110. elseif($enews==4)//所有点击排行
  111. {
  112. $order='onclick';
  113. $tbname=$public_r[tbname];
  114. $mid=$etable_r[$tbname][mid];
  115. $yhvar='bqhot';
  116. $yhid=$etable_r[$tbname][yhid];
  117. }
  118. elseif($enews==5)//所有推荐
  119. {
  120. $query.=' and isgood>0';
  121. $order='newstime';
  122. $tbname=$public_r[tbname];
  123. $mid=$etable_r[$tbname][mid];
  124. $yhvar='bqgood';
  125. $yhid=$etable_r[$tbname][yhid];
  126. }
  127. elseif($enews==10)//所有评论排行
  128. {
  129. $order='plnum';
  130. $tbname=$public_r[tbname];
  131. $mid=$etable_r[$tbname][mid];
  132. $yhvar='bqpl';
  133. $yhid=$etable_r[$tbname][yhid];
  134. }
  135. elseif($enews==13)//所有头条
  136. {
  137. $query.=' and firsttitle>0';
  138. $order='newstime';
  139. $tbname=$public_r[tbname];
  140. $mid=$etable_r[$tbname][mid];
  141. $yhvar='bqfirst';
  142. $yhid=$etable_r[$tbname][yhid];
  143. }
  144. elseif($enews==16)//所有下载排行
  145. {
  146. $order='totaldown';
  147. $tbname=$public_r[tbname];
  148. $mid=$etable_r[$tbname][mid];
  149. $yhvar='bqdown';
  150. $yhid=$etable_r[$tbname][yhid];
  151. }
  152. elseif($enews==18)//各表最新
  153. {
  154. $order='newstime';
  155. $tbname=$classid;
  156. $mid=$etable_r[$tbname][mid];
  157. $yhvar='bqnew';
  158. $yhid=$etable_r[$tbname][yhid];
  159. }
  160. elseif($enews==19)//各表热门
  161. {
  162. $order='onclick';
  163. $tbname=$classid;
  164. $mid=$etable_r[$tbname][mid];
  165. $yhvar='bqhot';
  166. $yhid=$etable_r[$tbname][yhid];
  167. }
  168. elseif($enews==20)//各表推荐
  169. {
  170. $query.=' and isgood>0';
  171. $order='newstime';
  172. $tbname=$classid;
  173. $mid=$etable_r[$tbname][mid];
  174. $yhvar='bqgood';
  175. $yhid=$etable_r[$tbname][yhid];
  176. }
  177. elseif($enews==21)//各表评论排行
  178. {
  179. $order='plnum';
  180. $tbname=$classid;
  181. $mid=$etable_r[$tbname][mid];
  182. $yhvar='bqpl';
  183. $yhid=$etable_r[$tbname][yhid];
  184. }
  185. elseif($enews==22)//各表头条信息
  186. {
  187. $query.=' and firsttitle>0';
  188. $order="newstime";
  189. $tbname=$classid;
  190. $mid=$etable_r[$tbname][mid];
  191. $yhvar='bqfirst';
  192. $yhid=$etable_r[$tbname][yhid];
  193. }
  194. elseif($enews==23)//各表下载排行
  195. {
  196. $order='totaldown';
  197. $tbname=$classid;
  198. $mid=$etable_r[$tbname][mid];
  199. $yhvar='bqdown';
  200. $yhid=$etable_r[$tbname][yhid];
  201. }
  202. elseif($enews==25)//标题分类最新
  203. {
  204. $query.=' and ('.$where.')';
  205. $order='newstime';
  206. $yhvar='bqnew';
  207. }
  208. elseif($enews==26)//标题分类点击排行
  209. {
  210. $query.=' and ('.$where.')';
  211. $order='onclick';
  212. $yhvar='bqhot';
  213. }
  214. elseif($enews==27)//标题分类推荐
  215. {
  216. $query.=' and ('.$where.') and isgood>0';
  217. $order='newstime';
  218. $yhvar='bqgood';
  219. }
  220. elseif($enews==28)//标题分类评论排行
  221. {
  222. $query.=' and ('.$where.')';
  223. $order='plnum';
  224. $yhvar='bqpl';
  225. }
  226. elseif($enews==29)//标题分类头条
  227. {
  228. $query.=' and ('.$where.') and firsttitle>0';
  229. $order='newstime';
  230. $yhvar='bqfirst';
  231. }
  232. elseif($enews==30)//标题分类下载排行
  233. {
  234. $query.=' and ('.$where.')';
  235. $order='totaldown';
  236. $yhvar='bqdown';
  237. }
  238. //优化
  239. $yhadd='';
  240. if(!empty($eyh_r[$yhid]['dosbq']))
  241. {
  242. $yhadd=ReturnYhSql($yhid,$yhvar);
  243. if(!empty($yhadd))
  244. {
  245. $query.=' and '.$yhadd;
  246. }
  247. }
  248. //不调用
  249. if(!strstr($public_r['nottobq'],','.$classid.','))
  250. {
  251. $notbqwhere=ReturnNottoBqWhere();
  252. if(!empty($notbqwhere))
  253. {
  254. $query.=' and '.$notbqwhere;
  255. }
  256. }
  257. //图片信息
  258. if(!empty($do))
  259. {
  260. $query.=" and ispic=1";
  261. }
  262. //附加条件
  263. if(!empty($ewhere))
  264. {
  265. $query.=' and ('.$ewhere.')';
  266. }
  267. //中止
  268. if(empty($tbname))
  269. {
  270. echo "ClassID=<b>".$classid."</b> Table not exists.(DoType=".$enews.")";
  271. return false;
  272. }
  273. //排序
  274. $addorder=empty($eorder)?$order.' desc':$eorder;
  275. $query='select '.ReturnSqlListF($mid).' from '.$dbtbpre.'ecms_'.$tbname.$query.' order by '.$addorder.' limit '.$line;
  276. $sql=$empire->query1($query);
  277. if(!$sql)
  278. {
  279. echo"SQL Error: ".ReRepSqlTbpre($query);
  280. }
  281. return $sql;
  282. }
  283. //灵动标签:返回SQL内容函数
  284. function espace_eloop($classid=0,$line=10,$enews=3,$doing=0,$ewhere='',$eorder=''){
  285. return espace_ReturnBqQuery($classid,$line,$enews,$doing,$ewhere,$eorder);
  286. }
  287. //灵动标签:返回特殊内容函数
  288. function espace_eloop_sp($r){
  289. global $class_r;
  290. $sr['titleurl']=sys_ReturnBqTitleLink($r);
  291. $sr['classname']=$class_r[$r[classid]][bname]?$class_r[$r[classid]][bname]:$class_r[$r[classid]][classname];
  292. $sr['classurl']=sys_ReturnBqClassname($r,9);
  293. return $sr;
  294. }
  295. ?>