public static function getPrevEpisode($id, $current)
 {
     $episodes = MasterAnime::getEpisodes($id);
     $total = count($episodes);
     if ($total > 1) {
         $search = array_search($current, $episodes);
         if ($search + 1 < $total) {
             return $episodes[$search + 1];
         }
     }
     return 0;
 }
 public function getEpisode($id, $name, $episode)
 {
     $anime = Anime::find($id);
     if (!empty($anime)) {
         $mirrors = MasterAnime::getEpisode($anime->id, $episode);
         if (!empty($mirrors) && count($mirrors) > 0) {
             return View::make('watch', array('title' => 'Watch ' . $anime->name . ' - episode ' . $episode, 'description' => 'Watch ' . $anime->name . ' episode ' . $episode . ' online in HD on desktop, tablet and mobile.', 'anime' => $anime, 'mirrors' => $mirrors, 'episode' => $episode));
         }
         return App::abort(404);
     }
     return App::abort(404);
 }
 public function addDropped()
 {
     $anime_id = Input::get("anime_id");
     if (Sentry::check()) {
         $row = UserLibrary::firstOrNew(array('user_id' => Sentry::getUser()->id, 'anime_id' => $anime_id));
         $row->library_status = 4;
         $row->save();
         MasterAnime::addSocialList($anime_id, 0, 4);
         return 'true';
     }
     return 'false';
 }
