$torrentInfo['signed'] = array_key_exists('signatures', $array) ? 'Yes' : 'No';
if (array_key_exists('signatures', $array)) {
foreach ($array['signatures'] as $value => $key) {
$torrentInfo['authority'] = $value;
foreach ($key as $certinfo) {
$filter = array('' => '', '' => '', '' => '', '' => '', '' => '', '' => '', '' => '', 'U' => '', '6' => '', '/' => ' ', '0x06' => '', '' => '', '' => '', '1' => '', '8' => '', '0' => '', '' => '', '2' => '', '4' => '', '9' => '', 'Z' => '', '3' => '', 'b' => '');
$alloc = strtr($certinfo, $filter);
$torrentInfo['certificate'] = explode (' ', trim(explode("\n", $alloc)[3]), 3)[2];
$split = explode("\n", $alloc)[3];
$sep = preg_split('/[\s,]+/', $split, 3);
$torrentInfo['issuer'] = implode(', ', array($sep[0], $sep[1]));
break;
}
}
}
ALTER TABLE users ADD 2fa_auth enum('yes','no') NOT NULL;
class myClass {
const DEF_SMS_API_HOST = 'api.sms.to/sms/send';
const DEF_SMS_API_KEY = 'Your_Own_API_Key';
const DEF_SMS_SENDER_ID = 'SMSto';
$this->smsApiHost = self::DEF_SMS_API_HOST;
$this->smsApiKey = self::DEF_SMS_API_KEY;
$this->smsSenderId = self::DEF_SMS_SENDER_ID;
public function send_twofactor_sms(string $phonenumber): mixed
{
$securepin = mt_rand(10000,99999);
$curl = curl_init();
$headers = array(
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer " . $this->smsApiKey
);
$params = array(
'to' => $phonenumber,
"bypass_optout" => true,
'message' => "Your verification PIN is \n" . $securepin,
'sender_id' => $this->smsSenderId
);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://" . $this->smsApiHost,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FAILONERROR => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($params),
CURLOPT_HTTPHEADER => $headers
));
$response = curl_exec($curl);
if (curl_errno($curl)) {
throw curl_error($curl);
}
curl_close($curl);
return $response;
}
$checkauth = json_decode($response, true);
if ($checkauth[0]["success"] == true) {
// PIN Verified - Do some SQL/friendly message, etc
}
function get_time_elapsed($datetime)
{
return round((((time() - strtotime($datetime)) / 60) / 60) / 24) . ' day(s) ago';
}
function get_time_elapsed($time)
{
$time = time() - $time;
$time = ($time < 1) ? 1 : $time;
$tokens = array(
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit)
continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : '') . ' ago';
}
}
<?
function torr(string $filename = ''): mixed
{
// Array storage
$torrentInfo = array();
$array = array();
// Torrent Version
$version = array();
// Torrent filename
$torrent = explode(".", $filename);
$fileend = strtolower(end($torrent));
if ($fileend == "torrent") {
$fp = fopen($filename, 'rb');
$parse = '';
while (!feof($fp)) {
$parse .= fread($fp, 8192);
}
fclose($fp);
// If Parse Lets Read It
if ($parse === false) {
echo "Error Getting Torrent file";
} else {
// Decode File Array
$array = Bencode::decode($parse);
// Push version to Array
array_push($version, (array_key_exists('meta version', $array['info']) ? intval($array['info']['meta version']) : 1));
// If Array Lets Read It
if (empty($array)) {
die('Unable to decode metadata.');
} else {
if (array_key_exists('info', $array) !== true) {
die('Error opening torrent');
} else {
// Get Announce URL
$torrentInfo['announce'] = isset($array["announce"]) ? $array["announce"] : null;
// Get Announce List Array
$torrentInfo["announce-list"] = (isset($array["announce-list"])) ? $array["announce-list"] : null;
// Calculates date from UNIX Epoch - You want to return NULL on this if empty to pass parse validation
$torrentInfo["creation date"] = isset($array["creation date"]) ? date('r', $array["creation date"]) : null;
// Get torrents comment
$torrentInfo['comment'] = (isset($array['comment'])) ? $array['comment'] : null;
// Read info - files
$info = $array["info"];
// The name of the torrents is different to the file name
$torrentInfo['name'] = $info['name'];
// Read the torrent version stored in array previously
$torrentInfo['type'] = $version[0];
// Calculate Size/Count
$filecount = 0;
$torrentsize = 0;
// Calculates Hashes - SHA1/SHA256
$torrentInfo['hash'] = in_array(2, $version) ? hash('sha256', Bencode::encode($info)) : hash('sha1', Bencode::encode($info));
$path = array();
// File List
$struct = in_array(2, $version) ? $info['file tree'] : $info['files'];
if (array_key_exists('file tree', $info)) {
foreach ($struct as $key => $value) {
foreach ($value as $detail) {
$filecount = ++$filecount;
$torrentsize += $detail['length'];
array_merge($path, array(
'length' => $detail['length']
));
}
array_push($path, array(
'length' => $detail['length'],
'path' => array(
sizeof($value) - 1 => $key
)
));
}
$torrentInfo['files'] = $path;
$torrentInfo['length'] = $torrentsize;
$torrentInfo['ttfilecount'] = $filecount;
}
if (array_key_exists('file tree', $info) || array_key_exists('files', $info)) {
if (isset($info['files']) || $filecount > 1) {
// Multi File
if (isset($info['files']) && is_array($info['files'])) {
$torrentInfo['files'] = $info['files'];
foreach ($info['files'] as $file) {
$filecount = ++$filecount;
$torrentsize += $file['length'];
}
$torrentInfo['length'] = $torrentsize;
$torrentInfo['ttfilecount'] = !empty($path) ? count($path) : $filecount;
}
} else {
if ($filecount === 1) {
// Single File - Remove or Use
}
}
}
}
}
}
}
return $torrentInfo;
} Quote:Modify the top of torrents-upload.php to look like this. This will let you know what's going on. They should of implemented a exception class for these purposes future-proofing the script itself. Anyway.. do this:
<?
error_reporting(E_ALL);