コード例 #1
0
 public function uploadAction()
 {
     if ($code = $this->getRequest()->getPost("code")) {
         try {
             if (empty($_FILES) || empty($_FILES['file']['name'])) {
                 throw new Exception("No file has been sent");
             }
             $path = Core_Model_Directory::getPathTo(System_Model_Config::IMAGE_PATH);
             $base_path = Core_Model_Directory::getBasePathTo(System_Model_Config::IMAGE_PATH);
             if (!is_dir($base_path)) {
                 mkdir($base_path, 0777, true);
             }
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination($base_path);
             if ($adapter->receive()) {
                 $file = $adapter->getFileInfo();
                 $config = new System_Model_Config();
                 $config->find($code, "code");
                 $config->setValue($path . DS . $file['file']['name'])->save();
                 $message = sprintf("Your %s has been successfully saved", $code);
                 $this->_sendHtml(array("success" => 1, "message" => $this->_($message)));
             } else {
                 $messages = $adapter->getMessages();
                 if (!empty($messages)) {
                     $message = implode("\n", $messages);
                 } else {
                     $message = $this->_("An error occurred during the process. Please try again later.");
                 }
                 throw new Exception($message);
             }
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
     }
 }
コード例 #2
0
ファイル: DbServicePrice.php プロジェクト: samlanh/lynacr
 public function updateServicePrice($data)
 {
     $db = $this->getAdapter();
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $part = PUBLIC_PATH . '/images';
     $adapter->setDestination($part);
     $adapter->receive();
     $photo = $adapter->getFileInfo();
     if (!empty($photo['photo']['name'])) {
         $img = $photo['photo']['name'];
     } else {
         $img = $data['oldphoto'];
     }
     if (!empty($photo['photo1']['name'])) {
         $img1 = $photo['photo1']['name'];
     } else {
         $img1 = $data['oldphoto1'];
     }
     if (!empty($photo['photo2']['name'])) {
         $img2 = $photo['photo2']['name'];
     } else {
         $img2 = $data['oldphoto2'];
     }
     $arr = array('service_title' => $data['serice_title'], 'description' => $data['description'], 'photo' => $img, 'photo1' => $img1, 'photo2' => $img2, 'price' => $data['price'], 'date' => date("Y-m-d"), 'user_id' => $this->getUserId(), 'status' => $data['status']);
     $where = $this->getAdapter()->quoteInto("id=?", $data['id']);
     $this->update($arr, $where);
 }
コード例 #3
0
 public function uploadAction()
 {
     try {
         if (empty($_FILES) || empty($_FILES['module']['name'])) {
             throw new Exception("No file has been sent");
         }
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
         //            $adapter->addValidator('MimeType', false, 'application/zip');
         if ($adapter->receive()) {
             $file = $adapter->getFileInfo();
             $parser = new Installer_Model_Installer_Module_Parser();
             if ($parser->setFile($file['module']['tmp_name'])->check()) {
                 $infos = pathinfo($file['module']['tmp_name']);
                 $filename = $infos['filename'];
                 $this->_redirect('installer/module/install', array('module_name' => $filename));
             } else {
                 $messages = $parser->getErrors();
                 $message = implode("\n", $messages);
                 throw new Exception($this->_($message));
             }
         } else {
             $messages = $adapter->getMessages();
             if (!empty($messages)) {
                 $message = implode("\n", $messages);
             } else {
                 $message = $this->_("An error occurred during the process. Please try again later.");
             }
             throw new Exception($message);
         }
     } catch (Exception $e) {
         $this->getSession()->addError($e->getMessage());
         $this->_redirect('installer/module');
     }
 }
コード例 #4
0
 /**
  * Handle the uploaded file
  * 
  * @return string|boolean
  */
 public function handleUploadedFile()
 {
     $upload = new Zend_File_Transfer_Adapter_Http();
     $target = $this->getTargetFilename($upload->getFilename());
     $upload->addFilter(new Zend_Filter_File_Rename(array('target' => $target)));
     return $upload->receive() ? $target : false;
 }
コード例 #5
0
ファイル: Observer.php プロジェクト: adamj88/RK_TypeCMS
 /**
  * @param string $attributeCode
  * @param string $type
  * @return bool
  */
 protected static function handleUpload($attributeCode, $type)
 {
     if (!isset($_FILES)) {
         return false;
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     if ($adapter->isUploaded('typecms_' . $attributeCode . '_')) {
         if (!$adapter->isValid('typecms_' . $attributeCode . '_')) {
             Mage::throwException(Mage::helper('typecms')->__('Uploaded ' . $type . ' is invalid'));
         }
         $upload = new Varien_File_Uploader('typecms[' . $attributeCode . ']');
         $upload->setAllowCreateFolders(true);
         if ($type == 'image') {
             $upload->setAllowedExtensions(array('jpg', 'gif', 'png'));
         }
         $upload->setAllowRenameFiles(true);
         $upload->setFilesDispersion(false);
         try {
             if ($upload->save(Mage::helper('typecms')->getBaseImageDir())) {
                 return $upload->getUploadedFileName();
             }
         } catch (Exception $e) {
             Mage::throwException('Uploaded ' . $type . ' is invalid');
         }
     }
     return false;
 }
コード例 #6
0
ファイル: Image.php プロジェクト: OleKh/TestTask
 public function uploadImage($scope)
 {
     // create an instance of class Zend_File_Transfer_Adapter_Http
     // and add validator
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->addValidator('ImageSize', true, $this->_imageSize);
     $adapter->addValidator('Size', true, self::MAX_FILE_SIZE);
     // if image can be uploaded
     if ($adapter->isUploaded($scope)) {
         //validate image
         if (!$adapter->isValid($scope)) {
             Mage::throwException(Mage::helper('ab_adverboard')->__('Uploaded image is not valid'));
         }
         // upload image
         $upload = new Varien_File_Uploader($scope);
         $upload->setAllowCreateFolders(true);
         $upload->setAllowedExtensions($this->_allowedExtensions);
         $upload->setAllowRenameFiles(false);
         $upload->setFilesDispersion(false);
         if ($upload->save($this->getBaseDir(), $_FILES['image']['name'])) {
             return $upload->getUploadedFileName();
         }
     }
     return false;
 }
コード例 #7
0
 public function uploadAction()
 {
     $project_id = $this->_request->getParam('id');
     //Validate that project belongs to user here.
     $project_helper = $this->_helper->Projects;
     if ($project_helper->isOwner($this->user_session->id, $project_id, $this->project_model)) {
         $adapter = new Zend_File_Transfer_Adapter_Http();
         foreach ($adapter->getFileInfo() as $key => $file) {
             //Get extension
             $path = split("[/\\.]", $file['name']);
             $ext = end($path);
             try {
                 $adapter->addValidator('Extension', false, array('extension' => 'jpg,gif,png', 'case' => true));
                 //Should probably use the array method below to enable overwriting
                 $new_name = md5(rand()) . '-' . $project_id . '.' . $ext;
                 //Add rename filter
                 $adapter->addFilter('Rename', UPLOAD_PATH . $new_name);
             } catch (Zend_File_Transfer_Exception $e) {
                 die($e->getMessage());
             }
             try {
                 //Store
                 if ($adapter->receive($file['name'])) {
                     $this->image_model->addOne($project_id, $new_name, $key);
                 }
             } catch (Zend_File_Transfer_Exception $e) {
                 die($e->getMessage());
             }
         }
         header("Location: /account/project/id/{$project_id}");
     } else {
         header("Location: /account");
     }
 }
コード例 #8
0
 public function signupAction()
 {
     $users = new Application_Model_User();
     $form = new Application_Form_Registration();
     $this->view->form = $form;
     // Define a transport and set the destination on the server
     //   $upload = new Zend_File_Transfer_Adapter_Http();
     // $upload->addFilter('Rename', APPLICATION_PATH . '/../data/'.'jpg');
     // $upload->addFilter('Rename', APPLICATION_PATH . '/../data/');
     // Zend_Debug::dump($upload->getFileInfo());
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             //                 $upload->setDestination('data/');
             //
             //                 $upload->receive();
             $data = $form->getValues();
             $upload = new Zend_File_Transfer_Adapter_Http();
             $upload->receive();
             if ($data['password'] != $data['confirmPassword']) {
                 $this->view->errorMessage = "Password and confirm password don't match.";
                 return;
             }
             if ($users->checkUnique($data['name'])) {
                 $this->view->errorMessage = "Name already taken. Please choose      another one.";
                 return;
             }
             unset($data['confirmPassword']);
             $users->insert($data);
             echo 'tmaaaaaaaam';
             $this->_redirect('auth/login');
             echo 'tmaaaaaaaam';
         }
     }
 }
