/**
  * Sube el archivo a temporal
  * @return string
  */
 public function upload($extenciones = array('kml', 'kmz'))
 {
     $correcto = true;
     $upload = new Zend_File_Transfer();
     $upload->addValidator('Extension', false, $extenciones);
     $upload->addValidator('FilesSize', false, array('min' => '0.001kB', 'max' => '64MB'));
     $file = $upload->getFileInfo();
     foreach ($file as $field_name => $file_data) {
         if (!$upload->isUploaded($field_name)) {
             $correcto = false;
             $retorno = array("correcto" => false, "mensaje" => "No se subio ningún archivo o estaba vacío");
         }
         if (!$upload->isValid($field_name)) {
             $texto = "</br>";
             $mensajes = $upload->getMessages();
             foreach ($mensajes as $key => $txt) {
                 $texto .= $txt . "</br>";
             }
             $correcto = false;
             $retorno = array("correcto" => false, "mensaje" => "<b>El archivo es inv&aacute;lido</b>." . $texto);
         }
         $this->_setFileConfig($file_data["name"]);
         $this->_mime = $file_data["type"];
         $this->_hash = $this->_ci->string_core->rand_string(20);
         $this->_target = $this->_dir_temp . $this->_hash . "." . $this->_file_ext;
         $upload->addFilter('Rename', array('target' => $this->_target, 'overwrite' => true));
     }
     if ($correcto) {
         fb($upload->receive());
         $retorno = $this->_saveToCache();
     }
     return $retorno;
 }
Ejemplo n.º 2
0
 public function importSeasons()
 {
     $option = JRequest::getCmd('option');
     $controller = JRequest::getCmd('controller');
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $path = JPATH_ROOT . "/tmp";
     $upload = new Zend_File_Transfer();
     $upload->setDestination($path);
     $upload->addValidator('Extension', false, array("csv"));
     $errors = array();
     $file = "products_seasons";
     $info = $upload->getFileInfo($file);
     if ($upload->isUploaded($file)) {
         if (!$upload->isValid($file)) {
             foreach ($upload->getMessages() as $k => $v) {
                 $errors[$k] = true;
             }
         }
     }
     if ($upload->receive()) {
         $mProduct = new EcwidgatewayModelProducts();
         $mProduct->processSeasonsCsv($path . "/" . $info[$file]["name"]);
         $msg = "Данные импортированы";
     } else {
         $errorMessages = array("Ошибка при загрузке файла");
         foreach ($errors as $k => $v) {
             if (isset($errors[Zend_Validate_File_Extension::FALSE_EXTENSION])) {
                 $errorMessages[] = JText::_("Недопустимое расширение файла");
             }
         }
         $msg = implode("<p>", $errorMessages);
     }
     $link = 'index.php?option=' . $option . '&controller=' . $controller;
     $this->setRedirect($link, $msg);
 }
Ejemplo n.º 3
0
 public function uploadAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $db = new Fotos();
     $album_id = $this->_request->getPost('album_id');
     $db->setAlbumId($album_id);
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination(APPLICATION_PATH . '/../data/temp');
     $upload = new Zend_File_Transfer();
     $files = $upload->getFileInfo();
     if (!file_exists(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id)) {
         mkdir(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id, 0777, true);
     }
     foreach ($files as $file => $info) {
         if ($upload->isUploaded($file)) {
             $extension = substr($info['name'], strrpos($info['name'], '.') + 1);
             $filename = 'photo_' . time() . '.' . $extension;
             $adapter->addFilter('Rename', array('target' => APPLICATION_PATH . '/../data/temp/' . $filename, 'overwrite' => true));
             $adapter->receive($info['name']);
             if (!$adapter->receive()) {
                 $messages = $adapter->getMessages();
                 echo implode("\n", $messages);
                 exit;
             }
             //setFileName::Url
             $db->setUrl($filename);
             //setCapa::false (0)
             $db->setCapa(0);
             $imanee = new Imanee\Imanee(APPLICATION_PATH . '/../data/temp/' . $filename);
             //resized
             $imanee->resize(870, 653)->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'r_' . $filename, 80);
             //full
             //$imanee->resize(1024, 768)
             //        ->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'f_' . $filename, 80);
             //thumbnail
             $imanee->thumbnail(200, 200, true)->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 't_' . $filename, 60);
             unlink(APPLICATION_PATH . '/../data/temp/' . $filename);
             $data = array('url' => $db->getUrl(), 'album_id' => $db->getAlbumId(), 'capa' => $db->getCapa());
             $foto_id = $db->saveFoto($data);
             $data['foto_id'] = $foto_id;
             echo json_encode($data);
         }
     }
 }
