Пример #1
0
 public function view($id = '')
 {
     $cards = new Cards($this->db);
     if (!$cards->count(array('filename=?', $id))) {
         $this->f3->error(404);
     } else {
         $this->f3->set('info', $cards->getByFilename($id));
         $this->f3->set('content', 'app/views/cards-view.htm');
         echo Template::instance()->render('app/templates/default.htm');
     }
 }
Пример #2
0
 public function edit($id = '')
 {
     /***********************************
     		Edit form
     		************************************/
     $this->f3->scrub($_POST);
     $members = new Members($this->db);
     $this->f3->set('member', $members->read(array('id=?', $id), [])[0]);
     $this->f3->set('SESSION.flash', array());
     $this->f3->set('status', array('Active', 'Hiatus'));
     $cards = new Cards($this->db);
     $this->f3->set('decks', $cards->allAlpha());
     $this->f3->set('months', array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
     // form submitted
     if ($this->f3->exists('POST.edit')) {
         $audit = \Audit::instance();
         // validate form
         if (!preg_match("/^[\\w\\-]{2,30}\$/", $this->f3->get('POST.name'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name. Only letters, numbers, underscores (_), and dashes (-) are allowed.'));
         }
         if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
         }
         if (!$audit->url($this->f3->get('POST.url'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid trade post URL.'));
         }
         if (!in_array($this->f3->get('POST.birthday'), $this->f3->get('months'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid birthday'));
         }
         if ($cards->count(array('id=?', $this->f3->get('POST.collecting'))) == 0) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid collecting deck.'));
         }
         if ($this->f3->get('member')->status !== 'Pending' && !in_array($this->f3->get('POST.status'), $this->f3->get('status'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid status.'));
         }
         // if there are no errors, process the form
         if (count($this->f3->get('SESSION.flash')) === 0) {
             $this->f3->set('collectingID', $this->f3->get('POST.collecting'));
             $this->f3->set('POST.collecting', $cards->getById($this->f3->get('POST.collecting'))->filename);
             if ($members->edit($this->f3->get('POST.id'))) {
                 $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Member ' . $this->f3->get('POST.name') . ' edited!'));
                 $this->f3->reroute('/mytcg/members');
             } else {
                 $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again!'));
             }
         }
     }
     $this->f3->set('content', 'app/views/mytcg/members_edit.htm');
     echo Template::instance()->render('app/templates/admin.htm');
 }
Пример #3
0
 public function delete($id = '')
 {
     /***********************************
     		Delete form
     		************************************/
     $cards = new Cards($this->db);
     $this->f3->set('deck', $cards->read(array('id=?', $id), [])[0]);
     $this->f3->set('SESSION.flash', array());
     if ($_SERVER['QUERY_STRING'] == "execute") {
         $cards->delete($this->f3->get('deck')->id);
         $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => $this->f3->get('deck')->filename . ' deck deleted!'));
         $this->f3->reroute('/mytcg/cards');
     }
     $this->f3->set('content', 'app/views/mytcg/cards_delete.htm');
     echo Template::instance()->render('app/templates/admin.htm');
 }
Пример #4
0
 function success()
 {
     Cards::Success();
     $tree['seo_title'] = 'Покупка подарочной карты';
     Funcs::setMeta($tree);
     View::render('cards/fail', $tree);
 }
Пример #5
0
 public function testGetCardByAttack()
 {
     $type = "Minion";
     $parameters = ['attack' => 11, 'health' => 11];
     $card = \Cards::type($type, $parameters);
     $this->assertEquals(1, count($card));
     $this->assertEquals("Thaddius", $card[0]["name"]);
 }
 public function deletecardAction()
 {
     $this->view->disable();
     $id = $this->request->getPost('id');
     $cards = Cards::findFirst("id = '" . $id . "'");
     if ($cards->delete() == false) {
         echo false;
     } else {
         echo true;
     }
 }
Пример #7
0
 public function get_troops_with_infos()
 {
     // récupération des informations dans la base
     $units = $this->get_troops();
     $modifiers = Cards::get_static_modifiers($this->user_id);
     $infos = self::get_unit_infos();
     foreach ($infos as $unit_id => $info) {
         if ($this->combat_id == -1 || !is_null($units[$unit_id]['troop_id'])) {
             $troop = new Troop($units[$unit_id]['troop_id']);
             $this->troops[$unit_id] = $troop;
             $troop->hydrate(['name' => $info['name'], 'description' => $info['description'], 'price' => $info['price'] * $modifiers['price'], 'building_time' => $info['building_time'] * $modifiers['building'], 'damage' => $info['damage'] * $modifiers['damage'], 'life' => $info['life'] * $modifiers['life'], 'image_name' => $info['image_name']]);
             $this->total_units += $troop->quantity;
             $this->total_damage += $troop->damage * $troop->quantity;
             $this->total_life += $troop->life * $troop->quantity;
         }
     }
     return $this->troops;
 }
Пример #8
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Cards the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Cards::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #9
0
 public static function getCardbyCardID($idCart)
 {
     $model = Cards::model()->findByPk($idCart);
     return $model;
 }
Пример #10
0
 private function doubles()
 {
     /***********************************
     		Process Doubles Exchange! 
     		************************************/
     $this->f3->scrub($_POST);
     $members = new Members($this->db);
     $cards = new Cards($this->db);
     $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]);
     $this->f3->set('SESSION.flash', array());
     // validate form
     if ($this->f3->get('POST.type') != 'Regular' && $this->f3->get('POST.type') != 'Special') {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid type.'));
     }
     if (intval($this->f3->get('POST.number')) > 20 || intval($this->f3->get('POST.number')) < 1) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Limit 20 cards per exchange. Please submit the form again if you need more!'));
     }
     // if there are no errors, process the form
     if (count($this->f3->get('SESSION.flash')) === 0) {
         $mailer = new Mailer();
         $message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': ' . $this->f3->get('member')->name . ' Doubles Exchange')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('member')->email))->setBody(Template::instance()->render('app/templates/emails/doubles-notif.htm'), 'text/html');
         if ($mailer->send($message)) {
             $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]);
             $this->f3->set('rewardType', 'Doubles Exchange');
             // Generate rewards!
             $this->f3->set('rewards', array());
             // random regular cards
             if ($this->f3->get('POST.type') == 'Regular') {
                 for ($i = 0; $i < $this->f3->get('POST.number'); $i++) {
                     $this->f3->push('rewards', $cards->random(array('worth=?', 1)));
                 }
             }
             // random special cards
             if ($this->f3->get('POST.type') == 'Special') {
                 for ($i = 0; $i < $this->f3->get('POST.number'); $i++) {
                     $this->f3->push('rewards', $cards->random(array('worth=?', 2)));
                 }
             }
             $log = '[' . date("D, d M Y H:i:s") . '] <strong>Doubles Exchange</strong>: ' . implode(', ', $this->f3->get('rewards'));
             $logger = new Logger();
             $logger->push($this->f3->get('SESSION.userID'), $log);
         } else {
             $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
         }
     }
 }
