Exemplo n.º 1
0
function __autoload($classname)
{
    if (file_exists(_configs()->paths->library . $classname . ".php")) {
        include_once _configs()->paths->library . $classname . ".php";
    } else {
        trigger_error("Could not find library class file {$classname}.php");
    }
}
Exemplo n.º 2
0
 function Build()
 {
     if (file_exists(_configs()->paths->pages . $this->_page_url . "/" . $this->_page_action . ".php")) {
         ob_start();
         include _configs()->paths->pages . $this->_page_url . "/" . $this->_page_action . ".php";
         $data = ob_get_contents();
         ob_clean();
         return $data;
     } else {
         return "Page file not found";
     }
 }
Exemplo n.º 3
0
<?php

include "init.php";
// index.php?link_type=(torrent|text|link)&infohash=B05930182B4FC941E73A4278FC612D154D5A822B
define("LINK_TYPE", isset($_GET['link_type']) ? $_GET['link_type'] : '');
define("LINK_INFOHASH", isset($_GET['infohash']) ? $_GET['infohash'] : '');
define("PAGE_ACTION", isset($_GET['page_action']) ? $_GET['page_action'] : "main");
if (LINK_TYPE == 'link') {
    define("PAGE_URL", 'link');
} else {
    define("PAGE_URL", isset($_GET['page_url']) ? $_GET['page_url'] : "start");
}
if (file_exists(_configs()->paths->torrents . LINK_INFOHASH . '.torrent') && preg_match("/^[0-F]{40}/i", LINK_INFOHASH)) {
    if (LINK_TYPE == 'torrent' || LINK_TYPE == 'text' || LINK_TYPE == '') {
        $file = file_get_contents(_configs()->paths->torrents . LINK_INFOHASH . '.torrent');
        if (LINK_TYPE == 'text') {
            header('Content-Disposition: attachment; filename="' . LINK_INFOHASH . '.txt"');
            header('Content-Type: text/plain');
        } else {
            header('Content-Disposition: attachment; filename="' . LINK_INFOHASH . '.torrent"');
            header('Content-Type: application/x-bittorrent');
        }
        die($file);
    } else {
        $tpl = new Template(_configs()->paths->template . 'template.php');
        echo $tpl->Display();
    }
} else {
    $tpl = new Template(_configs()->paths->template . 'template.php');
    echo $tpl->Display();
}
Exemplo n.º 4
0
<div class="jumbotron">
	<?php 
