session_start();
$password = "your_password";
$path = "uploads/";
$title = "DJ Mike's File Mover";
#### log out ####
if ( $_GET[logout] )
{
$_SESSION[pass] = "";
header("location:$_SERVER[PHP_SELF]");
}
#### log in ####
elseif ( $_GET[pass] == $password)
{
$_SESSION[pass] = $password;
header("location:$_SERVER[PHP_SELF]");
}
########
?>
echo "$title"; ?>
echo "$title"; ?>
#### hide rest of if not logged in
if ( $_SESSION[pass] != $password )
{
echo "";
exit;
}
# save notes
if ( $_POST[notes] )
{ $_SESSION[notes] = $_POST[notes]; }
# only move URL's
if ( $_POST && !preg_match("#^http#i", "$_POST[url]", $x) )
{
echo "$_POST[url] is not a URL!
";
}
elseif ( $_POST[url] )
# find file name
{
$url = trim($_POST[url]);
$url_array = parse_url($url);
if ( isset($url_array[path]) )
{
$path_array = explode( "/", $url_array[path] );
$num = count($path_array)-1;
$new_name = $path_array[$num];
}
else
# if no file name, use host name
{ $new_name = $url_array[host]; }
# if new name submitted, use it instead of original name
if ( $_POST[new_name] )
{
$new_name = trim($_POST[new_name]);
# remove illegal characters
$new_name = preg_replace( "#[^\w\.]#", "_", $new_name );
echo "$new_name
";
}
$name = "$path" . "$new_name";
# move & rename file
if ( @copy( "$url", "$name" ) )
{
echo "$_POST[url] uploaded and renamed to $name
";
}
else
{
echo "$_POST[url] was not uploaded!
";
}
}
?>