1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-02-21 12:33:47 +01:00

First commit. Check if all is uploaded well.

This commit is contained in:
Kevin Puertas
2017-10-30 22:59:39 +01:00
parent f88dceff1b
commit 6b38aa6cf8
247 changed files with 27230 additions and 0 deletions

46
counter.js Executable file
View File

@@ -0,0 +1,46 @@
var script = document.currentScript; //For know path
//Returns path of file, without /
function cutUrlFile(cad){
chars = cadena.split("");
blocks = cadena.split("/");
blockNum=1;
if(chars[chars.length-1]==="/"){
blockNum++;
}
pseudoReturn = [];
for(i=0;i<blocks.length-blockNum;i++){
pseudoReturn.push(blocks[i]);
}
return pseudoReturn.join("/");
}
var path = cutUrlFile(script.src); //Path, for calling php in Ajax
function loadcounter() { //Todo el js
var cookiename = "CheckWeb" + SiteID;
var b = document.cookie.match('(^|;)\\s*' + cookiename + '\\s*=\\s*([^;]+)');
var iscookie = b ? b.pop() : '';
if (iscookie != ""){
var visited = 1; //Visitado
}else{ //Si no esta visitado, hacer la cookie y contar visita unica
var visited = 0;
var d = new Date();
d.setTime(d.getTime() + (24*3600*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = "CheckWeb" + SiteID + "=visited" + "; " + expires;
}
// Enviamos los datos para introducir en la DB
// Obtener la instancia del objeto XMLHttpRequest
conexion = new XMLHttpRequest();
// Realizar peticion HTTP
conexion.open('POST', path+'/counterajax.php');
conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
conexion.send("SiteID="+SiteID+"&visited="+visited);
}
loadcounter(); //Para que funcione