示例#1
0
 public function afterDispatch(MvcEvent $e)
 {
     $controllerName = $e->getRouteMatch()->getMatchedRouteName();
     if ($controllerName != 'login' && ($controllerName != 'application' && $controllerName != 'home')) {
         $containerSession = new \Zend\Session\Container('cbol');
         $e->getTarget()->layout()->repo = $containerSession->reportesVias;
         $e->getTarget()->layout()->acceso = $containerSession->permisosUser;
         $e->getTarget()->layout()->suge = $containerSession->sugerencias;
         $auth = new \Zend\Authentication\AuthenticationService();
         $response = $e->getResponse();
         if (!$auth->hasIdentity()) {
             $url = $e->getRequest()->getBaseUrl() . '/login';
             $response->getHeaders()->addHeaderLine('Location', $url);
             $response->setStatusCode(302);
             $response->sendHeaders();
             return $response;
         } else {
             $localAcl = new \Login\Model\permisos();
             if (!$localAcl->isAllowed($auth->getIdentity()->perfil_id, $controllerName)) {
                 $this->onDispatchError($e, $controllerName);
             } elseif (is_null($containerSession->idSession)) {
                 $url = $e->getRequest()->getBaseUrl() . '/login/logout';
                 $response->getHeaders()->addHeaderLine('Location', $url);
                 $response->setStatusCode(302);
                 $response->sendHeaders();
                 return $response;
             } elseif ($e->getResponse()->getStatusCode() == 403) {
                 $this->onDispatchError($e, $controllerName);
             }
         }
     }
 }
示例#2
0
 /**
  * Método que verifica se o usuario está logado
  * @param type $e
  */
 public function validaAutenticacao($e)
 {
     $authenticateService = new \Zend\Authentication\AuthenticationService();
     $authenticateService->setStorage(new \Zend\Authentication\Storage\Session("Semente"));
     $sessao = new \Zend\Session\Container("Semente");
     $controller = $e->getTarget();
     $em = $controller->getServiceLocator()->get('ZeDbManager');
     $rotaAcessada = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
     //erro 404: http://pensadores.local:8080/colunas/pensando-cabeca/100
     /** Liberando rota para não precisar de autenticação */
     $rota_livre = in_array($rotaAcessada, ['acesso/login', 'acesso/logout', 'acesso/nao-autorizado']);
     if ($rota_livre) {
         return true;
     } else {
         if (!$authenticateService->hasIdentity()) {
             $controller->redirect()->toRoute("acesso/login");
         } else {
             $controlador = $controller->params()->fromRoute('controller');
             $action = $controller->params()->fromRoute('action');
             $user = $authenticateService->getIdentity()['cliente'];
             $esta_autorizado = TRUE;
             if (!$esta_autorizado) {
                 return $controller->redirect()->toRoute("acesso/nao-autorizado", array('controlador' => $controlador, 'acao' => $action));
             }
         }
     }
 }
示例#3
0
 /**
  * @dataProvider authenticationDataProvider
  */
 public function testRouteAuthentication($requestMethod, $path, $location, $hasIdentity, $identity, $httpStatus)
 {
     \Slim\Environment::mock(array('REQUEST_METHOD' => $requestMethod, 'PATH_INFO' => $path));
     $this->auth->expects($this->once())->method('hasIdentity')->will($this->returnValue($hasIdentity));
     $this->auth->expects($this->once())->method('getIdentity')->will($this->returnValue($identity));
     $app = new \Slim\Slim(array('debug' => false));
     $app->error(function (\Exception $e) use($app) {
         // Example of handling Auth Exceptions
         if ($e instanceof AuthException) {
             $app->response->setStatus($e->getCode());
             $app->response->setBody($e->getMessage());
         }
     });
     $app->get('/', function () {
     });
     $app->get('/member', function () {
     });
     $app->delete('/member/photo/:id', function ($id) {
     });
     $app->get('/admin', function () {
     });
     $app->map('/login', function () {
     })->via('GET', 'POST')->name('login');
     $app->add($this->middleware);
     ob_start();
     $app->run();
     ob_end_clean();
     $this->assertEquals($httpStatus, $app->response->status());
     $this->assertEquals($location, $app->response->header('location'));
 }
 function coreAuth(&$adapter, &$authService)
 {
     $dbAdapter = new \Zend\Db\Adapter\Adapter(array('driver' => 'Pdo', 'username' => 'kevin', 'password' => '123456', 'dsn' => 'mysql:dbname=bd_grupos;host=192.168.1.50', 'driver_options' => array()));
     $adapter = new \Zend\Authentication\AuthenticationService();
     $authService = new \Zend\Authentication\Adapter\DbTable($dbAdapter, 'ta_usuario', 'va_nombre', 'va_contrasena');
     $adapter->setStorage(new \Zend\Authentication\Storage\Session('Auth'));
     $adapter->setAdapter($authService);
 }