コード例 #9
0
 /**
  * Bulk product upload functinality for seller
  *
  * @return void
  */
 public function bulkuploadAction()
 {
     /**
      * Check license key
      */
     Mage::helper('marketplace')->checkMarketplaceKey();
     /**
      * Check whether seller or not
      */
     $this->checkWhetherSellerOrNot();
     try {
         /**
          * New zend File Uploader
          */
         $uploadsData = new Zend_File_Transfer_Adapter_Http();
         $filesDataArray = $uploadsData->getFileInfo();
         /**
          * Checking whether csv exist or not
          */
         if (!empty($filesDataArray)) {
             $this->saveBulkUploadFiles($filesDataArray);
         }
     } catch (Exception $e) {
         /**
          * Display error message for csv file upload
          */
         Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
         $this->_redirect('marketplace/product/manage');
         return;
     }
 }
コード例 #10
0
 function configAction()
 {
     // When the form is submitted
     $form_mess = "";
     if (isset($_POST['confName'])) {
         $form_mess = $this->updateConfig($_POST, $this->db_v1, $this->view, $this->session);
         $this->config_v1 = GetConfig($this->db_v1);
         // Check whether the logo file has been transmitted
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination('images/');
         $adapter->addValidator('IsImage', false);
         if ($adapter->receive()) {
             $name = $adapter->getFileName('logo_file');
             //récupérer le nom du fichier sans avoir tout le chemin
             $name = basename($name);
             $this->db_v1->execRequete("UPDATE Config SET logo_file='{$name}'");
         }
         $config = new Config();
         $this->config = $config->fetchAll()->current();
         $this->config->putInView($this->view);
         $registry = Zend_registry::getInstance();
         $registry->set("Config", $this->config);
     }
     $this->view->config_message = $form_mess;
     $this->instantiateConfigVars($this->config_v1, $this->view);
     $this->view->setFile("content", "config.xml");
     $this->view->setFile("form_config", "form_config.xml");
     $form_mess = "";
     $this->view->messages = $form_mess;
     // N.B: the config values ar eput in the views by the Myreview controller
     echo $this->view->render("layout");
 }
