-
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 972c514
Showing
120 changed files
with
29,521 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,31 @@ | ||
Copyright (c) 2014-2016, Humberto Lourenço <betto@m3uzz.com>. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
|
||
* Neither the name of Humberto Lourenço nor the names of his | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
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,51 @@ | ||
{ | ||
"name": "m3uzz/onionfw", | ||
"description": "Onion CMS", | ||
"homepage": "http://onion.m3uzz.com/", | ||
"license": "BSD-3-Clause", | ||
"authors": [ | ||
{ | ||
"name": "Humberto S Lourenco", | ||
"email": "betto@m3uzz.com" | ||
} | ||
], | ||
"keywords": [ | ||
"m3uzz", | ||
"onion", | ||
"onionfw", | ||
"cms", | ||
"framework" | ||
], | ||
"type": "library", | ||
"repositories": [ | ||
{ | ||
"type": "package", | ||
"package": { | ||
"name": "m3uzz/onionfw", | ||
"version": "master", | ||
"dist": { | ||
"url": "https://github.com/m3uzz/onionfw/archive/master.zip", | ||
"type": "zip" | ||
}, | ||
"source": { | ||
"url": "https://github.com/m3uzz/onionfw.git", | ||
"type": "git", | ||
"reference": "master" | ||
} | ||
} | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4", | ||
"m3uzz/onionlib": "master" | ||
}, | ||
"require-dev": { | ||
}, | ||
"suggest": { | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Onion\\": "src/" | ||
} | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository | ||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
/** | ||
* This autoloading setup is really more complicated than it needs to be for most | ||
* applications. The added complexity is simply to reduce the time it takes for | ||
* new developers to be productive with a fresh skeleton. It allows autoloading | ||
* to be correctly configured, regardless of the installation method and keeps | ||
* the use of composer completely optional. This setup should work fine for | ||
* most users, however, feel free to configure autoloading however you'd like. | ||
*/ | ||
|
||
// Composer autoloading | ||
if (file_exists('vendor/autoload.php')) { | ||
$loader = include 'vendor/autoload.php'; | ||
} | ||
|
||
if (class_exists('Zend\Loader\AutoloaderFactory')) { | ||
return; | ||
} | ||
|
||
$zf2Path = false; | ||
|
||
if (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable | ||
$zf2Path = getenv('ZF2_PATH'); | ||
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value | ||
$zf2Path = get_cfg_var('zf2_path'); | ||
} | ||
|
||
if ($zf2Path) { | ||
if (isset($loader)) { | ||
$loader->add('Zend', $zf2Path); | ||
$loader->add('ZendXml', $zf2Path); | ||
} else { | ||
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; | ||
Zend\Loader\AutoloaderFactory::factory(array( | ||
'Zend\Loader\StandardAutoloader' => array( | ||
'autoregister_zf' => true | ||
) | ||
)); | ||
} | ||
} | ||
|
||
if (!class_exists('Zend\Loader\AutoloaderFactory')) { | ||
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); | ||
} |
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 | ||
/** | ||
* This file is part of Onion | ||
* | ||
* Copyright (c) 2014-2016, Humberto Lourenço <betto@m3uzz.com>. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* * Neither the name of Humberto Lourenço nor the names of his | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @category PHP | ||
* @package Onion | ||
* @author Humberto Lourenço <betto@m3uzz.com> | ||
* @copyright 2014-2016 Humberto Lourenço <betto@m3uzz.com> | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License | ||
* @link http://github.com/m3uzz/onionfw | ||
*/ | ||
|
||
defined('DS') || define('DS', DIRECTORY_SEPARATOR); | ||
defined('PS') || define('PS', PATH_SEPARATOR); | ||
defined('EOF') || define('EOF', chr(13).chr(10)); | ||
|
||
defined('BASE_DIR') || define('BASE_DIR', realpath(dirname(dirname(dirname(__DIR__))))); | ||
defined('CLIENT_DIR') || define('CLIENT_DIR', BASE_DIR . DS . 'client'); | ||
|
||
defined('REQUEST_MICROTIME') || define('REQUEST_MICROTIME', microtime(true)); | ||
|
||
|
||
// Define application environment | ||
defined('APP_ENV') || define('APP_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); | ||
|
||
|
||
// Display all errors when APPLICATION_ENV is development. | ||
if(APP_ENV === 'development') | ||
{ | ||
error_reporting(E_ALL); | ||
ini_set("display_errors", 1); | ||
} | ||
|
||
|
||
// Decline static file requests back to the PHP built-in webserver | ||
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { | ||
return false; | ||
} | ||
|
||
|
||
// Setup autoloading | ||
require 'init_autoloader.php'; | ||
|
||
try | ||
{ | ||
$goApp = Onion\Application\Application::getInstance(); | ||
$goApp->init(require 'config/application.config.php'); | ||
$goApp->run(); | ||
//Onion\Log\Debug::display($goApp->toArray()); | ||
} | ||
catch (Exception $e) | ||
{ | ||
include BASE_DIR . DS . 'layout' . DS . 'theme' . DS . 'exception' . DS . 'error.phtml'; | ||
} |
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,165 @@ | ||
<?php | ||
/** | ||
* This file is part of Onion | ||
* | ||
* Copyright (c) 2014-2016, Humberto Lourenço <betto@m3uzz.com>. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* * Neither the name of Humberto Lourenço nor the names of his | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @category PHP | ||
* @package Onion | ||
* @author Humberto Lourenço <betto@m3uzz.com> | ||
* @copyright 2014-2016 Humberto Lourenço <betto@m3uzz.com> | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License | ||
* @link http://github.com/m3uzz/onionfw | ||
*/ | ||
|
||
namespace Onion\Acl; | ||
use \Zend\Permissions\Acl\Acl as ZendAcl; | ||
use \Zend\Permissions\Acl\Role\GenericRole as Role; | ||
use \Zend\Permissions\Acl\Resource\GenericResource as Resource; | ||
|
||
class Acl extends ZendAcl | ||
{ | ||
|
||
/** | ||
* Default Role | ||
*/ | ||
const DEFAULT_ROLE = 'guest'; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param array $config | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function __construct ($paConfig) | ||
{ | ||
if (!isset($paConfig['acl']['roles']) || !isset($paConfig['acl']['resources'])) | ||
{ | ||
throw new \Exception('Invalid ACL Config found'); | ||
} | ||
|
||
$laRoles = $paConfig['acl']['roles']; | ||
|
||
if (! isset($laRoles[self::DEFAULT_ROLE])) | ||
{ | ||
$laRoles[self::DEFAULT_ROLE] = ''; | ||
} | ||
|
||
$this->_addRoles($laRoles); | ||
$this->_addResources($paConfig['acl']['resources']); | ||
} | ||
|
||
/** | ||
* Adds Roles to ACL | ||
* | ||
* @param array $roles | ||
* @return User\Acl | ||
*/ | ||
protected function _addRoles (array $paRoles) | ||
{ | ||
foreach ($paRoles as $lsName => $lsParent) | ||
{ | ||
if (!$this->hasRole($lsName)) | ||
{ | ||
if (empty($lsParent)) | ||
{ | ||
$lsParent = array(); | ||
} | ||
else | ||
{ | ||
$lsParent = explode(',', $lsParent); | ||
} | ||
|
||
$this->addRole(new Role($lsName), $lsParent); | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Adds Resources to ACL | ||
* | ||
* @param | ||
* $resources | ||
* @return User\Acl | ||
* @throws \Exception | ||
*/ | ||
protected function _addResources (array $paResources) | ||
{ | ||
foreach ($paResources as $lsPermission => $laControllers) | ||
{ | ||
if (is_array($laControllers)) | ||
{ | ||
foreach ($laControllers as $lsController => $laActions) | ||
{ | ||
if ($lsController == 'all') | ||
{ | ||
$lsController = null; | ||
} | ||
else | ||
{ | ||
if (!$this->hasResource($lsController)) | ||
{ | ||
$this->addResource(new Resource($lsController)); | ||
} | ||
} | ||
|
||
foreach ($laActions as $lsAction => $lsRole) | ||
{ | ||
if ($lsAction == 'all') | ||
{ | ||
$lsAction = null; | ||
} | ||
|
||
if ($lsPermission == 'allow') | ||
{ | ||
$this->allow($lsRole, $lsController, $lsAction); | ||
} | ||
elseif ($lsPermission == 'deny') | ||
{ | ||
$this->deny($lsRole, $lsController, $lsAction); | ||
} | ||
else | ||
{ | ||
throw new \Exception('No valid permission defined: ' . $lsPermission); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.