mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-05-04 12:36:32 -05:00
Closes #1567 The main reason I'm not simply merging Annika's PR is because this way makes it clearer that I'm taking responsibility for all this code, that it's mostly code I wrote, and also because it makes it easier to ensure that none of the files have been changed. (Not that I don't personally trust Annika, but I have something resembling an obligation to users not to expose them to risks based on personal trust.)
69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
<?php
|
|
|
|
//debug_print_backtrace();
|
|
//die();
|
|
|
|
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']);
|