$year["subcategory"], "year_posts_count" => $year["n"]); } file_put_contents("assets/json/anni_decisioni_costituzionali.json", json_encode($anni_decisioni_costituzionali, JSON_PRETTY_PRINT)); //echo "GENERATO: assets/json/anni_decisioni_costituzionali.json"; //DECISIONI COSTITUZIONALI } function login($username, $password) { ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 7); $username = strip_tags(str(strtolower(trim($username)))); $password = str(md5(DB_MD5_SALT.trim($password))); $login_user = mysqli_fetch_assoc(query("SELECT * FROM users WHERE user_login = '" . $username . "' AND user_pass = '" . $password . "' AND user_status = 1")); $ip = $_SERVER["HTTP_CF_CONNECTING_IP"] != "" ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"]; $user_agent = $_SERVER["HTTP_USER_AGENT"]; if($login_user["id"] > 0) { query("INSERT INTO `log` (`datetime`, `type`, `description`) VALUES (NOW(), 'user', 'LOGIN SUCCESS | usr: $username | ip: $ip | user agent: $user_agent')"); $_SESSION["user"] = $login_user; return true; } else { query("INSERT INTO `log` (`datetime`, `type`, `description`) VALUES (NOW(), 'user', 'LOGIN ERROR | usr: $username | psw: ".$_POST['password']." | ip: $ip | user agent: $user_agent')"); return false; } return false; } use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; function mailHtml($from = "noreply@giurcost.org", $dest, $subject, $message, $ccn = "", $viewport = "device-width", $send_or_output = "send", $include_template = false) { //Load Composer's autoloader require $_SERVER['DOCUMENT_ROOT'].'/assets/php/PHPMailer-6.8.1/vendor/autoload.php'; $body_width = $viewport == "device-width" || $viewport == "" ? 600 : $viewport; /* prima era 480 */ if($include_template == false) { $final_message = $message; } else { $final_message = '
'.$message.'
'; } query("INSERT INTO `log` (`datetime`, `type`, `description`) VALUES (NOW(), 'email', 'dest: $dest | subject: ".str($subject)." | message: ".str($message)."')"); if($send_or_output == "return") { return $final_message; } elseif($send_or_output == "send") { //$email_provider = ""; $email_provider = "privateemail"; $mail = new PHPMailer; if($email_provider == "privateemail") { $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = "mail.privateemail.com"; // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "mail2025Verzino$$$$$"; // SMTP password $mail->SMTPSecure = "ssl"; // Enable encryption, 'ssl' also accepted $mail->Port = 465; // TCP port to connect to $mail->CharSet = 'UTF-8'; $mail->AddReplyTo = $from; $mail->From = "[email protected]"; //$mail->FromName = "giurcost"; $mail->IsHTML(true); $mail->Subject = $subject; $dest = filter_var(trim($dest), FILTER_VALIDATE_EMAIL); $mail->AddAddress($dest); $mail->Body = $final_message; } elseif($email_provider == "sendinblue") { $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = "smtp-relay.sendinblue.com"; // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "6pwWJd70X1LQOaCz"; // SMTP NEW password $mail->SMTPSecure = "tls"; // Enable encryption, 'ssl' also accepted $mail->Port = 587; // TCP port to connect to $mail->CharSet = 'UTF-8'; $mail->From = "[email protected]"; $mail->FromName = "giurcost"; $mail->IsHTML(true); $mail->Subject = $subject; $dest = filter_var(trim($dest), FILTER_VALIDATE_EMAIL); $mail->AddAddress($dest); foreach(explode(",", $ccn) as $ccn_mail) $mail->AddBCC($ccn_mail); $mail->Body = $final_message; } else { $mail->CharSet = 'UTF-8'; $mail->From = "[email protected]"; $mail->FromName = "Giurcost"; $mail->IsHTML(true); $mail->Subject = $subject; $dest = filter_var(trim($dest), FILTER_VALIDATE_EMAIL); $mail->AddAddress($dest); foreach(explode(",", $ccn) as $ccn_mail) $mail->AddBCC($ccn_mail); $mail->Body = $final_message; } //print_r($mail); if(!$mail->Send()) { query("INSERT INTO `log` (`datetime`, `type`, `description`) VALUES (NOW(), 'email', 'SENT ERROR ".$mail->ErrorInfo." | dest: $dest | subject: ".str($subject)." | message: ".str($message)."')"); return false; //die("errore nella spedizione: ".$mail->ErrorInfo); } else { query("INSERT INTO `log` (`datetime`, `type`, `description`) VALUES (NOW(), 'email', 'SENT OK | dest: $dest | subject: ".str($subject)." | message: ".str($message)."')"); return true; //echo "Il messaggio di posta è stato inviato correttamente"; } } } function translate_with_libretranslate_OLD($text, $sourceLang, $targetLang) { // Avvia LibreTranslate in background con i modelli solo per it ed en // Aggiungi nohup e redirezione su /dev/null per evitare che blocchi l'esecuzione // Controlla se LibreTranslate è in esecuzione $processCheck = shell_exec("pgrep -f 'libretranslate --load-only it,en'"); if (!$processCheck) { // Avvia LibreTranslate in background con nohup e redirezione output exec("nohup libretranslate --load-only it,en > /dev/null 2>&1 &"); // Aspetta qualche secondo per dare tempo al server di avviarsi sleep(3); } // URL dell'istanza locale di LibreTranslate $apiUrl = "http://localhost:5000/translate"; // Parametri da inviare in JSON $data = [ 'q' => $text, 'source' => $sourceLang, 'target' => $targetLang ]; $ch = curl_init($apiUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { throw new Exception("Errore cURL: " . curl_error($ch)); } curl_close($ch); $json = json_decode($response, true); if (isset($json['error'])) { throw new Exception("Errore LibreTranslate: " . $json['error']); } return $json['translatedText'] ?? null; } function translate_with_libretranslate($text, $sourceLang, $targetLang) { // URL dell'istanza locale di LibreTranslate $apiUrl = "http://localhost:5000/translate"; // Creazione del file temporaneo per il payload JSON $temp_file = tempnam(sys_get_temp_dir(), 'libretranslate_'); $data = [ 'q' => $text, 'source' => $sourceLang, 'target' => $targetLang ]; // Scrivi il payload JSON nel file temporaneo file_put_contents($temp_file, json_encode($data)); // Imposta cURL per leggere il payload dal file temporaneo $ch = curl_init($apiUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($temp_file)); // Leggi il contenuto dal file curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Esegui la richiesta cURL $response = curl_exec($ch); if (curl_errno($ch)) { throw new Exception("Errore cURL: " . curl_error($ch)); } curl_close($ch); // Rimuovi il file temporaneo unlink($temp_file); // Decodifica la risposta JSON $json = json_decode($response, true); if (isset($json['error'])) { throw new Exception("Errore LibreTranslate: " . $json['error']); } // Ritorna il testo tradotto return $json['translatedText'] ?? null; } function translate_with_gemini_OLD($text, $sourceLang, $targetLang) { $gemini_api_key = "AIzaSyCpXnRQoEqPqg7Pj4JawBqnHkqty4g1jYY"; // Sostituisci con la tua API Key $translation_json = json_decode(die('curl -H "Content-Type: application/json" -d "{\"contents\":[{\"parts\":[{\"text\":\"Traduci il seguente HTML da ' . strtoupper($sourceLang) . ' a ' . strtoupper($targetLang) . ', usa un linguaggio formale e giuridico: \n\n'.$text.'\"}]}]}" -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key='.$gemini_api_key.'"'), true); //print_r($translation_json); $translated_text = $translation_json['candidates'][0]['content']['parts'][0]['text'] ?? null; $translated_text = str_replace(array('```html', '```'), '', $translated_text); return $translated_text; } function translate_with_gemini($text, $sourceLang, $targetLang) { $gemini_api_key = "AIzaSyCpXnRQoEqPqg7Pj4JawBqnHkqty4g1jYY"; // Sostituisci con la tua API Key //$gemini_model = 'gemini-1.5-flash-latest'; $gemini_model = 'gemini-flash-lite-latest'; // Creazione del file temporaneo per il payload JSON $temp_file = tempnam(sys_get_temp_dir(), 'gemini_'); $payload = [ "contents" => [ [ "parts" => [ [ "text" => "Traduci il seguente testo HTML in inglese. Mantieni la struttura e i tag HTML esattamente come nell'input, ma traduci solo il contenuto testuale. " . strtoupper($sourceLang) . " a " . strtoupper($targetLang) . ", usa un linguaggio formale e giuridico: \n\n" . $text ] ] ] ] ]; // Scrivi il payload JSON nel file temporaneo file_put_contents($temp_file, json_encode($payload)); // Esegui la richiesta CURL usando il file temporaneo $command = 'curl -H "Content-Type: application/json" -d @' . escapeshellarg($temp_file) .' -X POST "https://generativelanguage.googleapis.com/v1beta/models/'.$gemini_model.':generateContent?key=' . $gemini_api_key . '"'; //die($command); $translation_json = json_decode(shell_exec($command), true); // Rimuovi il file temporaneo unlink($temp_file); // Estrai il testo tradotto $translated_text = $translation_json['candidates'][0]['content']['parts'][0]['text'] ?? null; $translated_text = str_replace(array('```html', '```'), '', $translated_text); $translated_text = str_replace('Constitutional legitimacy review', 'Constitutional review', $translated_text); return $translated_text; } function send_push_notification($title, $message, $url = "", $test = "1") { $config = [ "onesignal_app_id" => "3ed08db6-6a9c-479f-aeb5-9717e2d5488c", "onesignal_api_key" => "os_v2_app_h3ii3ntktrdz7lvvs4l6fvkirr46j4fbrfyuxvvzihosmfynugggby6e2pj4bb5twpyjvteivgqc6lh26qdh2xhdmtegfoqeafbw4gy" ]; //print_r(func_get_args()); die(); if($test == "1") { $content = [ "app_id" => $config["onesignal_app_id"], "included_segments" => ["Total Subscriptions"], // Invia a tutti gli iscritti "filters" => [ ["field" => "tag", "key" => "test", "relation" => "=", "value" => "1"] ], "headings" => ["en" => $title], "contents" => ["en" => $message], ]; } else { $content = [ "app_id" => $config["onesignal_app_id"], "included_segments" => ["Total Subscriptions"], // Invia a tutti gli iscritti "headings" => ["en" => $title], "contents" => ["en" => $message], ]; } if ($url) { $content["url"] = $url; // Aggiunge il link se presente } $ch = curl_init("https://onesignal.com/api/v1/notifications"); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Authorization: Basic " . $config["onesignal_api_key"] ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($content)); $result = curl_exec($ch); curl_close($ch); return json_decode($result, true); } $ip = $_SERVER["HTTP_CF_CONNECTING_IP"] != "" ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"]; define("DB_MD5_SALT", "GiurCost.2021jio34j5903094"); $_POST = array_map('str', $_POST); $_GET = array_map('str', $_GET); $_SERVER['HTTP_REFERER'] = str($_SERVER['HTTP_REFERER']); $_SERVER['HTTP_USER_AGENT'] = str($_SERVER['HTTP_USER_AGENT']); */ //query("DELETE FROM `log` WHERE type = '404' AND description LIKE '%".str($_SERVER["REQUEST_URI"])."%'"); echo ""; if($op2 == "trVII" && $op3 = "Alta Corte Siciliana") { $res_post = query("SELECT * FROM `posts` WHERE status = 1 AND category = 'decisioni' AND subcategory = 'Alta Corte Siciliana' AND subcategory2 = 'trVII' AND original_html_file LIKE '%".$op4.".htm%'"); $post = mysqli_fetch_assoc($res_post); if((int)$post["id"] != 0) { $post_title = str_replace(array("Consulta Online - ", "/"), array("", " del "), $post_title); $post_description = unstr($post["description"]); $post_description = str_replace("http://www.giurcost.org/", "/", $post_description); $post_description = str_replace(array('
"; $log_values = json_encode(array("url" => str($_SERVER["REQUEST_URI"]), "referer" => str($_SERVER["HTTP_REFERER"]))); query("INSERT INTO log SET datetime = NOW(), type = '404', description = '".$log_values."'"); } } elseif($op2 == "Alta Corte siciliana") { if($op3 == "indicealtacorte") { ?>
Decisioni Alta Corte Siciliana
loadHTML(file_get_contents("contents/giurcost".$url)); $post_title = $d->getElementsByTagName('title')->item(0)->textContent; $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child){ $mock->appendChild($mock->importNode($child, true)); } $post_content = $mock->saveHTML(); $post_content = str_replace('
0) { ?>
LE DECISIONI DI COSTITUZIONALITÀ DEL PERIODO TRANSITORIO (1946-1956)
ALTA CORTE PER LA REGIONE SICILIANA



DECISIONI

Fonti normative

Istituzione dell'Alta Corte

Norme di attuazione

Costituzione della Repubblica
loadHTML(file_get_contents("contents/giurcost".$url)); $post_title = $d->getElementsByTagName('title')->item(0)->textContent; $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child){ $mock->appendChild($mock->importNode($child, true)); } $post_content = $mock->saveHTML(); $post_content = str_replace('
LE DECISIONI DI COSTITUZIONALITÀ DEL PERIODO TRANSITORIO (1946-1956)
".$term_value."", $post_content); } */ $post_title = str_replace(array("Consulta Online - ", "/"), array("", " del "), $post_title); $post_description = unstr($post["description"]); $post_description = str_replace("http://www.giurcost.org/", "/", $post_description); $post_description = str_replace(array(''), array(''), $post_description); ?>
str($_SERVER["REQUEST_URI"]), "referer" => str($_SERVER["HTTP_REFERER"]))); query("INSERT INTO log SET datetime = NOW(), type = '404', description = '".$log_values."'"); ?>

