From 2d4988c814c0eb8927bc81a62518a02f1a95fb05 Mon Sep 17 00:00:00 2001 From: Peter van Westen Date: Mon, 4 Nov 2013 15:17:11 +0100 Subject: [PATCH] Fixed unnecessary checks in php files with no code This fix makes the GPL check not give false negatives on placeholder files. So php files with only a comment tag in it. These don't need GPL info. --- .../com_jedchecker/libraries/rules/gpl.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/administrator/components/com_jedchecker/libraries/rules/gpl.php b/source/administrator/components/com_jedchecker/libraries/rules/gpl.php index 3f09378..ff5c111 100644 --- a/source/administrator/components/com_jedchecker/libraries/rules/gpl.php +++ b/source/administrator/components/com_jedchecker/libraries/rules/gpl.php @@ -80,8 +80,21 @@ class jedcheckerRulesGpl extends JEDcheckerRule $licenses = $this->params->get('constants'); $licenses = explode(',', $licenses); + $hascode = 0; + foreach ($content AS $key => $line) { + $tline = trim($line); + + if ($tline == '' || $tline == '') + { + continue; + } + + if ($tline['0'] != '/' && $tline['0'] != '*') + { + $hascode = 1; + } // Search for GPL license $gpl = stripos($line, 'GPL'); @@ -120,6 +133,6 @@ class jedcheckerRulesGpl extends JEDcheckerRule unset($content); - return false; + return $hascode ? false : true; } }