"; if ((ecommerce($iduser)) and (!empty_carrello($idcat))) $t->assign("CARRELLO","$link_carrello"); $t->out(); //gestione della ricerca $find_text e dell'ordinamento $order nelle righe delle news /*$form = "

Ricerca  

"; ECHO $form; $form = "

Ricerca  

"; ECHO $form; */ $my_where = " WHERE (admin.idcliente = '$iduser') AND (news.keycliente = admin.idcliente) AND (categorie.idcategoria = news.keycategoria) AND (categorie.keycliente = admin.idcliente) AND (news.idnews = linguenews.keynews) AND (linguenews.keylingue = '$idlang') AND (categorie.idcategoria = '$idcat') AND (linguecategorie.keycategoria = categorie.idcategoria) AND (linguecategorie.keylingua = '$idlang') AND (news.attivo = '1') AND (news.data_inizio_attivazione <= CURDATE()) AND (news.data_fine_attivazione >= CURDATE())"; $my_order = " ORDER BY news.progressivo "; $keys = explode (" ",$find_text); reset ($keys); if ($find_text != "") { $my_where .= "AND ("; while (list(,$find_text) = each ($keys)) { $find_text = trim($find_text); //if ($find_text != "") //{ if (! strpos($find_text, " ") === FALSE) $find_text = substr($find_text, 0, strpos($find_text, " ")); $my_where .= "(linguenews.titolo LIKE \"%$find_text%\") OR (linguenews.testobreve LIKE \"%$find_text%\") OR "; $find_text = stripslashes($find_text); // toglie evt. slash per display //} } $my_where .= "0)"; } if ($order !="") { if (! strpos($order, " ") === FALSE) $order = substr($forder, 0, strpos($order, " ")); $my_order = " ORDER BY ".$order.""; } //includo nella pagina i blocchi di una categoria (ogni blocco è una riga della news) $query = "select linguecategorie.riganews,linguenews.titolo,linguenews.testobreve,news.idnews,linguecategorie.immagine,categorie.nome,news.data_inizio_attivazione,news.data_fine_attivazione,news.prezzo,linguecategorie.carrello from news,admin,categorie,linguenews,linguecategorie ".$my_where.$my_order; $resultblock = sql_query ($query,$dbi); //nel template inserisco il titolo,la descrizione e l'immagine di ogni categoria di news //se l'immagine non è presente visualizzo un'immagine (.gif) tipica della categoria IF (sql_num_rows($resultblock,$dbi)>0) { while(list($block,$titolo_news,$testo_breve,$idnews,$immagine,$nome_categoria,$data_dal,$data_scad,$prezzo,$carrello) = sql_fetch_row($resultblock, $dbi)) { $riganews=$block; $nomefileminewsmin = $images_min."/".$idnews.".jpg"; $nomefileminewsbig = $images_big."/".$idnews.".jpg"; $immagine_categoria = $immagine; //formattazione della data per la visualizzazione (gg-mm-aaaa) IF ($data_dal == "0000-00-00") $data_dal = ""; ELSE $data_dal = substr($data_dal, 8, 2)."/".substr($data_dal, 5, 2)."/".substr($data_dal, 0, 4); IF ($data_scad == "0000-00-00") $data_scad = ""; ELSE $data_scad = substr($data_scad, 8, 2)."/".substr($data_scad, 5, 2)."/".substr($data_scad, 0, 4); $t = new Template($riganews); if (!empty($data_dal)) $t->assign("DAL","$data_dal"); if (!empty($data_scad)) $t->assign("AL","$data_scad"); if (!empty($titolo_news)) $t->assign("TITOLO","$titolo_news"); if (!empty($testo_breve)) $t->assign("DESCRIZIONE","$testo_breve"); //$linkimmaginebig="\"$titolo_news\""; $linkimmaginebig="\"$titolo_news\""; $linkimmaginestandard="\"$titolo_news\""; //$linkimmaginesmall=" \"\""; // //file_exists non funziona in remoto utilizzo la fopen IF (file_exists($nomefileminewsmin)) //apertura del file in lettura, se non si apre è come se non esiste // if(@$pfile = fopen ("$nomefileminewsmin","r")) {//echo"Impossibile aprire il file in remoto"; $t->assign("IMAGELINK","$linkimmaginebig"); } else $t->assign("IMAGELINK","$linkimmaginestandard"); //$t->assign("ALT","$titolo_news"); //fclose ($pfile); //chiusura del file $t->out(); //se l'azienda è abilitata al commercio elettronico //creo un nuovo template contenente i dati del carrello //(i campi per il parsing sono il prezzo di ciascun prodotto) if ((ecommerce($iduser)) and (!empty($carrello))) { $carrellocomm = $carrello; $c = new Template($carrellocomm); if (!empty($prezzo)) $c->assign("IMPORTO","$prezzo"); if (!empty($idnews)) $c->assign("CODICEPRODOTTO","$idnews"); if (!empty($titolo_news)) $c->assign("TITOLONEWS","$titolo_news"); $c->out(); } } } //includo nella pagina il footer di una categoria $resultfooter = sql_query("select linguecategorie.footer from linguecategorie,categorie where (categorie.keycliente = '$iduser') and (linguecategorie.keylingua ='$idlang') and (linguecategorie.keycategoria = '$idcat') and (linguecategorie.keycategoria = categorie.idcategoria)",$dbi); list($footer) = sql_fetch_row($resultfooter, $dbi); echo($footer); ECHO ""; function ecommerce($user) { global $dbi; $querycommerce = sql_query ("select ecommerce from admin where (admin.idcliente='$user')",$dbi); list($commerce) = sql_fetch_row($querycommerce, $dbi); $ecommerce=$commerce; if (($ecommerce) == 'SI') return 1; else if (($ecommerce) == 'NO') return 0; } function empty_carrello($idcategoria) { global $dbi; $querycarrello = sql_query ("select carrello from linguecategorie where (linguecategorie.keycategoria='$idcategoria')",$dbi); list($carrello) = sql_fetch_row($querycarrello, $dbi); if (($carrello) == '') return 1; else return 0; } ?>