I need a small PHP script that will perform the following functions:
1. Receive a POST notification from BitBucket repository and then fetches the latest change set of the specified branch from the repository and download that change set as a zip on web server running on cPanel.
2. Extract that change set/zip to a temporary folder.
3. Empty the existing application folder except two configuration files (again specified in some config file), and then copy the extracted zip (from step 2) to the app folder
4. Record that change set in a log file which it will refer every time a POST is received from BitBucket to ensure it doesn't write until a newer change set is received.
5. After successful copying, delete the zip and temporary files.
6. Call a URL using Curl to execute database related changes.
You can take a look at this open source project on Bitbucket which does the same thing (with some limitations): https://github.com/codearts/BitBuc
I don't want you to copy the code from the above URL.
It's a small project and I need this within 2 days after awarding it to you. Timely completion is very important.