Esempio n. 1
0
    }
}
for ($i = 0; $i < $linkCount; $i++) {
    $var1 = "option" . $i;
    $var2 = "backlink" . $i;
    $var3 = "isBackLink" . $i;
    if (!empty(${$var1})) {
        $linkFound = true;
    }
    if ($editing && empty(${$var1})) {
        $warning .= "You must provide a description for option " . ($i + 1) . ".<BR>";
    }
    if (strlen(${$var1}) > 255) {
        $warning .= "The description for option " . ($i + 1) . " cannot be longer then 255 characters.<BR>";
    }
    if (Util::maximumWordLength(${$var1}) > 30) {
        $warning .= "The description for option " . ($i + 1) . " cannot contain a word with more than 30 characters in it.<BR>";
    }
    if (${$var2} != 0 && !$editing || ${$var3} == "Y") {
        if ($editing && ${$var2} == $episode) {
            $warning .= "Option " . ($i + 1) . " is back linked to the same episode you are editing.<BR>";
        }
        if (empty(${$var1}) && !$editing) {
            $warning .= "Option " . ($i + 1) . " is back linked, but has no description.<BR>";
        }
        $dbStatement = Util::getDbConnection()->prepare("SELECT IsLinkable " . "FROM Episode " . "WHERE EpisodeID = :episodeID");
        $dbStatement->bindParam(":episodeID", ${$var2}, PDO::PARAM_INT);
        $dbStatement->execute();
        $row = $dbStatement->fetch(PDO::FETCH_NUM);
        if (!$row) {
            $warning .= "The back linked episode for option " . ($i + 1) . " doesn't exist.<BR>";
Esempio n. 2
0
        throw new HardStoryException("Unable to update the lock on the episode.");
    }
}
$message = "";
$linkDescription = "";
$linkEpisode = 0;
if ($command == "AddLinkSave") {
    $linkDescription = Util::getStringParam($_POST, "description");
    $linkEpisode = Util::getIntParamDefault($_POST, "linkedEpisode", 0);
    if (empty($linkDescription)) {
        $message .= "You must enter the link description.<BR>";
    }
    if (strlen($linkDescription) > 255) {
        $message .= "The link description cannot be longer then 255 characters.<BR>";
    }
    if (Util::maximumWordLength($linkDescription) > 30) {
        $message .= "The link description cannot contain a word with more than 30 characters.<BR>";
    }
    if ($linkEpisode != 0) {
        if ($linkEpisode == $episode) {
            $message .= "The link cannot link back to the same episode you are editing.<BR>";
        }
        $dbStatement = Util::getDbConnection()->prepare("SELECT COUNT( * ) " . "FROM Link " . "WHERE SourceEpisodeID = :episode " . "AND TargetEpisodeID = :linkEpisode");
        $dbStatement->bindParam(":episode", $episode, PDO::PARAM_INT);
        $dbStatement->bindParam(":linkEpisode", $linkEpisode, PDO::PARAM_INT);
        $dbStatement->execute();
        $row = $dbStatement->fetch(PDO::FETCH_NUM);
        if (!$row) {
            throw new HardStoryException("Problem fetching link count row from the database.");
        }
        if ($row[0] != 0) {