Created
May 3, 2018 16:46
-
-
Save vetleledaal/08bb1d0ba5a88d04e4f567bee64131be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db_text = file_get_contents('DB.csv'); | |
$table = []; | |
foreach(explode("\n", $db_text) as $line) { | |
if(strlen($line) != 0) { | |
$table[] = explode('|', $line); | |
} | |
} | |
$c = 0; | |
$errors = ''; | |
foreach($table as $row) { | |
foreach($row as $k => $dir) { | |
if($k < 3 || $k % 2 == 0) continue; | |
if( | |
preg_match('/^\[.*\]$/', $dir, $m) === 0 && | |
preg_match('/^\[.*\]$/', $row[$k + 1], $m) === 0 && | |
preg_match('/([^\/]+)\/(?!.*\/)(.*)/', $dir, $m) === 1 | |
) { | |
$dirL = $m[1]; | |
$dirR = $m[2]; | |
$dirL = str_replace(['$STEAMAPPS', '$STEAMUSER'], [$row[2], '76000000000000000'], $dirL); | |
$dirR = str_replace(['$STEAMAPPS', '$STEAMUSER'], [$row[2], '76000000000000000'], $dirR); | |
if( | |
$row[$k + 1] != $dirL && | |
$row[$k + 1] != $dirR && | |
$row[$k + 1] != ($dirL . '/' . $dirR) | |
) { | |
$c++; | |
$errors .= '// AppID: ' . $row[0] . ', column ' . chr(ord('A') + $k + 1) . PHP_EOL . | |
'"' . $row[$k + 1] . '" != "' . $dirL . '"' . PHP_EOL . | |
'"' . $row[$k + 1] . '" != "' . $dirR . '"' . PHP_EOL . PHP_EOL; | |
} | |
} | |
} | |
} | |
echo $errors; | |
echo 'Inconsistencies found: ' . $c . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment