"Obiwan, post: 69410, member: 4":
Sorry, didn't mean to offend.
It's just that a Beta1 was made available on here, so figured a Beta2 would have followed fairly soon after. Seems like a Beta2 would have been good, and get rid if the Beta1, since it is no where near usable.
Anyway. Keep at it. Seems like nice work so far. And I imagine it is really time consuming. So once again, sorry if I offended.
"Botanicar, post: 69408, member: 19833":
Thanks for the information, the login was successfully completed, but that's all, nothing phenomenal. Nowhere to access for administration or the like. It remains to wait for some more realizations of this project.
Thanks for the hard work
"Obiwan, post: 69406, member: 4":
Try
Admin
password
(That is if you want to bother with all the errors that are in Beta 1. I've been waiting for a release of Beta 2 on here...so far nothing but shouts about "this, that, and the other" being modded/fixed/written/done. And more than a couple allusions to the Beta 2 being released...soon, within couple days, etc. Whatever. Good luck.)
// Auto promote users
$regular = 1; // Regular class ID
$promotclass = 3; // Promoted class ID
$limit = 25 * 1024 * 1024 * 1024;
$minratio = 1.05;
$maxdt = get_date_time(time() - 86400 * 28);
$res = SQL_Query_exec("SELECT id, username FROM users WHERE class = $regular AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");
if ($res) {
$dt = get_date_time();
$msg = "Congratulations, you have been automatically promoted to Power User. You can now do more stuff.";
while ($arr = mysql_fetch_assoc($res)) {
SQL_Query_exec("UPDATE users SET class = $promotclass WHERE id = $arr[id]");
$txt = "You have been promoted to Power User!";
$event = "$arr[username] has been promoted Power User";
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
SQL_Query_exec("INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, $arr[username], $event, $dt, 0)");
write_log("The user <a href=\"/user/?id=$arr[id]\">$arr[username]</a> was automatically promoted to power user.");
}
}
// Auto demote users
$minratio = 0.95;
$res = SQL_Query_exec("SELECT id, username FROM users WHERE class = $promotclass AND uploaded / downloaded < $minratio");
if ($res) {
$dt = get_date_time();
$msg = "You were automatically demoted from Power User to Regular because your share ratio fell below $minratio.";
while ($arr = $res->fetch()) {
SQL_Query_exec("UPDATE users SET class = $regular WHERE id = $arr[id]");
$txt = "You have been demoted to Regular!";
$event = "$arr[username] has been demoted Regular";
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
SQL_Query_exec("INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, $arr[username], $event, $dt, 0)");
write_log("The user <a href=\"/user/?id=$arr[id]\">$arr[username]</a> was automatically demoted to regular.");
}
}
// BEGIN holiday / voucher check
$t = date('Y-m-d');
$q = $db->query_params("SELECT value_s as s, value_i as i FROM avps WHERE arg = 'lastholidaycheck'");
$d = $q->fetch();
if($d['s'] != $t){
if($d['i'] === 0){
$i = 0;
$h = new Holidays();
if(!$h->isDateIsHoliday($t))
$i = 1;
else{
$v = new voucher();
if($v->todaysVoucher() === false)
$v->create("","",0,true);
$c = $v->code;
$q = $db->query_params('SELECT user_id FROM users');
$d = $q->fetch();
$txt = "To celebrate the day you will receive ". $C." This voucher is only valid today! [url=vouchers.php] Click here![/url]";
foreach($d as $u)
$db->query_params('INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, :user_id, NOW(), :message, 0)', array('user_id' => $u['user_id'], 'message' => $txt));
$i = 1;
}
$q = $db->query_params("UPDATE avps SET value_s = :s, value_i = :i WHERE arg = 'lastholidaycheck'", array('s' => $t, 'i' => $i));
}
}
// Defines the transmission rate from which a Ratiofaker entry is created in the user profile.
// For trackers that do not have a speed limit, this value should be set to approx. 5 MB per second. Ratiofaker tools usually have upload rates in the GB / s range.
// Type: Number (bytes per second)
// Possible values: N / A
if (($data['uploaded'] / 60 * 20) > 1024 * 1024 * 5) fail('Ratiofaker-Tool used!');
ALTER TABLE users ADD COLUMN slots INT(10) NOT NULL DEFAULT 3
// Max download slots check - Sep 20, 2020
$maxslots = $db->query_params("SELECT COUNT(DISTINCT torrent_id) AS total FROM peers WHERE user_id = :user_id AND seeder = 'no'", array('user_id' => $user_row['user_id']));
$maxslot2 = $db->query_params("SELECT p.user_id, u.slots FROM users u LEFT JOIN peers p ON p.user_id = u.user_id WHERE u.user_id = :user_id AND p.seeder = 'no' LIMIT 1", array('user_id' => $user_row['user_id']));
foreach ($maxslots as $slots) {
foreach ($maxslot2 as $maxslot) {
if ($slots['total'] > $maxslot['slots']) {
fail("Maximum $slots[total]/$maxslot[slots] download slots exceeded! Finish current transfers to reclaim slots.");
}
}
}
// Max Slots - Fixed - Seedbox-Compatible - Sep 20, 2020 - No foreach!
$maxslots = $db->query_params("SELECT COUNT(DISTINCT torrent_id) AS total, last_announce FROM peers WHERE user_id = :user_id AND seeder = 'no'", array('user_id' => $user_row['user_id']));
$current = $maxslots->fetch();
if ($current['total'] > $user_row['slots']) {
$checklast = $db->query_params('SELECT user, date, message FROM shoutbox WHERE user = :username', array('username' => $user_row['username']));
$lastmessage = $checklast->fetch();
if ($lastmessage['date'] <= $current['last_announce']) {
$event = "$user_row[username] reached their maximum download slot $current[total]/$user_row[slots]";
$db->query_params('INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, :receiver, :event, NOW(), 0)', array('receiver' => $user_row['username'], 'event' => $event));
}
fail("$current[total]/$user_row[slots] download slots exceeded! Finish current transfers to reclaim slots.");
}
<?
// Seed Bonus - Reworked - Sep 19, 2020
require_once '../site.php';
$db->connect();
site_header();
if (!$account->sessionLogin()) {
header(sprintf('Location: %s/siginin/', $CONFIG['base_url']));
die;
}
$errors = array();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = array();
$keys = array('id', 'userid', 'torrentid');
foreach ($keys as $key) {
if (!array_key_exists($key, $_POST)) {
sprintf('Seed bonus item ID %s not valid.', $key);
}
$data[$key] = $_POST[$key];
}
$res = $db->query_params('SELECT users.seedbonus, users.perk_avatar, users.username, users.slots, users.last_exchange, users.class, users.user_id, bonus.cost, bonus.descr, bonus.type, bonus.value, bonus.id FROM users, bonus WHERE users.user_id = :user_id AND bonus.id = :post_id', array('user_id' => $account->getId(), 'post_id' => $data['id'])) or die('db error');
if (!($row = $res->fetch()) || $row['seedbonus'] < $row['cost']) {
$errors []= 'Demand not valid.';
}
if (empty($errors)) {
$db->query_params("UPDATE users SET seedbonus = seedbonus - :cost WHERE user_id = :user_id", array('cost' => $row['cost'], 'user_id' => $account->getid())) or die('User bonus update failed.');
}
$types = array(
'invite' => true,
'traffic' => true,
'hnr' => true,
'slots' => true,
'vip' => true,
'last_exchange' => true,
'value' => true,
'feature' => true
);
$data_row = array();
foreach ($types as $key => $req) {
if (array_key_exists($key, $row)) {
$data_row[$key] = $row[$key];
} else if ($req) {
sprintf('Invalid type %s', $key);
}
}
if (empty($errors) || array_key_exists('id', $data)) {
if ($row['type'] == 'invite' && $data['id'] == $row['id']) {
$db->query_params("UPDATE users SET invites = invites + :value WHERE user_id = :user_id", array('value' => $row['value'], 'user_id' => $account->getid()));
echo sprintf('Your account has been <b>credited</b> for <b>%s</b> Extra Invites!', $row['value']);
}
if ($row['type'] == 'traffic' && $data['id'] == $row['id']) {
$db->query_params("UPDATE users SET uploaded = uploaded + :value, last_exchange = :bonus WHERE user_id = :user_id", array('bonus' => $row['value'], 'value' => $row['value'], 'user_id' => $account->getid()));
echo sprintf('Your account has been <b>credited</b> for <b>%s</b> bonus Upload Data!', format_size($row['value']));
}
if ($row['type'] == 'HnR' && $data['id'] == $row['id']) {
$uid = $row['class'] == '1' ? $data['userid'] : $account->getId();
if (!array_key_exists('torrentid', $data)) {
die('You must fill the box with the id of the torrent.');
}
if (isset($uid)) {
$res = $db->query_params("SELECT * FROM snatched WHERE tid = :tid AND uid = :uid AND hnr = 'yes'", array('tid' => $data['torrentid'], 'uid' => $uid));
if ($res)
die('No HnR found with this information.');
$res1 = $db->query_params("SELECT username FROM users WHERE user_id = :uid", array('uid' => $uid));
$row1 = $res1->fetch();
$res2 = $db->query_params("SELECT name FROM torrents WHERE torrent_id = :tid", array('tid' => $tid));
$row2 = $res2->fetch();
$username = html_escape($row1['username']);
$torname = html_escape($row2['name']);
// TODO: db Hit n Run logging
echo sprintf('Hit and Run has been cleared for torrent %s', $row2['name']);
if ($uid == $account->getId())
$new_modcomment .= "H&R on the torrent " . $torname . " cleared against " . $row['cost'] . " points \n";
else
$new_modcomment .= "H&R on the torrent " . $torname . " cleared by " . $account->username() . " \n";
$modcom = gmdate('d-m-Y \à H:i') . ' - ';
$db->query_params('UPDATE users SET modcomment = CONCAT(:modcom,modcomment) WHERE user_id = :user_id', array('modcom' => $modcom, 'user_id' => $uid));
$db->query_params("UPDATE snatched SET ltime = '129600', hnr = 'no' WHERE tid = :tid AND uid = :uid", array('tid' => $modcom, 'uid' => $uid));
}
}
if ($row['type'] == 'slots' && $data['id'] == $row['id']) {
$db->query_params('UPDATE users SET slots = :slots WHERE user_id = :user_id', array('slots' => $data_row['value'], 'user_id' => $account->getid()));
echo sprintf('Your account has been <b>credited</b> for <b>%s</b> Extra Download Slots!', $row['value']);
}
if ($row['type'] == 'feature' && $data['id'] == $row['id']) {
$db->query_params("UPDATE users SET perk_avatar = 'yes' WHERE user_id = :user_id", array('user_id' => $account->getid()));
echo sprintf('Your avatar has been <b>enlarged</b> to <b>%s</b> Pixels!', $row['value']);
}
}
}
<?
$findseeders = $db->query_params("SELECT COUNT(torrent) FROM peers WHERE seeder = 'yes' AND torrent = :torrent_id", array(
'torrent_id' => $torrent['id']
));
$findleechers = $db->query_params("SELECT COUNT(torrent) FROM peers WHERE seeder = 'no' AND torrent = :torrent_id", array(
'torrent_id' => $torrent['id']
));
foreach ($findseeders->fetch() as $row) {
$getseeders = $row;
foreach ($findleechers->fetch() as $row2) {
$getleechers = $row2;
}
}
echo $getseeders;
echo $getleechers;
SELECT COUNT(torrent) FROM peers WHERE seeder = 'yes' AND torrent = 27;
SELECT COUNT(torrent) FROM peers WHERE seeder = 'no' AND torrent = 27;
"m-jay, post: 69356, member: 20288":
Two things I've learnt that might be useful
Close connection under header()
header("Connection: Close");
Close page after output
exit();