This commit is contained in:
kremsy 2017-04-16 16:41:30 +02:00
parent 653ee5b577
commit 01bc21e37b
6 changed files with 40 additions and 9 deletions

View File

@ -26,7 +26,7 @@ abstract class BackupUtil {
}
$time = date('y-m-d_H-i-s');
if(defined('PHP_UNIT_TEST')){
if (defined('PHP_UNIT_TEST')) {
$time = date('y-m-d_H-i');
}
@ -82,7 +82,7 @@ abstract class BackupUtil {
}
$useBaseFileNames = !empty($baseFileNames);
while (false !== ($file = readdir($folderHandle))) {
if (substr($file, 0, 1) === '.') {
if (FileUtil::isHiddenFile($file)) {
// Skip such .files
continue;
}

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Files;
use ManiaControl\Logger;
use ManiaControl\Utils\Formatter;
use ManiaControl\Utils\SystemUtil;
use ManiaControl\Utils\WebReader;
/**
@ -131,7 +130,7 @@ abstract class FileUtil {
foreach ($directories as $directory) {
$dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory);
foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) {
if (substr($fileName, 0, 1) === '.') {
if (self::isHiddenFile($fileName)) {
continue;
}
if (!is_writable($fileName)) {
@ -227,4 +226,14 @@ abstract class FileUtil {
return $className;
}
/**
* Checks if a File is Hidden
*
* @param $fileName
* @return bool
*/
public static function isHiddenFile($fileName) {
return (substr($fileName, 0, 1) === '.');
}
}

View File

@ -11,6 +11,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\Controls\Quads\Quad_UIConstructionBullet_Buttons;
use FML\ManiaLink;
use FML\Script\Features\Paging;
use ManiaControl\Files\FileUtil;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
@ -246,7 +247,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$mapFiles = array();
$dirFiles = scandir($directory);
foreach ($dirFiles as $fileName) {
if (substr($fileName, 0, 1) === '.') {
if (FileUtil::isHiddenFile($fileName)) {
continue;
}
$fullFileName = $directory . $fileName;

View File

@ -121,8 +121,8 @@ class PluginManager {
return false;
}
$reflector = new ReflectionClass($pluginClass);
$className = $pluginClass;
$reflector = new ReflectionClass($pluginClass);
$className = $pluginClass;
$splitNameSpace = explode('\\', $pluginClass);
if (is_array($splitNameSpace)) {
$className = end($splitNameSpace);
@ -297,7 +297,7 @@ class PluginManager {
}
$pluginFiles = scandir($directory);
foreach ($pluginFiles as $pluginFile) {
if (substr($pluginFile, 0, 1) === '.') {
if (FileUtil::isHiddenFile($pluginFile)) {
continue;
}

View File

@ -30,7 +30,7 @@ abstract class WebReader {
}
return $response;
}
/**
* Create a new cURL Request for the given URL
*

View File

@ -0,0 +1,21 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 16. Apr. 2017
* Time: 15:38
*/
use ManiaControl\Utils\SystemUtil;
class SystemUtilTest extends PHPUnit_Framework_TestCase {
public function testCheckRequirements() {
SystemUtil::checkRequirements();
$this->assertContains("Checking for minimum required PHP-Version 5.4", $this->getActualOutput());
$this->assertContains("Checking for installed MySQLi ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed cURL ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed PHP ZIP ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed Zlib ... FOUND!", $this->getActualOutput());
}
}