从内网下载外网的文件或者将外网的文件上传,不能用ftp,只能用80端口,而且外网的文件不能被外人下载,也就是要实行加密 从内网下载外网的文件或者将外网的文件上传,不能用ftp,只能用80端口,而且外网的文件不能被外人下载,也就是要实行加密,可以用linux,java,最好是php编写先谢谢各位了!急!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我现在已用php编写了一段代码,主要是下面这条语句,它虽可以访问外网的文件,但这样很不安全,肯定是不行,不知谁有什么好的办法吗?$remotefile = @fopen ("http://100.80.1.1/mysqlbackup/20090904.sql", "rb");if (!$remotefile) { echo "<p>Unable to open remote file.\n"; exit;}$line="";while (!feof ($remotefile)) { $line .=@fgets ($remotefile, 1024);}fclose($remotefile);$tempfile="/var/www/html/mysqlbackup/20090908.sql";$localfile=@fopen($tempfile,"wb");@fwrite($localfile,$line);fclose($localfile); 服务器server.php<?phpif (isset ($_POST)) { $login_name = $_POST[username]; $login_password = $_POST[password]; $login_ip = $_POST[ip];//如果为了安全,用户名、密码及IP可以从数据库中存储 if ($login_name=="liu" and $login_password=="123" and $login_ip=="19.16.16.252"){ echo "right"; $filename = "/bak1/test.txt"; header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($filename)); $line=readfile($filename); }else{ die("wrong"); } }exit;?>客户端client.php<?php$url='http://11.8.14.3/mysqlbackup/server.php';$fields = "username=liu&password=123&ip=192.168.166.252"; $fp=fopen("test.txt",wb);$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_FILE, $fp);curl_setopt($ch, CURLOPT_POST, 1 );curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields ); curl_setopt($ch, CURLOPT_HEADER, 0);$str=curl_exec($ch);fwrite($fp,$str);fclose($fp);curl_close($ch); ?> 二次开发的含义 dedecms 如何配置 如何获取Header中的value php问卷调查系统 phpexcel乱码 wordpress代码:sql 语句中的 pm wp 是什么意思? sum函数输出 在线等 微信后台开发 tp5的动态多级路由问题 求助资源 心情不爽,散分 从内网下载外网的文件或者将外网的文件上传,不能用ftp,只能用80端口,而且外网的文件不能被外人下载,也就是要实行加密,可以用linux,java,最好是php
$remotefile = @fopen ("http://100.80.1.1/mysqlbackup/20090904.sql", "rb");
if (!$remotefile) {
echo "<p>Unable to open remote file.\n";
exit;
}
$line="";
while (!feof ($remotefile)) {
$line .=@fgets ($remotefile, 1024);}fclose($remotefile);$tempfile="/var/www/html/mysqlbackup/20090908.sql";
$localfile=@fopen($tempfile,"wb");
@fwrite($localfile,$line);
fclose($localfile);
<?php
if (isset ($_POST)) {
$login_name = $_POST[username];
$login_password = $_POST[password];
$login_ip = $_POST[ip];
//如果为了安全,用户名、密码及IP可以从数据库中存储
if ($login_name=="liu" and $login_password=="123" and $login_ip=="19.16.16.252"){
echo "right";
$filename = "/bak1/test.txt";
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($filename));
$line=readfile($filename);
}else{
die("wrong");
}
}
exit;
?>
客户端client.php
<?php
$url='http://11.8.14.3/mysqlbackup/server.php';
$fields = "username=liu&password=123&ip=192.168.166.252";
$fp=fopen("test.txt",wb);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields );
curl_setopt($ch, CURLOPT_HEADER, 0);
$str=curl_exec($ch);
fwrite($fp,$str);
fclose($fp);
curl_close($ch);
?>