Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tooblue committed Nov 16, 2015
2 parents fc400d9 + 4f2c8a7 commit 75a9cbd
Show file tree
Hide file tree
Showing 103 changed files with 990 additions and 1,385 deletions.
2 changes: 2 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RewriteEngine On

RewriteRule ^(tmp)\/|\.ini$ - [R=404]

RewriteRule ^plugins/(.*)/(.*)/assets/(.*) app/plugins/$1/$2/assets/$3 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Expand Down
2 changes: 1 addition & 1 deletion app/.htaccess
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Deny from all
Deny from all
6 changes: 3 additions & 3 deletions app/controllers/core/AffiliatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public function index()
{
$affiliates = new Affiliates($this->db);
$this->f3->set('affiliates',$affiliates->read(array('status=?','Active'),[]));
$this->f3->set('content','app/views/affiliates.htm');
echo Template::instance()->render('app/templates/default.htm');
$this->f3->set('content','app/themes/'.$this->f3->get('theme').'/views/affiliates.htm');
echo Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/default.htm');
}

public function request()
Expand Down Expand Up @@ -47,7 +47,7 @@ public function request()
->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/affiliation.htm'), 'text/html')
->setBody(Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/emails/affiliation.htm'), 'text/html')
;

// send email & save to db
Expand Down
111 changes: 56 additions & 55 deletions app/controllers/core/CardsController.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
<?php

namespace Controllers\Core;

use Models\Core\Cards;
use Models\Core\Members;
use Template;

class CardsController extends Controller {
public function index()
{
$cards = new Cards($this->db);

$this->f3->set('decks',array());
foreach ( $this->f3->get('category') as $index => $cat ) {
$this->f3->set('decks['.$index.']',$cards->getByCat($index));
}

$this->f3->set('content','app/views/cards.htm');
echo Template::instance()->render('app/templates/default.htm');
}
public function alpha()
{
$cards = new Cards($this->db);

$this->f3->set('decks',$cards->allAlpha());
$this->f3->set('content','app/views/cards-alpha.htm');
echo Template::instance()->render('app/templates/default.htm');
}
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');
}
}
public function members()
{
$mem = new Members($this->db);

$this->f3->set('members',$mem->allWhereMemCards());
$this->f3->set('content','app/views/cards-members.htm');
echo Template::instance()->render('app/templates/default.htm');
}
public function upcoming()
{
$upcoming = new Upcoming($this->db);

$this->f3->set('decks',$upcoming->all());
$this->f3->set('content','app/views/cards-upcoming.htm');
echo Template::instance()->render('app/templates/default.htm');
}
<?php

namespace Controllers\Core;

use Models\Core\Cards;
use Models\Core\Upcoming;
use Models\Core\Members;
use Template;

class CardsController extends Controller {
public function index()
{
$cards = new Cards($this->db);

$this->f3->set('decks',array());
foreach ( $this->f3->get('category') as $index => $cat ) {
$this->f3->set('decks['.$index.']',$cards->getByCat($index));
}

$this->f3->set('content','app/themes/'.$this->f3->get('theme').'/views/cards.htm');
echo Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/default.htm');
}
public function alpha()
{
$cards = new Cards($this->db);

$this->f3->set('decks',$cards->allAlpha());
$this->f3->set('content','app/themes/'.$this->f3->get('theme').'/views/cards-alpha.htm');
echo Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/default.htm');
}
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/themes/'.$this->f3->get('theme').'/views/cards-view.htm');
echo Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/default.htm');
}
}
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 upcoming()
{
$upcoming = new Upcoming($this->db);

$this->f3->set('decks',$upcoming->all());
$this->f3->set('content','app/themes/'.$this->f3->get('theme').'/views/cards-upcoming.htm');
echo Template::instance()->render('app/themes/'.$this->f3->get('theme').'/templates/default.htm');
}
}
126 changes: 63 additions & 63 deletions app/controllers/core/ContactController.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
<?php

namespace Controllers\Core;

use Models\Core\Members;
use Filler00\Mailer;
use Template;

class ContactController extends Controller {

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/views/contact.htm');
echo Template::instance()->render('app/templates/default.htm');
}
private function process()
{
$this->f3->scrub($_POST);
$audit = \Audit::instance();
$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.'));
if ( !$audit->email($this->f3->get('POST.email'), FALSE) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Invalid email address'));
if ( !empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url')) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Invalid URL.'));
if ( empty($this->f3->get('POST.message')) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Please include a message!'));

// 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!'));

// if there are no errors, process the form
if ( count($this->f3->get('SESSION.flash')) === 0 ) {
$this->f3->set('POST.level',$this->f3->get('member')->level + 1);

$mailer = new Mailer;
$message = $mailer->message()
->setSubject($this->f3->get('tcgname') . ': Contact Form')
->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/contact.htm'), 'text/html')
;

if ( $mailer->send($message) ) {
$this->f3->push('SESSION.flash',array('type'=>'success','msg'=>'Your form has been sent. Thanks for contacting us!'));
} 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!'));
}
}
}
<?php

namespace Controllers\Core;

use Models\Core\Members;
use Filler00\Mailer;
use Template;

class ContactController extends Controller {

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 process()
{
$this->f3->scrub($_POST);
$audit = \Audit::instance();
$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.'));
if ( !$audit->email($this->f3->get('POST.email'), FALSE) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Invalid email address'));
if ( !empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url')) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Invalid URL.'));
if ( empty($this->f3->get('POST.message')) )
$this->f3->push('SESSION.flash',array('type'=>'warning','msg'=>'Please include a message!'));

// 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!'));

// if there are no errors, process the form
if ( count($this->f3->get('SESSION.flash')) === 0 ) {
$this->f3->set('POST.level',$this->f3->get('member')->level + 1);

$mailer = new Mailer;
$message = $mailer->message()
->setSubject($this->f3->get('tcgname') . ': Contact Form')
->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/contact.htm'), 'text/html')
;

if ( $mailer->send($message) ) {
$this->f3->push('SESSION.flash',array('type'=>'success','msg'=>'Your form has been sent. Thanks for contacting us!'));
} 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!'));
}
}
}
}
33 changes: 21 additions & 12 deletions app/controllers/core/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,28 @@
use \Session;

class Controller {

protected $f3;
protected $db;
protected $jig;
protected $auth;

function __construct() {
$f3 = Base::instance();

$this->db = new SQL(
'mysql:host=' . $f3->get('db_server') . ';port=' . $f3->get('db_port') . ';dbname=' . $f3->get('db_database'),
$f3->get('db_user'),
$f3->get('db_password')
);
$this->jig = new Jig('storage/jig/');

$user = new SQL\Mapper($this->db, 'members');
$this->auth = new \Auth($user, array('id'=>'name', 'pw'=>'password'));
$this->f3 = $f3;

}

function beforeRoute() {
new Session();

Expand All @@ -22,19 +41,9 @@ function beforeRoute() {
}
*/
}

function afterRoute() {
$this->f3->clear('SESSION.flash');
}
function __construct() {
$f3 = Base::instance();
$db = new SQL(
'mysql:host=' . $f3->get('db_server') . ';port=3306;dbname=' . $f3->get('db_database'),
$f3->get('db_user'),
$f3->get('db_password')
);
$user = new SQL\Mapper($db, 'members');
$this->auth = new \Auth($user, array('id'=>'name', 'pw'=>'password'));
$this->f3 = $f3;
$this->db = $db;
}

}
Loading

0 comments on commit 75a9cbd

Please sign in to comment.