使用 PHP 创建自解压可执行文件
我尝试开发的自解压可执行文件是一个安装程序。最终用户将访问一个网站,然后系统会提示他们在该网站上注册,并向他们提供下载。该下载是自解压可执行文件,它将在最终用户的计算机上安装该软件以及一个配置文件,其中包含用户的唯一 ID。该软件是一项 Windows 服务,因此它无法简单地询问用户的用户名和密码。
为了能够将注册用户的唯一 ID 插入安装程序,我必须动态生成安装程序。经过研究和使用我自己的经验后,我决定自解压可执行文件将是最佳选择。我现在的问题是如何使用 PHP 生成一个?研究这个问题后,我发现最常见的解决方案是安装一个可执行文件,该可执行文件可以在服务器计算机上创建自解压可执行文件,然后从 PHP 调用它。但是,我的网络主机无法执行可执行文件,因此这不是一个可行的解决方案。
The self-extracting executable that I'm attempting to develop is an installer. An end-user will visit a site, then they will be prompted to register on the site and a download will be provided to them. That download is the self-extracting executable that will install the software on the end-user's computer along with a config file that will have the user's unique id in it. The software is a Windows Service so it will not be able to simply ask the user their username and password.
To be able to insert the registered user's unique id into the installer, I would have to generate the installer on the fly. After researching and using my own experience, I decided that a self-extracting executable would be the best option. The question I have now is how can I generate one using PHP? After researching this problem, I found that the most common solution was to install a executable that could create self-extracting executables on the server machine and then invoke it from PHP. However, executing a executable is not possible with my web host, so this is not a viable solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为在这种情况下,您将需要切换到允许您执行此操作的网络主机(或租用专用或虚拟服务器)。安装必要的库后,您可以从 PHP 中创建 ZIP 文件,仅此而已。生成自解压可执行文件不在菜单上。
如果这不是一个选项,您将必须找到一种方法来预先生成自解压可执行文件,然后将用户 ID 注入其中。这当然是可能的,但我希望您必须为此构建一个自定义的自解压器。
I think in that case, you will need to switch to a web host that lets you do this (or rent a dedicated or virtual server). You can create ZIP files from within PHP when the necessary libraries are installed, but that is about it. Producing Self-extracting executables is not on the menu.
If that is not an option, you would have to find a way to pre-produce the self-extracting executable and inject the user ID into it afterwards. That is surely possible, but I expect you would have to build a custom self-extractor for this.
自解压存档只是附加了存档数据的提取器。提取器程序自行打开,找到数据的偏移量并提取。可能有预告片记录来帮助找到偏移量。
您可以在 PHP 中轻松附加文件:程序和用户数据的存档。但是您需要编写一个自定义提取器来识别这种格式。
A self-extracting archive is just an extractor with archive data appended. The extractor program opens itself, finds the offset of the data and extracts. There might be a trailer record to help find the offset.
You can append files easily in PHP: both an archive with your program and the user data. But you need to write a custom extractor that will be aware of this format.
我不确定这是否可能。您最多能做的就是使用 PHP 来动态获取所需的文件?
无论如何,也许您的应用程序可以访问互联网以定期获取所需的文件?
或者,您可以在程序中引用外部 PHP 文件,例如
/data.php?userid=1222&token=9999
,这应该相当安全。I'm not sure this is possible.. The most you could do is use PHP to dynamically grab the files required surely?
Anyway, perhaps your application could access the internet to grab the files it needs periodically?
Or, you could reference an external PHP file in your program like
/data.php?userid=1222&token=9999
which should be fairly secure.