From a06ba57d3096b755899ab199c1308252694fc067 Mon Sep 17 00:00:00 2001 From: BlackScorpion Date: Wed, 9 Aug 2017 22:13:49 -0300 Subject: [PATCH] Add Config files --- Config/Database/Blog.php | 86 ++++++++++++++++++++++++++++++++++++++++ Config/Routers/Blog.php | 27 +++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 Config/Database/Blog.php create mode 100644 Config/Routers/Blog.php diff --git a/Config/Database/Blog.php b/Config/Database/Blog.php new file mode 100644 index 0000000..c01ab26 --- /dev/null +++ b/Config/Database/Blog.php @@ -0,0 +1,86 @@ + + * @copyright 2016 Bill Rocha + * @license MIT + * @version GIT: 0.0.1 + * @link http://paulorocha.tk/devbr + */ + +namespace Config\Database; + +/** + * Config\Database Class + * + * @category Database + * @package Config + * @author Bill Rocha + * @license 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; + } +} diff --git a/Config/Routers/Blog.php b/Config/Routers/Blog.php new file mode 100644 index 0000000..8d468b6 --- /dev/null +++ b/Config/Routers/Blog.php @@ -0,0 +1,27 @@ +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/(?(.*)?)', 'Blog\Page::edit') + ->respond('get', 'a/(?.*?)', '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/(?(\d+)?)', 'Blog\Ajax::delete') + ->respond('post', 'x/upload/(?(\d+)?)', 'Blog\Ajax::upload') + + //USER for Facebook + ->respond('post', 'x/userlog', 'User\Facebook::userlog') + + //USERS + ->respond('get', 'u/(?(.*)?)', 'User\Facebook::perfil') + + //ADMIN + ->respond('get', 'admin', 'Blog\Admin::index') + ->respond('get', 'admin/(\d+)/(\d+)/(\d+)', 'Blog\Admin::pagination'); \ No newline at end of file