public function members() { $mem = new Members($this->db); $this->f3->set('members', $mem->allWhereMemCards()); $this->f3->set('content', 'app/themes/' . $this->f3->get('theme') . '/views/cards-members.htm'); echo Template::instance()->render('app/themes/' . $this->f3->get('theme') . '/templates/default.htm'); }
public function index() { $members = new Members($this->db); $upcoming = new Upcoming($this->db); $this->f3->set('pendingMembers', $members->getByStatus('pending')); $this->f3->set('upcomingDecks', $upcoming->all()); $this->f3->set('content', 'app/themes/' . $this->f3->get('admintheme') . '/views/mytcg/index.htm'); echo Template::instance()->render('app/themes/' . $this->f3->get('admintheme') . '/templates/admin.htm'); }
public function index() { if ($this->f3->exists('SESSION.userID')) { $members = new Members($this->db); $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]); } if ($this->f3->exists('POST.submit')) { $this->process(); } $this->f3->set('content', 'app/themes/' . $this->f3->get('theme') . '/views/contact.htm'); echo Template::instance()->render('app/themes/' . $this->f3->get('theme') . '/templates/default.htm'); }
private function login() { $this->f3->set('SESSION.flash', array()); $this->f3->scrub($_POST); if (in_array(strtolower($this->f3->get('POST.username')), array_map('strtolower', $this->f3->get('admin_users'))) && $this->auth->login($this->f3->get('POST.username'), $this->f3->get('POST.password'))) { $members = new Members($this->db); $this->f3->set('SESSION.adminID', $members->getByName($this->f3->get('POST.username'))->id); $this->f3->set('SESSION.adminName', $members->getByName($this->f3->get('POST.username'))->name); $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Welcome back, ' . $this->f3->get('SESSION.adminName') . '!')); $this->f3->reroute('/mytcg'); } else { $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'Authentication failed. Please try again or contact us for assistance.')); } }
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/themes/' . $this->f3->get('theme') . '/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/themes/' . $this->f3->get('theme') . '/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/themes/' . $this->f3->get('theme') . '/views/join.htm'); } $this->f3->set('decks', $cards->allAlpha()); echo Template::instance()->render('app/themes/' . $this->f3->get('theme') . '/templates/default.htm'); }
public function logs() { if ($this->f3->exists('SESSION.userID')) { $members = new Members($this->db); $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]); $this->f3->set('content', 'app/themes/' . $this->f3->get('theme') . '/views/logs.htm'); echo Template::instance()->render('app/themes/' . $this->f3->get('theme') . '/templates/default.htm'); } else { $this->f3->reroute('/members/login'); } }
public function delete($id = '') { /*********************************** Delete members ************************************/ $members = new Members($this->db); $this->f3->set('member', $members->read(array('id=?', $id), [])[0]); $this->f3->set('SESSION.flash', array()); if ($_SERVER['QUERY_STRING'] == "execute") { $members->delete($this->f3->get('member')->id); $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Member ' . $this->f3->get('member')->name . ' deleted!')); $this->f3->reroute('/mytcg/members'); } $this->f3->set('content', 'app/themes/' . $this->f3->get('admintheme') . '/views/mytcg/members_delete.htm'); echo Template::instance()->render('app/themes/' . $this->f3->get('admintheme') . '/templates/admin.htm'); }
private function quit() { /*********************************** Process Quit Form! ************************************/ $this->f3->scrub($_POST); $members = new Members($this->db); $this->f3->set('member', $members->read(array('id=?', $this->f3->get('SESSION.userID')), [])[0]); $this->f3->set('SESSION.flash', array()); // nothing to validate! // 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') . ': Quit Form (' . $this->f3->get('member')->name . ')')->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/themes/' . $this->f3->get('theme') . '/templates/emails/quit-notif.htm'), 'text/html'); if ($mailer->send($message)) { $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your quit form has been sent. Sorry to see you leave - we hope you\'ll change your mind and join us again in the future!')); } 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!')); } } }