OSDN Git Service

Fixed some bugs and some more runtime errors. PHP Notice errors.
[idb/iDB.git.git] / inc / categories.php
1 <?php
2 /*
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the Revised BSD License.
5
6     This program is distributed in the hope that it will be useful,
7     but WITHOUT ANY WARRANTY; without even the implied warranty of
8     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9     Revised BSD License for more details.
10
11     Copyright 2004-2007 Cool Dude 2k - http://intdb.sourceforge.net/
12     Copyright 2004-2007 Game Maker 2k - http://upload.idb.s1.jcink.com/
13
14     $FileInfo: categories.php - Last Update: 07/31/2007 SVN 59 - Author: cooldude2k $
15 */
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="categories.php"||$File3Name=="/categories.php") {
18         require('index.php');
19         exit(); }
20 $prequery = query("select * from `".$Settings['sqltable']."categories` where `id`=%i and `ShowCategory`='yes'", array($_GET['id']));
21 $preresult=mysql_query($prequery);
22 $prenum=mysql_num_rows($preresult);
23 $prei=0;
24 if($prenum==0) { redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
25 while ($prei < $prenum) {
26 $CategoryID=mysql_result($preresult,$prei,"id");
27 $CategoryName=mysql_result($preresult,$prei,"Name");
28 $CategoryShow=mysql_result($preresult,$prei,"ShowCategory");
29 $CategoryType=mysql_result($preresult,$prei,"CategoryType");
30 $SubShowForums=mysql_result($preresult,$prei,"SubShowForums");
31 $CategoryDescription=mysql_result($preresult,$prei,"Description");
32 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
33 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
34         $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
35 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
36         $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
37 redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
38 ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
39 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @mysql_close(); die(); }
40 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
41 if(!isset($CatCheck)) { $CatCheck = null; } 
42 if($CatCheck!="skip") {
43 if($CategoryType=="subcategory") {
44 redirect("location",$basedir.url_maker($exfile['subcategory'],$Settings['file_ext'],"act=".$_GET['act']."&id=".$_GET['id'],$Settings['qstr'],$Settings['qsep'],$prexqstr['subcategory'],$exqstr['subcategory'],FALSE));
45 ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
46 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @mysql_close(); die(); } }
47 $query = query("select * from `".$Settings['sqltable']."forums` where `ShowForum`='yes' and `CategoryID`=%i and `InSubForum`=0 ORDER BY `id`", array($CategoryID));
48 $result=mysql_query($query);
49 $num=mysql_num_rows($result);
50 $i=0;
51 if($num>=1) {
52 ?>
53 <div class="Table1Border">
54 <table id="Cat<?php echo $CategoryID; ?>" class="Table1">
55 <tr id="CatStart<?php echo $CategoryID; ?>" class="TableRow1">
56 <td class="TableRow1" colspan="5"><span style="float: left;">
57 <?php echo $ThemeSet['TitleIcon'] ?><a href="<?php echo url_maker($exfile[$CategoryType],$Settings['file_ext'],"act=view&id=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php echo $CategoryName; ?></a></span>
58 <?php echo "<span style=\"float: right;\">&nbsp;</span>"; ?></td>
59 </tr>
60 <tr id="ForumStatRow<?php echo $CategoryID; ?>" class="TableRow2">
61 <th class="TableRow2" style="width: 4%;">&nbsp;</th>
62 <th class="TableRow2" style="width: 58%;">Forum</th>
63 <th class="TableRow2" style="width: 7%;">Topics</th>
64 <th class="TableRow2" style="width: 7%;">Posts</th>
65 <th class="TableRow2" style="width: 24%;">Last Topic</th>
66 </tr>
67 <?php }
68 while ($i < $num) {
69 $ForumID=mysql_result($result,$i,"id");
70 $ForumName=mysql_result($result,$i,"Name");
71 $ForumShow=mysql_result($result,$i,"ShowForum");
72 $ForumType=mysql_result($result,$i,"ForumType");
73 $NumTopics=mysql_result($result,$i,"NumTopics");
74 $NumPosts=mysql_result($result,$i,"NumPosts");
75 $ForumDescription=mysql_result($result,$i,"Description");
76 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
77         $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
78 unset($LastTopic); if(!isset($LastTopic)) { $LastTopic = null; }
79 $gltquery = query("select * from `".$Settings['sqltable']."topics` where `CategoryID`=%i and `ForumID`=%i ORDER BY `LastUpdate` DESC", array($CategoryID,$ForumID));
80 $gltresult=mysql_query($gltquery);
81 $gltnum=mysql_num_rows($gltresult);
82 if($gltnum>0){
83 $TopicID=mysql_result($gltresult,0,"id");
84 $TopicName=mysql_result($gltresult,0,"TopicName");
85 $NumReplys=mysql_result($gltresult,0,"NumReply");
86 $ShowReply = $NumReplys + 1;
87 $TopicName1 = substr($TopicName,0,15);
88 if (strlen($TopicName)>12) { $TopicName1 = $TopicName1."..."; }
89 $UsersID=mysql_result($gltresult,0,"UserID");
90 $GuestName=mysql_result($gltresult,0,"GuestName");
91 $UsersName = GetUserName($UsersID,$Settings['sqltable']);
92 if($UsersName=="Guest") { $UsersName=$GuestName;
93 if($UsersName==null) { $UsersName="Guest"; } }
94 $UsersName1 = substr($UsersName,0,18);
95 if (strlen($UsersName)>15) { $UsersName1 = $UsersName1."...";
96 $oldtopicname=$TopicName; $oldusername=$UsersName;
97 $TopicName=$TopicName1; $UsersName=$UsersName1; } $lul = null;
98 if($UsersID!="-1") {
99 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
100 $LastTopic = "User: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName."</a><br />\nTopic: <a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."#post".$ShowReply."\" title=\"".$oldtopicname."\">".$TopicName."</a>"; }
101 if($UsersID=="-1") {
102 $LastTopic = "User: <span title=\"".$oldusername."\">".$UsersName."</span><br />\nTopic: <a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."#post".$ShowReply."\" title=\"".$oldtopicname."\">".$TopicName."</a>"; } }
103 @mysql_free_result($gltresult);
104 $ForumType = strtolower($ForumType);
105 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
106 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
107 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
108 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
109 ?>
110 <tr class="TableRow3" id="Forum<?php echo $ForumID; ?>">
111 <td class="TableRow3"><div class="forumicon">
112 <?php echo $PreForum; ?></div></td>
113 <td class="TableRow3"><div class="forumname"><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=view&id=".$ForumID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a></div>
114 <div class="forumescription"><?php echo $ForumDescription; ?></div></td>
115 <td class="TableRow3" style="text-align: center;"><?php echo $NumTopics; ?></td>
116 <td class="TableRow3" style="text-align: center;"><?php echo $NumPosts; ?></td>
117 <td class="TableRow3"><?php echo $LastTopic; ?></td>
118 </tr>
119 <?php } ++$i; } @mysql_free_result($result);
120 if($num>=1) { ?>
121 <tr id="CatEnd<?php echo $CategoryID; ?>" class="TableRow4">
122 <td class="TableRow4" colspan="5">&nbsp;</td>
123 </tr>
124 </table></div>
125 <div>&nbsp;</div>
126 <?php } } ++$prei; }
127 @mysql_free_result($preresult); ?>