$res = DB::run("SELECT last_time FROM tasks WHERE task='cleanup'")->fetch();
$result = DB::run("SELECT date FROM shoutbox WHERE msgid=46")->fetch();
// $type=date/string || $target=sqlresult || $amount=add/sub date
function modify($type, $target, $amount)
{
if ($type == 'date') {
$date = date_create($target);
date_modify($date, $amount);
} elseif ($type == 'time') {
$date = date_create();
date_timestamp_set($date, $target);
date_modify($date, $amount);
}
return date_format($date, 'Y-m-d H:i:s');
}
echo '<br>1<br>';
echo modify('date', $result['date'], '-15 minute');
echo '<br>2<br>';
echo modify('time', $res['last_time'], '+10 day');
echo '<br>3<br>';
echo TT_DATE . '<br>';
$test = modify('time', $res['last_time'], '-1 hour');
if ($test > TT_DATE) {
echo 'false';
} else {
echo 'true';
}
#country-list{float:left;list-style:none;margin-top:-3px;padding:0;width:190px;position: absolute;}
#country-list li{padding: 10px; background: #f0f0f0; border-bottom: #bbb9b9 1px solid;}
#country-list li:hover{background:#ece3d2;cursor: pointer;}
#search-box{padding: 10px;border: #a8d4b1 1px solid;border-radius:4px;}
<script>
$(document).ready(function(){
$("#search-box").keyup(function(){
$.ajax({
type: "POST",
url: "readCountry.php",
data:'keyword='+$(this).val(),
beforeSend: function(){
$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
},
success: function(data){
$("#suggesstion-box").show();
$("#suggesstion-box").html(data);
$("#search-box").css("background","#FFF");
}
});
});
});
function userCountry(val) {
$("#search-box").val(val);
$("#suggesstion-box").hide();
}
</script>
<input type="text" id="search-box" name="reciever" placeholder="User Name" />
<div id="suggesstion-box"></div>
$config = include APPROOT.'/config/configgg.php'; <?php
return array (
"DB_HOST", "localhost",
"DB_USER", "torrenttrader",
"DB_PASS", "password",
"DB_NAME", "pdo",
'DB_CHAR' => 'utf8mb4',
'URLROOT' => 'http://localhost/torrenttraderpdo',
'CAPTCHA_ON' => false,
'CAPTCHA_KEY' => 'googlecaptchakey',
'CAPTCHA_SECRET' => 'googlecaptchasecret',
'APPROOT' => dirname(dirname(__FILE__)),
'CACHE' => '../data/cache',
'LANG' => '../data/languages/',
'TORRENTDIR' => '../data/uploads',
'NFODIR' => '../data/uploads',
'BLOCKSDIR' => '../views/blocks',
'IMPORT' => '../data/import',
'LOGGER' => '../data/logs',
'BACUP' => '../data/backups',
'SITENAME' => 'TorrentTraderMVC',
'_SITEDESC' => 'A PHP support forum for Torrent Trader',
'SITEEMAIL' => 'something@email.com',
'VERSION' => 'PDO',
'TT_TIME' => time(),
'TT_DATE' => date("Y-m-d H:i:s"),
'CACHE_TYPE' => 'disk',
'MEMCACHE_HOST' => 'localhost',
'MEMCACHE_PORT' => 11211,
'SITENOTICEON' => true,
'SITENOTICE' => 'Welcome To TorrentTrader MVC/PDO',
'DEFAULTLANG' => 'english',
'DEFAULTTHEME' => 'darktheme',
'CHARSET' => 'utf-8',
'ANNOUNCELIST' => URLROOT . '/announce.php',
'MEMBERSONLY' => true,
'MEMBERSONLY_WAIT' => true,
'ALLOWEXTERNAL' => true,
'UPLOADERSONLY' => false,
'INVITEONLY' => false,
'ENABLEINVITES' => true,
'CONFIRMEMAIL' => false,
'ACONFIRM' => false,
'ANONYMOUSUPLOAD' => false,
'PASSKEYURL' => URLROOT . '/announce.php?passkey=%s',
'UPLOADSCRAPE' => true,
'FORUMS' => true,
'FORUMS_GUESTREAD' => false,
'OLD_CENSOR' => false,
'MAXUSERS' => 20000,
'MAXUSERSINVITE' => 50000,
'CURRENCYSYMBOL' => '£',
'BONUSPERTIME' => 0.1,
'ADDBONUS' => 3600,
'FORCETHANKS' => false,
'ALLOWLIKES' => true,
'BANNED_AGENTS' => '-AZ21, -BC, LIME',
'IMAGEMAXFILESIZE' => 524288,
'ALLOWEDIMAGETYPES' => array(
"image/gif" => ".gif",
"image/pjpeg" => ".jpg",
"image/jpeg" => ".jpg",
"image/jpg" => ".jpg",
"image/png" => ".png",
),
'SITE_ONLINE' => true,
'OFFLINEMSG' => 'Site is down for a little while',
'WELCOMEPM_ON' => true,
'WELCOMEPM_MSG' => 'Thank you for registering at our tracker! Please remember to keep your ratio at 1.00 or greater',
'UPLOADRULES' => 'You should also include a .nfo file wherever possible<br />Try to make sure your torrents are well-seeded for at least 24 hours<br />Do not re-release material that is still active',
'ISURL' => array('login', 'logout', 'signup'),
'LEFTNAV' => true,
'RIGHTNAV' => true,
'MIDDLENAV' => true,
'SHOUTBOX' => true,
'NEWSON' => true,
'DONATEON' => true,
'DISCLAIMERON' => true,
'CLASS_WAIT' => 1,
'GIGSA' => 1,
'RATIOA' => 0.50,
'A_WAIT' => 24,
'GIGSB' => 3,
'RATIOB' => 0.65,
'B_WAIT' => 12,
'GIGSC' => 5,
'RATIOC' => 0.80,
'C_WAIT' => 6,
'GIGSD' => 7,
'RATIOD' => 0.95,
'D_WAIT' => 2,
'PEERLIMIT' => 10000,
'AUTOCLEANINTERVAL' => 600,
'LOGCLEAN' => 28 * 86400,
'ANNOUNCEINTERVAL' => 900,
'SIGNUPTIMEOUT' => 259200,
'MAXDEADTORRENTTIMEOUT' => 21600,
'RATIOWARNENABLE' => true,
'RATIOWARNMINRATIO' => 0.4,
'RATIOWARN_MINGIGS' => 4,
'RATIOWARN_DAYSTOWARN' => 14,
'TORRENTTABLE_COLUMNS' => 'category,name,dl,magnet,tube,imdb,uploader,comments,size,seeders,leechers,health,external,added',
'TORRENTTABLE_EXPAND' => '',
'mail_type' => 'php',
'mail_smtp_host' => 'localhost',
'mail_smtp_port' => 25,
'mail_smtp_ssl' => false,
'mail_smtp_auth' => false,
'mail_smtp_user' => '',
'mail_smtp_pass' => '',
'_USER' => 1,
'_POWERUSER' => 2,
'_VIP' => 3,
'_UPLOADER' => 4,
'_MODERATOR' => 5,
'_SUPERMODERATOR' => 6,
'_ADMINISTRATOR' => 7,
'FORUMONINDEX' => true,
'IPCHECK' => true,
'ACCOUNTMAX' => 1,
'IMDB1' => true,
'YOU_TUBE' => true,
'FREELEECHGBON' => true,
'FREELEECHGB' => 8589934592,
'REQUESTSON' => true,
'HIDEBBCODE' => true,
'HNR_ON' => false,
'HNR_DEADLINE' => 7 * 86400,
'HNR_SEEDTIME' => 172800,
'HNR_WARN' => 5,
'HNR_STOP_DL' => 5,
'HNR_BAN' => 50,
'HNR_DISABLED' => TRUE,
)
?><?php
class Config
{
public static function TT()
{
global $config;
return $config;
}
}
<?php
// do some checks - for username ?
if ($_SESSION["control_panel"] != "yes" || $_SESSION["username"] != "mjay") {
Redirect::to(URLROOT . "/logout");
}
// get form input all post input names need to match array key name
if ($_POST) {
file_put_contents(
APPROOT.'/config/configgg.php',
"<?php\nreturn " . var_export($_POST, true) . "\n?>"
);
}
// now the form this is just the version example - still need to finish this just repeat input form for each config setting
<?php
echo Config::TT()['VERSION'];
?>
<form method="post" action="' . URLROOT . '/adminconfig/submit">
<div class="row justify-content-md-center">
<div class="col-md-8">';
////////////////////////////////////
// example for config setting array
<center><label for="ttversion">TTversion:</label><br></center>
<input type="text" class="form-control" id="ttversion" name="ttversion" value="<?php echo Config::TT()['VERSION'] ?>">
////////////////////////////////////
<br><br>
<center><input type="submit" class="btn btn-sm ttbtn" value="Submit"></center>
</div>
</div>
</form>
<?php
// get any files we need & the installer class
include 'installer.php';
include '../../app/config/config.php';
include '../../app/libraries/DB.php';
// use $_get to set step
$Step = $_GET['step'] ?? 0;
// call the installer
$Installer = new Installer();
// run everything through installer class
if ($Step == 1) {
$Installer->step1();
} elseif ($Step == 2) {
$Installer->step2();
} elseif ($Step == 3) {
$Installer->step3();
} elseif ($Step == 4) {
$Installer->step4();
} elseif ($Step == 5) {
$Installer->step5();
} else {
$Installer->index();
}
<?php
class Installer
{
public function index()
{
$html = '<!DOCTYPE html>
<html>
<head>
<style>
.center {
margin: auto;
width: 60%;
border: 3px solid #73AD21;
padding: 10px;
}
</style>
</head>
<body>
<center><h2>Lets do some checks</h2><center>
<form method="post" action="index.php?step=1">
<div class="center">
// database details use session so set on all pages
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>';
echo $html;
}
public function step1()
{
$sql = file_get_contents('Full Database.sql');
$qr = DB::exec($sql);
}
}
$filecounts = (int) $filecount;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once(BACKEND."/Scraper.php"); // Mail functions
require_once(BACKEND."/Torrent.php");
require_once(BACKEND."/Tscraper.php");
<?php
class Tscraper
{
public static function ScrapeId($id)
{
$torrent = new Torrent(TORRENTDIR . "/$id.torrent");
try {
$scraped = $torrent->scrape();
} catch (\Exception $e) {
//$scraped = $torrent->errors();
//exit();
}
$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 !== null) {
// Update the Torrent
DB::run(" UPDATE torrents
SET leechers = ?, seeders = ?, times_completed = ?, last_action = ?, visible = ?
WHERE id = ?",
[$leechers, $seeders, $completed, TimeDate::get_date_time(), 'yes', $id]
);
} else {
// Its Dead :(
DB::run("UPDATE torrents SET last_action = ? WHERE id=?", [TimeDate::get_date_time(), $id]);
}
}
public static function scrapeall()
{
// Set A time limit ? how fast is your server ?
//set_time_limit(15);
// Rescrape torrents every x seconds. (Default: 2 days)
$stmt = DB::run("SELECT `id`, `info_hash`, `last_action`
FROM `torrents`
WHERE `external` = 'yes'
AND `last_action` <= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 DAY) LIMIT 10");
foreach ($stmt as $tor) {
self::ScrapeId($tor['id']);
}
}
}
//EXTERNAL SCRAPE
if ($external == 'yes' && UPLOADSCRAPE) {
Tscraper::ScrapeId($id);
}
//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);
}
$id = $_GET['id'];
if ($_SESSION["view_torrents"] != "yes") {
Session::flash('info', Lang::T("NO_TORRENT_VIEW"), URLROOT . "/home");
}
Tscraper::ScrapeId($id);
Redirect::autolink(URLROOT . "/torrent?id=$id", Lang::T("The Tracker is Updated"));
$now = TimeDate::gmtime();
$ts = $row['last_action'];
if ($ts + 172800 > $now) {
$scraper = "
<br><b>" . Lang::T("EXTERNAL_TORRENT") . "</b>
<form action='".URLROOT."/Scrapethis?id=".$id."' method='post'>
<button type='submit' class='btn btn-warning center-block' value=''>". Lang::T("Update Stats")."</button>
</form>";
} else {
$scraper = "<br>
<br><b>" . Lang::T("EXTERNAL_TORRENT") . "</b>
<font size='4' color=#ff9900><b>Stats Recently Updated</b></font>";
}
// Scrape External Torrents
if ($torr["external"] == 'yes') {
echo $scraper;
}
Tscraper::scrapeall();Tscraper::scrapeall($limit = $site_config['scrapelimit']);$GLOBALS['tstart'] = array_sum(explode(" ", microtime()));// NOW BENC THE DATA AND SEND TO CLIENT???
$totaltime = array_sum(explode(" ", microtime())) - $GLOBALS['tstart'];
err("$totaltime");
<?php
require_once("backend/functions.php");
dbconn();
$id = (int) ($_GET["id"] ?? 0);
if (!isset($id) || !$id) {
autolink('home', "no id");
}
$res = SQL_Query_exec("SELECT
forum_posts.id, topicid, userid, forum_posts.added, body,
avatar, signature, username, title, class, uploaded, downloaded, privacy, donated
FROM forum_posts
LEFT JOIN users
ON forum_posts.userid = users.id
WHERE userid = $id ORDER BY forum_posts.userid "); //$limit
$row = mysqli_fetch_assoc($res);
if (!$row) {
autolink('home', "User has not posted in forum");
}
$title = T_("COMMENTSFOR") . "<a href='profile?id=" . $row['userid'] . "'> $row[username]</a>";
stdhead($title);
begin_frame($title);
while ($row = mysqli_fetch_assoc($res))) {
$postername = $row["username"];
if ($postername == "") {
$postername = T_("DELUSER");
$title = T_("DELETED_ACCOUNT");
$avatar = "";
$usersignature = "";
$userdownloaded = "";
$useruploaded = "";
} else {
$privacylevel = $row["privacy"];
$avatar = htmlspecialchars($row["avatar"]);
$title = format_comment($row["title"]);
$usersignature = stripslashes(format_comment($row["signature"]));
$userdownloaded = mksize($row["downloaded"]);
$useruploaded = mksize($row["uploaded"]);
}
if ($row["downloaded"] > 0) {
$userratio = number_format($row["uploaded"] / $row["downloaded"], 2);
} else {
$userratio = "---";
}
if (!$avatar) {
$avatar = "/images/default_avatar.png";
}
$commenttext = format_comment($row["body"]);
$edit = null;
if ($CURUSER["edit_torrents"] == "yes" || $CURUSER["edit_news"] == "yes" || $CURUSER['id'] == $row['user']) {
$edit = '[<a href="forums/editpost&postid=' . $row['id'] . '">Edit</a>] ';
}
$delete = null;
if ($CURUSER["delete_torrents"] == "yes" || $CURUSER["delete_news"] == "yes") {
$delete = '[<a href="forums/deletepost&postid=' . $row['id'] . '&sure=0">Delete</a>] ';
}
print('<div><table style="border: 1px solid black" >');
print('<thead><tr">');
print('<th align="center" width="150"></th>');
print('<th align="right">' . $edit . $delete . '[<a href="report/forum?forumid=' . $row['topicid'] . '&forumpost=' . $row['id'] . '">Report</a>] Posted: ' . date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row["added"])) . '<a id="comment' . $row["id"] . '"></a></th>');
print('</tr></thead>');
print('<tr valign="top">');
if ($CURUSER['edit_users'] == 'no' && $privacylevel == 'strong') {
print('<td align="left" width="150"><center><a href="profile?id=' . $row['id'] . '"><b>' . $postername . '</b></a><br /><i>' . $title . '</i><br /><img width="80" height="80" src="' . $avatar . '" alt="" /><br /><br />Uploaded: ---<br />Downloaded: ---<br />Ratio: ---<br /><br /><a href="profile?id=' . $row["user"] . '"><img src="themes/default/forums/icon_profile.png" border="" alt="" /></a> <a href='messages/create?id=' . $row["user"] . '"><img src="themes/default/forums/icon_pm.png" border="0" alt="" /></a></center></td>');
} else {
print('<td align="left" width="150"><center><a href="profile?id=' . $row['id'] . '"><b>' . $postername . '</b></a><br /><i>' . $title . '</i><br /><img width="80" height="80" src="' . $avatar . '" alt="" /><br /><br />Uploaded: ' . $useruploaded . '<br />Downloaded: ' . $userdownloaded . '<br />Ratio: ' . $userratio . '<br /><br /><a href="profile?id=' . $row["user"] . '"><img src="themes/defualt/forums/icon_profile.png" border="0" alt="" /></a> <a href="/messages/create?id=' . $row["user"] . '"><img src="themes/default/forums/icon_pm.png" border="0" alt="" /></a></center></td>');
}
print('<td>' . $commenttext . '<hr />' . $usersignature . '</td>');
print('</tr>');
print('</table></div>');
}
end_frame();
stdfoot();
$torrent = new Torrent( "uploads/$id.torrent");
try {
$scraped = $torrent->scrape();
} catch (Exception $e) {
$scraped = $torrent->errors();
exit();
}
$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 !== null) {
// Update the Torrent
SQL_Query_exec("
UPDATE torrents
SET leechers = $leechers, seeders = $seeders, times_completed = $completed, last_action = get_date_time(), visible = 'yes'
WHERE id = $id");
}
}
//END SCRAPE



<?php
require_once("backend/Scraper.php");
require_once("backend/Torrent.php");
// change this id from 7
$file = 'uploads/7.torrent';
$torrent = new Torrent($file);
try {
$scraped = $torrent->scrape();
} catch (Exception $e) {
$scraped = $torrent->errors();
exit();
}
$myarray = array_shift($scraped);
echo $myarray['completed'].'<br>';
echo $myarray['leechers'].'<br>';
echo $myarray['seeders'].'<br>';
DB::run("
UPDATE torrents
SET leechers = ?, seeders = ?, times_completed = ?, last_action = ?, visible = ?
WHERE id = ?",
[$leechers, $seeders, $downloaded, TimeDate::get_date_time(), 'yes', $id]);