コード例 #1
0
ファイル: Lambda.php プロジェクト: pldin601/php-lambda
/**
 * Creates function using $pattern.
 *
 * @param string $pattern
 *
 * @throws \Exception
 *
 * @return callable
 */
function l($pattern)
{
    $isUnindexed = isUnindexed($pattern);
    $isIndexed = isIndexed($pattern);
    if ($isUnindexed && $isIndexed) {
        throw new \Exception('Mixing of indexed and unindexed placeholders is not supported.');
    } elseif ($isUnindexed) {
        return lambdaUnindexed($pattern);
    }
    return lambdaIndexed($pattern);
}
コード例 #2
0
    }
    return 0;
}
$dbw = wfGetDB(DB_MASTER);
$dbw->query("insert IGNORE into google_indexed (gi_page, gi_page_created) select fe_page, fe_timestamp from firstedit where fe_user_text='WRM'");
$res = $dbw->select(array('google_indexed', 'page'), array("page_title", "page_id"), array("page_id = gi_page"), "checkGoogleIndex", array("ORDER BY" => "gi_times_checked, rand()", "LIMIT" => 500));
$titles = array();
while ($row = $dbw->fetchObject($res)) {
    $titles[] = Title::newFromDBKey($row->page_title);
}
foreach ($titles as $t) {
    if (!$t) {
        continue;
    }
    $ts = wfTimestampNow();
    $ret = isIndexed($t);
    #echo "got return of $ret\n"; exit;
    $dbw = wfGetDB(DB_MASTER);
    $opts = array('gl_page' => $t->getArticleID(), 'gl_pos' => $ret == null ? 0 : 1, 'gl_checked' => $ts);
    if ($ret == null) {
        $opts['gl_err_str'] = $wgLastCurlError;
        $opts['gl_err'] = 1;
    }
    $dbw->insert('google_indexed_log', $opts);
    if ($ret) {
        $indexed = $ret > 0 ? 1 : 0;
        $dbw->update('google_indexed', array('gi_lastcheck' => $ts, 'gi_indexed' => $indexed, 'gi_times_checked = gi_times_checked + 1'), array('gi_page' => $t->getArticleID()));
    }
    // throttle
    $x = rand(1, 3);
    sleep($x);