Author Topic: Regarding Online Leaderboards library  (Read 522 times)

darkhog

  • Newbie
  • *
  • Posts: 40
    • View Profile
Regarding Online Leaderboards library
« on: June 13, 2016 »
Currently it stores its data on NaaLaa's servers.

But how about distributing a php file along with the lib that would allow you to put leaderboards on your own server? From api side, all functions that download/upload scores would be given additional string parameter that would set url the score was to be uploaded to/downloaded from (wmpty for default value of NaaLaa server).

This way, people who don't have a webserver could still use NaaLaa's server and those who have access to one and need security that if NaaLaa's servers will go down the scores are still up could upload server-side part of the scoreboard (php script) to their own server and just point OLB in its direction in their games.

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 549
    • View Profile
Re: Regarding Online Leaderboards library
« Reply #1 on: June 15, 2016 »
Good idea! Will fix that :)

Edit It's not an advanced (or the least safe, haha) system at all, just a php script that reads and writes to textfiles.

The p2p multiplayer extension I'm working on atleast uses a mysql database to manage live lobbies.

« Last Edit: June 15, 2016 by Marcus »
.\\\opz

darkhog

  • Newbie
  • *
  • Posts: 40
    • View Profile
Re: Regarding Online Leaderboards library
« Reply #2 on: June 15, 2016 »
I see. Would be nice to get php script in question. I remember writing leaderboards script for one of my multimedia fusion 2 games, maybe I can dig it up.

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 549
    • View Profile
Re: Regarding Online Leaderboards library
« Reply #3 on: June 22, 2016 »
I'm not sure if John wrote the script himself or if he just grabbed it from somewhere, but here it is:

Code: [Select]
<?php header("Cache-Control: no-cache, must-revalidate");
  
// Create a Blank File if it doesn't already exist
if (!file_exists($_GET["filename"]))
{
$file=fopen($_GET["filename"], "w");
fclose ($file);
}

// Read the file in
$oscores file ($_GET["filename"]);
$numreadin count($oscores);

// Break out the data into a new 2-d array called $tscores
for ($i 0$i $numreadin$i++)
{
$g unserialize($oscores[$i]);
$tscores[$i][0] = $g[0];
$tscores[$i][1] = $g[1];
}

// Fill in any missing data with none/0
for ($i $numreadin$i $_GET["scoresize"]; $i++)
{
$tscores[$i][0] = 0;
$tscores[$i][1] = "empty";
}

// Process the actions

// Insert a score/name
if ($_GET["action"] == "INSERT")
{

// Add name to end of list, and sort
$tscores[$_GET["scoresize"] + 1][0] = $_GET["winscore"];
$tscores[$_GET["scoresize"] + 1][1] = $_GET["winname"];
rsort ($tscores);

$file=fopen($_GET["filename"], "w");

// Write them out
for ($i 0$i $_GET["scoresize"]; $i++)
{
$st serialize($tscores[$i]) . "\n";
fputs($file$st);
}

fclose($file);
}

// Clear the list
if ($_GET["action"] == "CLEAR")
{
$file=fopen($_GET["filename"], "w");
fclose($file);

    for (
$i 0$i $_GET["scoresize"]; $i++)
    {
      
$tscores[$i][0] = 0;
      
$tscores[$i][1] = "empty";
    }

}

for ($i 0$i $_GET["scoresize"]; $i++)
{
echo ($tscores[$i][1]);
echo ("\n");
echo ($tscores[$i][0]);
echo ("\n");
}

?>


I'm gonna have to check some backups for the scourcecode of the naalaa library (olb.lib), should be on some usb stick i got from John. I assume it just uses the 'download' function to get the output of the script.
« Last Edit: June 22, 2016 by Marcus »
.\\\opz