Ejemplo n.º 4
0
 public function editarAction()
 {
     $tp = new LoginTipo();
     $ut = new Util();
     $us = new Usuarios();
     $tiposLogin = $tp->getAllLoginTipo();
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $usuario = $us->getUserByLoginId($id);
     if (!$usuario) {
         $this->_helper->redirector('listar', 'usuarios');
     }
     if ($request->isPost()) {
         $erro = false;
         $msg = '';
         $nascimento = empty($request->getPost('Nascimento')) ? NULL : $ut->dateToSql($request->getPost('Nascimento'));
         $now = $ut->nowDateSql();
         $rg = $ut->limpaDados($request->getPost('Rg'));
         $cpf = $ut->limpaDados($request->getPost('Cpf'));
         $telefone = $ut->limpaDados($request->getPost('Telefone'));
         $celular = $ut->limpaDados($request->getPost('Celular'));
         $us->setNome($request->getPost('Nome'));
         $us->setSobrenome($request->getPost('Sobrenome'));
         $us->setEmail($request->getPost('Email'));
         $us->setLoginId($id);
         $us->setRg($rg);
         $us->setCpf($cpf);
         $us->setNascimento($nascimento);
         $us->setTelefone($telefone);
         $us->setCelular($celular);
         $us->setSexo($request->getPost('Sexo'));
         $us->setCadastradoEm($now);
         $data = array('nome' => $us->getNome(), 'sobrenome' => $us->getSobrenome(), 'email' => $us->getEmail(), 'login_id' => $us->getLoginId(), 'rg' => $us->getRg(), 'cpf' => $us->getCpf(), 'nascimento' => $us->getNascimento(), 'telefone' => $us->getTelefone(), 'celular' => $us->getCelular(), 'sexo' => $us->getSexo());
         $us->saveUser($data, $id);
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination(APPLICATION_PATH . '/../data/temp');
         $upload = new Zend_File_Transfer();
         $files = $upload->getFileInfo();
         if ($files['Avatar']['tmp_name']) {
             if (!file_exists(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id)) {
                 mkdir(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id, 0777, true);
             }
             foreach ($files as $file => $info) {
                 if ($upload->isUploaded($file)) {
                     //$extension = substr($info['name'], strrpos($info['name'], '.') + 1);
                     $filename = 'avatar.jpg';
                     $adapter->addFilter('Rename', array('target' => APPLICATION_PATH . '/../data/temp/' . $filename, 'overwrite' => true));
                     $adapter->receive($info['name']);
                     if (!$adapter->receive()) {
                         $messages = $adapter->getMessages();
                         echo implode("\n", $messages);
                         exit;
                     }
                     //setFileName::Url2
                     $us->setAvatar($filename);
                     $imanee = new Imanee\Imanee(APPLICATION_PATH . '/../data/temp/' . $filename);
                     //resized
                     $imanee->resize(300, 300, false)->write(ROOT_DIR . DS . 'painel' . DS . 'images' . DS . 'usuario' . DS . $id . DS . $filename, 80);
                     //full
                     //$imanee->resize(1024, 768)
                     //        ->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'f_' . $filename, 80);
                     unlink(APPLICATION_PATH . '/../data/temp/' . $filename);
                 }
             }
         }
         if ($erro) {
             $msg = 'Ocorreu um erro, tente novamente';
             $this->view->msg = $msg;
         } else {
             $this->_helper->redirector('listar', 'usuarios');
         }
     }
     $this->view->usuario = $usuario;
     $this->view->tipos = $tiposLogin;
     $this->view->util = $ut;
     $this->render();
 }
 /**
  * Upload a new file for this user if one is present in the form data, or if
  * not, check if one has been uploaded previously.  If there's one known
  * about, return its name.  Uses session to persist an uploaded file's
  * details between form submission attempts, in the case the overall form
  * doesn't validate.
  *
  * @todo Move somewhere else.
  *
  * @return array Array indicating boolean true for success plus and an
  * associative array with uploaded file information (or empty array if no
  * file), or boolean false for failure and an array of error messages.
  */
 private function _uploadPersistentCompanyApplicationFile()
 {
     // For storing original filename intact
     $session = new Zend_Session_Namespace('homelet_connect_referencing');
     $tempFile = "{$this->_params->connect->tempPrivatePath}companyApp_{$this->_agentSchemeNumber}_{$this->_agentId}";
     // Is a new file being sent?
     $upload = new Zend_File_Transfer('http');
     if ($upload->isUploaded()) {
         $upload->getValidator('Upload')->setMessages(array(Zend_Validate_File_Upload::INI_SIZE => 'The uploaded file size exceeds system maximum (' . ini_get('upload_max_filesize') . ')', Zend_Validate_File_Upload::FORM_SIZE => 'The uploaded file size exceeds the HTML form maximum', Zend_Validate_File_Upload::PARTIAL => 'The uploaded file was only partially uploaded', Zend_Validate_File_Upload::NO_FILE => 'No file was uploaded', Zend_Validate_File_Upload::NO_TMP_DIR => 'Missing a temporary folder', Zend_Validate_File_Upload::CANT_WRITE => 'Failed to write file to disk', Zend_Validate_File_Upload::EXTENSION => 'File upload stopped by extension', Zend_Validate_File_Upload::UNKNOWN => 'Unknown upload error'));
         $upload->addValidator('Count', true, 1);
         $upload->addValidator('Size', false, $this->_params->connect->companyapps->fileUpload->maxSize->file);
         $upload->getValidator('Size')->setMessages(array(Zend_Validate_File_Size::TOO_SMALL => 'File \'%value%\' below minimum size', Zend_Validate_File_Size::TOO_BIG => 'File \'%value%\' above maximum size'));
         $upload->addValidator('MimeType', false, $this->_params->connect->companyapps->fileUpload->mimeTypes);
         $upload->getValidator('MimeType')->setMessages(array(Zend_Validate_File_MimeType::FALSE_TYPE => 'File \'%value%\' of incorrect MIME type'));
         $upload->addValidator('Extension', true, $this->_params->connect->companyapps->fileUpload->extensions);
         $upload->getValidator('Extension')->setMessages(array(Zend_Validate_File_Extension::FALSE_EXTENSION => 'File \'%value%\' of incorrect extension'));
         if ($upload->isValid()) {
             // First delete any old file that may have been previously
             //   uploaded
             $this->_deleteCompanyApplicationFile();
             // Upload new one
             $session->companyAppFile->originalFilename = $upload->getFileName(null, false);
             $upload->addFilter('Rename', $tempFile);
             if ($upload->receive()) {
                 $session->companyAppFile->uploadedFile = $tempFile;
             } else {
                 unset($session->companyAppFile);
             }
         } else {
             // Send back validation messages
             return array(false, $upload->getMessages());
         }
     }
     // Is there one stored, perhaps already?  If yes, return original
     //   filename
     $returnVal = array();
     if (isset($session->companyAppFile->originalFilename)) {
         $returnVal = array('originalName' => $session->companyAppFile->originalFilename, 'pathToFile' => $tempFile);
     }
     return array(true, $returnVal);
 }
