Skip to content

Commit

Permalink
Fix php notices w/ proper var checks
Browse files Browse the repository at this point in the history
  • Loading branch information
billz committed Sep 6, 2023
1 parent 55c0a49 commit c64bdb4
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,23 +318,23 @@ function CSRFMetaTag()
*/
function CSRFValidate()
{
$post_token = $_POST['csrf_token'];
$header_token = $_SERVER['HTTP_X_CSRF_TOKEN'];
if(isset($_POST['csrf_token'])) {
$post_token = $_POST['csrf_token'];
$header_token = $_SERVER['HTTP_X_CSRF_TOKEN'];

if (empty($post_token) && empty($header_token)) {
return false;
}

$request_token = $post_token;
if (empty($post_token)) {
$request_token = $header_token;
}

if (hash_equals($_SESSION['csrf_token'], $request_token)) {
return true;
} else {
error_log('CSRF violation');
return false;
if (empty($post_token) && empty($header_token)) {
return false;
}
$request_token = $post_token;
if (empty($post_token)) {
$request_token = $header_token;
}
if (hash_equals($_SESSION['csrf_token'], $request_token)) {
return true;
} else {
error_log('CSRF violation');
return false;
}
}
}

Expand Down Expand Up @@ -685,8 +685,10 @@ function getColorOpt()
}
function getSidebarState()
{
if ($_COOKIE['sidebarToggled'] == 'true' ) {
return"toggled";
if(isset($_COOKIE['sidebarToggled'])) {
if ($_COOKIE['sidebarToggled'] == 'true' ) {
return "toggled";
}
}
}

Expand Down

0 comments on commit c64bdb4

Please sign in to comment.