示例#5
0
文件: Module.php 项目: ram600/vasabi
 public function getServiceConfig()
 {
     return array('factories' => array('auth-storage' => function ($sm) {
         return new \Sticks\Storage\Auth('user_auth');
     }, 'auth-service' => function ($sm) {
         $doctrineAdapter = $adapter = new \Custom\Auth\Adapter\Doctrine(null, '\\Sticks\\Model\\User', 'email', 'password', 'md5');
         $authService = new \Zend\Authentication\AuthenticationService();
         $authService->setAdapter($doctrineAdapter);
         $authService->setStorage($sm->get('auth-storage'));
         //$authService->setStorage(new \Zend\Authentication\Storage\Session('vasabi-auth'));
         return $authService;
     }, 'user-session' => function ($sm) {
     }));
 }
示例#6
0
 public function getControllerConfig()
 {
     return array('initializers' => array(), 'factories' => array('Indicateur\\Controller\\ScoreAjax' => function ($sm) {
         $authService = new \Zend\Authentication\AuthenticationService();
         if ($authService->hasIdentity()) {
             // Identity exists; get it
             $etabId = $authService->getIdentity()->et_code_fk;
             $puiId = $authService->getIdentity()->pui_code_fk;
             $userId = $authService->getIdentity()->user_code_pk;
         }
         $controller = new \Indicateur\Controller\ScoreAjaxController();
         $controller->setEtabId($etabId);
         $controller->setPuiId($puiId);
         $controller->setUserId($userId);
         // $locator = $sm->getServiceLocator();
         // $controller->setCommentForm($locator->get('commentForm'));
         // $controller->setCommentService($locator->get('commentService'));
         return $controller;
     }));
 }
 /**
  * Registers Slim Auth services on the given container.
  *
  * @param Container $pimple A container instance
  */
 public function register(Container $pimple)
 {
     // This must be set to true or Slim Auth will not work.
     // @see https://github.com/marcelbonnet/slim-auth/issues/37
     $pimple['settings']['determineRouteBeforeAppMiddleware'] = true;
     $pimple['auth'] = function ($c) {
         $auth = new \Zend\Authentication\AuthenticationService();
         $auth->setAdapter($c->get('authAdapter'));
         if ($c->has('authStorage')) {
             $auth->setStorage($c->get('authStorage'));
         }
         return $auth;
     };
     $pimple['redirectHandler'] = function ($c) {
         $redirectNotAuthenticated = '/login';
         $redirectNotAuthorized = '/403';
         if (isset($c['redirectNotAuthenticated'])) {
             $redirectNotAuthenticated = $c['redirectNotAuthenticated'];
         }
         if (isset($c['redirectNotAuthorized'])) {
             $redirectNotAuthorized = $c['redirectNotAuthorized'];
         }
         return new \marcelbonnet\Slim\Auth\Handlers\RedirectHandler($redirectNotAuthenticated, $redirectNotAuthorized);
     };
     $pimple['throwHttpExceptionHandler'] = function ($c) {
         return new \marcelbonnet\Slim\Auth\Handlers\ThrowHttpExceptionHandler();
     };
     $pimple['slimAuthRedirectMiddleware'] = function ($c) {
         return new \marcelbonnet\Slim\Auth\Middleware\Authorization($c->get('auth'), $c->get('acl'), $c->get('redirectHandler'));
     };
     $pimple['slimAuthThrowHttpExceptionMiddleware'] = function ($c) {
         return new \marcelbonnet\Slim\Auth\Middleware\Authorization($c->get('auth'), $c->get('acl'), $c->get('throwHttpExceptionHandler'));
     };
     $pimple['authenticator'] = function ($c) {
         return new \marcelbonnet\Slim\Auth\Authenticator($c->get('auth'));
     };
 }
示例#8
0
文件: Helper.php 项目: arbi/MyCode
 public static function setLog($type, $value, $old = false, $object = false)
 {
     if ($type == 'commentWithoutData' && '' == $value) {
         return '';
     }
     $authService = new \Zend\Authentication\AuthenticationService();
     $auth = $authService->getIdentity();
     $logger = $auth->firstname . ' ' . $auth->lastname;
     $timestamp = date('Y-m-d H:i:s');
     $log = '';
     if ($type == 'checkbox') {
         if ($value == $old) {
             return '';
         }
         $action = 1 == $old ? 'Checked' : 'Unchecked';
         $log = "|| {$object} || {$action} ----\n\n";
     } elseif ($type == 'comment') {
         $value = trim($value);
         if ('' == $value) {
             return '';
         }
         $timestamp = date('Y-m-d H:i:s');
         $log = "|| Comment ----\n{$value}\n\n";
     } elseif ($type == 'other') {
         $log = "|| {$value} ----\n\n";
     } elseif ($type == 'commentWithoutData') {
         return "\n\n{$value}\n\n";
     }
     return "---- {$timestamp} (Amsterdam Time) || {$logger} {$log}";
 }
