Am trying to code Socks proxy checker using, js and php and for sure html
but am getting some issues with the script which is
i can load the list of proxies which is in this format > IP:PORT <
from file using
<input type="file" id="files" name="files[]" class="form-control" placeholder="">
am trying to get the script to get the socks list from textarea and run and start the check
sctipts >>>>>
<body>
<div class="container">
<form id="proxy_form" class="form-horizontal">
<fieldset>
<legend>Select Proxy File</legend>
<input style="margin-bottom:2px;" type="text" id="host" class="form-control" placeholder="Ping Site (Optional | Default: http://wtfismyip.com/)">
<div class="input-group">
<input type="file" id="files" name="files[]" class="form-control" placeholder="">
<span class="input-group-btn">
<input type="submit" class="btn btn-default" type="button">Go!</button>
</span>
</div>
</fieldset>
</form>
<br>
<div id="results-panel" class="panel panel-default scrollable-y size-3" hidden>
<div class="panel-body">
<div id="results"></div>
</div>
</div>
<a id="download_working_proxies" style="width: 100%;margin-bottom:15px;" class="btn btn-success hidden">Download Working Proxies</a>
<footer>
<p>Made by hixtox | <span id="status" class="pull-right">Idle...</span></p>
<p>Checked:<span id="checked" class="pull-right">0</span></p>
</footer>
</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="bootstrap-custom/js/bootstrap-custom.js"></script>
<script type="text/javascript" src="js/ProxyChecker.js"></script>
<script>
$(document).ready(function() {
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
alert("Not all the File API's are supported by your browser!");
}
$("#proxy_form").submit(function(event) {
event.preventDefault();
var form = $("#proxy_form");
if (form[0][2].files) {
var file = form[0][2].files[0];
var fileReader = new FileReader();
fileReader.readAsText(file);
fileReader.onload = function(o) {
var result = o.target.result.split(/\s+/);
new ProxyChecker(result, "#host").check();
}
}
});
});
</script>
</body>
JS SCRIPT >>>>
var ProxyChecker = function(proxies, host) {
this.proxies = proxies;
this.host = host;
$("#status").html("Initializing...");
}
ProxyChecker.prototype.check = function() {
$("#results-panel").fadeIn("fast");
$("#status").html("Checking...");
$("#results").empty();
//Amount of proxies in our array.
var max = this.proxies.length;
//Amount of proxies checked.
var checked = 0;
//Amount of working proxies.
var working = [];
for (i = 0; i < this.proxies.length; i++) {
var proxy = this.proxies[i];
/**
* Perform an AJAX request to our ping script.
*/
$.ajax({
url: "php/ping.php",
data: "proxy=" + proxy + "&host=" + $(this.host).val(),
success: function(response) {
checked += 1;
$("#checked").html(checked);
//Strip and clean response.
response = response.replace(/(<([^>]+)>)/ig,"");
response = response.trim();
if (response.match("Die") || response.match("^Die")) { //Match all possible errors.
$("#results").append("<p>" + response + "</p>");
}
} else { //All successful proxies.
$("#results").append("<p>" + response + "</p>");
working.push(response); //Push the working proxy to our working proxies array.
}
if (checked == max - 1) { //Once all our proxies are checked.
var workingString = "";
//Loop over our working proxies array and append it to a single string for the file download.
for (i1 = 0; i1 < working.length; i1++) {
workingString += working[i1] + "\n";
}
var dateObj = new Date($.now());
var time = dateObj.toJSON().substring(11, 19);
var date = dateObj.toJSON().substring(0, 10);
var filename = "proxies-" + time + "_" + date + ".txt";
createDownload(filename, workingString);
$("#download_working_proxies").fadeIn("fast");
$("#status").html("Finished - " + working.length + " working proxies.");
}
}
});
}
}
/**
* Creates a client-side file with the passed text.
* @see http://stackoverflow.com/a/18197341
*/
function createDownload(filename, text) {
$("#download_working_proxies").attr('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
$("#download_working_proxies").attr('download', filename);
$("#download_working_proxies").removeClass("hidden");
}