public static function getMirrorsBBcode($mirrorList)
 {
     $bbcode = '';
     // Return variable
     $mirrorCount = 0;
     // Used in output (for [mirror 1][mirror 2], etc.) and to give special output on the first mirror
     foreach ($mirrorList as $mirror) {
         if (DEVMODE) {
             echo '(Mirror ' . $mirror->url . ' ' . ($mirror->uptodate === 1 ? 'uptodate' : 'outdated/down') . ")\n";
         }
         if ($mirror->uptodate === 1) {
             if ($mirrorCount == 0) {
                 $bbcode .= '[url=' . $mirror->url . ']Deze statistieken[/url] [sup]';
             } else {
                 $bbcode .= '[[url=' . $mirror->url . ']mirror ' . $mirrorCount . '[/url]]';
             }
             $mirrorCount += 1;
         }
     }
     if (empty($bbcode)) {
         // Uh-oh. I don't know what is wrong here, but better return all mirrors instead of none.
         if (DEVMODE) {
             echo "[b]WARNING:[/b] Something went wrong checking our mirrors. Slow internet perhaps? (The timeout is 1 second.)\n";
         }
         foreach ($mirrorList as $mirror) {
             $mirror->uptodate = 1;
             // Let's just pretend they're all available and re-generate.
         }
         $bbcode = Mirror::getMirrorsBBcode($mirrorList);
     }
     return $bbcode;
 }
 public function getScraper($id)
 {
     if (Sentry::check()) {
         $user = Sentry::getUser();
         if ($user->isSuperUser()) {
             $data = Mirror::put($id);
             return View::make('debug', array('debug' => $data));
         }
     }
     return 'You must be a super user for this feature.';
 }
示例#3
0
 public static function scrapeAllAnimeWithNoEpisodes()
 {
     $animes = DB::table('series')->select('id', 'name')->get();
     ob_implicit_flush(1);
     foreach ($animes as $anime) {
         $mirrors = DB::table('mirrors')->where("anime_id", "=", $anime->id)->select('id')->get();
         if (empty($mirrors) && count($mirrors) === 0) {
             echo 'Started scraping anime: ' . $anime->name . '<br>';
             echo Mirror::put($anime->id);
         }
     }
     return "<br> Scraped anime!";
 }
示例#4
0
Route::get('/anime/{id}', 'AnimeController@getAnime');
Route::get('/anime/{id}/{name}', 'AnimeController@getAnime');
Route::get('/watch/anime/{id}/{name}/{episode}', 'AnimeController@getEpisode');
/*User library routes*/
Route::post('/userlib/favorite', 'UserLibraryController@addFavorite');
Route::post('/userlib/watched', 'UserLibraryController@addWatched');
Route::post('/userlib/drop', 'UserLibraryController@addDropped');
Route::post('/userlib/plan_to_watch', 'UserLibraryController@addPlanToWatch');
/*Account routes*/
Route::any('/account', 'AccountController@getIndex');
Route::any('/account/settings', 'AccountController@getIndex');
Route::get('/account/myanime', 'AccountController@getMyanime');
Route::get('/account/logout', 'AccountController@getLogout');
Route::any('/account/register', 'AccountController@getRegister');
/*API routes*/
Route::get('/api/anime/all', 'ApiController@getAll');
Route::get('/api/anime/ongoing', 'ApiController@getOngoing');
Route::get('/api/anime/search/{keyword}', 'ApiController@getSearch');
Route::get('/api/anime/latest', 'ApiController@getLatest');
Route::get('/api/anime/{id}', 'ApiController@getAnime');
Route::get('/api/anime/{id}/{episode}', 'ApiController@getEpisode');
Route::post('/api/anime/account/lastwatched', 'ApiController@setLastwatched');
Route::post('/api/anime/account/validate', 'ApiController@getValidate');
Route::post('/api/anime/video', function () {
    if (Request::ajax() && Input::has('id')) {
        $id = Input::get('id');
        if (is_numeric($id)) {
            return View::make('api.video', array('mirror' => Mirror::find($id)));
        }
    }
});
// display totals
echo '[b]Totalen[/b]' . ENDL;
echo '[table]';
echo '[tr][td]Keys [/td]';
echo '[td]' . Format::StatNumber($totals['keys']) . '[tt]    [/tt][/td]';
echo '[td]' . ($totals['keysDiff'] > 0 ? '[green]+' : '[red]-') . Format::StatNumber($totals['keysDiff']) . '[/td][/tr]' . ENDL;
echo '[tr][td]Kliks [/td]';
echo '[td]' . Format::StatNumber($totals['clicks']) . '[/td]';
echo '[td]' . ($totals['clicksDiff'] > 0 ? '[green]+' : '[red]-') . Format::StatNumber($totals['clicksDiff']) . '[/td][/tr]' . ENDL;
echo '[tr][td]Uptime [/td]';
echo '[td]' . Format::Uptime($totals['uptime']) . '[/td]';
echo '[td]' . ($totals['uptimeDiff'] > 0 ? '[green]+' : '[red]-') . Format::Uptime($totals['uptimeDiff']) . '[/td][/tr]' . ENDL;
echo '[tr][td]Download [/td]';
echo '[td]' . Format::Bandwidth($totals['download']) . '[/td]';
echo '[td]' . ($totals['downloadDiff'] > 0 ? '[green]+' : '[red]-') . Format::Bandwidth($totals['downloadDiff']) . '[/td][/tr]' . ENDL;
echo '[tr][td]Upload [/td]';
echo '[td]' . Format::Bandwidth($totals['upload']) . '[/td]';
echo '[td]' . ($totals['uploadDiff'] > 0 ? '[green]+' : '[red]-') . Format::Bandwidth($totals['uploadDiff']) . '[/td][/tr]' . ENDL;
if ($totals['pulsers'] > 0) {
    echo '[tr][td]Pulsers[/td][td]' . $totals['pulsers'] . '[/td]';
    echo '[td][abbr=Percentage van alle leden]' . round($totals['pulsers'] / $totals['active'] * 100, 2) . '%[/td][/tr]' . ENDL;
    echo '[tr][td]Spaarders[tt]    [/tt][/td][td]' . $totals['savers'] . '[/td]';
    echo '[td][abbr=Percentage van de pulsers]' . round($totals['savers'] / $totals['pulsers'] * 100, 2) . '%[/td][/tr]' . ENDL;
}
echo '[/table]' . ENDL . ENDL;
echo Mirror::getMirrorsBBcode($mirrors);
echo '[/sup] ([url=https://github.com/goldenice/GMOT-Whatpulse-Parser]Broncode[/url])' . ENDL . ENDL;
if (DEVMODE || isset($_GET['devmode']) || isset($_GET['gentime'])) {
    echo 'Generated in ' . (microtime(true) - $starttime) * 1000 . ' milliseconds.';
    echo 'On ' . date('r') . '.';
}
<?php

