<?php
//示例路径:/list/1.html
function put_contents($url){
$root='http://'.$_SERVER['HTTP_HOST'];
$urls=explode('/',$url);
$g_url=SITE_PATH;
foreach($urls as $k=>$v){
if($v&&strpos($v,'.html') !== false){
if($g_url&&!file_exists($g_url)){
mkdir($g_url,0777,true);
}
$url = file_get_contents($root.$url);
if($k==1){
$g_url='./'.$v;
$index = fopen($g_url, "w");
fwrite($index, $url);
fclose($index);
}else{
$g_url=$g_url.'/'.$v;
$index = fopen($g_url, "w");
fwrite($index, $url);
fclose($index);
}
}else{
if($k==1){
$g_url=$v;
}else{
$g_url=$g_url.'/'.$v;
}
}
}
}
?>