コード例 #1
0
$time = microtime(TRUE);
// Get URLs from sitemap
$urls = array();
foreach ($sitemap_urls as $url) {
    $urls = array_merge($urls, get_urls_sitemap($url, $options['timeout']));
}
// Additional URLs
if (!empty($additional_urls)) {
    $urls = array_merge($urls, $additional_urls);
}
// Remove duplicate URLs
$urls = array_unique($urls);
// Split preloading
$t = count($urls);
$n = ceil($t * $options['gc'] / $options['cache']);
$urls = array_slice($urls, get_split($n, $t), $n);
// Additional UA
if (!empty($options['agent'])) {
    $user_agent = array_merge($user_agent, (array) $options['agent']);
}
// millisecond to microsecond
$options['interval'] *= 1000;
// Fetch URLs
$n = 0;
foreach ($user_agent as $ua) {
    $t = $treq = 0;
    $pages = $urls;
    while (count($pages)) {
        // Fetch pages
        $retry = array();
        $t = microtime(TRUE);
コード例 #2
0
ファイル: mci.php プロジェクト: OlivierLamiraux/mtgas
     $rarity = substr($match['rarity'], 0, 1);
     if (preg_match('/\\(Color Indicator: (?<color>.{1,100})\\)/', $html, $colors_matches)) {
         // Cards with no casting cost (Ancestral Vision)
         $text = $name . ' is ' . strtolower(implode(' and ', explode(' ', $colors_matches['color']))) . ".\n" . $text;
     }
     $lastcard = $importer->addcard($card_url, $rarity, $name, $cost, $types, $text, card_image_url($match), $card_matches['multiverseid']);
 }
 // Lang
 $nb = preg_match_all($lang_regex, $html, $matches_lang, PREG_SET_ORDER);
 foreach ($matches_lang as $lang) {
     $code = $lang['code'];
     $url = card_image_url($match, $code);
     if (array_search($lang['code'], array('de', 'fr', 'it', 'es', 'pt')) !== false) {
         // Expected charset
         $lname = $lang['name'];
         get_split($lname);
         if (!$secondpart) {
             $lastcard->setlang($code, $lname, $url);
         } else {
             if (!$doubleface) {
                 $url = null;
             }
             if ($split) {
                 $lastcard->addlang($code, $lname, $url);
             } else {
                 $lastcard->addlangimg($code, $url);
             }
         }
     } else {
         if (!($split && $secondpart)) {
             $lastcard->addlangimg($code, $url);