예제 #1
0
파일: post.php 프로젝트: ponydevs/MLPVC-RR
use App\Models\Reservation;
use App\DeviantArt;
use App\Episodes;
use App\Input;
use App\Logs;
use App\Notifications;
use App\Permission;
use App\Posts;
use App\RegExp;
use App\Response;
use App\Time;
use App\Users;
/** @var $data string */
/** @var $signedIn bool */
if (!POST_REQUEST) {
    CoreUtils::notFound();
}
if (preg_match(new RegExp('^reload-(request|reservation)/(\\d+)$'), $data, $_match)) {
    $thing = $_match[1];
    $Post = $Database->where('id', $_match[2])->getOne("{$thing}s");
    if (empty($Post)) {
        Response::fail("The specified {$thing} does not exist");
    }
    Response::done(array('li' => Posts::getLi($Post, isset($_POST['FROM_PROFILE']), true)));
}
if (!$signedIn) {
    Response::fail();
}
CSRFProtection::protect();
$_match = array();
if (preg_match(new RegExp('^([gs]et)-(request|reservation)/(\\d+)$'), $data, $_match)) {
예제 #2
0
 /**
  * Loads the episode page
  *
  * @param null|int|Episode $force              If null: Parses $data and loads approperiate epaisode
  *                                             If array: Uses specified arra as Episode data
  * @param bool             $serverSideRedirect Handle redirection to the correct page on the server/client side
  */
 static function loadPage($force = null, $serverSideRedirect = true)
 {
     global $data, $CurrentEpisode, $Database, $PrevEpisode, $NextEpisode, $LinkedPost;
     if ($force instanceof Episode) {
         $CurrentEpisode = $force;
     } else {
         $EpData = self::parseID($data);
         if ($EpData['season'] === 0) {
             error_log("Attempted visit to {$data} from " . (!empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '[unknown referrer]') . ', redirecting to /movie page');
             HTTP::redirect('/movie/' . $EpData['episode']);
         }
         $CurrentEpisode = empty($EpData) ? self::getLatest() : self::getActual($EpData['season'], $EpData['episode']);
     }
     if (empty($CurrentEpisode)) {
         CoreUtils::notFound();
     }
     $url = $CurrentEpisode->formatURL();
     if (!empty($LinkedPost)) {
         $url .= '#' . $LinkedPost->getID();
     }
     if ($serverSideRedirect) {
         CoreUtils::fixPath($url);
     }
     $js = array('imagesloaded.pkgd', 'jquery.ba-throttle-debounce', 'jquery.fluidbox', 'Chart', 'episode');
     if (Permission::sufficient('member')) {
         $js[] = 'episode-manage';
     }
     if (Permission::sufficient('staff')) {
         $js[] = 'moment-timezone';
         $js[] = 'episodes-manage';
     }
     if (!$CurrentEpisode->isMovie) {
         $PrevEpisode = $Database->where('no', $CurrentEpisode->no, '<')->where('season', 0, '!=')->orderBy('no', 'DESC')->getOne('episodes', 'season,episode,title,twoparter');
         $NextEpisode = $Database->where('no', $CurrentEpisode->no, '>')->where('season', 0, '!=')->orderBy('no', 'ASC')->getOne('episodes', 'season,episode,title,twoparter');
     } else {
         $PrevEpisode = $Database->where('season', 0)->where('episode', $CurrentEpisode->episode, '<')->orderBy('episode', 'DESC')->getOne('episodes', 'season,episode,title');
         $NextEpisode = $Database->where('season', 0)->where('episode', $CurrentEpisode->episode, '>')->orderBy('episode', 'ASC')->getOne('episodes', 'season,episode,title');
     }
     $heading = $CurrentEpisode->formatTitle();
     CoreUtils::loadPage(array('title' => "{$heading} - Vector Requests & Reservations", 'heading' => $heading, 'view' => 'episode', 'css' => 'episode', 'js' => $js, 'url' => $serverSideRedirect ? null : $url));
 }