/** * 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)); } } } }
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); } } } }
/** * * @return Ambigous <\Zend\Http\Response, \Zend\Stdlib\ResponseInterface> */ public function processAction() { $username = $this->params()->fromPost('username'); $password = $this->params()->fromPost('passwd'); $adapterService = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'); $authService = new \Zend\Authentication\AuthenticationService(); if (!trim($username) || !trim($password)) { // clear identity anyway $authService->clearIdentity(); return $this->redirect()->toRoute('application/child', array('controller' => 'signin', 'action' => 'index')); } $adapter = new \Zend\Authentication\Adapter\DbTable($adapterService, 'energy_user', 'username', 'passwd'); $authService->setAdapter($adapter); $authService->getAdapter()->setIdentity($username)->setCredential($password); $result = $authService->authenticate(); if ($result->isValid()) { $UserTable = $this->getServiceLocator()->get('Model\\Entity\\User'); $UserData = $UserTable->getFinder()->setParams(array("where" => array("username" => $username)))->findOne(); if ($UserData) { if ($UserData->status == User::ACTIVE) { // now write auth into session, but not password $UserData->passwd = NULL; $UserData->auth_token = NULL; $authService->getStorage()->write($UserData); if ($authService->hasIdentity()) { // type must be a valid type to login switch ($UserData->user_type) { case User::SU: $this->flashMessenger()->addMessage(array('success' => 'Logged in as Super User.')); return $this->redirect()->toRoute('su'); case User::CUSTOMER: $this->flashMessenger()->addMessage(array('success' => 'You are successfully logged in.')); return $this->redirect()->toRoute('user'); case 'default': $this->flashMessenger()->addMessage(array('error' => 'Cannot Identify User.')); } } else { $this->flashMessenger()->addMessage(array('error' => 'Server error occurred.')); } } else { $this->flashMessenger()->addMessage(array('error' => 'Cannot Login. Please check account status.')); } } } else { $this->flashMessenger()->addMessage(array('error' => 'Invalid Username/Password')); } // clear identity, just in case of bug $authService->clearIdentity(); return $this->redirect()->toRoute('application/child', array('controller' => 'signin', 'action' => 'quit')); }
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; })); }
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); }
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')); }
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)); }
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)); }
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')); }
public function index05Action() { $authenticateObj = new \Zend\Authentication\AuthenticationService(); if ($authenticateObj->hasIdentity()) { echo "<pre style='font-weight:bold'>"; print_r($authenticateObj->getIdentity()); echo "</pre>"; } return false; }
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); }