use isset() + ?: or error suppression where value may not be set

This commit is contained in:
Christopher Smith 2014-03-05 22:04:14 +00:00
parent 6d2af55dde
commit f87b5dbbba
4 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -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 = '';

View File

@ -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);

View File

@ -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();
}