Code:<?php
// File: index.php
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Version For PHPNUKE by Rob wolf visit http://www.tremorsfan.com for the latest version.
// Original Author of file: Rebecca Smallwood
// Fictioneer Updrades to file by Theresa Sanchez and Joyce Melton
// ----------------------------------------------------------------------
if (!preg_match("/modules.php/i", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$pagetitle = "- Fictioneer";
$ModName = Fictioneer;
$dontcare = -1;
include("modules/$ModName/config.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
//Intro page
function FictioneerMain()
{
global $bgcolor1, $bgcolor2, $prefix;
$result = $mysqli->query("select * from ".$prefix."_fictioneer_settings");
if($settings = $result->fetch_assoc)
{
FictioneerHeader();
echo "<br><table width=\"100%\">";
echo "<tr valign=\"top\"><td width=\"60%\">";
echo "".$settings[welcome]."";
echo "</td>";
echo "<td width=\"40%\">";
echo "<b>Categories</b><br><br>";
ListCategories();
echo "<br></td></tr></table>";
FictioneerFooter();
}
else
{
echo "This is an error message.";
}
}
//Header
function FictioneerHeader()
{
global $bgcolor1, $bgcolor2, $ModName, $sitename, $user, $cookie, $subsoff;
include("header.php");
OpenTable();
if (is_user($user))
{
cookiedecode($user);
$author = $cookie[1];
}
echo "<br><table width=\"100%\"><tr><td colspan=\"2\"><center><b>$sitename -- "._FNNAME."</b></center></td></tr>";
echo "<tr><td>";
echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"modules.php?name=$ModName&file=index&options=SearchResults&pagenumber=1&searchterm=$searchterm&searchkind=$searchkind&totalpages=-1\">";
echo "<a href=\"modules.php?name=$ModName&file=index\">Main</a> | ";
if($subsoff == "1")
echo "<a href=\"modules.php?name=$ModName&file=index&options=ViewRules\">Add Story</a> | ";
echo "<a href=\"modules.php?name=$ModName&file=index&options=DisplayStories&pagenumber=1&categoryid=-1&totalpages=-1\">Recent Stories</a> | ";
if(($subsoff == "1") && (is_user($user)))
echo "<a href=\"modules.php?name=$ModName&file=index&options=SearchResults&searchterm=".$author."&pagenumber=1&searchkind=author&totalpages=-1\">Your Stories</a> | ";
echo "<a href=\"modules.php?name=$ModName&file=index&options=Help\">Help</a> | ";
echo "<select name=\"searchkind\">";
echo "<option value=\"author\">Author</option>";
echo "<option value=\"title\">Title</option>";
echo "<option value=\"keywords\">Keywords</option>";
echo "<option value=\"summary\">Summary</option>";
echo "</select>";
echo "<input type=\"text\" name=\"searchterm\" size=\"10\"> ";
echo "<input type=\"submit\" name=\"search\" value=\"Search\"> ";
echo "</form>";
echo "</td></tr></table>";
CloseTable();
OpenTable();
}
//Footer
function FictioneerFooter()
{
global $bgcolor1, $bgcolor2;
CloseTable();
echo "<BR><div align=\"center\">Fictioneer Module 0.5 by <a href=\"http://www.fictioneer.net\">Theresa Sanchez</a>, and <a href=\"http://bigcloset.ateros.com\">Joyce Melton</a></div>";
echo "<div align=\"center\">Original FanFiction Module by <a href=\"http://orodruin.sourceforge.net\">Rebecca Smallwood</a></div>";
echo "<div align=\"center\">Version for phpnuke by <a href=\"http://www.tremorsfan.com\">Rob Wolf</a> Dev v0.2</div>";
include("footer.php");
}
//Helpfile for clueless people
function Help()
{
global $bgcolor1, $bgcolor2, $ModName;
FictioneerHeader();
include ("modules/$ModName/help.txt");
FictioneerFooter();
}
//listing of all the top level categories
function ListCategories()
{
global $bgcolor1, $bgcolor2, $prefix, $ModName;
$result = $mysqli->query("select * from ".$prefix."_fictioneer_categories WHERE parent=-1");
while($catlist = $result->fetch_assoc)
{
echo "<a href=\"modules.php?name=$ModName&file=index&options=DisplayStories&pagenumber=1&categoryid=".$catlist[categoryid]."&totalpages=-1\">".$catlist[category]."</a><BR>";
echo "".$catlist[description]."<BR><BR>";
}
}
//this is here so that the admin can view the story without having the header junk and all that
function AdminViewStory($storyid, $author, $title)
{
global $bgcolor1, $bgcolor2, $prefix, $ModName, $nukeurl, $user, $cookie, $admin;
$result = $mysqli->query("select * from ".$prefix."_fictioneer_stories WHERE storyid=$storyid");
$storyresults = $result->fetch_assoc;
if (is_admin($admin))
{
echo "<table width=\"100%\"><tr><td>";
echo "".$storyresults[title]." by <a href=\"user.php?op=userinfo&uname=".$storyresults[author]."\">".$storyresults[author]."</a></td><td>";
echo "</td><td align=\"right\">";
$result = $mysqli->query("select * from ".$prefix."_fictioneer_stories WHERE parentstoryid='$storyresults[parentstoryid]' ORDER by storyid ASC");
echo "<form name=\"jump\">";
echo "<select name=\"jumpmenu\" OnChange=\"location.href=jump.jumpmenu.options[selectedIndex].value\">";
echo "<option>Chapters</option>";
while ($chapterdisplay = $result->fetch_assoc)
{
echo "<option value=\"modules.php?name=$ModName&file=index&options=DisplayStory&storyid=".$chapterdisplay[storyid]."\">$chapterdisplay[title]</option>";
}
echo "</select>";
echo "</form>";
echo "</td></tr></table>";
//writes out the story, and replaces the carriage returns with <BR> tags
$file = "modules/$ModName/stories/$storyresults[author]/$storyresults[storyid].txt";
$log_file = fopen($file, "r");
$file_contents = fread($log_file, filesize($file));
echo(nl2br(htmlspecialchars($file_contents)));
fclose($log_file);
echo "<hr>";
echo "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"modules.php?op=modload&name=Fictioneer&file=index&options=SubmitVauthorStory&storyid=".$storyresults[storyid]."\">";
echo ""._FNTITLE.": <INPUT type=\"text\" name=\"title\" value=\"$storyresults[title]\"><BR><BR>";
echo ""._FNKEYWORDS.": <TEXTAREA name=\"keywords\" COLS=40 ROWS=3>".$storyresults[keywords]."</textarea><BR><BR>";
echo ""._FNSUMMARY.": <TEXTAREA name=\"summary\" COLS=40 ROWS=3>".$storyresults[summary]."</textarea><BR><BR>";
echo "<INPUT type=\"hidden\" name=\"storyid\" value=\"$storyresults[storyid]\">";
echo "<INPUT type=\"hidden\" name=\"author\" value=\"$storyresults[author]\">";
echo "<INPUT type=\"hidden\" name=\"categoryid\" value=\"$storyresults[categoryid]\">";
echo "<INPUT type=\"hidden\" name=\"parentstoryid\" value=\"$storyresults[parentstoryid]\">";
echo "<INPUT type=\"hidden\" name=\"ratingid\" value=\"$storyresults[ratingid]\">";
echo "<INPUT type=\"hidden\" name=\"char1\" value=\"$storyresults[char1]\">";
echo "<INPUT type=\"hidden\" name=\"char2\" value=\"$storyresults[char2]\">";
echo "<INPUT type=\"hidden\" name=\"genre\" value=\"$storyresults[genre]\">";
echo "<INPUT type=\"hidden\" name=\"roundrobin\" value=\"$storyresults[roundrobin]\">";
echo ""._FNTEXT.": <TEXTAREA wrap=\"virtual\" name=\"story\" COLS=40 ROWS=6>";
include ("modules/$ModName/stories/$storyresults[author]/$storyresults[storyid].txt");
echo "</textarea><BR><BR>";
echo "<INPUT type=\"submit\" name=\"buttonaction\" value=\"Update Story\">";
}
}
//notes for public
//add previous and next 2 pages and have it show what page you're on
//if no results when sorting, have it say so.
//if no results on search, say so
//if no stories by author, say so
//notes for admin
//fix weird e-mail return address
//figure out fatal head error
switch($options)
{
case "Help":
Help();
break;
case "ViewRules":
include_once ("modules/$ModName/fn-submitstory.php");
ViewRules();
break;
case "ChooseCategory":
include_once ("modules/$ModName/fn-submitstory.php");
ChooseCategory();
break;
case "SearchResults":
include_once ("modules/$ModName/fn-displaystory.php");
SearchResults($searchterm, $searchkind, $pagenumber, $totalpages);
break;
case "SortResults":
include_once ("modules/$ModName/fn-displaystory.php");
SortResults($categoryid, $ratingid, $char1, $char2, $genre, $pagenumber, $totalpages);
break;
case "SubmitVauthorStory":
include_once ("modules/$ModName/fn-submitstory.php");
SubmitVauthorStory($categoryid, $parentstoryid, $title, $keywords, $summary, $story, $ratingid, $char1, $char2, $genre, $author, $email, $roundrobin, $buttonaction, $imgfile, $imgfile_name, $storyid, $unvalidated);
break;
case "SubmitUnvalidAuthorStory":
include_once ("modules/$ModName/fn-submitstory.php");
SubmitUnvalidAuthorStory($categoryid, $parentstoryid, $title, $keywords, $summary, $story, $ratingid, $char1, $char2, $genre, $author, $roundrobin, $buttonaction, $imgfile, $imgfile_name, $storyid, $unvalidated);
break;
case "SubmitStory":
include_once ("modules/$ModName/fn-submitstory.php");
SubmitStory($author, $user, $categoryid, $parentstoryid, $roundrobin);
break;
case "EditStory":
include_once ("modules/$ModName/fn-submitstory.php");
EditStory($storyid, $categoryid);
break;
case "DeleteStory":
include_once ("modules/$ModName/fn-submitstory.php");
DeleteStory($deleteall, $storyid, $author, $submit, $transmit);
break;
case "DisplayStories":
include_once ("modules/$ModName/fn-displaystory.php");
DisplayStories($summary, $pagenumber, $categoryid, $totalpages);
break;
case "DisplayReviews":
include_once ("modules/$ModName/fn-reviews.php");
DisplayReviews($parentstoryid);
break;
case "DeleteReviews":
include_once ("modules/$ModName/fn-reviews.php");
DeleteReviews($reviewid, $submit);
break;
case "SubmitReview":
include_once ("modules/$ModName/fn-reviews.php");
SubmitReview($parentstoryid, $submit, $comment, $reviewer, $vote);
break;
case "DisplayStory":
include_once ("modules/$ModName/fn-displaystory.php");
DisplayStory($storyid, $author, $title);
break;
case "AdminViewStory":
//include_once ("modules/$ModName/fn-submitstory.php");
AdminViewStory($storyid, $author, $title);
break;
case "SendAcceptance":
include_once ("modules/$ModName/fn-letters.php");
SendAcceptance($submit, $author, $email, $subject, $yesletter);
break;
case "SendNoThankYou":
include_once ("modules/$ModName/fn-letters.php");
SendNoThankYou($submit, $author, $email, $subject, $noletter);
break;
default:
FictioneerMain();
break;
}
?>
|