Skip to content

Commit

Permalink
Initial PSR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
snake14 committed Dec 5, 2024
1 parent e1b8131 commit 346de40
Show file tree
Hide file tree
Showing 31 changed files with 166 additions and 223 deletions.
3 changes: 2 additions & 1 deletion Controller.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand All @@ -16,7 +17,7 @@
*/
class Controller extends \Piwik\Plugin\ControllerAdmin
{
function index()
public function index()
{
Piwik::checkUserHasSuperUserAccess();

Expand Down
1 change: 1 addition & 0 deletions Menu.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
45 changes: 17 additions & 28 deletions PhpSecInfo/PhpSecInfo.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?php

/**
* Main class file
*
* @package PhpSecInfo
* @author Ed Finkler <coj@funkatron.com>
*/


/**
* The default language setting if none is set/retrievable
*
*/
define ('PHPSECINFO_LANG_DEFAULT', 'en');
define('PHPSECINFO_LANG_DEFAULT', 'en');

/**
* a general version string to differentiate releases
*
*/
define ('PHPSECINFO_VERSION', '0.2.2');
define('PHPSECINFO_VERSION', '0.2.2');

/**
* a YYYYMMDD date string to indicate "build" date
*
*/
define ('PHPSECINFO_BUILD', '20080723');
define('PHPSECINFO_BUILD', '20080723');

/**
* Homepage for phpsecinfo project
*
*/
define ('PHPSECINFO_URL', 'http://phpsecinfo.com');
define('PHPSECINFO_URL', 'http://phpsecinfo.com');

/**
* The base folder where views are stored. Include trailing slash
Expand Down Expand Up @@ -94,13 +94,12 @@
*/
class PhpSecInfo
{

/**
* An array of tests to run
*
* @var array PhpSecInfo_Test
*/
var $tests_to_run = array();
$tests_to_run = array();


/**
Expand All @@ -112,7 +111,7 @@ class PhpSecInfo
*
* @var array
*/
var $test_results = array();
$test_results = array();


/**
Expand All @@ -125,7 +124,7 @@ class PhpSecInfo
*
* @var array
*/
var $tests_not_run = array();
$tests_not_run = array();


/**
Expand All @@ -135,7 +134,7 @@ class PhpSecInfo
* @var string
* @see PHPSECINFO_LANG_DEFAULT
*/
var $language = PHPSECINFO_LANG_DEFAULT;
$language = PHPSECINFO_LANG_DEFAULT;


/**
Expand All @@ -144,22 +143,22 @@ class PhpSecInfo
*
* @var array
*/
var $result_counts = array();
$result_counts = array();


/**
* The number of tests that have been run
*
* @var integer
*/
var $num_tests_run = 0;
$num_tests_run = 0;


/**
* The base directory for phpsecinfo. Set within the constructor. Paths are resolved from this.
* @var string
*/
var $_base_dir;
$_base_dir;


/**
Expand All @@ -169,15 +168,15 @@ class PhpSecInfo
*
* @var string
*/
var $_view_directory;
$_view_directory;


/**
* The output format, used to load the proper view
*
* @var string
**/
var $_format;
$_format;

/**
* Constructor
Expand Down Expand Up @@ -206,7 +205,6 @@ function __construct($opts = null)
$this->setFormat(PHPSECINFO_FORMAT_DEFAULT);
}
}

} else { /* Use defaults */
$this->setViewDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . PHPSECINFO_VIEW_DIR_DEFAULT);
if (!strcasecmp(PHP_SAPI, 'cli')) {
Expand Down Expand Up @@ -246,7 +244,6 @@ function loadTests()
$classNames[] = "PhpSecInfo_Test_" . $test_dir . "_" . basename($entry, '.php');
}
}

}

// modded this to not throw a PHP5 STRICT notice, although I don't like passing by value here
Expand Down Expand Up @@ -288,7 +285,7 @@ function runTests()
$this->test_results[$test->getTestGroup()][$test->getTestName()] = $rs;

// initialize if not yet set
if (!isset ($this->result_counts[$rs['result']])) {
if (!isset($this->result_counts[$rs['result']])) {
$this->result_counts[$rs['result']] = 0;
}

Expand All @@ -297,8 +294,8 @@ function runTests()
} else {
$rs = array('result' => $test->getResult(),
'message' => $test->getMessage(),
'value_current' => NULL,
'value_recommended' => NULL,
'value_current' => null,
'value_recommended' => null,
'moreinfo_url' => $test->getMoreInfoURL(),
);
$this->result_counts[PHPSECINFO_TEST_RESULT_NOTRUN]++;
Expand Down Expand Up @@ -368,7 +365,6 @@ function _outputRenderStatsTable()
}

$this->_outputRenderTable('Test Results Summary', $stats);

}


Expand All @@ -381,7 +377,6 @@ function _outputRenderNotRunTable()
{

$this->_outputRenderTable('Tests Not Run', $this->tests_not_run);

}


Expand Down Expand Up @@ -421,7 +416,6 @@ function _outputGetCssClassFromResult($code)
return 'value-notrun';
break;
}

}


