ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require_once 'include/language_handler.inc';
require_once 'include/db_handler.inc';
require_once 'include/mixed_include.inc';
require_once 'include/class.parola.inc';
$conversions = array(
'a' => array("á", "ä", "à", "â", "Á", "Ä", "À", "Â"),
'e' => array("é", "ë", "è", "ê", "É", "Ë", "È", "Ê"),
'i' => array("í", "ï", "ì", "î", "Í", "Ï", "Ì", "Î"),
'o' => array("ó", "ö", "ò", "ô", "Ó", "Ö", "Ò", "Ô"),
'u' => array("ú", "ü", "ù", "û", "Ú", "Ü", "Ù", "Û"),
'' => array(' ', '\t', '\n')
);
$AUDIOPLAY_TEMPLATE3 = '
';
//';
$nome = $_REQUEST['nome_spec'] ?? "";
/*
$categoria = $_REQUEST['cat'];
$cat_id = $_REQUEST['cat_id'];
$show_categories = strlen($_REQUEST['show_categories']) > 0 && $_REQUEST['show_categories'] == "true";
*/
// Uso l'operatore ?? (null coalesce) che assegna un valore vuoto se il parametro non esiste nell'URL
$categoria = $_REQUEST['cat'] ?? "";
$cat_id = $_REQUEST['cat_id'] ?? "";
// Per la riga 32, controlliamo prima se esiste 'show_categories' per evitare l'errore su strlen
$show_categories = isset($_REQUEST['show_categories']) && strlen($_REQUEST['show_categories']) > 0 && $_REQUEST['show_categories'] == "true";
if($dict_lang == $lang && $dict_lang == 'it') {
$trad_lang = 'en';
}
else {
//$trad_lang = $dict_lang;
$trad_lang = $lang;
}
// metadescription generica
$_metadesc = (isset($nome) ? "{$nome} - " : "") . $output["metadescription"];
// metaurl generica
$_metaurl = "https://" . $_SERVER['SERVER_NAME'] . "/" . $dict_lang . "/"; // URL base
$_is_casuale = false;
$_is_suggest = false;
// tags
$tags = ORM::for_table('tags', 't', array("tag", "ID"))
->from_cache()
->join("traduzioni_tags", "t.ID = tt.ID AND tt.lingua = '{$lang}'", 'tt', array("label"))
->order_by_asc('tt.label')
->limit(15)
->find_many();
$tags_code = "
";
ob_start();
if (strlen($nome) > 0) {
// CODE DELETED 3
if ($nome == '_casuale'):
$possibilita = ORM::for_table('parole')
->where('lingua', $dict_lang)
->order_by_asc('RAND()')
->limit(5)
->find_many();
$_is_casuale = true; else:
if (strlen($nome) > 0) {
$possibilita = ORM::for_table('parole')->where_raw("lingua = '{$dict_lang}' AND label = LOWER(TRIM('{$nome}'))", array())->find_many();
}
endif;
ini_set('memory_limit', '128M');
if (is_array($possibilita)) {
if (count($possibilita) == 0 && strlen($nome) > 0) {
// provo a tradurre la parola e ritentare la ricerca...
// CODE DELETED 1
$traduzioni = ORM::for_table('dizionario', 'd', array("parola", "traduzione",'time_stamp'))
->from_cache()
->join("parole", "d.parola = p.ID AND d.lingua = '{$lang}' AND d.traduzione = '{$nome}'", 'p', array("name"))
->order_by_asc('p.name')
->limit(15)
->find_many();
if (is_array($traduzioni) && count($traduzioni) > 0) {
// abbiamo una traduzione: cerchiamo!
$traduzione = $traduzioni[0];
$possibilita = ORM::for_table('parole')
->where_raw("lingua = '{$dict_lang}' AND label = LOWER(TRIM('{$traduzione->name}'))", array())
->find_many();
}
if (!is_array($possibilita) || count($possibilita) == 0) {
// nulla! cerco parole simili...
$possibilita = search_dictionary_lev(array($nome), $from = $dict_lang, 5);
if (count($possibilita) > 0) {
$_suggest = getLanguageKey("suggest", "forse cercavi");
$_is_suggest = true;
} else {
// NULLA! mi arrendo...
$_suggest = "-{" . getLanguageKey("no_match_found", "nessun risultato trovato") . "]}
";
}
} else if(is_object($traduzione)) {
// ho trovato dei risultati con la traduzione: informo l'utente che ho tradotto la sua parola...
echo "'{$traduzione->name}' " . getLanguageKey("translation_means", "means") . " '{$nome}' " . getLanguageKey("translation_in", "in italian") . "
";
}
} else {
// la ricerca ha prodotto risultati: controllo se devo ridirigere per ottenere un URL corretto
if (isset($_POST['nome_spec']) && $_GET['nome_spec'] != $_POST['nome_spec']) {
// vengo da un post: ridirigo per avere il token della parola nell'indirizzo
header("location: https://{$_SERVER['SERVER_NAME']}/{$dict_lang}/{$nome}");
}
}
?>
if (count($possibilita) == 1) {
// una sola parola...
// compongo una metadescription specifica
$poss = $possibilita[0];
$_metadesc = "{$poss->label} [{$poss->hypen}] {$poss->IPA}. " . getLanguageKey("metadescription_frase_1", "Learn Italian pronunciation and translation online") . ". " . getLanguageKey("metadescription_frase_2", "How to say") . ": {{$poss->label}}";
$_metaurl = $_metaurl . $poss->label;
//$oParola = new Parola($poss->ID);
$traduzioni =
ORM::for_table('dizionario', 'd', array("parola", "traduzione",'time_stamp'))
->from_cache()
->join("parole", "d.parola = p.ID AND d.lingua = '{$trad_lang}'", 'p', array("name"))
->where('d.parola',$poss->ID)
->order_by_asc('p.name')
->limit(15)
->find_many();
}
foreach ($possibilita as $poss) {
// SPOSTA QUI LA CREAZIONE DELL'OGGETTO
$oParola = new Parola($poss->ID);
$traduzioni =
ORM::for_table('dizionario', 'd', array("parola", "traduzione",'time_stamp'))
->from_cache()
->join("parole", "d.parola = p.ID AND d.lingua = '{$trad_lang}'", 'p', array("name"))
->where('d.parola',$poss->ID)
->order_by_asc('p.name')
->limit(15)
->find_many();
?>
if (!$_is_casuale && !$_is_suggest) {
echo str_ireplace(array('#ID#', '#FILE_NAME#'), array($poss->ID, $poss->name), $AUDIOPLAY_TEMPLATE3);
} ?>
if ($_is_casuale || $_is_suggest) { ?>
} ?> if ($_is_casuale || $_is_suggest) { ?> } ?>
if (strlen($poss->hypen) > 0): ?>
[] endif; ?>
if (strlen($poss->IPA) > 0): ?>
// endif; ?>
if(is_array($traduzioni) && count($traduzioni) > 0) {
echo "";
foreach($traduzioni as $traduzione) { ?>
}
echo "
";
} ?>
if (is_object($oParola) && is_array($oParola->sinonimi) && count($oParola->sinonimi) > 0) { ?>