32 lines
1.7 KiB
PHP
32 lines
1.7 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,"CREATE TABLE `mastostart`.`ZHits` ( `UID` CHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , `URL` VARCHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , `Lang` CHAR(2) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , `TS` INT UNSIGNED NOT NULL ) ENGINE = InnoDB")
|
|
or mexit(mysqli_error($link).N,2);
|
|
|
|
mysqli_query($link,"CREATE TABLE mastostart.`ZStats` (`TS` int(10) UNSIGNED NOT NULL, `Hits` int(10) UNSIGNED NOT NULL, `HitsCa` int(10) UNSIGNED NOT NULL, `HitsEn` int(10) UNSIGNED NOT NULL, `HitsEs` int(10) UNSIGNED NOT NULL, `HitsFr` int(10) UNSIGNED NOT NULL, `HitsIt` int(10) UNSIGNED NOT NULL, `HitsHome` int(10) UNSIGNED NOT NULL, `HitsInst` int(10) UNSIGNED NOT NULL, `HitsAbout` int(10) UNSIGNED NOT NULL, `HitsStats` int(10) UNSIGNED NOT NULL, `HitsTrans` int(10) UNSIGNED NOT NULL, `Hits404` int(10) UNSIGNED NOT NULL, `Visits` int(10) UNSIGNED NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;")
|
|
or mexit(mysqli_error($link).N,2);
|
|
|
|
mysqli_query($link,"GRANT SELECT, INSERT ON `mastostart`.`ZHits` TO 'MastoStartUser'@'localhost'")
|
|
or mexit(mysqli_error($link).N,2);
|
|
|
|
mysqli_close($link);
|
|
|
|
exit(0);
|
|
|
|
?>
|