public function send() { if (Config::db('profiling')) { $profile = View::create('profile', array('profile' => DB::profile()))->render(); $this->output = preg_replace('#</body>#', $profile . '</body>', $this->output); } return parent::send(); }
function __construct() { $config = Config::db(); $this->host = $config['host']; $this->database = $config['database']; $this->username = $config['username']; $this->password = $config['password']; }
public static function getDb() { if (self::$db == null) { $dbName = PREFIX; $mongo = new Mongo(); self::$db = $mongo->{$dbName}; } return self::$db; }
public static function table($name = null) { if (is_null(static::$prefix)) { static::$prefix = Config::db('prefix', ''); } if (!is_null($name)) { return static::$prefix . $name; } return static::$prefix . static::$table; }
/** Returns the memoized database connection or creates a new one.. */ public static function getDB() { if (self::$db === null) { $config = self::$config['database']; $db = new mysqli($config['server'], $config['user'], $config['pass'], $config['db']); $db->set_charset('utf8'); self::$db = $db; } return self::$db; }
public function actionIndex() { if (Yii::app()->user->isGuest) { $this->redirect(Yii::app()->homeUrl); } $this->pageTitle = Yii::t('title', 'Character list'); $criteria = new CDbCriteria(); $criteria->select = 'name, account_id, account_name, exp, race, player_class, creation_date'; $criteria->join = 'INNER JOIN ' . Config::db('db') . '.log_referals ON (log_referals.slave_id = t.account_id AND log_referals.master_id = "' . Yii::app()->user->id . '" AND status = "unpaid")'; $referals = Players::model()->findAll($criteria); $form = new LogReferals(); if (isset($_POST['LogReferals'])) { $form->attributes = $_POST['LogReferals']; $check_isset = LogReferals::model()->count('master_id = ' . Yii::app()->user->id . ' AND slave_id = ' . $form->slave_id . ' AND status = "unpaid"'); if ($check_isset != 1) { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('pers', 'You have no referrаls.') . '</div>'); $this->refresh(); } $master = AccountData::model()->find('id = ' . Yii::app()->user->id); $check_ip = AccountData::model()->count('id = ' . $form->slave_id . ' AND last_ip = "' . $master->last_ip . '"'); if ($check_ip != 0) { $log = LogReferals::model()->find('master_id = ' . Yii::app()->user->id . ' AND slave_id = ' . $form->slave_id . ' AND status = "unpaid"'); $log->status = 'blocked'; $log->update(false); Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('pers', 'You have no referrаls.') . '</div>'); $this->refresh(); } $criteria = new CDbCriteria(); $criteria->select = 'exp'; $criteria->condition = 'account_id = ' . $form->slave_id; $criteria->order = 'exp DESC'; $criteria->limit = 1; $check_lvl = Players::model()->find($criteria); if (Info::lvl($check_lvl->exp) < Config::get('referal_level')) { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('pers', 'Less than the minimum level.') . '</div>'); $this->refresh(); } $criteria = new CDbCriteria(); $criteria->condition = 'id = ' . Yii::app()->user->id; $money = AccountData::model()->find($criteria); $money[Yii::app()->params->money] = $money[Yii::app()->params->money] + Config::get('referal_bonus'); $money->save(); $criteria = new CDbCriteria(); $criteria->condition = 'id = ' . $form->slave_id; $money = AccountData::model()->find($criteria); $money[Yii::app()->params->money] = $money[Yii::app()->params->money] + Config::get('referal_bonus_ref'); $money->save(); $log = LogReferals::model()->find('master_id = ' . Yii::app()->user->id . ' AND slave_id = ' . $form->slave_id . ' AND status = "unpaid"'); $log->status = 'complete'; $log->update(false); Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('pers', 'Bonus credit applied!') . '</div>'); $this->refresh(); } $this->render('/pers', array('model' => Players::getPlayers(), 'referals' => $referals)); }
/** * Returns an array of ids for posts that have the specified tag * * @param string * @return array */ function get_posts_with_tag($tag) { $tag_ext = Extend::where('key', '=', 'post_tags')->get(); $tag_id = $tag_ext[0]->id; $prefix = Config::db('prefix', ''); $posts = array(); foreach (Query::table($prefix . 'post_meta')->where('extend', '=', $tag_id)->where('data', 'LIKE', '%' . $tag . '%')->get() as $meta) { $posts[] = $meta->post; } return array_unique($posts); }
public function has_table($table) { $default = Config::db('default'); $db = Config::db('connections.' . $default . '.database'); $sql = 'SHOW TABLES FROM `' . $db . '`'; list($result, $statement) = DB::ask($sql); $statement->setFetchMode(PDO::FETCH_NUM); $tables = array(); foreach ($statement->fetchAll() as $row) { $tables[] = $row[0]; } return in_array($table, $tables); }
public function run() { if (Yii::app()->getController()->id == 'news' && Yii::app()->getController()->action->id == 'index') { $criteria = new CDbCriteria(); $criteria->select = 'name, exp, gender, race, player_class, online'; $criteria->condition = 'exp > 100'; $criteria->order = 'weekly_kill DESC, all_kill DESC, ap DESC, gp DESC'; $criteria->join = 'INNER JOIN ' . Config::db('ls') . '.account_data ON (account_data.id=t.account_id AND account_data.access_level < ' . Config::get('hide_top') . ')'; $criteria->limit = 10; $model = Players::model()->with('abyssRank')->findAll($criteria); $this->render('widgetPvp', array('model' => $model)); } }
public function actionOnline() { $this->pageTitle = Yii::t('title', 'Players online'); $criteria = new CDbCriteria(); $criteria->select = 'name, account_id, exp, gender, race, player_class, world_id, show_location'; $criteria->condition = 'online = 1'; $criteria->order = 'exp DESC, ap DESC'; $criteria->join = 'INNER JOIN ' . Config::db('ls') . '.account_data ON (account_data.id=t.account_id AND account_data.access_level < ' . Config::get('hide_top') . ')'; $pages = new CPagination(Players::model()->count($criteria)); $pages->pageSize = Config::get('page_top'); $pages->applyLimit($criteria); $model = Players::model()->with('abyssRank')->findAll($criteria); $this->render('online', array('model' => $model, 'pages' => $pages)); }
public function run() { // Binder do banco $this->db = new Database(); global $db; $db = $this->db; $this->dbo = new DatabaseOld(); global $dbo; $dbo = $this->dbo; // Binder dos configs $this->config = (object) array('db' => Config::db(), 'email' => Config::email()); // Binder do request Request::build(); // Binder do router $this->router = new Router(); }
static function addToIndex($id) { $indexThese = array('title', 'creator', 'subject', 'publisher', 'contributor', 'identifier', 's:subtitle', 's:isbn', 's:tag'); $prefix = Config::db('prefix', ''); $title = Input::get('title'); $input = Input::get('extend.metadata_wtf'); $metadata = self::parse_wtf($input); if (empty($metadata['.']['title'])) { $metadata['.']['title'][] = $title; } $query = Query::table($prefix . 'wtfsearch')->where('post_id', '=', $id); $query->delete(); foreach ($metadata['.'] as $k => $vals) { if (in_array($k, $indexThese)) { foreach ($vals as $val) { $query->insert(array('post_id' => $id, 'meta_key' => $k, 'meta_value' => normalize($val))); } } } //var_dump($prefix, $metadata, $id); //die; }
/** * Returns an array of unique tags that exist on post given post, * empty array if no tags are found. * * @return array */ function get_tags_for_post($post_id) { $tag_ext = Extend::where('key', '=', 'post_tags')->where('type', '=', 'post')->get(); $tag_id = $tag_ext[0]->id; $prefix = Config::db('prefix', ''); $tags = array(); $index = 0; $meta = Query::table($prefix . 'post_meta')->left_join('posts', 'posts.id', '=', 'post_meta.post')->where('posts.status', '=', 'published')->where('extend', '=', $tag_id)->where('post', '=', $post_id)->get(); $post_meta = json_decode($meta[0]->data); if (!trim($post_meta->text) == "") { foreach (explode(",", $post_meta->text) as $tag_text) { $tags[$index] = trim($tag_text); $index += 1; } } return array_unique($tags); }
<?php use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule(); $capsule->addConnection(\Config::db()); $capsule->setAsGlobal(); $capsule->bootEloquent();
public function tableName() { return Config::db('db') . '.news'; }
public function tableInfo($str, $column) { $query = "select * from information_schema.columns \nwhere table = '" . Config::db()->dbname . "' TABLE_NAME = '" . $str . "' \nAND COLUMN_NAME = '" . $column . "_id'"; $table = $this->query($query); return count($table) > 0; }
public function tableName() { return Config::db('gs') . '.abyss_rank'; }
public function tableName() { return Config::db('gs') . '.droplist'; }
private static function makePrimary() { $envdb = getenv('DATABASE_URL'); $dbopts = parse_url($envdb); $connstr = $envdb ? 'pgsql:dbname=' . ltrim($dbopts['path'], '/') . ';host=' . $dbopts['host'] : Config::db('connstr'); $user = $envdb ? $dbopts['user'] : Config::db('user'); $pass = $envdb ? $dbopts['pass'] : Config::db('pass'); $db = new PDO($connstr, $user, $pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); static::add('primary', $db); }
public function tableName() { return Config::db('gs') . '.siege_locations'; }
public function tableName() { return Config::db('db') . '.log_referals'; }
public function tableName() { return Config::db('gs') . '.broker'; }
public function tableName() { return Config::db('gs') . '.player_quests'; }
public function tableName() { return Config::db('gs') . '.legions'; }
public function tableName() { return Config::db('ls') . '.account_data'; }
public function actionSettings() { if (Yii::app()->user->isGuest) { $this->redirect(Yii::app()->homeUrl); } $this->pageTitle = Yii::t('title', 'Account settings'); $model = AccountData::model()->findByPk(Yii::app()->user->id); $model->scenario = 'edit'; $form2 = Players::model()->findAll('account_id = ' . Yii::app()->user->id); if (isset($_POST['AccountData'])) { $model->attributes = $_POST['AccountData']; if ($this->hashPassword($model->current_password) == $model->password) { if (!empty($model->new_password)) { $model->password = $this->hashPassword($model->new_password); } if ($model->save()) { Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Settings modified!') . '</div>'); $this->refresh(); } } else { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('account', 'Incorrect password!') . '</div>'); $this->refresh(); } } if (isset($_POST['Players'])) { $clear = Yii::app()->db->createCommand('UPDATE ' . Config::db('gs') . '.players SET show_location = 0, show_inventory = 0 WHERE account_id = ' . Yii::app()->user->id); $clear->execute(); if (isset($_POST['Players']['show_location'])) { $command = Yii::app()->db->createCommand('UPDATE ' . Config::db('gs') . '.players SET show_location = 1 WHERE id=:id'); foreach ($_POST['Players']['show_location'] as $key => $value) { $command->execute(array(':id' => $key)); } } if (isset($_POST['Players']['show_inventory'])) { $command = Yii::app()->db->createCommand('UPDATE ' . Config::db('gs') . '.players SET show_inventory = 1 WHERE id=:id'); foreach ($_POST['Players']['show_inventory'] as $key => $value) { $command->execute(array(':id' => $key)); } } Yii::app()->user->setFlash('message2', '<div class="flash_success">' . Yii::t('main', 'Settings modified!') . '</div>'); $this->refresh(); } $this->render('settings', array('form' => $model, 'form2' => $form2)); }