Skip to content

Commit

Permalink
remove all 'or die(mysql_errno())'
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Jun 15, 2021
1 parent ab8069a commit 7727ffc
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 52 deletions.
3 changes: 3 additions & 0 deletions include/cleanup.php
Expand Up @@ -967,6 +967,9 @@ function docleanup($forceAll = 0, $printProgress = false) {
}
$log = 'Full cleanup is done';
do_log($log);
if ($printProgress) {
printProgress($log);
}
return $log;
}
?>
14 changes: 7 additions & 7 deletions include/functions.php
Expand Up @@ -35,20 +35,20 @@ function get_langfile_path($script_name ="", $target = false, $lang_folder = "")
function get_row_count($table, $suffix = "")
{
$r = sql_query("SELECT COUNT(*) FROM $table $suffix") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r) or die(mysql_error());
$a = mysql_fetch_row($r);
return $a[0];
}

function get_row_sum($table, $field, $suffix = "")
{
$r = sql_query("SELECT SUM($field) FROM $table $suffix") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r) or die(mysql_error());
$a = mysql_fetch_row($r);
return $a[0];
}

function get_single_value($table, $field, $suffix = ""){
$r = sql_query("SELECT $field FROM $table $suffix LIMIT 1") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r) or die(mysql_error());
$a = mysql_fetch_row($r);
if ($a) {
return $a[0];
} else {
Expand Down Expand Up @@ -1578,7 +1578,7 @@ function image_code () {
$imagehash = md5($randomstr);
$dateline = time();
$sql = 'INSERT INTO `regimages` (`imagehash`, `imagestring`, `dateline`) VALUES (\''.$imagehash.'\', \''.$randomstr.'\', \''.$dateline.'\');';
sql_query($sql) or die(mysql_error());
sql_query($sql);
return $imagehash;
}

Expand Down Expand Up @@ -1877,7 +1877,7 @@ function userlogin() {
}
if (!$row["passkey"]){
$passkey = md5($row['username'].date("Y-m-d H:i:s").$row['passhash']);
sql_query("UPDATE users SET passkey = ".sqlesc($passkey)." WHERE id=" . sqlesc($row["id"]));// or die(mysql_error());
sql_query("UPDATE users SET passkey = ".sqlesc($passkey)." WHERE id=" . sqlesc($row["id"]));
}

$oldip = $row['ip'];
Expand Down Expand Up @@ -2260,8 +2260,8 @@ function get_style_highlight()
}
if (!$hltr)
{
$r = sql_query("SELECT hltr FROM stylesheets WHERE id=5") or die(mysql_error());
$a = mysql_fetch_array($r) or die(mysql_error());
$r = sql_query("SELECT hltr FROM stylesheets WHERE id=5");
$a = mysql_fetch_array($r);
$hltr = $a["hltr"];
}
return $hltr;
Expand Down
64 changes: 32 additions & 32 deletions public/bitbucketlog.php
@@ -1,7 +1,7 @@
<?php
<?php
require "../include/bittorrent.php";
dbconn();
loggedinorreturn();
dbconn();
loggedinorreturn();
parked();
if (get_user_class() < UC_ADMINISTRATOR)
stderr("Sorry", "Access denied.");
Expand All @@ -10,44 +10,44 @@
{
$delete = intval($_GET["delete"] ?? 0);
if (is_valid_id($delete)) {
$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=".mysql_real_escape_string($delete)) or sqlerr(__FILE__, __LINE__);
$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=".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(mysql_error()); $row = mysql_fetch_array($res); $count = $row[0];
$perpage = 10;
} } } }
stdhead("BitBucket Log");
$res = sql_query("SELECT count(*) FROM bitbucket"); $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 (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");
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 (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 = mysql_fetch_assoc($res)) {
$date = substr($arr['added'], 0, strpos($arr['added'], " "));
$time = substr($arr['added'], strpos($arr['added'], " ") + 1);
$date = substr($arr['added'], 0, strpos($arr['added'], " "));
$time = substr($arr['added'], strpos($arr['added'], " ") + 1);
$name = $arr["name"];
list($width, $height, $type, $attr) = getimagesize("" . get_protocol_prefix() . "$BASEURL/$bitbucket/$name");
list($width, $height, $type, $attr) = getimagesize("" . get_protocol_prefix() . "$BASEURL/$bitbucket/$name");
$url = str_replace(" ", "%20", htmlspecialchars("$bitbucket/$name"));
print("<tr>");
print("<td><center><a href=$url><img src=\"".$url."\" border=0 onLoad='SetSize(this, 400)'></a></center>");
print("<td><center><a href=$url><img src=\"".$url."\" border=0 onLoad='SetSize(this, 400)'></a></center>");
print("Uploaded by: " . get_username($arr['owner']). "<br />");
print("(#{$arr['id']}) Filename: $name ($width&nbsp;x&nbsp;$height)");
if (get_user_class() >= UC_MODERATOR)
if (get_user_class() >= UC_MODERATOR)
print(" <b><a href=?delete={$arr['id']}>[Delete]</a></b><br />");
print("Added: $date $time");
print("</tr>");
}
print("</table>");
}
echo
$pagerbottom;
print("Added: $date $time");
print("</tr>");
}
print("</table>");
}
echo
$pagerbottom;
stdfoot();
?>
2 changes: 1 addition & 1 deletion public/sendmessage.php
Expand Up @@ -12,7 +12,7 @@
if ($replyto && !is_valid_id($replyto))
stderr($lang_sendmessage['std_error'],$lang_sendmessage['std_permission_denied']);

