Code:
<?php
$config = array(
"auth" => 'Your auth key',
"link_to_file" => '',
"file_name" => 'players'
);
function updateCount($config) {
if ($_GET['auth'] == $config['auth']) {
file_put_contents($config['link_to_file'] . $config['file_name'] . ".txt", $_GET['players']);
exit;
} else {
echo 'Your auth key was incorrect; Your count has not been updated.';
}
}
function getPlayers($config) {
if (file_exists($config['link_to_file'] . $config['file_name'] . ".txt")) {
return file_get_contents($config['link_to_file'] . $config['file_name'] . ".txt");
} else {
echo $config['file_name'] . '.txt could not be found at the given location.';
}
}
Include that file anywhere, and you can use these functions:
Code:
#Update the count
updateCount($config);
#Get the player count
getPlayers($config);
Make sure you echo the last function.