mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* allow overwriting generic/fine log output * fix some errors * can't catch notices generated by mysqli_connect * removed some unnessecary ORDER from querys
69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
if (!CLI)
|
|
die('not in cli mode');
|
|
|
|
function soundfiles()
|
|
{
|
|
$ok = true;
|
|
|
|
// ALL files
|
|
$files = DB::Aowow()->selectCol('SELECT ABS(id) AS ARRAY_KEY, CONCAT(path, "/", `file`) FROM ?_sounds_files');
|
|
$nFiles = count($files);
|
|
$qtLen = strlen($nFiles);
|
|
$sum = 0;
|
|
|
|
$intv = 0.5;
|
|
$time = microtime(true);
|
|
$sum = 0;
|
|
|
|
foreach ($files as $fileId => $filePath)
|
|
{
|
|
$sum++;
|
|
$newTime = microtime(true);
|
|
if ($newTime > $time + $intv)
|
|
{
|
|
CLI::write(sprintf(' * %'.$qtLen.'d / %d (%4.1f%%)', $sum, $nFiles, round(100 * $sum / $nFiles, 1)), CLI::LOG_BLANK, true, true);
|
|
$time = $newTime;
|
|
DB::Aowow()->selectCell('SELECT 1'); // keep mysql busy or it may go away
|
|
}
|
|
|
|
// expect converted files as file.wav_ or file.mp3_
|
|
$filePath .= '_';
|
|
|
|
// just use the first locale available .. there is no support for multiple audio files anyway
|
|
foreach (CLISetup::$expectedPaths as $locStr => $__)
|
|
{
|
|
// get your paths straight!
|
|
$p = CLI::nicePath($filePath, CLISetup::$srcDir, $locStr);
|
|
|
|
if (CLISetup::fileExists($p))
|
|
{
|
|
// copy over to static/wowsounds/
|
|
if (!copy($p, 'static/wowsounds/'.$fileId))
|
|
{
|
|
$ok = false;
|
|
CLI::write(' - could not copy '.CLI::bold($p).' into '.CLI::bold('static/wowsounds/'.$fileId), CLI::LOG_ERROR);
|
|
$time = 0;
|
|
break 2;
|
|
}
|
|
|
|
continue 2;
|
|
}
|
|
}
|
|
|
|
CLI::write(' - did not find file: '.CLI::bold(CLI::nicePath($filePath, CLISetup::$srcDir, '['.implode(',', CLISetup::$locales).']')), CLI::LOG_WARN);
|
|
$time = 0;
|
|
// flag as unusable in DB
|
|
DB::Aowow()->query('UPDATE ?_sounds_files SET id = ?d WHERE ABS(id) = ?d', -$fileId, $fileId);
|
|
}
|
|
|
|
return $ok;
|
|
}
|
|
|
|
?>
|
|
|