2007-10-26 21:14:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("../inc/db_conn.inc");
|
2007-10-29 16:38:25 +00:00
|
|
|
require_once("../inc/util.inc");
|
2007-10-26 21:14:35 +00:00
|
|
|
|
|
|
|
class BoincDb extends DbConn {
|
2007-10-29 04:02:41 +00:00
|
|
|
static $instance;
|
2007-10-26 21:14:35 +00:00
|
|
|
|
2007-10-29 16:38:25 +00:00
|
|
|
static function get($readonly = false) {
|
2007-11-06 18:25:44 +00:00
|
|
|
global $generating_xml;
|
|
|
|
if (web_stopped()) {
|
|
|
|
if ($generating_xml) {
|
|
|
|
xml_error(-183);
|
|
|
|
} else {
|
|
|
|
page_head("Page not available");
|
|
|
|
echo "This page requires database access.
|
|
|
|
Our database server is temporarily shut down for maintenance.
|
|
|
|
Please try again later.
|
|
|
|
";
|
|
|
|
page_tail();
|
|
|
|
}
|
|
|
|
exit();
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
if (!isset($instance)) {
|
2007-10-29 16:38:25 +00:00
|
|
|
$config = get_config();
|
|
|
|
$user = parse_config($config, '<db_user>');
|
|
|
|
$passwd = parse_config($config, '<db_passwd>');
|
|
|
|
$host = parse_config($config, '<db_host>');
|
|
|
|
$replica_host = parse_config($config, '<replica_db_host>');
|
|
|
|
$name = parse_config($config, '<db_name>');
|
|
|
|
if ($host == null) {
|
|
|
|
$host = "localhost";
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
$instance = new DbConn();
|
2007-10-29 16:38:25 +00:00
|
|
|
if ($readonly && $replica_host) {
|
|
|
|
$retval = $instance->init_conn($user, $passwd, $replica_host, $name);
|
|
|
|
if ($retval) return $instance;
|
|
|
|
}
|
|
|
|
$retval = $instance->init_conn($user, $passwd, $host, $name);
|
2007-10-26 21:14:35 +00:00
|
|
|
if (!$retval) return null;
|
|
|
|
}
|
|
|
|
return $instance;
|
|
|
|
}
|
2007-10-27 20:38:12 +00:00
|
|
|
static function escape_string($string) {
|
|
|
|
$db = self::get();
|
|
|
|
return $db->base_escape_string($string);
|
|
|
|
}
|
2007-11-12 22:28:17 +00:00
|
|
|
static function error() {
|
|
|
|
$db = self::get();
|
|
|
|
return $db->base_error();
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincUser {
|
2007-11-10 00:32:42 +00:00
|
|
|
static $cache;
|
2007-10-29 16:38:25 +00:00
|
|
|
static function lookup($clause) {
|
2007-10-26 21:14:35 +00:00
|
|
|
$db = BoincDb::get();
|
2007-10-29 16:38:25 +00:00
|
|
|
return $db->lookup('user', 'BoincUser', $clause);
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 00:32:42 +00:00
|
|
|
static function lookup_id_nocache($id) {
|
2007-10-26 21:14:35 +00:00
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'user', 'BoincUser');
|
|
|
|
}
|
2007-11-10 00:32:42 +00:00
|
|
|
static function lookup_id($id) {
|
|
|
|
if (!isset(self::$cache[$id])) {
|
|
|
|
self::$cache[$id] = self::lookup_id_nocache($id);
|
|
|
|
}
|
|
|
|
return self::$cache[$id];
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
static function count($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->count('user', $clause);
|
|
|
|
}
|
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'user', $clause);
|
|
|
|
}
|
2007-11-05 23:55:33 +00:00
|
|
|
static function enum($where_clause, $order_clause=null) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('user', 'BoincUser', $where_clause, $order_clause);
|
|
|
|
}
|
|
|
|
static function enum_fields($fields, $where_clause, $order_clause=null) {
|
2007-10-26 21:14:35 +00:00
|
|
|
$db = BoincDb::get();
|
2007-11-05 23:55:33 +00:00
|
|
|
return $db->enum_fields(
|
|
|
|
'user', 'BoincUser', $fields, $where_clause, $order_clause
|
|
|
|
);
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
2007-10-28 15:03:14 +00:00
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('user', $clause);
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincTeam {
|
2007-11-05 23:55:33 +00:00
|
|
|
static $cache;
|
2007-11-01 17:54:44 +00:00
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('team', $clause);
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'team', 'BoincTeam');
|
|
|
|
}
|
2007-11-05 23:55:33 +00:00
|
|
|
static function lookup_id_cache($id) {
|
|
|
|
if (!isset($cache[$id])) {
|
|
|
|
$cache[$id] = self::lookup_id($id);
|
|
|
|
}
|
|
|
|
return $cache[$id];
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'team', $clause);
|
|
|
|
}
|
2007-10-29 16:38:25 +00:00
|
|
|
static function enum($clause, $clause2=null) {
|
2007-10-26 21:14:35 +00:00
|
|
|
$db = BoincDb::get();
|
2007-10-29 16:38:25 +00:00
|
|
|
return $db->enum('team', 'BoincTeam', $clause, $clause2);
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
2007-11-01 17:54:44 +00:00
|
|
|
static function lookup($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('team', 'BoincTeam', $clause);
|
|
|
|
}
|
2007-11-07 17:23:29 +00:00
|
|
|
function delete() {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete($this, 'team');
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincTeamDelta {
|
2007-10-29 16:38:25 +00:00
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('team_delta', $clause);
|
|
|
|
}
|
2007-10-26 21:14:35 +00:00
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('team_delta', 'BoincTeamDelta', $clause);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-27 20:38:12 +00:00
|
|
|
class BoincHost {
|
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'host', 'BoincHost');
|
|
|
|
}
|
2007-10-28 15:03:14 +00:00
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'host', $clause);
|
|
|
|
}
|
2007-10-27 20:38:12 +00:00
|
|
|
function delete() {
|
2007-11-06 23:21:55 +00:00
|
|
|
$db = BoincDb::get();
|
2007-10-27 20:38:12 +00:00
|
|
|
return $db->delete($this, 'host');
|
|
|
|
}
|
2007-10-28 15:03:14 +00:00
|
|
|
static function enum($clause, $clause2=null) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('host', 'BoincHost', $clause, $clause2);
|
|
|
|
}
|
2007-10-27 20:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class BoincResult {
|
|
|
|
static function count($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->count('result', $clause);
|
|
|
|
}
|
2007-10-28 15:03:14 +00:00
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('result', 'BoincResult', $clause);
|
|
|
|
}
|
2007-10-29 04:02:41 +00:00
|
|
|
static function update_aux($clause) {
|
2007-10-28 15:03:14 +00:00
|
|
|
$db = BoincDb::get();
|
2007-10-29 04:02:41 +00:00
|
|
|
return $db->update_aux('result', $clause);
|
2007-10-28 15:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
class BoincWorkunit {
|
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'workunit', 'BoincWorkunit');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BoincApp {
|
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'app', 'BoincApp');
|
|
|
|
}
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('app', 'BoincApp', $clause);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BoincAppVersion {
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('app_version', 'BoincAppVersion', $clause);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-29 04:02:41 +00:00
|
|
|
class BoincProfile {
|
|
|
|
static function lookup($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('profile', 'BoincProfile', $clause);
|
|
|
|
}
|
|
|
|
static function update_aux($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update_aux('profile', $clause);
|
|
|
|
}
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('profile', $clause);
|
|
|
|
}
|
2007-10-29 16:38:25 +00:00
|
|
|
static function enum($clause, $clause2=null) {
|
2007-10-29 04:02:41 +00:00
|
|
|
$db = BoincDb::get();
|
2007-10-29 16:38:25 +00:00
|
|
|
return $db->enum('profile', 'BoincProfile', $clause, $clause2);
|
2007-10-29 04:02:41 +00:00
|
|
|
}
|
2007-11-12 22:28:17 +00:00
|
|
|
function delete_aux() {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete_aux('profile', $clause);
|
|
|
|
}
|
2007-10-29 04:02:41 +00:00
|
|
|
}
|
|
|
|
|
2007-11-07 17:23:29 +00:00
|
|
|
class BoincTeamAdmin {
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('team_admin', $clause);
|
|
|
|
}
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('team_admin', 'BoincTeamAdmin', $clause);
|
|
|
|
}
|
|
|
|
static function delete($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete_aux('team_admin', $clause);
|
|
|
|
}
|
|
|
|
static function lookup($teamid, $userid) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup('team_admin', 'BoincTeamAdmin', "teamid=$teamid and userid=$userid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-12 16:00:37 +00:00
|
|
|
class BoincPrivateMessage {
|
|
|
|
static function lookup_id($id) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->lookup_id($id, 'private_messages', 'BoincPrivateMessage');
|
|
|
|
}
|
|
|
|
function update($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->update($this, 'private_messages', $clause);
|
|
|
|
}
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('private_messages', 'BoincPrivateMessage', $clause);
|
|
|
|
}
|
|
|
|
static function insert($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->insert('private_messages', $clause);
|
|
|
|
}
|
|
|
|
static function count($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->count('private_messages', $clause);
|
|
|
|
}
|
|
|
|
function delete() {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete($this, 'private_messages');
|
|
|
|
}
|
2007-11-12 22:28:17 +00:00
|
|
|
function delete_aux($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->delete_aux('private_messages', $clause);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BoincPlatform {
|
|
|
|
static function enum($clause) {
|
|
|
|
$db = BoincDb::get();
|
|
|
|
return $db->enum('platform', 'BoincPlatform', $clause);
|
|
|
|
}
|
2007-11-12 16:00:37 +00:00
|
|
|
}
|
|
|
|
|
2007-10-26 21:14:35 +00:00
|
|
|
?>
|