コード例 #11
0
 public function uploadAction()
 {
     try {
         if (empty($_FILES) || empty($_FILES['file']['name'])) {
             throw new Exception($this->_("No file has been sent"));
         }
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
         if ($adapter->receive()) {
             $file = $adapter->getFileInfo();
             $data = $this->_getPackageDetails($file['file']['tmp_name']);
         } else {
             $messages = $adapter->getMessages();
             if (!empty($messages)) {
                 $message = implode("\n", $messages);
             } else {
                 $message = $this->_("An error occurred during the process. Please try again later.");
             }
             throw new Exception($message);
         }
     } catch (Exception $e) {
         $data = array("error" => 1, "message" => $e->getMessage());
     }
     $this->_sendHtml($data);
 }
コード例 #12
0
 public function uploadFile($object, $type, $subtype)
 {
     $sheets = new SxModule_Sheets();
     $base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
     $path = $type . '/' . $subtype;
     if (!is_dir($base . '/' . $path)) {
         echo $base . '/' . $path;
         mkdir($base . '/' . $type);
         mkdir($base . '/' . $path);
     }
     if ($object->getFile() == null) {
         $object->setFile('');
     }
     $uploadAdapter = new Zend_File_Transfer_Adapter_Http();
     $uploadAdapter->setDestination($base . '/' . $path);
     $uploadAdapter->setOptions(array('ignoreNoFile' => true));
     $uploadAdapter->receive();
     $files = $uploadAdapter->getFileName(null, true);
     foreach ($_FILES['file']['name'] as $key => $filename) {
         if (!$filename) {
             continue;
         }
         $file = $base . '/' . $path . '/' . $filename;
         $date = date('Y-m-d His');
         $path_info = pathinfo($filename);
         $myfilename = str_replace(' ', '_', $path_info['filename'] . '_' . $date . '.' . $path_info['extension']);
         $myfilename = $sheets->createFileName($myfilename);
         $newfile = $base . '/' . $path . '/' . $myfilename;
         rename($file, $newfile);
         $object->setFile($myfilename);
     }
 }
コード例 #13
0
 public function addAction()
 {
     SxCms_Acl::requireAcl('securedocs', 'securedocs.add');
     $base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
     $path = base64_decode($this->_getParam('path'));
     if ($this->getRequest()->isPost()) {
         $uploadAdapter = new Zend_File_Transfer_Adapter_Http();
         $uploadAdapter->setDestination($base . $path);
         $uploadAdapter->setOptions(array('ignoreNoFile' => true));
         $uploadAdapter->receive();
         $files = $uploadAdapter->getFileName(null, true);
         foreach ($_FILES['file']['name'] as $key => $filename) {
             if (!$filename) {
                 continue;
             }
             $summary = $this->_getParam('samenvatting');
             $mail = $this->_getParam('mail', '');
             $file = $base . $path . '/' . $filename;
             $newfile = $base . $path . '/' . str_replace(" ", "", $filename);
             rename($file, $newfile);
             $file = new SxModule_Securedocs_File($newfile);
             $file->setPath($path);
             $file->setSummary($summary[$key]);
             $file->setMail(isset($mail[$key]) ? "1" : "0");
             $file->save();
             if ($mail[$key]) {
                 $groups = explode('/', $path);
                 $control = $path;
                 if ($control != "") {
                     $proxy = new SxModule_Securedocs_Folder_Proxy();
                     $folder = $proxy->getByFolder($groups[1]);
                     $folderId = $folder->getFolderId();
                     $proxy = new SxModule_Securedocs_Group_Proxy();
                     $groups = $proxy->getAllByMap($folderId);
                     $aantal = count($groups);
                     $q = 0;
                     $groupids = '(';
                     foreach ($groups as $group) {
                         $q++;
                         if ($q != $aantal) {
                             $groupids .= $group->getGroupId() . ",";
                         } else {
                             $groupids .= $group->getGroupId();
                         }
                     }
                     $groupids .= ')';
                     $proxy = new SxModule_Members_Proxy();
                     $members = $proxy->getAllByGroups($groupids);
                     foreach ($members as $member) {
                         $member->sendDocument($file);
                     }
                 }
             }
         }
         $this->_redirect('/admin/securedocs/index/path/' . base64_encode($path));
     }
     $this->view->path = $path;
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Securedocs_File');
 }
