Case insensitive array_diff for files, test on windows

This commit is contained in:
color.diff=auto 2021-03-28 00:33:15 -06:00
parent ce01b0e602
commit f7e3fe9560
3 changed files with 5 additions and 7 deletions

View File

@ -3,7 +3,6 @@
// have been created. Config writes active mod to session.
session_start();
include "./_pdo.php";
function processCubeMain(){
@ -36,19 +35,18 @@ if (file_exists("d2im.db")) {
$parser = new D2TxtParser();
$db = new D2Database();
$data = null;
// Parse all files
foreach ($files->files as $k => $v) {
$data[$v] = $parser->parseFile($v);
}
// Write all parse data to mod db
foreach ($data as $k => $v) {
$db->createTables($k, $v);
$db->fillsTables($k, $v);
}
unset($data);
processCubeMain('cubemain.txt');
// put in html redirect as backup, because
// for some odd reason windows gives

View File

@ -74,7 +74,7 @@ ERROR: INVALID PATH</h1></center>';
$path = $_POST['path'];
$path = rtrim($_POST['path'], "/");
$path = $path . DIRECTORY_SEPARATOR;
if (!is_dir($path)) {
echo '<center><h1 style="font-family:Lato; color:#880000;"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
ERROR: INVALID PATH</h1></center>';

View File

@ -29,9 +29,9 @@ class D2Files {
];
$glob = glob($_SESSION['path'].'*.txt');
foreach ($glob as $g){
$files[] = strtolower(basename($g));
$files[] = basename($g);
}
$this->files = array_diff($files, $filesToIgnore);
$this->files = array_udiff($files, $filesToIgnore, 'strcasecmp');
return $this->files;
}
}