Пример #11
0
 public function actionGetboard()
 {
     $session = Yii::app()->session;
     $boards = array();
     if (isset($session['token'])) {
         $token = $session['token'];
         $client = new Trello\Client();
         $client->authenticate('658f0e49767a334eb04b65d1c43167b4', $token, Client::AUTH_URL_CLIENT_ID);
         $boardID = "";
         $listID = "";
         $boards = $client->api('member')->boards()->all("me", array());
         foreach ($boards as $board) {
             // Insert board to DB
             $boardID = $board['id'];
             $board_name = $board['name'];
             $user_id = "658f0e49767a334eb04b65d1c43167b4";
             Boards::insertBoard($boardID, $board_name, $user_id);
             $lists = $client->api('boards')->lists()->all("{$boardID}", array());
             foreach ($lists as $list) {
                 // Insert list to DB
                 $listID = $list['id'];
                 $name = $list['name'];
                 Lists::insertList($listID, $name, $boardID);
                 $cards = $client->api('lists')->cards()->all("{$listID}", array());
                 foreach ($cards as $card) {
                     // Insert card to DB
                     $card_id = $card['id'];
                     $card_name = $card['name'];
                     $card_des = $card['desc'];
                     $card_due = $card['due'];
                     Cards::insertCard($card_id, $card_name, $card_des, $card_due, $listID);
                 }
             }
         }
         // // Get list boards
         // $boards = $client->api('member')->boards()->all("me", array());
     }
     return $this->render("getboard", array('boards' => $boards));
 }
    } elseif ($hStraight) {
        $best_hand['rank'] = R_STRAIGHT;
    } elseif ($hThreeKind) {
        $best_hand['rank'] = R_THREE_KIND;
    } elseif ($hTwoPair) {
        $best_hand['rank'] = R_TWO_PAIR;
    } elseif ($hPair) {
        $best_hand['rank'] = R_PAIR;
    } else {
        $best_hand['rank'] = R_HIGH_CARD;
    }
    return $best_hand;
}
require_once "poker_cards.php";
echo "<h3><u>Some Random Testing</u></h3><table>";
$pcards = new Cards();
for ($i = 0; $i < 20; $i++) {
    $pcards->Deal();
    unset($ph);
    unset($ch);
    $ph[] = $pcards->pickCard();
    $ph[] = $pcards->pickCard();
    $ch[] = $pcards->pickCard();
    $ch[] = $pcards->pickCard();
    $ch[] = $pcards->pickCard();
    $ch[] = $pcards->pickCard();
    $ch[] = $pcards->pickCard();
    echo "<tr><td><p><b>Select best from following.</b><br>";
    display_hand($ph);
    display_hand($ch);
    echo "</p></td>";
Пример #13
0
/* @var $this CardsController */
/* @var $model Cards */
Booster::getBooster()->registerPackage('datepicker');
$cs = Yii::app()->clientScript;
$cs->registerScript(__CLASS__ . __LINE__, 'jQuery("#Cards_created_at").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#Cards_created_at").on("changeDate", function(ev){
    jQuery(this).datepicker("hide");
});', CClientScript::POS_READY);
$cs->registerScript(__CLASS__ . __LINE__, 'jQuery("#Cards_expired_at").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#Cards_expired_at").on("changeDate", function(ev){
    jQuery(this).datepicker("hide");
});', CClientScript::POS_READY);
?>