コード例 #14
0
 /**
  * upload
  */
 public function uploadAction()
 {
     // disable layouts for this action:
     $this->_helper->layout->disableLayout();
     if ($this->_request->isPost()) {
         try {
             $destination = PUBLIC_PATH . "/uploads/files";
             /* Check destination folder */
             if (!is_dir($destination)) {
                 if (is_writable(PUBLIC_PATH . "/uploads")) {
                     mkdir($destination);
                 } else {
                     throw new Exception("Uploads directory is not writable");
                 }
             }
             /* Uploading Document File on Server */
             $upload = new Zend_File_Transfer_Adapter_Http();
             try {
                 // upload received file(s)
                 $upload->receive();
             } catch (Zend_File_Transfer_Exception $e) {
                 $e->getMessage();
             }
             // you MUST use following functions for knowing about uploaded file
             // Returns the file name for 'doc_path' named file element
             $filePath = $upload->getFileName('file');
             // pathinfo
             $name = pathinfo($filePath, PATHINFO_FILENAME);
             $ext = pathinfo($filePath, PATHINFO_EXTENSION);
             // prepare filename
             $name = strtolower($name);
             $name = preg_replace('/[^a-z0-9_-]/', '-', $name);
             // prepare extension
             if ($ext == 'php' or $ext == 'php4' or $ext == 'php5' or $ext == 'phtml') {
                 $ext = 'phps';
             }
             // rename uploaded file
             $renameFile = $name . '.' . $ext;
             $counter = 0;
             while (file_exists($destination . '/' . $renameFile)) {
                 $counter++;
                 $renameFile = $name . '-' . $counter . '.' . $ext;
             }
             $fileIco = $this->getIco($ext);
             $fullFilePath = $destination . '/' . $renameFile;
             // Rename uploaded file using Zend Framework
             $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
             $filterFileRename->filter($filePath);
             $this->_helper->viewRenderer->setNoRender(true);
             $link = '<a href="javascript:void(null);" rel="' . $renameFile . '" class="redactor_file_link redactor_file_ico_' . $fileIco . '" title="' . $renameFile . '">' . $renameFile . '</a>';
             echo $link;
         } catch (Exception $e) {
             $this->_forwardError($e->getMessage());
         }
     } else {
         $this->_forwardError('Internal Error of Uploads controller');
     }
 }
 public function saveProviderAction($providerId, Form_GenericProviderConfiguration $form, $action, $actionType)
 {
     $actionObject = null;
     $contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($this->client);
     try {
         $actionObject = $contentDistributionPlugin->genericDistributionProviderAction->getByProviderId($providerId, $actionType);
     } catch (Exception $e) {
     }
     $isNew = true;
     if ($actionObject) {
         $isNew = false;
     } else {
         $actionObject = new Kaltura_Client_ContentDistribution_Type_GenericDistributionProviderAction();
         $actionObject->genericDistributionProviderId = $providerId;
         $actionObject->action = $actionType;
     }
     $actionObject = $form->getActionObject($actionObject, $action, $actionType);
     if (!$actionObject) {
         if (!$isNew) {
             $contentDistributionPlugin->genericDistributionProviderAction->deleteByProviderId($providerId, $actionType);
         }
         return;
     }
     $genericDistributionProviderAction = null;
     if ($isNew) {
         $genericDistributionProviderAction = $contentDistributionPlugin->genericDistributionProviderAction->add($actionObject);
     } else {
         // reset all readonly fields
         $actionObject->id = null;
         $actionObject->createdAt = null;
         $actionObject->updatedAt = null;
         $actionObject->genericDistributionProviderId = null;
         $actionObject->action = null;
         $actionObject->status = null;
         $actionObject->mrssTransformer = null;
         $actionObject->mrssValidator = null;
         $actionObject->resultsTransformer = null;
         $genericDistributionProviderAction = $contentDistributionPlugin->genericDistributionProviderAction->updateByProviderId($providerId, $actionType, $actionObject);
     }
     $genericDistributionProviderActionId = $genericDistributionProviderAction->id;
     $upload = new Zend_File_Transfer_Adapter_Http();
     $files = $upload->getFileInfo();
     if (count($files)) {
         if (isset($files["mrssTransformer{$action}"]) && $files["mrssTransformer{$action}"]['size']) {
             $file = $files["mrssTransformer{$action}"];
             $contentDistributionPlugin->genericDistributionProviderAction->addMrssTransformFromFile($genericDistributionProviderActionId, $file['tmp_name']);
         }
         if (isset($files["mrssValidator{$action}"]) && $files["mrssValidator{$action}"]['size']) {
             $file = $files["mrssValidator{$action}"];
             $contentDistributionPlugin->genericDistributionProviderAction->addMrssValidateFromFile($genericDistributionProviderActionId, $file['tmp_name']);
         }
         if (isset($files["resultsTransformer{$action}"]) && $files["resultsTransformer{$action}"]['size']) {
             $file = $files["resultsTransformer{$action}"];
             $contentDistributionPlugin->genericDistributionProviderAction->addResultsTransformFromFile($genericDistributionProviderActionId, $file['tmp_name']);
         }
     }
 }
