Beispiel #1
0
 public function isLatest() : bool
 {
     $latest = Episodes::getLatest();
     return $this->is($latest);
 }
Beispiel #2
0
    }
}, array(Input::IS_OPTIONAL => true, Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_INVALID => 'Post type (@value) is invalid'))))->out();
if (!empty($type) && $type === 'reservation') {
    if (Permission::insufficient('member')) {
        Response::fail();
    }
    Users::reservationLimitExceeded();
}
$Image = Posts::checkImage(Posts::validateImageURL());
if (empty($type)) {
    Response::done(array('preview' => $Image->preview, 'title' => $Image->title));
}
$insert = array('preview' => $Image->preview, 'fullsize' => $Image->fullsize);
$season = Episodes::validateSeason(Episodes::ALLOW_MOVIES);
$episode = Episodes::validateEpisode();
$epdata = Episodes::getActual($season, $episode, Episodes::ALLOW_MOVIES);
if (empty($epdata)) {
    Response::fail("The specified episode (S{$season}E{$episode}) does not exist");
}
$insert['season'] = $epdata->season;
$insert['episode'] = $epdata->episode;
$ByID = $currentUser->id;
if (Permission::sufficient('developer')) {
    $username = Posts::validatePostAs();
    if (isset($username)) {
        $PostAs = Users::get($username, 'name', 'id,role');
        if (empty($PostAs)) {
            Response::fail('The user you wanted to post as does not exist');
        }
        if ($type === 'reservation' && !Permission::sufficient('member', $PostAs->role) && !isset($_POST['allow_nonmember'])) {
            Response::fail('The user you wanted to post as is not a club member, do you want to post as them anyway?', array('canforce' => true));
Beispiel #3
0
 private static function _genericPostInfo(Post $Post, array $data, array &$details)
 {
     $label = CoreUtils::capitalize($data['type']) . " #{$data['id']}";
     if (!empty($Post)) {
         $label = $Post->toAnchor($label);
     }
     $details[] = array('Post', $label);
     if (empty($Post)) {
         $details[] = array('Still exists', false);
     }
     $EpID = (new Episode($Post))->formatTitle(AS_ARRAY, 'id');
     $EpData = Episodes::parseID($EpID);
     $Episode = Episodes::getActual($EpData['season'], $EpData['episode'], Episodes::ALLOW_MOVIES);
     $details[] = array('Posted under', !empty($Episode) ? "<a href='" . $Episode->formatURL() . "'>{$EpID}</a>" : $EpID . ' (now deleted/moved)');
     if (!empty($Post)) {
         $details[] = array(($data['type'] === 'request' ? 'Requested' : 'Reserved') . ' by', Users::get($data['type'] === 'request' ? $Post->requested_by : $Post->reserved_by)->getProfileLink());
         if ($data['type'] === 'request') {
             if (!empty($Post->reserved_by)) {
                 $details[] = array('Reserved by', Users::get($Post->reserved_by)->getProfileLink());
             } else {
                 $details[] = array('Reserved', false);
             }
         }
     }
 }
Beispiel #4
0
<?php

use App\CoreUtils;
use App\Models\Episode;
use App\Episodes;
use App\RegExp;
if (!preg_match(new RegExp('^(\\d+)?(-?[a-z\\-]+)?$', 'i'), $data, $title)) {
    CoreUtils::notFound();
}
$Database->where('season', 0);
if (isset($title[1]) && is_numeric($title[1])) {
    $Database->where('episode', intval($data, 10));
} else {
    if (!empty($title[2])) {
        $data = strtolower($title[2]);
        $Database->where("regexp_replace(regexp_replace(lower(\"title\"), '[^a-z]', '-', 'g'), '-{2,}', '-', 'g') = '{$data}'");
    } else {
        $Database->reset();
        CoreUtils::notFound();
    }
}
/** @var $CurrtentEpisode Episode */
$CurrtentEpisode = $Database->getOne('episodes');
if (empty($CurrtentEpisode)) {
    CoreUtils::notFound();
}
$CurrtentEpisode = $CurrtentEpisode->addAiringData();
Episodes::loadPage($CurrtentEpisode);
Beispiel #5
0
         }
         if (!isset(Episodes::$ALLOWED_PREFIXES[$match[1]])) {
             $mostSimilar = null;
             $mostMatcing = 0;
             foreach (Episodes::$ALLOWED_PREFIXES as $prefix => $shorthand) {
                 foreach (array($prefix, $shorthand) as $test) {
                     $matchingChars = similar_text(strtolower($match[1]), strtolower($test));
                     if ($matchingChars >= 3 && $matchingChars > $mostMatcing) {
                         $mostMatcing = $matchingChars;
                         $mostSimilar = $prefix;
                     }
                 }
             }
             Response::fail("Unsupported prefix: {$match[1]}. " . (isset($mostSimilar) ? "<em>Did you mean <span class='color-ui'>{$mostSimilar}</span></em>?" : 'Use a backslash if the colon is part of the title (e.g. <code>\\:</code>)'));
         }
         $title = Episodes::removeTitlePrefix($value);
         if (Input::checkStringLength($title, $range, $code)) {
             return $code;
         }
         $value = "{$match[1]}: {$title}";
     } else {
         if (Input::checkStringLength($value, $range, $code)) {
             return $code;
         }
     }
 }, array(Input::IN_RANGE => [5, 35], Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => "{$What} title is missing", Input::ERROR_RANGE => "{$What} title must be between @min and @max characters", 'prefix-movieonly' => "Prefixes can only be used for movies"))))->out();
 CoreUtils::checkStringValidity($insert['title'], "{$What} title", INVERSE_EP_TITLE_PATTERN);
 $airs = (new Input('airs', 'timestamp', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'No air date & time specified', Input::ERROR_INVALID => 'Invalid air date and/or time (@value) specified'))))->out();
 if (empty($airs)) {
     Response::fail('Please specify an air date & time');
 }
