rybo,
I have no idea what you mean by "fallback".
What vibration sensor?
In general web servers running PHP scripts only run them when a browser requests a URL from the server.
That means that in order to get updates the browser has to poll the server, often using some Javascript in the web page to make an AJAX request.
This is slow and crude.
A better approach is to:
1) Throw away Apache and PHP
2) Create a little HTTP server in Javascript using node.js.
3) Have that server read your GPIO or whatever.
4) Have the server "push" updates from the GPIO to the web page using websockets.
Now you have a system where whatever data updates you have on the server, GPIO chages etc, can be seen in the web page as they happen.
I have tried to create the smallest, simplest example I can think of that does what you want here
https://bitbucket.org/zicog/pigpio2html
Basically it relays GPIO input changes to "LEDs" on the web page. And it relays clicks on the web page to outputs on the GPIO.
Memory in C++ is a leaky abstraction .