Daily KB Articles

Just a little script I threw together to download a random KB article from Microsoft; set cron to run this daily.

<?php

$file = false;

// keep generating random article IDs until we hit a valid one
while($file == false):

  // create an array with random numbers
  for ($i=0; $i < 6; $i++)
  {
    $random = (rand()%9);
    $array[$i] = $random;
  }

  // let our array be used for the MS KB article ID
  $article_id = $array[0] . $array[1] . $array[2] . $array[3] . $array[4] . $array[5];
  $url = 'http://support.microsoft.com/kb/' . $article_id;
  $file = @fopen($url,'r');

  // be a good netizen
  sleep(5);

endwhile;

// once the above loop exits with a valid URL, save the article to PDF
exec ('/usr/local/bin/wkhtmltopdf -q ' . $url . ' /path/to/dir/' . $article_id . '.pdf');

?>