$val) { if(substr($key,0,5)=="Form_") $$key=$val; } /* 20091109 nexus PROBLEMA 1: Se si fa una ricerca scegliendo solo un argomento o solo un'area tematica d� errore "Devi compilare almeno un campo". PROBLEMA 2: Se nella ricerca avanzata non era compilato il campo "ricerca nel testo" dava sempre errore "La ricerca viene effettuata solo per parole con almeno tre caratteri" quindi ho cercato di risolvere in modo artigianale, ma pare funzioni. */ if (($_REQUEST["type_search"]=="simple" && strlen($Form_search_submitter)<3) || ($_REQUEST["type_search"]!="simple" && $_REQUEST["Form_search_d"]=="" && $_REQUEST["Form_search_m"]=="" && $_REQUEST["Form_search_y"]=="" && $_REQUEST["Form_search_numero"]=="" && $_REQUEST["Form_search_natura"]=="" && $_REQUEST["Form_search_autore"]=="" && $_REQUEST["Form_search_argomento"]=="" && $_REQUEST["Form_search_area"]=="" && $_REQUEST["Form_search_nazione"]=="" && strlen($Form_search_testo)<3)) { echo "

".$txt['research']."

"; return false; } $where_clause=""; $criteria=""; if ($_GET["type_search"]=="simple") { $Form_search_news=$Form_search_aree=$Form_search_riviste=$Form_search_libri="S"; } /**************************************/ /* DOCUMENTI */ /**************************************/ //NATURA if ($Form_search_natura) { $where_clause.=" AND t1.id_natura='".$Form_search_natura."'"; $tres=db_exec("SELECT natura FROM nature WHERE id='".$Form_search_natura."'"); if (!$tres) { echo strtoupper($txt['natura'])."
"; db_error($query); } $natura=""; if (db_numrows($tres)) { $natura=db_result($tres,0,"natura"); $criteria.="".$txt['natura'].": ".$natura."
"; array_push($hkws,$natura); } } //NUMERO if ($Form_search_numero) { $where_clause.=($where_clause?" AND ":" AND ")." t1.numero='".$Form_search_numero."'"; $criteria.="".$txt['numero'].": ".$Form_search_numero."
"; array_push($hkws,$Form_search_numero); } //DATA if ($Form_search_d) { $where_clause.=($where_clause?" AND ":" AND ")." DAYOFMONTH(t1.data)='".$Form_search_d."'"; $criteria.="".$txt['giorno'].": ".$Form_search_d."
"; array_push($hkws,$Form_search_d); } if ($Form_search_m) { $month=strftime("%B",mktime(0,0,0,$Form_search_m,1,2001)); $where_clause.=($where_clause?" AND ":" AND ")." MONTH(t1.data)='".$Form_search_m."'"; $criteria.="".$txt['mese'].": ".$month."
"; array_push($hkws,$month); } if ($Form_search_y) { $where_clause.=($where_clause?" AND ":" AND ")." YEAR(t1.data)='".$Form_search_y."'"; $criteria.="".$txt['anno'].": ".$Form_search_y."
"; array_push($hkws,$Form_search_y); } //AUTORE if ($Form_search_autore) { //$where_clause.=($where_clause?" AND ":" ")." da.autore LIKE '%".$Form_search_autore."%'"; $where_clause.=" AND da.id='".intval($Form_search_autore)."'"; $tres=db_exec("SELECT autore FROM documenti_autori WHERE id='".intval($Form_search_autore)."'"); if (!$tres) { echo strtoupper($txt['autore'])."
"; db_error($query); } $autore=""; if (db_numrows($tres)) { $autore=db_result($tres,0,"autore"); $criteria.="".$txt['autore'].": ".$autore."
"; array_push($hkws,$autore); } } //ARGOMENTO if ($Form_search_argomento) { //QUIIIIIIII //Descrizione argomento //$where_clause.=($where_clause?" AND ":" ")." t1.id_categoria='".$Form_search_argomento."'"; $tres=db_exec("SELECT titolo FROM categorie WHERE id='".intval($Form_search_argomento)."'"); if (!$tres) { echo strtoupper($txt['argomento'])."
"; db_error($query); } if (db_numrows($tres)) { $argomento=db_result($tres,0,"titolo"); $criteria.="".$txt['argomento'].": ".$argomento; array_push($hkws,$argomento); } $catlist=array (); array_push($catlist,$Form_search_argomento); if ($Form_search_sottocat=="S") { Get_Categorie ($catlist,$Form_search_argomento); $criteria.=" + ".$txt['sottoArgomenti']; } $criteria.="
"; /*$where_clause.=($where_clause?" AND ":" ")." t2.id IN ("; while(list($var,$val)=each($catlist)) { $where_clause.=$val.","; } $where_clause=substr($where_clause,0,-1).")";*/ } //AREA TEMATICA if ($Form_search_area) { //Descrizione area ($where_clause?" AND ":" ") $where_clause.= " AND t1.id_area='".intval($Form_search_area)."'"; $tres=db_exec("SELECT titolo FROM aree WHERE id='".intval($Form_search_area)."'"); if (!$tres) { echo "DOSSIER
"; db_error($query); } if (db_numrows($tres)) { $area=db_result($tres,0,"titolo"); $criteria.="dossier: ".$area; array_push($hkws,$area); } $areelist=array (); array_push($areelist,$Form_search_area); if ($Form_search_sottoaree=="S") { Get_Aree ($areelist,$Form_search_area); $criteria.=" + ".$txt['sottoAree']; } $criteria.="
"; /*$where_clause.=($where_clause?" AND ":" ")." t4.id IN ("; while(list($var,$val)=each($areelist)) { $where_clause.=$val.","; } $where_clause=substr($where_clause,0,-1).")";*/ } //NAZIONE if ($Form_search_nazione) { //($where_clause?" AND ":" ") $where_clause.=" AND n.nazione LIKE '%".$Form_search_nazione."%'"; $criteria.="".$txt['nazione'].": ".$Form_search_nazione."
"; array_push($hkws,$Form_search_nazione); } if ($Form_search_submitter || $Form_search_testo) { $search_keys=1; if ($Form_search_submitter) { $Form_search_submitter = trim(preg_replace("/[[:blank:]]+/"," ",$Form_search_submitter)); $words=explode(" ",$Form_search_submitter); array_push($hkws,$Form_search_submitter); } elseif ($Form_search_testo) { $Form_search_testo = trim(preg_replace("/[[:blank:]]+/"," ",$Form_search_testo)); $words=explode(" ",$Form_search_testo); array_push($hkws,$Form_search_testo); } //parole chiave $words_key=$words; //while ( list($key,$word) = each($words)) { //$dbquery="SELECT distinct doc_id FROM keywords WHERE keyword LIKE '".$word."'"; //RECUPERA DOCS PER KEYWORDS E LE STORA IN UN ARRAY DEDICATO $documenti=array(); $docs_index = array(); //INDICE DOCS PER DATA $dbquery = "SELECT t1.id, t1.data, t1.numero, t1.tipo, t1.testata, t1.id_categoria, t1.abstract_it, t3.natura natura,t3.natura_eng natura_eng, da.autore, n.nazione FROM keywords k LEFT JOIN documenti as t1 ON k.doc_id = t1.id LEFT JOIN nature t3 ON t1.id_natura=t3.id LEFT JOIN documenti_autori da ON t1.id_autore=da.id LEFT JOIN nazioni n ON t1.id_nazione=n.id WHERE keyword LIKE '".implode("' OR keyword LIKE '", __::map($words, function($w){ return $w; }))."'"; $res=db_exec($dbquery); if (!$res) { echo "KEYWORDS
"; db_error($dbquery); } while ($row=db_FetchArray($res)) { $documenti[$row["id"]] = $row; $docs_index[$row["id"]] = $row["data"]; //$docsres[$row["doc_id"]]++; } } /* $nr_words=count($words); $ids="-1"; while ( list($key,$val) = each($docsres) ) { if ($val==$nr_words) $ids.=",$key"; } $where_clause.=($where_clause?" AND ":" ")." (t1.id IN (".$ids.") ";*/ //RICERCA PAROLE IN AND $first=true; while (list($key,$word_key) = each($words_key)) { if ($first) { //$where_clause.=" OR ("." parole_chiave".(($lang == 'ita')?"":"_eng")." LIKE '%".trim($word_key)."%' "; $where_clause.=" AND (("." parole_chiave".(($lang == 'ita')?"":"_eng")." LIKE '%".trim($word_key)."%' "; $first=false; continue; } $where_clause.=($where_clause?" AND ":" ")." parole_chiave".(($lang == 'ita')?"":"_eng")." LIKE '%".trim($word_key)."%'"; } if (!$first) $where_clause.=")"; $where_clause.=")"; $criteria.="".$txt['testo_ricerca_eng'].": ".$Form_search_submitter.$Form_search_testo."
"; } if (!$where_clause) { $numrows=0; } else { $where_clause .= " AND t1.stato = 'A'"; /*$dbquery="SELECT t1.*, t3.natura natura, da.autore, n.nazione FROM documenti as t1 LEFT JOIN categorie as t2 ON t1.id_categoria=t2.id LEFT JOIN nature t3 ON t1.id_natura=t3.id LEFT JOIN aree t4 ON t1.id_area=t4.id LEFT JOIN documenti_autori da ON t1.id_autore=da.id LEFT JOIN nazioni n ON t1.id_nazione=n.id WHERE ".$where_clause." ORDER BY t1.data DESC";*/ $dbquery="SELECT t1.id, t1.data, t1.numero, t1.tipo, t1.testata, t1.id_categoria, t1.abstract_it, t3.natura natura,t3.natura_eng natura_eng, da.autore, n.nazione FROM documenti as t1 LEFT JOIN nature t3 ON t1.id_natura=t3.id LEFT JOIN documenti_autori da ON t1.id_autore=da.id LEFT JOIN nazioni n ON t1.id_nazione=n.id WHERE 1 ".$where_clause." ORDER BY t1.data DESC"; //echo $dbquery; //$res=db_exec($dbquery); /*$numrows=db_numrows($res); if ($numrows && $res2sw=="") $res2sw="doc";*/ } //FILTRO AREE if ($Form_search_area) { $filtra_aree=array(); $a_query="SELECT * FROM documenti_aree WHERE id_area IN(".implode(",",$areelist).")"; $a_res=db_Exec($a_query); if (mysql_error()) { echo "DOSSIER FILTER
"; echo mysql_error(); } while ($a_row=db_FetchArray($a_res)) array_push($filtra_aree,$a_row["id_documento"]); } //FILTRO CATEGORIE if ($Form_search_argomento) { $filra_args=array(); $a_query="SELECT * FROM documenti_categorie WHERE id_categoria IN (".implode(",",$catlist).")"; $a_res=db_Exec($a_query); if (mysql_error()) { echo "CATEGORIE FILTER
"; echo mysql_error(); echo $a_query; } while ($a_row=db_FetchArray($a_res)) array_push($filra_args,$a_row["id_documento"]); } //FILTRA DOCUMENTI $doc_num=0; if ($where_clause) { $res=db_Exec($dbquery); //echo ""; while ($row=db_FetchArray($res)) { if ($Form_search_area && !in_array($row["id"],$filtra_aree)) continue; if ($Form_search_argomento && !in_array($row["id"],$filra_args)) continue; //if (!in_array($row["id"], $ids_keys)); // continue; //array_push($documenti,$row); $documenti[$row["id"]] = $row; $docs_index[$row["id"]] = $row["data"]; //$doc_num++; } //ORDINA DOC PER DATA arsort($docs_index); $doc_num = count($docs_index); } if ($doc_num && $res2sw=="") $res2sw="doc"; ////////////////////////////// // ESTENSIONE RICERCA // ////////////////////////////// $ext_seacrh=false; if ($Form_search_news || $Form_search_aree || $Form_search_riviste || $Form_search_libri) { $criteria.="".$txt['research_extended'].":"; $ext_seacrh=true; } // NEWS if ($Form_search_news && sizeof($words)) { $criteria.=" News,"; $news_query="SELECT n.* FROM news n WHERE n.online='S' AND n.deleted!='S' "; reset ($words); while (list($key,$word) = each($words)) { $news_query.="AND MATCH (titolo,testo) AGAINST ('".strtolower($word)."') "; } $news_query.=" ORDER BY n.data DESC,n.id DESC "; $news_res=db_exec($news_query); if (!$news_res) { echo "NEWS
"; db_error($news_query); } $news_num=db_numrows($news_res); if ($news_num && $res2sw=="") $res2sw="news"; } // AREE TEMATICHE if ($Form_search_aree && sizeof($words)) { $criteria.=" Dossier,"; $aree_query="SELECT a.id, a.id_avo FROM aree a WHERE a.stato='A' "; reset ($words); while (list($key,$word) = each($words)) { $aree_query.="AND (MATCH (titolo) AGAINST ('".strtolower($word)."') OR MATCH (abstract) AGAINST ('".strtolower($word)."')) "; } $aree_query.=" ORDER BY a.id_avo, a.id_padre, a.ordine, a.tag_title "; $aree_res=db_exec($aree_query); if (!$aree_res) { echo "DOSSIER-
"; db_error($aree_query); } $aree_num=db_numrows($aree_res); if ($aree_num && $res2sw=="") $res2sw="aree"; } // RIVISTE if ($Form_search_riviste && sizeof($words)) { $criteria.=" Riviste,"; $riviste_query="SELECT t.titolo, t.immagine, n.* FROM numeri_testate n LEFT JOIN testate t ON n.id_testa=t.id WHERE n.online='S' AND t.online='S' "; reset ($words); while (list($key,$word) = each($words)) { $riviste_query.="AND MATCH (n.testo) AGAINST ('".strtolower($word)."') "; } $riviste_query.=" ORDER BY n.id_testa, YEAR(n.data) DESC, n.numero "; $riviste_res=db_exec($riviste_query); if (!$riviste_res) { echo "RIVISTE
"; db_error($riviste_query); } $riviste_num=db_numrows($riviste_res); if ($riviste_num && $res2sw=="") $res2sw="riviste"; } // LIBRI if ($Form_search_libri && sizeof($words)) { $criteria.=" Libri "; $libri_query="SELECT l.*, a.nome FROM libri l LEFT JOIN autori a ON l.id_autore=a.id WHERE l.online='S' "; reset ($words); while (list($key,$word) = each($words)) { //$libri_query.="AND MATCH (l.titolo,l.info,l.descrizione,l.recensione,l.intro) AGAINST ('".$word."') "; $libri_query.=" AND ( LOWER(a.nome) REGEXP '[[:<:]]".$word."[[:>:]]' OR LOWER(l.titolo) REGEXP '[[:<:]]".$word."[[:>:]]' OR LOWER(l.info) REGEXP '[[:<:]]".$word."[[:>:]]' OR LOWER(l.descrizione) REGEXP '[[:<:]]".$word."[[:>:]]' OR LOWER(l.recensione) REGEXP '[[:<:]]".$word."[[:>:]]' OR LOWER(l.intro) REGEXP '[[:<:]]".$word."[[:>:]]') "; } $libri_query.=" ORDER BY a.nome, l.titolo "; $libri_res=db_exec($libri_query); if (!$libri_res) { echo "LIBRI
"; db_error($libri_query); } $libri_num=db_numrows($libri_res); if ($libri_num && $res2sw=="") $res2sw="libri"; } $criteria=substr($criteria,0,-1).($ext_seacrh?"
":""); ?>

Devi compilare almeno un campo


"; /*
0) { ?> | "; if (!$where_clause) { ?>

Devi compilare almeno un campo
"; //Criteri di ricerca if ($criteria!="") echo "".$txt['criteri'].":
".$criteria."
"; if(!$res) db_error($res); //$doc_num=db_numrows($res); // HTTP-QUERY SEARCH $post_lnk=$_SERVER['QUERY_STRING']; $pos=strpos($post_lnk,"&res2sw="); if ($pos) $post_lnk=substr($post_lnk,0,$pos); ///////////////////////////////////////////////////////////////////////////// // DOCUMENTI $str_out="*"; if ($doc_num>0 && $res2sw!="doc") $str_out="*"; echo str_replace("*",$txt['documenti'].": ".($doc_num>0?$doc_num:$txt['nessuno']),$str_out).".
"; // NEWS if ($Form_search_news) { $str_out="*"; if ($news_num>0 && $res2sw!="news") $str_out="*"; echo str_replace("*",$txt['news_trovate'].": ".($news_num>0?$news_num:$txt['nessuna']),$str_out).".
"; } // AREE if ($Form_search_aree) { $str_out="*"; if ($aree_num>0 && $res2sw!="aree") $str_out="*"; echo str_replace("*",$txt['dossier_trovate'].": ".($aree_num>0?$aree_num:$txt['nessuna']),$str_out).".
"; } // RIVISTE if ($Form_search_riviste) { $str_out="*"; if ($riviste_num>0 && $res2sw!="riviste") $str_out="*"; echo str_replace("*",$txt['riviste_trovate'].":".($riviste_num>0?$riviste_num:$txt['nessuna']),$str_out).".
"; } // LIBRI if ($Form_search_libri) { $str_out="*"; if ($libri_num>0 && $res2sw!="libri") $str_out="*"; echo str_replace("*",$txt['libri_trovati'].": ".($libri_num>0?$libri_num:$txt['nessuno']),$str_out).".
"; } if ($id=="") echo "
".$txt['risultati_ordinati']."
"; echo "

"; switch ($res2sw) { case "news": //$hr=false; while ($row=db_FetchArray($news_res)) { if ($id!="" && $row["id"]!=$id) continue; /*if ($hr) echo "
"; $hr=true;*/ list($y,$m,$d)=explode("-",$row["data"]); if ($id!="") { ?>">torna ai risultati ricerca


  ">  " target="_blank">link
".nl2br($row["testo"]); if ($row["old"]=="S") { $row["titolo"]=nl2br(html_entity_decode((($lang != 'ita' && $row['titolo_'.$lang]!= "")? $row['titolo_'.$lang]:$row["titolo"] ))); $row["testo"]=nl2br(html_entity_decode((($lang != 'ita' && $row['testo_'.$lang]!= "")? $row['testo_'.$lang]:$row["testo"] ))); } list($y,$m,$d)=explode("-",$row["data"]); $textSpan=" style=\"width: 490px !important;\""; echo "

\r\n"; if ($row["thumb"]!="" && file_exists($config["root"].$config["news_img"].$row["thumb"])) { //$textSpan=""; $info=getimagesize($config["root"].$config["news_img"].$row["thumb"]); echo ""; } /*else $textSpan=" style=\"width: 490px !important;\"";*/ echo strftime("%d %B %Y",mktime(0,0,0,$m,$d,$y))."

".(html_entity_decode((($lang != 'ita' && $row['titolo_'.$lang]!= "")? $row['titolo_'.$lang]:$row['titolo'] )))."


".stripslashes(html_entity_decode((($lang != 'ita' && $row['testo_'.$lang]!= "")? $row['testo_'.$lang]:$row["testo"] )))."

\r\n"; } echo "

"; } break; case "aree": //GET IDS $id_aree=array(); $id_avi="("; while ($row=db_FetchArray($aree_res)) { array_push($id_aree,$row["id"]); $id_avi.="'".$row["id_avo"]."',"; } $id_avi=substr($id_avi,0,-1).")"; //GET AVI $a_query="SELECT id,titolo,titolo_eng FROM aree WHERE stato = 'A' AND id_padre = '0' ORDER BY ordine, titolo"; $a_res=db_exec($a_query); if (!$a_res) db_error($a_query); while ($a_row=db_FetchArray($a_res)) { //echo "
";
		  //print_r($a_row);
		  //echo "
"; if ($a_row["titolo"]=="#-#") continue; echo "

"; $str_out="*"; if (in_array($a_row["id"],$id_aree)) $str_out="*"; echo str_replace("*",html_entity_decode((($lang != 'ita' && $a_row['titolo_'.$lang]!= "")? $a_row['titolo_'.$lang]:$a_row["titolo"] )),$str_out)."
"; /* quaaa */ List_Area ($a_row["id"],$id_aree,5); echo "

"; } break; case "riviste": $id_att=-1; while ($row=db_FetchArray($riviste_res)) { if ($id!="" && $id==$row["id"]) { ?>
">



" border="0" align="left" style="margin-right: 8px"> ".$num_titolo."

".html_entity_decode((($lang != 'ita' && $row['testo_'.$lang]!= "")? $row['testo_'.$lang]:$a_row["testo"] )); echo nl2br($num_testo); echo "

"; break; } else if ($id!="" && $id!=$row["id"]) continue; list ($y,$m,$d)=explode("-",$row["data"]); if ($id_att!=$row["id_testa"]) { ?>

" class="reg">- ,

" style="float:right;">
".$row["nome"].""; echo "

"; $text_padding=0; if ($row["immagine"]!="" && file_exists($config["root"].$config["img_libri"].$row["immagine"])) { $info=getimagesize($config["root"].$config["img_libri"].$row["immagine"]); $text_padding=$info[0]+8; ?>" width="" height="" border="0" align="left" class="img_border" /> \r\n"; echo (html_entity_decode((($lang != 'ita' && $row['info_'.$lang]!= "")? $row['info_'.$lang]:$row["info"] ))); echo "

\r\n"; //INTRO if ($row["tipo_intro"]=="T" && $row["intro"]!="") { ?>

" target="_blank"> [PFD KB]

" target="_blank"> [PFD KB]
".html_entity_decode((($lang != 'ita' && $row['descrizione_'.$lang]!= "")? $row['descrizione_'.$lang]:$row["descrizione"] )); echo "

"; ?> "; if ($autore=="") $autore=$row["autore"]; if ($autore!=$row["nome"]) echo "
"; //echo "
"; ?>- "> di
"; } break; case "doc": $i=0; //while ($row=db_FetchArray($res)) //foreach ($documenti as $row) //CICLO SU INDICE DATE PER SORT foreach($docs_index as $id_document => $data_document) { $row = $documenti[$id_document]; /*if ($i!=0) { ?>

"> - 0) echo (int)$d; if ($m>0) echo " ".strftime("%B",mktime(0,0,0,$m,1,2001)); if ($y>0) echo " ".$y; if ($row["numero"]!="") echo ", "; } //list ($y,$m,$d)=split("-",$row["data"]); //echo $row["natura"]." ".$d." ".strtolower($mesi[((int)$m-1)])." ".$y; //STAMPA NUMERO if ($row["numero"]!="") { ?>

"; if ($row["data"]!="NULL" && $row["data"]!="0000-00-00") { ?>: 0) echo (int)$d; if ($m>0) /* 20091106 nexus la visualizzazione del mese non funzionava ho cambiato la linea echo " ".strtolower($mesi[((int)$m-1)]); con quella qui sotto presa da /documenti/index.php */ echo " ".strftime("%B",mktime(0,0,0,$m,1,2001)); if ($y>0) echo " ".$y; ?>
0) echo $txt['argomento'].": ".implode(", ",$Args)."
"; // STAMPA DOSSIER if (sizeof($Aree)>0) echo "dossier: ".implode(", ",$Aree)."
"; if ($row["testata"]!='') { ?>:
:
:
abstract: "; } break; default: ?>

"; } function List_Area ($ID,$sr,$tab) { global $lang; $dbquery="SELECT * FROM aree WHERE stato = 'A' AND id_padre = '".$ID."' ORDER BY ordine, titolo"; $res=db_exec($dbquery); if (!$res) db_error($dbquery); if (db_numrows($res)) { while ($row=db_FetchArray($res)) { /*echo "
";
		  print_r($row);
		  echo "
";*/ for ($i=0; $i<$tab; $i++) echo " "; $str_out="*"; if (in_array($row["id"],$sr)) $str_out="*"; echo "- ".str_replace("*",html_entity_decode((($lang != 'ita' && $row['titolo_'.$lang]!= "")? $row['articolo']." ".$row['titolo_'.$lang]:$row['articolo']." ".$row["titolo"] )),$str_out)."
"; List_Area ($row["id"],$sr,($tab+5)); } } } $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo ""; ?>