File: file_activity.php

package info (click to toggle)
owl-dms 0.90-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 17,292 kB
  • ctags: 10,919
  • sloc: php: 48,457; sql: 3,603; sh: 363; perl: 204; makefile: 73
file content (340 lines) | stat: -rw-r--r-- 9,776 bytes parent folder | download
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
 * file_activity.php
 * 
 * Copyright (c) 1999-2005 The Owl Project Team
 * Licensed under the GNU GPL. For full terms see the file COPYING.
 *
 * Author: Steve Bourgeois <owl@bozzit.com>
 * Project Founder: Chris Vincent <cvincent@project802.net>
 * 
 * $Id: file_activity.php,v 1.2 2006/01/04 20:57:50 b0zz Exp $
 */


$CountLines = 0;
$sql = new Owl_DB;
$sql->query("SELECT creatorid, sum(f_size) as total_size , count(*) as num_files from $default->owl_files_table group by creatorid order by num_files desc");
print("<tr>\n");
print("<td class='title1' colspan='3'>$owl_lang->username</td>\n");
print("<td class='title1'>$owl_lang->tot_files</td>");
print("</tr>\n");

print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");

// 
// User File Stats BEGIN
// 
print("<td class='admin2' align='left' colspan='4'>$owl_lang->stats_files</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");

$iGrandFileTotal = 0;
$iGrandSizeTotal = 0;
while ($sql->next_record())
{
   $CountLines++;
   $PrintLines = $CountLines % 2;
   if ($PrintLines == 0)
   {
      $sTrClass = "file1";
      $sLfList = "lfile1";
   }
   else
   {  
      $sTrClass = "file2";
      $sLfList = "lfile1";
   }
      
   print("\t\t\t\t<tr>\n");

   print("<td class='$sTrClass' colspan='2'>" . uid_to_name($sql->f("creatorid")) . "</td>\n");
   print("<td class='$sTrClass'>" . $sql->f("num_files") . "</td>\n");
   $iGrandFileTotal = $iGrandFileTotal + $sql->f("num_files");
   print("<td class='$sTrClass'>" . gen_filesize($sql->f("total_size")) . "</td>\n");
   $iGrandSizeTotal = $iGrandSizeTotal + $sql->f("total_size");
   print("</tr>\n");
} 
print("<tr>\n");
print("<td class='title1' colspan='2'>$owl_lang->tot_files</td>\n");
print("<td class='title1'>$iGrandFileTotal</td>\n");
print("<td class='title1'>" . gen_filesize($iGrandSizeTotal) . "</td>\n");
print("</tr>\n");
// 
// User File Stats END
// 
// 
// User Folder Stats BEGIN
// 
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td class='admin2' align='left' colspan='4'>$owl_lang->stats_folders</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");

$sql->query("SELECT creatorid , count(*) as num_folders from $default->owl_folders_table group by creatorid order by num_folders desc");

$iGrandFolderTotal = 0;
while ($sql->next_record())
{
   $CountLines++;
   $PrintLines = $CountLines % 2;
   if ($PrintLines == 0)
   {
      $sTrClass = "file1";
      $sLfList = "lfile1";
   }
   else
   {  
      $sTrClass = "file2";
      $sLfList = "lfile1";
   }
      
   print("\t\t\t\t<tr>\n");
   print("<td class='$sTrClass' colspan='3'>" . uid_to_name($sql->f("creatorid")) . "</td>\n");
   print("<td class='$sTrClass'>" . $sql->f("num_folders") . "</td>\n");
   $iGrandFolderTotal = $iGrandFolderTotal + $sql->f("num_folders");
   print("</tr>\n");
} 
print("<tr>\n");
print("<td class='title1' colspan='3'>$owl_lang->tot_files</td>\n");
print("<td class='title1'>$iGrandFolderTotal</td>\n");
print("</tr>\n");
// 
// User Folder Stats END
// 
if ($default->logging && $default->log_file)
{ 
   // 
   // User Logon Stats BEGIN
   // 
   print("<tr>\n");
   print("<td align='left' colspan='3'>&nbsp;</td>\n");
   print("<td align='left'>&nbsp;</td>\n");
   print("</tr>\n");
   print("<tr>\n");
   print("<td  class='admin2' colspan='4'>$owl_lang->stats_users</td>\n");
   print("<td align='left'>&nbsp;</td>\n");
   print("</tr>\n");
   print("<tr>\n");
   print("<td align='left' colspan='3'>&nbsp;</td>\n");
   print("<td align='left'>&nbsp;</td>\n");
   print("</tr>\n");

   $sql->query("select count(*) as num_action, userid, action  from $default->owl_log_table where type='LOGIN' group by userid, action");

   $iGrandLoginTotal = 0;
   $iGrandLogoutTotal = 0;
   $iGrandFailedTotal = 0;
   $SaveUser = -1;
   $iLoginTotal = 0;
   $iLogoutTotal = 0;
   $iFailedTotal = 0;

   while ($sql->next_record())
   {
      if ($SaveUser <> $sql->f("userid"))
      {
         if ($SaveUser <> -1)
         {
            print("($iLoginTotal / $iFailedTotal / $iLogoutTotal )");
            print("</td>\n");
            print("</tr>\n");
            $iGrandLoginTotal = $iGrandLoginTotal + $iLoginTotal;
            $iGrandLogoutTotal = $iGrandLogoutTotal + $iLogoutTotal;
            $iGrandFailedTotal = $iGrandFailedTotal + $iFailedTotal;
            $iLoginTotal = 0;
            $iLogoutTotal = 0;
            $iFailedTotal = 0;
         } 
         $CountLines++;
         $PrintLines = $CountLines % 2;
         if ($PrintLines == 0)
         {
            $sTrClass = "file1";
            $sLfList = "lfile1";
         }
         else
         {  
            $sTrClass = "file2";
            $sLfList = "lfile1";
         }
            
         print("\t\t\t\t<tr>\n");
         print("<td class='$sTrClass' colspan='3'>" . uid_to_name($sql->f("userid")) . "</td>\n");
         print("<td class='$sTrClass'>");
      } 

      switch ($sql->f("action"))
      {
         case LOGIN:
            $iLoginTotal = $sql->f("num_action");
            break;
         case LOGIN_FAILED:
            $iFailedTotal = $sql->f("num_action");
            break;
         case LOGOUT:
            $iLogoutTotal = $sql->f("num_action");
            break;
      } 
      $SaveUser = $sql->f("userid");
   } 

   $iGrandLoginTotal = $iGrandLoginTotal + $iLoginTotal;
   $iGrandLogoutTotal = $iGrandLogoutTotal + $iLogoutTotal;
   $iGrandFailedTotal = $iGrandFailedTotal + $iFailedTotal;

   print("($iLoginTotal / $iFailedTotal / $iLogoutTotal )");
   print("</td>\n");
   print("</tr>\n");
   print("<tr>\n");
   print("<td class='title1' colspan='3'>$owl_lang->tot_files</td>\n");
   print("<td class='title1'>($iGrandLoginTotal / $iGrandFailedTotal / $iGrandLogoutTotal)</td>\n");
   print("</tr>\n"); 
   // 
   // User Logon Stats END
   // 
} 
// 
// Currently Logged In BEGIN
// 
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td  class='admin2' align='left' colspan='4'>$owl_lang->stats_users_loggedin</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");