$infohash = LINK_INFOHASH;
if (file_exists(_configs()->paths->torrents . $infohash . '.torrent')) {
    $torrent_link = _configs()->website->url . $infohash;
    $text_link = _configs()->website->url . 'text/' . $infohash;
    $magnet_link = 'magnet:?xt=urn:btih:' . $infohash . '&tr=' . implode('&tr=', _configs()->trackers);
    ?>
		
		<p style="text-align:center">To download the torrent with infohash<br />
		<?php 
    echo LINK_INFOHASH;
    ?>
<br />
		click one of the following links.</p>
		<a class="btn btn-lg btn-success" style="width:33%" href="<?php 
    echo $torrent_link;
    ?>
">Torrent</a>
		<a class="btn btn-lg btn-success" style="width:33%" href="<?php 
    echo $text_link;
    ?>
">Text</a>
		<a class="btn btn-lg btn-success" style="width:33%" href="<?php 
    echo $magnet_link;
    ?>
">Magnet</a>

		<?php 
} else {
    echo '<p style="text-align:center">Torrent doesn\'t exist.  Did you forget to upload it?</p>';
Exemplo n.º 5
0
include "../init.php";
if (isset($_POST['upload'])) {
    try {
        if (!isset($_FILES['torrent'])) {
            throw new Exception("Missing torrent data");
        }
        if (empty($_FILES['torrent']['name'])) {
            throw new Exception("No torrent file selected");
        }
        $file = $_FILES['torrent'];
        $ext = explode(".", $file['name']);
        $ext = end($ext);
        if ($ext != "torrent") {
            throw new Exception("A torrent file has to end with .torrent");
        }
        $filetmp = $_FILES['torrent']['tmp_name'];
        $dict = Bcode::bdec_file($filetmp, filesize($filetmp));
        list($ann, $info) = Bcode::dict_check($dict, "announce(string):info");
        $infohash = strtoupper(sha1($info["string"]));
        $filename = $infohash;
        $file_path = _configs()->paths->torrents . $filename;
        $magnet_link = 'magnet:?xt=urn:btih:' . $infohash . "&tr=" . implode("&tr=", _configs()->trackers);
        if (move_uploaded_file($file['tmp_name'], $file_path . '.torrent')) {
            $array = array("error" => false, "message" => "The torrent has been successfully uploaded", "url" => _configs()->website->url . $filename, "magnet" => $magnet_link);
            die(json_encode($array));
        }
    } catch (Exception $e) {
        $array = array("error" => true, "message" => $e->getMessage());
        die(json_encode($array));
    }
}
Exemplo n.º 6
0
</div>
<div class="container">
    <div class="content">
        <?php 
echo $content;
?>
    </div>
</div>
<div class="container">
    <div class="footer navbar navbar-default">
        <div class="navbar-text pull-left">
            Powered by TorrentCaching
        </div>
        <div class="navbar-text navbar-right" style="margin-right: 15px;">
            v<?php 
echo _configs()->system->version;
?>
 @ Wuild
        </div>
    </div>
</div>
<script>
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
            m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
Exemplo n.º 7
0
    $post_data = array(
        "upload" => true, // Don't change
        "torrent" => "@/path/to/torrent/dexter.s03.e07.torrent"
    );

    $ch = curl_init("<?php 
echo _configs()->website->url;
?>
api/upload.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $result = curl_exec($ch);
    curl_close($ch);
    $json = json_decode($result);

    if (!$json->error){
        echo $json->message;
        echo $json->url;
    }else if($json->error){
        echo $json->message;
    }
</pre>
<div class="page-header">
    <h4>Json return code</h4>
</div>
<pre style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;">
<?php 
$array = array("error" => false, "message" => "The torrent has been successfully uploaded", "url" => _configs()->website->url . "torrent/" . strtoupper(sha1("dexter.s03.e07")) . ".torrent", "magnet" => "magnet:?xt=urn:btih:" . strtoupper(sha1("dexter.s03.e07")) . "&tr=" . implode("&tr=", _configs()->trackers));
echo json_encode($array);
?>
</pre>
Exemplo n.º 8
0
        }
        $file = $_FILES['torrent'];
        $ext = explode(".", $file['name']);
        $ext = end($ext);
        if ($ext != "torrent") {
            throw new Exception("A torrent file has to end with .torrent");
        }
        $filetmp = $_FILES['torrent']['tmp_name'];
        $dict = Bcode::bdec_file($filetmp, filesize($filetmp));
        list($ann, $info) = Bcode::dict_check($dict, "announce(string):info");
        $infohash = strtoupper(sha1($info["string"]));
        $filename = $infohash;
        $file_path = _configs()->paths->torrents . $filename;
        $magnet_link = 'magnet:?xt=urn:btih:' . $infohash . "&tr=" . implode("&tr=", _configs()->trackers);
        if (move_uploaded_file($file['tmp_name'], $file_path . '.torrent')) {
            echo "<div class='alert alert-success'>The torrent has been successfully uploaded, to download it follow the link below<br />\n\t\t\t<a href='" . _configs()->website->url . $filename . "'>" . _configs()->website->url . $filename . "</a><br />\n\t\t\t<a href='" . $magnet_link . "'>Magnet link</a> | <a href='" . _configs()->website->url . 'text/' . $filename . "'>Text</a> | \n\t\t\t<a href='" . _configs()->website->url . 'link/' . $filename . "'>Link</a></div>";
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
?>

<h5>Select torrent file to upload</h5>
<form method="post" enctype="multipart/form-data" class="form-horizontal">
    <div class="form-group">
        <div class="col-md-8">
            <input type="file" class="form-control" name="torrent"/><br/>
        </div>
        <div class="col-md-4">
            <input type="submit" name="upload" value="Upload" class="btn btn-success btn-block"/>