Location: PHPKode > projects > Spacemarc News > spacemarc-news/include.php
<!-- begin Spacemarc News -->
<table width="250" border="0" cellpadding="1" cellspacing="1">           
  <tr>                   
    <td align="center" bgcolor="#336699">Ultime notizie</td>           
  </tr>
<?php

/*****************************************************************
*  Spacemarc News
*  Version: 1.2.0
*  Author and copyright (C): Marcello Vitagliano
*  Web site: http://www.spacemarc.it
*  License: GNU General Public License
*
*  This program is free software: you can redistribute it and/or
*  modify it under the terms of the GNU General Public License
*  as published by the Free Software Foundation, either version 3
*  of the License, or (at your option) any later version.
*
*  Current file: include.php
*****************************************************************/

//includo i file di configurazione
require_once (dirname(__FILE__) . '/config.php');

//connessione a mysql
$db = @mysql_connect($db_host, $db_user, $db_password);
@mysql_select_db($db_name, $db);
$config = mysql_query("SELECT max_tit_include, max_parole_include, nuova_news_day FROM $tab_config", $db);
$config_val = @mysql_fetch_assoc($config);
$max_tit = $config_val['max_tit_include'];

if ($config_val['max_parole_include'] > 0) {
    $words = $config_val['max_parole_include'];
    $sql_include = "SELECT id, data_pubb, titolo, LEFT(testo, $words) AS testo FROM $tab_news ORDER BY data_pubb DESC LIMIT $max_tit";
}
else {
    $words = NULL;
    $sql_include = "SELECT id, data_pubb, titolo FROM $tab_news ORDER BY data_pubb DESC LIMIT $max_tit";
}
$result_inc = mysql_query("$sql_include", $db);

while ($row_inc = @mysql_fetch_array($result_inc)) {

    //vedo se nella query ho scelto di mostrare il testo, per evitare il Notice di variabile indefinita
    $testo_inc = (isset($row_inc['testo'])) ? $row_inc['testo'] : NULL;

    //stampo l'icona di nuova notizia
    $img_new = ((time() - $row_inc['data_pubb']) <= 60 * 60 * 24 * $config_val['nuova_news_day']) ? "<img src=\"/$news_dir/$img_dir/new.gif\" border=\"0\" alt=\"\" />" : "<img src=\"/$news_dir/$img_dir/art.gif\" border=\"0\" alt=\"\" />";
    
    if ($words > 0) {
        echo "<tr><td align=\"left\" bgcolor=\"#FFFFFF\"> $img_new <a href=\"/$news_dir/view.php?id=" . $row_inc['id'] . "\" title=\"Leggi...\">" . $row_inc['titolo'] . "</a> " . strftime("%d/%m/%Y %H:%M", $row_inc['data_pubb']) . "<br />$testo_inc</td></tr>\n";
    }
    else {
        echo "<tr><td align=\"left\" bgcolor=\"#FFFFFF\"> $img_new <a href=\"/$news_dir/view.php?id=" . $row_inc['id'] . "\" title=\"Leggi...\">" . $row_inc['titolo'] . "</a> " . strftime("%d/%m/%Y %H:%M", $row_inc['data_pubb']) . "</td></tr>\n";
    }
}
echo "<tr><td align=\"center\" bgcolor=\"#336699\"><a href=\"/$news_dir/archivio.php\" class=\"top\" title=\"Tutte le news\">Archivio notizie</a></td></tr>\n</table>\n";
?>         
  <!-- end Spacemarc News -->
Return current item: Spacemarc News