Skip to content

Commit f36e224

Browse files
committed
Upload
First Upload
0 parents  commit f36e224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6323
-0
lines changed

.htaccess

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<IfModule mod_rewrite.c>
2+
RewriteEngine On
3+
#RewriteBase /
4+
5+
# Allow any files or directories that exist to be displayed directly
6+
RewriteCond %{REQUEST_FILENAME} !-f
7+
RewriteCond %{REQUEST_FILENAME} !-d
8+
9+
# Rewrite all other URLs to index.php/URL
10+
RewriteRule ^ index.php [L]
11+
</IfModule>

app/config/aliases.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* Class aliases
5+
*/
6+
return array(
7+
'Arr' => 'System\\Arr',
8+
'Autoloader' => 'System\\Autoloader',
9+
'Config' => 'System\\Config',
10+
'Cookie' => 'System\\Cookie',
11+
'DB' => 'System\\Database',
12+
'Error' => 'System\\Error',
13+
'Input' => 'System\\Input',
14+
'Query' => 'System\\Database\\Query',
15+
'Record' => 'System\\Database\\Record',
16+
'Request' => 'System\\Request',
17+
'Response' => 'System\\Response',
18+
'Route' => 'System\\Route',
19+
'Router' => 'System\\Router',
20+
'Session' => 'System\\Session',
21+
'Uri' => 'System\\Uri',
22+
'View' => 'System\\View'
23+
);

app/config/app.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
return array(
4+
/*
5+
* Application base URL
6+
*/
7+
'url' => '',
8+
9+
/*
10+
* Application Index
11+
*/
12+
'index' => '',
13+
14+
/*
15+
* Application Timezone
16+
*/
17+
'timezone' => 'UTC',
18+
19+
/*
20+
* Application Key
21+
*/
22+
'key' => hash('md5', 'nanoframework'),
23+
24+
/*
25+
* Application Language
26+
*/
27+
'language' => 'en_GB',
28+
29+
/*
30+
* Application Character Encoding
31+
*/
32+
'encoding' => 'UTF-8'
33+
);

app/config/cache.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
return array(
4+
5+
// The Memcached server used by your application.
6+
'memcache' => array(
7+
'host' => 'localhost',
8+
'port' => 11211
9+
),
10+
11+
'memcached' => array(
12+
'host' => 'localhost',
13+
'port' => 11211
14+
)
15+
16+
);

app/config/db.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
return array(
4+
/*
5+
* The default database configuration to use
6+
*/
7+
'default' => 'mysql',
8+
9+
/*
10+
* Query logging
11+
*
12+
* When set to True all queries are stored and can be
13+
* retreived using DB::profile();
14+
*/
15+
'profiling' => true,
16+
17+
/*
18+
* Array of database connections available
19+
*
20+
* DB::connection() // will return the default
21+
* DB::connection('mysql') // will return the 'mysql' connection
22+
*/
23+
'connections' => array(
24+
'sqlite' => array(
25+
'driver' => 'sqlite',
26+
'database' => ':memory:',
27+
'prefix' => ''
28+
),
29+
30+
'mysql' => array(
31+
'driver' => 'mysql',
32+
'hostname' => 'localhost',
33+
'port' => 3306,
34+
'username' => 'root',
35+
'password' => 'root',
36+
'database' => 'anchoria',
37+
'charset' => 'utf8',
38+
'prefix' => ''
39+
)
40+
)
41+
);

app/config/error.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
return array(
4+
/*
5+
* Error detail report
6+
*
7+
* When set to True errors will be show with full details and stack trace
8+
* Set to False in production
9+
*/
10+
'report' => true,
11+
12+
/*
13+
* Error logging
14+
*
15+
* The log function is always called regardless of the error detail report.
16+
*/
17+
'log' => function($exception) {}
18+
);

app/config/session.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
return array(
4+
/*
5+
* Session driver
6+
*
7+
* Available options are: cookie, database, memcache, memcached, runtime
8+
*/
9+
'driver' => 'database',
10+
11+
/*
12+
* Session cookie name
13+
*/
14+
'cookie' => 'nano',
15+
16+
/*
17+
* Session database table name when used with the 'database' driver
18+
*/
19+
'table' => 'sessions',
20+
21+
/*
22+
* Session lifespan in seconds
23+
*/
24+
'lifetime' => 14400,
25+
26+
/*
27+
* Session cookie expires at the end of the browser session
28+
*/
29+
'expire_on_close' => false,
30+
31+
/*
32+
* Session cookie path
33+
*/
34+
'path' => '/',
35+
36+
/*
37+
* Session cookie domain
38+
*/
39+
'domain' => '',
40+
41+
/*
42+
* Session cookie secure (only available via https)
43+
*/
44+
'secure' => false
45+
);

app/libraries/.gitkeep

Whitespace-only changes.

app/libraries/auth.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
class Auth {
4+
5+
private static $session = 'auth';
6+
7+
public static function guest() {
8+
return Session::get(static::$session) === null;
9+
}
10+
11+
public static function user() {
12+
if($id = Session::get(static::$session)) {
13+
return User::find($id);
14+
}
15+
}
16+
17+
public static function attempt($username, $password) {
18+
if($user = User::where('username', '=', $username)->where('status', '=', 'active')->fetch()) {
19+
// found a valid user now check the password
20+
if(Hash::check($password, $user->password)) {
21+
// store user ID in the session
22+
Session::put(static::$session, $user->id);
23+
24+
return true;
25+
}
26+
}
27+
28+
return false;
29+
}
30+
31+
public static function logout() {
32+
Session::erase(static::$session);
33+
}
34+
35+
}

app/libraries/csrf.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
class Csrf {
4+
5+
public static function check($token) {
6+
$tokens = Session::get('csrf_tokens', array());
7+
8+
if(($index = array_search($token, $tokens)) !== false) {
9+
unset($tokens[$index]);
10+
11+
Session::put('csrf_tokens', $tokens);
12+
13+
return $token;
14+
}
15+
16+
return false;
17+
}
18+
19+
public static function token() {
20+
$tokens = Session::get('csrf_tokens', array());
21+
22+
$token = hash('md5', noise());
23+
24+
$tokens[] = $token;
25+
26+
Session::put('csrf_tokens', $tokens);
27+
28+
return $token;
29+
}
30+
31+
}

0 commit comments

Comments
 (0)