Code:<?php
/* $Id: news.php,v 1.28 2007/05/12 21:27:09 luca_negrini Exp $ */
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2006-2007 by Luca Negrini */
/* Copyright (c) 2003-2005 by Joubert Berger */
/* Copyright (c) 2002 by Francisco Burzi */
/* */
/* 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 2 of the License. */
/************************************************************************/
/* This file was taken from the Submit_News module and modified by */
/* Joubert Berger for Nuke-League. */
/************************************************************************/
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
require_once("modules/League/util.php");
get_lang("League");
$pagetitle = "- "._SUBMITNEWS."";
function defaultDisplay($schid, $lid, $sid, $tid) {
global $AllowableHTML, $prefix, $user, $cookie, $anonymous,
$currentlang, $multilingual, $db;
include ('header.php');
$prefs = getLeaguePrefs($lid);
$result = $db->sql_query("select tid1, tid2 from " . $prefix . "_league_schedule where id = $schid");
list($tid1, $tid2) = $db->sql_fetchrow($result);
if ($prefs[matchreport] == 0)
return;
OpenTable();
echo "<center><font class=\"title\"><b>"._SUBMITNEWS."</b></font><br>";
echo getTeamName($tid1) . " " . _VS . " " . getTeamName($tid2) . "<br><br>";
echo "<font class=\"content\"><i>"._SUBMITADVICE."</i></font></center><br>";
CloseTable();
echo "<br>";
OpenTable();
if (is_user($user)) getusrinfo($user);
echo "<p><form action=\"modules.php?name=League&file=news\" method=\"post\">"
."<b>"._YOURNAME.":</b> ";
if (is_user($user)) {
cookiedecode($user);
echo "<a href=\"account.html\">$cookie[1]</a> <font class=\"content\">[ <a href=\"modules.php?name=Your_Account&op=logout\">"._LOGOUT."</a> ]</font>";
} else {
echo "$anonymous <font class=\"content\">[ <a href=\"account.html\">"._NEWUSER."</a> ]</font>";
}
echo "<br><br>"
."<b>"._SUBTITLE."</b> "
."("._BEDESCRIPTIVE.")<br>"
."<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"80\"><br><font class=\"content\">("._BADTITLES.")</font>";
if ($prefs[topicid] == 0) {
echo "<br><br>";
echo "<b>"._TOPIC.":</b> <select name=\"topic\">";
$toplist = $db->sql_query("select topicid, topictext from ".$prefix."_topics order by topictext");
echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
while(list($topicid, $topics) = $db->sql_fetchrow($toplist)) {
if ($topicid==$prefs[topicid]) {
$sel = "selected ";
}
echo "<option $sel value=\"$topicid\">$topics</option>\n";
$sel = "";
}
echo "</select>";
}
echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
echo "<input type=\"hidden\" name=\"schid\" value=\"$schid\">";
echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
echo "<input type=\"hidden\" name=\"tid\" value=\"$tid\">";
// echo "<br><br>"
// ."<b>"._STORYTEXT.":</b> ("._HTMLISFINE.")<br>"
// ."<textarea cols=\"50\" rows=\"12\" name=\"story\"></textarea><br>"
echo "<br><br>"
."<b>"._STORYTEXT.":</b> ("._HTMLISFINE.")<br>";
# ."<textarea cols=\"50\" rows=\"12\" name=\"story\"></textarea><br>"
wysiwyg_textarea("story", "", "NukeUser", "50", "12");
."<br><br><b>"._EXTENDEDTEXT.":</b><br>"
."<textarea cols=\"50\" rows=\"12\" name=\"storyext\"></textarea><br>"
."("._AREYOUSURE.")</font><br><br>"
."<font class=\"content\">"._ALLOWEDHTML."<br>";
while (list($key,) = each($AllowableHTML)) echo " <".$key.">";
echo "<br><br><input type=\"submit\" name=\"op\" value=\""._PREVIEW."\"> "
."<select name=\"posttype\">\n"
."<option value=\"exttrans\">"._EXTRANS."</option>\n"
."<option value=\"html\" >"._HTMLFORMATED."</option>\n"
."<option value=\"plaintext\" selected>"._PLAINTEXT."</option>\n"
."</select>"
."<br>("._SUBPREVIEW.")</form>";
CloseTable();
include ('footer.php');
}
function PreviewStory($name, $address, $subject, $story, $storyext, $topic,
$alanguage, $posttype, $schid, $lid, $sid, $tid) {
global $user, $cookie, $bgcolor1, $bgcolor2, $anonymous, $prefix, $multilingual, $AllowableHTML, $db;
include ('header.php');
$subject = stripslashes($subject);
$story = stripslashes($story);
$storyext = stripslashes($storyext);
if ($posttype=="exttrans") {
$f_story = nl2br(htmlspecialchars($story));
$f_storyext = nl2br(htmlspecialchars($storyext));
} elseif ($posttype=="plaintext") {
$f_story = nl2br($story);
$f_storyext = nl2br($storyext);
} else {
$f_story = $story;
$f_storyext = $storyext;
}
$story2 = "$f_story<br><br>$f_storyext";
OpenTable();
echo "<center><font class=\"title\"><b>"._NEWSUBPREVIEW."</b></font>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><i>"._STORYLOOK."</i></center><br><br>";
echo "<table width=\"70%\" bgcolor=\"$bgcolor2\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"align=\"center\"><tr><td>"
."<table width=\"100%\" bgcolor=\"$bgcolor1\" cellpadding=\"8\" cellspacing=\"1\" border=\"0\"><tr><td>";
if ($topic=="") {
$topicimage="AllTopics.gif";
$warning = "<center><blink><b>"._SELECTTOPIC."</b></blink></center>";
} else {
$warning = "";
$result = $db->sql_query("select topicimage from ".$prefix."_topics where topicid='$topic'");
list($topicimage) = $db->sql_fetchrow($result);
}
echo "<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
themepreview($subject, $story2);
echo "$warning"
."</td></tr></table></td></tr></table>"
."<br><br><center><font class=\"tiny\">"._CHECKSTORY."</font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<p><form action=\"modules.php?name=League&file=news\" method=\"post\">"
."<b>"._YOURNAME.":</b> ";
if (is_user($user)) {
cookiedecode($user);
echo "<a href=\"account.html\">$cookie[1]</a> <font class=\"content\">[ <a href=\"modules.php?name=Your_Account&op=logout\">"._LOGOUT."</a> ]</font>";
} else {
echo "$anonymous";
}
echo "<br><br><b>"._SUBTITLE.":</b><br>"
."<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"80\" value=\"$subject\">";
if ($topic=="") {
echo "<br><br>";
echo "<b>"._TOPIC.":</b> <select name=\"topic\">";
$toplist = $db->sql_query("select topicid, topictext from ".$prefix."_topics order by topictext");
echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
while(list($topicid, $topics) = $db->sql_fetchrow($toplist)) {
if ($topicid==$prefs[topicid]) {
$sel = "selected ";
}
echo "<option $sel value=\"$topicid\">$topics</option>\n";
$sel = "";
}
echo "</select>";
}
// echo "<br><br><b>"._STORYTEXT.":</b> ("._HTMLISFINE.")<br>"
// ."<textarea cols=\"50\" rows=\"12\" name=\"story\">$story</textarea><br>"
echo "<br><br>"
."<b>"._STORYTEXT.":</b> ("._HTMLISFINE.")<br>";
# ."<textarea cols=\"50\" rows=\"12\" name=\"story\"></textarea><br>"
wysiwyg_textarea("story", "", "NukeUser", "50", "12");
."<br><b>"._EXTENDEDTEXT.":</b><br>"
."<textarea cols=\"50\" rows=\"12\" name=\"storyext\">$storyext</textarea><br>"
."<font class=\"content\">("._AREYOUSURE.")</font><br><br>"
.""._ALLOWEDHTML."<br>";
while (list($key,) = each($AllowableHTML)) echo " <".$key.">";
echo "<br><br>"
."<input type=\"submit\" name=\"op\" value=\""._PREVIEW."\"> "
."<input type=\"submit\" name=\"op\" value=\""._OK."\"> "
."<select name=\"posttype\"><option value=\"exttrans\"";
if ($posttype=="exttrans") {
echo " selected";
}
echo ">"._EXTRANS."</option>\n"
."<OPTION value=\"html\"";;
if ($posttype=="html") {
echo " selected";
}
echo ">"._HTMLFORMATED."</option>\n"
."<OPTION value=\"plaintext\"";
if (($posttype!="exttrans") && ($posttype!="html")) {
echo " selected";
}
echo ">"._PLAINTEXT."</option></select>"
. "<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
. "<input type=\"hidden\" name=\"schid\" value=\"$schid\">"
. "<input type=\"hidden\" name=\"sid\" value=\"$sid\">"
. "<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
. "</form>";
CloseTable();
include ('footer.php');
}
function SubmitStory($name, $address, $subject, $story, $storyext, $topic,
$alanguage, $posttype, $schid, $lid, $sid, $tid) {
global $user, $EditedMessage, $cookie, $anonymous, $notify, $notify_email,
$notify_subject, $notify_message, $notify_from, $prefix, $db,
$aid, $Version_Num;
if (is_user($user)) {
cookiedecode($user);
$uid = $cookie[0];
$name = $cookie[1];
} else {
$uid = 1;
$name = "$anonymous";
}
$prefs = getLeaguePrefs($lid);
if ($uid == 1)
$author="";
if ($prefs[matchreport] == 0)
Header("Locations: modules.php?name=League&file=game&op=update_game&schid=$schid&lid=$lid&sid=$sid");
$subject = ereg_replace("\"", "''", $subject);
$subject = FixQuotes(filter_text($subject, "nohtml"));
if($posttype=="exttrans") {
$story = FixQuotes(nl2br(htmlspecialchars(check_words($story))));
$storyext = FixQuotes(nl2br(htmlspecialchars(check_words($storyext))));
} elseif($posttype=="plaintext") {
$story = FixQuotes(nl2br(filter_text($story)));
$storyext = FixQuotes(nl2br(filter_text($storyext)));
} else {
$story = FixQuotes(filter_text($story));
$storyext = FixQuotes(filter_text($storyext));
}
if ($prefs[autopost] == 0) {
$sql = "insert into ".$prefix."_queue ( qid, uid, uname, subject, story, storyext, timestamp, topic, alanguage) values (NULL, '$uid', '$name', '$subject', '$story', '$storyext', now(), '$prefs[topicid]', '$alanguage')";
echo $sql; exit();
$result = $db->sql_query($sql);
if(!$result) {
echo ""._ERROR."<br>";
exit();
}
if($notify) {
$notify_message = "$notify_message\n\n\n========================================================\n$subject\n\n\n$story\n\n$storyext\n\n$name";
mail($notify_email, $notify_subject, $notify_message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
}
}
else {
$haspoll = 0;
$id = 0;
$catid = getStoriesCat($tid);
if ($story == $storyext) $storyext = "";
$sql ="insert into ".$prefix."_stories (sid, catid, aid, title, time, hometext, bodytext, comments, counter, topic, informant, notes, ihome, alanguage, acomm, haspoll, pollID, score, ratings, associated) values (NULL, '$catid', '$name', '$subject', now(), '$story', '$storyext', '0', '0', '$prefs[topicid]', '$name', '$notes', '$prefs[publish]', '$alanguage', '0', '$haspoll', '$id', '0', '0', '')";
$result = $db->sql_query($sql);
if (!$result) {
Header("Locations: modules.php?name=League&file=game&op=update_game&schid=$schid&lid=$lid&sid=$sid");
}
$result = $db->sql_query("select tid1, tid2 from " . $prefix . "_league_schedule where id = $schid");
list($tid1, $tid2) = $db->sql_fetchrow($result);
if ($tid == $tid1)
$mr = "matchreport1";
else if ($tid == $tid2)
$mr = "matchreport2";
else
$mr = "";
if ($mr != "")
$db->sql_query("update " . $prefix . "_league_schedule set $mr = last_insert_id() where id = $schid");
if ($uid == 1) {
} else {
$db->sql_query("update ".$prefix."_users set counter=counter+1 where uid='$uid'");
}
if ($aid != "")
$db->sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'");
}
Header("Location: modules.php?name=League&file=game&op=update_game&schid=$schid&lid=$lid&sid=$sid");
}
function removeStory($sid, $schid, $lid, $ssid, $ok=0) {
global $aid, $prefix, $db;
$result2 = $db->sql_query("select aid from ".$prefix."_stories where sid='$sid'");
list($aaid) = $db->sql_fetchrow($result2);
if($ok) {
$counter--;
$db->sql_query("DELETE FROM ".$prefix."_stories where sid=$sid");
$db->sql_query("DELETE FROM ".$prefix."_comments where sid=$sid");
$db->sql_query("update ".$prefix."_poll_desc set artid='0' where artid='$sid'");
$result = $db->sql_query("update ".$prefix."_authors set counter=counter-1' where aid='$aid'");
$db->sql_query("update " . $prefix . "_league_schedule set matchreport1 = NULL where id = $schid and matchreport1 = $sid");
$db->sql_query("update " . $prefix . "_league_schedule set matchreport2 = NULL where id = $schid and matchreport2 = $sid");
Header("Location: modules.php?name=League&file=game&op=update_game&schid=$schid&lid=$lid&sid=$ssid");
}
else {
include("header.php");
OpenTable();
echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center>"._REMOVESTORY." $sid "._ANDCOMMENTS."";
echo "<br><br>[ <a href=\"admin.php\">"._NO."</a> | <a href=\"modules.php?name=League&file=news&op=RemoveStory&sid=$sid&schid=$schid&lid=$lid&ssid=$ssid&ok=1\">"._YES."</a> ]</center>";
CloseTable();
include("footer.php");
}
}
switch($op) {
case ""._PREVIEW."":
PreviewStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype, $schid, $lid, $sid, $tid);
break;
case ""._OK."":
SubmitStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype, $schid, $lid, $sid, $tid);
break;
case "RemoveStory":
removeStory($sid, $schid, $lid, $ssid, $ok);
break;
default:
defaultDisplay($schid, $lid, $sid, $tid);
break;
}
?>
|