Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[疑难] 问个菜鸟问题,不喜误入

[复制链接]
ty424919 发表于 2009-10-6 08:30:45 | 显示全部楼层 |阅读模式
  1. <?
  2. if(!defined('IN_UCHOME')) {
  3. exit('Access Denied');
  4. }
  5. include_once(S_ROOT.'./data/data_indexjufeng.php');
  6. include_once(S_ROOT.'./data/data_huandeng.php');
  7. $spacecount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT COUNT(*) FROM '.tname('space')),0);
  8. $cachefile = S_ROOT.'./data/cache_indexjufeng_blog.txt';
  9. if(check_indexjufeng_cache('blog')) {
  10. $bloglist = unserialize(sreadfile($cachefile));
  11. }else {
  12. $sqlarr = mk_indexjufeng_sql('blog',
  13. array('blogid','uid'),
  14. array('hot','viewnum','replynum'),
  15. array('dateline'),
  16. array('dateline','viewnum','replynum','hot')
  17. );
  18. extract($sqlarr);
  19. $wherearr[] = "main.friend='0'";
  20. $query = $_SGLOBAL['db']->query('SELECT main.*, field.*
  21.                 FROM '.tname('blog').' main
  22.                 LEFT JOIN '.tname('blogfield').' field ON field.blogid=main.blogid
  23.                 WHERE '.implode(' AND ',$wherearr)." AND main.pic<>''
  24.                 ORDER BY RAND() LIMIT 0,1");
  25. $bloglist = array();
  26. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  27. if($value['pic']) $value['pic'] = pic_cover_get($value['pic'],$value['picflag']);
  28. $value['title'] = getstr($value['message'],0,0,0,0,0,-1);
  29. $value['message'] = getstr($value['message'],66,0,0,0,0,-1);
  30. $value['subject'] = getstr($value['subject'],50,0,0,0,0,-1);
  31. $bloglist[] = $value;
  32. }
  33. if($_SGLOBAL['indexjufeng']['blog']['cache']) {
  34. swritefile($cachefile,serialize($bloglist));
  35. }
  36. }
  37. foreach($bloglist as $key =>$value) {
  38. realname_set($value['uid'],$value['username']);
  39. $bloglist[$key] = $value;
  40. }
  41. $cachefile = S_ROOT.'./data/cache_huandeng1_blog.txt';
  42. if(check_huandeng_cache('blog')) {
  43. $erblog = unserialize(sreadfile($cachefile));
  44. }else {
  45. $sqlarr = mk_huandeng_sql('blog',
  46. array('blogid','uid'),
  47. array('hot','viewnum','replynum'),
  48. array('dateline'),
  49. array('dateline','viewnum','replynum','hot')
  50. );
  51. extract($sqlarr);
  52. $wherearr[] = "main.friend='0' and feeld.uid=field.uid";
  53. $query = $_SGLOBAL['db']->query('SELECT main.*, field.*, feeld.*
  54.                 FROM '.tname('blog').' main
  55.                 LEFT JOIN '.tname('blogfield').' field ON field.blogid=main.blogid
  56.                 LEFT JOIN '.tname('class').' feeld ON feeld.classid=main.classid
  57.                 WHERE '.implode(' AND ',$wherearr)."
  58.                 ORDER BY main.{$order} $sc LIMIT 0,3");
  59. $erblog = array();
  60. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  61. $value['subject'] = getstr($value['subject'],50,0,0,0,0,-1);
  62. $erblog[] = $value;
  63. }
  64. if($_SGLOBAL['huandeng']['blog']['cache']) {
  65. swritefile($cachefile,serialize($erblog));
  66. }
  67. }
  68. foreach($erblog as $key =>$value) {
  69. realname_set($value['uid'],$value['username']);
  70. $erblog[$key] = $value;
  71. }
  72. $cachefile = S_ROOT.'./data/cache_huandeng_blog.txt';
  73. if(check_huandeng_cache('blog')) {
  74. $bablog = unserialize(sreadfile($cachefile));
  75. }else {
  76. $sqlarr = mk_huandeng_sql('blog',
  77. array('blogid','uid'),
  78. array('hot','viewnum','replynum'),
  79. array('dateline'),
  80. array('dateline','viewnum','replynum','hot')
  81. );
  82. extract($sqlarr);
  83. $wherearr[] = "main.friend='0' and main.uid=feeld.uid";
  84. $query = $_SGLOBAL['db']->query('SELECT main.*, field.*, feeld.*
  85.                 FROM '.tname('blog').' main
  86.                 LEFT JOIN '.tname('blogfield').' field ON field.blogid=main.blogid
  87.                 LEFT JOIN '.tname('class').' feeld ON feeld.classid=main.classid
  88.                 WHERE '.implode(' AND ',$wherearr)."
  89.                 ORDER BY main.{$order} $sc LIMIT 4,8");
  90. $bablog = array();
  91. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  92. $value['subject'] = getstr($value['subject'],50,0,0,0,0,-1);
  93. $bablog[] = $value;
  94. }
  95. if($_SGLOBAL['huandeng']['blog']['cache']) {
  96. swritefile($cachefile,serialize($bablog));
  97. }
  98. }
  99. foreach($bablog as $key =>$value) {
  100. realname_set($value['uid'],$value['username']);
  101. $bablog[$key] = $value;
  102. }
  103. $cachefile = S_ROOT.'./data/cache_indexjufeng_pic.txt';
  104. if(check_indexjufeng_cache('pic')) {
  105. $piclist = unserialize(sreadfile($cachefile));
  106. }else {
  107. $sqlarr = mk_indexjufeng_sql('pic',
  108. array('picid','uid'),
  109. array('hot'),
  110. array('dateline'),
  111. array('dateline','hot')
  112. );
  113. extract($sqlarr);
  114. $shownum = 5;
  115. $piclist = array();
  116. $query = $_SGLOBAL['db']->query('SELECT album.albumname, album.friend, space.username, space.name, space.namestatus, main.*
  117.                 FROM '.tname('pic').' main
  118.                 LEFT JOIN '.tname('album').' album ON album.albumid=main.albumid
  119.                 LEFT JOIN '.tname('space').' space ON space.uid=main.uid
  120.                 WHERE '.implode(' AND ',$wherearr)."
  121.                 ORDER BY main.{$order} $sc LIMIT 0,$shownum");
  122. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  123. if(empty($value['friend'])) {
  124. $value['pic'] = pic_get($value['filepath'],$value['remote']);
  125. $piclist[] = $value;
  126. }
  127. }
  128. if($_SGLOBAL['indexjufeng']['pic']['cache']) {
  129. swritefile($cachefile,serialize($piclist));
  130. }
  131. }
  132. foreach($piclist as $key =>$value) {
  133. realname_set($value['uid'],$value['username'],$value['name'],$value['namestatus']);
  134. $piclist[$key] = $value;
  135. }
  136. $cachefile = S_ROOT.'./data/cache_huandeng_pic.txt';
  137. if(check_huandeng_cache('pic')) {
  138. $albumlist = unserialize(sreadfile($cachefile));
  139. }else {
  140. $sqlarr = mk_huandeng_sql('pic',
  141. array('picid','uid'),
  142. array('hot'),
  143. array('dateline'),
  144. array('dateline','hot')
  145. );
  146. extract($sqlarr);
  147. $shownum = 8;
  148. $wherearr[] = "main.albumid != '0'";
  149. $albumlist = array();
  150. $query = $_SGLOBAL['db']->query('SELECT album.albumname, album.friend, album.albumname, space.username, space.name, space.namestatus, main.*
  151.                 FROM '.tname('pic').' main
  152.                 LEFT JOIN '.tname('album').' album ON album.albumid=main.albumid
  153.                 LEFT JOIN '.tname('space').' space ON space.uid=main.uid
  154.                 WHERE '.implode(' AND ',$wherearr)."
  155.                 ORDER BY main.{$order} $sc LIMIT 0,$shownum");
  156. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  157. if(empty($value['friend'])) {
  158. $value['pic'] = pic_get($value['filepath'],$value['remote']);
  159. $albumlist[] = $value;
  160. }
  161. }
  162. if($_SGLOBAL['huandeng']['pic']['cache']) {
  163. swritefile($cachefile,serialize($albumlist));
  164. }
  165. }
  166. foreach($albumlist as $key =>$value) {
  167. realname_set($value['uid'],$value['username'],$value['name'],$value['albumname'],$value['namestatus']);
  168. $albumlist[$key] = $value;
  169. }
  170. $cachefile = S_ROOT.'./data/cache_indexjufeng_thread.txt';
  171. if(check_indexjufeng_cache('thread')) {
  172. $gonggao = unserialize(sreadfile($cachefile));
  173. }else {
  174. $sqlarr = mk_indexjufeng_sql('thread',
  175. array('tid','uid'),
  176. array('hot','viewnum','replynum'),
  177. array('dateline','lastpost'),
  178. array('dateline','viewnum','replynum','hot')
  179. );
  180. extract($sqlarr);
  181. $shownum = 10;
  182. $gonggao = array();
  183. $query = $_SGLOBAL['db']->query('SELECT main.*, m.tagname
  184.                 FROM '.tname('thread').' main
  185.                 LEFT JOIN '.tname('mtag').' m ON m.tagid=main.tagid
  186.                 WHERE '.implode(' AND ',$wherearr)."
  187.                 ORDER BY main.{$order} $sc LIMIT 0,$shownum");
  188. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  189. $value['tagname'] = getstr($value['tagname'],20);
  190. $value['subject'] = getstr($value['subject'],50);
  191. $gonggao[] = $value;
  192. }
  193. if($_SGLOBAL['indexjufeng']['thread']['cache']) {
  194. swritefile($cachefile,serialize($gonggao));
  195. }
  196. }
  197. foreach($gonggao as $key =>$value) {
  198. realname_set($value['uid'],$value['username']);
  199. $gonggao[$key] = $value;
  200. }
  201. $cachefile = S_ROOT.'./data/cache_huandeng_thread.txt';
  202. if(check_huandeng_cache('thread')) {
  203. $threadlist = unserialize(sreadfile($cachefile));
  204. }else {
  205. $sqlarr = mk_huandeng_sql('thread',
  206. array('tid','uid'),
  207. array('hot','viewnum','replynum'),
  208. array('dateline','lastpost'),
  209. array('dateline','viewnum','replynum','hot')
  210. );
  211. extract($sqlarr);
  212. $shownum = 3;
  213. $threadlist = array();
  214. $query = $_SGLOBAL['db']->query('SELECT main.*, m.tagname
  215.                 FROM '.tname('thread').' main
  216.                 LEFT JOIN '.tname('mtag').' m ON m.tagid=main.tagid
  217.                 WHERE '.implode(' AND ',$wherearr)."
  218.                 ORDER BY main.{$order} $sc LIMIT 0,$shownum");
  219. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  220. $value['tagname'] = getstr($value['tagname'],20);
  221. $threadlist[] = $value;
  222. }
  223. if($_SGLOBAL['huandeng']['thread']['cache']) {
  224. swritefile($cachefile,serialize($threadlist));
  225. }
  226. }
  227. foreach($threadlist as $key =>$value) {
  228. realname_set($value['uid'],$value['username']);
  229. $threadlist[$key] = $value;
  230. }
  231. include_once(S_ROOT.'./data/data_eventclass.php');
  232. $cachefile = S_ROOT.'./data/cache_indexjufeng_event.txt';
  233. if(check_indexjufeng_cache('event')) {
  234. $eventlist = unserialize(sreadfile($cachefile));
  235. }else {
  236. $sqlarr = mk_indexjufeng_sql('event',
  237. array('eventid','uid'),
  238. array('hot','membernum','follownum'),
  239. array('dateline'),
  240. array('dateline','membernum','follownum','hot')
  241. );
  242. extract($sqlarr);
  243. $shownum = 4;
  244. $eventlist = array();
  245. $query = $_SGLOBAL['db']->query('SELECT main.*
  246.                 FROM '.tname('event').' main
  247.                 WHERE '.implode(' AND ',$wherearr)."
  248.                 ORDER BY main.{$order} $sc LIMIT 0,$shownum");
  249. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  250. $value['title'] = getstr($value['title'],45);
  251. if($value['poster']){
  252. $value['pic'] = pic_get($value['poster'],$value['thumb'],$value['remote']);
  253. }else {
  254. $value['pic'] = $_SGLOBAL['eventclass'][$value['classid']]['poster'];
  255. }
  256. $eventlist[] = $value;
  257. }
  258. if($_SGLOBAL['indexjufeng']['event']['cache']) {
  259. swritefile($cachefile,serialize($eventlist));
  260. }
  261. }
  262. foreach($eventlist as $key =>$value) {
  263. realname_set($value['uid'],$value['username']);
  264. $eventlist[$key] = $value;
  265. }
  266. $feedlist = array();
  267. if(ckprivacy('feed')) {
  268. $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('feed')." WHERE friend='0' ORDER BY dateline DESC LIMIT 0,20");
  269. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  270. if(ckfriend($value['uid'],$value['friend'],$value['target_ids'])) {
  271. realname_set($value['uid'],$value['username']);
  272. $feedlist[] = $value;
  273. }
  274. }
  275. $feednum = count($feedlist);
  276. }
  277. $mtaglist = $mtaglist = array();
  278. $query = $_SGLOBAL['db']->query('SELECT tagid,tagname,membernum,pic,announcement FROM '.tname('mtag').' ORDER BY membernum DESC LIMIT 0,3');
  279. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  280. if(empty($value['pic'])) {
  281. $value['pic'] = 'image/nologo.jpg';
  282. }
  283. $value['title'] = getstr($value['announcement'],0,0,0,0,0,-1);
  284. $mtaglist[] = $value;
  285. }
  286. $jiluspacelist = array();
  287. $query = $_SGLOBAL['db']->query('SELECT a.uid,a.username,a.name,a.namestatus,b.uid,b.doid,b.message,b.dateline FROM '.tname('space').' a, '.tname('doing')." b where a.uid=b.uid and a.updatetime>'$wheretime' and b.doid in (select max(doid) from ".tname('doing').' b group by b.uid) ORDER BY b.dateline DESC LIMIT 0,3
  288. ');
  289. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  290. realname_set($value['uid'],$value['username'],$value['name'],$value['namestatus']);
  291. $value['title'] = getstr($value['message'],0,0,0,0,0,-1);
  292. $jiluspacelist[] = $value;
  293. }
  294. $myappcount = 0;
  295. $myapplist = array();
  296. if($_SCONFIG['my_status']) {
  297. $myappcount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT COUNT(*) FROM '.tname('myapp')." WHERE flag>='0'"),0);
  298. if($myappcount) {
  299. $query = $_SGLOBAL['db']->query('SELECT appid,appname FROM '.tname('myapp').' WHERE flag>=0 ORDER BY RAND() LIMIT 0,7');
  300. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  301. $myapplist[] = $value;
  302. }
  303. }
  304. }
  305. $sharelist = array();
  306. $query = $_SGLOBAL['db']->query('SELECT *
  307.         FROM '.tname('share').'
  308.         ORDER BY dateline DESC LIMIT 0,11');
  309. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  310. realname_set($value['uid'],$value['username']);
  311. $sharelist[] = $value;
  312. }
  313. foreach ($feedlist as $key =>$value) {
  314. $feedlist[$key] = mkfeed($value);
  315. }
  316. realname_get();
  317. $membername = empty($_SCOOKIE['loginuser'])?'':sstripslashes($_SCOOKIE['loginuser']);
  318. $wheretime = $_SGLOBAL['timestamp']-3600*24*30;
  319. if(empty($uid))
  320. {
  321. $uid=$_SGLOBAL['supe_uid'];
  322. }
  323. $sex        =        '';
  324. $space = getspace($uid);
  325. if($space['sex']==1)
  326. {
  327. $sex        =        2;
  328. }
  329. if($space['sex']==2)
  330. {
  331. $sex        =        1;
  332. }
  333. if(!empty($sex))
  334. {
  335. $wheresql        =        'where sex ='.$sex;
  336. }
  337. $onlinelist = array();
  338. $i=0;
  339. $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacefield').' '.$wheresql.'  ORDER BY rand() DESC');
  340. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
  341. if($i>=10)
  342. {
  343. break;
  344. }
  345. realname_set($value['uid'],$value['username']);
  346. if(!ckavatar($value['uid']))
  347. {
  348. continue;
  349. }
  350. else
  351. {
  352. $onlinelist[] = $value;
  353. $i++;
  354. }
  355. }
  356. $_TPL['css'] = 'indexjufeng';
  357. include_once template('indexjufeng');
  358. function check_indexjufeng_cache($type) {
  359. global $_SGLOBAL;
  360. if($_SGLOBAL['indexjufeng'][$type]['cache']) {
  361. $cachefile = S_ROOT.'./data/cache_indexjufeng_'.$type.'.txt';
  362. $ftime = filemtime($cachefile);
  363. if($_SGLOBAL['timestamp'] -$ftime <$_SGLOBAL['indexjufeng'][$type]['cache']) {
  364. return true;
  365. }
  366. }
  367. return false;
  368. }
  369. function check_huandeng_cache($type) {
  370. global $_SGLOBAL;
  371. if($_SGLOBAL['huandeng'][$type]['cache']) {
  372. $cachefile = S_ROOT.'./data/cache_huandeng_'.$type.'.txt';
  373. $ftime = filemtime($cachefile);
  374. if($_SGLOBAL['timestamp'] -$ftime <$_SGLOBAL['huandeng'][$type]['cache']) {
  375. return true;
  376. }
  377. }
  378. return false;
  379. }
  380. function mk_indexjufeng_sql($type,$ids,$crops,$days,$orders) {
  381. global $_SGLOBAL;
  382. $nt = $_SGLOBAL['indexjufeng'][$type];
  383. $wherearr = array('1');
  384. foreach ($ids as $value) {
  385. if($nt[$value]) {
  386. $wherearr[] = "main.{$value} IN (".$nt[$value].')';
  387. }
  388. }
  389. foreach ($crops as $value) {
  390. $value1 = $value.'1';
  391. $value2 = $value.'2';
  392. if($nt[$value1]) {
  393. $wherearr[] = "main.{$value} >= '".$nt[$value1]."'";
  394. }
  395. if($nt[$value2]) {
  396. $wherearr[] = "main.{$value} <= '".$nt[$value2]."'";
  397. }
  398. }
  399. foreach ($days as $value) {
  400. if($nt[$value]) {
  401. $daytime = $_SGLOBAL['timestamp'] -$nt[$value]*3600*24;
  402. $wherearr[] = "main.{$value}>='$daytime'";
  403. }
  404. }
  405. $order = in_array($nt['order'],$orders)?$nt['order']:array_shift($orders);
  406. $sc = in_array($nt['sc'],array('desc','asc'))?$nt['sc']:'desc';
  407. return array('wherearr'=>$wherearr,'order'=>$order,'sc'=>$sc);
  408. }
  409. function mk_huandeng_sql($type,$ids,$crops,$days,$orders) {
  410. global $_SGLOBAL;
  411. $nt = $_SGLOBAL['huandeng'][$type];
  412. $wherearr = array('1');
  413. foreach ($ids as $value) {
  414. if($nt[$value]) {
  415. $wherearr[] = "main.{$value} IN (".$nt[$value].')';
  416. }
  417. }
  418. foreach ($crops as $value) {
  419. $value1 = $value.'1';
  420. $value2 = $value.'2';
  421. if($nt[$value1]) {
  422. $wherearr[] = "main.{$value} >= '".$nt[$value1]."'";
  423. }
  424. if($nt[$value2]) {
  425. $wherearr[] = "main.{$value} <= '".$nt[$value2]."'";
  426. }
  427. }
  428. foreach ($days as $value) {
  429. if($nt[$value]) {
  430. $daytime = $_SGLOBAL['timestamp'] -$nt[$value]*3600*24;
  431. $wherearr[] = "main.{$value}>='$daytime'";
  432. }
  433. }
  434. $order = in_array($nt['order'],$orders)?$nt['order']:array_shift($orders);
  435. $sc = in_array($nt['sc'],array('desc','asc'))?$nt['sc']:'desc';
  436. return array('wherearr'=>$wherearr,'order'=>$order,'sc'=>$sc);
  437. }
  438. ?>
复制代码
谁帮我从中分离出 可以调用 【message】这个表,像下图一样的调用





请高手帮忙,顺便告诉我使用方法

  如果你提供有偿服务,只要价格合理,请留下QQ 号码。马上开学了,我得尽快搞,感谢!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
ylkj 发表于 2009-10-6 08:56:20 | 显示全部楼层
发代码尽量精简
DZ的代码又没有语法高亮,谁愿意看啊
回复

使用道具 举报

 楼主| ty424919 发表于 2009-10-6 09:51:45 | 显示全部楼层
发代码尽量精简
DZ的代码又没有语法高亮,谁愿意看啊
ylkj 发表于 2009-10-6 08:56



回复

使用道具 举报

coldhair 发表于 2009-10-6 10:34:48 | 显示全部楼层
太长了,没法找啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-18 14:38 , Processed in 0.018371 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表