Beispiel #6
0
<?php

use App\CoreUtils;
use App\Episodes;
use App\Pagination;
use App\Permission;
/** @var $do string */
$Pagination = new Pagination('episodes', 10, $Database->where('season != 0')->count('episodes'));
CoreUtils::fixPath("/episodes/{$Pagination->page}");
$heading = "Episodes";
$title = "Page {$Pagination->page} - {$heading}";
$Episodes = Episodes::get($Pagination->getLimit());
if (isset($_GET['js'])) {
    $Pagination->respond(Episodes::getTableTbody($Episodes), '#episodes tbody');
}
$settings = array('title' => $title, 'do-css', 'js' => array('paginate', $do));
if (Permission::sufficient('staff')) {
    $settings['js'] = array_merge($settings['js'], array('moment-timezone', "{$do}-manage"));
}
CoreUtils::loadPage($settings);
Beispiel #7
0
 static function getAppearancesSectionHTML(Episode $Episode) : string
 {
     global $CGDb, $Color;
     $HTML = '';
     $EpTagIDs = Episodes::getTagIDs($Episode);
     if (!empty($EpTagIDs)) {
         $TaggedAppearances = $CGDb->rawQuery("SELECT p.id, p.label, p.private\n\t\t\t\tFROM tagged t\n\t\t\t\tLEFT JOIN appearances p ON t.ponyid = p.id\n\t\t\t\tWHERE t.tid IN (" . implode(',', $EpTagIDs) . ") && p.ishuman = ?\n\t\t\t\tORDER BY p.label", array($Episode->isMovie));
         if (!empty($TaggedAppearances)) {
             $hidePreviews = UserPrefs::get('ep_noappprev');
             $pages = CoreUtils::makePlural('page', count($TaggedAppearances));
             $HTML .= "<section class='appearances'><h2>Related <a href='/cg'>{$Color} Guide</a> {$pages}</h2>";
             $LINKS = '<ul>';
             $isStaff = Permission::sufficient('staff');
             foreach ($TaggedAppearances as $p) {
                 $safeLabel = Appearances::getSafeLabel($p);
                 if (Appearances::isPrivate($p, true)) {
                     $preview = "<span class='typcn typcn-" . ($isStaff ? 'lock-closed' : 'time') . " color-" . ($isStaff ? 'orange' : 'darkblue') . "'></span> ";
                 } else {
                     if ($hidePreviews) {
                         $preview = '';
                     } else {
                         $preview = Appearances::getPreviewURL($p);
                         $preview = "<img src='{$preview}' class='preview'>";
                     }
                 }
                 $LINKS .= "<li><a href='/cg/v/{$p['id']}-{$safeLabel}'>{$preview}{$p['label']}</a></li>";
             }
             $HTML .= "{$LINKS}</ul></section>";
         }
     }
     return $HTML;
 }
