如果密码正确,PHP从其他服务器下载.zip文件 [英] PHP download .zip file from another server if the password is correct

查看:137
本文介绍了如果密码正确,PHP从其他服务器下载.zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事我自己的CMS。我将CMS的最新更新放在服务器上的更新文件夹中,文件名为update.zip。



有没有办法让我们说一个具有变量的更新服务器上的PHP文件例如 http://updateserver.com/update.php?pass=JDFSDH324723HDSFSDJFDSHSD3



如果通行证是正确的,那么系统可能会下载.zip文件?



或者如果你们能想到更好的方式制作更新系统我打开建议:)

解决方案

在更新服务器上:

 <?php 
if($ _GET ['pass'] == $ thepassword){
header -Transfer-Encoding:binary');
header('Content-Length:'.filesize($ zipfile));
header('Content-Type:application / zip');
readfile($ zipfile);
exit();
}
else {
echo'error';
}
?>


I'm working on my very own CMS. I put the latest updates of the CMS into an update folder on the server and the file name is update.zip.

Is there a way for me to call let's say a PHP file on the update server with a variable e.g. http://updateserver.com/update.php?pass=JDFSDH324723HDSFSDJFDSHSD3

And if the pass is correct that then the system may download the .zip file?

Or if you guys can think a better way of making an update system I'm open for suggestions :)

解决方案

On the update server:

<?php
if ($_GET['pass'] == $thepassword) {
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: '.filesize($zipfile));
    header('Content-Type: application/zip');
    readfile($zipfile);
    exit();
}
else {
    echo 'error';
}
?>

这篇关于如果密码正确,PHP从其他服务器下载.zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