$sql->query("select usid, lastused, ip  from $default->owl_sessions_table order by usid");

$iGrandUserTotal = 0;
while ($sql->next_record())
{
   $CountLines++;
   $PrintLines = $CountLines % 2;
   if ($PrintLines == 0)
   {
      $sTrClass = "file1";
      $sLfList = "lfile1";
   }
   else
   {  
      $sTrClass = "file2";
      $sLfList = "lfile1";
   }
            
   print("\t\t\t\t<tr>\n");

   print("<td class='$sTrClass'>" . uid_to_name($sql->f("usid")) . "</td>\n");

   $time = time();
   if (($time - $sql->f("lastused")) <= $default->owl_timeout)
   {
      print("<td class='$sTrClass'>SESSION ACTIVE</td>\n");
   } 
   else
   {
      print("<td class='$sTrClass'>SESSION EXPIRED</td>\n");
   } 
   print("<td class='$sTrClass'>" . $sql->f("ip") . "</td>\n");
   if (Net_CheckIP::check_ip($sql->f('ip')))
   {
      print("<td class='$sTrClass'>" . fGetHostByAddress($sql->f('ip')) . "</td>\n");
   }
   else
   {
      print("<td class='$sTrClass'>" . $sql->f('ip') . "</td>\n");
   }

   $iGrandUserTotal = $iGrandUserTotal + 1;
   print("</tr>\n");
} 
print("<tr>\n");
print("<td class='title1' colspan='3'>$owl_lang->tot_files</td>\n");
print("<td class='title1'>$iGrandUserTotal</td>\n");
print("</tr>\n");
// 
// User Folder Stats END
// 
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>");
print("<td class='title1' colspan='3'>$owl_lang->file</td>");
print("<td class='title1'>$owl_lang->tot_files</td>");
print("</tr>");
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td class='title1' colspan='3'>$owl_lang->stats_top</td>\n");
print("<td class='title1'>&nbsp;</td>\n");
print("</tr>\n");
print("<tr>\n");
print("<td align='left' colspan='3'>&nbsp;</td>\n");
print("<td align='left'>&nbsp;</td>\n");
print("</tr>\n");

if ($default->logging && $default->log_file)
{
   $sGetAction = FILE_DOWNLOADED;
   $sql->query("select action, parent, filename, count(filename) as download_count from $default->owl_log_table where action = '$sGetAction' group by filename, action, parent order by download_count desc");

   $iTopCount = 0;
   while ($sql->next_record())
   {
      $CountLines++;
      $PrintLines = $CountLines % 2;
      if ($PrintLines == 0)
      {
         $sTrClass = "file1";
         $sLfList = "lfile1";
      }
      else
      {  
         $sTrClass = "file2";
         $sLfList = "lfile1";
      }
      
      print("\t\t\t\t<tr>\n");
      print("<td class='$sTrClass' colspan='3'>" . $sql->f("filename") . "</td>\n");
      print("<td class='$sTrClass'>" . $sql->f("download_count") . "</td>\n");
      print("</tr>\n");
      $iTopCount++;

      if ($iTopCount > 20)
         break;
   } 
} 
else
{
   print("<tr>\n");
   print("<td class='$sTrClass' colspan='3'>$owl_lang->stats_information</td>\n");
   print("<td class='$sTrClass'>&nbsp;</td>\n");
   print("</tr>\n");
} 

?>