/**
 * @var modX $modx
 * @var array $scriptProperties
 */
$flushParameterName = trim($modx->getOption('flushParameter', $scriptProperties, ''));
if ($modx->event->name != 'OnWebPageInit' || $modx->context->get('key') == 'mgr' || !empty($flushParameterName) && !isset($_GET[$flushParameterName])) {
    return;
} else {
    $resourceId = $modx->resourceIdentifier;
    if ($modx->resourceMethod == 'alias') {
        $resourceId = $modx->aliasMap[$resourceId];
    }
    if (!is_numeric($resourceId)) {
        return;
    }
}
unset($scriptProperties['flushParameter']);
require_once $modx->getOption('mirror.core_path', null, $modx->getOption('core_path') . 'components/mirror/') . 'model/mirror/mirror.class.php';
$objectsMeta = array('chunks' => array('extension' => 'html', 'className' => 'modChunk', 'processComments' => false), 'plugins' => array('extension' => 'php', 'className' => 'modPlugin', 'processComments' => true), 'snippets' => array('extension' => 'php', 'className' => 'modSnippet', 'processComments' => true), 'templates' => array('extension' => 'html', 'className' => 'modTemplate', 'processComments' => false));
$mirror = new Mirror($modx, $scriptProperties);
$mirror->process($objectsMeta);
$modx->cacheManager->refresh();
示例#7
0
文件: mirror.php 项目: yakar/yioop
                file_put_contents("{$dir}/{$file['name']}", $data);
                crawlLog(".. {$file['name']} file copied.");
            } else {
                $offset = 0;
                $fh = fopen("{$dir}/{$file['name']}", "wb");
                $request .= "&l=" . self::DOWNLOAD_RANGE;
                while ($offset < $file['size']) {
                    $data = FetchUrl::getPage($request . "&o={$offset}", NULL, true);
                    $old_offset = $offset;
                    $offset += self::DOWNLOAD_RANGE;
                    $end_point = min($offset, $file["size"]);
                    //crude check if we need to redownload segment
                    if (strlen($data) != $end_point - $old_offset) {
                        $offset = $old_offset;
                        crawlLog(".. Download error re-requesting segment");
                        continue;
                    }
                    fwrite($fh, $data);
                    crawlLog(".. {$file['name']} downloaded bytes {$old_offset} " . "to {$end_point}..");
                }
                crawlLog(".. {$file['name']} file copied.");
                fclose($fh);
            }
        }
    }
}
/*
 * Instantiate and runs the Mirror program
 */
$syncer = new Mirror(NAME_SERVER);
$syncer->start();
 public static function getEpisode($id, $episode)
 {
     return Mirror::whereRaw('anime_id = ? and episode = ?', array($id, $episode))->orderBy('quality', 'DESC')->orderBy(DB::raw("field(host, 'MP4Upload','Arkvid', 'Masteranime') "), 'DESC')->get();
 }
示例#9
0
 public function scrape()
 {
     Mirror::put($this->id, true, $this->episode);
 }
 public function updateMirror()
 {
     return $this->execute(function () {
         $anime_id = Input::get('anime_id');
         $episode = Input::get('episode');
         $src = Input::get('src');
         $host = Input::get('host');
         $quality = Input::get('quality');
         $anime = Anime::findOrFail($anime_id, array('id', 'name'));
         Mirror::create(["anime_id" => $anime->id, "episode" => $episode, "src" => $src, "host" => $host, "quality" => $quality, "subbed" => 1]);
         return View::make('mod_panel')->nest('update_msg', 'child.alerts', array('msg_type' => 'success', 'msg' => 'You succesfully added a new mirror for: ' . $anime->name));
     });
 }
示例#11
0
 public static function mirror_exsists($anime_id, $ep, $host, $quality)
 {
     $mirrors = Mirror::whereRaw('anime_id = ? and episode = ?', array($anime_id, $ep))->select('quality', 'host')->get();
     if (!empty($mirrors)) {
         foreach ($mirrors as $mirror) {
             if ($mirror->quality == $quality && $mirror->host == $host) {
                 return true;
             }
         }
     }
     return false;
 }