Codice HTML:
<html>
<body bgcolor=yellow>
<basefont size=2 face=arial>
<b>Add Article</b>
<?
include ("template.inc");
include ("config.php");
$summary_template = "t_summary.html";
$article_template = "t_article.html";
$max_summary = 5;
function summary_page ($subject, $date, $summary, $article_id)
{
global $summary_template;
$t = new Template();
$t->set_file("SummaryPage", $summary_template);
$article_url = "article_".$article_id.".html";
$date = nl2br($date);
$summary = nl2br($summary);
$t->set_var( array(
"subject" => $subject,
"date" => $date,
"summary" => $summary,
"article_url" => $article_url
));
$t->parse("Summary", "SummaryPage");
return $t->get_var("Summary");
}
function main_page ($subject, $date, $summary, $article_id, $body)
{
global $article_template;
$t = new Template();
$t->set_file("ArticlePage", $article_template);
$article_url = "article_".$article_id.".html";
$date = nl2br($date);
$summary = nl2br($summary);
$body = nl2br($body);
$t->set_var( array(
"subject" => $subject,
"date" => $date,
"summary" => $summary,
"body" => $body,
"article_url" => $article_url
));
$t->parse("Article", "ArticlePage");
return $t->get_var("Article");
}
function add_article($filename, $news)
{
if(file_exists($filename)){
$fh = fopen($filename, "r");
$old_news = fread($fh, filesize($filename));
fclose($fh);
}
/* TODO: Multipage articles
preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches;
if( count($matches[0]) >= $max_summary){
$oldfilename = $filename.($matches[0][0]+1);
}
*/
$fh = fopen($filename, "w");
$news = stripslashes($news);
fwrite($fh, "\n<!--ARTICLE-->\n$news $old_news");
fclose($fh);
}
?>
<?
if(strcmp($subject, "")){
if(!(strcmp($passwd, $password))){
add_article("article_summary.html", summary_page($subject, $date, $summary, $article_id));
add_article("article_$article_id.html", main_page($subject, $date, $summary, $article_id, $body));
echo "<p> Article has been added! <p>";
}else{
echo "<p><b> Password is wrong! </b>";
}
}
?>
<script type="text/javascript" src="file.js"></script>
<form action=news.php method=post>
<table border=0>
<tr> <td> (Password): </td><td> <input type=text name=passwd size=30> </td></tr>
<tr> <td> Subject: </td><td> <input type=text name=subject size=30> </td></tr>
<tr> <td> Article ID: </td><td> <input type=text name=article_id value=<? echo date("Y_m_j_is"); ?> size=30> </td></tr>
<tr> <td> Date/Author/etc: </td><td> <textarea name=date rows=2 cols=30 wrap=soft><? echo date("M j, Y\n"); ?>Author: </textarea> </td></tr>
<tr> <td> Summary: </td><td> <textarea name=summary rows=5 cols=30 wrap=soft></textarea> </td></tr>
<tr><td>Notizia</td>
<td>
<a href="javascript:smiley_bbcode('newsposting', 'news', ';)');"><img src="http://acciarello.altervista.org/news/upload/smillies/blink1.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':weirdo:');"><img src="http://acciarello.altervista.org/news/upload/smillies/smile1.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':unsure:');"><img src="http://acciarello.altervista.org/news/upload/smillies/unsure.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':s');"><img src="http://acciarello.altervista.org/news/upload/smillies/wacko.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':roll:');"><img src="http://acciarello.altervista.org/news/upload/smillies/rolleyes.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':push:');"><img src="http://acciarello.altervista.org/news/upload/smillies/push.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':puke:');"><img src="http://acciarello.altervista.org/news/upload/smillies/sick.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':oh:');"><img src="http://acciarello.altervista.org/news/upload/smillies/oh.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':o');"><img src="http://acciarello.altervista.org/news/upload/smillies/amazed.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':love:');"><img src="http://acciarello.altervista.org/news/upload/smillies/love.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':idea:');"><img src="http://acciarello.altervista.org/news/upload/smillies/idea.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':huh:');"><img src="http://acciarello.altervista.org/news/upload/smillies/weird.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':hmm:');"><img src="http://acciarello.altervista.org/news/upload/smillies/suspicious.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':eek:');"><img src="http://acciarello.altervista.org/news/upload/smillies/huh.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':amazed:');"><img src="http://acciarello.altervista.org/news/upload/smillies/amazed.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':\'(');"><img src="http://acciarello.altervista.org/news/upload/smillies/cry.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':P');"><img src="http://acciarello.altervista.org/news/upload/smillies/toung.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':O');"><img src="http://acciarello.altervista.org/news/upload/smillies/amazed.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':D');"><img src="http://acciarello.altervista.org/news/upload/smillies/bigsmile.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':@');"><img src="http://acciarello.altervista.org/news/upload/smillies/mad.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':)');"><img src="http://acciarello.altervista.org/news/upload/smillies/smile.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', ':$');"><img src="http://acciarello.altervista.org/news/upload/smillies/embarrest.gif" alt="" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '8)');"><img src="http://acciarello.altervista.org/news/upload/smillies/cool.gif" alt="" /></a><br />
<a href="javascript:smiley_bbcode('newsposting', 'news', '[b]text[/b]');"><img src="img/bold.gif" alt="Bold" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[i]text[/i]');"><img src="img/italic.gif" alt="Italic" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[u]text[/u]');"><img src="img/underline.gif" alt="Underline" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[s]text[/s]');"><img src="img/strike.gif" alt="Strike Out" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[sub]text[/sub]');"><img src="img/sub.gif" alt="Subscript" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[sup]text[/sup]');"><img src="img/sup.gif" alt="Superscript" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[shadow=red,left,1]TEXT[/shadow]');"><img src="img/shadow.gif" alt="Shadow Text" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[glow=red,2,1]TEXT[/glow]');"><img src="img/glow.gif" alt="Glow Text" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[color=red]text[/color]');"><img src="img/color.gif" alt="Font color" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[font=verdana]text[/font]');"><img src="img/fontface.gif" alt="Font Family" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[size=2]text[/size]');"><img src="img/fontsize.gif" alt="Font Size" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[align=left]text[/align]');"><img src="img/fontleft.gif" alt="Font Alignment" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[tt]text[/tt]');"><img src="img/tele.gif" alt="Teletype" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[hr]');"><img src="img/hr.gif" alt="Horizontal Line" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[move]STUFF[/move]');"><img src="img/move.gif" alt="Marquee" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[quote]text[/quote]');"><img src="img/quote2.gif" alt="Quote" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[flash=200,200]URL[/flash]');"><img src="img/flash.gif" alt="Flash Image" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[img]URL[/img]');"><img src="img/img.gif" alt="Image" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[email=username@site.com]Mail Me[/email]');"><img src="img/email2.gif" alt="E-mail link" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[url=http://www.url.com]address[/url]');"><img src="img/url.gif" alt="hyperlink" /></a><a href="javascript:smiley_bbcode('newsposting', 'news', '[list][*]text1[*]text2[*]text3[/list]');"><img src="img/list.gif" alt="List" /></a><br />
<textarea class="post" id="news" name="news" rows="15" cols="80"></textarea>
</td>
</tr>
</table>
</form>
<p>
<a href=source.php?f=news.php>Source</a>