public static function validatePage()
 {
     $databaseHost = Util::getStringParamDefault($_POST, "databaseHost", "");
     $databaseUsername = Util::getStringParamDefault($_POST, "databaseUsername", "");
     $databasePassword = Util::getStringParamDefault($_POST, "databasePassword", "");
     $databaseName = Util::getStringParamDefault($_POST, "databaseName", "");
     $errors = array();
     if (strlen($databaseHost) == 0) {
         $errors[] = new RawText("Host must be set.");
     }
     if (strlen($databaseUsername) == 0) {
         $errors[] = new RawText("Username must be set.");
     }
     if (strlen($databasePassword) == 0) {
         $errors[] = new RawText("Password must be set.");
     }
     if (strlen($databaseName) == 0) {
         $errors[] = new RawText("Database must be set.");
     }
     if (count($errors) == 0) {
         global $dbHost, $dbUser, $dbPassword, $dbDatabase;
         $dbHost = $databaseHost;
         $dbUser = $databaseUsername;
         $dbPassword = $databasePassword;
         $dbDatabase = $databaseName;
         try {
             $dbConnection = Util::getDbConnection();
         } catch (Exception $e) {
             $errors[] = new RawText("Unable to connect to database: " . $e->getMessage());
         }
     }
     if (count($errors) == 0) {
         $dbStatement = $dbConnection->prepare("SHOW TABLES");
         $dbStatement->execute();
         $tables = $dbStatement->fetchAll(PDO::FETCH_NUM);
         if (count($tables) > 0) {
             $errors[] = new RawText("Database already contains tables.");
         }
     }
     if (count($errors) > 0) {
         return new DatabaseConnectionPage(new UnorderedList($errors));
     }
     return null;
 }
Esempio n. 2
0
    $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
    $dbStatement->execute();
    if ($dbStatement->rowCount() != 1) {
        throw new HardStoryException("Unable to update the episode record for editing.");
    }
    for ($i = 0; $i < $linkCount; $i++) {
        $var1 = "linkID" . $i;
        $var2 = "isBackLink" . $i;
        $var3 = "option" . $i;
        $var4 = "backlink" . $i;
        $dbStatement;
        if (${$var2} == "Y") {
            $dbStatement = Util::getDbConnection()->prepare("UPDATE Link " . "SET TargetEpisodeID = :backlink, " . "Description     = :option " . "WHERE LinkID = :linkID");
            $dbStatement->bindParam(":backlink", ${$var4}, PDO::PARAM_INT);
        } else {
            $dbStatement = Util::getDbConnection()->prepare("UPDATE Link " . "SET Description = :option " . "WHERE LinkID = :linkID");
        }
        $dbStatement->bindParam(":option", ${$var3}, PDO::PARAM_STR);
        $dbStatement->bindParam(":linkID", ${$var1}, PDO::PARAM_INT);
        $dbStatement->execute();
        if ($dbStatement->rowCount() != 1) {
            throw new HardStoryException("Unable to update the link record for editing.");
        }
    }
}
if ($command == "Save") {
    ?>

<HTML><HEAD>
<TITLE>Finished Creating Episode <?php 
    echo $episode;
Esempio n. 3
0
    </TR>
</TABLE>

</CENTER>

<?php 
    require __DIR__ . "/include/config/Footer.php";
    ?>

</BODY></HTML>

<?php 
    exit;
}
$statusValue = $status == 1 ? 0 : 2;
$dbStatement = Util::getDbConnection()->prepare("UPDATE Episode " . "SET " . ($status == 1 ? "AuthorSessionID" : "EditorSessionID") . " = 0, " . "Status = :statusValue, " . "LockDate = '-', " . "LockKey = 0 " . "WHERE EpisodeID = :episode");
$dbStatement->bindParam(":statusValue", $statusValue, PDO::PARAM_INT);
$dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
$dbStatement->execute();
if ($dbStatement->rowCount() != 1) {
    throw new HardStoryException("Unable to unlock the episode record.");
}
?>

<HTML><HEAD>
<TITLE>Cleared Episode <?php 
echo $episode;
?>
 Lock</TITLE>