Beispiel #8
0
<?php

use App\CoreUtils;
use App\Episodes;
use App\HTTP;
use App\RegExp;
if (POST_REQUEST) {
    HTTP::statusCode(400, AND_DIE);
}
/** @var $data string */
if (!preg_match(new RegExp('^(req|res)/(\\d+)$'), $data, $match)) {
    CoreUtils::notFound();
}
$match[1] .= array('req' => 'uest', 'res' => 'ervation')[$match[1]];
/** @var $LinkedPost \App\Models\Post */
$LinkedPost = $Database->where('id', $match[2])->getOne("{$match[1]}s");
if (empty($LinkedPost)) {
    CoreUtils::notFound();
}
$Episode = Episodes::getActual($LinkedPost->season, $LinkedPost->episode);
if (empty($Episode)) {
    CoreUtils::notFound();
}
$Episode->LinkedPost = $LinkedPost;
Episodes::loadPage($Episode, false);
Beispiel #9
0
?>
</tbody>
	</table>
<?  }
	echo $Pagination;
	$Movies = $Database->where('season', 0)->orderBy('episode','DESC')->get('episodes'); ?>
	<h1>Movies</h1>
<?  if (empty($Episodes)){ ?>
	<p>There are no movies stored in the database</p>
<?  }
	if (Permission::sufficient('staff')) { ?>
	<div class="actions">
		<button id="add-movie" class="green typcn typcn-plus">Add Movie</button>
	</div>
<?  }
	if (!empty($Episodes) || (empty($Episodes) && Permission::sufficient('staff'))){ ?>
	<table id="movies">
		<thead>
			<tr>
				<th><span class="mobile-hide">Overall </span>#</th>
				<th>Title &amp; Air Date</th>
			</tr>
		</thead>
		<tbody><?php 
echo Episodes::getTableTbody($Movies, true);
?>
</tbody>
	</table>
<?  } ?>
</div>
Beispiel #10
0
<?php 
        }
    }
    if ($do === 'colorguide' && (!empty($Appearance) || !empty($Ponies)) && empty($Map)) {
        ?>
	<section id="hash-copy">
		<h2>Color Guide</h2>
		<p>You can click any <?php 
        echo $color;
        ?>
ed square on this page to copy its HEX <?php 
        echo $color;
        ?>
 code to your clipboard. Holding Shift while clicking will display a dialog with the RGB <?php 
        echo $color;
        ?>
 values instead.</p>
		<button class='blue typcn typcn-refresh' id='toggle-copy-hash'>Checking&hellip;</button>
	</section>
<?php 
    }
    echo Episodes::getSidebarUpcoming();
} else {
    ?>

	<section class="login">
		<h2>Welcome!</h2>
		<p>We're having some technical difficulties and signing in is not possible at the moment. Please check back later.</p>
	</section>
<?php 
}
Beispiel #11
0
 static function getHTML($Notifications, $wrap = true)
 {
     global $Database;
     $HTML = $wrap ? '<ul class="notif-list">' : '';
     foreach ($Notifications as $n) {
         $data = !empty($n['data']) ? JSON::decode($n['data']) : null;
         if (preg_match(new RegExp('^post-'), $n['type'])) {
             /** @var $Post Post */
             $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
             $Episode = Episodes::getActual($Post->season, $Post->episode, Episodes::ALLOW_MOVIES);
             $EpID = $Episode->formatTitle(AS_ARRAY, 'id');
             $url = $Post->toLink($Episode);
         }
         switch ($n['type']) {
             case "post-finished":
                 $HTML .= self::_getNotifElem("Your <a href='{$url}'>request</a> under {$EpID} has been fulfilled", $n);
                 break;
             case "post-approved":
                 $HTML .= self::_getNotifElem("A <a href='{$url}'>post</a> you reserved under {$EpID} has been added to the club gallery", $n);
                 break;
             case "post-passon":
                 $userlink = Users::get($data['user'])->getProfileLink();
                 $HTML .= self::_getNotifElem("{$userlink} is interested in finishing a <a href='{$url}'>post</a> you reserved under {$EpID}. Would you like to pass the reservation to them?", $n);
                 break;
             case "post-passdeny":
             case "post-passallow":
             case "post-passfree":
             case "post-passdel":
             case "post-passsnatch":
             case "post-passperm":
                 $userlink = Users::get($data['by'])->getProfileLink();
                 $passaction = str_replace('post-pass', '', $n['type']);
                 switch ($passaction) {
                     case "allow":
                         $HTML .= self::_getNotifElem("Reservation transfer status: {$userlink} <strong class='color-lightgreen'>transferred</strong> the reservation of <a href='{$url}'>this post</a> under {$EpID} to you!", $n);
                         break;
                     case "deny":
                         $HTML .= self::_getNotifElem("Reservation transfer status: {$userlink} <strong class='color-lightred'>denied</strong> transferring the reservation of <a href='{$url}'>this post</a> under {$EpID} to you.", $n);
                         break;
                     case 'free':
                     case 'del':
                     case 'snatch':
                     case 'perm':
                         $message = Posts::TRANSFER_ATTEMPT_CLEAR_REASONS[$passaction];
                         $message = str_replace('post', "<a href='{$url}'>post</a>", $message);
                         switch ($passaction) {
                             case 'del':
                                 $message .= " by {$userlink}";
                                 break;
                             case "perm":
                                 $message = str_replace('the previous reserver', $userlink, $message);
                                 break;
                         }
                         $HTML .= self::_getNotifElem("Reservation transfer status: {$message}", $n);
                         break;
                 }
                 break;
             default:
                 $HTML .= "<li><code>Notification({$n['type']})#{$n['id']}</code> <span class='nobr'>&ndash; Missing handler</span></li>";
         }
     }
     return $HTML . ($wrap ? '</ul>' : '');
 }