Ejemplo n.º 6
0
 public function editarAction()
 {
     $eq = new Equipe();
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $equipe = $eq->getById($id);
     if (!$equipe) {
         $this->_helper->redirector('listar', 'equipe');
     }
     $erro = false;
     if ($request->isPost()) {
         $erro = false;
         $msg = '';
         $eq->setNome($request->getPost('Nome'));
         $eq->setCargo($request->getPost('Cargo'));
         $eq->setDescricao($request->getPost('Descricao'));
         $data = array('nome' => $eq->getNome(), 'cargo' => $eq->getCargo(), 'descricao' => $eq->getDescricao());
         $eq->save($data, $id);
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination(APPLICATION_PATH . '/../data/temp');
         $upload = new Zend_File_Transfer();
         $files = $upload->getFileInfo();
         if ($files['Avatar']['tmp_name']) {
             if (!file_exists(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'equipe' . DS . $id)) {
                 mkdir(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'equipe' . DS . $id, 0777, true);
             }
             foreach ($files as $file => $info) {
                 if ($upload->isUploaded($file)) {
                     //$extension = substr($info['name'], strrpos($info['name'], '.') + 1);
                     $filename = 'avatar.jpg';
                     $adapter->addFilter('Rename', array('target' => APPLICATION_PATH . '/../data/temp/' . $filename, 'overwrite' => true));
                     $adapter->receive($info['name']);
                     if (!$adapter->receive()) {
                         $messages = $adapter->getMessages();
                         echo implode("\n", $messages);
                         exit;
                     }
                     //setFileName::Url
                     $eq->setAvatar($filename);
                     $imanee = new Imanee\Imanee(APPLICATION_PATH . '/../data/temp/' . $filename);
                     //resized
                     $imanee->resize(300, 300)->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'equipe' . DS . $id . DS . $filename, 80);
                     //full
                     //$imanee->resize(1024, 768)
                     //        ->write(ROOT_DIR . DS . 'site' . DS . 'images' . DS . 'galeria' . DS . $album_id . DS . 'f_' . $filename, 80);
                     unlink(APPLICATION_PATH . '/../data/temp/' . $filename);
                 }
             }
         }
         if ($erro) {
             $msg = 'Ocorreu um erro, tente novamente';
             $this->view->msg = $msg;
         } else {
             $this->_helper->redirector('listar', 'equipe');
         }
     }
     $this->view->equipe = $equipe;
     $this->render();
 }
 public function addAction()
 {
     if ($this->_request->isPost()) {
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormProducts')) {
             $dataProducts = $this->_request->getParam('dataFormProducts');
             //основные - sku, name, description, note, sorting, path
             $product = new Catalog_Model_Products($dataProducts);
             //modDate, order
             $product->setMetaTitle($dataProducts['name'])->setMetaDescription($dataProducts['description'])->setMetaKeywords($dataProducts['name'])->setOrder($dataProducts['sorting'])->setActive(1)->setDeleted(0)->setAddDate(date("Y-m-d H:i:s"))->setModDate(date("Y-m-d H:i:s"));
             $this->_modelMapper->save($product);
             $productId = $this->_modelMapper->getDbTable()->getAdapter()->lastInsertId();
             $categoriesMapperXref = new Catalog_Model_Mapper_CategoriesXref();
             $categoriesMapperXref->save(new Catalog_Model_CategoriesXref(array('productId' => $productId, 'categoryId' => $this->_request->getParam('categoryId'))));
             $product = $this->_modelMapper->find($productId, $this->_model);
             $upload = new Zend_File_Transfer();
             $uploadPath = '/upload/products/' . $product->getId() . '/';
             //image
             if ($upload->isUploaded('fileLoadImage')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadImage');
                 $product->setUploadPath($uploadPath)->setImage($imageFile['fileLoadImage']['name']);
             }
             //draft
             if ($upload->isUploaded('fileLoadDraft')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadDraft');
                 $product->setUploadPathDraft($uploadPath)->setDraft($imageFile['fileLoadDraft']['name']);
             }
             $this->_modelMapper->save($product);
             $url = '/catalog/' . $product->getFullPath();
         }
         $this->clearCache('CatalogProductsList');
         $this->_redirector->gotoUrlAndExit($url);
     }
     //Zend_Debug::dump($this->_request->getParams());
 }
 public function editAction()
 {
     $categoryId = $this->_request->getParam('id');
     if (is_null($categoryId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $category = $this->_modelMapper->find($categoryId, new Catalog_Model_Categories());
     if (is_null($category)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     $parentCategoryId = $category->getParentId();
     if ($this->_request->isPost()) {
         //Zend_Debug::dump($this->_request->getParams());
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormCategory')) {
             $dataCategory = $this->_request->getParam('dataFormCategory');
             $category->setOptions($dataCategory);
             $category->setModDate(date("Y-m-d H:i:s"));
             $context_html = Michelf\MarkdownExtra::defaultTransform($dataCategory['contentMarkdown']);
             $category->setContentHtml($context_html);
             $parentFullPath = $this->_modelMapper->generateFullPath($dataCategory['parentId']);
             $fullPath = !is_null($parentFullPath) ? $parentFullPath . '/' . $category->getPath() : $category->getPath();
             $category->setFullPath($fullPath);
             $url = '/catalog/' . $fullPath;
             $productsRel = $this->_modelMapper->fetchProductsRel($categoryId);
             if ($productsRel) {
                 $productsMapper = new Catalog_Model_Mapper_Products();
                 /** @var Catalog_Model_Products $product */
                 foreach ($productsRel as $product) {
                     $product->setFullPath($fullPath . '/' . $product->getPath());
                     $productsMapper->save($product);
                 }
             }
             $upload = new Zend_File_Transfer();
             if ($upload->isUploaded()) {
                 $imageFile = $this->_uploadFiles($categoryId, $upload);
                 $category->setUploadPath('/upload/categories/' . $categoryId . '/');
                 $category->setImage($imageFile['fileLoad']['name']);
             }
             $this->_modelMapper->save($category);
         }
         $this->clearCache('CatalogCategories');
         $this->_redirector->gotoUrlAndExit($url);
     }
 }
Ejemplo n.º 9
0
    function regAction()
    {
        if ($this->_request->isPost('reg-form')) {
            Zend_Loader::loadClass('Zend_Filter_StripTags');
            Zend_Loader::loadClass('Zend_File_Transfer');
            Zend_Loader::loadClass('Zend_Date');
            Zend_Loader::loadClass('Zend_Mail');
            Zend_Loader::loadClass('Zend_Validate_EmailAddress');
            Zend_Loader::loadClass('Zend_Validate_StringLength');
            Zend_Loader::loadClass('Zend_Validate_Alnum');
            $filter = new Zend_Filter_StripTags();
            $email = trim($filter->filter($this->_request->getPost('reg-email')));
            $username = trim($filter->filter($this->_request->getPost('reg-name')));
            $password = trim($filter->filter($this->_request->getPost('reg-pswd')));
            $password_confirm = trim($filter->filter($this->_request->getPost('reg-pswd-verification')));
            $real_name = trim($filter->filter($this->_request->getPost('reg-real-name')));
            $file_name = '';
            $warnings = new Zend_Session_Namespace();
            $warnings->username = $username;
            $warnings->email = $email;
            $warnings->real_name = $real_name;
            $warnings->error = '';
            $error_msg = '';
            $mail_val = new Zend_Validate_EmailAddress();
            $name_lenght_val = new Zend_Validate_StringLength(6, 12);
            $name_an_val = new Zend_Validate_Alnum();
            $pass_lenght_val = new Zend_Validate_StringLength(6, 16);
            $real_name_lenght_val = new Zend_Validate_StringLength(0, 60);
            if ($email == '') {
                $error_msg .= '<p>Enter your email.</p>';
            } else {
                if (!$mail_val->isValid($email)) {
                    foreach ($mail_val->getMessages() as $message) {
                        $error_msg .= '<p>' . $message . '</p>';
                    }
                } else {
                    $data = new Users();
                    $query = 'email = "' . $email . '"';
                    $data_row = $data->fetchRow($query);
                    if ($data_row['email'] != '') {
                        $error_msg .= '<p>User with such an email is already registered.</p>';
                    }
                }
            }
            if ($username == '') {
                $error_msg .= '<p>Enter your username.</p>';
            } else {
                if (!$name_lenght_val->isValid($username) || !$name_an_val->isValid($username)) {
                    foreach ($name_lenght_val->getMessages() as $message) {
                        $error_msg .= '<p>' . $message . '</p>';
                    }
                    foreach ($name_an_val->getMessages() as $message) {
                        $error_msg .= '<p>' . $message . '</p>';
                    }
                } else {
                    $data = new Users();
                    $query = 'login = "******"';
                    $data_row = $data->fetchRow($query);
                    if ($data_row['login'] != '') {
                        $error_msg .= '<p>User with such an username is already registered.</p>';
                    }
                }
            }
            if ($password == '' || !$pass_lenght_val->isValid($password)) {
                $error_msg .= '<p>Enter password (must consist 6 to 16 characters).</p>';
            } else {
                if ($password_confirm == '') {
                    $error_msg .= '<p>Empty verification password.</p>';
                } else {
                    if ($password != $password_confirm) {
                        $error_msg .= '<p>The entered passwords do not match.</p>';
                    } else {
                        $salt = substr(sha1(microtime(true) . rand(1, 99999)), 0, 3);
                        $password = sha1($password . $salt);
                    }
                }
            }
            if ($real_name != '') {
                if (!$real_name_lenght_val->isValid($real_name)) {
                    foreach ($real_name_lenght_val->getMessages() as $message) {
                        $error_msg .= '<p>' . $message . '</p>';
                    }
                }
            }
            $upload = new Zend_File_Transfer();
            if ($upload->isUploaded()) {
                $upload->setDestination('public/upload/avatars/');
                $upload->addValidator('IsImage', false);
                $upload->addValidator('Size', false, 1024 * 1024);
                if (!$upload->isValid()) {
                    foreach ($upload->getMessages() as $message) {
                        $error_msg .= '<p>' . $message . '</p>';
                    }
                } else {
                    $upload_info = $upload->getFileName();
                    $file_ext = mb_substr($upload_info, strrpos($upload_info, '.') + 1);
                    $file_name = $username . '.' . $file_ext;
                    $upload->addFilter('Rename', array('target' => 'public/upload/avatars/' . $file_name, 'overwrite' => true));
                }
            }
            if ($error_msg != '') {
                $warnings->error = $error_msg;
                $warnings->status = '';
                $this->_redirect('/register/');
                return;
            } else {
                $date = new Zend_Date();
                $current_date = $date->toString('YYYY-MM-dd');
                $upload->receive();
                $data = array('login' => $username, 'email' => $email, 'password' => $password, 'salt' => $salt, 'real_name' => $real_name, 'reg_date' => $current_date, 'avatar' => $file_name, 'last_login' => '-');
                $user = new Users();
                $user->insert($data);
                $warnings->error = '<p>Registration complete.</p><p>Now check your E-Mail to activate your profile.</p>';
                $warnings->username = '';
                $warnings->email = '';
                $warnings->real_name = '';
                $warnings->status = ' reg_ok';
                $mail = new Zend_Mail();
                $hash = sha1($email . $salt);
                $url = $this->getRequest()->getServer('HTTP_HOST');
                $mail->setBodyHtml('<p>To activate your profile follow the link below:</p>
									<p>Link: <a href="http://' . $url . '/register/activate/' . $hash . '">http://' . $url . '/register/activate/' . $hash . '</a></p>
									<p>Thanks for your registration.</p>
									');
                $mail->setFrom('*****@*****.**', 'Administrator');
                $mail->addTo($email, $username);
                $mail->setSubject('Test activation link');
                $mail->send();
                $this->_redirect('/register/');
                return;
            }
        }
    }
Ejemplo n.º 10
0
 /**
  * Controller to handle file upload form
  * @throws Exception
  */
 public function indexAction()
 {
     $response = new stdClass();
     try {
         $upload = new Zend_File_Transfer();
     } catch (Exception $e) {
         $response->error = $e->getMessage();
         $this->_helper->json->sendJson($response);
     }
     $upload->addValidator('Count', false, array('min' => 1, 'max' => 100));
     $upload->addValidator('IsImage', false);
     $upload->addValidator('Size', false, array('max' => '10MB', 'bytestring' => false));
     $translate = Zend_Registry::get('Zend_Translate');
     $updating = false;
     try {
         if (!$upload->receive()) {
             throw new Exception($translate->translate('error_uploading'));
         } else {
             $files = $upload->getFileInfo();
             // Updating hash with new images
             if (!empty($_POST['hash']) && Unsee_Hash::isValid($_POST['hash'])) {
                 $hashDoc = new Unsee_Hash($_POST['hash']);
                 $updating = true;
                 $response = array();
                 if (!Unsee_Session::isOwner($hashDoc) && !$hashDoc->allow_anonymous_images) {
                     die('[]');
                 }
             } else {
                 // Creating a new hash
                 $hashDoc = new Unsee_Hash();
                 $this->setExpiration($hashDoc);
                 $response->hash = $hashDoc->key;
             }
             $imageAdded = false;
             foreach ($files as $file => $info) {
                 if ($upload->isUploaded($file)) {
                     $imgDoc = new Unsee_Image($hashDoc);
                     $res = $imgDoc->setFile($info['tmp_name']);
                     $imgDoc->setSecureParams();
                     //hack to populate correct secureTtd
                     if ($updating) {
                         $ticket = new Unsee_Ticket();
                         $ticket->issue($imgDoc);
                         $newImg = new stdClass();
                         $newImg->hashKey = $hashDoc->key;
                         $newImg->key = $imgDoc->key;
                         $newImg->src = '/image/' . $imgDoc->key . '/' . $imgDoc->secureMd5 . '/' . $imgDoc->secureTtd . '/';
                         $newImg->width = $imgDoc->width;
                         $newImg->ticket = md5(Unsee_Session::getCurrent() . $hashDoc->key);
                         $response[] = $newImg;
                     }
                     if ($res) {
                         $imageAdded = true;
                     }
                     // Remove uploaded file from temporary dir if it wasn't removed
                     if (file_exists($info['tmp_name'])) {
                         @unlink($info['tmp_name']);
                     }
                 }
             }
             if (!$imageAdded) {
                 throw new Exception('No images were added');
             }
         }
     } catch (Exception $e) {
         $response->error = $e->getMessage();
     }
     $this->_helper->json->sendJson($response);
 }