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
|
<?php
$kWarez = "http://www.carbonpictures.com/bucky/data/";
mysql_connect("localhost","tfarnon","blunderbus"); // lol security
mysql_select_db("bucky");
if (!isset ($_GET['s']) || !isset ($_GET['e'])) {
$startIndex = 0;
$endIndex = 9;
} else {
$startIndex = $_GET['s'];
$endIndex = $_GET['e'];
}
$page = ($endIndex - $startIndex);
$query = mysql_query("SELECT * FROM `files` order by `date` desc limit $startIndex, $endIndex");
$nrows = mysql_num_rows($query);
$rString = "&numItems=".$page;
if (!isset ($_GET['p'])) {
// display as querystring (&p=1)
for ($i = $startIndex; $i <= $endIndex; $i++) {
$row = mysql_fetch_array($query);
$rString .= "&filetype" .$i ."=". fileExt($row['filename']);
$rString .= "&filename" .$i ."=". $row['filename'];
$rString .= "&username" .$i ."=". $row['username'];
$rString .= "&date" .$i ."=". strtolower (date("D M j", $row['date'] ));
$rString .= "&url" .$i ."=". $kWarez . $row['parent_id'] . "/" . str_replace(" ", "%20", $row['filename']);
$rString .= "&size" .$i ."=". sizeinK ($row['size']);
}
echo $rString;
}
// display pretty:
else {
$nextURL = "http://www.carbonpictures.com/tfarnon/buckyFiles.php?p=1&s=" . ($endIndex+1) . "&e=" . ($endIndex+$page+1);
$prevURL = "http://www.carbonpictures.com/tfarnon/buckyFiles.php?p=1&s=" . ($startIndex-$page-1) . "&e=" . ($startIndex-1) ;
echo "<br><br>";
if ($startIndex > 0) {
echo "<a href = '$prevURL'>previous " . ($page+1) . "</a>";
echo " | ";
}
echo "<a href = '$nextURL'>next " . ($page+1) . "</a>";
echo "<br>files " . $startIndex . " - " . $endIndex . " on bucky:<br>";
for ($i=$startIndex; $i <= $endIndex; $i++) {
$row = mysql_fetch_array($query);
if (doubleCheck ($row))
{
echo "<br>";
echo $i . " ";
echo fileExt($row['filename'] . ": ");
echo "on ";
echo strtolower (date("D M j", $row['date'] ));
echo " ";
echo $row['username'];
echo " uploaded ";
echo "<b>" .
"<a href = \"" . $kWarez .
$row['parent_id'].
"/".
str_replace(" ", "%20", $row['filename']) . "\" target = \"_blank\">".
$row['filename'].
"</a>".
"</b>";
echo " (" . sizeinK ($row['size']) . ")";
}
}
}
function doubleCheck ($row) {
if (!$row['filename'] || !$row['date'] || !$row['username'] || !$row['parent_id'] || !$row['size'])
{
echo "<br>(this file looks weird/null -- not listing)";
return (false);
} else {
return (true);
}
}
function fileExt ($inStr) {
return strtoupper (end(explode('.',$inStr)));
}
function sizeinK($bytes) {
$size = $bytes / 1024;
if($size < 1024) {
$size = number_format($size, 2);
$size .= 'k';
} else { if ($size / 1024 < 1024) {
$size = number_format($size / 1024, 2);
$size .= 'mb';
} else if ($size / 1024 / 1024 < 1024) {
$size = number_format($size / 1024 / 1024, 2);
$size .= ' GB';
}
}
return $size;
}
?>
|