<commit_before><?php
require_once 'Vps/Loader.php';
Vps_Loader::registerAutoload();

function p($src, $max_depth = 5) {
    ini_set('xdebug.var_display_max_depth', $max_depth);
    if(function_exists('xdebug_var_dump')) {
        xdebug_var_dump($src);
    } else {
        echo "<pre>";
        var_dump($src);
        echo "</pre>";
    }
}

function d($src, $max_depth = 5)
{
    p($src, $max_depth);
    exit;
}

class Vps_Controller_Front extends Zend_Controller_Front
{
    public static function setUp()
    {
        error_reporting(E_ALL);
        date_default_timezone_set('Europe/Berlin');
        set_error_handler(array('Vps_Debug', 'handleError'), E_ALL);
        Zend_Registry::set('config', Vps_Setup::createConfig());
    }

    public static function setUpDb()
    {
        $dao = new Vps_Dao(new Zend_Config_Ini('application/config.db.ini', 'database'));
        Zend_Registry::set('dao', $dao);
        $db = $dao->getDb();
        $db->query('SET names UTF8');
        Zend_Registry::set('db', $db);
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
    }

    public static function getInstance($isComponentsWeb = true)
    {
        self::setUp();
        $front = parent::getInstance();

        Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
        Zend_Controller_Action_HelperBroker::addHelper(new Vps_Controller_Action_Helper_ViewRenderer());

        $front->setControllerDirectory('application/controllers');
        $front->returnResponse(true);

        $router = $front->getRouter();
        if ($isComponentsWeb) {
            $front->setDispatcher(new Vps_Controller_Dispatcher());

            $router->AddRoute('default', new Zend_Controller_Router_Route('*', array('controller' => 'web', 'action' => 'index')));
            $router->AddRoute('ajax', new Zend_Controller_Router_Route('ajax/*', array('controller' => 'web', 'action' => 'ajax')));
            $router->AddRoute('ajaxfe', new Zend_Controller_Router_Route('ajax/fe/:action', array('controller' => 'fe', 'action' => 'action')));
            $router->AddRoute('admin', new Zend_Controller_Router_Route('admin/:controller/:action', array('module' => 'admin', 'controller' => 'index', 'action' => 'index')));
            $router->AddRoute('login', new Zend_Controller_Router_Route('login/:action', array('module' => 'admin', 'controller' => 'login', 'action' => 'index')));
            $router->AddRoute('menu', new Zend_Controller_Router_Route('menu/:action', array('module' => 'admin', 'controller' => 'menu', 'action' => 'index')));

            $router->AddRoute('components', new Zend_Controller_Router_Route('components/:action', array('module' => 'admin', 'controller' => 'components', 'action' => 'index')));
            $router->AddRoute('componentshow', new Zend_Controller_Router_Route('component/:action/:class/:componentId', array('module' => 'admin', 'controller' => 'components', 'action' => 'show')));
            $router->AddRoute('componentedit', new Zend_Controller_Router_Route('component/edit/:class/:componentId/:action', array('module' => 'component', 'controller' => 'Index', 'action' => 'index')));
            $router->AddRoute('componentsetup', new Zend_Controller_Router_Route('component/setup/:class', array('module' => 'admin', 'controller' => 'components', 'action' => 'setup')));
            $router->AddRoute('media', new Zend_Controller_Router_Route('media/:uploadId/:componentId/:checksum/:filename', array('controller' => 'Media', 'action' => 'password')));
            $router->AddRoute('mediaoriginal', new Zend_Controller_Router_Route('media/:uploadId', array('controller' => 'Media', 'action' => 'original')));

            $plugin = new Zend_Controller_Plugin_ErrorHandler();
            $plugin->setErrorHandlerModule('admin');
            $front->registerPlugin($plugin);

            self::setUpDb();

            // ACL
            $acl = new Vps_Acl();

            // Roles
            $acl->addRole(new Vps_Acl_Role('member'), 'guest');
            $acl->addRole(new Vps_Acl_Role('admin'), 'member');

            // Resources
            $acl->add(new Zend_Acl_Resource('web'));
            $acl->add(new Zend_Acl_Resource('media'));
            $acl->add(new Zend_Acl_Resource('mediaoriginal'));
            $acl->add(new Zend_Acl_Resource('fe'));
            $acl->add(new Vps_Acl_Resource_MenuDropdown('admin', 'Admin'));
            $acl->add(new Vps_Acl_Resource_MenuCommand(
                'pages',
                array('text' => 'Sitetree', 'icon' => 'application_side_tree.png'),
                'Vps.Component.Pages',
                array('controllerUrl'=>'/admin/pages/'))
            );
            $acl->add(new Zend_Acl_Resource('pageedit'), 'admin');
            $acl->add(new Zend_Acl_Resource('components', 'Komponentenübersicht',
                                            '/admin/components/'), 'admin'); // für /component/show
            $acl->add(new Zend_Acl_Resource('component'), 'admin'); // für /component/edit

            // Berechtigungen
            $acl->allow('admin', 'web');
            $acl->allow('admin', 'fe');
            $acl->allow('admin', 'admin');
            $acl->allow('admin', 'pages');
            $acl->allow('member', 'fe');
            $acl->allow('guest', 'web');
            $acl->allow('guest', 'media');
            $acl->allow('admin', 'mediaoriginal');

            Zend_Registry::set('acl', $acl);
        }

        return $front;
    }
}<commit_msg>- routen lesbarer gemacht - member erbt nicht mehr von guest, weil er sonst die index-seite nicht sehen darf<commit_after><?php
require_once 'Vps/Loader.php';
Vps_Loader::registerAutoload();

