CREATE TABLE `attachments` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`content_id` int(10) UNSIGNED NOT NULL,
`view_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
`user_id` int(10) UNSIGNED NOT NULL,
`upload_date` int(10) UNSIGNED NOT NULL,
`filename` varchar(100) NOT NULL,
`file_size` int(10) UNSIGNED NOT NULL,
`file_hash` varchar(50) NOT NULL,
`attach_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
`content_type` varchar(10) NOT NULL DEFAULT 'post',
`topicid` int(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
function get_attachment($id)
{
$sql = DB::raw('attachments', '*', ['content_id' =>$id]);
if ($sql->rowCount() != 0) {
foreach ($sql as $row7) {
print("<br><br> <b>$row7[filename]</b><br>");
$extension = substr($row7['filename'], -3);
if ($extension == 'zip') {
$daimage = UPLOADDIR . "/attachment/$row7[file_hash].data";
if (file_exists($daimage)) {
print(" <a class='btn btn-sm ttbtn' href=\"" . URLROOT . "/download/attachment?id=$row7[id]&hash=" . rawurlencode($row7["file_hash"]) . "\"><i class='fa fa-file-archive-o tticon' ></i>Download</a><br>");
} else {
print("no zip<br>");
}
} else {
$daimage = "uploads/thumbnail/$row7[file_hash].jpg";
if (file_exists($daimage)) { ?>
<!-- Trigger/Open The Model -->
<img id="myBtn" src='<?php echo data_uri($daimage, $row7['filename']); ?>' height='110px' width='110px' border='0' alt='' data-toggle="modal" data-target="#myModal-<?=$daimage;?>">
<!-- The Modal -->
<div id="myModal-<?=$daimage;?>" class="modal">
<!-- Modal content -->
<div class="modal-content">
<!-- The Close Button --> <?php
$switchimage = UPLOADDIR . "/attachment/$row7[file_hash].data"; ?>
<button type="button" class="btn btn-sm ttbtn" data-dismiss="modal"><b>CLOSE</b></button><br><?php
echo $row7['filename']; ?><br>
<img src='<?php echo data_uri($switchimage, $row7['filename']); ?>' style="width:100%" alt=''>
</div>
</div> <?php
} else {
print("<a href=\"" . URLROOT . "/download/attachment?id=$row7[id]&hash=" . rawurlencode($row7["file_hash"]) . "\"><img src='" . URLROOT . "/thumb/$row7[file_hash].jpg' height='110px' width='110px' border='0' alt='' /></a><br>");
}
}
}
}
}
function set_attachmnent($topicid, $postid)
{
if (isset($_FILES['upfile'])):
$array = array($_FILES['upfile']['name']);
$result = array_filter($array);
foreach ($result as $k => $ar):
// check if file has one of the following extensions
$allowedfileExtensions = array('jpg', 'gif', 'png', 'zip');
if (in_array($_FILES['upfile']['type'][$k], $allowedfileExtensions)) {
Redirect::autolink(URLROOT . '/forum', "Sorry, only zip, JPG, JPEG, PNG, GIF files are allowed.");
}
$sourcePath = $_FILES['upfile']['tmp_name'][$k]; // Storing source path of the file in a variable
$fileSize = $_FILES['upfile']['size'][$k];
$fileName = $_FILES['upfile']['name'][$k];
$extension = substr($fileName, -3);
$hash = sha1($sourcePath);
$newfile = $hash . "." . $extension;
$targetPath = UPLOADDIR . "/attachment/" . $hash . ".data"; // Target path where file is to be stored
$thumbPath = "uploads/thumbnail/" . $hash . ".jpg"; // Target path where attachment as jpg is to be stored
if ($extension == 'zip') {
move_uploaded_file($sourcePath, $targetPath); // Moving Uploaded file
DB::run("INSERT INTO attachments (content_id, user_id, upload_date, filename, file_size, file_hash, topicid)
VALUES (?,?,?,?,?,?,?)",
[$postid, Users::get('id'), TimeDate::gmtime(), $fileName, $fileSize, $hash, $topicid]);
} else {
if (move_uploaded_file($sourcePath, $targetPath)) { // Moving Uploaded file
SimpleThumbnail::create()->image($targetPath)->thumbnail(100)->to($thumbPath);
DB::run("INSERT INTO attachments (content_id, user_id, upload_date, filename, file_size, file_hash, topicid)
VALUES (?,?,?,?,?,?,?)",
[$postid, Users::get('id'), TimeDate::gmtime(), $fileName, $fileSize, $hash, $topicid]);
}
}
endforeach;
endif;
}<p class='text-center'><input type="file" name="upfile[]" multiple></p> $id = (int) Input::get("id");
$filename = Input::get("hash");
$fn = UPLOADDIR . "/attachment/$filename.data";
$sql = DB::select('attachments', '*', ['id'=>$id]);
$extension = substr($sql['filename'], -3);
if (!file_exists($fn)) {
Redirect::autolink($_SERVER['HTTP_REFERER'], "The file $filename does not exists");
} else {
header('Content-Disposition: attachment; filename="' . $sql['filename'] . '"');
header('Content-Length: ' . filesize($fn));
header("Content-Type: application/$extension");
readfile($fn);
} <?php
// uncomment if error
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(0);
require_once("backend/functions.php");
require_once("backend/parse.php");
require_once("backend/Scraper.php");
dbconn();
$tor = ParseTorrent("uploads/1.torrent");
$infohash = $tor[1];
$annlist = $tor[6];
// uncomment to see torrent parse array
//var_dump($tor);
$scraper = new Scraper();
$ret = $scraper->scrape($infohash, $annlist, 20, 4, true );
var_dump($ret);
// parse torrent
$torInfo = new Parse();
$torrentInfo = $torInfo->torr(UPLOADDIR."/torrents/13.torrent");
//var_dump($torrentInfo[8]);echo '<br>';echo '<br>';
// get the tree
$file_tree = $torrentInfo[8];
// set a path
$path = '';
// loop through for path
foreach ($file_tree as $file) {
//var_dump($file);
echo '<br><br>';
// if path matches must be same folder/file
if ($file['path'][0] == $path) {
echo $file['path'][0];
echo '<p style="color:red">This is a path.</p>';
} else {
echo $file['path'][0];
echo '<p style="color:green">This is a file.</p>';
}
// so change or update path path
$path = $file['path'][0];
}
<?php
require_once("backend/functions.php");
require_once("backend/Scraper.php");
dbconn();
$tor = ParseTorrent(UPLOADDIR."/torrents/1.torrent");
$announce = $tor[0];
$infohash = $tor[1];
$creationdate = $tor[2];
$internalname = $tor[3];
$torrentsize = $tor[4];
$filecount = $tor[5];
$annlist = $tor[6];
$comment = $tor[7];
$filelist = $tor[8];
var_dump($tor);
$scraper = new Scrapeer\Scraper();
$ret = $scraper->scrape($infohash, $annlist, 20, 4, true );
var_dump($ret); if ($external === 'yes') {
$multi = array_flatten($annlist);
$announcelist = serialize($multi);
}
$multi = array_flatten($filelist);
$fileliststring = serialize($multi); $array = unserialize($row['announcelist']);
foreach ($array as $subarray){
echo $subarray."<br>";
}function ScrapeId($id, $annlist, $infohash)
{
if (!is_array($annlist)) {
$tor = ParseTorrent(UPLOADDIR."/torrents/$id.torrent");
$infohash = $tor[1];
$annlist = array_flatten($tor[6]);
$var2 = serialize($annlist);
}
$scraper = new Scraper();
$scraped = $scraper->scrape($infohash, $annlist, 20, 4, true );
$myarray = array_shift($scraped);
$seeders = $leechers = $completed = 0;
if ($myarray['seeders'] > 0) {
$seeders = $myarray['seeders'];
}
if ($myarray['leechers'] > 0) {
$leechers = $myarray['leechers'];
}
if ($myarray['completed'] > 0) {
$completed = $myarray['completed'];
}
if ($seeders !== 0) {
// Update the Torrent
DB::update('torrents', ['leechers' =>$leechers, 'seeders' =>$seeders, 'times_completed' =>$completed, 'last_action' =>TimeDate::get_date_time(), 'visible' =>'yes', 'announcelist'=>$var2,], ['id'=>$id]);
} else {
// Its Dead :(
DB::update('torrents', ['last_action' =>TimeDate::get_date_time()], ['id' => $id]);
}
}$data = json_decode($json_data, true);var_dump($json_data); die(); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); <?php
function url_get_contents($Url)
{
if (!function_exists('curl_init')) {
header("HTTP/1.0 403 Forbidden");
echo '<html><head><title>Forbidden</title> </head><body> <h1>Forbidden</h1>CURL is not installed!.<br> </body></html>';
die();
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$json_data = url_get_contents("https://radio.neri-info.com/api/nowplaying/6" );
$data = json_decode($json_data, true);
foreach($data as $key => $value){
var_dump($key);
echo '<br>';
var_dump($value);
echo '<br>';
}
foreach (['numwant', 'corrupt', 'no_peer_id', 'compact'] as $key) {
if (!is_numeric($client[$key]) || $client[$key] < 0) {
die(self::response("wrong option input"));
}
}
/*
foreach (['numwant', 'corrupt', 'no_peer_id', 'compact'] as $key) {
if (!is_numeric($client[$key]) || $client[$key] < 0) {
die(self::response("wrong option input"));
}
}
*/
<?php
class Upload
{
public function __construct()
{
$this->session = Auth::user(0, 2);
}
public static function checks()
{
// Checks
if ($_SESSION["can_upload"] == "no") {
Redirect::autolink(URLROOT, Lang::T("UPLOAD_NO_PERMISSION"));
}
if (Config::TT()['UPLOADERSONLY'] && $_SESSION["class"] < _VIP) {
Redirect::autolink(URLROOT, Lang::T("UPLOAD_ONLY_FOR_UPLOADERS"));
}
}
public function index()
{
self::checks();
// Announcelist
$announce_urls = explode(",", ANNOUNCELIST);
$data = [
'title' => Lang::T("UPLOAD"),
'announce_urls' => $announce_urls,
];
View::render('upload/index', $data, 'user');
}
public function submit()
{
self::checks();
if ($_POST["takeupload"] == "yes") {
// Check form data.
if (!isset($_POST['type'], $_POST['name'], $_FILES['torrent'])) {
$message = Lang::T('MISSING_FORM_DATA');
}
$tupload = new Tupload('torrent');
if (($num = $tupload->getError())) {
Redirect::autolink(URLROOT . '/upload', Lang::T("UPLOAD_ERR[$num]"));
}
if (!($fname = $tupload->getName())) {
$message = Lang::T("EMPTY_FILENAME");
}
// NFO
$nfo = 'no';
if ($_FILES['nfo']['size'] != 0) {
$nfofile = $_FILES['nfo'];
if ($nfofile['name'] == '') {
$message = Lang::T("NO_NFO_UPLOADED");
}
if (!preg_match('/^(.+)\.nfo$/si', $nfofile['name'], $fmatches)) {
$message = Lang::T("UPLOAD_NOT_NFO");
}
if ($nfofile['size'] == 0) {
$message = Lang::T("NO_NFO_SIZE");
}
if ($nfofile['size'] > 65535) {
$message = Lang::T("NFO_UPLOAD_SIZE");
}
$nfofilename = $nfofile['tmp_name'];
if (($num = $_FILES['nfo']['error'])) {
$message = Lang::T("UPLOAD_ERR[$num]");
}
$nfo = 'yes';
}
// Check Post Inputs
$descr = Input::get("descr");
if (!$descr) {
$descr = Lang::T("UPLOAD_NO_DESC");
}
$vip = Input::get("vip");
if (!$vip) {
$vip = 0;
}
$free = Input::get("free");
if (!$free) {
$free = 0;
}
$langid = (int) Input::get("lang");
$catid = (int) Input::get("type");
if (!Validate::Id($catid)) {
$message = Lang::T("UPLOAD_NO_CAT");
}
if (!empty(Input::get('tube'))) {
$tube = Input::get('tube');
}
if (!Validate::Filename($fname)) {
$message = Lang::T("UPLOAD_INVALID_FILENAME");
}
if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches)) {
$message = Lang::T("UPLOAD_INVALID_FILENAME_NOT_TORRENT");
}
$shortfname = $torrent = $matches[1];
if (!empty(Input::get("name"))) {
$name = Input::get("name");
}
if (!empty(Input::get('tmdb'))) {
$tmdb = Input::get('tmdb');
}
// If Message Show
if ($message) {
Redirect::autolink(URLROOT . '/upload', $message);
}
if (!$message) {
//parse torrent file
$torrent_dir = UPLOADDIR."/torrents";
$nfo_dir = UPLOADDIR."/nfos";
if (!($tupload->move("$torrent_dir/$fname"))) {
Redirect::autolink(URLROOT . '/upload', Lang::T("ERROR") . ": " . Lang::T("UPLOAD_COULD_NOT_BE_COPIED") . " $torrent_dir - $fname");
}
$torInfo = new Parse();
$tor = $torInfo->torr("$torrent_dir/$fname");
$announce = $tor[0];
$infohash = $tor[1];
$creationdate = $tor[2];
$internalname = $tor[3];
$torrentsize = $tor[4];
$filecount = $tor[5];
$annlist = $tor[6];
$comment = $tor[7];
$filelist = $tor[8];
//if externals is turned off
//$external = $announce !== ANNOUNCELIST ? "yes" : "no";
$announce_urls = explode(",", ANNOUNCELIST);
if (!in_array($announce, $announce_urls, 1)){
$external='yes';
}else{
$external='no';
}
if (!Config::TT()['ALLOWEXTERNAL'] && $external == 'yes') {
$message = Lang::T("UPLOAD_NO_TRACKER_ANNOUNCE");
}
}
if ($message) {
@$tupload->remove();
@unlink("$torrent_dir/$fname");
Redirect::autolink(URLROOT . '/upload', $message);
}
//release name check and adjust
if ($name == "") {
$name = $internalname;
}
$name = str_replace(".torrent", "", $name);
$name = str_replace("_", " ", $name);
//upload images
$allowed_types = ALLOWEDIMAGETYPES;
$inames = array();
for ($x = 0; $x < 2; $x++) {
if (!($_FILES['image' . $x]['name'] == "")) {
$y = $x + 1;
if ($_FILES['image$x']['size'] > IMAGEMAXFILESIZE) {
Redirect::autolink(URLROOT . '/upload', Lang::T("INVAILD_FILE_SIZE_IMAGE"));
}
$uploaddir = UPLOADDIR . '/images/';
$ifile = $_FILES['image' . $x]['tmp_name'];
$im = getimagesize($ifile);
if (!$im[2]) {
Redirect::autolink(URLROOT . '/upload', sprintf(Lang::T("INVALID_IMAGE")));
}
if (!array_key_exists($im['mime'], $allowed_types)) {
Redirect::autolink(URLROOT . '/upload', Lang::T("INVALID_FILETYPE_IMAGE"));
}
$row = DB::run("SHOW TABLE STATUS LIKE 'torrents'")->fetch();
$next_id = $row['Auto_increment'];
$ifilename = $next_id . $x . $allowed_types[$im['mime']];
$copy = copy($ifile, $uploaddir . $ifilename);
if (!$copy) {
Redirect::autolink(URLROOT . '/upload', sprintf(Lang::T("IMAGE_UPLOAD_FAILED")));
}
$inames[] = $ifilename;
}
}
//anonymous upload
$anonyupload = Input::get("anonycheck");
if ($anonyupload == "yes") {
$anon = "yes";
} else {
$anon = "no";
}
$filecounts = (int) $filecount;
// Insert Torrent
try {
DB::run("INSERT INTO torrents (filename, owner, name, vip, descr, image1, image2, category, tube, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action, freeleech, tmdb)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
[$fname, $_SESSION['id'], $name, $vip, $descr, $inames[0], $inames[1], $catid, $tube, TimeDate::get_date_time(), $infohash, $torrentsize, $filecounts, $fname, $announce, $external, $nfo, $langid, $anon, TimeDate::get_date_time(), $free, $tmdb]);
} catch (PDOException $e) {
rename("$torrent_dir/$fname", "$torrent_dir/duplicate.torrent"); // todo
Redirect::to(URLROOT . '/exceptions');
}
$id = DB::lastInsertId();
if ($id == 0) {
unlink("$torrent_dir/$fname");
Redirect::autolink(URLROOT . '/upload', Lang::T("UPLOAD_NO_ID"));
}
rename("$torrent_dir/$fname", "$torrent_dir/$id.torrent");
if (is_array($filelist)) {
foreach ($filelist as $file) {
$dir = '';
$size = $file["length"];
$count = count($file["path"]);
for ($i = 0; $i < $count; $i++) {
if (($i + 1) == $count) {
$fname = $dir . $file["path"][$i];
} else {
$dir .= $file["path"][$i] . "/";
}
}
Files::insertFiles($id, $fname, $size);
}
} else {
Files::insertFiles($id, $internalname, $torrentsize);
}
if ($nfo == 'yes') {
move_uploaded_file($nfofilename, "$nfo_dir/$id.nfo");
}
// Log Upload
Logs::write(sprintf(Lang::T("TORRENT_UPLOADED"), htmlspecialchars($name), $_SESSION["username"]));
// Shout new torrent
$msg_shout = "New Torrent: [url=" . URLROOT . "/torrent?id=" . $id . "]" . $torrent . "[/url] has been uploaded " . ($anon == 'no' ? "by [url=" . URLROOT . "/profile?id=" . $_SESSION['id'] . "]" . $_SESSION['username'] . "[/url]" : "") . "";
Shoutboxs::insertShout(0, TimeDate::get_date_time(), 'System', $msg_shout);
//Uploaded ok message
if ($external == 'no') {
$message = sprintf(Lang::T("TORRENT_UPLOAD_LOCAL"), $name, $id, $id);
} else {
$message = sprintf(Lang::T("TORRENT_UPLOAD_EXTERNAL"), $name, $id);
// scrape external
Tscraper::ScrapeId($id);
}
Redirect::autolink(URLROOT . "/torrent?id=$id", $message);
} else {
Redirect::autolink(URLROOT, Lang::T("ERROR"));
}
}
}function navmenu(){// Active Link
function activelink($page)
{
$active = $_GET['url'] == $page ? '#fff' : '#000';
return $active;
}<?php print("<a href='account.php'><b>".T_("YOUR_PROFILE")."</b></a>");?><?php print("<a href='account.php'><font color=". activelink('account.php')."><b>".T_("YOUR_PROFILE")."</b></font></a>"); ?>;<?php print("<a href='mailbox.php'><font color=". activelink('mailbox.php')."><b>".T_("YOUR_MESSAGES")."</b></font></a>");?>