/** * load config values, if availiable */ public function __construct() { // Load config-Params from config-class, if availiable (only once -> static) if (class_exists("cBootstrap") && empty(self::$config["host"])) { $loader = cBootstrap::getInstance(); self::$config = $loader->getConfig("db"); } }
/** * set all params from config file */ public function __construct() { stream_wrapper_register('pop3', 'pop3_stream'); $s = cBootstrap::getInstance(); $this->config = $s->getConfig('mail'); $this->server = new pop3_class(); $this->server->hostname = $this->config['host']; }
/** * log error or warning in log file * * @return void * @author Elias Müller **/ private static function log($message, $type) { $s = cBootstrap::getInstance(); $user = is_object($s->user) ? ' caused by ' . $s->user->id : ''; $dbg = debug_backtrace(); $dbg = $dbg[1]; $message = str_replace('<br/>', ' ', $message); $message = str_replace('<br>', ' ', $message); $msg = $type . ': ' . strip_tags($message) . $user . ' in ' . $dbg['file'] . ' on line ' . $dbg['line']; error_log($msg); }
public function Header() { $s = cBootstrap::getInstance(); $config = $s->getConfig('pdf'); // Logo $this->Image($config['header']['logo'], 15, 12, 85, '', 'PNG', '', 'T', true, 300); // Title $this->SetFont($config['font']['header'], '', $config['size']['header']); $this->SetX(117); $this->MultiCell(100, 15, $config['header']['text'], 0, 'L', false, 0, 117, 10.5); // ending header line $this->Line(4, 42, 206, 42, array('width' => 1, 'color' => array(147, 0, 0))); }
/** * set all params from config file */ public function __construct() { $s = cBootstrap::getInstance(); $this->config = $s->getConfig('mail'); $this->mail = new smtp_message_class(); $this->mail->localhost = "localhost"; $this->mail->default_charset = 'UTF-8'; $this->mail->smtp_host = $this->config['smtp']; $this->mail->smtp_port = $this->config['smtp_port']; $this->mail->smtp_user = $this->config['smtp_user']; $this->mail->smtp_password = $this->config['smtp_password']; $this->mail->smtp_port = $this->config['smtp_port']; $this->mail->smtp_ssl = 1; }
/** * save the object information */ public function save() { $db = DB::getInstance(); $s = cBootstrap::getInstance(); $game = $this->info['game'] != FALSE ? $this->info['game']->id : 0; $spot = $this->info['spot'] != FALSE ? $this->info['spot']->id : 0; if ($this->id === false) { $sql = "INSERT INTO poker_tables\n SET idgame = '" . $game . "',\n idspot = '" . $spot . "',\n title = '" . $this->info['title'] . "',\n iduser = '******',\n d = '" . $this->info['positions']['dealer'] . "',\n sb = '" . $this->info['positions']['smallblind'] . "',\n bb = '" . $this->info['positions']['bigblind'] . "',\n seats = '" . $this->info['seats'] . "',\n blind = '" . $this->info['blinds']['small'] . "'"; } else { $sql = "UPDATE poker_tables\n SET idgame = '" . $game . "',\n idspot = '" . $spot . "',\n title = '" . $this->info['title'] . "',\n d = '" . $this->info['positions']['dealer'] . "',\n sb = '" . $this->info['positions']['smallblind'] . "',\n bb = '" . $this->info['positions']['bigblind'] . "',\n seats = '" . $this->info['seats'] . "',\n blind = '" . $this->info['blinds']['small'] . "'\n WHERE idtable = " . $this->id; } $id = $db->query($sql); if ($id != 0) { if ($this->id === false) { $this->id = $id; self::$objects[$id] = $this; } return true; } return false; }
/** * Get the player object for the current user and table */ public static function getActivePlayer($idtable) { $db = DB::getInstance(); $s = cBootstrap::getInstance(); $sql = "SELECT idplayer\n FROM poker_players\n WHERE idtable = '" . $idtable . "'\n AND iduser = '******'\n AND pactive = 1"; $result = $db->query($sql); if ($result->length() > 0) { return self::getInstance($result->idplayer); } else { return false; } }
/** * get all unread messages for one user * * @return array * @author Elias Müller **/ public static function getUnread() { $s = cBootstrap::getInstance(); $db = new DB(); $messages = array(); $sql = "SELECT m.idmessage\n\t\t\t\t FROM messages AS m\n\t\t\t\t WHERE m.iduser = "******"\n\t\t\t\t AND m.read = 0\n\t\t\t\t AND m.recvr = 'user'\n\t\t\t ORDER BY m.idmessage DESC"; $result = $db->query($sql); if ($result->length() > 0) { do { $messages[$result->idmessage] = Message::getInstance($result->idmessage); } while ($result->next()); } return $messages; }
/** * get the singleton object of this class or create new * * @param string $config path to the config file * @return cBootstrap reference to the bootstrap object */ public static function getInstance($config = '') { if (!is_object(self::$object)) { self::$object = new cBootstrap($config); } return self::$object; }
protected function __construct() { $this->s = cBootstrap::getInstance(); session_start(); }
/** * save the object information */ public function save() { $db = DB::getInstance(); $s = cBootstrap::getInstance(); if ($this->id === false) { $sql = "INSERT INTO poker_spots\n SET title = '" . $this->info['title'] . "',\n iduser = '******',\n button = '" . $this->info['button'] . "',\n p1_stack = '" . $this->info['stacks'][0] . "',\n p2_stack = '" . $this->info['stacks'][1] . "',\n p1_range = '" . serialize($this->info['ranges'][0]) . "',\n p2_range = '" . serialize($this->info['ranges'][1]) . "'"; } else { $sql = "UPDATE poker_spots\n SET title = '" . $this->info['title'] . "',\n button = '" . $this->info['button'] . "',\n p1_stack = '" . $this->info['stacks'][0] . "',\n p2_stack = '" . $this->info['stacks'][1] . "',\n p1_range = '" . serialize($this->info['ranges'][0]) . "',\n p2_range = '" . serialize($this->info['ranges'][1]) . "'\n WHERE idspot = " . $this->id; } $id = $db->query($sql); if ($id != 0) { if ($this->id === false) { $this->id = $id; self::$objects[$id] = $this; } return true; } return false; }
<?php /** * the centerpoint of every action on chispa-sites. * This script loads the config file, calls the bootstrap and initiates the controller action. * * @author: Elias Müller * @version: 0.2 * @since: chispa 0.1 * @package: core */ // path to the configuration file $config = dirname(__FILE__) . '/config.inc.php'; // load bootstrap object to handle the request require_once "classes/c_bootstrap.class.php"; $loader = cBootstrap::getInstance($config); // load the controller-object for this site and execute requested action $site = $loader->loadController();