示例#9
0
 /**
  *
  * @return Ambigous <\Zend\Http\Response, \Zend\Stdlib\ResponseInterface>
  */
 public function quitAction()
 {
     $authService = new \Zend\Authentication\AuthenticationService();
     $authService->clearIdentity();
     return $this->redirect()->toRoute('application/child', array('controller' => 'signin', 'action' => 'index'));
 }
示例#10
0
 public function editarlocalAction()
 {
     $auth = new \Zend\Authentication\AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/usuario/index/login');
     }
     $id = (int) $this->params()->fromQuery('id', 0);
     $idrest = (int) $this->params()->fromRoute('in_id', 0);
     if (!$id) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local/index/agregarlocal');
     }
     try {
         $local = $this->getLocalTable()->getLocal($id);
         //->toArray();
     } catch (\Exception $ex) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local');
     }
     $form = new LocalForm();
     $servi = $this->getUbigeoTable()->getServicios();
     $array = array();
     foreach ($servi as $y) {
         $array[$y['in_id']] = $y['va_nombre'];
     }
     $form->get('servicio')->setValueOptions($array);
     $form->get('pais')->setValue($local['in_idpais']);
     $hiddenpais = new Element\Hidden('h_pais');
     $hiddenpais->setValue($local['in_idpais']);
     $hiddenpais->setAttribute('id', 'h_pais');
     $form->add($hiddenpais);
     $hiddendepa = new Element\Hidden('h_departamento');
     $hiddendepa->setValue($local['in_iddep']);
     $hiddendepa->setAttribute('id', 'h_departamento');
     $form->add($hiddendepa);
     $hiddenprov = new Element\Hidden('h_provincia');
     $hiddenprov->setValue($local['in_idprov']);
     $hiddenprov->setAttribute('id', 'h_provincia');
     $form->add($hiddenprov);
     $hiddendist = new Element\Hidden('h_distrito');
     $hiddendist->setValue($local['in_iddis']);
     $hiddendist->setAttribute('id', 'h_distrito');
     $form->add($hiddendist);
     $form->bind($local);
     $form->get('submit')->setAttribute('value', 'MODIFICAR');
     $request = $this->getRequest();
     //$this->getLocalTable()->editarLocal($id,$data);
     if ($request->isPost()) {
         $aux = $this->getRequest()->getPost()->toArray();
         $this->getLocalTable()->editarLocal($aux, $id);
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/local/index/index/' . $idrest);
         //           $form->setInputFilter($local->getInputFilter());
         //            $form->setData($request->getPost());
         //
         //            $servicio = $this->params()->fromPost('servicio');
         //
         //            if ($form->isValid()) {
         //
         //                $this->getLocalTable()->editarLocal($id,$local);//guardarLocal($local, $servicio);
         //
         //                return $this->redirect()->toUrl($this->
         //                                        getRequest()->getBaseUrl() . '/local/index/index');
         //            } else {
         //                //$this->getLocalTable()->guardarLocal($local, $servicio);
         //                echo 'no validado';
         //                exit;
         //            }
     }
     return array('id' => $id, 'form' => $form, 'id_re' => $idrest);
 }
