#!/usr/bin/php . */ require(__DIR__.'/../site/mustard/include/mb_ucfirst.php'); define('N',"\n"); use function mysqli_real_escape_string as myesc; $inifp=__DIR__.'/../conf/mustard.ini'; $iniarr=@parse_ini_file($inifp) or mexit('Impossibile aprire il file di configurazione «'.$inifp.'»'.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 server MySQL: '.mysqli_connect_error().N,1); mysqli_set_charset($link,'utf8mb4') or mexit(mysqli_error($link).N,1); $localesfp='locales.json'; $locales=@file_get_contents($localesfp); if ($locales===false) mexit('Non ho potuto aprire il file «'.$localesfp.'».'.N,1); $locales=json_decode($locales,true); print_r($locales); //mexit('Ecco.'.N,1); foreach ($locales as $key=>$val) { $code=myesc($link,$key); $NameOrig=myesc($link,mb_ucfirst(locale_get_display_name($key,$key))); $NameCa=myesc($link,mb_ucfirst(locale_get_display_name($key,'ca'))); $NameEn=myesc($link,mb_ucfirst(locale_get_display_name($key,'en'))); $NameEs=myesc($link,mb_ucfirst(locale_get_display_name($key,'es'))); $NameFr=myesc($link,mb_ucfirst(locale_get_display_name($key,'fr'))); $NameIt=myesc($link,mb_ucfirst(locale_get_display_name($key,'it'))); $que='INSERT INTO Languages (ID, Code, NameOrig, NameCA, NameEN, NameES, NameFR, NameIT) VALUES (NULL, \''.$code.'\', \''.$NameOrig.'\', \''.$NameCa.'\', \''.$NameEn.'\', \''.$NameEs.'\', \''.$NameFr.'\', \''.$NameIt.'\')'; echo($que.N); mysqli_query($link,$que) or mexit(mysqli_error($link).N,2); } mysqli_close($link); exit(0); function mexit($msg,$rv) { global $link; if ($link) mysqli_close($link); echo($msg); exit($rv); } ?>