コード例 #16
0
 public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false)
 {
     $object = parent::getObject($objectType, $properties, $add_underscore, $include_empty_fields);
     $upload = new Zend_File_Transfer_Adapter_Http();
     $files = $upload->getFileInfo();
     if (count($files) && isset($files["xslfile"]) && $files["xslfile"]['size']) {
         $object->xsl = file_get_contents($files["xslfile"]['tmp_name']);
     }
     return $object;
 }
コード例 #17
0
 public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false)
 {
     /* @var $object Kaltura_Client_FtpDistribution_Type_FtpDistributionProfile */
     $object = parent::getObject($objectType, $properties, $add_underscore, true);
     $upload = new Zend_File_Transfer_Adapter_Http();
     $files = $upload->getFileInfo();
     if (isset($files['sftp_public_key'])) {
         $object->sftpPublicKey = $this->getFileContent($files['sftp_public_key']);
     }
     if (isset($files['sftp_private_key'])) {
         $object->sftpPrivateKey = $this->getFileContent($files['sftp_private_key']);
     }
     if (isset($files['aspera_public_key'])) {
         $object->asperaPublicKey = $this->getFileContent($files['aspera_public_key']);
     }
     if (isset($files['aspera_private_key'])) {
         $object->asperaPrivateKey = $this->getFileContent($files['aspera_private_key']);
     }
     $updateRequiredEntryFields = array();
     $updateRequiredMetadataXpaths = array();
     $entryFields = array_keys($this->getEntryFields());
     $metadataXpaths = array_keys($this->getMetadataFields());
     $fieldConfigArray = $object->fieldConfigArray;
     foreach ($properties as $property => $value) {
         if (!$value) {
             continue;
         }
         $updateField = null;
         $matches = null;
         if (preg_match('/update_required_entry_fields_(\\d+)$/', $property, $matches)) {
             $index = $matches[1];
             if (isset($entryFields[$index])) {
                 $updateField = $entryFields[$index];
             }
         }
         if (preg_match('/update_required_metadata_xpaths_(\\d+)$/', $property, $matches)) {
             $index = $matches[1];
             if (isset($metadataXpaths[$index])) {
                 $updateField = $metadataXpaths[$index];
             }
         }
         if ($updateField) {
             $fieldConfig = new Kaltura_Client_ContentDistribution_Type_DistributionFieldConfig();
             $fieldConfig->fieldName = md5($updateField);
             // needs to have a value for the field to get saved
             $fieldConfig->updateOnChange = true;
             $string = new Kaltura_Client_Type_String();
             $string->value = $updateField;
             $fieldConfig->updateParams = array($string);
             $fieldConfigArray[] = $fieldConfig;
         }
     }
     $object->fieldConfigArray = $fieldConfigArray;
     return $object;
 }
