Last active
December 16, 2015 09:51
-
-
Save ahvonenj/0b432c759de47e76447a to your computer and use it in GitHub Desktop.
PHP dependency sniffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* Script: PHP dependency sniffer | |
* Description: Figures out to which PHP scripts the page contacts during use | |
* Date: 15.10.2015 | |
* Comments | |
* It is not perfect, but at least gives some idea which PHP files some page uses | |
* | |
* Include this script on the page you want to sniff for PHP file usage and | |
* use the page normally, as in go through page's controls of which you think | |
* make ajax calls. To view sniffer results type "sniffed_php_dependencies" | |
* to developer console. | |
*******************************************************************************/ | |
var sniffed_php_dependencies = []; | |
(function(open) | |
{ | |
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) | |
{ | |
this.addEventListener("readystatechange", function() | |
{ | |
var regxp = /((.*)\/(.*(.php)))/gi.exec(this.responseURL); | |
if(regxp && regxp[4] === '.php') | |
{ | |
if(sniffed_php_dependencies.indexOf(regxp[3]) === -1) | |
{ | |
sniffed_php_dependencies.push(/((.*)\/(.*(.php)))/gi.exec(this.responseURL)[3]); | |
} | |
} | |
console.log(sniffed_php_dependencies); | |
}, false); | |
open.call(this, method, url, async, user, pass); | |
}; | |
})(XMLHttpRequest.prototype.open); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment