Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information...
karolbrennan committed May 4, 2015
1 parent 1c47750 commit 1177d573b9007584606bfccf25bc2c537fa01a6d
Showing 329 changed files with 416,031 additions and 0 deletions.
@@ -0,0 +1,2 @@

app/core/credentials.php
@@ -0,0 +1,16 @@
Options -Indexes

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

#comment out to keep trailing slashes
RewriteRule ^(.+)/$ $1 [R=307,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?$1 [QSA,L]

</IfModule>
@@ -0,0 +1 @@
retrogaming.zone
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="On explicit save action" serverName="RetroGaming.Zone">
<serverData>
<paths name="RetroGaming.Zone">
<serverdata>
<mappings>
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ON_EXPLICIT_SAVE" />
</component>
</project>

@@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="karolbrennan" />
</component>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
<component name="VagrantSettings">
<option name="instanceFolder" value="" />
<option name="provider" value="" />
<option name="vagrantExecutable" value="vagrant" />
</component>
</project>

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/retrogaming.zone.iml" filepath="$PROJECT_DIR$/.idea/retrogaming.zone.iml" />
</modules>
</component>
</project>

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@@ -0,0 +1,128 @@
<?php
/**
* Created by PhpStorm.
* User: karolbrennan
* Date: 11/9/14
* Time: 7:29 PM
*/
namespace controllers;
use core\view as View;
class Auth extends BaseController
{
/**
* Set data elements and display login page
*/
public function loginPage()
{
$data = array();
$data['title'] = "Login";
$data['message'] = "Please login to use Retro Gaming Zone!";
$data['errors'] = \helpers\session::pull('errors');
$data['sticky-form'] = \helpers\session::pull('sticky-form');
// render templates and pass data to them
View::rendertemplate('header', $data);
View::render('auth/login', $data);
View::rendertemplate('footer', $data);
}
/**
* Process form when someone attempts to log in
*/
public function processLogin() {
$user = array();
$errors = array();
$stickyForm = array();
if($_SERVER['REQUEST_METHOD'] === 'POST') {
if(!empty($_POST['email'])) {
$email = \models\User::validateEmail($_POST['email']);
if($email['valid'] === true) {
$user['email'] = $email['value'];
} else {
$errors['login']['email'] = $email['message'];
$stickyForm['email'] = $email['value'];
}
}
if(!empty($_POST['password'])) {
$password = \models\User::validatePassword($_POST['password']);
if($password['valid'] === true) {
$user['password'] = $password['value'];
} else {
$errors['login']['password'] = $password['message'];
}
}
} else {
$errors['login']['required'] = "Please fill out the form.";
}
if(empty($errors)) {
$loginStatus = \services\User::loginUser($user);
if($loginStatus['success'] === false) {
$errors['login']['combo'] = $loginStatus['error'];
}
}
if (empty($errors)) {
\helpers\session::destroy('errors');
\helpers\session::destroy('sticky-form');
\helpers\url::redirect('');
} else {
\helpers\session::set('errors', $errors);
\helpers\url::redirect('login');
}
}
/**
* Set data elements and display the logout page
*/
public function logoutPage()
{
$this->processLogout();
$data['message'] = "You have successfully logged out!";
View::rendertemplate('header', $data);
View::render('auth/logout', $data);
View::rendertemplate('footer', $data);
}
/**
* Processes a log out by destroying the user session along with errors and sticky form data
*/
public function processLogout() {
\helpers\session::destroy('user');
}
/**
* Redirect to registration page if user is not logged in
*/
public static function redirectToRegisterIfNotLoggedIn(){
$user = \helpers\session::get('user');
if(empty($user)) {
\helpers\url::redirect('register');
}
}
/**
* Redirect to login page if user is not logged in
*/
public static function redirectToLoginIfNotLoggedIn(){
$user = \helpers\session::get('user');
if(empty($user)) {
\helpers\url::redirect('login');
}
}
/**
* Redirect to home page if user is logged in
*/
public static function redirectToHomeIfLoggedIn(){
$user = \helpers\session::get('user');
if(!empty($user)) {
\helpers\url::redirect('');
}
}
}
@@ -0,0 +1,5 @@
<?php namespace controllers;
class BaseController extends \core\controller {
}
@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: karolbrennan
* Date: 12/7/14
* Time: 9:07 PM
*/
namespace controllers;
use core\view as View;
class Consoles extends BaseController {
/**
* Display the consoles listing page and pass relevant data
*/
public function consolesListingPage() {
Auth::redirectToLoginIfNotLoggedIn();
$data['title'] = 'Consoles';
$data['message'] = 'Here is the entire listing of available consoles.';
$data['no-consoles'] = "Sorry, there aren't any consoles available yet.";
$data['consoles'] = \services\Console::createConsoleObjectArray();
View::rendertemplate('header', $data);
View::render('consoles/consoles', $data);
View::rendertemplate('footer', $data);
}
}
@@ -0,0 +1,119 @@
<?php
/**
* Created by PhpStorm.
* User: karolbrennan
* Date: 12/7/14
* Time: 9:07 PM
*/
namespace controllers;
use core\view as View;
class Games {
/**
* Get games listing page and handle filtering of results
*/
public function gamesListingPage() {
Auth::redirectToLoginIfNotLoggedIn();
if(isset($_GET['resultNum']) && $_GET['resultNum'] !== 'Per Page'){
$resultNum = filter_var($_GET['resultNum'], FILTER_SANITIZE_NUMBER_INT);
}else{
$resultNum = 20;
};
$data['selectedNumber'] = $resultNum;
$ext = "&resultNum=" . $resultNum;
if(isset($_GET['console'])){
if($_GET['console'] !== 'Select Console') {
$console = filter_var($_GET['console'], FILTER_SANITIZE_STRING);
switch ($console) {
case 'Atari 2600';
$filterConsole = '1';
$consoleName = 'Atari+2600';
break;
case 'Atari 5200';
$filterConsole = '4';
$consoleName = 'Atari+5200';
break;
case 'Atari 7800';
$filterConsole = '7';
$consoleName = 'Atari+7800';
break;
case 'Atari Jaguar';
$filterConsole = '14';
$consoleName = 'Atari+Jaguar';
break;
case 'ColecoVision';
$filterConsole = '5';
$consoleName = 'ColecoVision';
break;
case 'Commodore 64';
$filterConsole = '6';
$consoleName = 'Commodore+64';
break;
case 'Intellivision';
$filterConsole = '2';
$consoleName = 'Intellivision';
break;
case 'NES';
$filterConsole = '9';
$consoleName = 'NES';
break;
case 'SNES';
$filterConsole = '13';
$consoleName = 'SNES';
break;
case 'N64';
$filterConsole = '17';
$consoleName = 'N64';
break;
case 'Sega Master System';
$filterConsole = '8';
$consoleName = 'Sega+Master+System';
break;
case 'Sega 32X';
$filterConsole = '11';
$consoleName = 'Sega+32X';
break;
case 'Sega CD';
$filterConsole = '10';
$consoleName = 'Sega+CD';
break;
case 'Sega Genesis';
$filterConsole = '12';
$consoleName = 'Sega+Genesis';
break;
case 'Sega Saturn';
$filterConsole = '16';
$consoleName = 'Sega+Saturn';
break;
case 'PlayStation';
$filterConsole = '15';
$consoleName = 'PlayStation';
break;
};
$data['selectedConsole'] = $console;
$ext .= "&console=" . $consoleName;
}
}else{
$filterConsole = null;
};
$data['title'] = 'Games';
$data['message'] = 'Here is a listing of available games.';
$pages = new \helpers\paginator($resultNum,'p');
$data['games'] = \services\Game::createGameObjectArray($resultNum, $filterConsole, $pages->get_limit($resultNum));
$total = \services\Game::getTotalOfRecords($filterConsole);
$pages->set_total($total);
$path = '?';
$data['pages'] = $pages->page_links($path,$ext);
View::rendertemplate('header', $data);
View::render('games/games', $data);
View::rendertemplate('footer', $data);
}
}

0 comments on commit 1177d57

Please sign in to comment.
You can’t perform that action at this time.