Articolo non trovato

0 && (int)$year_value <= 40) $year_value = "20" . $year_value; else $year_value = "19" . $year_value; } if($year_value != "") { $res_year_posts = query("SELECT *, STR_TO_DATE(datetime, '%d-%m-%Y') AS datetime_eng FROM `posts` WHERE status = 1 AND category = 'decisioni' AND subcategory = '$year_value' ORDER BY weight ASC, datetime_eng DESC, title ASC"); $year_posts_count = mysqli_num_rows($res_year_posts); $_META["title"] = "Lista decisioni ".$year_value; $_META["description"] = "Lista decisioni ".$year_value; ?>
Lista decisioni ""
(.*?)

|', unstr($post["description"]), $output); if(strlen($output[1][0]) <= 2) preg_match_all('|

(.*?)

|', unstr($post["description"]), $output); //print_r($output[1]); $new_post_title = strip_tags(trim(ucfirst(strtolower($output[1][0])), " \n\r")); if($new_post_title != " ") { echo("UPDATE posts SET title = '$new_post_title' WHERE original_html_file LIKE '%$original_html_file%' AND subcategory = '$year_value';"); } }*/ ob_start(); $is_ordinanze_amicus_curiae = $is_ordinanze_dibattimentale = $is_ordinanze_normali = false; if(stripos($post["title"], "amicus curiae") !== FALSE) $is_ordinanze_amicus_curiae = true; elseif(stripos($post["title"], "dibattimentale") !== FALSE) $is_ordinanze_dibattimentale = true; else $is_ordinanze_normali = true; if( $is_ordinanze_normali && ($i % 100 == 0 || $i == 0) ) { ?>

'; if($is_ordinanze_amicus_curiae) $html_ordinanze_amicus_curiae .= ob_get_clean(); elseif($is_ordinanze_dibattimentale) $html_ordinanze_dibattimentale .= ob_get_clean(); else $html_ordinanze_normali .= ob_get_clean(); } echo "
".$html_ordinanze_normali."
"; echo "
"; if($html_ordinanze_amicus_curiae != "") echo "

".$html_ordinanze_amicus_curiae."
"; if($html_ordinanze_dibattimentale != "") echo "

".$html_ordinanze_dibattimentale."
"; ?>
Ricerca cronologica delle decisioni
$year_info) { //die("$year_folder/*.html"); $year_posts_count = $year_info["year_posts_count"]; $year_value = $year_info["year"]; if($year_info["year"] != "Alta Corte Siciliana") { ?>
'; } //include("assets/html/cartelle_anni_decisioni_costituzionali.html"); ?>
= 56) $year_value = "19" . $year_value; else $year_value = "20" . $year_value; Header( "HTTP/1.1 301 Moved Permanently" ); header("location: /decisioni/cron.html?anno=$year_value"); } elseif(strlen($op2) == 4) // ANNO /decisioni/cron.html?anno=2021 { $year_value = $op2; ?>
loadHTML(file_get_contents("contents/giurcost".$url)); $post_title = $d->getElementsByTagName('title')->item(0)->textContent; $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child){ $mock->appendChild($mock->importNode($child, true)); } $post_content = $mock->saveHTML(); $post_content = str_replace('
= 3) { $terms_values_cleaned[] = $term_value; } } $terms_values = $terms_values_cleaned; } else { $terms_values = $terms_values_cleaned = array_filter(explode(" ", $search_terms)); } $search_terms = " ".implode(" ", $terms_values_cleaned)." "; } ?>
Ricerca testuale