<h1><?php 
echo Yii::t('app', 'Manage cards');
?>
</h1>

<hr>
<?php 
$this->widget('booster.widgets.TbButtonGroup', array('buttons' => array(array('label' => Yii::t('app', 'Create card'), 'buttonType' => 'link', 'url' => array('create'), 'icon' => 'plus', 'context' => 'success', 'htmlOptions' => array('title' => Yii::t('app', 'Create card'))))));
echo '<hr>';
$this->widget('booster.widgets.TbGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'type' => 'striped bordered', 'template' => "{items}\n{pager}", 'enablePagination' => true, 'afterAjaxUpdate' => 'function(){
jQuery("#Cards_created_at").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#Cards_created_at").on("changeDate", function(ev){
        jQuery(this).datepicker("hide");
    });
jQuery("#Cards_expired_at").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#Cards_expired_at").on("changeDate", function(ev){
    jQuery(this).datepicker("hide");
});    
}', 'pager' => array('class' => 'booster.widgets.TbPager'), 'columns' => array('series' => array('name' => 'series', 'filter' => Cards::getSeriesList(), 'type' => 'raw', 'value' => 'Cards::getSeriesList($data->series)', 'htmlOptions' => array('data-title' => Yii::t('app', 'Series'))), 'number' => array('name' => 'number', 'htmlOptions' => array('data-title' => Yii::t('app', 'Number'))), 'created_at' => array('name' => 'created_at', 'value' => 'date("d.m.Y H:i:s", strtotime($data->created_at))', 'htmlOptions' => array('data-title' => Yii::t('app', 'Issue date'))), 'expired_at' => array('name' => 'expired_at', 'value' => 'date("d.m.Y H:i:s", $data->expired_at)', 'htmlOptions' => array('data-title' => Yii::t('app', 'Expiration date'))), 'status' => array('name' => 'status', 'filter' => Cards::getStatusList(), 'value' => '$data->cardStatus', 'type' => 'raw', 'htmlOptions' => array('data-title' => Yii::t('app', 'Status'))), array('class' => 'booster.widgets.TbToggleColumn', 'toggleAction' => 'update', 'filter' => false, 'name' => 'status', 'value' => '$data->status==1', 'uncheckedIcon' => 'ok-circle', 'uncheckedButtonLabel' => Yii::t('app', 'Activation'), 'checkedIcon' => 'ban-circle', 'checkedButtonLabel' => Yii::t('app', 'Deactivation'), 'header' => Yii::t('app', 'Change status'), 'htmlOptions' => array('data-title' => Yii::t('app', 'Change status'), 'style' => 'text-align:center;')), array('class' => 'booster.widgets.TbButtonColumn', 'updateButtonOptions' => array('style' => 'display:none'), 'viewButtonIcon' => 'time', 'viewButtonOptions' => array('title' => Yii::t('app', 'View history')), 'htmlOptions' => array('data-title' => Yii::t('app', 'Action'))))));
Пример #14
0
Booster::getBooster()->registerPackage('datepicker');
$cs = Yii::app()->clientScript;
$cs->registerScript(__CLASS__ . __LINE__, 'jQuery("#CardsHistory_action_date").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#CardsHistory_action_date").on("changeDate", function(ev){
    jQuery(this).datepicker("hide");
});', CClientScript::POS_READY);
?>

