forked from smogon/pokemon-showdown-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move session library inside repository
For too long, ntbb-session and ntbb-database have been maintained outside of this repo, but no longer! All these files are now part of the repository, making it significantly more self-contained. If I had to say why it took this long, I think it was mostly inertia. It was easier leaving them where they were than having to audit them for private keys in the wrong places, etc. I'm starting to think of PS more as sim first, website secondary than the other way around, now. Especially now that we don't have a forum, the website itself isn't really important... Maybe one day I'll get rid of the landing page and make the sim itself the first thing you see when you hit pokemonshowdown.com... but today is not that day! The repo is still not "batteries-included" since I am not going to teach anyone how to set up PHP and MySQL or even get the config files working. But for anyone who wanted their own client, well, it gets a lot easier to do now.
- Loading branch information
Showing
9 changed files
with
860 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
mb_internal_encoding('UTF-8'); | ||
|
||
$psconfig = [ | ||
|
||
'sysops' => ['zarel'], | ||
|
||
// password and SID hashing settings | ||
|
||
'password_cost' => 12, | ||
'sid_length' => 15, | ||
'sid_cost' => 4, | ||
|
||
// database | ||
|
||
'server' => 'localhost', | ||
'username' => '', | ||
'password' => '', | ||
'database' => '', | ||
'prefix' => 'ps_', | ||
'charset' => 'utf8', | ||
|
||
// CORS requests | ||
|
||
'cors' => [ | ||
'/^http:\/\/smogon\.com$/' => 'smogon.com_', | ||
'/^http:\/\/www\.smogon\.com$/' => 'www.smogon.com_', | ||
'/^http:\/\/logs\.psim\.us$/' => 'logs.psim.us_', | ||
'/^http:\/\/logs\.psim\.us:8080$/' => 'logs.psim.us_', | ||
'/^http:\/\/[a-z0-9]+\.psim\.us$/' => '', | ||
'/^http:\/\/play\.pokemonshowdown\.com$/' => '', | ||
], | ||
|
||
// key signing for SSO | ||
|
||
'privatekeys' => [ | ||
|
||
1 => '-----BEGIN PRIVATE KEY----- | ||
[insert RSA private key] | ||
-----END PRIVATE KEY----- | ||
', | ||
|
||
] | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
$PokemonServers = array ( | ||
'showdown' => | ||
array ( | ||
'name' => 'Smogon University', | ||
'id' => 'showdown', | ||
'server' => 'sim.psim.us', | ||
'port' => 8000, | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
include_once dirname(__FILE__).'/../config/config.inc.php'; | ||
|
||
class NTBBDatabase { | ||
var $db = null; | ||
|
||
var $server = null; | ||
var $username = null; | ||
var $password = null; | ||
var $database = null; | ||
var $prefix = null; | ||
var $charset = null; | ||
//var $queries = array(); | ||
|
||
function NTBBDatabase($server, $username, $password, $database, $prefix, $charset) { | ||
$this->server = $server; | ||
$this->username = $username; | ||
$this->password = $password; | ||
$this->database = $database; | ||
$this->prefix = $prefix; | ||
$this->charset = $charset; | ||
} | ||
|
||
function connect() { | ||
if (!$this->db) { | ||
$this->db = mysqli_connect($this->server, $this->username, $this->password, $this->database); | ||
if ($this->charset) { | ||
mysqli_set_charset($this->db, $this->charset); | ||
} | ||
} | ||
} | ||
function query($query) { | ||
$this->connect(); | ||
//$this->queries[] = $query; | ||
return mysqli_query($this->db, $query); | ||
} | ||
function fetch_assoc($resource) { | ||
return mysqli_fetch_assoc($resource); | ||
} | ||
function fetch($resource) { | ||
return mysqli_fetch_assoc($resource); | ||
} | ||
function escape($data) { | ||
$this->connect(); | ||
return mysqli_real_escape_string($this->db, $data); | ||
} | ||
function error() { | ||
if ($this->db) { | ||
return mysqli_error($this->db); | ||
} | ||
} | ||
function insert_id() { | ||
if ($this->db) { | ||
return mysqli_insert_id($this->db); | ||
} | ||
} | ||
} | ||
|
||
$psdb = new NTBBDatabase($psconfig['server'], | ||
$psconfig['username'], | ||
$psconfig['password'], | ||
$psconfig['database'], | ||
$psconfig['prefix'], | ||
$psconfig['charset']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.