<?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: print.php
*****************************************************************/
header('Content-type: text/html; charset=ISO-8859-1');
//includo i file di configurazione
require_once (dirname(__FILE__) . '/config.php');
require_once (dirname(__FILE__) . '/admin/functions.php');
// apro la connessione a mysql
$db = @mysql_connect($db_host, $db_user, $db_password);
@mysql_select_db($db_name, $db);
//seleziono l'ID minore e maggiore delle news
$result = mysql_query("SELECT MIN(id) AS MinID, MAX(id) AS MaxID FROM $tab_news");
$row = @mysql_fetch_array($result);
//se l'id della notizia c'è ed è di tipo numerico ed è presente in tabella procedo
if (isset($_GET['id']) && preg_match('/^[0-9]{1,8}$/', $_GET['id']) && $_GET['id'] <= $row['MaxID'] && $_GET['id'] >= $row['MinID']) {
//aumento il numero di stampe della notizia
mysql_query("UPDATE $tab_news SET stampe=stampe+1 WHERE id=" . intval($_GET['id']));
//estraggo la notizia
$result2 = mysql_query("SELECT nt.id, nt.titolo, nu.nome_cognome, nt.testo, nt.data_pubb, nt.immagine, nt.nosmile FROM $tab_news nt JOIN $tab_utenti nu ON nu.user_id=nt.user_id WHERE nt.id=" . intval($_GET['id']));
$row2 = mysql_fetch_array($result2);
$testo = nl2br($row2['testo']);
$img_view = ($row2['immagine'] != "") ? "<div id=\"imgap\" class=\"imageap\"><img src=\"" . $row2['immagine'] . "\" border=\"1\" alt=\"immagine\" width=\"96\" height=\"86\" /></div>" : NULL;
//estraggo le impostazioni
$result3 = mysql_query("SELECT nome_sito, url_sito FROM $tab_config");
$row3 = mysql_fetch_array($result3);
function bbCode($testo) {
global $img_path, $row2;
//sostituisco i bbcode con i tags HTML e con gli smlies
if ($row2['nosmile'] == 0) {
$replace = array(
'[b]' => '<b>',
'[/b]' => '</b>',
'[i]' => '<i>',
'[/i]' => '</i>',
'[u]' => '<u>',
'[/u]' => '</u>',
'[ul]' => '<ul>',
'[/ul]' => '</ul>',
'[li]' => '<li>',
'[/li]' => '</li>',
'&' => '&',
':cool:' => '<img src="' . $img_path . '/cool.gif" alt="cool" />',
':)' => '<img src="' . $img_path . '/smile.gif" alt="smile" />',
'):' => '<img src="' . $img_path . '/mad.gif" alt="mad" />',
':p' => '<img src="' . $img_path . '/tongue.gif" alt="tongue" />',
':D' => '<img src="' . $img_path . '/biggrin.gif" alt="biggrin" />',
';)' => '<img src="' . $img_path . '/wink.gif" alt="wink" />',
':o' => '<img src="' . $img_path . '/ohh.gif" alt="ohh" />',
':zizi:' => '<img src="' . $img_path . '/zizi.gif" alt="zizi" />',
':(' => '<img src="' . $img_path . '/sad.gif" alt="sad" />',
':green:' => '<img src="' . $img_path . '/mrgren.gif" alt="mrgren" />',
':dotto:' => '<img src="' . $img_path . '/dotto.gif" alt="dotto" />',
':cry:' => '<img src="' . $img_path . '/cry.gif" alt="cry" />',
':parolaccia:' => '<img src="' . $img_path . '/parolaccia.gif" alt="parolaccia" />',
':incupito:' => '<img src="' . $img_path . '/incupito.gif" alt="incupito" />',
':stordito:' => '<img src="' . $img_path . '/stordito.gif" alt="stordito" />',
':info:' => '<img src="' . $img_path . '/info.png" alt="info" />',
':star:' => '<img src="' . $img_path . '/star.png" alt="star" />',
':alert:' => '<img src="' . $img_path . '/alert.png" alt="alert" />',
':???:' => '<img src="' . $img_path . '/question.png" alt="question" />',
':check:' => '<img src="' . $img_path . '/check.png" alt="check" />',
':wiki:' => '<img src="' . $img_path . '/wikipedia.png" alt="wikipedia" />',
':chat:' => '<img src="' . $img_path . '/chat.png" alt="chat" />',
':www:' => '<img src="' . $img_path . '/www.png" alt="www" />',
':man:' => '<img src="' . $img_path . '/man.png" alt="man" />',
':mail:' => '<img src="' . $img_path . '/mail.png" alt="mail" />',
':fb:' => '<img src="' . $img_path . '/facebook.gif" alt="facebook" />',
':li:' => '<img src="' . $img_path . '/linkedin.gif" alt="linkedin" />',
':ms:' => '<img src="' . $img_path . '/myspace.gif" alt="myspace" />',
':tw:' => '<img src="' . $img_path . '/twitter.gif" alt="twitter" />',
':gw:' => '<img src="' . $img_path . '/gwave.png" alt="gwave" />'
);
$testo = strtr($testo, $replace);
}
else {
$replace = array(
'[b]' => '<b>',
'[/b]' => '</b>',
'[i]' => '<i>',
'[/i]' => '</i>',
'[u]' => '<u>',
'[/u]' => '</u>',
'[ul]' => '<ul>',
'[/ul]' => '</ul>',
'[li]' => '<li>',
'[/li]' => '</li>',
'&' => '&'
);
$testo = strtr($testo, $replace);
}
$testo_cerca = array(
"{\[email\](\r\n|\r|\n)*([a-zA-Z0-9\._-]+@(([a-zA-Z0-9_-])+\.)+[a-z]{2,6})\[/email\]}siU",
"{\[email=(\w[\w\-\.\+]*?@\w[\w\-\.]*?\w\.[a-zA-Z]{2,4})\](.+)?\[\/email\]}siU",
"{(\[)(url)(])((http|ftp|https)://)([^;<>\*\(\)\"\s]*)(\[/url\])}siU",
"{(\[)(url)(=)(['\"]?)((http|ftp|https)://)([^;<>\*\(\)\"\s]*)(\\4])(.*)(\[/url\])}siU",
"{(\[)(callto)(])((callto):)([^;<>\*\(\)\"\s]*)(\[/callto\])}siU",
"{(\[)(callto)(=)(['\"]?)((callto):)([^;<>\*\(\)\"\s]*)(\\4])(.*)(\[/callto\])}siU",
"{(\[)(size)(=)(['\"]?)([0-9]*)(\\4])(.*)(\[/size\])}siU",
"{\[img\](\r\n|\r|\n)*((http|https)://([^;<>\*\(\)\"\s]+)|[a-z0-9/\\\._\- ]+)\[/img\]}siU",
"{\[quote\](\r\n|\r|\n)*(.+)\[/quote\]}siU",
"{\[code\](\r\n|\r|\n)*(.+)\[/code\]}siU",
"{\[yt\]([0-9A-Za-z-_]{11})\[/yt]}siU"
);
//...e li sostituisco con gli appositi tags HTML
$testo_sostituisci = array(
"\\2",
"\\2 [\\1]",
"\\4\\6",
"\\9 [\\5\\7]",
"\\4\\6",
"\\9 [\\5\\7]",
"<span style=\"font-size: \\5pt;\">\\7</span>",
"<img src=\"\\2\" border=\"0\" alt=\"immagine\" title=\"\" />",
"<div style=\"margin:0 auto; width:90%; font-size: 11px; \"><b>Citazione:</b></div><div style=\"margin:0 auto; width:90%; height: auto; border: 1px solid #DEE3E7; padding: 3px;\">\\2</div>",
"<div style=\"margin:0 auto; width:100%; font-size: 11px; \"><b>Codice:</b></div><div style=\"width: 750px; height: auto; padding: 0px; line-height: 7px; font-size: 11px; border: 1px solid #E1E1E1; white-space: nowrap; overflow: auto;\"><pre>\\2</pre></div>",
"[Video: youtube.com/watch?v=\\1]"
);
$testo = preg_replace($testo_cerca, $testo_sostituisci, $testo);
return $testo;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<?php echo $row2['titolo']; ?> - VERSIONE STAMPABILE
</title>
<link rel="stylesheet" href="print.css" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="Feed RSS News" href="<?php echo $row3['url_sito'] . "/" . $news_dir . "/rss.php"; ?>" />
<script language="JavaScript" src="javascript.js" type="text/JavaScript"></script>
</head>
<body>
<div id="container_print">
<div id="logo">
<a href="/" title="Home Page">
<img src="/imgs/logo.gif" alt="LOGO SITO" border="0" /></a>
</div>
<div id="tools">
<a href="javascript:;" onclick="img_hide();" title="Stampa senza le immagini">Senza immagini</a> -
<a href="javascript:;" onclick="img_show();" title="Stampa con le immagini">Con immagini</a> -
<a href="javascript:;" onclick="alert('Rispetta l\'ambiente: non stampare questa pagina se non è necessario.'); self.print();" title="Stampa">Stampa</a>
</div><br /><br /><br /><br /><br />
<div id="news_print">
<?php
echo "
<b>Titolo</b>: " . $row2['titolo'] . "<br />
<b>Data</b>: " . strftime("%d/%m/%Y %H:%M", $row2['data_pubb']) . " <b>Autore</b>: " . $row2['nome_cognome'] . " <b>URL</b>: " . $row3['url_sito'] . "/$news_dir/view.php?id=" . $row2['id'] . "<br /><br /><br />$img_view " . bbCode($testo) . " ";
?>
<p>
</p><br /><br />
<div id="note">Copyright ©
<?php echo $row3['nome_sito']; ?> - Tutti i diritti riservati.
</div>
</div>
</div>
</body>
</html>
<?php
//chiudo la connessione a mysql
mysql_close($db);
}
else {
echo "Notizia inesistente";
}
?>