From 2fcd1054949f748867f69c4e0f24f1efe171fafe Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 30 Nov 2025 19:13:30 +0000 Subject: [PATCH 1/3] Fix various PHP warnings This commit fixes several PHP warnings and deprecation notices that were cluttering the nginx error log. - Fixed "Undefined array key" and "Undefined variable" warnings by using `isset()` checks, the null coalescing operator (`??`), and initializing variables. - Addressed "Trying to access array offset on value of type null" warnings by adding checks for null values before accessing array offsets. - Resolved "Deprecated: preg_match(): Passing null to parameter # 2 ($subject) of type string is deprecated" and "Deprecated: pathinfo(): Passing null to parameter # 1 ($path) of type string is deprecated" notices by ensuring the variables are not null. --- include/class/PeerRequest.php | 4 ++-- web/apps/admin/index.php | 3 ++- web/apps/docs/index.php | 6 ++++++ web/apps/explorer/txs.php | 8 ++++---- web/mine.php | 5 ++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/class/PeerRequest.php b/include/class/PeerRequest.php index 8c81e5bf..c27d3eb3 100644 --- a/include/class/PeerRequest.php +++ b/include/class/PeerRequest.php @@ -150,7 +150,7 @@ static function peer() { $res = Peer::getSingle($hostname, $ip); if ($res == 1) { _log("$hostname is already in peer db",3); - if ($data['repeer'] == 1) { + if (isset($data['repeer']) && $data['repeer'] == 1) { $res = peer_post($hostname."/peer.php?q=peer", ["hostname" => $_config['hostname']], 30, $err); if ($res !== false) { api_echo("re-peer-ok"); @@ -169,7 +169,7 @@ static function peer() { Peer::updatePeerInfo($ip, $_REQUEST['info']); } // re-peer to make sure the peer is valid - if ($data['repeer'] == 1) { + if (isset($data['repeer']) && $data['repeer'] == 1) { _log("Repeer to $hostname",3); $res = peer_post($hostname . "/peer.php?q=peer", ["hostname" => $_config['hostname']], 30, $err); _log("peer response " . print_r($res,1),4); diff --git a/web/apps/admin/index.php b/web/apps/admin/index.php index eaa25363..c97eb2ab 100755 --- a/web/apps/admin/index.php +++ b/web/apps/admin/index.php @@ -13,6 +13,7 @@ require_once __DIR__. '/../common/include/top.php'; +$msg = []; if(isset($_POST['action'])) { $action = $_POST['action']; if($action == "generate") { @@ -141,7 +142,7 @@ } $setAdminPass = !empty($_config['admin_password']); -$login = $_SESSION['login']; +$login = $_SESSION['login'] ?? false; if(isset($_GET['view'])) { $view = $_GET['view']; diff --git a/web/apps/docs/index.php b/web/apps/docs/index.php index a7d476b2..cbbc319f 100644 --- a/web/apps/docs/index.php +++ b/web/apps/docs/index.php @@ -8,7 +8,13 @@ class ParsedownExt extends Parsedown { function inlineLink($Excerpt) { + if (!isset($Excerpt['text'])) { + return null; + } $link = parent::inlineLink($Excerpt); + if (!isset($link['element']['attributes']['href'])) { + return $link; + } $link['element']['attributes']['href'] = "/apps/docs/index.php?link=".urlencode($link['element']['attributes']['href']); return $link; } diff --git a/web/apps/explorer/txs.php b/web/apps/explorer/txs.php index fa352d4c..11b2cc2f 100644 --- a/web/apps/explorer/txs.php +++ b/web/apps/explorer/txs.php @@ -68,17 +68,17 @@ function TransactiongetAll($dm) {
+ value="">
+ value="">
- +
- +
+
diff --git a/web/apps/wallet/login.php b/web/apps/wallet/login.php index 6bead7cc..fbaf536d 100644 --- a/web/apps/wallet/login.php +++ b/web/apps/wallet/login.php @@ -2,9 +2,9 @@ require_once dirname(__DIR__)."/apps.inc.php"; if(isset($_GET['action']) && $_GET['action']=="login-link") { - $login_code = $_GET['login_code']; - $public_key = $_GET['public_key']; - $login_key = $_GET['login_key']; + $login_code = $_GET['login_code'] ?? null; + $public_key = $_GET['public_key'] ?? null; + $login_key = $_GET['login_key'] ?? null; if(empty($login_code) || empty($public_key) || empty($login_key)) { $_SESSION['msg']=[['icon'=>'warning', 'text'=>'Invalid data received']]; diff --git a/web/mine.php b/web/mine.php index 15340b1e..3e4c6121 100755 --- a/web/mine.php +++ b/web/mine.php @@ -26,7 +26,7 @@ */ require_once dirname(__DIR__).'/include/init.inc.php'; set_time_limit(360); -$q = $_GET['q']; +$q = $_GET['q'] ?? null; if(!Nodeutil::miningEnabled()) { api_err("mining-not-enabled"); @@ -72,8 +72,8 @@ function saveGeneratorStat($generator_stat) { } function checkVersion() { - $version = $_POST['version']; - $minerInfo = $_POST['minerInfo']; + $version = $_POST['version'] ?? null; + $minerInfo = $_POST['minerInfo'] ?? null; $version_ok = version_compare($version, MIN_MINER_VERSION)>=0; _log("checkVersion q=".$_GET['q']. " version=".$version. " MIN_VERSION=".MIN_MINER_VERSION. " minerInfo=$minerInfo version_ok=$version_ok"); return $version_ok; @@ -198,8 +198,8 @@ function checkStats($ip) { api_err("no-live-peers"); } - $address = san($_POST['address']); - $height = san($_POST['height']); + $address = san($_POST['address'] ?? null); + $height = san($_POST['height'] ?? null); if(empty($height) || empty($address)) { _logf("rejected: missing-parameters height=$height address=$address", 0); @@ -216,12 +216,12 @@ function checkStats($ip) { _logp(" minerInfo=$minerInfo "); - $nonce = san($_POST['nonce']); + $nonce = san($_POST['nonce'] ?? null); $version = Block::versionCode($height); - $address = san($_POST['address']); - $elapsed = intval($_POST['elapsed']); - $difficulty = san($_POST['difficulty']); - $argon = $_POST['argon']; + $address = san($_POST['address'] ?? null); + $elapsed = intval($_POST['elapsed'] ?? 0); + $difficulty = san($_POST['difficulty'] ?? null); + $argon = $_POST['argon'] ?? null; _logp(" height=$height address=$address elapsed=$elapsed argon=$argon"); diff --git a/web/peer.php b/web/peer.php index 84df7502..97d044ee 100755 --- a/web/peer.php +++ b/web/peer.php @@ -27,12 +27,12 @@ require_once dirname(__DIR__).'/include/init.inc.php'; header('Content-Type: application/json'); -$q = $_GET['q']; +$q = $_GET['q'] ?? null; $t1=microtime(true); $info = ""; -$data = json_decode(trim($_POST['data']), true); +$data = json_decode(trim($_POST['data'] ?? ''), true); $lock_name = false; $lock_filename = false;