use empty() where array values might not be set

This commit is contained in:
Christopher Smith 2014-03-05 21:58:46 +00:00
parent 17dd401e94
commit 0e80bb5e34
9 changed files with 24 additions and 24 deletions

View File

@ -733,7 +733,7 @@ function act_subscription($act){
}
// any action given? if not just return and show the subscription page
if(!$params['action'] || !checkSecurityToken()) return $act;
if(empty($params['action']) || !checkSecurityToken()) return $act;
// Handle POST data, may throw exception.
trigger_event('ACTION_HANDLE_SUBSCRIBE', $params, 'subscription_handle_post');

View File

@ -191,7 +191,7 @@ function pageinfo() {
if($REV) {
$revinfo = getRevisionInfo($ID, $REV, 1024);
} else {
if(is_array($info['meta']['last_change'])) {
if(!empty($info['meta']['last_change']) && is_array($info['meta']['last_change'])) {
$revinfo = $info['meta']['last_change'];
} else {
$revinfo = getRevisionInfo($ID, $info['lastmod'], 1024);

View File

@ -691,7 +691,7 @@ function html_recent($first=0, $show_changes='both'){
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
if ($recent['media']) {
if (!empty($recent['media'])) {
$form->addElement(media_printicon($recent['id']));
} else {
$icon = DOKU_BASE.'lib/images/fileicons/file.png';
@ -705,7 +705,7 @@ function html_recent($first=0, $show_changes='both'){
$diff = false;
$href = '';
if ($recent['media']) {
if (!empty($recent['media'])) {
$diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id'])));
if ($diff) {
$href = media_managerURL(array('tab_details' => 'history',
@ -715,7 +715,7 @@ function html_recent($first=0, $show_changes='both'){
$href = wl($recent['id'],"do=diff", false, '&');
}
if ($recent['media'] && !$diff) {
if (!empty($recent['media']) && !$diff) {
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
} else {
$form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
@ -729,7 +729,7 @@ function html_recent($first=0, $show_changes='both'){
$form->addElement(form_makeCloseTag('a'));
}
if ($recent['media']) {
if (!empty($recent['media'])) {
$href = media_managerURL(array('tab_details' => 'history',
'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
} else {
@ -745,7 +745,7 @@ function html_recent($first=0, $show_changes='both'){
)));
$form->addElement(form_makeCloseTag('a'));
if ($recent['media']) {
if (!empty($recent['media'])) {
$href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
$class = (file_exists(mediaFN($recent['id']))) ? 'wikilink1' : $class = 'wikilink2';
$form->addElement(form_makeOpenTag('a', array('class' => $class, 'href' => $href)));

View File

@ -176,7 +176,7 @@ if(function_exists('set_magic_quotes_runtime')) @set_magic_quotes_runtime(0);
$_REQUEST = array_merge($_GET,$_POST);
// we don't want a purge URL to be digged
if(isset($_REQUEST['purge']) && $_SERVER['HTTP_REFERER']) unset($_REQUEST['purge']);
if(isset($_REQUEST['purge']) && !empty($_SERVER['HTTP_REFERER'])) unset($_REQUEST['purge']);
// disable gzip if not available
if($conf['compression'] == 'bz2' && !function_exists('bzopen')){

View File

@ -1018,7 +1018,7 @@ function media_file_tags($meta) {
foreach($fields as $key => $tag){
$t = array();
if (!empty($tag[0])) $t = array($tag[0]);
if(is_array($tag[3])) $t = array_merge($t,$tag[3]);
if(isset($tag[3]) && is_array($tag[3])) $t = array_merge($t,$tag[3]);
$value = media_getTag($t, $meta);
$tags[] = array('tag' => $tag, 'value' => $value);
}
@ -1779,7 +1779,7 @@ function media_nstree_item($item){
global $INPUT;
$pos = strrpos($item['id'], ':');
$label = substr($item['id'], $pos > 0 ? $pos + 1 : 0);
if(!$item['label']) $item['label'] = $label;
if(empty($item['label'])) $item['label'] = $label;
$ret = '';
if (!($INPUT->str('do') == 'media'))
@ -1841,7 +1841,7 @@ function media_resize_image($file, $ext, $w, $h=0){
if( $mtime > filemtime($file) ||
media_resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) ||
media_resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){
if($conf['fperm']) @chmod($local, $conf['fperm']);
if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
return $local;
}
//still here? resizing failed
@ -1902,7 +1902,7 @@ function media_crop_image($file, $ext, $w, $h=0){
if( $mtime > @filemtime($file) ||
media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) ||
media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){
if($conf['fperm']) @chmod($local, $conf['fperm']);
if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
return media_resize_image($local,$ext, $w, $h);
}

View File

@ -141,7 +141,7 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){
//we do nothing with directories
if($type == 'd') {
if(!$opts['depth']) return true; // recurse forever
if(empty($opts['depth'])) return true; // recurse forever
$depth = substr_count($file,'/');
if($depth >= $opts['depth']) return false; // depth reached
return true;
@ -157,12 +157,12 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){
//check ACL for namespace (we have no ACL for mediafiles)
$info['perm'] = auth_quickaclcheck(getNS($info['id']).':*');
if(!$opts['skipacl'] && $info['perm'] < AUTH_READ){
if(empty($opts['skipacl']) && $info['perm'] < AUTH_READ){
return false;
}
//check pattern filter
if($opts['pattern'] && !@preg_match($opts['pattern'], $info['id'])){
if(!empty($opts['pattern']) && !@preg_match($opts['pattern'], $info['id'])){
return false;
}
@ -176,7 +176,7 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){
}else{
$info['isimg'] = false;
}
if($opts['hash']){
if(!empty($opts['hash'])){
$info['hash'] = md5(io_readFile(mediaFN($info['id']),false));
}
@ -361,7 +361,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){
if($type == 'd') {
// decide if to recursion into this directory is wanted
if(!$opts['depth']){
if(empty($opts['depth'])){
$return = true; // recurse forever
}else{
$depth = substr_count($file,'/');
@ -407,7 +407,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){
$item['level'] = $lvl;
$item['open'] = $return;
if($opts['meta']){
if(!empty($opts['meta'])){
$item['file'] = utf8_basename($file);
$item['size'] = filesize($base.'/'.$file);
$item['mtime'] = filemtime($base.'/'.$file);
@ -417,8 +417,8 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){
}
if($type == 'f'){
if($opts['hash']) $item['hash'] = md5(io_readFile($base.'/'.$file,false));
if($opts['firsthead']) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER);
if(!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base.'/'.$file,false));
if(!empty($opts['firsthead'])) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER);
}
// finally add the item

View File

@ -57,7 +57,7 @@
}
// give info on PHP caught upload errors
if($_FILES['upload']['error']){
if(!empty($_FILES['upload']['error'])){
switch($_FILES['upload']['error']){
case 1:
case 2:
@ -71,7 +71,7 @@
}
// handle upload
if($_FILES['upload']['tmp_name']){
if(!empty($_FILES['upload']['tmp_name'])){
$JUMPTO = media_upload($NS,$AUTH);
if($JUMPTO) $NS = getNS($JUMPTO);
}

View File

@ -488,7 +488,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
function _html_list_acl($item){
$ret = '';
// what to display
if($item['label']){
if(!empty($item['label'])){
$base = $item['label'];
}else{
$base = ':'.$item['id'];

View File

@ -53,7 +53,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
}
// attempt to retrieve any import failures from the session
if ($_SESSION['import_failures']){
if (!empty($_SESSION['import_failures'])){
$this->_import_failures = $_SESSION['import_failures'];
}
}