Expand Down Expand Up @@ -462,7 +456,6 @@ function _outputGetResultTypeFromCode($code)
return 'Invalid Result Code';
break;
}

}


Expand Down Expand Up @@ -548,8 +541,6 @@ function loadView($view_name, $data = null)
} else {
user_error("The view '{$view_file}' either does not exist or is not readable", E_USER_WARNING);
}


}


Expand Down Expand Up @@ -585,7 +576,6 @@ function setFormat($format)
{
$this->_format = $format;
}

}


Expand All @@ -600,4 +590,3 @@ function phpsecinfo()
$psi->loadAndRun();
$psi->renderOutput();
}

8 changes: 5 additions & 3 deletions PhpSecInfo/Test/Application/php.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* Test class for PHP Application
*
* @package PhpSecInfo
* @author Piwik
*/

use Piwik\Http;

/**
Expand All @@ -23,9 +25,9 @@
class PhpSecInfo_Test_Application_Php extends PhpSecInfo_Test_Application
{
const SOCKET_TIMEOUT = 2;
var $test_name = "PHP";
$test_name = "PHP";

var $recommended_value = null;
$recommended_value = null;

function _retrieveCurrentValue()
{
Expand Down Expand Up @@ -67,7 +69,7 @@ function _setMessages()
{
parent::_setMessages();

if(\Piwik\Common::getRequestVar('tests_hide_piwik_version', 0, 'int') == 1) {
if (\Piwik\Common::getRequestVar('tests_hide_piwik_version', 0, 'int') == 1) {
$this->recommended_value = 'Screenshot testing - Version is hidden';
$this->current_value = 'PHP MAX HACK';
}
Expand Down
8 changes: 5 additions & 3 deletions PhpSecInfo/Test/Application/piwik.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* Test class for Piwik Application
*
* @package PhpSecInfo
* @author Piwik
*/

use Piwik\UpdateCheck;
use Piwik\Version;

Expand All @@ -23,9 +25,9 @@
*/
class PhpSecInfo_Test_Application_Piwik extends PhpSecInfo_Test_Application
{
var $test_name = "Matomo";
$test_name = "Matomo";

var $recommended_value = null;
$recommended_value = null;

function _retrieveCurrentValue()
{
Expand Down Expand Up @@ -58,7 +60,7 @@ function _setMessages()
$piwikVersion = $this->current_value;
$recommendedValue = $this->recommended_value;

if(\Piwik\Common::getRequestVar('tests_hide_piwik_version', 0, 'int') == 1) {
if (\Piwik\Common::getRequestVar('tests_hide_piwik_version', 0, 'int') == 1) {
$piwikVersion = $recommendedValue = 'Screenshot testing - Version is hidden';
}

Expand Down
6 changes: 3 additions & 3 deletions PhpSecInfo/Test/CGI/force_redirect.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Test class for cgi force_redirect
*
Expand All @@ -19,20 +20,19 @@
*/
class PhpSecInfo_Test_Cgi_Force_Redirect extends PhpSecInfo_Test_Cgi
{

/**
* This should be a <b>unique</b>, human-readable identifier for this test
*
* @var string
*/
var $test_name = "force_redirect";
$test_name = "force_redirect";

/**
* The recommended setting value
*
* @var mixed
*/
var $recommended_value = TRUE;
$recommended_value = true;


function _retrieveCurrentValue()
Expand Down
13 changes: 5 additions & 8 deletions PhpSecInfo/Test/Core/allow_url_fopen.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

/**
* Test Class for allow_url_fopen
*
* @package PhpSecInfo
* @author Ed Finkler <coj@funkatron.com>
*/


/**
* require the PhpSecInfo_Test_Core class
*/
Expand All @@ -26,14 +26,14 @@ class PhpSecInfo_Test_Core_Allow_Url_Fopen extends PhpSecInfo_Test_Core
*
* @var string
*/
var $test_name = "allow_url_fopen";
$test_name = "allow_url_fopen";

/**
* The recommended setting value
*
* @var mixed
*/
var $recommended_value = FALSE;
$recommended_value = false;


function _retrieveCurrentValue()
Expand All @@ -54,7 +54,7 @@ function _execTest()

return PHPSECINFO_TEST_RESULT_WARN;
} else { /* In 5.2, we'll consider allow_url_fopen "safe" */
$this->recommended_value = TRUE;
$this->recommended_value = true;
return PHPSECINFO_TEST_RESULT_OK;
}
}
Expand All @@ -69,11 +69,8 @@ function _setMessages()
if (version_compare(PHP_VERSION, '5.2', '<')) { /* this is much more severe if we're running < 5.2 */
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'allow_url_fopen is disabled, which is the recommended setting');
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', 'allow_url_fopen is enabled. This could be a serious security risk. You should disable allow_url_fopen and consider using the <a href="http://php.net/manual/en/ref.curl.php" rel="noreferrer" target="_blank">PHP cURL functions</a> instead.');

} else {
$this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'You are running PHP 5.2 or greater, which makes allow_url_fopen significantly safer. Make sure allow_url_include is <em>disabled</em>, though');
}
}


}
}
Loading

0 comments on commit 346de40

Please sign in to comment.