Beispiel #12
0
    /**
     * Returns the HTML of the "Appears in # episodes" section of appearance pages
     *
     * @param array $Appearance
     * @param bool  $allowMovies
     *
     * @return string
     */
    static function getRelatedEpisodesHTML($Appearance, $allowMovies = false)
    {
        global $CGDb;
        $EpTagsOnAppearance = $CGDb->rawQuery("SELECT t.tid\n\t\t\tFROM tagged tt\n\t\t\tLEFT JOIN tags t ON tt.tid = t.tid\n\t\t\tWHERE tt.ponyid = ? &&  t.type = 'ep'", array($Appearance['id']));
        if (!empty($EpTagsOnAppearance)) {
            foreach ($EpTagsOnAppearance as $k => $row) {
                $EpTagsOnAppearance[$k] = $row['tid'];
            }
            $EpAppearances = $CGDb->rawQuery("SELECT DISTINCT name FROM tags WHERE tid IN (" . implode(',', $EpTagsOnAppearance) . ") ORDER BY name");
            if (empty($EpAppearances)) {
                return '';
            }
            $List = '';
            foreach ($EpAppearances as $tag) {
                $name = strtoupper($tag['name']);
                $EpData = Episodes::parseID($name);
                $Ep = Episodes::getActual($EpData['season'], $EpData['episode'], $allowMovies);
                $List .= (empty($Ep) ? self::expandEpisodeTagName($name) : "<a href='{$Ep->formatURL()}'>" . $Ep->formatTitle() . '</a>') . ', ';
            }
            $List = rtrim($List, ', ');
            $N_episodes = CoreUtils::makePlural($Appearance['ishuman'] ? 'movie' : 'episode', count($EpAppearances), PREPEND_NUMBER);
            $hide = '';
        } else {
            $N_episodes = 'no episodes';
            $List = '';
            $hide = 'style="display:none"';
        }
        return <<<HTML
\t<section id="ep-appearances" {$hide}>
\t\t<h2><span class='typcn typcn-video'></span>Appears in {$N_episodes}</h2>
\t\t<p>{$List}</p>
\t</section>
HTML;
    }