</HEAD><BODY>
//$dbStatement = Util::getDbConnection()->prepare( "SELECT * FROM Episode WHERE 1=2" );
$dbStatement = Util::getDbConnection()->prepare("SELECT COUNT( * ) FROM Episode WHERE Status = 2 OR Status = 3");
$dbStatement->execute();
$row = $dbStatement->fetch(PDO::FETCH_NUM);
if (!$row) {
    throw new HardStoryException("Problem fetching created episode count row from the database.");
}
$created = $row[0];
$dbStatement = Util::getDbConnection()->prepare("SELECT COUNT( * ) FROM Episode WHERE Status = 0 OR Status = 1");
$dbStatement->execute();
$row = $dbStatement->fetch(PDO::FETCH_NUM);
if (!$row) {
    throw new HardStoryException("Problem fetching empty episode count row from the database.");
}
$empty = $row[0];
$dbStatement = Util::getDbConnection()->prepare("SELECT COUNT( * ) FROM Episode");
$dbStatement->execute();
$row = $dbStatement->fetch(PDO::FETCH_NUM);
if (!$row) {
    throw new HardStoryException("Problem fetching episode count row from the database.");
}
$count = $row[0];
?>

<HTML><HEAD>
<TITLE><?php 
echo $storyName;
?>
: Statistics</TITLE>
</HEAD><BODY>
Esempio n. 5
0
        if ($method == "author") {
            $dbStatement = Util::getDbConnection()->prepare($queryPart1 . "AuthorName LIKE :text " . $queryPart2);
            $dbStatement->bindParam(":text", $text, PDO::PARAM_STR);
        } else {
            if ($method == "time") {
                $dbStatement = Util::getDbConnection()->prepare($queryPart1 . "CreationDate LIKE :text " . $queryPart2);
                $dbStatement->bindParam(":text", $text, PDO::PARAM_STR);
            } else {
                if ($method == "extendable") {
                    $dbStatement = Util::getDbConnection()->prepare($queryPart1 . "IsExtendable = 'Y' " . $queryPart2);
                } else {
                    if ($method == "linkable") {
                        $dbStatement = Util::getDbConnection()->prepare($queryPart1 . "IsLinkable = 'Y' " . $queryPart2);
                    } else {
                        if ($method == "days") {
                            $dbStatement = Util::getDbConnection()->prepare($queryPart1 . "CreationTimestamp > SUBDATE( NOW(), INTERVAL :days DAY ) " . $queryPart2);
                            $dbStatement->bindParam(":days", $days, PDO::PARAM_INT);
                        } else {
                            throw new HardStoryException("The specified search method is not supported.");
                        }
                    }
                }
            }
        }
    }
}
$dbStatement->execute();
$rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
?>

<HTML><HEAD>
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
For information about Extend-A-Story and its authors, please visit the website:
http://www.sir-toby.com/extend-a-story/
*/
require __DIR__ . "/include/Extend-A-Story.php";
use Extend_A_Story\Util;
Util::getSessionAndUserIDs($sessionID, $userID);
$storyName = Util::getStringValue("StoryName");
$siteName = Util::getStringValue("SiteName");
$storyHome = Util::getStringValue("StoryHome");
$siteHome = Util::getStringValue("SiteHome");
$episode = Util::getIntParam($_GET, "episode");
$dbStatement = Util::getDbConnection()->prepare("SELECT Link.SourceEpisodeID, " . "Episode.Title " . "FROM Link, " . "Episode " . "WHERE Link.SourceEpisodeID = Episode.EpisodeID " . "AND Link.TargetEpisodeID = :episode " . "ORDER BY Episode.EpisodeID");
$dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
$dbStatement->execute();
$rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
?>

