summaryrefslogtreecommitdiff
path: root/bPod/php/buckyFiles.php
diff options
context:
space:
mode:
Diffstat (limited to 'bPod/php/buckyFiles.php')
-rw-r--r--bPod/php/buckyFiles.php102
1 files changed, 102 insertions, 0 deletions
diff --git a/bPod/php/buckyFiles.php b/bPod/php/buckyFiles.php
new file mode 100644
index 0000000..00fdafd
--- /dev/null
+++ b/bPod/php/buckyFiles.php
@@ -0,0 +1,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 "&nbsp;&nbsp;|&nbsp;&nbsp;";
+ }
+
+ 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;
+ }
+?> \ No newline at end of file