diff --git a/.gitignore b/.gitignore index 88da7cf..4222c52 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,6 @@ # Project Files config/config.ini +phpunit.xml public/uploads/* tests/_reports/* diff --git a/Boxfile b/Boxfile new file mode 100644 index 0000000..d5c9948 --- /dev/null +++ b/Boxfile @@ -0,0 +1,20 @@ +web1: + name: liga-solidaria-storage + shared_writable_dirs: + - public/uploads + document_root: public + php_version: 5.4.14 + php_default_locale: "pt_BR" + php_date_timezone: "America/Sao_Paulo" + php_error_reporting: -1 + php_display_errors: "1" + php_extensions: + - zip + after_build: + - "if [ ! -f composer.phar ]; then curl -s http://getcomposer.org/installer | php; fi" + - "php composer.phar install --no-dev --optimize-autoloader" + - "cp config/config.ini.dist config/config.ini" + +db1: + name: liga-solidaria-storage + type: mysql diff --git a/Layout Liga 2.png b/Layout Liga 2.png new file mode 100644 index 0000000..239d803 Binary files /dev/null and b/Layout Liga 2.png differ diff --git a/composer.lock b/composer.lock index 861d818..2b0a416 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "776111f97941bc416eec0c1f76a993c5", + "hash": "c3ae5ea9ff94ac89a0f0035b6027d4ce", "packages": [ { "name": "respect/config", @@ -368,18 +368,67 @@ "description": "The most awesome validation engine ever created for PHP", "time": "2012-12-17 09:51:01" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ], + "time": "2013-08-30 12:35:21" + }, { "name": "twig/twig", - "version": "v1.13.2", + "version": "v1.14.1", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755" + "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755", - "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/8873d7593ad7c120004f177c0fd01459b383c9cb", + "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb", "shasum": "" }, "require": { @@ -388,7 +437,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -415,7 +464,7 @@ "keywords": [ "templating" ], - "time": "2013-08-03 15:35:31" + "time": "2013-10-15 19:17:38" } ], "packages-dev": [ @@ -482,16 +531,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.3.3", + "version": "1.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "16a78140ed2fc01b945cfa539665fadc6a038029" + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/16a78140ed2fc01b945cfa539665fadc6a038029", - "reference": "16a78140ed2fc01b945cfa539665fadc6a038029", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", "shasum": "" }, "require": { @@ -518,12 +567,12 @@ } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ "filesystem", "iterator" ], - "time": "2012-10-11 11:44:38" + "time": "2013-10-10 15:34:57" }, { "name": "phpunit/php-text-template", @@ -669,12 +718,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b024e753e3421837afbcca962c8724c58b39376" + "reference": "598a467a7d234dd78788cd72d5fd58105a1dfd0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b024e753e3421837afbcca962c8724c58b39376", - "reference": "4b024e753e3421837afbcca962c8724c58b39376", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/598a467a7d234dd78788cd72d5fd58105a1dfd0e", + "reference": "598a467a7d234dd78788cd72d5fd58105a1dfd0e", "shasum": "" }, "require": { @@ -735,7 +784,7 @@ "testing", "xunit" ], - "time": "2013-09-16 03:09:52" + "time": "2013-10-17 23:32:19" }, { "name": "phpunit/phpunit-mock-objects", @@ -788,16 +837,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "1.4.6", + "version": "1.4.7", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "a99caa52ed173ee83d6721ba012614f38c1dcbb6" + "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a99caa52ed173ee83d6721ba012614f38c1dcbb6", - "reference": "a99caa52ed173ee83d6721ba012614f38c1dcbb6", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/df764a1604607ea61c4eeea5410666e27cb37a8b", + "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b", "shasum": "" }, "require": { @@ -855,21 +904,21 @@ "phpcs", "standards" ], - "time": "2013-07-25 03:49:02" + "time": "2013-09-26 00:08:21" }, { "name": "symfony/yaml", - "version": "v2.3.4", + "version": "v2.3.6", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" + "reference": "6bb881b948368482e1abf1a75c08bcf88a1c5fc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", - "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/6bb881b948368482e1abf1a75c08bcf88a1c5fc3", + "reference": "6bb881b948368482e1abf1a75c08bcf88a1c5fc3", "shasum": "" }, "require": { @@ -902,7 +951,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-08-24 15:26:22" + "time": "2013-09-22 18:04:39" } ], "aliases": [ diff --git a/config/config.ini.dist b/config/config.ini.dist index dd4e77d..cdbac3e 100644 --- a/config/config.ini.dist +++ b/config/config.ini.dist @@ -11,6 +11,11 @@ default_charset = 'UTF-8' view_path = '../templates/' +; Login credentials + +user = 'admin' +pass = '123456' + ; Database parameteres db_driver = "mysql" diff --git a/data/db.sql b/data/db.sql new file mode 100644 index 0000000..4209765 --- /dev/null +++ b/data/db.sql @@ -0,0 +1,19 @@ +-- Database: Liga Solidaria Storage + +CREATE DATABASE `liga`; + +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(40) NOT NULL, + `password` varchar(40) NOT NULL, + `email` varchar(100) NOT NULL, + `group_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `group` (`group_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `group` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSE=utf8; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 25cbb5f..e5cf04f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/public/index.php b/public/index.php index 3922375..56e60dc 100644 --- a/public/index.php +++ b/public/index.php @@ -4,14 +4,22 @@ use Respect\Rest\Router; +$auth = new LigaSolidariaStorage\Routine\Auth; +$authenticated = function() use($auth) {return $auth();}; $r = new Router; $r->isAutoDispatched = false; -$r->any('/', 'LigaSolidariaStorage\Storage\Controller\HomeController'); +$r->any('/login', 'LigaSolidariaStorage\Storage\Controller\Login'); +$r->get('/logout', 'LigaSolidariaStorage\Storage\Controller\Logout'); -$r->get('/list/*', 'LigaSolidariaStorage\Storage\Controller\ArtefatoListController' ); +$r->any('/', 'LigaSolidariaStorage\Storage\Controller\HomeController') + ->by($authenticated); -$r->any('/upload', 'LigaSolidariaStorage\Storage\Controller\ArtefatoUploadController'); +$r->get('/list/*', 'LigaSolidariaStorage\Storage\Controller\ArtefatoListController' ) + ->by($authenticated); + +$r->any('/upload', 'LigaSolidariaStorage\Storage\Controller\ArtefatoUploadController') + ->by($authenticated); $r->any('/contact', 'LigaSolidariaStorage\Storage\Controller\ContactController', array($c->mailer)); diff --git a/src/LigaSolidariaStorage/Routine/Auth.php b/src/LigaSolidariaStorage/Routine/Auth.php new file mode 100644 index 0000000..b30ab4f --- /dev/null +++ b/src/LigaSolidariaStorage/Routine/Auth.php @@ -0,0 +1,23 @@ + 'login.html.twig'); + } + + public function post() + { + try { + $vars = array('_view'=>'index.html.twig'); + $email = filter_input(INPUT_POST, 'email'); + $pass = filter_input(INPUT_POST, 'password'); + + if (empty($email) || empty($pass)) { + throw new Argument('Email ou senha inválidos'); + } + + $_SESSION['email'] = $_POST['email']; + + header('Location: /'); + + } catch(Argument $e) { + $vars['message'] = $e->getMessage(); + return $vars; + } + } +} diff --git a/src/LigaSolidariaStorage/Storage/Controller/Logout.php b/src/LigaSolidariaStorage/Storage/Controller/Logout.php new file mode 100644 index 0000000..85ee12f --- /dev/null +++ b/src/LigaSolidariaStorage/Storage/Controller/Logout.php @@ -0,0 +1,14 @@ + Contato +
  • + Logout +
  • diff --git a/templates/login.html.twig b/templates/login.html.twig new file mode 100644 index 0000000..595ab98 --- /dev/null +++ b/templates/login.html.twig @@ -0,0 +1,16 @@ + + + + + +
    + + + + + + + +
    + +