Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<form action="download.php" method="post">
<p><label>Pfad</label><input type="text" name="T1" size="55"></p>
<p><input type="submit" value="Download" name="B1"></p>
</form>
<?php
function spliturl($url)
{
$url_array=explode("://",$url);
if (count($url_array)>1)
{
$protocol=$url_array[0];
$url=$url_array[1];
}
else
{
$protocol="http";
$url=$url_array[0];
}
$url_array=explode("?",$url);
if (count($url_array)>1)
{
$parameters=$url_array[1];
}
else
{
$parameters="";
}
$url=$url_array[0];
$url_array=explode("/",$url);
if (count($url_array)>1)
{
$url=$url_array[0];
unset($url_array[0]);
$path=implode("/",$url_array);
}
else
{
$url=$url_array[0];
$path="";
}
$url_array=explode(":",$url);
if (count($url_array)>1)
{
$port=$url_array[1];
}
else
{
if ($protocol=="http")
{
$port=80;
}
elseif ($protocol=="https")
{
$port=443;
}
}
$host=$url_array[0];
$url=array("protocol"=>$protocol,"host"=>$host,"port"=>$port,"path"=>$path,"parameters"=>$parameters);
return $url;
}
if (!empty($_POST['url']))
{
require("httpconnection.class.php");
$url=spliturl($_POST['url']);
if ($url['protocol']=="https")
{
$http=new httpconnection($url['host'],$url['port'],true,$_SERVER['HTTP_USER_AGENT']);
}
else
{
$http=new httpconnection($url['host'],$url['port'],false,$_SERVER['HTTP_USER_AGENT']);
}
$data=$http->get($url['path'],$url['parameters']);
while (isset($data['head']['location']))
{
if (isset($data['head']['location']['parameters']))
{
$data=$http->get($data['head']['location']['uri'],$data['head']['location']['parameters']);
}
else
{
$data=$http->get($data['head']['location']['uri']);
}
}
if (isset($data['head']['contenttype']))
{
header("Content-Type:".$data['head']['contenttype']);
}
header("Content-Disposition:attachment; filename=\"".$url['path']."\"");
echo $data['body'];
}
else
{
echo '<form method="post" action="download.php">';
echo '<input type="text" name="url">';
echo '<input type="submit" name="download" value="Download">';
echo '</form>';
}
?>