C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\portal\modules\documents\mod.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
require("code.php");
if(
$code != $xcode) {
exit;
}
$cat strip_dir_illegals($cat);
$id strip_dir_illegals($id);
if(
$cat == "") {
echo <<<HTML

<center><b>Documents</b></center><hr noshade>
<table width="100%" 
$sp_table>
<tr 
$sp_htr><td width="100%" $sp_htd>Categories</td></tr>
HTML;
$i 0;
$i3 0;
$dir $mod_root."/categories/";
$handle = @opendir($dir);
if (
$handle) {
while (
$file readdir($handle)) {
if ((
$file != ".") && ($file != "..")) {
if (!
is_dir($dir $file)) $filelist[] = $file;
}
}
closedir($handle);
}
if (!empty(
$filelist)) {
natcasesort($filelist);
foreach (
$filelist as $singleFile) {
$f_size filesize($dir $singleFile);
$atime date("Y-m-d, H:i:s"fileatime($dir $singleFile));
$mtime date("Y-m-d, H:i:s"filemtime($dir $singleFile));
$path = @pathinfo($dir $singleFile);
if((
$singleFile != ".") && ($singleFile != "..") && ($singleFile != "index.html")) {
require(
$dir.$singleFile);
}
$info_arr[] = $file_name."||".$singleFile."||".$f_size;
clearstatcache();
}
if (
$sort == "date") {
arsort($info_arr);
}
natcasesort($info_arr);
foreach (
$info_arr as $single_z) {
$all explode("||"$single_z);
if(
$all[1] != "index.html") {
$name str_replace(".php","",$all[1]);
$dir2 $mod_root."/documents";
$handle2=@opendir($dir2);
 
$i2=0;
  while (
$file2 readdir($handle2))
 {
  if (
$file2 != "." && $file2 != ".." && $file2 != "index.html")
  {
$fn str_replace(".php","",$file2);
if(
str_replace($name."&","",$fn) != $name) {
if(
str_replace($name."&","",$fn) > 0) {
   
$i2++;
}
}
  }
 }
closedir($handle2);
echo 
"<tr $sp_ctr><td $sp_ctd><a href=\"".$mod_url."&cat=".$name."\">".str_replace("_"," ",$name)."</a> (".$i2.")</td></tr>\n";
$i3 $i3 $i2;
$i++;
}
}
}
echo <<<HTML

</table><br><br>
<center><small>There are 
$i categories with $i3 documents.</small><br></center><br>
HTML;
}
else {
if(
file_exists($mod_root."/categories/".$cat.".php")) {
$cat_caption str_replace("_"," ",$cat);
if(
$do == "post_comment") {
if(
$online == 1) {
// TO-DO: Post Comment //
}
else { 
$viv "Not_Logged_In"; }
}
if(
$do == "post_comment_go") {
if(
$online == 1) {
// TO-DO: Post Comment //
}
else { 
$viv "Not_Logged_In"; }
}
if(
$do == "view_document") {
if(
file_exists($mod_root."/documents/".$cat."&".$id.".php")) {
require(
$mod_root."/documents/".$cat."&".$id.".php");
$document_content add_emoticons(add_vxcode($document_content,0));
echo <<<HTML

<center>Documents : 
$cat_caption : $document_title</center><hr noshade>
<center>[<a href="
$mod_url&cat=$cat">Back to Documents : $cat_caption</a>]</center><br /><br />
<table width="100%" 
$sp_table>
<tr 
$sp_htr><td $sp_htd>$document_title</td></tr>
<tr 
$sp_ctr><td $sp_ctd>Posted by: $poster<br />Date Posted: $date_posted<br /></td></tr>
<tr 
$sp_ctr><td $sp_ctd>
<center>[<a href="
$mod_url&cat=$cat&do=post_comment&id=$id">Post a Comment</a>]</center><br />
</td></tr>
<tr 
$sp_ctr><td $sp_ctd>
$document_content
</td></tr>
<tr 
$sp_ctr><td $sp_ctd>
<center>[<a href="
$mod_url&cat=$cat&do=post_comment&id=$id">Post a Comment</a>|]</center><br />
</td></tr>
</table><br />
HTML;
if(
$document_comments != "") {
$comments_arr explode("||",$document_comments);
foreach(
$comments_arr as $single) {
$arr explode("&&",$single);
echo <<<HTML

<table width="100%" 
$sp_table>
<tr 
$sp_htr><td colspan="2" $sp_htd>$arr[0]</td></tr>
<tr 
$sp_ctr><td $sp_ctd>
<a href="
$url/load.php?viv=Profile&user=$arr[1]">$arr[1]</a><br />
<br />
$arr[2]<br />
<br />
</td><td 
$sp_ctd>
$arr[3]
</td></tr>
</table><br />
HTML;
}
}
else { echo 
"There are no comments for this document.<br>"; }
echo <<<HTML

<br />
<center>[<a href="
$mod_url&cat=$cat">Back to Documents : $cat_caption</a>]</center><br /><br />
HTML;
}
else { 
derr("Document <i>".$id."</i> not found."); }
}
if(
$do == "") {
echo <<<HTML

<center><b>Documents : 
$cat_caption</b></center><hr noshade>
<center>
[<a href="
$mod_url">Back to Documents Main</a>]<br><br>
HTML;
if((
$online == 1) && ($u_rank >= $rank_required['mod_post'])) {
echo 
"[<a href=\"".$admin_url."&do=post_document&cat=".$cat."\">Post a Document</a>]<br><br>\n";
}
echo <<<HTML

<table width="100%" 
$sp_table>
<tr 
$sp_htr><td width="50%" $sp_htd>Document Name</td><td width="20%" $sp_htd>Posted By</td><td width="30%" $sp_htd>Date Posted</td></tr>
HTML;
$i 0;
$dir $mod_root."/documents/";
$handle = @opendir($dir);
if (
$handle) {
while (
$file readdir($handle)) {
if ((
$file != ".") && ($file != "..")) {
if (!
is_dir($dir $file)) $filelist[] = $file;
}
}
closedir($handle);
}
if (!empty(
$filelist)) {
natcasesort($filelist);
foreach (
$filelist as $singleFile) {
$f_size filesize($dir $singleFile);
$atime date("Y-m-d, H:i:s"fileatime($dir $singleFile));
$mtime date("Y-m-d, H:i:s"filemtime($dir $singleFile));
$path = @pathinfo($dir $singleFile);
if((
$singleFile != ".") && ($singleFile != "..") && ($singleFile != "index.html")) {
require(
$dir.$singleFile);
}
$info_arr[] = $file_name."||".$singleFile."||".$f_size;
clearstatcache();
}
natcasesort($info_arr);
foreach (
$info_arr as $single_z) {
$all explode("||"$single_z);
if(
$all[1] != "index.html") {
$fn str_replace(".php","",$all[1]);
if(
str_replace($cat."&","",$fn) != $fn) {
if(
str_replace($cat."&","",$fn) > 0) {
$document_id str_replace($cat."&","",$fn);
require(
$dir.$all[1]);
$admin_options "";
if(
$online == 1) {
if(
$u_rank >= $rank_required['mod_edit']) {
$admin_options $admin_options " [<a href=\"$admin_url&do=edit_document&cat=$cat&id=$document_id\">Edit</a>]";
}
if(
$u_rank >= $rank_required['mod_delete']) {
$admin_options $admin_options " [<a href=\"$admin_url&do=delete_document&cat=$cat&id=$document_id\">Delete</a>]";
}
}
echo <<<HTML

<tr 
$sp_ctr><td $sp_ctd><table width="100%"><tr><td align="left"><a href="$mod_url&cat=$cat&do=view_document&id=$document_id">$document_title</a></td><td align="right">$admin_options</td></tr></table></td><td $sp_ctd><a href="load.php?viv=Profile&user=$poster">$poster</a></td><td $sp_ctd>$date_posted</td></tr>
HTML;
$i++;
}
}
}
}
}
echo <<<HTML

</table><br>
HTML;
if((
$online == 1) && ($u_rank >= $rank_required['mod_post'])) {
echo 
"[<a href=\"".$admin_url."&do=post_document&cat=".$cat."\">Post a Document</a>]<br><br>\n";
}
echo <<<HTML

[<a href="
$mod_url">Back to Documents Main</a>]<br><br>
<small>There are 
$i documents in $cat_caption.</small><br>
</center><br>
HTML;
}
}
else { 
derr("Category <i>".$cat."</i> not found."); }
}
?>