MastodonHelp/web/clitools/unatantum/UPDATE.php

32 lines
939 B
PHP
Raw Permalink Normal View History

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 07:33:40 +01:00
$res=mysqli_query($link,'SELECT * FROM ZStats');
2020-10-31 06:57:34 +01:00
$hpage;
while ($row=mysqli_fetch_assoc($res)) {
2020-11-01 09:05:03 +01:00
$hpage=preg_replace(array('#instancesancesances#','#contributeuteute#'),array('instances','contribute'),$row['HitsPage']);
echo($hpage.N);
2020-10-31 07:33:40 +01:00
mysqli_query($link,"UPDATE `ZStats` SET HitsPage='".$hpage."' WHERE TS=".$row['TS']);
2020-10-31 06:57:34 +01:00
}
2020-10-13 08:21:26 +02:00
mysqli_close($link);
exit(0);
?>