<HTML><HEAD>
<TITLE><?php 
echo $storyName;
?>
: Back Link Trace for Episode <?php 
echo $episode;
?>
</TITLE>
</HEAD><BODY>
Esempio n. 7
0
    $dbStatement->execute();
    $row = $dbStatement->fetch(PDO::FETCH_NUM);
    if (!$row) {
        throw new HardStoryException("Unable to fetch the max EpisodeEditLogID record from database.");
    }
    $maxEpisodeEditLogID = (int) $row[0];
    $start = Util::getIntParamDefault($_GET, "start", 0);
    if ($start < 1 || $start > $maxEpisodeEditLogID) {
        $start = $maxEpisodeEditLogID;
    }
    $dbStatement = Util::getDbConnection()->prepare("SELECT EpisodeEditLogID, " . "EpisodeID, " . "EditDate, " . "EditLogEntry " . "FROM EpisodeEditLog " . "WHERE EpisodeEditLogID <= :start " . "ORDER BY EpisodeEditLogID DESC " . "LIMIT 20");
    $dbStatement->bindParam(":start", $start, PDO::PARAM_INT);
    $dbStatement->execute();
    $edits = $dbStatement->fetchAll(PDO::FETCH_NUM);
}
$dbStatement = Util::getDbConnection()->prepare("SELECT UserID, " . "LoginName " . "FROM User " . "ORDER BY LoginName");
$dbStatement->execute();
$users = $dbStatement->fetchAll(PDO::FETCH_NUM);
if ($command == "listOrphans") {
    ?>

<HTML><HEAD>
<TITLE><?php 
    echo $storyName;
    ?>
: Administration</TITLE>
</HEAD><BODY>

<CENTER>

<H1><?php 
<?php 
    sort($curEpisodes, SORT_NUMERIC);
    $nextEpisodes = array();
    for ($i = 0; $i < count($curEpisodes); $i++) {
        $episode = $curEpisodes[$i];
        $dbStatement = Util::getDbConnection()->prepare("SELECT Parent, " . "Title " . "FROM Episode " . "WHERE EpisodeID = :episode");
        $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
        $dbStatement->execute();
        $row = $dbStatement->fetch(PDO::FETCH_NUM);
        if (!$row) {
            throw new HardStoryException("Problem fetching episode row from database.");
        }
        $parent = $row[0];
        $title = $row[1];
        $dbStatement = Util::getDbConnection()->prepare("SELECT TargetEpisodeID, " . "IsCreated, " . "IsBackLink " . "FROM Link " . "WHERE SourceEpisodeID = :episode " . "ORDER BY LinkID");
        $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
        $dbStatement->execute();
        $rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
        $children = "";
        for ($j = 0; $j < count($rows); $j++) {
            $row = $rows[$j];
            $target = $row[0];
            $isCreated = $row[1];
            $isBackLink = $row[2];
            if ($isBackLink == "Y") {
                $color = "#0000FF";
            } else {
                if ($isCreated == "Y") {
                    $color = "#008000";
                    array_push($nextEpisodes, $target);
Esempio n. 9
0
        }
        $dbStatement = Util::getDbConnection()->prepare("UPDATE Link " . "SET IsCreated = 'N' " . "WHERE TargetEpisodeID = :episode");
        $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
        $dbStatement->execute();
        if ($dbStatement->rowCount() != 1) {
            throw new HardStoryException("Problem resetting link IsCreated status.");
        }
        $command = "Done";
        $message = "Episode Deleted";
    } else {
        $command = "DeleteEpisode";
    }
}
if ($command == "RevokeAuthorSave") {
    Util::createEpisodeEditLog($episode, "Author's edit permission revoked by " . $userName . ".");
    $dbStatement = Util::getDbConnection()->prepare("UPDATE Episode " . "SET AuthorSessionID   = 0, " . "EditorSessionID   = :sessionID, " . "Status            = 2, " . "LockDate          = '', " . "LockKey           = 0, " . "CreationTimestamp = now() " . "WHERE EpisodeID = :episode");
    $dbStatement->bindParam(":sessionID", $sessionID, PDO::PARAM_INT);
    $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
    $dbStatement->execute();
    if ($dbStatement->rowCount() != 1) {
        throw new HardStoryException("Unable to update the episode record.");
    }
    $message = "Author's Edit Permission Revoked";
    $command = "Done";
}
if ($command == "Done") {
    ?>

<HTML><HEAD>
<TITLE>Edit Completed</TITLE>
</HEAD><BODY>
Esempio n. 10
0
 public static function canEditEpisode($sessionID, $userID, $episodeID)
 {
     if ($userID != 0) {
         return true;
     }
     $dbStatement = Util::getDbConnection()->prepare("SELECT AuthorSessionID, " . "CreationDate " . "FROM Episode " . "WHERE EpisodeID = :episodeID");
     $dbStatement->bindParam(":episodeID", $episodeID, PDO::PARAM_INT);
     $dbStatement->execute();
     $row = $dbStatement->fetch(PDO::FETCH_NUM);
     if (!$row) {
         throw new HardStoryException("Episode " . $episodeID . " not found.");
     }
     $authorSessionID = $row[0];
     $creationDate = $row[1];
     if ($sessionID == $authorSessionID) {
         $maxEditDays = Util::getIntValue("MaxEditDays");
         $creationTime = strtotime($creationDate);
         $curTime = time();
         $seconds = $curTime - $creationTime;
         $minutes = (int) ($seconds / 60);
         $hours = (int) ($minutes / 60);
         $days = (int) ($hours / 24);
         if ($days < $maxEditDays) {
             return true;
         }
     }
     return false;
 }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
For information about Extend-A-Story and its authors, please visit the website:
http://www.sir-toby.com/extend-a-story/
*/
require __DIR__ . "/include/Extend-A-Story.php";
use Extend_A_Story\Util;
Util::getSessionAndUserIDs($sessionID, $userID);
$storyName = Util::getStringValue("StoryName");
$siteName = Util::getStringValue("SiteName");
$storyHome = Util::getStringValue("StoryHome");
$siteHome = Util::getStringValue("SiteHome");
$dbStatement = Util::getDbConnection()->prepare("SELECT EpisodeID " . "FROM Episode " . "WHERE Status = 1 " . "ORDER BY EpisodeID");
$dbStatement->execute();
$rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
?>

<HTML><HEAD>
<TITLE><?php 
echo $storyName;
?>
: Locked Episodes</TITLE>
</HEAD><BODY>

<CENTER>
<H1><?php 
echo $storyName;
?>
Esempio n. 12
0
        </TD>
    </TR>
</TABLE>

</CENTER>

<?php 
    require __DIR__ . "/include/config/Footer.php";
    ?>

</BODY></HTML>

<?php 
    exit;
}
$dbStatement = Util::getDbConnection()->prepare("SELECT EpisodeEditLogID, " . "EditDate, " . "EditLogEntry " . "FROM EpisodeEditLog " . "WHERE EpisodeID = :episode " . "ORDER BY EpisodeEditLogID");
$dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
$dbStatement->execute();
$rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
?>

<HTML><HEAD>
<TITLE>Viewing Edits for Episode <?php 
echo $episode;
?>
</TITLE>
</HEAD><BODY>

<CENTER>
<H1>Viewing Edits for Episode <?php 
echo $episode;
$row = $dbStatement->fetch(PDO::FETCH_NUM);
if (!$row) {
    throw new HardStoryException("Problem fetching scheme row from the database.");
}
$schemeName = $row[0];
$bgcolor = $row[1];
$text = $row[2];
$link = $row[3];
$vlink = $row[4];
$alink = $row[5];
$background = $row[6];
$uncreatedLink = $row[7];
$createdLink = $row[8];
$backLinkedLink = $row[9];
$body = "<BODY BGCOLOR=\"" . $bgcolor . "\" " . "TEXT=\"" . $text . "\" " . "LINK=\"" . $link . "\" " . "VLINK=\"" . $vlink . "\" " . "ALINK=\"" . $alink . "\"" . (empty($background) ? ">" : " BACKGROUND=\"" . $background . "\">");
$dbStatement = Util::getDbConnection()->prepare("SELECT SchemeID, SchemeName FROM Scheme");
$dbStatement->execute();
$rows = $dbStatement->fetchAll(PDO::FETCH_NUM);
?>

<HTML><HEAD>
<TITLE><?php 
echo $storyName;
?>
: Scheme Preview</TITLE>
</HEAD><?php 
echo $body;
?>

<CENTER>
<H1><?php