コード例 #18
0
 public function indexAction()
 {
     SxCms_Acl::requireAcl('filemanager', 'filemanager.index');
     $base = APPLICATION_PATH . '/../public_html/files/';
     $base = realpath($base);
     $path = base64_decode($this->_getParam('path'));
     if ($this->getRequest()->isPost()) {
         if (null !== $this->_getParam('folder')) {
             SxCms_Acl::requireAcl('filemanager', 'filemanager.add.folder');
             if (strlen($this->_getParam('folder'))) {
                 $dirname = $path . '/' . $this->_getParam('folder');
                 mkdir($base . $dirname);
                 $this->_redirect('/admin/filemanager/index/path/' . base64_encode($path));
             }
         } else {
             SxCms_Acl::requireAcl('filemanager', 'filemanager.add.file');
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination(realpath($base) . $path);
             if ($adapter->receive()) {
                 $filename = realpath($adapter->getFileName('filename'));
                 $file = new SxCms_File($filename);
                 $path = $file->getPathnameFromBase();
                 $nfile = $path . '/' . $file->getBasename();
                 $this->_redirect('/admin/filemanager/edit/file/' . base64_encode($nfile) . '/path/' . base64_encode($path));
             } else {
                 $msg = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
                 $msg->addMessage('file', $adapter->getMessages());
             }
         }
     }
     $this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
     try {
         $it = new SxCms_Filesystem(realpath($base . $path));
     } catch (Exception $e) {
         $it = new SxCms_Filesystem($base);
         $path = '';
         $e;
     }
     $topdir = explode('/', $path);
     if (count($topdir) > 1) {
         array_pop($topdir);
         $topdir = implode('/', $topdir);
     } else {
         $topdir = '';
     }
     $this->view->files = $it;
     $this->view->path = $path;
     $this->view->showpath = explode('/', $path);
     $this->view->topdir = $topdir;
     if ($this->_getParam('full')) {
         $this->_helper->layout->setLayout('nolayout');
         $this->view->full = true;
     }
 }
 /**
  * Processa os dados do formulário de importação de RPS [json]
  * 
  * @return void
  */
 public function rpsProcessarAction()
 {
     parent::noLayout();
     $oForm = new Contribuinte_Form_ImportacaoArquivo();
     $oForm->renderizaCamposRPS();
     // Adiciona a validação do arquivo junto ao restante das mensagens de erro do form
     $aDados = array_merge($this->getRequest()->getPost(), array('isUploaded' => $oForm->arquivo->isUploaded()));
     // Valida o formulario e processa a importação
     if ($this->getRequest()->isPost() && $oForm->arquivo->isUploaded()) {
         $oArquivoUpload = new Zend_File_Transfer_Adapter_Http();
         try {
             $oArquivoUpload->setDestination(APPLICATION_PATH . '/../public/tmp/');
             // Confirma o upload e processa o arquivo
             if ($oArquivoUpload->receive()) {
                 $oImportacaoModelo1 = new Contribuinte_Model_ImportacaoArquivoRpsModelo1();
                 $oImportacaoModelo1->setArquivoCarregado($oArquivoUpload->getFileName());
                 $oArquivoCarregado = $oImportacaoModelo1->carregar();
                 if ($oArquivoCarregado != NULL && $oImportacaoModelo1->validaArquivoCarregado()) {
                     // Valida as regras de negócio e processa a importação
                     $oImportacaoProcessamento = new Contribuinte_Model_ImportacaoArquivoProcessamento();
                     $oImportacaoProcessamento->setCodigoUsuarioLogado($this->usuarioLogado->getId());
                     $oImportacaoProcessamento->setArquivoCarregado($oArquivoCarregado);
                     // Processa a importação
                     $oImportacao = $oImportacaoProcessamento->processarImportacaoRps();
                     if ($oImportacao->getId()) {
                         $sUrlRecibo = "/contribuinte/importacao-arquivo/rps-recibo/id/{$oImportacao->getId()}";
                         $aRetornoJson['status'] = TRUE;
                         $aRetornoJson['url'] = $this->view->baseUrl($sUrlRecibo);
                         $aRetornoJson['success'] = $this->translate->_('Arquivo importado com sucesso.');
                     } else {
                         throw new Exception($this->translate->_('Ocorreu um erro ao importar o arquivo.'));
                     }
                 } else {
                     throw new Exception($oImportacaoModelo1->processaErroSistema());
                 }
             }
         } catch (DBSeller_Exception_ImportacaoXmlException $oErro) {
             $aRetornoJson['status'] = FALSE;
             $aRetornoJson['error'] = array_merge(array('<b>' . $this->translate->_('Ocorreu um erro ao importar o arquivo:') . '</b><br>'), $oErro->getErrors());
         } catch (Exception $oErro) {
             $aRetornoJson['status'] = FALSE;
             $aRetornoJson['error'][] = $oErro->getMessage();
         }
         if (is_file($oArquivoUpload->getFileName())) {
             unlink($oArquivoUpload->getFileName());
         }
     } else {
         $aRetornoJson['status'] = FALSE;
         $aRetornoJson['fields'] = array_keys($oForm->getMessages());
         $aRetornoJson['error'][] = $this->translate->_('Preencha os dados corretamente.');
     }
     echo $this->getHelper('json')->sendJson($aRetornoJson);
 }
コード例 #20
0
ファイル: DbRestore.php プロジェクト: samlanh/lynacr
 public function UploadFileDatabase($data)
 {
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination(PUBLIC_PATH);
     $fileinfo = $adapter->getFileInfo();
     $rs = $adapter->receive();
     if ($rs == 1) {
         return true;
     } else {
         return false;
     }
 }
コード例 #21
0
ファイル: FileUploader.php プロジェクト: jager/cms
 public function transferFile()
 {
     if (!is_dir($this->_path)) {
         mkdir($this->_path, 0777, true);
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($this->_path);
     if (!$adapter->receive()) {
         $messages = $adapter->getMessages();
         throw new Exception(implode("<br />", $messages));
     }
     return $adapter->getFileInfo();
 }
コード例 #22
0
ファイル: Layouts.php プロジェクト: Sywooch/forums
 public function actionInstall()
 {
     $this->_assertPostOnly();
     $fileTransfer = new Zend_File_Transfer_Adapter_Http();
     if ($fileTransfer->isUploaded('upload_file')) {
         $fileInfo = $fileTransfer->getFileInfo('upload_file');
         $fileName = $fileInfo['upload_file']['tmp_name'];
     } else {
         $fileName = $this->_input->filterSingle('server_file', XenForo_Input::STRING);
     }
     $this->getModelFromCache('EWRporta_Model_Layouts')->installLayoutXmlFromFile($fileName);
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('ewrporta/layouts'));
 }
