You are here

function lc_RandReduce in Link checker 5

1 call to lc_RandReduce()
lc_DoLinkChecks in ./linkchecker.module

File

./linkchecker.module, line 557
This module periodically check html links referenced by drupal nodes Developed and maintained by Marek Tichy, marek@ecn.cz

Code

function lc_RandReduce($urls) {
  $maxtime = variable_get('linkchecker_maxtime', 30);
  $timeout = variable_get('linkchecker_socket_timeout', 3);
  if ($timeout < 1) {
    $timeout = 1;
  }
  $maxlinks = variable_get('linkchecker_max_links_per_node', 0);
  $newurls = array();
  srand((double) microtime() * 10000000);
  if ($maxlinks > 0 && sizeof($urls) > $maxlinks) {
    $rand = array_rand($urls, $maxlinks);
    foreach ($rand as $key) {
      $newurls[] = $urls[$key];
    }
    d_("Too many links, reducing to {$maxlinks} only.");
  }
  else {
    $newurls = $urls;
  }
  return $newurls;
}