diff --git a/admanage.php b/admanage.php index 7e8aa010..fe05af69 100644 --- a/admanage.php +++ b/admanage.php @@ -190,7 +190,7 @@ tr($lang_admanage['row_flash_height']."*", "\"ad\""; break; case 'flash': - $_POST['ad']['flash']['width'] = 0+$_POST['ad']['flash']['width']; - $_POST['ad']['flash']['height'] = 0+$_POST['ad']['flash']['height']; + $_POST['ad']['flash']['width'] = $_POST['ad']['flash']['width'] ?? 0; + $_POST['ad']['flash']['height'] = $_POST['ad']['flash']['height'] ?? 0; if (!$_POST['ad']['flash']['url'] || !$_POST['ad']['flash']['width'] || !$_POST['ad']['flash']['height']) stderr($lang_admanage['std_error'], $lang_admanage['std_missing_form_data']); $parameters = serialize($_POST['ad']['flash']); diff --git a/adredir.php b/adredir.php index c4e89e02..496502ba 100644 --- a/adredir.php +++ b/adredir.php @@ -4,7 +4,7 @@ dbconn(); require_once(get_langfile_path()); if ($enablead_advertisement != 'yes') stderr($lang_adredir['std_error'], $lang_adredir['std_ad_system_disabled']); -$id=0+$_GET['id']; +$id=$_GET['id'] ?? 0; if (!$id) stderr($lang_adredir['std_error'], $lang_adredir['std_invalid_ad_id']); $redir=htmlspecialchars_decode(urldecode($_GET['url'])); diff --git a/announce.php b/announce.php index ccabe477..686d725e 100644 --- a/announce.php +++ b/announce.php @@ -57,7 +57,7 @@ if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){ $Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950); } if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL"); -$userid = 0+$az['id']; +$userid = $az['id'] ?? 0; //3. CHECK IF CLIENT IS ALLOWED $clicheck_res = check_client($peer_id,$agent,$client_familyid); diff --git a/bookmark.php b/bookmark.php index 2f5ad805..528166f5 100644 --- a/bookmark.php +++ b/bookmark.php @@ -9,7 +9,7 @@ header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-Type: text/xml; charset=utf-8"); -$torrentid = 0 + $_GET['torrentid']; +$torrentid = $_GET['torrentid'] ?? 0; if(isset($CURUSER)) { $res_bookmark = sql_query("SELECT * FROM bookmarks WHERE torrentid=" . sqlesc($torrentid) . " AND userid=" . sqlesc($CURUSER[id])); diff --git a/catmanage.php b/catmanage.php index a0e31dc9..f387b3fb 100644 --- a/catmanage.php +++ b/catmanage.php @@ -575,7 +575,7 @@ print($pagerbottom); } elseif($action == 'del') { - $id = 0 + $_GET['id']; + $id = $_GET['id'] ?? 0; if (!$id) { stderr($lang_catmanage['std_error'], $lang_catmanage['std_invalid_id']); @@ -602,7 +602,7 @@ elseif($action == 'del') } elseif($action == 'edit') { - $id = 0 + $_GET['id']; + $id = $_GET['id'] ?? 0; if (!$id) { stderr($lang_catmanage['std_error'], $lang_catmanage['std_invalid_id']); @@ -640,7 +640,7 @@ elseif($action == 'submit') { $dbtablename=return_category_db_table_name($type); if ($_POST['isedit']){ - $id = 0 + $_POST['id']; + $id = $_POST['id'] ?? 0; if (!$id) { stderr($lang_catmanage['std_error'], $lang_catmanage['std_invalid_id']); @@ -658,23 +658,23 @@ elseif($action == 'submit') if (!$name) stderr($lang_catmanage['std_error'], $lang_catmanage['std_missing_form_data']); $updateset[] = "name=".sqlesc($name); - $sort_index = 0+$_POST['sort_index']; + $sort_index = $_POST['sort_index'] ?? 0; $updateset[] = "sort_index=".sqlesc($sort_index); $Cache->delete_value($dbtablename.'_list'); } elseif ($type=='searchbox'){ $name = $_POST['name']; - $catsperrow = 0+$_POST['catsperrow']; - $catpadding = 0+$_POST['catpadding']; + $catsperrow = $_POST['catsperrow'] ?? 0; + $catpadding = $_POST['catpadding'] ?? 0; if (!$name || !$catsperrow || !$catpadding) stderr($lang_catmanage['std_error'], $lang_catmanage['std_missing_form_data']); - $showsource = 0+$_POST['showsource']; - $showmedium = 0+$_POST['showmedium']; - $showcodec = 0+$_POST['showcodec']; - $showstandard = 0+$_POST['showstandard']; - $showprocessing = 0+$_POST['showprocessing']; - $showteam = 0+$_POST['showteam']; - $showaudiocodec = 0+$_POST['showaudiocodec']; + $showsource = $_POST['showsource'] ?? 0; + $showmedium = $_POST['showmedium'] ?? 0; + $showcodec = $_POST['showcodec'] ?? 0; + $showstandard = $_POST['showstandard'] ?? 0; + $showprocessing = $_POST['showprocessing'] ?? 0; + $showteam = $_POST['showteam'] ?? 0; + $showaudiocodec = $_POST['showaudiocodec']; $updateset[] = "catsperrow=".sqlesc($catsperrow); $updateset[] = "catpadding=".sqlesc($catpadding); $updateset[] = "name=".sqlesc($name); @@ -720,13 +720,13 @@ elseif($action == 'submit') $name = $_POST['name']; $image = trim($_POST['image']); $class_name = trim($_POST['class_name']); - $source = 0+$_POST['source']; - $medium = 0+$_POST['medium']; - $codec = 0+$_POST['codec']; - $standard = 0+$_POST['standard']; - $processing = 0+$_POST['processing']; - $team = 0+$_POST['team']; - $audiocodec = 0+$_POST['audiocodec']; + $source = $_POST['source'] ?? 0; + $medium = $_POST['medium'] ?? 0; + $codec = $_POST['codec'] ?? 0; + $standard = $_POST['standard'] ?? 0; + $processing = $_POST['processing'] ?? 0; + $team = $_POST['team'] ?? 0; + $audiocodec = $_POST['audiocodec'] ?? 0; if (!$name || !$image) stderr($lang_catmanage['std_error'], $lang_catmanage['std_missing_form_data']); if (!valid_file_name($image)) @@ -756,9 +756,9 @@ elseif($action == 'submit') elseif ($type=='category'){ $name = $_POST['name']; $image = trim($_POST['image']); - $mode = 0+$_POST['mode']; + $mode = $_POST['mode'] ?? 0; $class_name = trim($_POST['class_name']); - $sort_index = 0+$_POST['sort_index']; + $sort_index = $_POST['sort_index'] ?? 0; if (!$name || !$image) stderr($lang_catmanage['std_error'], $lang_catmanage['std_missing_form_data']); if (!valid_file_name($image)) diff --git a/checkuser.php b/checkuser.php index b430dfdc..0c79bad7 100644 --- a/checkuser.php +++ b/checkuser.php @@ -4,7 +4,7 @@ dbconn(); require_once(get_langfile_path()); loggedinorreturn(); parked(); -$id = 0 + $_GET["id"]; +$id = $_GET["id"] ?? 0; int_check($id,true); function bark($msg) { diff --git a/comment.php b/comment.php index 7622b14e..3f2ae143 100644 --- a/comment.php +++ b/comment.php @@ -5,7 +5,7 @@ require_once(get_langfile_path()); require(get_langfile_path("",true)); $action = htmlspecialchars($_GET["action"]); -$sub = htmlspecialchars($_GET["sub"]); +$sub = htmlspecialchars($_GET["sub"] ?? ''); $type = htmlspecialchars($_GET["type"]); loggedinorreturn(); diff --git a/delete.php b/delete.php index 687d4fb8..d313ca3b 100644 --- a/delete.php +++ b/delete.php @@ -16,7 +16,7 @@ function bark($msg) { if (!mkglobal("id")) bark($lang_delete['std_missing_form_date']); -$id = 0 + $id; +$id = $id ?? 0; if (!$id) die(); @@ -28,7 +28,7 @@ if (!$row) if ($CURUSER["id"] != $row["owner"] && get_user_class() < $torrentmanage_class) bark($lang_delete['std_not_owner']); -$rt = 0 + $_POST["reasontype"]; +$rt = $_POST["reasontype"] ?? 0; if (!is_int($rt) || $rt < 1 || $rt > 5) bark($lang_delete['std_invalid_reason']."$rt."); diff --git a/details.php b/details.php index a0ca6ce9..4cedf783 100644 --- a/details.php +++ b/details.php @@ -26,26 +26,26 @@ if (!$row) elseif ($row['banned'] == 'yes' && get_user_class() < $seebanned_class) permissiondenied(); else { - if ($_GET["hit"]) { + if (!empty($_GET["hit"])) { sql_query("UPDATE torrents SET views = views + 1 WHERE id = $id"); } if (!isset($_GET["cmtpage"])) { stdhead($lang_details['head_details_for_torrent']. "\"" . $row["name"] . "\""); - if ($_GET["uploaded"]) + if (!empty($_GET["uploaded"])) { print("

".$lang_details['text_successfully_uploaded']."

"); print("

".$lang_details['text_redownload_torrent_note']."

"); header("refresh: 1; url=download.php?id=$id"); //header("refresh: 1; url=getimdb.php?id=$id&type=1"); } - elseif ($_GET["edited"]) { + elseif (!empty($_GET["edited"])) { print("

".$lang_details['text_successfully_edited']."

"); if (isset($_GET["returnto"])) print("

".$lang_details['text_go_back'] . "" . $lang_details['text_whence_you_came']."

"); } - $sp_torrent = get_torrent_promotion_append($row[sp_state],'word'); + $sp_torrent = get_torrent_promotion_append($row['sp_state'],'word'); $s=htmlspecialchars($row["name"]).($sp_torrent ? "   ".$sp_torrent : ""); print("

".$s."

\n"); @@ -86,27 +86,28 @@ else { $size_info = "".$lang_details['text_size']."" . mksize($row["size"]); $type_info = "   ".$lang_details['row_type'].": ".$row["cat_name"]; + $source_info = $medium_info = $codec_info = $audiocodec_info = $standard_info = $processing_info = $team_info = ''; if (isset($row["source_name"])) - $source_info = "   ".$lang_details['text_source']." ".$row[source_name]; + $source_info = "   ".$lang_details['text_source']." ".$row['source_name']; if (isset($row["medium_name"])) - $medium_info = "   ".$lang_details['text_medium']." ".$row[medium_name]; + $medium_info = "   ".$lang_details['text_medium']." ".$row['medium_name']; if (isset($row["codec_name"])) - $codec_info = "   ".$lang_details['text_codec']." ".$row[codec_name]; + $codec_info = "   ".$lang_details['text_codec']." ".$row['codec_name']; if (isset($row["standard_name"])) - $standard_info = "   ".$lang_details['text_stardard']." ".$row[standard_name]; + $standard_info = "   ".$lang_details['text_stardard']." ".$row['standard_name']; if (isset($row["processing_name"])) - $processing_info = "   ".$lang_details['text_processing']." ".$row[processing_name]; + $processing_info = "   ".$lang_details['text_processing']." ".$row['processing_name']; if (isset($row["team_name"])) - $team_info = "   ".$lang_details['text_team']." ".$row[team_name]; + $team_info = "   ".$lang_details['text_team']." ".$row['team_name']; if (isset($row["audiocodec_name"])) - $audiocodec_info = "   ".$lang_details['text_audio_codec']." ".$row[audiocodec_name]; + $audiocodec_info = "   ".$lang_details['text_audio_codec']." ".$row['audiocodec_name']; tr($lang_details['row_basic_info'], $size_info.$type_info.$source_info . $medium_info. $codec_info . $audiocodec_info. $standard_info . $processing_info . $team_info, 1); if ($CURUSER["downloadpos"] != "no") $download = "\"download\" ".$lang_details['text_download_torrent']." | "; else $download = ""; - tr($lang_details['row_action'], $download. ($owned == 1 ? "<$editlink>\"edit\" ".$lang_details['text_edit_torrent'] . " | " : ""). (get_user_class() >= $askreseed_class && $row[seeders] == 0 ? "\"reseed\" ".$lang_details['text_ask_for_reseed'] ." | " : "") . "\"report\" ".$lang_details['text_report_torrent']."", 1); + tr($lang_details['row_action'], $download. ($owned == 1 ? "<$editlink>\"edit\" ".$lang_details['text_edit_torrent'] . " | " : ""). (get_user_class() >= $askreseed_class && $row['seeders'] == 0 ? "\"reseed\" ".$lang_details['text_ask_for_reseed'] ." | " : "") . "\"report\" ".$lang_details['text_report_torrent']."", 1); // ---------------- start subtitle block -------------------// $r = sql_query("SELECT subs.*, language.flagpic, language.lang_name FROM subs LEFT JOIN language ON subs.lang_id=language.id WHERE torrent_id = " . sqlesc($row["id"]). " ORDER BY subs.lang_id ASC") or sqlerr(__FILE__, __LINE__); @@ -154,7 +155,7 @@ else { if ($CURUSER['showdescription'] != 'no' && !empty($row["descr"])){ $torrentdetailad=$Advertisement->get_ad('torrentdetail'); - tr("\"Show/Hide\" ".$lang_details['row_description']."", "
".($Advertisement->enable_ad() && $torrentdetailad ? "
".$torrentdetailad[0]."
" : "").format_comment($row["descr"])."
", 1); + tr("\"Show/Hide\" ".$lang_details['row_description']."", "
".($Advertisement->enable_ad() && $torrentdetailad ? "
".$torrentdetailad[0]."
" : "").format_comment($row["descr"])."
", 1); } if (get_user_class() >= $viewnfo_class && $CURUSER['shownfo'] != 'no' && $row["nfosz"] > 0){ @@ -162,7 +163,7 @@ else { $nfo = code($row["nfo"], $view == "magic"); $Cache->cache_value('nfo_block_torrent_id_'.$id, $nfo, 604800); } - tr("\"Show/Hide\" ".$lang_details['text_nfo']."
". $lang_details['text_view_nfo']. "", "
".$nfo."
\n", 1); + tr("\"Show/Hide\" ".$lang_details['text_nfo']."
". $lang_details['text_view_nfo']. "", "
".$nfo."
\n", 1); } if ($imdb_id && $showextinfo['imdb'] == 'yes' && $CURUSER['showimdb'] != 'no') @@ -345,7 +346,7 @@ else { $Cache->add_whole_row(); print(""); - print("\"Show/Hide\" ".$lang_details['text_imdb'] . $lang_details['row_info'] ."
". $smallth."
"); + print("\"Show/Hide\" ".$lang_details['text_imdb'] . $lang_details['row_info'] ."
". $smallth."
"); $Cache->end_whole_row(); $Cache->add_row(); $Cache->add_part(); @@ -410,15 +411,15 @@ else { } if (isset($copy_row["source_name"])) - $other_source_info = $copy_row[source_name].", "; + $other_source_info = $copy_row['source_name'].", "; if (isset($copy_row["medium_name"])) - $other_medium_info = $copy_row[medium_name].", "; + $other_medium_info = $copy_row['medium_name'].", "; if (isset($copy_row["codec_name"])) - $other_codec_info = $copy_row[codec_name].", "; + $other_codec_info = $copy_row['codec_name'].", "; if (isset($copy_row["standard_name"])) - $other_standard_info = $copy_row[standard_name].", "; + $other_standard_info = $copy_row['standard_name'].", "; if (isset($copy_row["processing_name"])) - $other_processing_info = $copy_row[processing_name].", "; + $other_processing_info = $copy_row['processing_name'].", "; $sphighlight = get_torrent_bg_color($copy_row['sp_state']); $sp_info = get_torrent_promotion_append($copy_row['sp_state']); @@ -432,7 +433,7 @@ else { "\n"; } $s .= "\n"; - tr(" 5 ? "plus" : "minus")."\" src=\"pic/trans.gif\" alt=\"Show/Hide\" id=\"picothercopy\" title=\"".$lang_detail['title_show_or_hide']."\" /> ".$lang_details['row_other_copies']."", "".$copies_count.$lang_details['text_other_copies']."
5 ? "display: none;" : "display: block;")."\">".$s."
",1); + tr(" 5 ? "plus" : "minus")."\" src=\"pic/trans.gif\" alt=\"Show/Hide\" id=\"picothercopy\" title=\"".$lang_details['title_show_or_hide']."\" /> ".$lang_details['row_other_copies']."", "".$copies_count.$lang_details['text_other_copies']."
5 ? "display: none;" : "display: block;")."\">".$s."
",1); } } @@ -505,7 +506,7 @@ else { tr($lang_details['row_health'], $health, 1);*/ tr("".$lang_details['row_peers']."
".$lang_details['text_see_full_list']."".$lang_details['text_hide_list']."", "
".$row['seeders'].$lang_details['text_seeders'].add_s($row['seeders'])." | ".$row['leechers'].$lang_details['text_leechers'].add_s($row['leechers'])."
" , 1); - if ($_GET['dllist'] == 1) + if (isset($_GET['dllist']) && $_GET['dllist'] == 1) { $scronload = "viewpeerlist(".$row['id'].")"; @@ -562,7 +563,7 @@ if ($CURUSER['showcomment'] != 'no'){ { print("

"); print("

" .$lang_details['h1_user_comments'] . "

\n"); - list($pagertop, $pagerbottom, $limit) = pager(10, $count, "details.php?id=$id&cmtpage=1&", array(lastpagedefault => 1), "page"); + list($pagertop, $pagerbottom, $limit) = pager(10, $count, "details.php?id=$id&cmtpage=1&", array('lastpagedefault' => 1), "page"); $subres = sql_query("SELECT id, text, user, added, editedby, editdate FROM comments WHERE torrent = $id ORDER BY id $limit") or sqlerr(__FILE__, __LINE__); $allrows = array(); diff --git a/download.php b/download.php index 59d5b21e..992e6c4d 100644 --- a/download.php +++ b/download.php @@ -4,7 +4,7 @@ dbconn(); $id = (int)$_GET["id"]; if (!$id) httperr(); -$passkey = $_GET['passkey']; +$passkey = $_GET['passkey'] ?? ''; if ($passkey){ $res = sql_query("SELECT * FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); $user = mysql_fetch_array($res); @@ -20,7 +20,7 @@ else { loggedinorreturn(); parked(); - $letdown = $_GET['letdown']; + $letdown = $_GET['letdown'] ?? 0; if (!$letdown && $CURUSER['showdlnotice'] == 1) { header("Location: " . get_protocol_prefix() . "$BASEURL/downloadnotice.php?torrentid=".$id."&type=firsttime"); diff --git a/downloadnotice.php b/downloadnotice.php index 7a08a82c..25ae721e 100644 --- a/downloadnotice.php +++ b/downloadnotice.php @@ -5,7 +5,7 @@ require_once(get_langfile_path()); loggedinorreturn(); if ($_SERVER["REQUEST_METHOD"] == "POST") { - $torrentid = 0+$_POST['id']; + $torrentid = $_POST['id'] ?? 0; $type = $_POST['type']; $hidenotice = $_POST['hidenotice']; if (!$torrentid || !in_array($type,array('firsttime', 'client', 'ratio'))) diff --git a/downloadsubs.php b/downloadsubs.php index e001caee..d1e75966 100644 --- a/downloadsubs.php +++ b/downloadsubs.php @@ -13,8 +13,8 @@ $dirname = $_GET["torrentid"]; if (!$filename || !$dirname) die("File name missing\n"); -$filename = 0 + $filename; -$dirname = 0 + $dirname; +$filename = $filename ?? 0; +$dirname = $dirname ?? 0; $res = sql_query("SELECT * FROM subs WHERE id=$filename") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res); diff --git a/edit.php b/edit.php index b42446bb..b9fdf737 100644 --- a/edit.php +++ b/edit.php @@ -4,7 +4,7 @@ dbconn(); require_once(get_langfile_path()); loggedinorreturn(); -$id = 0 + $_GET['id']; +$id = $_GET['id'] ?? 0; if (!$id) die(); diff --git a/email-gateway.php b/email-gateway.php index 4abaaa20..10f13c1e 100644 --- a/email-gateway.php +++ b/email-gateway.php @@ -1,7 +1,7 @@ Question:\n"); print("Answer:\n"); print("Status:"); - print(""); - print(""); + print(""); + print(""); print("\n"); print(""); end_main_frame(); @@ -168,23 +168,23 @@ elseif ($_GET[action] == "addsection") { elseif ($_GET[action] == "addnewitem" && $_POST[question] != NULL && $_POST[answer] != NULL) { $question = $_POST[question]; $answer = $_POST[answer]; - $categ = 0+$_POST[categ]; - $langid = 0+$_POST[langid]; + $categ = $_POST[categ] ?? 0; + $langid = $_POST[langid] ?? 0; $res = sql_query("SELECT MAX(`order`) AS maxorder, MAX(`link_id`) AS maxlinkid FROM `faq` WHERE `type`='item' AND `categ`=".sqlesc($categ)." AND lang_id=".sqlesc($langid)); while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) { $order = $arr['maxorder'] + 1; $link_id = $arr['maxlinkid']+1; } - sql_query("INSERT INTO `faq` (`link_id`, `type`, `lang_id`, `question`, `answer`, `flag`, `categ`, `order`) VALUES ('$link_id', 'item', ".sqlesc($langid).", ".sqlesc($question).", ".sqlesc($answer).", " . sqlesc(0+$_POST[flag]) . ", ".sqlesc($categ).", ".sqlesc($order).")") or sqlerr(); + sql_query("INSERT INTO `faq` (`link_id`, `type`, `lang_id`, `question`, `answer`, `flag`, `categ`, `order`) VALUES ('$link_id', 'item', ".sqlesc($langid).", ".sqlesc($question).", ".sqlesc($answer).", " . sqlesc($_POST['flag'] ?? 0) . ", ".sqlesc($categ).", ".sqlesc($order).")") or sqlerr(); header("Location: " . get_protocol_prefix() . "$BASEURL/faqmanage.php"); die; } // subACTION: addnewsect - add a new section to the db -elseif ($_GET[action] == "addnewsect" && $_POST[title] != NULL && $_POST[flag] != NULL) { - $title = $_POST[title]; - $language = 0+$_POST['language']; +elseif ($_GET['action'] == "addnewsect" && $_POST['title'] != NULL && $_POST['flag'] != NULL) { + $title = $_POST['title']; + $language = $_POST['language'] ?? 0; $res = sql_query("SELECT MAX(`order`) AS maxorder, MAX(`link_id`) AS maxlinkid FROM `faq` WHERE `type`='categ' AND `lang_id` = ".sqlesc($language)); while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) {$order = $arr['maxorder'] + 1;$link_id = $arr['maxlinkid']+1;} sql_query("INSERT INTO `faq` (`link_id`,`type`,`lang_id`, `question`, `answer`, `flag`, `categ`, `order`) VALUES (".sqlesc($link_id).",'categ', ".sqlesc($language).", ".sqlesc($title).", '', ".sqlesc($_POST[flag]).", '0', ".sqlesc($order).")") or sqlerr(); diff --git a/forums.php b/forums.php index 62799d75..8c62098e 100644 --- a/forums.php +++ b/forums.php @@ -258,7 +258,7 @@ $action = htmlspecialchars(trim($_GET["action"] ?? '')); //-------- Action: New topic if ($action == "newtopic") { - $forumid = 0+$_GET["forumid"]; + $forumid = $_GET["forumid"] ?? 0; check_whether_exist($forumid, 'forum'); stdhead($lang_forums['head_new_topic']); begin_main_frame(); @@ -269,7 +269,7 @@ if ($action == "newtopic") } if ($action == "quotepost") { - $postid = 0+$_GET["postid"]; + $postid = $_GET["postid"] ?? 0; check_whether_exist($postid, 'post'); stdhead($lang_forums['head_post_reply']); begin_main_frame(); @@ -283,7 +283,7 @@ if ($action == "quotepost") if ($action == "reply") { - $topicid = 0+$_GET["topicid"]; + $topicid = $_GET["topicid"] ?? 0; check_whether_exist($topicid, 'topic'); stdhead($lang_forums['head_post_reply']); begin_main_frame(); @@ -297,7 +297,7 @@ if ($action == "reply") if ($action == "editpost") { - $postid = 0+$_GET["postid"]; + $postid = $_GET["postid"] ?? 0; check_whether_exist($postid, 'post'); $res = sql_query("SELECT userid, topicid FROM posts WHERE id=".sqlesc($postid)) or sqlerr(__FILE__, __LINE__); @@ -383,7 +383,7 @@ if ($action == "post") if ($body == "") stderr($lang_forums['std_error'], $lang_forums['std_no_body_text']); - $userid = 0+$CURUSER["id"]; + $userid = $CURUSER["id"] ?? 0; $date = date("Y-m-d H:i:s"); if ($type != 'new'){ @@ -829,9 +829,9 @@ if ($action == "viewtopic") if ($action == "movetopic") { - $forumid = 0+$_POST["forumid"]; + $forumid = $_POST["forumid"] ?? 0; - $topicid = 0+$_GET["topicid"]; + $topicid = $_GET["topicid"] ?? 0; $ismod = is_forum_moderator($topicid,'topic'); if (!is_valid_id($forumid) || !is_valid_id($topicid) || (get_user_class() < $postmanage_class && !$ismod)) permissiondenied(); @@ -885,7 +885,7 @@ if ($action == "movetopic") if ($action == "deletetopic") { - $topicid = 0+$_GET["topicid"]; + $topicid = $_GET["topicid"] ?? 0; $res1 = sql_query("SELECT forumid, userid FROM topics WHERE id=".sqlesc($topicid)." LIMIT 1") or sqlerr(__FILE__, __LINE__); $row1 = mysql_fetch_array($res1); if (!$row1){ @@ -899,7 +899,7 @@ if ($action == "deletetopic") if (!is_valid_id($topicid) || (get_user_class() < $postmanage_class && !$ismod)) permissiondenied(); - $sure = 0+$_GET["sure"]; + $sure = $_GET["sure"] ?? 0; if (!$sure) { stderr($lang_forums['std_delete_topic'], $lang_forums['std_delete_topic_note'] . @@ -929,8 +929,8 @@ if ($action == "deletetopic") if ($action == "deletepost") { - $postid = 0+$_GET["postid"]; - $sure = 0+$_GET["sure"]; + $postid = $_GET["postid"] ?? 0; + $sure = $_GET["sure"] ?? 0; $ismod = is_forum_moderator($postid, 'post'); if ((get_user_class() < $postmanage_class && !$ismod) || !is_valid_id($postid)) @@ -1038,9 +1038,9 @@ if ($action == "setsticky") if ($action == "viewforum") { - $forumid = 0+$_GET["forumid"]; + $forumid = $_GET["forumid"] ?? 0; int_check($forumid,true); - $userid = 0+$CURUSER["id"]; + $userid = $CURUSER["id"] ?? 0; //------ Get forum name, moderators $row = get_forum_row($forumid); if (!$row){ diff --git a/fun.php b/fun.php index 4ce194c5..16d80a5d 100644 --- a/fun.php +++ b/fun.php @@ -12,7 +12,7 @@ if (!$action) } if ($action == 'delete') { - $id = 0+$_GET["id"]; + $id = $_GET["id"] ?? 0; int_check($id,true); $res = sql_query("SELECT userid FROM fun WHERE id=$id") or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_array($res); @@ -20,7 +20,7 @@ if ($action == 'delete') stderr($lang_fun['std_error'], $lang_fun['std_invalid_id']); if (get_user_class() < $funmanage_class) permissiondenied(); - $sure = 0+$_GET["sure"]; + $sure = $_GET["sure"] ?? 0; $returnto = $_GET["returnto"] ? htmlspecialchars($_GET["returnto"]) : htmlspecialchars($_SERVER["HTTP_REFERER"]); if (!$sure) stderr($lang_fun['std_delete_fun'],$lang_fun['text_please_click'] ."".$lang_fun['text_here_if_sure'],false); @@ -123,7 +123,7 @@ if ($row){ print(""); } if ($action == 'edit'){ - $id = 0+$_GET["id"]; + $id = $_GET["id"] ?? 0; int_check($id,true); $res = sql_query("SELECT * FROM fun WHERE id=$id") or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_array($res); @@ -165,7 +165,7 @@ if ($action == 'ban') { if (get_user_class() < $funmanage_class) permissiondenied(); - $id = 0+$_GET["id"]; + $id = $_GET["id"] ?? 0; int_check($id,true); $res = sql_query("SELECT * FROM fun WHERE id=$id") or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_array($res); @@ -210,7 +210,7 @@ function funreward($funvote, $totalvote, $title, $posterid, $bonus) if ($action == 'vote') { - $id = 0+$_GET["id"]; + $id = $_GET["id"] ?? 0; int_check($id,true); $res = sql_query("SELECT * FROM fun WHERE id=$id") or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_array($res); diff --git a/getrss.php b/getrss.php index 5539796e..51a20fa8 100644 --- a/getrss.php +++ b/getrss.php @@ -141,8 +141,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $query[] = "iuplder=1"; } $searchstr = mysql_real_escape_string(trim($_POST["search"] ?? '')); - if (empty($searchstr)) - unset($searchstr); +// if (empty($searchstr)) +// unset($searchstr); if ($searchstr) { $query[] = "search=".rawurlencode($searchstr); diff --git a/getusertorrentlistajax.php b/getusertorrentlistajax.php index 5466f35d..b021a0b9 100644 --- a/getusertorrentlistajax.php +++ b/getusertorrentlistajax.php @@ -161,7 +161,7 @@ function maketable($res, $mode = 'seeding') return $ret; } -$id = 0+$_GET['userid']; +$id = $_GET['userid'] ?? 0; $type = $_GET['type']; if (!in_array($type,array('uploaded','seeding','leeching','completed','incomplete'))) die; diff --git a/include/cleanup.php b/include/cleanup.php index 2df6510b..1c88fdad 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -53,9 +53,9 @@ function docleanup($forceAll = 0, $printProgress = false) { $torrentres = sql_query("select torrents.added, torrents.size, torrents.seeders from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $arr[userid] AND peers.seeder ='yes'") or sqlerr(__FILE__, __LINE__); while ($torrent = mysql_fetch_array($torrentres)) { - $weeks_alive = ($timenow - strtotime($torrent[added])) / $sectoweek; - $gb_size = $torrent[size] / 1073741824; - $temp = (1 - exp($valueone * $weeks_alive)) * $gb_size * (1 + $sqrtof2 * exp($valuethree * ($torrent[seeders] - 1))); + $weeks_alive = ($timenow - strtotime($torrent['added'])) / $sectoweek; + $gb_size = $torrent['size'] / 1073741824; + $temp = (1 - exp($valueone * $weeks_alive)) * $gb_size * (1 + $sqrtof2 * exp($valuethree * ($torrent['seeders'] - 1))); $A += $temp; $count++; } diff --git a/include/config.php b/include/config.php index 176f9f34..eb560916 100644 --- a/include/config.php +++ b/include/config.php @@ -297,8 +297,8 @@ $oneinvite_bonus = $BONUS['oneinvite']; $customtitle_bonus = $BONUS['customtitle']; $vipstatus_bonus = $BONUS['vipstatus']; $bonusgift_bonus = $BONUS['bonusgift']; -$basictax_bonus = 0+$BONUS['basictax']; -$taxpercentage_bonus = 0+$BONUS['taxpercentage']; +$basictax_bonus = $BONUS['basictax']; +$taxpercentage_bonus = $BONUS['taxpercentage']; $prolinkpoint_bonus = $BONUS['prolinkpoint']; $prolinktime_bonus = $BONUS['prolinktime']; @@ -395,7 +395,7 @@ $SUBSPATH = "subs"; //Make sure you have wget installed on your OS //replace "http://www.nexusphp.com/" with your own site address -$useCronTriggerCleanUp = false; +$useCronTriggerCleanUp = $MAIN['use_cron_trigger_cleanup']; //some promotion rules //$promotionrules_torrent = array(0 => array("mediumid" => array(1), "promotion" => 5), 1 => array("mediumid" => array(3), "promotion" => 5), 2 => array("catid" => array(402), "standardid" => array(3), "promotion" => 4), 3 => array("catid" => array(403), "standardid" => array(3), "promotion" => 4)); $promotionrules_torrent = array(); diff --git a/include/functions.php b/include/functions.php index 6f0d1ccc..fab0f10d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1037,7 +1037,7 @@ function insert_suggest($keyword, $userid, $pre_escaped = true) { if(mb_strlen($keyword,"UTF-8") >= 2) { - $userid = 0 + $userid; + $userid = $userid ?? 0; if($userid) sql_query("INSERT INTO suggest(keywords, userid, adddate) VALUES (" . ($pre_escaped == true ? "'" . $keyword . "'" : sqlesc($keyword)) . "," . sqlesc($userid) . ", NOW())") or sqlerr(__FILE__,__LINE__); } @@ -1053,7 +1053,7 @@ function get_external_tr($imdb_url = "") function get_torrent_extinfo_identifier($torrentid) { - $torrentid = 0 + $torrentid; + $torrentid = $torrentid ?? 0; $result = array('imdb_id'); unset($result); @@ -1796,7 +1796,7 @@ function userlogin() { //return; } $b_id = base64($_COOKIE["c_secure_uid"],false); - $id = 0 + $b_id; + $id = $b_id ?? 0; if (!$id || !is_valid_id($id) || strlen($_COOKIE["c_secure_pass"]) != 32) return; @@ -2036,7 +2036,7 @@ function validemail($email) { function validlang($langid) { global $deflang; - $langid = 0 + $langid; + $langid = $langid ?? 0; $res = sql_query("SELECT * FROM language WHERE site_lang = 1 AND id = " . sqlesc($langid)) or sqlerr(__FILE__, __LINE__); if(mysql_num_rows($res) == 1) { @@ -2474,13 +2474,13 @@ if ($msgalert) /* $pending_invitee = $Cache->get_value('user_'.$CURUSER["id"].'_pending_invitee_count'); if ($pending_invitee == ""){ - $pending_invitee = get_row_count("users","WHERE status = 'pending' AND invited_by = ".sqlesc($CURUSER[id])); + $pending_invitee = get_row_count("users","WHERE status = 'pending' AND invited_by = ".sqlesc($CURUSER['id'])); $Cache->cache_value('user_'.$CURUSER["id"].'_pending_invitee_count', $pending_invitee, 900); } if ($pending_invitee > 0) { $text = $lang_functions['text_your_friends'].add_s($pending_invitee).is_or_are($pending_invitee).$lang_functions['text_awaiting_confirmation']; - msgalert("invite.php?id=".$CURUSER[id],$text, "red"); + msgalert("invite.php?id=".$CURUSER['id'],$text, "red"); }*/ $settings_script_name = $_SERVER["SCRIPT_FILENAME"]; if (!preg_match("/index/i", $settings_script_name)) @@ -2557,21 +2557,21 @@ function stdfoot() { $year = substr($datefounded, 0, 4); $yearfounded = ($year ? $year : 2007); print(" (c) "." ".$SITENAME." ".($icplicense_main ? " ".$icplicense_main." " : "").(date("Y") != $yearfounded ? $yearfounded."-" : "").date("Y")." ".VERSION."

"); - printf ("[page created in %f sec", $totaltime); - print (" with ".count($query_name)." db queries, ".$Cache->getCacheReadTimes()." reads and ".$Cache->getCacheWriteTimes()." writes of memcached and ".mksize(memory_get_usage())." ram]"); + printf ("[page created in %s ms", sprintf("%.1f", $totaltime * 1000)); + print (" with ".count($query_name)." db queries, ".$Cache->getCacheReadTimes()." reads and ".$Cache->getCacheWriteTimes()." writes of Redis and ".mksize(memory_get_usage())." ram]"); print ("\n"); if ($enablesqldebug_tweak == 'yes' && get_user_class() >= $sqldebug_tweak) { print("
SQL query list: "); - print("Memcached key read:
"); $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars(trim($userRow["avatar"])) : ""); if (!$avatar) $avatar = "pic/default_avatar.png"; @@ -2842,8 +2842,8 @@ function commenttable($rows, $type, $parent_id, $review = false) print("".return_avatar_image($avatar)."\n"); print("
".$text.$text_editby."\n"); print("\n"); - $actionbar = "\"Quote\"". - "\"Add".(get_user_class() >= $commanage_class ? "\"Delete\"" : "").($row["user"] == $CURUSER["id"] || get_user_class() >= $commanage_class ? "\"Edit\""."" : ""); + $actionbar = "\"Quote\"". + "\"Add".(get_user_class() >= $commanage_class ? "\"Delete\"" : "").($row["user"] == $CURUSER["id"] || get_user_class() >= $commanage_class ? "\"Edit\""."" : ""); print(" ".("'".$userRow['last_access']."'"> $dt ? "\"Online\"":"\"Offline\"" )."\"PM\"\"Report\"".$actionbar.""); print("\n"); @@ -2933,8 +2933,8 @@ function return_torrent_bookmark_array($userid) function get_torrent_bookmark_state($userid, $torrentid, $text = false) { global $lang_functions; - $userid = 0 + $userid; - $torrentid = 0 + $torrentid; + $userid = $userid ?? 0; + $torrentid = $torrentid ?? 0; $ret = array(); $ret = return_torrent_bookmark_array($userid); if (!count($ret) || !in_array($torrentid, $ret, false)) // already bookmarked @@ -2969,7 +2969,7 @@ function torrenttable($res, $variant = "torrent") { if ($last_browse > $time_now) { $last_browse=$time_now; } - + $wait = 0; if (get_user_class() < UC_VIP && $waitsystem == "yes") { $ratio = get_ratio($CURUSER["id"], false); $gigs = $CURUSER["uploaded"] / (1024*1024*1024); @@ -3006,7 +3006,7 @@ foreach ($_GET as $get_name => $get_value) { if ($count_get > 0) { $oldlink = $oldlink . "&"; } -$sort = $_GET['sort']; +$sort = $_GET['sort'] ?? ''; $link = array(); for ($i=1; $i<=9; $i++){ if ($sort == $i) @@ -3180,6 +3180,8 @@ while ($row = mysql_fetch_assoc($res)) //comments $nl = "
"; + $lastcom_tooltip = []; + $torrent_tooltip = []; if (!$row["comments"]) { print("" . $row["comments"] . ""); } else { @@ -3236,7 +3238,7 @@ while ($row = mysql_fetch_assoc($res)) print("0\n"); if ($row["times_completed"] >=1) - print("" . number_format($row["times_completed"]) . "\n"); + print("" . number_format($row["times_completed"]) . "\n"); else print("" . number_format($row["times_completed"]) . "\n"); @@ -3255,7 +3257,7 @@ while ($row = mysql_fetch_assoc($res)) if (get_user_class() >= $torrentmanage_class) { - print("\"D\""); + print("\"D\""); print("
\"E\"\n"); } print("\n"); @@ -3274,7 +3276,7 @@ function get_username($id, $big = false, $link = true, $bold = true, $target = f { static $usernameArray = array(); global $lang_functions; - $id = 0+$id; + $id = (int)$id; if (func_num_args() == 1 && isset($usernameArray[$id])) { //One argument=is default display of username. Get it directly from static array if available return $usernameArray[$id]; diff --git a/include/functions_announce.php b/include/functions_announce.php index b4d9491e..8df4e70e 100644 --- a/include/functions_announce.php +++ b/include/functions_announce.php @@ -198,8 +198,8 @@ function check_client($peer_id, $agent, &$agent_familyid) { if($row_allowed_ua['peer_id_matchtype'] == 'dec') { - $match_target[$i+1] = 0 + $match_target[$i+1]; - $match_bench[$i+1] = 0 + $match_bench[$i+1]; + $match_target[$i+1] = $match_target[$i+1] ?? 0; + $match_bench[$i+1] = $match_bench[$i+1] ?? 0; } else if($row_allowed_ua['peer_id_matchtype'] == 'hex') { @@ -248,8 +248,8 @@ function check_client($peer_id, $agent, &$agent_familyid) { if($row_allowed_ua['agent_matchtype'] == 'dec') { - $match_target[$i+1] = 0 + $match_target[$i+1]; - $match_bench[$i+1] = 0 + $match_bench[$i+1]; + $match_target[$i+1] = $match_target[$i+1] ?? 0; + $match_bench[$i+1] = $match_bench[$i+1] ?? 0; } else if($row_allowed_ua['agent_matchtype'] == 'hex') { diff --git a/include/globalfunctions.php b/include/globalfunctions.php index e9def680..84b4bfba 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -67,9 +67,14 @@ function getip() { function sql_query($query) { + $begin = getmicrotime(); global $query_name; - $query_name[] = $query; - return mysql_query($query); + $result = mysql_query($query); + $query_name[] = [ + 'query' => $query, + 'time' => sprintf('%.3f', getmicrotime() - $begin), + ]; + return $result; } function sqlesc($value) { diff --git a/index.php b/index.php index 572f817b..8bcf4b1e 100644 --- a/index.php +++ b/index.php @@ -269,8 +269,8 @@ if ($CURUSER && $showpolls_main == "yes") print(""); if ($pollexists) { - $pollid = 0+$arr["id"]; - $userid = 0+$CURUSER["id"]; + $pollid = $arr["id"] ?? 0; + $userid = $CURUSER["id"]; $question = $arr["question"]; $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"], $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"], diff --git a/iphistory.php b/iphistory.php index 1e9a30a1..18d96c2b 100644 --- a/iphistory.php +++ b/iphistory.php @@ -7,7 +7,7 @@ loggedinorreturn(); if (get_user_class() < $userprofile_class) permissiondenied(); -$userid = 0 + $_GET["id"]; +$userid = $_GET["id"] ?? 0; if (!is_valid_id($userid)) stderr($lang_iphistory['std_error'], $lang_iphistory['std_invalid_id']); diff --git a/lang/chs/lang_details.php b/lang/chs/lang_details.php index 9bf49643..7009dd13 100644 --- a/lang/chs/lang_details.php +++ b/lang/chs/lang_details.php @@ -84,7 +84,7 @@ $lang_details = array 'row_last_seeder' => "最近活动:", 'text_ago' => "以前", 'text_size' => "大小:", - 'text_none_yet' => "暂无(需要".$minvotes."票,现在只有", + 'text_none_yet' => "暂无(需要".$TORRENT['minvotes']."票,现在只有", 'text_only' => "票", 'text_none' => "无", 'text_no_votes_yet' => "暂无评分", diff --git a/lang/cht/lang_details.php b/lang/cht/lang_details.php index 3683c940..bee50289 100644 --- a/lang/cht/lang_details.php +++ b/lang/cht/lang_details.php @@ -84,7 +84,7 @@ $lang_details = array 'row_last_seeder' => "最近現行:", 'text_ago' => "以前", 'text_size' => "大小:", - 'text_none_yet' => "暫無(需要".$minvotes."票,現在只有", + 'text_none_yet' => "暫無(需要".$TORRENT['minvotes']."票,現在只有", 'text_only' => "票", 'text_none' => "無", 'text_no_votes_yet' => "暫無評分", diff --git a/lang/en/lang_details.php b/lang/en/lang_details.php index 610939b0..51611c25 100644 --- a/lang/en/lang_details.php +++ b/lang/en/lang_details.php @@ -84,7 +84,7 @@ $lang_details = array 'row_last_seeder' => "Last Action: ", 'text_ago' => " ago", 'text_size' => "Size: ", - 'text_none_yet' => "none yet (needs at least ".$minvotes." votes and has got ", + 'text_none_yet' => "none yet (needs at least ".$TORRENT['minvotes']." votes and has got ", 'text_only' => "only ", 'text_none' => "none", 'text_no_votes_yet' => "No votes yet", diff --git a/linksmanage.php b/linksmanage.php index 42ae4f2c..1c7e43bc 100644 --- a/linksmanage.php +++ b/linksmanage.php @@ -81,7 +81,7 @@ elseif (get_user_class() < $linkmanage_class) permissiondenied(); else{ if ($_GET['action'] == "del") { -$id = 0 + $_GET['id']; +$id = $_GET['id'] ?? 0; if (!$id) { header("Location: linksmanage.php"); die();} $result = sql_query ("SELECT * FROM links where id = '".$id."'"); if ($row = mysql_fetch_array($result)) @@ -148,7 +148,7 @@ echo "".$row["name"]."".$row["url"]."".$row["title"]. echo ""; ?> diff --git a/location.php b/location.php index 5bc7fe7e..714e12ae 100644 --- a/location.php +++ b/location.php @@ -32,7 +32,7 @@ if($delid > 0) { $edited = $_GET['edited']; if($edited == 1) { - $id = 0 + $_GET['id']; + $id = $_GET['id'] ?? 0; $name = $_GET['name']; $flagpic = $_GET['flagpic']; $location_main = $_GET['location_main']; @@ -65,7 +65,7 @@ if($edited == 1) { } -$editid = 0 + $_GET['editid']; +$editid = $_GET['editid'] ?? 0; if($editid > 0) { $query = "SELECT * FROM locations WHERE id=" . sqlesc($editid); diff --git a/log.php b/log.php index e25e693c..8ecee352 100644 --- a/log.php +++ b/log.php @@ -177,10 +177,10 @@ else { elseif (isset($_POST['do']) && $_POST['do'] == "add") sql_query ("INSERT INTO chronicle (userid,added, txt) VALUES ('".$CURUSER["id"]."', now(), ".sqlesc($txt).")") or sqlerr(__FILE__, __LINE__); elseif (isset($_POST['do'] ) && $_POST['do'] == "update"){ - $id = 0 + $_POST['id']; + $id = $_POST['id'] ?? 0; if (!$id) { header("Location: log.php?action=chronicle"); die();} else sql_query ("UPDATE chronicle SET txt=".sqlesc($txt)." WHERE id=".$id) or sqlerr(__FILE__, __LINE__);} - else {$id = 0 + ($_GET['id'] ?? 0); + else {$id = ($_GET['id'] ?? 0); if (!$id) { header("Location: log.php?action=chronicle"); die();} elseif ($_GET['do'] == "del") sql_query ("DELETE FROM chronicle where id = '".$id."'") or sqlerr(__FILE__, __LINE__); diff --git a/massmail.php b/massmail.php index d495b5bb..07c07b0a 100644 --- a/massmail.php +++ b/massmail.php @@ -4,7 +4,7 @@ dbconn(); loggedinorreturn(); if (get_user_class() < UC_SYSOP) stderr("Error", "Permission denied."); -$class = 0 + $_POST["class"]; +$class = $_POST["class"] ?? 0; if ($class) int_check($class,true); $or = $_POST["or"]; diff --git a/maxlogin.php b/maxlogin.php index 1b218cea..a1e01953 100644 --- a/maxlogin.php +++ b/maxlogin.php @@ -33,7 +33,7 @@ function searchform () { here if you are sure.",false); diff --git a/moforums.php b/moforums.php index e22ce8ce..7368f94f 100644 --- a/moforums.php +++ b/moforums.php @@ -151,7 +151,7 @@ $nr = mysql_num_rows($res); 50000){ stdmsg($lang_mybonus['text_error'], $lang_mybonus['bonus_amount_not_allowed_two'], 0); stdfoot(); die(); } - $ratiocharity = 0.0+$_POST["ratiocharity"]; + $ratiocharity = $_POST["ratiocharity"]; if ($ratiocharity < 0.1 || $ratiocharity > 0.8){ stdmsg($lang_mybonus['text_error'], $lang_mybonus['bonus_ratio_not_allowed']); stdfoot(); @@ -416,7 +416,7 @@ if ($action == "exchange") { } elseif($art == "gift_1" && $bonusgift_bonus == 'yes') { //=== trade for giving the gift of karma - $points = 0+$_POST["bonusgift"]; + $points = $_POST["bonusgift"]; $message = $_POST["message"]; //==gift for peeps with no more options $usernamegift = sqlesc(trim($_POST["username"])); diff --git a/news.php b/news.php index e9924363..eec00c8d 100644 --- a/news.php +++ b/news.php @@ -12,12 +12,12 @@ $action = htmlspecialchars($_GET["action"]); if ($action == 'delete') { - $newsid = 0+$_GET["newsid"]; + $newsid = $_GET["newsid"] ?? 0; int_check($newsid,true); $returnto = $_GET["returnto"] ? htmlspecialchars($_GET["returnto"]) : htmlspecialchars($_SERVER["HTTP_REFERER"]); - $sure = 0+$_GET["sure"]; + $sure = $_GET["sure"] ?? 0; if (!$sure) stderr($lang_news['std_delete_news_item'], $lang_news['std_are_you_sure'] . "".$lang_news['std_here']."".$lang_news['std_if_sure'],false); @@ -59,7 +59,7 @@ if ($action == 'add') if ($action == 'edit') { - $newsid = 0+$_GET["newsid"]; + $newsid = $_GET["newsid"] ?? 0; int_check($newsid,true); $res = sql_query("SELECT * FROM news WHERE id=".sqlesc($newsid)) or sqlerr(__FILE__, __LINE__); diff --git a/offers.php b/offers.php index 995b543f..f1a03ef1 100644 --- a/offers.php +++ b/offers.php @@ -131,7 +131,7 @@ if (isset($_GET['off_details']) && $_GET["off_details"]){ if($off_details != '1') stderr($lang_offers['std_error'], $lang_offers['std_smell_rat']); - $id = 0+$_GET["id"]; + $id = $_GET["id"] ?? 0; if(!$id) die(); //stderr("Error", "I smell a rat!"); @@ -465,7 +465,7 @@ if (isset($_GET["vote"]) && $_GET["vote"]){ stderr($lang_offers['std_error'], $lang_offers['std_smell_rat']); if ($vote =='yeah' || $vote =='against') { - $userid = 0+$CURUSER["id"]; + $userid = $CURUSER["id"] ?? 0; $res = sql_query("SELECT * FROM offervotes WHERE offerid=".sqlesc($offerid)." AND userid=".sqlesc($userid)) or sqlerr(__FILE__,__LINE__); $arr = mysql_fetch_assoc($res); $voted = $arr; diff --git a/polloverview.php b/polloverview.php index 821d4269..4996ae02 100644 --- a/polloverview.php +++ b/polloverview.php @@ -7,7 +7,7 @@ loggedinorreturn(); if (get_user_class() < $pollmanage_class) permissiondenied(); -$pollid = 0+$_GET['id']; +$pollid = $_GET['id'] ?? 0; if ($pollid) { diff --git a/shoutbox.php b/shoutbox.php index 7b7af51b..87dff378 100644 --- a/shoutbox.php +++ b/shoutbox.php @@ -62,7 +62,7 @@ countdown(time); if(isset($_GET["sent"]) && $_GET["sent"]=="yes"){ if(!isset($_GET["shbox_text"]) || !$_GET['shbox_text']) { - $userid=0+$CURUSER["id"]; + $userid=$CURUSER["id"] ?? 0; } else { @@ -77,7 +77,7 @@ else } elseif ($_GET["type"] == 'shoutbox') { - $userid=0+$CURUSER["id"]; + $userid=$CURUSER["id"] ?? 0; if (!$userid){ write_log("Someone is hacking shoutbox. - IP : ".getip(),'mod'); die($lang_shoutbox['text_no_permission_to_shoutbox']); diff --git a/staffbox.php b/staffbox.php index 89c6073b..468826d4 100644 --- a/staffbox.php +++ b/staffbox.php @@ -68,7 +68,7 @@ if ($action == "viewpm") if (get_user_class() < $staffmem_class) permissiondenied(); -$pmid = 0 + $_GET["pmid"]; +$pmid = $_GET["pmid"] ?? 0; $ress4 = sql_query("SELECT * FROM staffmessages WHERE id=".sqlesc($pmid)); $arr4 = mysql_fetch_assoc($ress4); @@ -126,7 +126,7 @@ if ($action == "answermessage") { permissiondenied(); $answeringto = $_GET["answeringto"]; - $receiver = 0 + $_GET["receiver"]; + $receiver = $_GET["receiver"] ?? 0; int_check($receiver,true); @@ -166,7 +166,7 @@ if ($action == "takeanswer") { if (get_user_class() < $staffmem_class) permissiondenied(); - $receiver = 0 + $_POST["receiver"]; + $receiver = $_POST["receiver"] ?? 0; $answeringto = $_POST["answeringto"]; int_check($receiver,true); @@ -195,7 +195,7 @@ $Cache->delete_value('staff_new_message_count'); if ($action == "deletestaffmessage") { - $id = 0 + $_GET["id"]; + $id = $_GET["id"] ?? 0; if (!is_numeric($id) || $id < 1 || floor($id) != $id) die; @@ -218,7 +218,7 @@ if ($action == "setanswered") { if (get_user_class() < $staffmem_class) permissiondenied(); -$id = 0 + $_GET["id"]; +$id = $_GET["id"] ?? 0; sql_query ("UPDATE staffmessages SET answered=1, answeredby = $CURUSER[id] WHERE id = $id") or sqlerr(); $Cache->delete_value('staff_new_message_count'); diff --git a/subtitles.php b/subtitles.php index 8e040f90..1e33aad5 100644 --- a/subtitles.php +++ b/subtitles.php @@ -55,7 +55,7 @@ if ($lang_id) } -if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "upload" && ($in_detail!= 'in_detail')) +if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["action"]) && $_POST["action"] == "upload" && ($in_detail!= 'in_detail')) { //start process upload file $file = $_FILES['file']; @@ -72,7 +72,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "upload" && ($in exit; } - $accept_ext = array('sub' => sub, 'srt' => srt, 'zip' => zip, 'rar' => rar, 'ace' => ace, 'txt' => txt, 'SUB' => SUB, 'SRT' => SRT, 'ZIP' => ZIP, 'RAR' => RAR, 'ACE' => ACE, 'TXT' => TXT, 'ssa' => ssa, 'ass' => ass, 'cue' => cue); + $accept_ext = array('sub' => 'sub', 'srt' => 'srt', 'zip' => 'zip', 'rar' => 'rar', 'ace' => 'ace', 'txt' => 'txt', 'SUB' => 'SUB', 'SRT' => 'SRT', 'ZIP' => 'ZIP', 'RAR' => 'RAR', 'ACE' => 'ACE', 'TXT' => 'TXT', 'ssa' => 'ssa', 'ass' => 'ass', 'cue' => 'cue'); $ext_l = strrpos($file['name'], "."); $ext = strtolower(substr($file['name'], $ext_l+1, strlen($file['name'])-($ext_l+1))); @@ -158,7 +158,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["action"] == "upload" && ($in } //end process language - if ($_POST['uplver'] == 'yes' && get_user_class()>=$beanonymous_class) { + if (isset($_POST['uplver']) && $_POST['uplver'] == 'yes' && get_user_class()>=$beanonymous_class) { $anonymous = "yes"; $anon = "Anonymous"; } @@ -206,12 +206,12 @@ if (get_user_class() >= $delownsub_class) $a = mysql_fetch_assoc($r); if (get_user_class() >= $submanage_class || $a["uppedby"] == $CURUSER["id"]) { - $sure = $_GET["sure"]; + $sure = $_GET["sure"] ?? 0; if ($sure == 1) { $reason = $_POST["reason"]; sql_query("DELETE FROM subs WHERE id=$delete") or sqlerr(__FILE__, __LINE__); - if (!unlink("$SUBSPATH/$a[torrent_id]/$a[id].$a[ext]")) + if (!@unlink("$SUBSPATH/$a[torrent_id]/$a[id].$a[ext]")) { stdmsg($lang_subtitles['std_error'], $lang_subtitles['std_this_file']."$a[filename]".$lang_subtitles['std_is_invalid']); stdfoot(); diff --git a/takeconfirm.php b/takeconfirm.php index 554c66df..996d7a97 100644 --- a/takeconfirm.php +++ b/takeconfirm.php @@ -2,7 +2,7 @@ require_once("include/bittorrent.php"); dbconn(); require_once(get_langfile_path()); -$id = isset($_POST['id']) ? 0+$_POST['id'] : (isset($_GET['id']) ? 0+$_GET['id'] : die()); +$id = isset($_POST['id']) ? $_POST['id'] : (isset($_GET['id']) ? $_GET['id'] : die()); int_check($id,true); $email = unesc(htmlspecialchars(trim($_POST["email"]))); if(isset($_POST[conusr])) diff --git a/takeedit.php b/takeedit.php index 04144d8b..1a226318 100644 --- a/takeedit.php +++ b/takeedit.php @@ -36,7 +36,7 @@ $updateset = array(); //$shortfname = $matches[1]; //$dname = $row["save_as"]; -$url = parse_imdb_id($_POST['url']); +$url = parse_imdb_id($_POST['url'] ?? ''); if ($enablenfo_main=='yes'){ $nfoaction = $_POST['nfoaction']; @@ -68,7 +68,7 @@ if ($enablespecial == 'yes' && get_user_class() >= $movetorrent_class) else $allowmove = false; if ($oldcatmode != $newcatmode && !$allowmove) bark($lang_takeedit['std_cannot_move_torrent']); -$updateset[] = "anonymous = '" . ($_POST["anonymous"] ? "yes" : "no") . "'"; +$updateset[] = "anonymous = '" . (!empty($_POST["anonymous"]) ? "yes" : "no") . "'"; $updateset[] = "name = " . sqlesc($name); $updateset[] = "descr = " . sqlesc($descr); $updateset[] = "url = " . sqlesc($url); @@ -84,14 +84,14 @@ $updateset[] = "team = " . sqlesc($_POST["team_sel"] ?? 0); $updateset[] = "audiocodec = " . sqlesc($_POST["audiocodec_sel"] ?? 0); if (get_user_class() >= $torrentmanage_class) { - if ($_POST["banned"]) { + if (!empty($_POST["banned"])) { $updateset[] = "banned = 'yes'"; $_POST["visible"] = 0; } else $updateset[] = "banned = 'no'"; } -$updateset[] = "visible = '" . ($_POST["visible"] ? "yes" : "no") . "'"; +$updateset[] = "visible = '" . (!empty($_POST["visible"]) ? "yes" : "no") . "'"; if(get_user_class()>=$torrentonpromotion_class) { if(!isset($_POST["sel_spstate"]) || $_POST["sel_spstate"] == 1) @@ -135,6 +135,7 @@ if(get_user_class()>=$torrentsticky_class) } $pick_info = ""; +$place_info = ""; if(get_user_class()>=$torrentmanage_class && $CURUSER['picker'] == 'yes') { if(($_POST["sel_recmovie"] ?? 0) == 0) diff --git a/takemessage.php b/takemessage.php index d2fc6918..95a6507e 100644 --- a/takemessage.php +++ b/takemessage.php @@ -8,7 +8,7 @@ loggedinorreturn(); if ($_SERVER["REQUEST_METHOD"] != "POST") stderr($lang_takemessage['std_error'], $lang_takemessage['std_permission_denied']); - $origmsg = 0+$_POST["origmsg"]; + $origmsg = $_POST["origmsg"] ?? 0; $msg = trim($_POST["body"]); if ($_POST['forward'] == 1) //this is forwarding { @@ -35,7 +35,7 @@ if ($_SERVER["REQUEST_METHOD"] != "POST") } else { - $receiver = 0+$_POST["receiver"]; + $receiver = $_POST["receiver"] ?? 0; if (!is_valid_id($receiver) || ($origmsg && !is_valid_id($origmsg))) stderr($lang_takemessage['std_error'],$lang_takemessage['std_invalid_id']); $bodyadd = ""; diff --git a/takeupload.php b/takeupload.php index d9338c95..79d2e83e 100644 --- a/takeupload.php +++ b/takeupload.php @@ -30,7 +30,7 @@ $f = $_FILES["file"]; $fname = unesc($f["name"]); if (empty($fname)) bark($lang_takeupload['std_empty_filename']); -if (get_user_class()>=$beanonymous_class && $_POST['uplver'] == 'yes') { +if (get_user_class()>=$beanonymous_class && isset($_POST['uplver']) && $_POST['uplver'] == 'yes') { $anonymous = "yes"; $anon = "Anonymous"; } @@ -39,7 +39,7 @@ else { $anon = $CURUSER["username"]; } -$url = parse_imdb_id($_POST['url']); +$url = parse_imdb_id($_POST['url'] ?? ''); $nfo = ''; if ($enablenfo_main=='yes'){ @@ -67,14 +67,14 @@ $descr = unesc($_POST["descr"]); if (!$descr) bark($lang_takeupload['std_blank_description']); -$catid = (0 + $_POST["type"]); -$sourceid = (0 + $_POST["source_sel"]); -$mediumid = (0 + $_POST["medium_sel"]); -$codecid = (0 + $_POST["codec_sel"]); -$standardid = (0 + $_POST["standard_sel"]); -$processingid = (0 + $_POST["processing_sel"]); -$teamid = (0 + $_POST["team_sel"]); -$audiocodecid = (0 + $_POST["audiocodec_sel"]); +$catid = ($_POST["type"] ?? 0); +$sourceid = ($_POST["source_sel"] ?? 0); +$mediumid = ($_POST["medium_sel"] ?? 0); +$codecid = ($_POST["codec_sel"] ?? 0); +$standardid = ($_POST["standard_sel"] ?? 0); +$processingid = ($_POST["processing_sel"] ?? 0); +$teamid = ($_POST["team_sel"] ?? 0); +$audiocodecid = ($_POST["audiocodec_sel"] ?? 0); if (!is_valid_id($catid)) bark($lang_takeupload['std_category_unselected']); @@ -214,7 +214,7 @@ $allowtorrents = user_can_upload("torrents"); $allowspecial = user_can_upload("music"); $catmod = get_single_value("categories","mode","WHERE id=".sqlesc($catid)); -$offerid = $_POST['offer']; +$offerid = $_POST['offer'] ?? 0; $is_offer=false; if ($browsecatmode != $specialcatmode && $catmod == $specialcatmode){//upload to special section if (!$allowspecial) diff --git a/thanks.php b/thanks.php index 309a098d..27dd747b 100644 --- a/thanks.php +++ b/thanks.php @@ -4,7 +4,7 @@ dbconn(); loggedinorreturn(); -if ($_GET['id']) +if (isset($_GET['id'])) stderr("Party is over!", "This trick doesn't work anymore. You need to click the button!"); $userid = $CURUSER["id"]; $torrentid = $_POST["id"]; diff --git a/torrent_info.php b/torrent_info.php index 6e6f4942..401c4ca3 100644 --- a/torrent_info.php +++ b/torrent_info.php @@ -12,8 +12,7 @@ function print_array($array, $offset_symbol = "|--", $offset = "", $parent = "") reset($array); - - switch($array['type']) + switch($array['type'] ?? '') { case "string": printf("
  • - [STRING] [%s] (%d): %s
  • ",$parent,$array['strlen'],$array['value']); @@ -29,7 +28,7 @@ function print_array($array, $offset_symbol = "|--", $offset = "", $parent = "") break; case "dictionary": printf("
  • + [DICT] [%s] (%d)
    ",$parent,$array['strlen']); - while (list($key, $val) = each($array)) + foreach ($array as $key => $val) { if (is_array($val)) { @@ -42,7 +41,7 @@ function print_array($array, $offset_symbol = "|--", $offset = "", $parent = "") break; default: - while (list($key, $val) = each($array)) + foreach ($array as $key => $val) { if (is_array($val)) { diff --git a/torrentrss.php b/torrentrss.php index 7db53583..d9bd64ea 100644 --- a/torrentrss.php +++ b/torrentrss.php @@ -16,7 +16,7 @@ if ($passkey){ die("account disabed or parked"); elseif ($_GET['linktype'] == 'dl') $dllink = true; - $inclbookmarked=0+$_GET['inclbookmarked']; + $inclbookmarked=$_GET['inclbookmarked'] ?? 0; if($inclbookmarked == 1) { $bookmarkarray = return_torrent_bookmark_array($user['id']); @@ -26,7 +26,7 @@ if ($passkey){ } } } -$searchstr = mysql_real_escape_string(trim($_GET["search"])); +$searchstr = mysql_real_escape_string(trim($_GET["search"] ?? '')); if (empty($searchstr)) unset($searchstr); if (isset($searchstr)){ @@ -66,10 +66,10 @@ if (isset($searchstr)){ } $limit = ""; -$startindex = 0+$_GET['startindex']; +$startindex = $_GET['startindex'] ?? 0; if ($startindex) $limit .= $startindex.", "; -$showrows = 0+$_GET['rows']; +$showrows = $_GET['rows'] ?? 0; if($showrows < 1 || $showrows > 50) $showrows = 10; $limit .= $showrows; @@ -81,9 +81,9 @@ function get_where($tablename = "sources", $itemname = "source", $getname = "sou $whereitemina = array(); foreach ($items as $item) { - if ($_GET[$getname.$item[id]]) + if (!empty($_GET[$getname.$item['id']])) { - $whereitemina[] = $item[id]; + $whereitemina[] = $item['id']; } } if (count($whereitemina) >= 1){ diff --git a/uploaders.php b/uploaders.php index 2573daaa..6aee0590 100644 --- a/uploaders.php +++ b/uploaders.php @@ -7,10 +7,10 @@ loggedinorreturn(); if (get_user_class() < UC_UPLOADER) permissiondenied(); -$year=0+$_GET['year']; +$year=$_GET['year'] ?? 0; if (!$year || $year < 2000) $year=date('Y'); -$month=0+$_GET['month']; +$month=$_GET['month'] ?? 0; if (!$month || $month<=0 || $month>12) $month=date('m'); $order=$_GET['order']; diff --git a/usercp.php b/usercp.php index 9ab9dcd0..1e26d39a 100644 --- a/usercp.php +++ b/usercp.php @@ -280,7 +280,7 @@ tr($lang_usercp['row_school'], "", 1); $updateset[] = "lang = " . sqlesc($sitelanguage); } - $updateset[] = "torrentsperpage = " . min(100, 0 + $_POST["torrentsperpage"]); + $updateset[] = "torrentsperpage = " . min(100, $_POST["torrentsperpage"] ?? 0); if ($showmovies['hot'] == "yes"){ $showhot = $_POST["show_hot"]; $updateset[] = "showhot = " . sqlesc($showhot); @@ -323,9 +323,9 @@ tr($lang_usercp['row_school'], "", 1); $updateset[] = "pmnum = " . $pmnum; if ($showfunbox_main == 'yes'){$showfb = ($_POST["showfb"] == 'yes' ? "yes" : "no"); $updateset[] = "showfb = " . sqlesc($showfb);} - $sbnum = ($_POST["sbnum"] ? max(10, min(500, 0 + $_POST["sbnum"])) : 70); + $sbnum = ($_POST["sbnum"] ? max(10, min(500, $_POST["sbnum"] ?? 0)) : 70); $updateset[] = "sbnum = " . $sbnum; - $sbrefresh = ($_POST["sbrefresh"] ? max(10, min(3600, 0 + $_POST["sbrefresh"])) : 120); + $sbrefresh = ($_POST["sbrefresh"] ? max(10, min(3600, $_POST["sbrefresh"] ?? 0)) : 120); $updateset[] = "sbrefresh = " . $sbrefresh; if ($_POST["hidehb"] == 'yes') @@ -616,8 +616,8 @@ tr_small($lang_usercp['row_funbox'],"get_value('user_'.$CURUSER['id'].'_post_count')){ $forumposts = get_row_count("posts","WHERE userid=".$CURUSER['id']); $Cache->cache_value('user_'.$CURUSER['id'].'_post_count', $forumposts, 3600); } +$dayposts = 0; if ($forumposts) { $seconds3 = (TIMENOW - strtotime($CURUSER["added"])); @@ -915,8 +916,8 @@ while ($topicarr = mysql_fetch_assoc($res_topics)) /// GETTING USERID AND DATE OF LAST POST /// $arr = get_post_row($topicarr['lastpost']); - $postid = 0 + $arr["id"]; - $userid = 0 + $arr["userid"]; + $postid = $arr["id"] ?? 0; + $userid = $arr["userid"] ?? 0; $added = gettime($arr['added'],true,false); /// GET NAME OF LAST POSTER /// diff --git a/users.php b/users.php index 8d4f5c09..1270f103 100644 --- a/users.php +++ b/users.php @@ -8,7 +8,7 @@ if (get_user_class() < $viewuserlist_class) permissiondenied(); $search = trim($_GET['search']); $class = $_GET['class']; -$country = 0+$_GET['country']; +$country = $_GET['country'] ?? 0; $letter = trim($_GET["letter"]); if (strlen($letter) > 1) diff --git a/viewpeerlist.php b/viewpeerlist.php index 6cddcdec..508bb132 100644 --- a/viewpeerlist.php +++ b/viewpeerlist.php @@ -9,7 +9,7 @@ header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-Type: text/xml; charset=utf-8"); -$id = 0 + $_GET['id']; +$id = $_GET['id'] ?? 0; if(isset($CURUSER)) { function dltable($name, $arr, $torrent) diff --git a/viewsnatches.php b/viewsnatches.php index 1ac64746..bfab6d75 100644 --- a/viewsnatches.php +++ b/viewsnatches.php @@ -60,7 +60,7 @@ if ($count){ } else { - stdmsg($lang_viewsnatches['std_sorry'], $lang_viewsnatches['std_no_snatched_users']); + stdmsg($lang_viewsnatches['std_sorry'], $lang_viewsnatches['text_no_snatched_users']); } end_main_frame(); stdfoot();