From f87b5dbbbad408da775ac4c60ceb9f9666280527 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 22:04:14 +0000 Subject: [PATCH] use isset() + ?: or error suppression where value may not be set --- inc/auth.php | 2 +- inc/init.php | 8 ++++---- inc/search.php | 2 +- inc/template.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/auth.php b/inc/auth.php index 6c4636b2f..e44e837a7 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -325,7 +325,7 @@ function auth_browseruid() { $uid = ''; $uid .= $_SERVER['HTTP_USER_AGENT']; $uid .= $_SERVER['HTTP_ACCEPT_ENCODING']; - $uid .= $_SERVER['HTTP_ACCEPT_CHARSET']; + $uid .= @$_SERVER['HTTP_ACCEPT_CHARSET']; $uid .= substr($ip, 0, strpos($ip, '.')); $uid = strtolower($uid); return md5($uid); diff --git a/inc/init.php b/inc/init.php index 6fb27bd2a..bcd96e5e4 100644 --- a/inc/init.php +++ b/inc/init.php @@ -441,12 +441,12 @@ function getBaseURL($abs=null){ //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']); - $host = $parsed_host['host']; - $port = $parsed_host['port']; + $host = isset($parsed_host['host']) ? $parsed_host['host'] : null; + $port = isset($parsed_host['port']) ? $parsed_host['port'] : null; }elseif(isset($_SERVER['SERVER_NAME'])){ $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']); - $host = $parsed_host['host']; - $port = $parsed_host['port']; + $host = isset($parsed_host['host']) ? $parsed_host['host'] : null; + $port = isset($parsed_host['port']) ? $parsed_host['port'] : null; }else{ $host = php_uname('n'); $port = ''; diff --git a/inc/search.php b/inc/search.php index 840f70375..ee4eef534 100644 --- a/inc/search.php +++ b/inc/search.php @@ -351,7 +351,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ $return = true; // get ID and check if it is a valid one - $item['id'] = pathID($file,($type == 'd' || $opts['keeptxt'])); + $item['id'] = pathID($file,($type == 'd' || @$opts['keeptxt'])); if($item['id'] != cleanID($item['id'])){ if($opts['showmsg']) msg(hsc($item['id']).' is not a valid file name for DokuWiki - skipped',-1); diff --git a/inc/template.php b/inc/template.php index 0a6a9e4aa..d9aa8863f 100644 --- a/inc/template.php +++ b/inc/template.php @@ -210,7 +210,7 @@ function tpl_toc($return = false) { } else { $tocok = true; } - $toc = $meta['description']['tableofcontents']; + $toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null; if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { $toc = array(); }