To import old “Noxious” table dump into new Nox* columns “Instances”
This commit is contained in:
parent
d795e13e70
commit
64017b615a
1 changed files with 32 additions and 0 deletions
32
web/clitools/unatantum/setnoxreas.php
Normal file
32
web/clitools/unatantum/setnoxreas.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
const N="\n";
|
||||||
|
|
||||||
|
use function mysqli_real_escape_string as myesc;
|
||||||
|
|
||||||
|
function mexit($msg,$code) {
|
||||||
|
echo($msg);
|
||||||
|
exit($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$iniarr=@parse_ini_file(__DIR__.'/../../conf/mustard.ini')
|
||||||
|
or mexit('Impossibile aprire il file di configurazione.'.N,1);
|
||||||
|
$link=mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
|
||||||
|
or mexit('Impossibile connettersi al database: '.mysqli_connect_error().' ['.mysqli_connect_errno().']'.N,1);
|
||||||
|
mysqli_set_charset($link,'utf8mb4');
|
||||||
|
|
||||||
|
$dump=file('dump.txt',FILE_SKIP_EMPTY_LINES|FILE_IGNORE_NEW_LINES);
|
||||||
|
|
||||||
|
foreach ($dump as $rec) {
|
||||||
|
$rec=explode("\t",$rec);
|
||||||
|
mysqli_query($link,'UPDATE Instances SET NoxReason=\''.myesc($link,$rec[1]).'\', NoxLastModTS='.time().' WHERE URI=\''.myesc($link,$rec[0]).'\'');
|
||||||
|
$nrows=mysqli_affected_rows($link);
|
||||||
|
echo($rec[0].': '.$nrows.N);
|
||||||
|
}
|
||||||
|
|
||||||
|
mysqli_close($link);
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in a new issue