diff --git a/include/class/CommonSessionHandler.php b/include/class/CommonSessionHandler.php index abd16b3c..232597db 100644 --- a/include/class/CommonSessionHandler.php +++ b/include/class/CommonSessionHandler.php @@ -46,6 +46,7 @@ public function open($path, $name) #[\ReturnTypeWillChange] public function read($id) { + $out = ""; $sess_file = $this->path."/sess_$id"; if(file_exists($sess_file)) $out=@file_get_contents($sess_file); return (string) $out; @@ -63,7 +64,9 @@ static function setup($session_id = null) { $handler = new CommonSessionHandler(); session_set_save_handler($handler, true); $sessions_dir = ROOT."/tmp/sessions"; - @mkdir($sessions_dir); + if (!is_dir($sessions_dir)) { + @mkdir($sessions_dir, 0755, true); + } session_save_path($sessions_dir); if(!empty($session_id)) { session_id($session_id); diff --git a/include/class/PeerRequest.php b/include/class/PeerRequest.php index 8c81e5bf..463f1268 100644 --- a/include/class/PeerRequest.php +++ b/include/class/PeerRequest.php @@ -22,7 +22,7 @@ static function processRequest() { $data = json_decode(trim($_POST['data']), true); } global $_config; - if ($_POST['coin'] != COIN) { + if (!isset($_POST['coin']) || $_POST['coin'] != COIN) { _logf("Invalid coin request=".json_encode($_REQUEST)." server=".json_encode($_SERVER)); api_err("Invalid coin ".json_encode($_REQUEST), 3); } @@ -40,7 +40,7 @@ static function processRequest() { } $ip = Nodeutil::getRemoteAddr(); - if(version_compare($_POST['version'], MIN_VERSION) < 0) { + if(!isset($_POST['version']) || version_compare($_POST['version'], MIN_VERSION) < 0) { $peer = Peer::findByIp($ip); if($peer) { Peer::blacklist($peer['id'], "Invalid version ".$_POST['version']); @@ -49,12 +49,14 @@ static function processRequest() { _logf("Invalid version ".$_POST['version']); api_err("Invalid version ".$_POST['version']); } - $requestId = $_POST['requestId']; - _log("Peer request from IP = $ip requestId=$requestId q=".$_GET['q']." chainId=".$_POST['chain_id'] ,4); + $requestId = $_POST['requestId'] ?? null; + $q = $_GET['q'] ?? null; + $chain_id = $_POST['chain_id'] ?? null; + _log("Peer request from IP = $ip requestId=$requestId q=".$q." chainId=".$chain_id ,4); - _logp("q=".$_GET['q']); + _logp("q=".$q); - $info = $_POST['info']; + $info = $_POST['info'] ?? null; $ip = Peer::validateIp($ip); _log("Filtered IP = $ip",4); @@ -150,7 +152,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 +171,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/admin/tabs/server.php b/web/apps/admin/tabs/server.php index b1aec959..ac7f4ad0 100644 --- a/web/apps/admin/tabs/server.php +++ b/web/apps/admin/tabs/server.php @@ -7,21 +7,21 @@ global $action, $db; if($action == "task_enable") { - $task = $_GET['task']; + $task = $_GET['task'] ?? null; $task::enable(); header("location: ".APP_URL."/?view=server"); exit; } if($action == "task_disable") { - $task = $_GET['task']; + $task = $_GET['task'] ?? null; $task::disable(); header("location: ".APP_URL."/?view=server"); exit; } if($action == "task_stop") { - $task = $_GET['task']; + $task = $_GET['task'] ?? null; $name = $task::$name; $cmd = "php ".ROOT."/cli/$name.php --stop"; $res = shell_exec($cmd); diff --git a/web/apps/admin/tabs/utils.php b/web/apps/admin/tabs/utils.php index 33ae76ad..ee762f9f 100644 --- a/web/apps/admin/tabs/utils.php +++ b/web/apps/admin/tabs/utils.php @@ -21,8 +21,9 @@ exit; } +$checkBlocksResponse = false; if($action == "check_blocks") { - $peer = $_POST['peer']; + $peer = $_POST['peer'] ?? null; $invalid_block = Nodeutil::checkBlocksWithPeer($peer); $checkBlocksResponse = true; } @@ -32,14 +33,16 @@ } if($action == 'clear_blocks') { - $height = $_POST['height']; + $height = $_POST['height'] ?? null; Nodeutil::deleteFromHeight($height); header("location: ".APP_URL."/?view=utils"); exit; } +$accountsHash = false; +$blocksHash = false; if($action == "blocks-hash") { - $height = $_POST['height']; + $height = $_POST['height'] ?? null; $blocksHash = Nodeutil::calculateBlocksHash($height); } 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/accounts.php b/web/apps/explorer/accounts.php index 77fbcade..32081f77 100755 --- a/web/apps/explorer/accounts.php +++ b/web/apps/explorer/accounts.php @@ -19,7 +19,7 @@
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) {