public function getPlayers() { $criteria = new CDbCriteria(); $criteria->select = 'id, name, exp, race, player_class, creation_date'; $criteria->condition = 'account_id = ' . Yii::app()->user->id; return Players::model()->findAll($criteria); }
public function actionIndex() { if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) { $this->redirect(Yii::app()->homeUrl); } $this->pageTitle = Yii::t('title', 'Send mail'); $model = new Mail(); if (isset($_POST['Mail'])) { $model->attributes = $_POST['Mail']; $player_id = Players::model()->find('name = "' . $model->player_name . '"'); if ($player_id->online == 1) { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Error - You must first log out of the game server.') . '</div>'); } $criteria = new CDbCriteria(); $criteria->select = 'MAX(mail_unique_id) as mail_unique_id'; $last_mail_id = Mail::model()->find($criteria); $model->mail_unique_id = $last_mail_id->mail_unique_id + 1; $model->mail_recipient_id = $player_id->id; $model->sender_name = 'ServerWebsite'; $model->mail_title = $model->mail_title; $model->mail_message = $model->mail_message . "\n\nThis has been sent via our server website. Please, do not reply."; $model->unread = 1; // Fallenfate - Add function to send kinah to players. if ($model->item_count != NULL || $model->item_count != "") { $model->attached_item_id = 0; $model->attached_kinah_count = $model->item_count; } $model->express = 1; if ($model->save(false)) { Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Mail sent!') . '</div>'); $this->refresh(); } } $this->render('/admin/mail', array('model' => $model)); }
public function actionIndex() { if (Yii::app()->user->isGuest) { $this->redirect(Yii::app()->homeUrl); } $this->pageTitle = Yii::t('title', 'Userbar creation'); $image = null; $model = new UserbarForm(); if (isset($_POST['UserbarForm'])) { $model->attributes = $_POST['UserbarForm']; if ($model->validate()) { $criteria = new CDbCriteria(); $criteria->select = 'id, name, exp, gender, race, player_class'; $player = Players::model()->with('abyssRank', 'lifeStats')->findByPK($model->player_id); $criteria = new CDbCriteria(); $criteria->select = 'name'; $legion = Legions::model()->with(array('legionMembers' => array('joinType' => 'INNER JOIN', 'condition' => 'player_id = ' . $model->player_id)))->find(); if ($legion == NULL) { $legion->name = null; } Yii::app()->ih->load($_SERVER['DOCUMENT_ROOT'] . Yii::app()->baseUrl . '/images/userbars/ub' . $model->fon . '.png')->text($player->name, Yii::app()->basePath . '/fonts/romic.ttf', 14, $this->rgb($model->shadow), CImageHandler::CORNER_LEFT_TOP, 8, 8)->text($player->name, Yii::app()->basePath . '/fonts/romic.ttf', 14, $this->rgb($model->name), CImageHandler::CORNER_LEFT_TOP, 8, 7)->text($legion->name, Yii::app()->basePath . '/fonts/monaco.ttf', 10, $this->rgb($model->shadow), CImageHandler::CORNER_LEFT_TOP, 8, 36)->text($legion->name, Yii::app()->basePath . '/fonts/monaco.ttf', 10, $this->rgb($model->legion), CImageHandler::CORNER_LEFT_TOP, 8, 35)->text(Info::class_text($player->player_class) . ', ' . $this->genderRace($player->gender, $player->race), Yii::app()->basePath . '/fonts/verdana.ttf', 8, $this->rgb($model->shadow), CImageHandler::CORNER_LEFT_BOTTOM, 8, 9)->text(Info::class_text($player->player_class) . ', ' . $this->genderRace($player->gender, $player->race), Yii::app()->basePath . '/fonts/verdana.ttf', 8, $this->rgb($model->class_race), CImageHandler::CORNER_LEFT_BOTTOM, 8, 10)->text(Info::lvl($player->exp) . ' Level', Yii::app()->basePath . '/fonts/romic.ttf', 14, $this->rgb($model->shadow), CImageHandler::CORNER_RIGHT_TOP, 8, 6)->text(Info::lvl($player->exp) . ' Level', Yii::app()->basePath . '/fonts/romic.ttf', 14, $this->rgb($model->level), CImageHandler::CORNER_RIGHT_TOP, 8, 5)->text($player->abyssRank->all_kill . '/' . $player->abyssRank->weekly_kill . ' Kills', Yii::app()->basePath . '/fonts/monaco.ttf', 10, $this->rgb($model->shadow), CImageHandler::CORNER_RIGHT_TOP, 8, 34)->text($player->abyssRank->all_kill . '/' . $player->abyssRank->weekly_kill . ' Kills', Yii::app()->basePath . '/fonts/monaco.ttf', 10, $this->rgb($model->kills), CImageHandler::CORNER_RIGHT_TOP, 8, 33)->text($player->lifeStats->hp . ' HP, ' . $player->lifeStats->mp . ' MP', Yii::app()->basePath . '/fonts/verdana.ttf', 8, $this->rgb($model->shadow), CImageHandler::CORNER_RIGHT_BOTTOM, 8, 9)->text($player->lifeStats->hp . ' HP, ' . $player->lifeStats->mp . ' MP', Yii::app()->basePath . '/fonts/verdana.ttf', 8, $this->rgb($model->stats), CImageHandler::CORNER_RIGHT_BOTTOM, 8, 10)->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->baseUrl . '/userbars/' . $model->player_id . '.png'); $image = Yii::app()->homeUrl . 'userbars/' . $model->player_id . '.png'; } } $this->render('/userbar', array('model' => $model, 'players' => Players::getPlayers(), 'image' => $image)); }
public function actionView($id) { $model = Players::model(); $player = $model->findByPk($id); $count = $model->count('last_seen > ' . (time() - 60 * 60 * 24 * 7)); // Вывод всего на вьюху $this->render('view', array('model' => $player, 'count' => $count)); }
/** * Главная страница сайта */ public function actionIndex() { // Вытаскиваем 10 последних банов $dependecy = new CDbCacheDependency('SELECT MAX(`bid`) FROM {{bans}}'); $bans = new CActiveDataProvider(Bans::model()->cache(300, $dependecy), array('criteria' => array('condition' => Yii::app()->config->auto_prune ? 'expired = 0' : null, 'order' => 'bid DESC', 'limit' => 10), 'pagination' => false)); // Вытаскиваем 10 лучших игроков $dependecy = new CDbCacheDependency('SELECT MAX(`id`) FROM `bio_players`'); $players = new CActiveDataProvider(Players::model()->cache(300, $dependecy), array('criteria' => array('select' => '`id`, `nick`, ' . Players::sql_skill_formula() . ' AS `skill`', 'order' => '`skill` DESC, `id` ASC', 'condition' => 'last_seen > ' . (time() - 60 * 60 * 24 * 7), 'limit' => 10), 'pagination' => false)); $this->render('index', array('bans' => $bans, 'players' => $players, 'servers' => Serverinfo::model()->findAll())); }
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)); }
public static function playersJSON() { $players = Players::model()->findAll(); $_players = array(); foreach ($players as $player) { $tmp = array(); $tmp['name'] = $player->getFullName(true); $tmp['nickname'] = $player->nickname; $tmp['female'] = $player->female; $_players[] = $tmp; } return CJSON::encode($_players); }
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 actionCategory($name) { if (Yii::app()->user->isGuest) { $this->redirect(Yii::app()->homeUrl); } $id = WebshopCategory::model()->find('alt_name = "' . $name . '"'); $this->pageTitle = Yii::t('title', 'Webshop') . ': ' . $id->name; $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'category_id = ' . $id->category_id; $pages = new CPagination(Webshop::model()->count($criteria)); $pages->pageSize = Config::get('page_shop'); $pages->applyLimit($criteria); $model = Webshop::model()->findAll($criteria); $form = new Inventory(); $form->scenario = 'buy'; if (isset($_POST['Inventory'])) { $form->attributes = $_POST['Inventory']; if ($form->validate()) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'item_id = ' . $form->item_id; $item = Webshop::model()->find($criteria); $real_price = ceil($form->new_amount * ($item->price / $item->amount)); $account = AccountData::model()->findByPk(Yii::app()->user->id); if ($account[Yii::app()->params->money] < $real_price) { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Insufficient funds.') . '</div>'); $this->refresh(); } $criteria = new CDbCriteria(); $criteria->condition = 'id = ' . $form->item_owner . ' AND online = 1'; $online = Players::model()->count($criteria); if ($online == 1) { Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Log-out') . '</div>'); $this->refresh(); } $criteria = new CDbCriteria(); $criteria->select = 'MAX(mail_unique_id) as mail_unique_id'; $last_mail_id = Mail::model()->find($criteria); $mail = new Mail(); $mail->mail_unique_id = $last_mail_id->mail_unique_id + 1; $mail->mail_recipient_id = $form->item_owner; $mail->sender_name = 'Admin'; $mail->mail_title = Yii::t('webshop', 'Delivery'); $mail->mail_message = Yii::t('webshop', 'Your purchase has been successful. Thank you, and we hope you enjoy the game!'); $mail->unread = 1; if ($form->item_id == 182400001) { $mail->attached_item_id = 0; $mail->attached_kinah_count = $form->new_amount; } else { $mail->attached_item_id = $this->add_item($form->item_id, $form->item_owner, $form->new_amount); $mail->attached_kinah_count = 0; } $mail->express = 1; $mail->save(false); $account[Yii::app()->params->money] = $account[Yii::app()->params->money] - $real_price; $account->save(false); $log = new LogWebshop(); $log->player_id = $form->item_owner; $log->item = $form->item_id; $log->amount = $form->new_amount; $log->price = $real_price; $log->save(false); Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('webshop', 'Purchase successful!') . '</div>'); $this->refresh(); } } $this->render('category', array('model' => $model, 'id' => $id, 'form' => $form, 'players' => Players::getPlayers(), 'pages' => $pages)); }
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)); }
function level($level) { $criteria = new CDbCriteria(); if ($level == 10) { $criteria->condition = 'exp <= 307558'; } elseif ($level == 20) { $criteria->condition = 'exp > 307558 AND exp <= 4820229'; } elseif ($level == 30) { $criteria->condition = 'exp > 4820229 AND exp <= 35939440'; } elseif ($level == 35) { $criteria->condition = 'exp > 35939440 AND exp <= 89321807'; } elseif ($level == 40) { $criteria->condition = 'exp > 89321807 AND exp <= 243343723'; } elseif ($level == 45) { $criteria->condition = 'exp > 243343723 AND exp <= 559280864'; } elseif ($level == 50) { $criteria->condition = 'exp > 559280864 AND exp <= 1128723910'; } elseif ($level == 55) { $criteria->condition = 'exp > 1128723910 AND exp <= 1698166956'; } elseif ($level == 60) { $criteria->condition = 'exp > 1698166956 AND exp <= 2826890866'; } elseif ($level == 65) { $criteria->condition = 'exp > 2826890866'; } else { return 0; } return Players::model()->count($criteria); }