2020-10-13 08:21:26 +02:00
#!/usr/bin/php
< ? php
define ( 'N' , " \n " );
use function mysqli_real_escape_string as myesc ;
function mexit ( $msg , $code ) {
echo ( $msg );
exit ( $code );
}
2020-10-18 06:53:27 +02:00
$iniarr =@ parse_ini_file ( __DIR__ . '/../../conf/mustard.ini' )
2020-10-13 08:21:26 +02:00
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' );
2020-10-31 06:57:34 +01:00
mysqli_query ( $link , " ALTER TABLE `ZStats` ADD `HitsLang` VARCHAR(5000) NOT NULL AFTER `Hits`; " )
or mexit ( mysqli_error ( $link ) . N , 2 );
mysqli_query ( $link , " ALTER TABLE `ZStats` ADD `HitsPage` VARCHAR(5000) NOT NULL AFTER `HitsLang`; " )
or mexit ( mysqli_error ( $link ) . N , 2 );
$res = mysqli_query ( $link , " SELECT * FROM `ZStats` " )
or mexit ( mysqli_error ( $link ) . N , 2 );
$hlang ;
$hpage ;
while ( $row = mysqli_fetch_assoc ( $res )) {
$hlang = 'ca:' . $row [ 'HitsCa' ] . ';en:' . $row [ 'HitsEn' ] . ';es:' . $row [ 'HitsEs' ] . ';fr:' . $row [ 'HitsFr' ] . ';it:' . $row [ 'HitsIt' ];
$hpage = 'home:' . $row [ 'HitsHome' ] . ';inst:' . $row [ 'HitsInst' ] . ';about:' . $row [ 'HitsAbout' ] . ';stats:' . $row [ 'HitsStats' ] . ';contrib:' . $row [ 'HitsContrib' ] . ';404:' . $row [ 'Hits404' ];
mysqli_query ( $link , " UPDATE `ZStats` SET HitsLang=' " . $hlang . " ', HitsPage=' " . $hpage . " ' WHERE TS= " . $row [ 'TS' ]);
}
mysqli_query ( $link , " ALTER TABLE `ZStats` DROP `HitsCa`, DROP `HitsEn`, DROP `HitsEs`, DROP `HitsFr`, DROP `HitsIt`, DROP `HitsHome`, DROP `HitsInst`, DROP `HitsAbout`, DROP `HitsStats`, DROP `HitsContrib`, DROP `Hits404`; " )
or mexit ( mysqli_error ( $link ) . N , 2 );
2020-10-13 08:21:26 +02:00
mysqli_close ( $link );
exit ( 0 );
?>