function getAnime()
{
    $series = MasterAnime::getOngoingAnime();
    $anime = array();
    foreach ($series as $serie) {
        $latest = DB::table('latest_anime')->whereRaw('anime_id = ?', array($serie->id))->select('created_at', 'episode')->orderBy('created_at', 'DESC')->first();
        if (!empty($latest)) {
            $today = new DateTime();
            $future = new DateTime($latest->created_at);
            $future->add(new DateInterval("PT168H"));
            $interval = $future->diff($today);
            if ($future > $today) {
                $date = $interval->format('%d%H');
                array_push($anime, array('episode' => $latest->episode, 'interval' => $interval, 'anime' => $serie, 'sort' => $date));
            }
        }
    }
    return $anime;
}
 public function setLastWatched()
 {
     $username = Input::get("username");
     $password = Input::get("password");
     $id = Input::get("id");
     $episode = Input::get("episode");
     try {
         $credentials = array('username' => $username, 'password' => $password);
         $user = Sentry::authenticate($credentials, false);
         $user_id = $user->id;
         $mirrors = MasterAnime::getEpisode($id, $episode);
         if (!empty($mirrors) && count($mirrors) > 0 && !empty($id) && !empty($episode)) {
             $lastwatch = LastWatched::firstOrNew(array('user_id' => $user_id, 'anime_id' => $id));
             if (empty($lastwatch->episode) || $lastwatch->episode < $episode) {
                 MasterAnime::addToMAL($id, $episode, 1);
                 MasterAnime::addToHummingbird($id, $episode, 1);
                 $lastwatch->user_id = $user_id;
                 $lastwatch->anime_id = $id;
                 $lastwatch->episode = $episode;
                 $lastwatch->save();
                 return 'Succesfully added episode ' . $episode . ' to last watched anime!';
             }
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return 'Username is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return 'Password is required.';
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return 'Wrong password.';
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return 'User was not found.';
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return 'User is not activated.';
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return 'User is suspended.';
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return 'User is banned.';
     }
 }
示例#6
0
    return 'AJAX requests only';
});
Route::post('/anime/recent', function () {
    if (Request::ajax()) {
        if (Input::has('type')) {
            $gallery = Input::get('type') === 'gallery';
            MasterAnime::createRecentLayoutCookie($gallery);
            return Latest::getLatest(array("start" => 0, "end" => 12), $gallery);
        }
    }
    return 'AJAX requests only';
});
Route::post('/anime/search', function () {
    if (Request::ajax()) {
        $animelist = Input::has('animelist');
        $search_results = MasterAnime::searchAnime(Input::get('keyword'));
        if ($animelist) {
            return View::make('child.all_anime', array('search_display' => array('view' => false, 'series' => $search_results)));
        }
        return View::make('child.all_anime', array('search_display' => array('view' => true, 'series' => $search_results)));
    }
    return 'AJAX requests only';
});
Route::post('/anime/scraper', function () {
    if (Request::ajax()) {
        if (Sentry::check()) {
            $user = Sentry::getUser();
            if ($user->isSuperUser()) {
                $id = Input::get('anime_id');
                return Mirror::put($id);
            }
                    <div class="span12" id="controls-watch">
                        <div id="favorite-anime" class="pull-left">
                            @if (!empty($user))
                            @if (UserLibrary::getFavorite($anime->id, $user->id))
                            <a data-toggle="tooltip" title="remove from favorites"><input type="hidden" name="user_id" value="{{{ $user->id }}}"><input type="hidden" name="anime_id" value="{{{ $anime->id }}}"><span class="icon-heart icon-large met_gray_icon"></span></a>
                            @else
                            <a data-toggle="tooltip" title="add to favorites"><input type="hidden" name="user_id" value="{{{ $user->id }}}"><input type="hidden" name="anime_id" value="{{{ $anime->id }}}"><span class="icon-heart icon-large"></span></a>
                            @endif
                            @else
                            <a data-toggle="tooltip" title="Sign in to favorite anime"><span class="icon-heart icon-large"></span></a>
                            @endif
                        </div>
                        <div class="pull-right">
                            <?php 
$prev = MasterAnime::getPrevEpisode($anime->id, $episode);
$next = MasterAnime::getNextEpisode($anime->id, $episode);
?>
                            @if (!empty($prev))
                            <a href="{{{ URL::to('/watch/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), '_', $anime->name) . '/' . $prev) }}}" data-toggle="tooltip" title="previous episode"><span class="icon-arrow-left icon-large"></span></a>
                            @endif
                            <a href="{{{ URL::to('/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), '_', $anime->name)) }}}" data-toggle="tooltip" title="episode list"><span><i class="icon-th icon-large"></i></span></a>
                            @if (!empty($next))
                            <a href="{{{ URL::to('/watch/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), '_', $anime->name) . '/' . $next) }}}" data-toggle="tooltip" title="next episode"><span class="icon-arrow-right icon-large"></span></a>
                            @endif
                        </div>
                    </div>
                </div>
            </div>

            <div class="span3">
                <div class="row-fluid">
示例#8
0
            {{ HTML::image($screencap) }}
        </div>
        @endforeach
    </div>
</div>
@endif
<div class="row-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h1 class="title">Episodes</h1>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <?php 
$episodes = MasterAnime::getEpisodes($anime->id);
?>
            <ul class="nav nav-tabs nav-stacked">
                @if (!empty($episodes))
                @foreach ($episodes as $episode)
                <li>
                    <a href="{{  URL::to('watch/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), "_", $anime->name)) . '/' . $episode }}">
                    <i class="icon-play-circle"></i> {{ $episode }}
                    </a>
                </li>
                @endforeach
                @endif
            </ul>
        </div>
    </div>
</div>
@if (!empty($series) && count($series) > 0)
<ul class="last-watched">
    @foreach ($series as $watched)
    <?php 
$anime = Anime::findOrFail($watched->anime_id, array('id', 'name'));
$next = MasterAnime::getNextEpisode($anime->id, $watched->last_watched_episode);
?>
    <li id="{{$anime->id}}" class="item{{{ $next ? '' : ' finished'}}}">
        <p>{{{ $anime->name }}} - ep. {{{ $watched->last_watched_episode}}}</p>

        <p class="time hidden-phone">seen {{{ Latest::time_elapsed_string($watched->last_watched_time) }}} ago</p>
        <ul class="nav nav-pills">
            <li>
                <a data-toggle="tooltip" title="index eps" class="met_button" href="{{{ URL::to('/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), '_', $anime->name)) }}}">-</a>
            </li>
            @if ($next)
            <li>
                <a data-toggle="tooltip" title="next ep" class="met_button" href="{{{ URL::to('/watch/anime/' . $anime->id . '/' . str_replace(array(" ", "/", "?"), '_', $anime->name) . '/' . $next) }}}">></a>
            </li>
            @endif
            <li class="space">
                <a id="drop-anime" data-toggle="tooltip" title="drop anime" class="met_button" href="#"><input name="anime_id" type="hidden" value="{{{$anime->id}}}">x</a>
            </li>
        </ul>
    </li>
    @endforeach
</ul>
<script type="text/javascript">
    $(document).ready(function () {
        $('li[class=space] a[id=drop-anime]').on('click', function (e) {
            e.preventDefault()