示例#11
0
                $this->db->DeleteContributions([$args['id']]);
                $r->getBody()->write(json_encode(["Id" => $args['id']]));
                return $r;
            }
        }
        // Return error message
        $r->withStatus(500)->getBody()->write(json_encode(["Error" => $_error]));
        return $r;
    });
})->add($redis)->add($apiauth);
/* Asset Rewriting - only running on nginx. all other servers are just redirecting to */
$app->options('/asset/{id:[0-9]*}/{field:[0-9]*}/{file:.+}', function ($request, $response, $args) {
});
$app->get('/asset/{id:[0-9]*}/{field:[0-9]*}/{file:.+}', function ($request, $response, $args) {
    // Check if user is logged in
    $auth = new \Zend\Authentication\AuthenticationService();
    $logged_in = $auth->getIdentity()['username'];
    $apikey = false;
    $access = false;
    $s3 = $this->get('settings')['paths']['s3'];
    // Check for existing contribution. If logged in ignore state, otherwise just published or draft
    $c = $this->db->getContribution($args['id'], $logged_in ? false : true, true);
    if (!($c && $c->getId() == $args['id'])) {
        throw new \Slim\Exception\NotFoundException($request, $response);
    }
    // Public
    $public = $c->getTemplatenames()->getPublic() === "1";
    // Check for field
    $f = $this->db->getField($args['field']);
    // Check for NGINX
    $_isnginx = strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false;
 /**
  * Authenticate the given username and password with LDAP.
  *
  * @param string $username
  * @param string $password
  * @return \Zend\Authentication\Result
  */
 public function authenticate($username, $password)
 {
     $auth = new Zend\Authentication\AuthenticationService();
     $adapter = new Zend\Authentication\Adapter\Ldap(array($this->config()->options), $username, $password);
     return $auth->authenticate($adapter);
 }
 public function deleteAction()
 {
     // ------------------------ The block for Authorization
     $auth = new \Zend\Authentication\AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     $user = $auth->getIdentity();
     $usrlId = $user->usrl_id;
     // II) Protect our action
     if ($usrlId < 3) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     //------------------------- End the block for Authorization
     $id = $this->params()->fromRoute('id');
     if (!$id) {
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization', 'action' => 'index'));
     }
     $entityManager = $this->getEntityManager();
     try {
         $repository = $entityManager->getRepository('CsnUser\\Entity\\User');
         $user = $repository->find($id);
         $entityManager->remove($user);
         $entityManager->flush();
     } catch (\Exception $ex) {
         $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization', 'action' => 'index'));
     }
     return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine', 'action' => 'index'));
 }
示例#14
0
 public function deleteAction()
 {
     $auth = new \Zend\Authentication\AuthenticationService();
     if ($auth->hasIdentity()) {
         $user = $auth->getIdentity();
     } else {
         return $this->redirect()->toRoute('signin', array('action' => 'index'));
     }
     if ($user->role == 'Operator') {
         return array('error' => 'You don\'t have permission to do this action');
     }
     $id = (int) $this->params()->fromRoute('id', 0);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $del = $request->getPost('del', 'No');
         if ($del == 'Yes') {
             $id = (int) $request->getPost('id');
             if ($this->getUserTable()->getUser($id)->role == 'System Admin') {
                 return array('error' => 'You don\'t have permission to do this action');
             }
             $this->getUserTable()->deleteUser($id);
         }
         return $this->redirect()->toRoute('user');
     }
     return array('id' => $id, 'user' => $this->getUserTable()->getUser($id));
 }
示例#15
0
 public function index06Action()
 {
     $authenticateObj = new \Zend\Authentication\AuthenticationService();
     $authenticateObj->clearIdentity();
     return false;
 }
示例#16
0
<?php

$manager = new \Zend\Session\SessionManager();
$manager->setName('abbrevia');
\Zend\Session\Container::setDefaultManager($manager);
$auth = new Zend\Authentication\AuthenticationService();
$db->session = $manager->getStorage();
$facebookSession = new \Zend\Session\Container('facebook_id');
if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'login' && array_key_exists('xhrValidate', $_REQUEST) && array_key_exists('username', $_REQUEST) && array_key_exists('password', $_REQUEST)) {
    if (is_numeric(session_id())) {
        session_destroy();
    }
    $authAdapter = new \login\Auth($db, $_REQUEST['username'], $_REQUEST['password']);
    $authResult = $auth->authenticate($authAdapter);
    if ($authResult->getCode() != \Zend\Authentication\Result::SUCCESS) {
        $control->addValidationMessage('username_login', 'Credenziali errate');
    }
    $db->session->plain_pwd = $_REQUEST['password'];
} else {
    if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'register' && array_key_exists('username', $_REQUEST) && array_key_exists('password', $_REQUEST)) {
        $_REQUEST['task'] = 'register';
        if (array_key_exists('xhrValidate', $_REQUEST)) {
            if (!filter_var($_REQUEST['username'], FILTER_VALIDATE_EMAIL)) {
                $control->addValidationMessage('username_register', 'Inserisci una mail valida');
            }
            if (strlen($_REQUEST['password']) < 3) {
                $control->addValidationMessage('password_register', 'La password deve avere almeno tre caratteri');
            }
            if ($_REQUEST['password'] !== $_REQUEST['passwordr']) {
                $control->addValidationMessage('password_register', 'Le due password non coincidono');
            }
示例#17
0
 public function editarplatosAction()
 {
     $auth = new \Zend\Authentication\AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/usuario/index/login');
     }
     $id = (int) $this->params()->fromRoute('in_id', 0);
     $platicos = $this->platicos($id)->toArray();
     $comeya = $platicos[0]['va_imagen'];
     $va_nombre = 'prueba';
     $idlocal = (int) $this->params()->fromRoute('id_pa', 0);
     if (!$id) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/restaurante/index/agregarrestaurante');
     }
     try {
         $restaurante = $this->getPlatosTable()->getPlato($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/plato/listar');
     }
     $adpter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $form = new PlatosForm($adpter, $idlocal);
     $form->get('va_imagen')->setValue($comeya);
     /////////////////////PROMOCIONES////////////////////
     // $form->get('Ta_tipo_plato_in_id')->setOptions(array($platotipo[0]['in_id'] =>$platotipo[0]['va_nombre']  ));
     $form->bind($restaurante);
     $promobind = $this->getPlatosTable()->promocionxPlato($id)->toArray();
     $aux = array();
     foreach ($promobind as $value) {
         $aux[$value['ta_tag_in_id']] = $value['ta_tag_in_id'];
         $form->get('va_promocion')->setAttribute('value', $aux);
     }
     /////////////////////////////////////////////////////////////////////////////////
     $form->get('submit')->setAttribute('value', 'MODIFICAR');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $promoc = $this->params()->fromPost('va_promocion');
         $datos = $this->request->getPost();
         $plato_otro = $datos['va_otros'];
         $form->setInputFilter($restaurante->getInputFilter());
         $nonFile = $request->getPost()->toArray();
         $File = $this->params()->fromFiles('va_imagen');
         $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray());
         $form->setData($data);
         if ($form->isValid()) {
             $nonFile = $request->getPost()->toArray();
             if ($File['name'] != '') {
                 $adapter = new \Zend\File\Transfer\Adapter\Http();
                 if (!$adapter->isValid()) {
                     $dataError = $adapter->getMessages();
                     $error = array();
                     foreach ($dataError as $key => $row) {
                         $error[] = $row;
                     }
                     $form->setMessages(array('imagen' => $error));
                 } else {
                     $restaura = $this->restaurante($idlocal);
                     $rowset = $restaura;
                     $array = array();
                     foreach ($rowset as $resul) {
                         $array[] = $resul;
                     }
                     $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
                     $adapter = $this->dbAdapter;
                     $sql = new Sql($adapter);
                     $select = $sql->select()->from('ta_local')->join(array('tl' => 'ta_plato_has_ta_local'), 'ta_local.in_id = tl.Ta_local_in_id', array('cantidad' => new \Zend\Db\Sql\Expression('COUNT(tl.Ta_plato_in_id)')), 'left')->where(array('ta_local.in_id' => $idlocal))->group('ta_local.in_id');
                     $selectString = $sql->getSqlStringForSqlObject($select);
                     $results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
                     $plat = $results;
                     $platos = array();
                     foreach ($plat as $result) {
                         $platos[] = $result;
                     }
                     $anchura = 407;
                     $altura = 272;
                     $destacadox = 215;
                     $destacadoy = 155;
                     $generalx = 145;
                     $generaly = 112;
                     $imf = $File['name'];
                     $info = pathinfo($File['name']);
                     $tamanio = getimagesize($File['tmp_name']);
                     $ancho = $tamanio[0];
                     $alto = $tamanio[1];
                     $valor = uniqid();
                     $va = $this->getPlatosTable()->getPlato($id);
                     $imagen_antigua = $va->va_imagen;
                     if ($ancho > $alto) {
                         $eliminar = $this->_options->upload->images . '/plato/destacado/' . $imagen_antigua;
                         $eliminar1 = $this->_options->upload->images . '/plato/general/' . $imagen_antigua;
                         $eliminar2 = $this->_options->upload->images . '/plato/original/' . $imagen_antigua;
                         $eliminar3 = $this->_options->upload->images . '/plato/principal/' . $imagen_antigua;
                         unlink($eliminar);
                         unlink($eliminar1);
                         unlink($eliminar2);
                         unlink($eliminar3);
                         require './vendor/Classes/Filter/Alnum.php';
                         $alta = (int) ($alto * $anchura / $ancho);
                         if ($alta > 272) {
                             $altura = 272;
                         } else {
                             $altura = $alta;
                         }
                         if ($info['extension'] == 'jpg' or $info['extension'] == 'JPG' or $info['extension'] == 'jpeg') {
                             $nom = $nonFile['va_nombre'];
                             $imf2 = $valor . '.' . $info['extension'];
                             $filter = new \Filter_Alnum();
                             $filtered = $filter->filter($nom);
                             $name = $filtered . '-' . $imf2;
                             if (!is_dir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777)) {
                                 mkdir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 $principal = $this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $destacado = $this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $general = $this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $original = $this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             }
                             $estampa = imagecreatefrompng($this->_options->upload->images . '/defecto/loguito.png');
                             $viejaimagen = imagecreatefromjpeg($File['tmp_name']);
                             $margen_dcho = 340;
                             $margen_inf = 20;
                             $sx = imagesx($estampa);
                             $sy = imagesy($estampa);
                             imagecopy($viejaimagen, $estampa, $sx, $alto - 100, 0, 0, imagesx($estampa), imagesy($estampa));
                             $nuevaimagen = imagecreatetruecolor($anchura, $altura);
                             $destaque = imagecreatetruecolor($destacadox, $destacadoy);
                             $generale = imagecreatetruecolor($generalx, $generaly);
                             imagecopyresized($nuevaimagen, $viejaimagen, 0, 0, 0, 0, $anchura, $altura, $ancho, $alto);
                             imagecopyresized($destaque, $viejaimagen, 0, 0, 0, 0, $destacadox, $destacadoy, $ancho, $alto);
                             imagecopyresized($generale, $viejaimagen, 0, 0, 0, 0, $generalx, $generaly, $ancho, $alto);
                             $principal = $this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $destacado = $this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $general = $this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $original = $this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             imagejpeg($nuevaimagen, $principal);
                             imagejpeg($destaque, $destacado);
                             imagejpeg($generale, $general);
                             imagejpeg($viejaimagen, $original);
                             $nombre = $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $this->getPlatosTable()->guardarPlato($restaurante, $nombre, $idlocal, $plato_otro, $promoc);
                             $this->redirect()->toUrl('/plato/listar?id=' . $idlocal);
                         }
                     }
                     if ($ancho < $alto) {
                         $eliminar = $this->_options->upload->images . '/plato/destacado/' . $imagen_antigua;
                         $eliminar1 = $this->_options->upload->images . '/plato/general/' . $imagen_antigua;
                         $eliminar2 = $this->_options->upload->images . '/plato/original/' . $imagen_antigua;
                         $eliminar3 = $this->_options->upload->images . '/plato/principal/' . $imagen_antigua;
                         unlink($eliminar);
                         unlink($eliminar1);
                         unlink($eliminar2);
                         unlink($eliminar3);
                         require './vendor/Classes/Filter/Alnum.php';
                         $anchu = (int) ($ancho * $altura / $alto);
                         if ($anchu > 407) {
                             $anchura = 407;
                         } else {
                             $anchura = $anchu;
                         }
                         if ($info['extension'] == 'jpg' or $info['extension'] == 'JPG' or $info['extension'] == 'jpeg') {
                             $nom = $nonFile['va_nombre'];
                             $imf2 = $valor . '.' . $info['extension'];
                             $filter = new \Filter_Alnum();
                             $filtered = $filter->filter($nom);
                             $name = $filtered . '-' . $imf2;
                             if (!is_dir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777)) {
                                 mkdir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 mkdir($this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/', 0777);
                                 $principal = $this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $destacado = $this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $general = $this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                                 $original = $this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             }
                             $estampa = imagecreatefrompng($this->_options->upload->images . '/defecto/loguito.png');
                             $viejaimagen = imagecreatefromjpeg($File['tmp_name']);
                             $margen_dcho = 340;
                             $margen_inf = 20;
                             $sx = imagesx($estampa);
                             $sy = imagesy($estampa);
                             imagecopy($viejaimagen, $estampa, $sx, $alto - 100, 0, 0, imagesx($estampa), imagesy($estampa));
                             $nuevaimagen = imagecreatetruecolor($anchura, $altura);
                             $destaque = imagecreatetruecolor($destacadox, $destacadoy);
                             $generale = imagecreatetruecolor($generalx, $generaly);
                             imagecopyresized($nuevaimagen, $viejaimagen, 0, 0, 0, 0, $anchura, $altura, $ancho, $alto);
                             imagecopyresized($destaque, $viejaimagen, 0, 0, 0, 0, $destacadox, $destacadoy, $ancho, $alto);
                             imagecopyresized($generale, $viejaimagen, 0, 0, 0, 0, $generalx, $generaly, $ancho, $alto);
                             $principal = $this->_options->upload->images . '/plato/principal/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $destacado = $this->_options->upload->images . '/plato/destacado/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $general = $this->_options->upload->images . '/plato/general/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $original = $this->_options->upload->images . '/plato/original/' . $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             imagejpeg($nuevaimagen, $principal);
                             imagejpeg($destaque, $destacado);
                             imagejpeg($generale, $general);
                             imagejpeg($viejaimagen, $original);
                             $nombre = $array[0]['Ta_restaurante_in_id'] . '/' . $idlocal . '/' . $name;
                             $this->getPlatosTable()->guardarPlato($restaurante, $nombre, $idlocal, $plato_otro, $promoc);
                             $this->redirect()->toUrl('/plato/listar?id=' . $idlocal);
                         }
                     }
                 }
             } else {
                 $platos = $this->getPlatosTable()->getPlato($id);
                 $adapter = new \Zend\File\Transfer\Adapter\Http();
                 $name = $platos->va_imagen;
                 $this->getPlatosTable()->guardarPlato($restaurante, $name, $idlocal, $plato_otro, $promoc);
                 $this->redirect()->toUrl('/plato/listar?id=' . $idlocal);
             }
         }
     }
     return array('in_id' => $id, 'va_nombre' => $va_nombre, 'form' => $form, 'idlocal' => $idlocal);
 }
