<?php
$url = 'http://web.archive.org/web/20160404232801/http://fc-dmitrov.ru/';
$f = file_get_contents($url);
$domain = $_SERVER['HTTP_HOST'];
preg_match_all('|src="([^"]+)"|', $f, $m); //for all src (inc scripts, images)
foreach ($m[1] as $l){
if (strpos($l, $domain)!=FALSE)
{
$tmp = explode($domain,$l); //split string WA_part -> domain_part
$path = explode('/',$tmp[1]); //split domain part to path
$num = count($path);
$cpath = ''; //no path before checking
for ($i=0;$i<$num-1;$i++)
$cpath .= $path[$i].' ';
$cpath = str_replace(' ','/',trim($cpath));
@$tfile = file_get_contents('http://web.archive.org/'.$l); //404 may appear
if (!file_exists($cpath.'/'.$path[$num-1])){ //if there's not such a file
$out = file_put_contents($cpath.'/'.$path[$num-1], $tfile);
echo $out.' '.$cpath.'/'.$path[$num-1].'OK <br/>';
}
else echo 'File found<br/>';
}
}