<h1><?php 
echo Yii::t('app', 'History of the card #') . CHtml::encode($model->number);
?>
</h1>
<div class="row">
    <div class="col-sm-6">
        <?php 
$this->widget('booster.widgets.TbDetailView', array('data' => $model, 'type' => array('striped', 'bordered'), 'attributes' => array(array('name' => 'series', 'type' => 'raw', 'value' => function ($data) {
    return Cards::getSeriesList($data->series);
}), 'number', array('name' => 'created_at', 'type' => 'raw', 'value' => function ($data) {
    return date("d.m.Y H:i:s", strtotime($data->created_at));
}), array('name' => 'expired_at', 'type' => 'raw', 'value' => function ($data) {
    return date("d.m.Y H:i:s", $data->expired_at);
}), array('name' => 'status', 'type' => 'raw', 'value' => function ($data) {
    return $data->cardStatus;
}))));
?>
    </div>
    <div class="col-sm-6">
        <?php 
$this->widget('booster.widgets.TbGridView', array('id' => 'history-grid', 'dataProvider' => $historyModel->search(), 'filter' => $historyModel, 'afterAjaxUpdate' => 'function(){
jQuery("#CardsHistory_action_date").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#CardsHistory_action_date").on("changeDate", function(ev){
    jQuery(this).datepicker("hide");
});}', 'type' => 'striped bordered', 'template' => "{items}\n{pager}", 'enablePagination' => true, 'pager' => array('class' => 'booster.widgets.TbPager'), 'columns' => array('action_date' => array('name' => 'action_date', 'value' => 'date("d.m.Y H:i:s", strtotime($data->action_date))', 'htmlOptions' => array('data-title' => Yii::t('app', 'Date'))), 'status' => array('name' => 'status', 'filter' => CardsHistory::getStatusList(), 'value' => '$data->cardStatus', 'type' => 'raw', 'htmlOptions' => array('data-title' => Yii::t('app', 'Status'))))));
Пример #15
0
 /**
  * Updates the card and the associated data
  * @param  string $id  The card ID
  * @return JSON
  */
 public function actionUpdateCard($id = NULL)
 {
     header('Content-Type: application/json');
     $card = $this->getBaseCardConfig($id);
     $cardData = CJSON::decode($this->getBaseCardById($id));
     // Determine the runtime directory
     $runtimeDirectory = Yii::getPathOfAlias('application.runtime');
     $downloadPath = $runtimeDirectory . DIRECTORY_SEPARATOR . 'cards' . DIRECTORY_SEPARATOR . $card['folderName'] . '.zip';
     if (!is_writable($runtimeDirectory)) {
         throw new CHttpException(500, Yii::t('Dashboard.main', 'Runtime directory is not writable'));
     }
     $targetFile = fopen($downloadPath, 'w');
     // Initiate the CURL request
     $ch = curl_init($cardData['repository'] . '/archive/master.zip');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_FILE, $targetFile);
     curl_exec($ch);
     // Extract the file
     $zip = new ZipArchive();
     $res = $zip->open($downloadPath);
     // If we can open the file
     if ($res === true) {
         $extractionPath = str_replace('.zip', '', $downloadPath);
         // Extract it to the appropriate location
         $extraction = $zip->extractTo($extractionPath);
         // If we can extract it
         if ($extraction) {
             // Update all the cards
             $cardData = CJSON::decode($this->getBaseCardById($id));
             $cards = Cards::model()->findAllByAttributes(array('name' => $id));
             foreach ($cards as $c) {
                 $currentData = CJSON::decode($c['data']);
                 $activeSize = $currentData['activeSize'];
                 $newData = $cardData;
                 $newData['activeSize'] = $activeSize;
                 $c->data = CJSON::encode($newData);
                 $c->save();
             }
             unlink($downloadPath);
             echo CJSON::encode(array('updated' => true));
             return true;
         }
     }
     echo CJSON::encode(array('updated' => false, 'reason' => $res));
 }
