Page 1 of 1
Show a new thing every X seconds and user logs
Posted: Tue Mar 19, 2013 9:24 pm
by Eddy Parera
I thought instead of creating 2 threads, I could join them. If you are answering for the 1st, on top say 1st, or the 2nd say 2nd.
1st: There is a div that changes its content for something that is on the DB.
E.G. News number 1.
Title
time and date
text.
and every X seconds, I want the script to get a new news from the DB.
They are getting an id and I made it to get the last 5 id that have been entered (It will show the last 5 posted news.)
I know that it needs jQuery but I don't understand nothing about jQuery.
2nd: I want to create a activity log for every user.
I want to track every login IP to search for multiaccounts (I know how to get the Ip, but not how to store lots of them to the DB or a file).
Re: Show a new thing every X seconds and user logs
Posted: Tue Mar 19, 2013 10:00 pm
by hallsofvallhalla
1. Use ajax and timeout
this calls getNews function every 10 seconds
Code: Select all
setInterval(function() {getNews(); }, 10000);
this queries the database or rather calls getNews.php page and passes a get variable called date
Code: Select all
function getNews()
{
var query = $.ajax({
url:'getNews.php?date=' + date,
dataType: "json"
});
query.done(function(response,textStatus,jqXHR)
{
for(var i = 0;i<response.length;i++)
{
document.getElementById('NewsDiv').innerHTML = reponse[i];
}
}
}
now on your getNews.php
whatever you want to be displayed echo out as so
so lets say you had three fields to display date, author, and news
Code: Select all
$query = array();
array_push($query, $newsInfo3['date'],$newsInfo3['author'],$newsInfo3['news']);
echo json_encode($query);
this would pass the variable above called response an array so it would be
response[0] = date
response[1] = author
response[2] = news
2. not sure exactly what you mean but you could do as i have mentioned above but have it insert instead of query and use json to send it.
Re: Show a new thing every X seconds and user logs
Posted: Tue Mar 19, 2013 11:34 pm
by Eddy Parera
On the second thing, I want to build an anti-cheating system to prevent multi-accounts, So I need a place to store every information as a player activity log.
Thanks, the first one should work...
Re: Show a new thing every X seconds and user logs
Posted: Wed Mar 20, 2013 12:15 am
by vitinho444
2nd
Eddy, not sure if it works for you, but for me would. If i were you, i add to the auth page, where the login info is checked out:
Code: Select all
if($playerinfo["IP"]) //PLAYER HAS AN IP
{
$newip = CHECK_FOR_THE_IP_USER_IS_ACESSING;
$old_ip = $playerinfo["IP"];
if($newip != $old_ip)
{
echo "not the same ip.. are u using other computer?";
}
}
Then for the cheating problem, just use the same principle but check when a user registers, if the IP is already on any player's info, if yes, then the player is creating 2 accs on the same network.
Re: Show a new thing every X seconds and user logs
Posted: Thu Mar 21, 2013 5:16 pm
by Eddy Parera
hallsofvallhalla, can you explain better your code please
Because I don't understand where do you want me to put those codes.
I have tried different things but I can't get to what I want...