$res = sql_query("SELECT * FROM users WHERE id=$receiver") or die(mysql_error());
$res = sql_query("SELECT * FROM users WHERE id=$receiver");
$user = mysql_fetch_assoc($res);
if (!$user)
stderr($lang_sendmessage['std_error'],$lang_sendmessage['std_no_user_id']);
Expand Down
6 changes: 3 additions & 3 deletions public/staffbox.php
Expand Up @@ -23,7 +23,7 @@
{
stdmsg($lang_staffbox['std_sorry'], $lang_staffbox['std_no_messages_yet']);
}
else
else
{
begin_main_frame();
print("<form method=post action=\"?action=takecontactanswered\">");
Expand Down Expand Up @@ -130,13 +130,13 @@

int_check($receiver,true);

$res = sql_query("SELECT * FROM users WHERE id=" . sqlesc($receiver)) or die(mysql_error());
$res = sql_query("SELECT * FROM users WHERE id=" . sqlesc($receiver));
$user = mysql_fetch_assoc($res);

if (!$user)
stderr($lang_staffbox['std_error'], $lang_staffbox['std_no_user_id']);

$res2 = sql_query("SELECT * FROM staffmessages WHERE id=" . sqlesc($answeringto)) or die(mysql_error());
$res2 = sql_query("SELECT * FROM staffmessages WHERE id=" . sqlesc($answeringto));
$staffmsg = mysql_fetch_assoc($res2);
stdhead($lang_staffbox['head_answer_to_staff_pm']);
begin_main_frame();
Expand Down
12 changes: 6 additions & 6 deletions public/takeinvite.php
Expand Up @@ -33,15 +33,15 @@ function bark($msg) {


// check if email addy is already in use
$a = (@mysql_fetch_row(@sql_query("select count(*) from users where email=".sqlesc($email)))) or die(mysql_error());
$a = (@mysql_fetch_row(@sql_query("select count(*) from users where email=".sqlesc($email))));
if ($a[0] != 0)
bark($lang_takeinvite['std_email_address'].htmlspecialchars($email).$lang_takeinvite['std_is_in_use']);
$b = (@mysql_fetch_row(@sql_query("select count(*) from invites where invitee=".sqlesc($email)))) or die(mysql_error());
$b = (@mysql_fetch_row(@sql_query("select count(*) from invites where invitee=".sqlesc($email))));
if ($b[0] != 0)
bark($lang_takeinvite['std_invitation_already_sent_to'].htmlspecialchars($email).$lang_takeinvite['std_await_user_registeration']);

$ret = sql_query("SELECT username FROM users WHERE id = ".sqlesc($id)) or sqlerr();
$arr = mysql_fetch_assoc($ret);
$arr = mysql_fetch_assoc($ret);

$hash = md5(mt_rand(1,10000).$CURUSER['username'].TIMENOW.$CURUSER['passhash']);

Expand All @@ -63,7 +63,7 @@ function bark($msg) {
//this email is sent only when someone give out an invitation

header("Refresh: 0; url=invite.php?id=".htmlspecialchars($id)."&sent=1");
?>
?>



2 changes: 1 addition & 1 deletion public/torrentrss.php
Expand Up @@ -105,7 +105,7 @@ function get_where($tablename = "sources", $itemname = "source", $getname = "sou
if ($where)
$where = "WHERE ".$where;
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY torrents.added DESC LIMIT $limit";
$res = sql_query($query) or die(mysql_error());
$res = sql_query($query);
$torrentRep = new \App\Repositories\TorrentRepository();
$url = get_protocol_prefix().$BASEURL;
$year = substr($datefounded, 0, 4);
Expand Down
4 changes: 2 additions & 2 deletions public/torrents.php
Expand Up @@ -834,7 +834,7 @@
$sql = "SELECT COUNT(*), categories.mode FROM torrents LEFT JOIN categories ON category = categories.id " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $where." GROUP BY categories.mode";
}

$res = sql_query($sql) or die(mysql_error());
$res = sql_query($sql);
$count = 0;
while($row = mysql_fetch_array($res))
$count += $row[0];
Expand Down Expand Up @@ -877,7 +877,7 @@
$query = "SELECT torrents.id, torrents.sp_state, torrents.promotion_time_type, torrents.promotion_until, torrents.banned, torrents.picktype, torrents.pos_state, torrents.category, torrents.source, torrents.medium, torrents.codec, torrents.standard, torrents.processing, torrents.team, torrents.audiocodec, torrents.leechers, torrents.seeders, torrents.name, torrents.small_descr, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.anonymous,torrents.owner,torrents.url,torrents.cache_stamp,torrents.pt_gen,tags FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $where $orderby $limit";
}

$res = sql_query($query) or die(mysql_error());
$res = sql_query($query);
}
else
unset($res);
Expand Down

0 comments on commit 7727ffc

Please sign in to comment.