#LeaderboardC2
LeaderboardC2 is a self hosted Open Source PHP Leaderboard for Construct2. Post, fetch and display high scores.
- PHP 5.4+ with at least one library extension that deals with SQLite is required (either PDO, SQLite3, or SQLiteDatabase). PHP version 5.3.0 and greater usually comes with the SQLite3 extension installed and enabled by default so no custom action is necessary.
To determine your PHP version, create a new file with this PHP code: <?php echo PHP_VERSION; // version.php
. This will print your version number to the screen.
- Insure that you have the required components.
- Download LeaderboardC2 or cloning this Github repo.
- Upload LeaderboardC2 through FTP/SFTP or whatever upload method you prefer to the public-facing directory of your site.
- Ensure that the permissions for the
data
folder andyourbase.sqlite
file are set to0777
.
If you're using Apache, make sure you activate the URL rewriting module (mod_rewrite) in your apache.conf (or httpd.conf) file. You should also create a .htaccess file containing the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
The script tells Apache that whenever an HTTP request arrives and if no physical file (!-f) or path (!-d) or symbolic link (!-l) can be found, it should transfer control to index.php, which contains our main/front controller, and which in turn, invokes the framework.
The .htaccess file containing the Apache directives stated above should always be in the same folder as index.php.
You also need to set up Apache so it knows the physical location of index.php in your hard drive. A typical configuration is:
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks +Includes
AllowOverride All
Order allow,deny
Allow from All
</Directory>
PHP's latest stable version has its own built-in Web server. Start it up using the following configuration:
php -S localhost:80 -t /var/www/
The above command will start routing all requests to the Web root /var/www. If an incoming HTTP request for a file or folder is received, PHP will look for it inside the Web root and send it over to the browser if found. Otherwise, PHP will load the default index.php.
- Close Construct 2.
- Checkout the 'master' branch from this repository.
- Copy the contensts of the folder addon/files/leaderboard/ into CONSTRUCT2_INSTALLATION_FOLDER\exporters\html5\plugins\leaderboard.
Drag and drop the leaderboard.c2addon in to the Construct2 window to install it.
The plugin can be configured by selecting the object Leaderboard from the Object types list inside Construct2.
- Leaderboard service URL (The Leaderboard service URL. This value most not end with a slash, e.g: http//myserver/leaderboard)
- Game ID (The game id. Should be equal to the SQLite file name without the .sqlite extension)
- Magic number (The magic number. Should be equal to the 'magic_number' property in the config.ini file)
- Magic key (The magic key. Should be equal to the 'magic_key' property in the config.ini file)
- Log requests (Sends request URLs into console. For debugging purposes)
- Set timeout (Set the maximum time before a request is considered to have failed)
- Set request header (Set a HTTP header on the next request that is made)
- Request Top Scores (Top Scores request returns an array of scores to your function where you can display the data in your Leaderboard)
- Get the player's last rank (Get the player's last rank)
- Get the player's best rank (Get the player's best rank)
- Submit score (Submit player's score)
- On Top Scores completed (Triggered when a Top Scores request completes successfully)
- On Get Best Rank completed (Triggered when a Get Best Rank request completes successfully)
- On Get Last Rank completed (Triggered when a Get Last Rank request completes successfully)
- On Add Score completed (Triggered when a Add Score request completes successfully)
http://htejera.ukelelestudio.com/leaderboardc2/demo/
This project comes with a .capx as a reference to know how to use it, you can download it from here.
- Integers Google Play
- Simple Web
Got a successful game you'd like added to this section? Let me know in the forum!
https://www.scirra.com/forum/plugin-a-self-hosted-open-source-php-leaderboard-for-con_t125116
- phpLiteAdmin is a web-based SQLite database admin tool written in PHP with support for SQLite3 and SQLite2.
- SQLite Management Tools
If you need to get in touch with me, you can reach me at henrytejera |AT| gmail |DOT| com
Please submit issues to ohtejera/leaderboardC2 and pull requests to *-dev branches.
Fat-Free framework. A powerful yet easy-to-use PHP micro-framework .
The MIT License (MIT)
Copyright (c) 2015 Henry Tejera
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.