Skip to content

Commit

Permalink
sync with hdxxxx pt site again;
Browse files Browse the repository at this point in the history
use mysql again from mysqli(compatible with  PHP5; compatible with product web site);
update getip();update imdb.class.php;
  • Loading branch information
cdwolfling committed Dec 1, 2017
1 parent 303af38 commit b0af4fe
Show file tree
Hide file tree
Showing 125 changed files with 755 additions and 794 deletions.
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ for more detail: please contact me:
20171130:
mysql-->mysqli; update getip();update imdb.class.php;
ignore config/allconfig.php, please restore it from config/allconfig.php.bak
20171201:
sync with hdxxxx pt site again;
use mysql again from mysqli(compatible with PHP5; compatible with product web site);
update getip();update imdb.class.php;

2 changes: 1 addition & 1 deletion RELEASENOTE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Release note for v1.5 beta 4 20100919
Fix: "There is a minimum announce time of 30 seconds", caused by timezone settings. Now you should set correct timezone in php.ini
Fix: varchar column length exceed 255 characters, which causes errors in MySQL 5.0.3 and later
Mod: set mysql sql_mode in php level
Mod: change mysql_pconnect to mysqli_connect
Mod: change mysql_pconnect to mysql_connect
Release note for v1.5 beta 4 20100905
Add: promotion timeout setting per torrent
Fix: some minor bugs
Expand Down
4 changes: 2 additions & 2 deletions aboutnexus.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end_frame();
unset($ppl);
$res = sql_query("SELECT * FROM language ORDER BY trans_state") or sqlerr();
while ($arr = mysqli_fetch_assoc($res))
while ($arr = mysql_fetch_assoc($res))
{
$ppl .= "<tr><td class=\"rowfollow\"><img width=\"24\" height=\"15\" src=\"pic/flag/".$arr[flagpic]."\" alt=\"".$arr[lang_name]."\" title=\"".$arr[lang_name]."\" style=\"padding-bottom:1px;\" /></td>
<td class=\"rowfollow\">".$arr['lang_name']."</td>".
Expand All @@ -40,7 +40,7 @@
end_frame();
unset($ppl);
$res = sql_query("SELECT * FROM stylesheets ORDER BY id") or sqlerr();
while ($arr = mysqli_fetch_assoc($res))
while ($arr = mysql_fetch_assoc($res))
{
$ppl .= "<tr><td class=\"rowfollow\">".$arr['name']."</td>
<td class=\"rowfollow\">".$arr['designer']."</td>".
Expand Down
6 changes: 3 additions & 3 deletions adduser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
stderr("Error","Invalid username.");
$username = sqlesc($username);
$res = sql_query("SELECT id FROM users WHERE username=$username");
$arr = sql_fetch_row($res);
$arr = mysql_fetch_row($res);
if ($arr)
stderr("Error","Username already exists!");
$password = $_POST["password"];
$email = sqlesc($_POST["email"]);
$res = sql_query("SELECT id FROM users WHERE email=$email");
$arr = sql_fetch_row($res);
$arr = mysql_fetch_row($res);
if ($arr)
stderr("Error","The e-mail address is already in use.");
$secret = mksecret();
Expand All @@ -36,7 +36,7 @@

sql_query("INSERT INTO users (added, last_access, secret, username, passhash, status, stylesheet, class,email) VALUES(NOW(), NOW(), $secret, $username, $passhash, 'confirmed', ".$defcss.",".$defaultclass_class.",$email)") or sqlerr(__FILE__, __LINE__);
$res = sql_query("SELECT id FROM users WHERE username=$username");
$arr = sql_fetch_row($res);
$arr = mysql_fetch_row($res);
if (!$arr)
stderr("Error", "Unable to create the account. The user name is possibly already taken.");
header("Location: " . get_protocol_prefix() . "$BASEURL/userdetails.php?id=".htmlspecialchars($arr[0]));
Expand Down
10 changes: 5 additions & 5 deletions admanage.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function print_ad_editor($position, $row = "")
stderr($lang_admanage['std_error'], $lang_admanage['std_invalid_id']);
}
$res = sql_query ("SELECT * FROM advertisements WHERE id = ".sqlesc($id)." LIMIT 1");
if ($row = mysqli_fetch_array($res))
if ($row = mysql_fetch_array($res))
sql_query("DELETE FROM advertisements WHERE id = ".sqlesc($row['id'])) or sqlerr(__FILE__, __LINE__);
$Cache->delete_value('current_ad_array', false);
header("Location: ".get_protocol_prefix() . $BASEURL."/admanage.php");
Expand All @@ -212,7 +212,7 @@ function print_ad_editor($position, $row = "")
else
{
$res = sql_query("SELECT * FROM advertisements WHERE id = ".sqlesc($id)." LIMIT 1");
if (!$row = mysqli_fetch_array($res))
if (!$row = mysql_fetch_array($res))
stderr($lang_admanage['std_error'], $lang_admanage['std_invalid_id']);
else
{
Expand Down Expand Up @@ -261,14 +261,14 @@ function print_ad_editor($position, $row = "")
{
$adid = $id;
$res = sql_query("SELECT * FROM advertisements WHERE id = ".sqlesc($id)." LIMIT 1");
if (!$row = mysqli_fetch_array($res))
if (!$row = mysql_fetch_array($res))
stderr($lang_admanage['std_error'], $lang_admanage['std_invalid_id']);
}
}
else
{
$res = sql_query("SELECT id FROM advertisements ORDER BY id DESC LIMIT 1");
$row = mysqli_fetch_array($res);
$row = mysql_fetch_array($res);
if (!$row)
$adid = 1;
else $adid = $row['id']+1;
Expand Down Expand Up @@ -395,7 +395,7 @@ function print_ad_editor($position, $row = "")
<td class="colhead"><?php echo $lang_admanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
$clickcount=get_row_count("adclicks", "WHERE adid=".sqlesc($row['id']));
?>
Expand Down
2 changes: 1 addition & 1 deletion allagents.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
stdhead("All Clients");
print("<table align=center border=3 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead>Client</td><td class=colhead>Peer ID</td></tr>\n");
while($arr2 = mysqli_fetch_assoc($res2))
while($arr2 = mysql_fetch_assoc($res2))
{
print("</a></td><td align=left>$arr2[agent]</td><td align=left>$arr2[peer_id]</td></tr>\n");
}
Expand Down
2 changes: 1 addition & 1 deletion allowedemails.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
stdhead ("Show List");
print("<table border=1 cellspacing=0 cellpadding=5 width=737>\n");
$sql = sql_query("SELECT * FROM allowedemails") or sqlerr(__FILE__, __LINE__);
$list = mysqli_fetch_array($sql);
$list = mysql_fetch_array($sql);
?>
<form method=post action=allowedemails.php>
<input type=hidden name=action value=savelist>
Expand Down
2 changes: 1 addition & 1 deletion amountbonus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

sql_query("UPDATE users SET seedbonus=seedbonus + $seedbonus WHERE username=$username") or sqlerr(__FILE__, __LINE__);
$res = sql_query("SELECT id FROM users WHERE username=$username");
$arr = sql_fetch_row($res);
$arr = mysql_fetch_row($res);
if (!$arr)
stderr("Error", "Unable to update account.");
header("Location: " . get_protocol_prefix() . "$BASEURL/userdetails.php?id=".htmlspecialchars($arr[0]));
Expand Down
20 changes: 10 additions & 10 deletions announce.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
// check passkey
if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){
$res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
$az = mysqli_fetch_array($res);
$az = mysql_fetch_array($res);
$Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950);
}
if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL");
Expand Down Expand Up @@ -82,7 +82,7 @@
$torrentCacheKey = 'torrent_hash_'.bin2hex($info_hash).'_content';
if (!$torrent = $Cache->get_value($torrentCacheKey)){
$res = sql_query("SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, category FROM torrents WHERE " . hash_where("info_hash", $info_hash));
$torrent = mysqli_fetch_array($res);
$torrent = mysql_fetch_array($res);
$Cache->cache_value($torrentCacheKey, $torrent, 350);
}
if (!$torrent){
Expand Down Expand Up @@ -124,7 +124,7 @@
$peer_list = "";
unset($self);
// bencoding the peers info get for this announce
while ($row = mysqli_fetch_assoc($res))
while ($row = mysql_fetch_assoc($res))
{
$row["peer_id"] = hash_pad($row["peer_id"]);

Expand Down Expand Up @@ -163,7 +163,7 @@
if (!isset($self))
{
$res = sql_query("SELECT $fields FROM peers WHERE $selfwhere LIMIT 1");
$row = mysqli_fetch_assoc($res);
$row = mysql_fetch_assoc($res);
if ($row)
{
$self = $row;
Expand All @@ -177,7 +177,7 @@
// current peer_id, or you could say session with tracker not found in table peers
if (!isset($self))
{
$valid = @sql_fetch_row(@sql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND userid=" . sqlesc($userid)));
$valid = @mysql_fetch_row(@sql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND userid=" . sqlesc($userid)));
if ($valid[0] >= 1 && $seeder == 'no') err("You already are downloading the same torrent. You may only leech from one location at a time.");
if ($valid[0] >= 3 && $seeder == 'yes') err("You cannot seed the same torrent from more than 3 locations.");

Expand Down Expand Up @@ -218,7 +218,7 @@
if ($max > 0)
{
$res = sql_query("SELECT COUNT(*) AS num FROM peers WHERE userid='$userid' AND seeder='no'") or err("Tracker error 5");
$row = mysqli_fetch_assoc($res);
$row = mysql_fetch_assoc($res);
if ($row['num'] >= $max) err("Your slot limit is reached! You may at most download $max torrents at the same time, please read $BASEURL/faq.php#id66 for details");
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@
if (isset($self) && $event == "stopped")
{
sql_query("DELETE FROM peers WHERE $selfwhere") or err("D Err");
if (sql_affected_rows())
if (mysql_affected_rows())
{
$updateset[] = ($self["seeder"] == "yes" ? "seeders = seeders - 1" : "leechers = leechers - 1");
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." WHERE torrentid = $torrentid AND userid = $userid") or err("SL Err 1");
Expand All @@ -284,7 +284,7 @@

sql_query("UPDATE peers SET ip = ".sqlesc($ip).", port = $port, uploaded = $uploaded, downloaded = $downloaded, to_go = $left, prev_action = last_action, last_action = $dt, seeder = '$seeder', agent = ".sqlesc($agent)." $finished WHERE $selfwhere") or err("PL Err 1");

if (sql_affected_rows())
if (mysql_affected_rows())
{
if ($seeder <> $self["seeder"])
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1");
Expand All @@ -309,11 +309,11 @@
}
sql_query("INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ($torrentid, $userid, ".sqlesc($peer_id).", ".sqlesc($ip).", $port, '$connectable', $uploaded, $downloaded, $left, $dt, $dt, '$seeder', ".sqlesc($agent).", $downloaded, $uploaded, ".sqlesc($passkey).")") or err("PL Err 2");

if (sql_affected_rows())
if (mysql_affected_rows())
{
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1" : "leechers = leechers + 1");

$check = @sql_fetch_row(@sql_query("SELECT COUNT(*) FROM snatched WHERE torrentid = $torrentid AND userid = $userid"));
$check = @mysql_fetch_row(@sql_query("SELECT COUNT(*) FROM snatched WHERE torrentid = $torrentid AND userid = $userid"));
if (!$check['0']){
$hr = $az['class'] < $bypass_userclass_hnr && $torrent['hr'] && is_require_hitrun(intval($torrent['ts'])) ? 1 : 0;
sql_query("INSERT INTO snatched (torrentid, userid, ip, port, uploaded, downloaded, to_go, startdat, last_action, hr) VALUES ($torrentid, $userid, ".sqlesc($ip).", $port, $uploaded, $downloaded, $left, $dt, $dt, $hr)") or err("SL Err 4");
Expand Down
2 changes: 1 addition & 1 deletion bannedemails.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
stdhead (VERSION." - Show List");
print("<table border=1 cellspacing=0 cellpadding=5 width=737>\n");
$sql = sql_query("SELECT * FROM bannedemails") or sqlerr(__FILE__, __LINE__);
$list = mysqli_fetch_array($sql);
$list = mysql_fetch_array($sql);
?>
<form method=post action=bannedemails.php>
<input type=hidden name=action value=savelist>
Expand Down
8 changes: 4 additions & 4 deletions bans.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$remove = (int)$_GET['remove'];
if (is_valid_id($remove))
{
sql_query("DELETE FROM bans WHERE id=".sql_real_escape_string($remove)) or sqlerr();
sql_query("DELETE FROM bans WHERE id=".mysql_real_escape_string($remove)) or sqlerr();
write_log("Ban ".htmlspecialchars($remove)." was removed by $CURUSER[id] ($CURUSER[username])",'mod');
}

Expand All @@ -25,7 +25,7 @@
stderr("Error", "Bad IP address.");
$comment = sqlesc($comment);
$added = sqlesc(date("Y-m-d H:i:s"));
sql_query("INSERT INTO bans (added, addedby, first, last, comment) VALUES($added, ".sql_real_escape_string($CURUSER[id]).", $firstlong, $lastlong, $comment)") or sqlerr(__FILE__, __LINE__);
sql_query("INSERT INTO bans (added, addedby, first, last, comment) VALUES($added, ".mysql_real_escape_string($CURUSER[id]).", $firstlong, $lastlong, $comment)") or sqlerr(__FILE__, __LINE__);
header("Location: $_SERVER[REQUEST_URI]");
die;
}
Expand All @@ -38,15 +38,15 @@

print("<h1>Current Bans</h1>\n");

if (sql_num_rows($res) == 0)
if (mysql_num_rows($res) == 0)
print("<p align=center><b>Nothing found</b></p>\n");
else
{
print("<table border=1 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead>Added</td><td class=colhead align=left>First IP</td><td class=colhead align=left>Last IP</td>".
"<td class=colhead align=left>By</td><td class=colhead align=left>Comment</td><td class=colhead>Remove</td></tr>\n");

while ($arr = mysqli_fetch_assoc($res))
while ($arr = mysql_fetch_assoc($res))
{
print("<tr><td>".gettime($arr[added])."</td><td align=left>".long2ip($arr[first])."</td><td align=left>".long2ip($arr[last])."</td><td align=left>". get_username($arr['addedby']) .
"</td><td align=left>$arr[comment]</td><td><a href=bans.php?remove=$arr[id]>Remove</a></td></tr>\n");
Expand Down
14 changes: 7 additions & 7 deletions bitbucketlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
{
$delete = $_GET["delete"];
if (is_valid_id($delete)) {
$r = sql_query("SELECT name,owner FROM bitbucket WHERE id=".sql_real_escape_string($delete)) or sqlerr(__FILE__, __LINE__);
if (sql_num_rows($r) == 1) {
$a = mysqli_fetch_assoc($r);
$r = sql_query("SELECT name,owner FROM bitbucket WHERE id=".mysql_real_escape_string($delete)) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($r) == 1) {
$a = mysql_fetch_assoc($r);
if (get_user_class() >= UC_MODERATOR || $a["owner"] == $CURUSER["id"]) {
sql_query("DELETE FROM bitbucket WHERE id=".sql_real_escape_string($delete)) or sqlerr(__FILE__, __LINE__);
sql_query("DELETE FROM bitbucket WHERE id=".mysql_real_escape_string($delete)) or sqlerr(__FILE__, __LINE__);
if (!unlink("$bucketpath/$a[name]"))
stderr("Warning", "Unable to unlink file: <b>$a[name]</b>. You should contact an administrator about this error.",false);
} } } }
stdhead("BitBucket Log");
$res = sql_query("SELECT count(*) FROM bitbucket") or die(sql_error()); $row = mysqli_fetch_array($res); $count = $row[0];
$res = sql_query("SELECT count(*) FROM bitbucket") or die(mysql_error()); $row = mysql_fetch_array($res); $count = $row[0];
$perpage = 10;
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] . "?out=" . $_GET["out"] . "&" );
print("<h1>BitBucket Log</h1>\n");
print("Total Images Stored: $count");
echo $pagertop;
$res = sql_query("SELECT * FROM bitbucket ORDER BY added DESC $limit") or sqlerr(__FILE__, __LINE__);
if (sql_num_rows($res) == 0)
if (mysql_num_rows($res) == 0)
print("<b>BitBucket Log is empty</b>\n");
else {
print("<table align='center' border='0' cellspacing='0' cellpadding='5'>\n");
while ($arr = mysqli_fetch_assoc($res)) {
while ($arr = mysql_fetch_assoc($res)) {
$date = substr($arr['added'], 0, strpos($arr['added'], " "));
$time = substr($arr['added'], strpos($arr['added'], " ") + 1);
$name = $arr["name"];
Expand Down
2 changes: 1 addition & 1 deletion bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if(isset($CURUSER))
{
$res_bookmark = sql_query("SELECT * FROM bookmarks WHERE torrentid=" . sqlesc($torrentid) . " AND userid=" . sqlesc($CURUSER[id]));
if (sql_num_rows($res_bookmark) == 1){
if (mysql_num_rows($res_bookmark) == 1){
sql_query("DELETE FROM bookmarks WHERE torrentid=" . sqlesc($torrentid) . " AND userid=" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__,__LINE__);
$Cache->delete_value('user_'.$CURUSER['id'].'_bookmark_array');
echo "deleted";
Expand Down
20 changes: 10 additions & 10 deletions catmanage.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function return_category_mode_selection($selname, $selectionid)
{
$res = sql_query("SELECT * FROM searchbox ORDER BY id ASC");
$selection = "<select name=\"".$selname."\">";
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
$selection .= "<option value=\"" . $row["id"] . "\"". ($row["id"]==$selectedid ? " selected=\"selected\"" : "").">" . htmlspecialchars($row["name"]) . "</option>\n";
$selection .= "</select>";
return $selection;
Expand Down Expand Up @@ -160,7 +160,7 @@ function print_sub_category_list($type)
<td class="colhead"><?php echo $lang_catmanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
?>
<tr>
Expand Down Expand Up @@ -401,7 +401,7 @@ function print_sub_category_editor($type, $row='')
<td class="colhead"><?php echo $lang_catmanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
?>
<tr>
Expand Down Expand Up @@ -451,7 +451,7 @@ function print_sub_category_editor($type, $row='')
<td class="colhead"><?php echo $lang_catmanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
?>
<tr>
Expand Down Expand Up @@ -500,7 +500,7 @@ function print_sub_category_editor($type, $row='')
<td class="colhead"><?php echo $lang_catmanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
?>
<tr>
Expand Down Expand Up @@ -547,7 +547,7 @@ function print_sub_category_editor($type, $row='')
<td class="colhead"><?php echo $lang_catmanage['col_action']?></td>
</tr>
<?php
while ($row = mysqli_fetch_array($res))
while ($row = mysql_fetch_array($res))
{
?>
<tr>
Expand Down Expand Up @@ -582,7 +582,7 @@ function print_sub_category_editor($type, $row='')
}
$dbtablename=return_category_db_table_name($type);
$res = sql_query ("SELECT * FROM ".$dbtablename." WHERE id = ".sqlesc($id)." LIMIT 1");
if ($row = mysqli_fetch_array($res)){
if ($row = mysql_fetch_array($res)){
sql_query("DELETE FROM ".$dbtablename." WHERE id = ".sqlesc($row['id'])) or sqlerr(__FILE__, __LINE__);
if(in_array($type, $validsubcattype))
$Cache->delete_value($dbtablename.'_list');
Expand Down Expand Up @@ -611,7 +611,7 @@ function print_sub_category_editor($type, $row='')
{
$dbtablename=return_category_db_table_name($type);
$res = sql_query ("SELECT * FROM ".$dbtablename." WHERE id = ".sqlesc($id)." LIMIT 1");
if (!$row = mysqli_fetch_array($res))
if (!$row = mysql_fetch_array($res))
stderr($lang_catmanage['std_error'], $lang_catmanage['std_invalid_id']);
else
{
Expand Down Expand Up @@ -648,7 +648,7 @@ function print_sub_category_editor($type, $row='')
else
{
$res = sql_query("SELECT * FROM ".$dbtablename." WHERE id = ".sqlesc($id)." LIMIT 1");
if (!$row = mysqli_fetch_array($res))
if (!$row = mysql_fetch_array($res))
stderr($lang_catmanage['std_error'], $lang_catmanage['std_invalid_id']);
}
}
Expand Down Expand Up @@ -746,7 +746,7 @@ function print_sub_category_editor($type, $row='')
$updateset[] = "audiocodec=".sqlesc($audiocodec);
if($_POST['isedit']){
$res2=sql_query("SELECT * FROM secondicons WHERE id=".sqlesc($id)." LIMIT 1");
if ($row2=mysqli_fetch_array($res))
if ($row2=mysql_fetch_array($res))
{
$Cache->delete_value('secondicon_'.$row2['source'].'_'.$row2['medium'].'_'.$row2['codec'].'_'.$row2['standard'].'_'.$row2['processing'].'_'.$row2['team'].'_'.$row2['audiocodec'].'_content');
}
Expand Down
Loading

0 comments on commit b0af4fe

Please sign in to comment.