Beispiel #13
0
    if (isset($_GET['error_description'])) {
        $errdesc = $_GET['error_description'];
    }
    global $signedIn;
    if ($signedIn) {
        HTTP::redirect($_GET['state']);
    }
    Episodes::loadPage();
}
$currentUser = DeviantArt::getToken($_GET['code']);
$signedIn = !empty($currentUser);
if (isset($_GET['error'])) {
    $err = $_GET['error'];
    if (isset($_GET['error_description'])) {
        $errdesc = $_GET['error_description'];
    }
    if ($err === 'user_banned') {
        $errdesc .= "\n\nIf you'd like to appeal your ban, please <a href='http://mlp-vectorclub.deviantart.com/notes/'>send the group a note</a>.";
    }
    Episodes::loadPage();
}
if (preg_match(new RegExp('^[a-z\\d]+$', 'i'), $_GET['state'], $_match)) {
    $confirm = str_replace('{{CODE}}', $_match[0], file_get_contents(INCPATH . 'views/loginConfrim.html'));
    $confirm = str_replace('{{USERID}}', Permission::sufficient('developer') || UserPrefs::get('p_disable_ga') ? '' : $currentUser->id, $confirm);
    die($confirm);
} else {
    if (preg_match($REWRITE_REGEX, $_GET['state'])) {
        HTTP::redirect($_GET['state']);
    }
}
HTTP::redirect('/');
Beispiel #14
0
</h2>
		<?php 
    echo GlobalSettings::get('about_reservations');
    ?>
	</section>
	<section class="rules">
		<h2>Reservation Rules<?php 
    echo Permission::sufficient('staff') ? '<button class="orange typcn typcn-pencil" id="edit-reservation_rules">Edit</button>' : '';
    ?>
</h2>
		<?php 
    echo GlobalSettings::get('reservation_rules');
    ?>
	</section>
<?php 
    echo Episodes::getAppearancesSectionHTML($CurrentEpisode);
    if (Permission::sufficient('staff')) {
        ?>
	<section class="admin">
		<h2>Administration area</h2>
		<p class="align-center">
			<button id="edit-ep" class="typcn typcn-pencil large darkblue">Metadata</button>
			<button id="video" class="typcn typcn-pencil large darkblue">Video links</button>
			<button id="cg-relations" class="typcn typcn-pencil large darkblue">Guide relations</button>
		</p>
	</section>
<?php 
    }
    echo Posts::getReservationsSection(null, false, true);
    echo Posts::getRequestsSection(null, false, true);
    $export = array('SEASON' => $CurrentEpisode->season, 'EPISODE' => $CurrentEpisode->episode);