config.php 777 0 0 44525 10622256206 6125 0 /* Project : T-Xore version 0.0.4 released on 06/2006 By Bogaa This piece of software is free to use by anyone and may be redistributed and modified by anyone in any way. We can't be held liable for damage or copyright infringement claims. Read the documentation! Bogaa's Homepage : http://www.meganova.org Project Homepage : http://www.devnova.org */ /* check if file is being accessed directly *****************************************/ if (eregi('config.php',$_SERVER['PHP_SELF'])) {die;} // <<< start config /* General db config ******************************************/ $dbhost = 'localhost'; // SQL Host $dbuser = ''; // Username $dbpass = ''; // Database password $database = ''; // Database name $btdir = 'adm/b/torrents/'; // torrent folder (make sure you have chmodded this 777 and its the correct path, script might not work if not) $sitename = 'AK Tracker'; // you could also use etc... result will be displayed on every page (top) $admin_user = ''; $admin_pass = ''; $version = '4'; // Only change this when you have a newer version installed (change after every update) $base_uri = 'http://yourdomain.com'; // where the script runs at /* // end config >>> Connect to the database *******************************************/ function connect ($dbhost, $dbuser, $dbpass, $database) { $errormes = 'oops...'; @$connection = mysql_connect($dbhost, $dbuser, $dbpass); @mysql_select_db($database) or die($errormes); } // Sql category search extension function catsearch ($mcat) { if ($mcat == '1' || $mcat == '2' || $mcat == '3' || $mcat == '4' || $mcat == '5' || $mcat == '6' || $mcat == '7') { return "AND torrents.maincat = '$mcat'"; } } // Get microtime function get_micro_time() { list($usec, $sec) = explode(' ', microtime()); return ((float)$usec + (float)$sec); } // order torrent tables function tsort ($sort){ switch ($sort) { case 1: return 'ORDER BY torrents.added DESC'; break; case 2: return 'ORDER BY categories.name ASC'; break; case 3: return 'ORDER BY torrents.torrentname ASC'; break; case 4: return 'ORDER BY torrents.size DESC'; break; case 5: return 'ORDER BY torrents.seeds DESC'; break; case 6: return 'ORDER BY torrents.peers DESC'; break; default: return 'ORDER BY torrents.added DESC'; } } // Escape url (for scraping) function escape_url($url) { $ret = ''; for($i = 0; $i < strlen($url); $i+=2) $ret .= '%'.$url[$i].$url[$i + 1]; return $ret; } /* return description icon */ function desc($val) { if ($val == 1) { return ''; } } /* return registration icon */ function regicon($val,$tracker) { if ($val == 1) { $uri = parse_url($tracker); return ''; } } /* return registration value on details page*/ function detreg($val) { if ($val == 1) { $uri = parse_url($tracker); return 'registration required'; } else { return 'No registration required'; } } /* Magnet Link *********************************************/ function base32_encode ($inString) { $outString = ''; $compBits = ''; $BASE32_TABLE = array( '00000' => 0x61, '00001' => 0x62, '00010' => 0x63, '00011' => 0x64, '00100' => 0x65, '00101' => 0x66, '00110' => 0x67, '00111' => 0x68, '01000' => 0x69, '01001' => 0x6a, '01010' => 0x6b, '01011' => 0x6c, '01100' => 0x6d, '01101' => 0x6e, '01110' => 0x6f, '01111' => 0x70, '10000' => 0x71, '10001' => 0x72, '10010' => 0x73, '10011' => 0x74, '10100' => 0x75, '10101' => 0x76, '10110' => 0x77, '10111' => 0x78, '11000' => 0x79, '11001' => 0x7a, '11010' => 0x32, '11011' => 0x33, '11100' => 0x34, '11101' => 0x35, '11110' => 0x36, '11111' => 0x37, ); /* Turn the compressed string into a string that represents the bits as 0 and 1. */ for ($i = 0; $i < strlen($inString); $i++) { $compBits .= str_pad(decbin(ord(substr($inString,$i,1))), 8, '0', STR_PAD_LEFT); } /* Pad the value with enough 0's to make it a multiple of 5 */ if((strlen($compBits) % 5) != 0) { $compBits = str_pad($compBits, strlen($compBits)+(5-(strlen($compBits)%5)), '0', STR_PAD_RIGHT); } /* Create an array by chunking it every 5 chars */ $fiveBitsArray = split("\n",rtrim(chunk_split($compBits, 5, "\n"))); /* Look-up each chunk and add it to $outstring */ foreach($fiveBitsArray as $fiveBitsString) { $outString .= chr($BASE32_TABLE[$fiveBitsString]); } return $outString; } /* Fetch torrent meta info No hussle here just go along with it */ function torrent_info_file($file) { require_once 'BDecode.php'; require_once 'BEncode.php'; $torrent = BDecode(file_get_contents($file)); $ret = array(); $countfiles = count($torrent['info']['files']); if($countfiles == 0) { $ret['files'] = 1; $size = $torrent['info']['length']; $ret['fileinfo'][0]['name'] = $torrent['info']['name']; $ret['fileinfo'][0]['size'] = $size; } else { $ret['files'] = $countfiles; $size = 0; for($i = 0; $i < $countfiles; $i++) { $ret['fileinfo'][$i]['name'] = $torrent['info']['name']; for($j = 0; $j < count($torrent['info']['files'][$i]['path']); $j++) $ret['fileinfo'][$i]['name'] .= '/'.$torrent['info']['files'][$i]['path'][$j]; $ret['fileinfo'][$i]['size'] = $torrent['info']['files'][$i]['length']; $size += $torrent['info']['files'][$i]['length']; } } $announce = $torrent['announce']; $announce = preg_replace('/\\?passkey=(.*)/', '', $announce); $announce = preg_replace('/\\/tracker\\/(.*)\\/announce/', '/tracker//announce', $announce); $ret['announce'] = $announce; $ret['scrape'] = str_replace('announce', 'scrape', $announce); $ret['size'] = $size; $ret['hash'] = sha1(BEncode($torrent['info'])); return $ret; } /* fetch torrent seeds and peers */ function torrent_scrape_url($scrape, $hash) { require_once 'BDecode.php'; @$fp = file_get_contents($scrape.'?info_hash='.escape_url($hash)); $ret = array(); if(!$fp) { $ret['seeds'] = -1; $ret['peers'] = -1; } else { $stats = BDecode($fp); $binhash = addslashes(pack("H*", $hash)); $seeds = $stats['files'][$binhash]['complete']; $peers = $stats['files'][$binhash]['incomplete']; $ret['seeds'] = $seeds; $ret['peers'] = $peers; } return $ret; } /* return peers and seeds */ function getpeer($var) { if ($var == -1) { return '---'; } else { return $var; } } /* Seeders and peers (dont mind the function name) ************************************************/ function seeders ($peers) { if ($peers == -1) { $peers = '