Skip to content

Instantly share code, notes, and snippets.

@vetleledaal
Created May 3, 2018 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vetleledaal/08bb1d0ba5a88d04e4f567bee64131be to your computer and use it in GitHub Desktop.
Save vetleledaal/08bb1d0ba5a88d04e4f567bee64131be to your computer and use it in GitHub Desktop.
<?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