Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/07/2013, 14:18
jisgore
 
Fecha de Ingreso: julio-2013
Mensajes: 6
Antigüedad: 10 años, 10 meses
Puntos: 0
Exclamación Descargando Archivos Via PHP

Estyo tratando de que mis usuarios descargen unos archivos necesarios a tu pc via php.

A ver si me pueden ayudar y decirme comom hacer que el usuario pueda descargar el archivo creado aqui.

aqui esta el codigo.

Código PHP:
<?php

$agent 
$_SERVER['HTTP_USER_AGENT'];

if(
preg_match('/Linux/',$agent)) $os 'Linux';
elseif(
preg_match('/Win/',$agent)) $os 'Windows';
elseif(
preg_match('/Mac/',$agent)) $os 'Mac';
else 
$os 'Desconocido';

if(
$os!='Desconocido')
{
$delay 1;                
            
            
$x 3;    
            
                
$port 23;
                
$timeout 180;
                
$router_ip '192.168.11.5';
                
                
                     echo 
"Se establecio el punto terminal en el router!<br><br>";
                     
                    
$y $_SERVER["REMOTE_ADDR"];
                     
                        
                    
$w $x 10;

echo 
"Su sistema operativo es: $os<br><br>";

switch(
$os)
{

//windows vista / 2008 / 7
case "Windows":

echo 
"Copie y pegue estos comandos en su terminal en modo de administrador para completar la conexion:<br>";
echo 
"netsh interface teredo set state disabled<br>";                              
echo 
"netsh interface ipv6 add v6v4tunnel Tunnel".$x." ".$y." ".$router_ip."<br>";
echo 
"netsh interface ipv6 add address Tunnel".$x." 2001:470:db80:".$x."::".$w."/64<br>";                   
echo 
"netsh interface ipv6 add route ::/0 Tunnel".$x." 2001:470:db80:".$x."::".$x."<br>"

echo 
"<br>O si lo desea, puede descargar este archivo para realizar la configuracion de manera automatica.<br>
Recuerde ejecutarlo en modo de administrador para obtener los permisos necesarios.<br>"
;

$FileName "TunnelConfig.bat";
$FileHandle fopen($FileName'w') or die("can't open file");
$string "netsh interface teredo set state disabled\n";
fwrite($FileHandle$string);
$string "netsh interface ipv6 add v6v4tunnel Tunnel".$x." ".$y." ".$router_ip."\n";
fwrite($FileHandle$string);
$string "netsh interface ipv6 add address Tunnel".$x." 2001:470:db80:".$x."::".$w."/64\n";
fwrite($FileHandle$string);
$string "netsh interface ipv6 add route ::/0 Tunnel".$x." 2001:470:db80:".$x."::".$x."\n";
fwrite($FileHandle$string);
$string "PAUSE";
fwrite($FileHandle$string);
fclose($FileHandle);

break;

//mac os x
case "Mac":
    
echo 
"Copie y pegue estos comandos en su terminal para completar la conexion:<br>";
echo 
"ifconfig Tunnel".$x." create<br>";                              
echo 
"ifconfig Tunnel".$x." tunnel ".$y." ".$router_ip."<br>";
echo 
"ifconfig Tunnel".$x." inet6 2001:470:db80:".$x."::".$w." 2001:470:db80:".$x."::".$x." prefixlen 64<br>";                   
echo 
"route -n add -inet6 default 2001:470:db80:".$x."::".$x."<br>"

echo 
"<br>O si lo desea, puede descargar este archivo para realizar la configuracion de manera automatica.<br>
Recuerde ejecutarlo en modo de administrador pra obtener los permisos necesarios.<br>"
;

$FileName "TunnelConfig.sh";
$FileHandle fopen($FileName'w') or die("can't open file");
$string "ifconfig Tunnel".$x." create\n";
fwrite($FileHandle$string);
$string "ifconfig Tunnel".$x." tunnel ".$y." ".$router_ip."\n";
fwrite($FileHandle$string);
$string "ifconfig Tunnel".$x." inet6 2001:470:db80:".$x."::".$w." 2001:470:db80:".$x."::".$x." prefixlen 64\n";
fwrite($FileHandle$string);
$string "route -n add -inet6 default 2001:470:db80:".$x."::".$x."\n";
fwrite($FileHandle$string);
fclose($FileHandle);

break;

//debian / ubuntu
case "Linux":

echo 
"Copie y pegue estos comandos en su terminal para completar la conexion:<br>";
echo 
"auto Tunnel".$x."<br>";                              
echo 
"iface Tunnel".$x." inet6 v4tunnel<br>";
echo 
"address 2001:470:db80:".$x."::".$w."<br>";                   
echo 
"netmask 64<br>"
echo 
"endpoint ".$router_ip."<br>";
echo 
"local ".$y."<br>";
echo 
"ttl 255<br>";
echo 
"gateway 2001:470:db80:".$x."::".$x."<br>";

echo 
"<br>O si lo desea, puede descargar este archivo para realizar la configuracion de manera automatica.<br>
Recuerde ejecutarlo en modo de administrador pra obtener los permisos necesarios.<br>"
;

$FileName "TunnelConfig.sh";
$FileHandle fopen($FileName'w') or die("can't open file");
$string "auto Tunnel".$x."\n";
fwrite($FileHandle$string);
$string "iface Tunnel".$x." inet6 v4tunnel\n";
fwrite($FileHandle$string);
$string "address 2001:470:db80:".$x."::".$w."\n";
fwrite($FileHandle$string);
$string "netmask 64\n";
fwrite($FileHandle$string);
$string "endpoint ".$router_ip."\n";
fwrite($FileHandle$string);
$string "local ".$y."\n";
fwrite($FileHandle$string);
$string "ttl 255\n";
fwrite($FileHandle$string);
$string "gateway 2001:470:db80:".$x."::".$x."\n";
fwrite($FileHandle$string);
fclose($FileHandle);

break;

}

}
else 
{
    echo 
"No se pudo detectar su sistema operativo, por lo cual no se podran realizar las configuraciones pertinentes";
}
?>