42 lines
1.6 KiB
PHP
42 lines
1.6 KiB
PHP
#!/usr/bin/php
|
|
<?php
|
|
|
|
define('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');
|
|
|
|
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);
|
|
|
|
mysqli_close($link);
|
|
|
|
exit(0);
|
|
|
|
?>
|