The background is as follows. There is a flash widget on some resource that performs some operations with user content. In my particular case, these are photos. The task was as follows. It is necessary to collect impression statistics from external resources, i.e. how many times and where the flash drive lit up on user screens. the task was also complicated by the fact that in fact the shows had to be taken into account
not of the flash drive itself, but of the photos changing in it . If you also need to take into account the display of content inside the flash, then, alas, you will have to contact the flasher who made this widget. Why, I will explain later.
So let's get started. We all know perfectly well that the flash drive can not refer the referrer, or rather can, but this referrer will be the physical address of the location of the flash drive itself. What is not good and we absolutely do not need. So how do you refer a referrer? Very simple, just wrap the issue of a flash drive in a php script. In which we will grab the referrer to consider the show. If you have a task, just like mine, with an "asterisk", then we do a simple trick with redirecting and adding a parameter to the request, in this way. Having received the referrer in a PHP script, we generate a new request to the flash drive and redirect it. The flash drive, in turn, after receiving this parameter, adds it to each request (in my case, photos) to our server, where this request is processed by a script that takes into account all the information we need, including the referrer. Now so that everything becomes completely clear, I will give a small example of a utopian code (without checks, etc., only logic, so please do not be outraged):
If you need to add a parameter for the subsequent accounting of content within the flash drive itself, the code becomes a bit more complicated.
')
And here, we remember about the flasher, we transfer a new parameter to the flash drive, in which the referer is registered, in my case it is the referer parameter. A flasher, forming requests to the server for receiving photos (audio, video), substitutes it and the server when issuing the contents of the flash drive, takes into account the referrer and display, respectively.
The
isExternalRequest function
is not shown, it is not difficult to write it yourself. I think its essence is clear, it will return true if it is an external request and false if its server requested a USB flash drive.