示例#18
0
$container['csrf'] = function ($c) {
    return new \Slim\Csrf\Guard();
};
// replace request with our own
$container['request'] = function ($c) {
    return \MartynBiz\Slim3Controller\Http\Request::createFromEnvironment($c->get('environment'));
};
// replace reponse with our own
$container['response'] = function ($c) {
    $headers = new \Slim\Http\Headers(['Content-Type' => 'text/html; charset=UTF-8']);
    $response = new \MartynBiz\Slim3Controller\Http\Response(200, $headers);
    return $response->withProtocolVersion($c->get('settings')['httpVersion']);
};
$container['auth'] = function ($c) {
    // we're using Zend's AuthenticationService here
    $authService = new \Zend\Authentication\AuthenticationService();
    // even though SessionStorage is the default container, we want it to use
    // this app's object and namespace
    $authService->setStorage(new \Zend\Authentication\Storage\Session('crsrc'));
    // create an instance of our AuthInterface implemented class
    // pass in our User model for getCurrentUser method
    return new \Wordup\Auth\Auth($authService, $c['model.user']);
};
$container['flash'] = function ($c) {
    $storage = new \Zend\Session\Container('crsrc_flash_messages');
    return new \MartynBiz\FlashMessage\Flash($storage);
};
$container['cache'] = function ($c) {
    // we wanna set the prefix so not to clash with other apps
    $backend = new \Predis\Client(null, array('prefix' => 'wordup:'));
    $adapter = new \Desarrolla2\Cache\Adapter\Predis($backend);
        $config = $config['deit_authentication'];
        if (isset($config['map_auth_data_to_adapter_callback'])) {
            $options->setMapAuthDataToAdapterCallback($config['map_auth_data_to_adapter_callback']);
        }
        if (isset($config['fetch_entity_from_identity_callback'])) {
            $options->setFetchEntityFromIdentityCallback($config['fetch_entity_from_identity_callback']);
        }
    }
    return $options;
}, 'deit_authentication_events' => function ($sm) {
    return new \Zend\EventManager\EventManager();
}, 'deit_authentication_form' => function ($sm) {
    $form = new \DeitAuthenticationModule\Form\Authentication();
    return $form;
}, 'deit_authentication_service' => function ($sm) {
    $service = new \Zend\Authentication\AuthenticationService();
    $service->setStorage($sm->get('deit_authentication_storage'))->setAdapter($sm->get('deit_authentication_adapter'));
    return $service;
}, 'deit_authentication_storage' => function ($sm) {
    $storage = new \Zend\Authentication\Storage\Session();
    return $storage;
})), 'controllers' => array('invokables' => array('DeitAuthenticationModule\\Controller\\Authentication' => 'DeitAuthenticationModule\\Controller\\AuthenticationController')), 'controller_plugins' => array('factories' => array('identity' => function ($sm) {
    $sm = $sm->getServiceLocator();
    $plugin = new \DeitAuthenticationModule\Controller\Plugin\Identity();
    $plugin->setAuthenticationService($sm->get('deit_authentication_service'));
    return $plugin;
})), 'view_helpers' => array('factories' => array('identity' => function ($sm) {
    $sm = $sm->getServiceLocator();
    $plugin = new \DeitAuthenticationModule\View\Helper\Identity();
    $plugin->setAuthenticationService($sm->get('deit_authentication_service'));
    return $plugin;
 public function deleteAction()
 {
     // ------------------------ The block for Authorization
     $auth = new \Zend\Authentication\AuthenticationService();
     echo '<h1>hasIdentity = ' . $auth->hasIdentity() . '</h1>';
     $config = $this->getServiceLocator()->get('Config');
     $acl = new \CsnUser\Acl\Acl($config);
     $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
     if ($auth->hasIdentity()) {
         $usr = $auth->getIdentity();
         $usrl_id = $usr->usrl_id;
         // Use a view to get the name of the role
         // TODO we don't need that if the names of the roles are comming from the DB
         switch ($usrl_id) {
             case 1:
                 $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
                 // guest
                 break;
             case 2:
                 $role = 'member';
                 break;
             default:
                 $role = \CsnUser\Acl\Acl::DEFAULT_ROLE;
                 // guest
                 break;
         }
     }
     $controller = $this->params()->fromRoute('controller');
     $action = $this->params()->fromRoute('action');
     echo '<pre>';
     echo "controller = " . $controller . "\n";
     echo "action = " . $action . "\n";
     echo "role = " . $role . "\n";
     echo '</pre>';
     if (!$acl->hasResource($controller)) {
         throw new \Exception('Resource ' . $controller . ' not defined');
     }
     echo '<h1> Acl answer: ' . $acl->isAllowed($role, $controller, $action) . '</h1>';
     if (!$acl->isAllowed($role, $controller, $action)) {
         return $this->redirect()->toRoute('auth/default', array('controller' => 'index', 'action' => 'login'));
     }
     //------------------------- End the block for Authorization
     $id = $this->params()->fromRoute('id');
     if (!$id) {
         return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization-acl', 'action' => 'index'));
     }
     $entityManager = $this->getEntityManager();
     try {
         $repository = $entityManager->getRepository('CsnUser\\Entity\\User');
         $user = $repository->find($id);
         $entityManager->remove($user);
         $entityManager->flush();
     } catch (\Exception $ex) {
         $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine-simple-authorization-acl', 'action' => 'index'));
     }
     return $this->redirect()->toRoute('csn_user/default', array('controller' => 'user-doctrine', 'action' => 'index'));
 }
示例#21
0
 public function __invoke()
 {
     $authService = new \Zend\Authentication\AuthenticationService();
     return $authService->getStorage()->read()['user'];
 }
示例#22
0
 public function listadoregistroplatosAction()
 {
     $auth = new \Zend\Authentication\AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/usuario/index/login');
     }
     $id = $this->params()->fromRoute('id');
     $lista = $this->getRestauranteTable()->listarRegistroPlatos($id);
     return new ViewModel(array('listamenu' => $lista));
 }
示例#23
0
     * the container/session variable is used to store the surrogate key
     * for the session recorded in the database
     *
     * the user and the session entities are never stored in
     * the container/session, only de-referenced when needed by the
     * entity manager using their surrogate keys
     */
    $container = $sm->get('Acl\\Authentication\\Storage\\Session');
    $sessionPrototype = $sm->get('Acl\\Entity\\Session');
    $entityManager = $sm->get('Acl\\Entity\\Manager');
    $storage = new \Acl\Model\Authentication\DoctrineSessionStorage();
    $storage->setContainer($container)->setSessionPrototype($sessionPrototype)->setEntityManager($entityManager);
    return $storage;
}, 'Acl\\Authentication\\Service' => function ($sm) {
    $storage = $sm->get('Acl\\Authentication\\Storage\\Doctrine');
    $service = new \Zend\Authentication\AuthenticationService();
    $service->setStorage($storage);
    return $service;
}, 'Acl\\Authorization\\UserAttributeEvaluator' => function ($sm) {
    $em = $sm->get('Acl\\EntityManager');
    $evaluator = new \Acl\Model\Authorization\UserAttributeEvaluator();
    $evaluator->setEntityManager($em);
    return $evaluator;
}, 'Acl\\Authorization\\UserAttributeEvaluatorListener' => function ($sm) {
    $evaluator = $sm->get('Acl\\Authorization\\UserAttributeEvaluator');
    $authService = $sm->get('Acl\\Authentication\\Service');
    $routeForwardingContainer = $sm->get('Acl\\Authentication\\Storage\\RouteForwarding');
    $listener = new \Acl\Model\Authorization\UserAttributeEvaluatorListener();
    $listener->setAuthenticationService($authService)->setUserAttributeEvaluator($evaluator)->setRouteForwardingContainer($routeForwardingContainer);
    return $listener;
}, 'Acl\\View\\CurrentUserListener' => function ($sm) {
示例#24
0
<?php

require '../application/bootstrap.php';
$auth = new Zend\Authentication\AuthenticationService(new \Zend\Authentication\Storage\Session("CallStatistic\\Manager"));
if (!$auth->getIdentity() || !in_array($auth->getIdentity(), array("*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"))) {
    header("location: manager.auth.php");
}
$mainPage = new CallStatistic\Manager\MainPage();
$mainPageView = new CallStatistic\Manager\View\MainPageView($mainPage, null, "p");
$mainPageView->showDialog();