/
getFriends.php
executable file
·50 lines (41 loc) · 1.52 KB
/
getFriends.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/*This Runs as a service that will constantly wait for
@@new users to register, and when that happens this will run
@@This will update all of the tables needed for the first time
*/
include "dbConnect.php";
include "functions.php";
include "mongoconnect.php";
while(true){
$date= date('m-d-y');
$db1=mysqli_connect("localhost","root","password","profile");
//get the number of rows in the table
$numrows=mysqli_num_rows(mysqli_query($db1,'select * from tbluser;'));
/*echo $getLastDate['lastUpdated'];
if($getLastDate['lastUpdated']==$date){
echo 'dates match';
}*/
/*Reads through the tbluser table by row.
@@Then Grabs the selected row's steamid and date
@@Then Checks the date, if it is null then it will
@@add the users friends to the userstable, and the tblusers users gameslist to mongo
*/
for($i=0;$i<$numrows;$i++){
$getLastDate=mysqli_query($db1,"select lastUpdated from tbluser limit $i,1;");//select 1 row at index i
$userdate= mysqli_fetch_assoc($getLastDate);
//echo $userdate["lastUpdated"];
$fetchid=mysqli_query($db1,"select steamid from tbluser limit $i,1;");
$sid=mysqli_fetch_assoc($fetchid);
$steamid=$sid["steamid"];
if($userdate["lastUpdated"] == null){
if(mysqli_fetch_assoc($getLastDate) != $date){
echo 'dates dont match';
$newDate = "UPDATE tbluser SET lastUpdated='$date' WHERE steamid='$steamid'";
$sendquery=mysqli_query($db1,$newDate);
addFriendsToUsers($steamid);
sendMongo($steamid,2);
}//end if1
}//end if0
}//end for
}//end while
?>