File size: 1.85Kb
<?php
include ('../config.php');
$page='upload';
include ('session.php');
include ($config->real() . $config->header);
if($layout=='web'){?>
<div class="wrap">
<div style="float: left; width: 18%; margin-bottom: 5px;" class="container">
<?php include('sidebar.php'); ?>
</div>
<div style="float: right; width:80%;">
<?php
}?>
<div class="container"><div class="title">Folder Upload</div>
<?php if($layout=='web'){
echo '<div style="padding:5px;">';
}
if(isset($_POST,$_POST['dir'],$_POST['url'])):
function getLinks($link)
{
$ret = array();
$dom = new domDocument;
@$dom->loadHTML(file_get_contents($link));
$dom->preserveWhiteSpace = false;
$links = $dom->getElementsByTagName('a');
foreach ($links as $tag)
{
$ret[] = $tag->getAttribute('href');
}
return $ret;
}
$dir='../'.$config->filedir. $_POST['dir'] . '/';
if(!is_dir($dir)){
mkdir($dir,0777,true);
}
$links=getLinks($_POST['url']);
$search=explode(',',$config->ext);
foreach($links as $link):
$find = str_replace($search, '|',strtolower($link));
if(substr_count($find,'|')>0){
if(substr_count($find,'http://')<1)
$file=$_POST['url'].$link;
else
$file=$link;
$name = str_replace('%20','_',basename($file));
$name = str_replace('%5b','[',$name);
$name = str_replace('%5d','[',$name);
$name = str_replace('example.com',null,$name);
if(copy($file, $dir.$name)):
echo 'Copyied <a href="'.$dir.$name.'">'.$name.' </a> Successfully<br/>';
else:
echo 'Could Not Copy '.$name.'<br/>';
endif;
}
endforeach;
endif;
?>
<form action="" method="POST">
URL: <input type="text" name="url"/><br/>
Directory: <input type="text" name="dir" value="/"/><br/>
<input type="submit" value="Submit"/>
</form>
<br />In Directory Part: / = <?php echo '../'.$config->filedir; ?>
</div>
<?php if($layout=='web'){
echo '</div></div></div>';
}
?>
<?php
include ($config->real() . $config->footer); ?>