Пример #16
0
 /**
  * 开始游戏
  */
 function start($data)
 {
     $json = $this->json;
     do {
         // 判断是否有在进行中的游戏
         $game = M('zhajinhua')->where("qun_id = '{$this->qun['id']}' AND status in(0) AND update_time>{$this->time}")->find();
         if (!$game) {
             $json['msg_code'] = 10002;
             $json['msg_content'] = '没有进行中的游戏。';
             break;
         }
         if ($this->user['id'] != $game['user_id']) {
             $user = M('qun_user')->find($game['user_id']);
             $json['data']['message'] = "@{$this->user['nickname']} 只有游戏创建者【@{$user['nickname']} 】才能开始游戏。开始请【{$user['nickname']} 】说【开始】. ";
             break;
         }
         $user_list = M('zhajinhua_user')->where(array('zha_id' => $game['id']))->select();
         if (count($user_list) < 2) {
             $json['data']['message'] = "@{$this->user['nickname']} 参与游戏的人数必须要在2-10个人, 没加入的伙伴赶紧说【加入】参与." . count($user_list);
             break;
         }
         // 创建扑克牌
         $card = new Cards();
         $total_credit = 0;
         $card_data = array();
         $game_log = array();
         foreach ($user_list as $user) {
             $card_item = $card->getCard();
             $card_data[] = array('user_id' => $user['user_id'], 'card_data' => $card_item);
             $log = array('type' => 'dichi', 'user_id' => $user['user_id'], 'credit' => 5, 'is_show' => $user['is_show'], 'time' => time(), 'total_jiaopai' => 0);
             array_push($game_log, $log);
             $item = array('card_data' => json_encode($card_item), 'status' => 1, 'credit' => 5, 'credit_log' => json_encode(array($log)), 'update_time' => time());
             $total_credit += 5;
             M('zhajinhua_user')->where(array('id' => $user['id']))->save($item);
         }
         M('zhajinhua')->where(array('id' => $game['id']))->save(array('status' => 1, 'update_time' => time(), 'total_credit' => $total_credit, 'next_user_id' => $user_list[0]['user_id'], 'card_data' => json_encode($card_data), 'total_user' => count($user_list), 'credit_log' => json_encode($game_log)));
         $user = M('qun_user')->find($user_list[0]['user_id']);
         $user_list = M('zhajinhua_user')->where(array('zha_id' => $game['id']))->select();
         $user_str = '';
         foreach ($user_list as $uuser) {
             $user_str .= '【' . $uuser['nickname'] . '】';
         }
         $user_str = $user_str ? '压注顺序:' . $user_str : '';
         $json['data']['message'] = "游戏开始了, 可以开始压注了, {$user_str} 接下来【@{$user['nickname']} 】说话, 可以选择【看牌】【跟牌】【弃牌】【加+金币数】";
         break;
     } while (false);
     return $json;
 }
Пример #17
0
 function addCards($count)
 {
     $cards = new Cards();
     return "<p>Добавлено " . $cards->addItems($count) . " карт</p>";
 }