コード例 #23
0
 public function actionXenGallerySave()
 {
     $this->_assertPostOnly();
     $input = $this->_input->filter(array('group_id' => XenForo_Input::STRING, 'options' => XenForo_Input::ARRAY_SIMPLE, 'options_listed' => array(XenForo_Input::STRING, array('array' => true))));
     $options = XenForo_Application::getOptions();
     $optionModel = $this->_getOptionModel();
     $group = $optionModel->getOptionGroupById($input['group_id']);
     foreach ($input['options_listed'] as $optionName) {
         if ($optionName == 'xengalleryUploadWatermark') {
             continue;
         }
         if (!isset($input['options'][$optionName])) {
             $input['options'][$optionName] = '';
         }
     }
     $delete = $this->_input->filterSingle('delete_watermark', XenForo_Input::BOOLEAN);
     if ($delete) {
         $existingWatermark = $options->get('xengalleryUploadWatermark');
         if ($existingWatermark) {
             $watermarkWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Watermark', XenForo_DataWriter::ERROR_SILENT);
             $watermarkWriter->setExistingData($existingWatermark);
             $watermarkWriter->delete();
             $input['options']['xengalleryUploadWatermark'] = 0;
             $optionModel->updateOptions($input['options']);
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildAdminLink('options/list', $group)));
         }
     }
     $fileTransfer = new Zend_File_Transfer_Adapter_Http();
     if ($fileTransfer->isUploaded('watermark')) {
         $fileInfo = $fileTransfer->getFileInfo('watermark');
         $fileName = $fileInfo['watermark']['tmp_name'];
         $watermarkWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Watermark', XenForo_DataWriter::ERROR_SILENT);
         $existingWatermark = $options->get('xengalleryUploadWatermark');
         if ($existingWatermark) {
             $watermarkWriter->setExistingData($existingWatermark);
         }
         $watermarkData = array('watermark_user_id' => XenForo_Visitor::getUserId(), 'is_site' => 1);
         $watermarkWriter->bulkSet($watermarkData);
         $watermarkWriter->save();
         $image = new XenGallery_Helper_Image($fileName);
         $image->resize($options->xengalleryWatermarkDimensions['width'], $options->xengalleryWatermarkDimensions['height'], 'fit');
         $watermarkModel = $this->_getWatermarkModel();
         $watermarkPath = $watermarkModel->getWatermarkFilePath($watermarkWriter->get('watermark_id'));
         if (XenForo_Helper_File::createDirectory(dirname($watermarkPath), true)) {
             XenForo_Helper_File::safeRename($fileName, $watermarkPath);
             $input['options']['xengalleryUploadWatermark'] = $watermarkWriter->get('watermark_id');
         }
     }
     $optionModel->updateOptions($input['options']);
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildAdminLink('options/list', $group)));
 }
コード例 #24
0
ファイル: DbRestore.php プロジェクト: samlanh/lynacr
 public function UploadFileDatabase($data)
 {
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination(PUBLIC_PATH);
     $fileinfo = $adapter->getFileInfo();
     $rs = $adapter->receive();
     if ($rs == 1) {
         // 			return true;
         $file_name = $fileinfo['fileToUpload']['name'];
         $this->getRestoreDatabase($file_name);
     } else {
         return false;
     }
 }
コード例 #25
0
 public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false)
 {
     $object = parent::getObject($objectType, $properties, $add_underscore, $include_empty_fields);
     if ($object instanceof Kaltura_Client_TvinciDistribution_Type_TvinciDistributionProfile) {
         $upload = new Zend_File_Transfer_Adapter_Http();
         $files = $upload->getFileInfo();
         if (isset($files['xsltFile'])) {
             $file = $files['xsltFile'];
             $content = file_get_contents($file['tmp_name']);
             $object->xsltFile = $content;
         }
     }
     return $object;
 }
コード例 #26
0
 public function introasyncajaxAction()
 {
     $this->getResponse()->setHeader('Content-Type', 'application/json');
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $params = $this->_getAllParams();
     $intro = new Application_Model_O_GlobalConsultation();
     $validate = new Yy_Validate_Value();
     if ($validate->isValid($params['id'])) {
         $intro->setId($params['id']);
     } else {
         $intro->setCtime(date('Y-m-d H:i:s'));
     }
     if ($validate->isValid($params['title'])) {
         $intro->setTitle($params['title']);
     }
     if ($validate->isValid($params['content'])) {
         $intro->setContent($params['content']);
     }
     if ($validate->isValid($params['sort'])) {
         $intro->setSort($params['sort']);
     }
     if ($validate->isValid($params['status'])) {
         $intro->setStatus($params['status']);
     }
     try {
         $intro->save();
         $id = $intro->getId();
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $wrdir = Yy_Utils::getWriteDir();
         $adapter->setDestination($wrdir);
         if (!$adapter->receive()) {
             $messages = $adapter->getMessages();
             //echo implode("\n", $messages);
         }
         $filename = $adapter->getFileName();
         if (is_string($filename)) {
             $handle = fopen($filename, 'rb');
             $img = addslashes(fread($handle, filesize($filename)));
             fclose($handle);
             Application_Model_M_GlobalConsultation::updateImage($id, $img);
         }
         $url = '/diagnosis/introview?id=' . $id;
         $this->redirect($url);
     } catch (Zend_Db_Exception $e) {
         //$this->redirect('/error');
         $this->redirect('/error?message=' . $e->getMessage());
     }
 }