Racchiudendo fra doppi apici una frase si ottengono tutte le pagine che contengono la frase mantenendo lo stesso ordine della sequenza cercata

    Risultati per: ".htmlentities(strtolower(strip_tags($_GET["terms"])))." (tutti gli anni)


    "; else echo "

    Risultati per: ".htmlentities(strtolower(strip_tags($_GET["terms"])))." (anno ".$selected_year.")



    "; $total_posts_found_count = $total_strings_found_count = 0; $qry_year = ($selected_year == "*") ? " AND TRUE " : " AND subcategory = '".$selected_year."'"; //if(isset($_GET["debug"])) { die(unstr($_GET["terms"])); } $search_entire_sentence = substr(unstr($_GET["terms"]), 0, 1) == '"' && substr(unstr($_GET["terms"]), -1, 1) == '"'; if($search_entire_sentence) /* ricerca con apici all'inizio e fine */ { //if(isset($_GET["debug"])) die("search_entire_sentence"); $search_terms = trim(strtolower(strip_tags($_GET["terms"])), "“ "); $qry_search_posts = " SELECT id, subcategory, title, description_text, original_html_file, description_text LIKE '%".trim($search_terms)."%' AS strings_found_count FROM `posts` WHERE status = 1 AND category = 'decisioni' $qry_year HAVING strings_found_count > 0 ORDER BY strings_found_count DESC LIMIT ".(($current_page_number - 1) * $posts_per_page) .", $posts_per_page"; //if(isset($_GET["debug"])) die($qry_search_posts); } else { if(true) //if(isset($_GET["new"])) { $qry_search_posts = " SELECT * FROM ( SELECT id, subcategory, title, description_text, original_html_file, MATCH (description_text) AGAINST ('".trim($search_terms)."' IN BOOLEAN MODE) AS score, (CHAR_LENGTH(description_text) - CHAR_LENGTH(REPLACE(description_text, '".trim($search_terms)."', ''))) / CHAR_LENGTH('".trim($search_terms)."') AS strings_found_count FROM `posts` WHERE status = 1 AND category = 'decisioni' $qry_year AND MATCH(description_text) AGAINST('".str_replace(" ", " +", rtrim($search_terms))."' IN BOOLEAN MODE) ORDER BY strings_found_count DESC, score DESC LIMIT ". (($current_page_number - 1) * $posts_per_page) .", $posts_per_page ) AS main "; } else { $qry_search_posts = " SELECT id, subcategory, title, description_text, original_html_file, MATCH (description_text) AGAINST ('".str_replace(" ", " +", rtrim($search_terms))."' IN BOOLEAN MODE) AS score FROM `posts` WHERE status = 1 AND category = 'decisioni' $qry_year AND MATCH(description_text) AGAINST('".str_replace(" ", " +", rtrim($search_terms))."' IN BOOLEAN MODE) ORDER BY score DESC LIMIT ".(($current_page_number - 1) * $posts_per_page) .", $posts_per_page"; } } $res_search_posts = query($qry_search_posts); //echo "".$qry_search_posts.""; if((int)$_SESSION["user"]["id"] > 0) { echo "".$qry_search_posts.""; } //print_r($res_search_posts); die(); while($post = mysqli_fetch_assoc($res_search_posts)) { $strings_found_count = 0; $strings_found = null; if($total_posts_found_count <= $posts_per_page) { $post_year = $post["subcategory"]; $post_content = $post["description_text"]; //die($post_content); $post_title = str_replace("/", " del ", $post["title"]); $original_html_file = end(explode("/", $post["original_html_file"])); //if(isset($_GET["debug"])) { print_r($strings_found); die(); } if($search_entire_sentence) /* ricerca con apici all'inizio e fine */ { $search_position = stripos($post_content, $search_terms); $strings_found_count = substr_count(strtolower($post_content), strtolower($search_terms)); $total_strings_found_count += $strings_found_count; $post_content_small = "[...] ". substr($post_content, $search_position - 10, 200)." [...] "; $post_content_small = str_ireplace($search_terms, "".$search_terms."", $post_content_small); } else { foreach($terms_values as $term_value) { //die($term_value.", ".$post_content); $strings_found[] = stripos(strtolower($post_content), $term_value); //preg_match('#\b('.$terms_values.')\b#', $post_content); $strings_found_count += substr_count(strtolower($post_content), strtolower($search_terms)); } $total_strings_found_count += $strings_found_count; $search_position = $strings_found; //stripos($post_content, $first_term); $post_content_small = "[...] ". substr($post_content, $strings_found[0] - 10, 200)." [...] "; if(strlen($terms_values[0]) >= 3) $post_content_small = str_ireplace($terms_values[0], "".$terms_values[0]."", $post_content_small); if(strlen($terms_values[1]) >= 3) $post_content_small = str_ireplace($terms_values[1], "".$terms_values[1]."", $post_content_small); if(strlen($terms_values[2]) >= 3) $post_content_small = str_ireplace($terms_values[2], "".$terms_values[2]."", $post_content_small); } //$post_content_small = substr($post_content, 0, 300); ?>