Пример #18
0
 public function index()
 {
     $cards = new Cards($this->db);
     $members = new Members($this->db);
     $this->f3->set('months', array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
     if ($this->f3->exists('POST.join')) {
         $audit = \Audit::instance();
         $this->f3->scrub($_POST);
         $this->f3->set('SESSION.flash', array());
         // validate form
         if (!preg_match("/^[\\w\\-]{2,30}\$/", $this->f3->get('POST.name'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name. Only letters, numbers, underscores (_), and dashes (-) are allowed.'));
         }
         if ($members->count(array('name=?', $this->f3->get('POST.name'))) != 0) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your name is already taken by another player. Please select a different name and try again!'));
         }
         if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
         }
         if ($members->count(array('email=?', $this->f3->get('POST.email'))) != 0) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your email address is already in use by another player.'));
         }
         if (!$audit->url($this->f3->get('POST.url'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid trade post URL.'));
         }
         if (!preg_match("/^.{6,}\$/", $this->f3->get('POST.password'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your password must contain at least 6 characters.'));
         }
         if ($this->f3->get('POST.password') !== $this->f3->get('POST.password2')) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your passwords don\'t match!'));
         }
         if (!in_array($this->f3->get('POST.birthday'), $this->f3->get('months'))) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid birthday'));
         }
         if ($cards->count(array('id=?', $this->f3->get('POST.collecting'))) == 0) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid collecting deck.'));
         }
         if ($this->f3->get('POST.refer') !== '' && $members->count(array('name=?', $this->f3->get('POST.refer'))) == 0) {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid referral - that player\'s name doesn\'t exist in our database. Please check your spelling and try again!'));
         }
         // honey pot
         if ($this->f3->get('POST.username') !== '') {
             $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please do not use autofill or similar tools!'));
         }
         // process form if there are no errors
         if (count($this->f3->get('SESSION.flash')) === 0) {
             $this->f3->set('POST.status', 'Pending');
             $this->f3->set('POST.level', 1);
             $this->f3->set('POST.membercard', 'No');
             $this->f3->set('POST.mastered', 'None');
             $this->f3->set('POST.wishlist', 'Coming soon.');
             $this->f3->set('POST.biography', 'Coming soon.');
             $this->f3->set('POST.password', password_hash($this->f3->get('POST.password'), PASSWORD_DEFAULT));
             $this->f3->set('collectingID', $this->f3->get('POST.collecting'));
             $this->f3->set('POST.collecting', $cards->getById($this->f3->get('POST.collecting'))->filename);
             $mailer = new Mailer();
             $message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': New Member')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('POST.email')))->setBody(Template::instance()->render('app/templates/emails/newmember.htm'), 'text/html');
             // send email & save to db
             if ($mailer->send($message) && $members->add()) {
                 $this->f3->set('sp', array());
                 // random choice cards
                 for ($i = 0; $i < $this->f3->get('num_startchoice'); $i++) {
                     $this->f3->push('sp', $cards->random(array('id=?', $this->f3->get('collectingID'))));
                 }
                 // random regular cards
                 for ($i = 0; $i < $this->f3->get('num_startreg'); $i++) {
                     $this->f3->push('sp', $cards->random(array('worth=?', 1)));
                 }
                 // random special cards
                 for ($i = 0; $i < $this->f3->get('num_startspc'); $i++) {
                     $this->f3->push('sp', $cards->random(array('worth=?', 2)));
                 }
                 $mailer = new Mailer();
                 $message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Starter Pack')->setFrom(array($this->f3->get('noreplyemail') => $this->f3->get('tcgname')))->setTo(array($this->f3->get('POST.email')))->setReplyTo(array($this->f3->get('tcgemail')))->setBody(Template::instance()->render('app/templates/emails/starterpack.htm'), 'text/html');
                 $result = $mailer->send($message);
                 // load welcome message
                 $this->f3->set('content', 'app/views/welcome.htm');
             } else {
                 $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
             }
         }
     }
     if (!$this->f3->exists('content')) {
         $this->f3->set('content', 'app/views/join.htm');
     }
     $this->f3->set('decks', $cards->allAlpha());
     echo Template::instance()->render('app/templates/default.htm');
 }
Пример #19
0
<div class="row">
<div class="form col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
<?php 
$form = $this->beginWidget('booster.widgets.TbActiveForm', array('id' => 'cards-form', 'htmlOptions' => array('class' => 'well'), 'enableAjaxValidation' => false));
?>
    <legend><?php 
echo CHtml::encode($legend);
?>
</legend>
    <p class="note"><span class="help-block"><?php 
echo Yii::t('app', 'Fields with <span class="required">*</span> are required.');
?>
</span></p>
    <?php 
//echo $form->errorSummary($model);
?>
    <?php 
echo $form->dropDownListGroup($model, 'series', array('widgetOptions' => array('data' => Cards::getSeriesList())));
?>
    <?php 
echo $form->textFieldGroup($model, 'number');
?>
    <?php 
