-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc0249f
Showing
897 changed files
with
141,768 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#.htpasswd/.htaccess | ||
.sshtunnel | ||
.test.php | ||
|
||
# Test URI | ||
# Ignore netbeans folder | ||
nbproject/* | ||
|
||
# MAC | ||
.DS_Store | ||
|
||
# Windows | ||
Thumbs.db | ||
|
||
# Eclipse project files | ||
/.cache | ||
.project | ||
.tmp | ||
/.settings | ||
.buildpath | ||
/config/config.local.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: vendor/bin/heroku-php-apache2 webroot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Fat Free Framework - MVC Starter Kit | ||
============================================ | ||
|
||
An early approach to a very lightweight F3 MVC Starter Kit. | ||
It is currently based on an older F3 Version - updates will follow soon.... | ||
|
||
## System Requirements | ||
|
||
* PHP >= 5.3.3 | ||
* PCRE PHP Module >= 8.02 | ||
* mod_rewrite and mod_headers enabled | ||
* cURL, sockets or stream extension | ||
|
||
## System Config | ||
|
||
* Create MySQL Databse | ||
* Import SQL file(s) located in config/sql/* | ||
* Copy config/config.local.ini.sample to config/config.local.ini and adapt to your settings | ||
* Copy webroot/_htaccess to webroot/.htaccess | ||
* Create Apache V-Host pointing to webroot/ and use "local.*" as hostname | ||
* Modify your host-file | ||
|
||
## Basic File Structure | ||
|
||
To be updated..... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "fatfree-mvc", | ||
"description": "Fat Free Framework - MVC Starterkit", | ||
"repository": "https://github.com/fivenp/fatfree-mvc", | ||
"addons": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
class API extends Controller { | ||
|
||
function afterroute($f3) { | ||
echo View::instance()->render('layouts/default.json'); | ||
} | ||
|
||
function sampleGet($f3){ | ||
$f3->set('data',array('return'=>'sample')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
//! Base controller - Everything inside will be passed to the other controllers! | ||
class Controller { | ||
|
||
// HTTP route pre-processor | ||
function beforeroute($f3,$args) { | ||
if($f3->get('ENV.DATABASE_URL')){ | ||
$dbUrl = $this->__multiexplode(array('@',':','/'),$f3->get('ENV.DATABASE_URL')); | ||
$f3->set('db.dsn',"pgsql:host=".$dbUrl[5].";port=".$dbUrl[6].";dbname=".$dbUrl[7]); | ||
$f3->set('db.user',$dbUrl[3]); | ||
$f3->set('db.pass',$dbUrl[4]); | ||
} | ||
// $db = new \DB\SQL($f3->get('db.dsn'),$f3->get('db.user'),$f3->get('db.pass')); | ||
// $f3->set('DB',$db); | ||
} | ||
|
||
// HTTP route post-processor | ||
function afterroute($f3) { | ||
// Render appropriate layout | ||
if($f3->get('layout')=="empty"){ | ||
echo View::instance()->render('layouts/empty.php'); | ||
} else if($f3->get('AJAX')){ | ||
echo View::instance()->render('layouts/default.json'); | ||
} else { | ||
echo View::instance()->render('layouts/default.php'); | ||
} | ||
} | ||
|
||
// Instantiate class | ||
function __construct() { | ||
$f3=Base::instance(); | ||
} | ||
|
||
// Some tiny helper classes | ||
function __debug($d){ | ||
print_r($d); | ||
} | ||
function __in_array_r($needle, $haystack, $strict = true) { | ||
foreach ($haystack as $item) { | ||
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->__in_array_r($needle, $item, $strict))) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function __set_cache($f3,$secs=0){ | ||
if ($secs) { | ||
$time=microtime(TRUE); | ||
header_remove('Pragma'); | ||
header('Expires: '.gmdate('r',$time+$secs)); | ||
header('Cache-Control: public, max-age='.$secs); | ||
header('Last-Modified: '.gmdate('r')); | ||
} else { | ||
header('Cache-Control: no-cache, no-store, must-revalidate'); | ||
} | ||
} | ||
function __multiexplode ($delimiters,$string) { | ||
$ready = str_replace($delimiters, $delimiters[0], $string); | ||
$launch = explode($delimiters[0], $ready); | ||
return $launch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
class Index extends Controller { | ||
|
||
/** | ||
Index | ||
Just an EXAMPLE of how to do stuff | ||
**/ | ||
|
||
function index($f3){ | ||
$f3->set('title',''); | ||
$f3->set('classname','index'); | ||
$f3->set('template','views/index.php'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
namespace Model; | ||
|
||
class Sample extends \DB\Cortex { | ||
protected | ||
$fieldConf = array( | ||
'samples' => array( | ||
'has-many' => array('\Model\SampleImages','images'), | ||
), | ||
), | ||
$db = 'DB', // F3 hive key of a valid DB object | ||
$table = 'samples', | ||
// $fluid = true, // triggers the SQL Fluid Mode, default: false | ||
$primary = 'id', // name of the primary key (auto-created), default: id | ||
$ttl = 120, // caching time of field schema, default: 60 | ||
$rel_ttl = 30; // caching time of all relations, default: 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
class Rake extends Controller { | ||
|
||
/** | ||
RAKE | ||
This is intendet to be run either from CMD line or for initial tasks! | ||
**/ | ||
|
||
function task1($f3){ | ||
$db = new \DB\SQL($f3->get('db.dsn'),$f3->get('db.user'),$f3->get('db.pass')); | ||
|
||
$samples = new \DB\Cortex($db, 'samples'); | ||
$samples = $samples->find(array('test = ? AND status = ?','test',1),array('order'=>'id ASC')); | ||
|
||
foreach($samples as $sample){ | ||
// Do your stuff | ||
} | ||
|
||
$f3->set('layout','empty'); | ||
$f3->set('template','empty.php'); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
class User extends Controller { | ||
|
||
function afterroute($f3) { | ||
echo View::instance()->render('layouts/login.php'); | ||
} | ||
|
||
/** | ||
Display login form | ||
**/ | ||
function login($f3) { | ||
// $crypt = \Bcrypt::instance(); | ||
// die(print_r($crypt->hash('mypwd',$f3->get('md.salt')))); | ||
$f3->clear('SESSION'); | ||
$f3->set('title','BACKEND!'); | ||
$f3->set('classname','login'); | ||
$f3->set('template','views/user/login.php'); | ||
} | ||
|
||
/** | ||
Process login form | ||
**/ | ||
function auth($f3) { | ||
$crypt = \Bcrypt::instance(); | ||
$db = new \DB\SQL($f3->get('db.dsn'),$f3->get('db.user'),$f3->get('db.pass')); | ||
$users = new \DB\Cortex($db, 'users'); | ||
|
||
if (!$f3->get('COOKIE.sent')){ | ||
$f3->set('message_type','warning'); | ||
$f3->set('message','Cookies must be enabled to enter this area'); | ||
} else { | ||
$user = $users->find(array('login=?',$f3->get('POST.username'))); | ||
if($user){ | ||
if($user[0]->password === $crypt->hash($f3->get('POST.password'),$f3->get('md.salt')) ){ | ||
$f3->set('message_type','success'); | ||
$f3->set('message','User / PW match'); | ||
$f3->clear('COOKIE.sent'); | ||
$f3->set('SESSION.admin_user',$user[0]->login); | ||
$f3->set('SESSION.admin_isadmin',$user[0]->admin); | ||
$f3->set('SESSION.admin_id',$user[0]->id); | ||
$f3->set('SESSION.admin_lastseen',time()); | ||
|
||
$users->load(array('id = ?',$user[0]->id)); | ||
$users->last_login = date('Y-m-d H:i:s'); | ||
$users->last_login_remote_addr = ($f3->get('SERVER.HTTP_X_FORWARDED_FOR') ? $f3->get('SERVER.HTTP_X_FORWARDED_FOR') : $f3->get('SERVER.REMOTE_ADDR')); | ||
$users->save(); | ||
|
||
$f3->reroute('/'); | ||
} else { | ||
$f3->set('message_type','danger'); | ||
$f3->set('message','PW false'); | ||
} | ||
|
||
} else { | ||
$f3->set('message_type','danger'); | ||
$f3->set('message','Please check your Username and Password'); | ||
} | ||
} | ||
|
||
$this->login($f3); | ||
} | ||
|
||
/** | ||
Terminate session | ||
**/ | ||
function logout($f3) { | ||
$f3->clear('SESSION'); | ||
$f3->reroute('/login'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"require" : { | ||
"php": "^5.5.0", | ||
"ext-imagick": "*", | ||
"ext-gd": "*" | ||
}, | ||
"require-dev": { | ||
"heroku/heroku-buildpack-php": "*" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# BASIC LOCAL ENVIRONMENT CONFIGURATION | ||
|
||
[globals] | ||
DEBUG="3" | ||
env = "dev" | ||
asset_url = "/assets/" | ||
asset_domain = "" | ||
img_domain = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# BASIC LOCAL ENVIRONMENT CONFIGURATION | ||
|
||
[globals] | ||
DEBUG="3" | ||
env = "dev" | ||
asset_url = "/assets/" | ||
asset_domain = "" | ||
img_domain = "" | ||
|
||
# EITHER SET IT IN YOUR ENV VARS OR HERE | ||
|
||
db.dsn="pgsql:host=localhost;port=5432;dbname=test" | ||
db.host="localhost" | ||
db.port="5432" | ||
db.user="user" | ||
db.pass="pass" | ||
db.db="test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# BASIC LOCAL ENVIRONMENT CONFIGURATION | ||
|
||
[globals] | ||
DEBUG="0" | ||
env = "production" | ||
asset_url = "/assets/" | ||
asset_domain = "" | ||
img_domain = "" |
Oops, something went wrong.