function p($src, $max_depth = 5) {
    ini_set('xdebug.var_display_max_depth', $max_depth);
    if(function_exists('xdebug_var_dump')) {
        xdebug_var_dump($src);
    } else {
        echo "<pre>";
        var_dump($src);
        echo "</pre>";
    }
}

function d($src, $max_depth = 5)
{
    p($src, $max_depth);
    exit;
}

class Vps_Controller_Front extends Zend_Controller_Front
{
    public static function setUp()
    {
        error_reporting(E_ALL);
        date_default_timezone_set('Europe/Berlin');
        set_error_handler(array('Vps_Debug', 'handleError'), E_ALL);
        Zend_Registry::set('config', Vps_Setup::createConfig());
    }

    public static function setUpDb()
    {
        $dao = new Vps_Dao(new Zend_Config_Ini('application/config.db.ini', 'database'));
        Zend_Registry::set('dao', $dao);
        $db = $dao->getDb();
        $db->query('SET names UTF8');
        Zend_Registry::set('db', $db);
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
    }

    public static function getInstance($isComponentsWeb = true)
    {
        self::setUp();
        $front = parent::getInstance();

        Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
        Zend_Controller_Action_HelperBroker::addHelper(new Vps_Controller_Action_Helper_ViewRenderer());

        $front->setControllerDirectory('application/controllers');
        $front->returnResponse(true);

        $router = $front->getRouter();
        if ($isComponentsWeb) {
            $front->setDispatcher(new Vps_Controller_Dispatcher());

            $router->AddRoute('default', new Zend_Controller_Router_Route(
                        '*',
                        array('controller' => 'web',
                              'action' => 'index')));
            $router->AddRoute('ajax', new Zend_Controller_Router_Route(
                        'ajax/*',
                        array('controller' => 'web',
                              'action' => 'ajax')));
            $router->AddRoute('ajaxfe', new Zend_Controller_Router_Route(
                        'ajax/fe/:action',
                        array('controller' => 'fe',
                              'action' => 'action')));
            $router->AddRoute('admin', new Zend_Controller_Router_Route(
                        'admin/:controller/:action',
                        array('module' => 'admin',
                              'controller' => 'index',
                              'action' => 'index')));
            $router->AddRoute('login', new Zend_Controller_Router_Route(
                        'login/:action',
                        array('module' => 'admin',
                              'controller' => 'login',
                              'action' => 'index')));
            $router->AddRoute('menu', new Zend_Controller_Router_Route(
                        'menu/:action',
                        array('module' => 'admin',
                              'controller' => 'menu',
                              'action' => 'index')));

            $router->AddRoute('components', new Zend_Controller_Router_Route(
                        'components/:action',
                        array('module' => 'admin',
                              'controller' => 'components',
                              'action' => 'index')));
            $router->AddRoute('componentshow', new Zend_Controller_Router_Route(
                        'component/:action/:class/:componentId',
                        array('module' => 'admin',
                              'controller' => 'components',
                              'action' => 'show')));
            $router->AddRoute('componentedit', new Zend_Controller_Router_Route(
                        'component/edit/:class/:componentId/:action',
                        array('module' => 'component',
                              'controller' => 'Index',
                              'action' => 'index')));
            $router->AddRoute('componentsetup', new Zend_Controller_Router_Route(
                        'component/setup/:class',
                        array('module' => 'admin',
                              'controller' => 'components',
                              'action' => 'setup')));

            $router->AddRoute('media', new Zend_Controller_Router_Route(
                        'media/:uploadId/:componentId/:checksum/:filename',
                        array('controller' => 'Media',
                              'action' => 'password')));
            $router->AddRoute('mediaoriginal', new Zend_Controller_Router_Route(
                        'media/:uploadId',
                        array('controller' => 'Media',
                        'action' => 'original')));

            $plugin = new Zend_Controller_Plugin_ErrorHandler();
            $plugin->setErrorHandlerModule('admin');
            $front->registerPlugin($plugin);

            self::setUpDb();

            // ACL
            $acl = new Vps_Acl();

            // Roles
            $acl->addRole(new Vps_Acl_Role('member'));
            $acl->addRole(new Vps_Acl_Role('admin'), 'member');

            // Resources
            $acl->add(new Zend_Acl_Resource('web'));
            $acl->add(new Zend_Acl_Resource('media'));
            $acl->add(new Zend_Acl_Resource('mediaoriginal'));
            $acl->add(new Zend_Acl_Resource('fe'));
            $acl->add(new Vps_Acl_Resource_MenuDropdown('admin', 'Admin'));
            $acl->add(new Vps_Acl_Resource_MenuCommand(
                'pages',
                array('text' => 'Sitetree', 'icon' => 'application_side_tree.png'),
                'Vps.Component.Pages',
                array('controllerUrl'=>'/admin/pages/'))
            );
            $acl->add(new Zend_Acl_Resource('pageedit'), 'admin');
            $acl->add(new Zend_Acl_Resource('components', 'Komponentenübersicht',
                                            '/admin/components/'), 'admin'); // für /component/show
            $acl->add(new Zend_Acl_Resource('component'), 'admin'); // für /component/edit

            // Berechtigungen
            $acl->allow('admin', 'web');
            $acl->allow('admin', 'fe');
            $acl->allow('admin', 'admin');
            $acl->allow('admin', 'pages');
            $acl->allow('member', 'fe');
            $acl->allow('guest', 'web');
            $acl->allow('guest', 'media');
            $acl->allow('admin', 'mediaoriginal');

            Zend_Registry::set('acl', $acl);
        }

        return $front;
    }
}
{'fraction_non_alphanumeric': 0.15944582365660287, 'fraction_numerical': 0.00048049971970849685, 'mean_word_length': 2.077378018728438, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 153, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3480572', 'n_tokens_mistral': 3474, 'n_tokens_neox': 3337, 'n_words': 527}