-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
2b23488
commit a06ba57
Showing
2 changed files
with
113 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,86 @@ | ||
<?php | ||
/** | ||
* Config\Database | ||
* PHP version 7 | ||
* | ||
* @category Database | ||
* @package Config | ||
* @author Bill Rocha <prbr@ymail.com> | ||
* @copyright 2016 Bill Rocha <http://google.com/+BillRocha> | ||
* @license <https://opensource.org/licenses/MIT> MIT | ||
* @version GIT: 0.0.1 | ||
* @link http://paulorocha.tk/devbr | ||
*/ | ||
|
||
namespace Config\Database; | ||
|
||
/** | ||
* Config\Database Class | ||
* | ||
* @category Database | ||
* @package Config | ||
* @author Bill Rocha <prbr@ymail.com> | ||
* @license <https://opensource.org/licenses/MIT> MIT | ||
* @link http://paulorocha.tk/devbr | ||
*/ | ||
class Blog | ||
{ | ||
static $config = [ | ||
'mysql'=>[ | ||
'dsn'=>'mysql:host=localhost;dbname=devbr_site;charset=utf8', | ||
'user'=>'devbr_site', | ||
'passw'=>'devbr#123'], | ||
'sqlite'=>['dsn'=>'sqlite.db'] | ||
]; | ||
static $default = 'mysql'; | ||
|
||
//Configuração da tabela de usuário | Lib\User | ||
static $userTable = ['table'=>'usuario', | ||
'id'=>'id', | ||
'name'=>'nome', | ||
'token'=>'token', | ||
'life'=>'vida', | ||
'login'=>'login', | ||
'password'=>'senha', | ||
'level'=>'nivel', | ||
'status'=>'status']; | ||
|
||
/** | ||
* Get Database configurations | ||
* | ||
* @param string $alias Database config name | ||
* | ||
* @return bool|array Array (or false) of the configurations | ||
*/ | ||
static function get($alias = null) | ||
{ | ||
if ($alias === null) { | ||
return static::$config[static::$default]; | ||
} | ||
if (isset(static::$config[$alias])) { | ||
return static::$config[$alias]; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Get default database configuration | ||
* | ||
* @return string Alias of the default configurated database | ||
*/ | ||
static function getDefault() | ||
{ | ||
return static::$default; | ||
} | ||
|
||
/** | ||
* Get user configuration | ||
* | ||
* @return array Array of user table configs. | ||
*/ | ||
static function getUserConfig() | ||
{ | ||
return static::$userTable; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
$router->respond('get', '/blog', 'Blog\Page::index') | ||
->respond('get', '/blog\?(.*)', 'Blog\Page::index') | ||
|
||
->respond('get', 'login', 'Blog\Page::login') | ||
->respond('get', 'perfil', 'Blog\Page::perfil') | ||
|
||
->respond('get', 'e/(?<id>(.*)?)', 'Blog\Page::edit') | ||
->respond('get', 'a/(?<id>.*?)', 'Blog\Page::view') | ||
|
||
//AJAX ---------- | ||
->respond('post', 'x/put', 'Blog\Ajax::put') | ||
->respond('post', 'x/save', 'Blog\Ajax::save') | ||
->respond('post', 'x/checklink', 'Blog\Ajax::checkLink') | ||
->respond('post', 'x/delete/(?<id>(\d+)?)', 'Blog\Ajax::delete') | ||
->respond('post', 'x/upload/(?<id>(\d+)?)', 'Blog\Ajax::upload') | ||
|
||
//USER for Facebook | ||
->respond('post', 'x/userlog', 'User\Facebook::userlog') | ||
|
||
//USERS | ||
->respond('get', 'u/(?<id>(.*)?)', 'User\Facebook::perfil') | ||
|
||
//ADMIN | ||
->respond('get', 'admin', 'Blog\Admin::index') | ||
->respond('get', 'admin/(\d+)/(\d+)/(\d+)', 'Blog\Admin::pagination'); |