echo $form->dropDownListGroup($model, 'expired_var', array('widgetOptions' => array('data' => Cards::getExpiredList())));
?>
    <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'submit', 'context' => 'primary', 'label' => Yii::t('app', 'Create')));
$this->endWidget();
?>

</div><!-- form -->
Пример #20
0
 function ContractRummy($players = 2)
 {
     parent::Cards(2, 0);
 }
Пример #21
0
 public function settings()
 {
     if ($this->f3->exists('SESSION.userID')) {
         $cards = new Cards($this->db);
         $members = new Members($this->db);
         $this->f3->set('status', array('Active', 'Hiatus'));
         $this->f3->set('decks', $cards->allAlpha());
         $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]);
         if ($this->f3->exists('POST.update')) {
             $audit = \Audit::instance();
             $this->f3->scrub($_POST);
             $this->f3->set('SESSION.flash', array());
             // validate form
             if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address.'));
             }
             if ($this->f3->get('POST.email') != $this->f3->get('member')->email && $members->count(array('email=?', $this->f3->get('POST.email'))) != 0) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your email address is already in use by another player.'));
             }
             if (!$audit->url($this->f3->get('POST.url'))) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid trade post URL.'));
             }
             if ($this->f3->get('POST.password') !== '' && !preg_match("/^.{6,}\$/", $this->f3->get('POST.password'))) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your password must contain at least 6 characters.'));
             }
             if ($this->f3->get('POST.password') !== '' && $this->f3->get('POST.password') !== $this->f3->get('POST.password2')) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Your passwords don\'t match!'));
             }
             if ($this->f3->get('member')->status !== 'Pending' && !in_array($this->f3->get('POST.status'), $this->f3->get('status'))) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid status.'));
             }
             if ($cards->count(array('id=?', $this->f3->get('POST.collecting'))) == 0) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid collecting deck.'));
             }
             if (!preg_match("/^.{0,875}\$/", $this->f3->get('POST.biography')) || !preg_match("/^.{0,875}\$/", $this->f3->get('POST.wishlist'))) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please limit your Profile details to 875 characters.'));
             }
             // process form if there are no errors
             if (count($this->f3->get('SESSION.flash')) === 0) {
                 if ($this->f3->get('member')->status == 'Pending') {
                     // If they're pending, don't let them change their status!
                     $this->f3->set('POST.status', 'Pending');
                 }
                 if ($this->f3->exists('POST.password') && $this->f3->get('POST.password') != '') {
                     // if password was changed, hash it
                     $this->f3->set('POST.password', password_hash($this->f3->get('POST.password'), PASSWORD_DEFAULT));
                 } else {
                     $this->f3->clear('POST.password');
                 }
                 $this->f3->set('collectingID', $this->f3->get('POST.collecting'));
                 $this->f3->set('POST.collecting', $cards->getById($this->f3->get('POST.collecting'))->filename);
                 // update settings in db
                 if ($members->edit($this->f3->get('SESSION.userID'), array('email', 'url', 'status', 'password', 'level', 'collecting', 'wishlist', 'biography'))) {
                     $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your settings have been updated!'));
                     $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]);
                 } else {
                     $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
                 }
             }
         }
         $this->f3->set('content', 'app/views/settings.htm');
         echo Template::instance()->render('app/templates/default.htm');
     } else {
         $this->f3->reroute('/members/login');
     }
 }
Пример #22
0
?>
</legend>

			<div class="meta-container">
				<?php 
foreach ($cards as $card) {
    ?>
					<?php 
    $card->value = CJSON::decode($card->value);
    ?>
					<div class="pure-control-group">
						<?php 
    echo CHtml::tag('label', array('class' => 'inline'), Cii::titleize($card->value['class']));
    ?>
						<?php 
    $count = Cards::model()->countByAttributes(array('name' => $card->key));
    ?>
						<p class="text-small inline" style="top: -8px;"><?php 
    echo $card->value['name'];
    ?>
</p>
						<span class="pure-button pure-button-error pure-button-xsmall pure-button-link-xs pull-right remove-button" id="<?php 
    echo $card->key;
    ?>
">
							<span class="icon-remove"></span>
						</span>
						<span class="pure-button pure-button-warning pure-button-xsmall pure-button-link-xs pull-right">
							<?php 
    echo $count;
    ?>