コード例 #27
0
ファイル: Foto.php プロジェクト: jager/cms
 private function transfer($destination)
 {
     //s( $destination ); return;
     if (!is_dir($destination)) {
         mkdir($destination, 0777, true);
     }
     $adapter = new Zend_File_Transfer_Adapter_Http();
     $adapter->setDestination($destination);
     if (!$adapter->receive()) {
         $messages = $adapter->getMessages();
         return implode("<br />", $messages);
     } else {
         return $adapter;
     }
 }
コード例 #28
0
ファイル: Admin.php プロジェクト: Sywooch/forums
 public function actionImport()
 {
     if (!$this->perms['admin']) {
         return $this->responseNoPermission();
     }
     if (XenForo_Application::autoload('EWRmedio_XML_Premium')) {
         $fileTransfer = new Zend_File_Transfer_Adapter_Http();
         if ($fileTransfer->isUploaded('upload_file')) {
             $fileInfo = $fileTransfer->getFileInfo('upload_file');
             $fileName = $fileInfo['upload_file']['tmp_name'];
             $this->getModelFromCache('EWRmedio_Model_Services')->importService($fileName);
         }
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('media/admin/services'));
 }
コード例 #29
0
ファイル: Upload.php プロジェクト: lchen01/STEdwards
 /**
  * Use the Zend Framework adapter to handle validation instead of the 
  * built-in _validateFile() method.
  * 
  * @see Omeka_File_Ingest_AbstractIngest::_validateFile()
  * @param Zend_Validate_Interface $validator
  * @return void
  */
 public function addValidator(Zend_Validate_Interface $validator)
 {
     if (!$this->_adapter) {
         $this->_buildAdapter();
     }
     $this->_adapter->addValidator($validator);
 }
コード例 #30
-1
ファイル: Imagem.php プロジェクト: sgdoc/sgdoce-codigo
 /**
  * Metdo responsavel por persistir os uploads
  * @param type $destino
  * @param type $thumb
  * @param type $validFile
  * @param type $invalidFile
  * @return type
  */
 public static function upload($destino = 'anexoArtefato', $thumb = FALSE, $validFile = TRUE, $invalidFile = TRUE, $validImageSize = TRUE)
 {
     $configs = \Core_Registry::get('configs');
     $upload = new \Zend_File_Transfer_Adapter_Http();
     $files = $upload->getFileInfo();
     $filesUp = array();
     $return = array();
     $error = false;
     $pasta = 'anexo-material';
     if ($destino == 'anexoArtefato') {
         $pasta = 'anexo-artefato';
     }
     $path = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $pasta . DIRECTORY_SEPARATOR;
     foreach ($files as $file => $info) {
         $upload = new \Zend_File_Transfer_Adapter_Http();
         $upload->setDestination($path);
         $upload->setValidators(array());
         $upload->addValidator('Size', TRUE, array('max' => '100MB', 'messages' => "O tamanho do arquivo é superior ao permitido. O tamanho permitido é 100MB."));
         self::_invalidFile($invalidFile, $upload);
         self::_validFile($validFile, $upload);
         self::_validImageSize($validImageSize, $upload);
         self::_getValidator($upload);
         if ($upload->isValid($file)) {
             $fileinfo = pathinfo($info['name']);
             $upload->receive($file);
             $filesUp[] = $upload->getFileName($file);
             $return[] = array('name' => $upload->getFileName($file), 'size' => $upload->getFileSize($file));
         } else {
             $error = $upload->getMessages();
             break;
         }
     }
     if ($error) {
         if (count($filesUp)) {
             foreach ($filesUp as $file) {
                 unlink($file);
             }
         }
         return array('errors' => $error);
     }
     if ($thumb) {
         $pasta = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR;
         foreach ($filesUp as $endereco) {
             $fileinfo = pathinfo($endereco);
             $image = \WideImage::load($endereco);
             $image->resize(300, 300, 'outside')->crop('50% - 150', '50% - 150', 300, 300)->saveToFile($pasta . $fileinfo['filename'] . '_300_X_300.' . strtolower($fileinfo['extension']));
             $image->resize(133, 89, 'outside')->crop('50% - 67', '50% - 45', 133, 89)->saveToFile($pasta . $fileinfo['filename'] . '_133_X_89.' . strtolower($fileinfo['extension']));
         }
     }
     return $return;
 }