开发者

Best practices to let my web users download custom .exe from my site using PHP

开发者 https://www.devze.com 2023-03-30 03:03 出处:网络
im trying to implement on my site a system who let the user download a file that have to be change before the download.

im trying to implement on my site a system who let the user download a file that have to be change before the download.

I have a master file (a .exe program), that inside have a variable who has to be change for every different user.

The most simple solution is to change a variable inside a xml file every time the user wan开发者_高级运维t his personalized exe and then make the exe file to read the external file. BUT i dont want the user to download more than one file.

Is this possible? using php can i change a parametter inside a compiled program? Thanks for any help and suggestions!


If you really really know what you're doing and you know exactly the bits that need to be flipped inside the file, then yes, it's possible to modify the .exe file with PHP. Otherwise you have to make changes to the source or other files the .exe is built with and compile the program on the server before sending it to the user.


In theory it's certainly possible (PHP is turing complete), but as stated in other answers it will be hardly worth the hassle (considering the fact that you have to ask whether it is possible shows you'd have to investigate at last for days into the standard exe-format). I'd recommend one of the following: 1) Zip the program with the configuration file; either use a separate launcher (e.g. Java [a JAR is a ZIP file]) or add a configuration file that is read by the program itself. There is a number of PHP libraries for generating ZIP files. 2) compile the program with the changed source on the server itself; however this can also become quite complicated depending on your server configuration and the programming environment you use. If you have never administered a virtual server I would not even slightly recommend that as an option. 3) If you can assume that the user got somewhat stable Internet access you might also consider to let hir download a standard executable, where additional configuration will be downloaded later on by the program itself (e.g. by transmitting the username to the server). However this creates dependencies you might want to avoid (your user probably can't use it on machines without Internet access and you should assert that your server is up most of the time).


While it's probably possible, I doubt it's worth the hassle. Unless you're trying to fight piracy or something. Why don't you just serve the user a custom .zip file with the .exe and a config .xml?

[edit after OP commented]
I presume what you're trying to edit is the facebook ID/username? Well, try to compile the base file with some unique string like "THISNEEDSTOBEREPLACED", then use some binary safe function to replace it. Though remember things can and will get tricky if the string lengths don't match.

0

精彩评论

暂无评论...
验证码 换一张
取 消