当前位置: 首页>>代码示例>>PHP>>正文


PHP eZHTTPFile类代码示例

本文整理汇总了PHP中eZHTTPFile的典型用法代码示例。如果您正苦于以下问题:PHP eZHTTPFile类的具体用法?PHP eZHTTPFile怎么用?PHP eZHTTPFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了eZHTTPFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

/**
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2013.11
 * @package kernel
 */
$module = $Params['Module'];
if (!eZPackage::canUsePolicyFunction('import')) {
    return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
$package = false;
$installElements = false;
$errorList = array();
if ($module->isCurrentAction('UploadPackage')) {
    if (eZHTTPFile::canFetch('PackageBinaryFile')) {
        $file = eZHTTPFile::fetch('PackageBinaryFile');
        if ($file) {
            $packageFilename = $file->attribute('filename');
            $package = eZPackage::import($packageFilename, $packageName);
            if ($package instanceof eZPackage) {
                if ($package->attribute('install_type') != 'install' or !$package->attribute('can_install')) {
                    return $module->redirectToView('view', array('full', $package->attribute('name')));
                } else {
                    if ($package->attribute('install_type') == 'install') {
                        return $module->redirectToView('install', array($package->attribute('name')));
                    }
                }
            } else {
                if ($package == eZPackage::STATUS_ALREADY_EXISTS) {
                    $errorList[] = array('description' => ezpI18n::tr('kernel/package', 'Package %packagename already exists, cannot import the package', false, array('%packagename' => $packageName)));
                } else {
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:31,代码来源:upload.php

示例2: fetchObjectAttributeHTTPInput

 /**
  * Fetch object attribute http input, override the ezDataType method
  * This method is triggered when submiting a http form which includes Image class
  * Image is stored into file system every time there is a file input and validation result is valid.
  * @param $http http object
  * @param $base
  * @param $contentObjectAttribute : the content object attribute being handled
  * @return true if content object is not null, false if content object is null
  */
 function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     $result = false;
     $imageAltText = false;
     $hasImageAltText = false;
     if ($http->hasPostVariable($base . "_data_imagealttext_" . $contentObjectAttribute->attribute("id"))) {
         $imageAltText = $http->postVariable($base . "_data_imagealttext_" . $contentObjectAttribute->attribute("id"));
         $hasImageAltText = true;
     }
     $content = $contentObjectAttribute->attribute('content');
     $httpFileName = $base . "_data_imagename_" . $contentObjectAttribute->attribute("id");
     if (eZHTTPFile::canFetch($httpFileName)) {
         $httpFile = eZHTTPFile::fetch($httpFileName);
         if ($httpFile) {
             if ($content) {
                 $content->setHTTPFile($httpFile);
                 $result = true;
             }
         }
     }
     if ($content) {
         if ($hasImageAltText) {
             $content->setAttribute('alternative_text', $imageAltText);
         }
         $result = true;
     }
     return $result;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:37,代码来源:ezimagetype.php

示例3: uploadPackage

 /**
  * Upload local package.
  *
  * \private
  */
 function uploadPackage()
 {
     if (!eZHTTPFile::canFetch('PackageBinaryFile')) {
         $this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'No package selected for upload') . '.';
         return;
     }
     $file = eZHTTPFile::fetch('PackageBinaryFile');
     if (!$file) {
         $this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Failed fetching upload package file');
         return;
     }
     $packageFilename = $file->attribute('filename');
     $packageName = $file->attribute('original_filename');
     if (preg_match("#^(.+)-[0-9](\\.[0-9]+)-[0-9].ezpkg\$#", $packageName, $matches)) {
         $packageName = $matches[1];
     }
     $packageName = preg_replace(array("#[^a-zA-Z0-9]+#", "#_+#", "#(^_)|(_\$)#"), array('_', '_', ''), $packageName);
     $package = eZPackage::import($packageFilename, $packageName, false);
     if (is_object($package)) {
         // package successfully imported
         return;
     } elseif ($package == eZPackage::STATUS_ALREADY_EXISTS) {
         eZDebug::writeWarning("Package '{$packageName}' already exists.");
     } else {
         $this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Uploaded file is not an eZ Publish package');
     }
 }
开发者ID:nlenardou,项目名称:ezpublish,代码行数:32,代码来源:ezstep_site_types.php

示例4: validateImageFiles

    function validateImageFiles( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        // If we don't have an image we continue as normal
        if ( !eZHTTPFile::canFetch( 'PackageImageFile' ) )
            return true;

        $file = eZHTTPFile::fetch( 'PackageImageFile' );

        $result = true;
        if ( $file )
        {
            $mimeData = eZMimeType::findByFileContents( $file->attribute( 'original_filename' ) );
            $dir = eZSys::storageDirectory() .  '/temp';
            eZMimeType::changeDirectoryPath( $mimeData, $dir );
            $file->store( false, false, $mimeData );
            $persistentData['imagefiles'][] = $mimeData;
            $result = false;
        }
        return $result;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:20,代码来源:ezstylepackagecreator.php

示例5: fetchObjectAttributeHTTPInput

    function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        eZBinaryFileType::checkFileUploads();
        if ( $this->isDeletingFile( $http, $contentObjectAttribute ) )
        {
            return false;
        }

        if ( !eZHTTPFile::canFetch( $base . "_data_binaryfilename_" . $contentObjectAttribute->attribute( "id" ) ) )
            return false;

        $binaryFile = eZHTTPFile::fetch( $base . "_data_binaryfilename_" . $contentObjectAttribute->attribute( "id" ) );

        $contentObjectAttribute->setContent( $binaryFile );

        if ( $binaryFile instanceof eZHTTPFile )
        {
            $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
            $version = $contentObjectAttribute->attribute( "version" );

            /*
            $mimeObj = new  eZMimeType();
            $mimeData = $mimeObj->findByURL( $binaryFile->attribute( "original_filename" ), true );
            $mime = $mimeData['name'];
            */

            $mimeData = eZMimeType::findByFileContents( $binaryFile->attribute( "original_filename" ) );
            $mime = $mimeData['name'];

            if ( $mime == '' )
            {
                $mime = $binaryFile->attribute( "mime_type" );
            }
            $extension = eZFile::suffix( $binaryFile->attribute( "original_filename" ) );
            $binaryFile->setMimeType( $mime );
            if ( !$binaryFile->store( "original", $extension ) )
            {
                eZDebug::writeError( "Failed to store http-file: " . $binaryFile->attribute( "original_filename" ),
                                     "eZBinaryFileType" );
                return false;
            }

            $binary = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
            if ( $binary === null )
                $binary = eZBinaryFile::create( $contentObjectAttributeID, $version );

            $orig_dir = $binaryFile->storageDir( "original" );

            $binary->setAttribute( "contentobject_attribute_id", $contentObjectAttributeID );
            $binary->setAttribute( "version", $version );
            $binary->setAttribute( "filename", basename( $binaryFile->attribute( "filename" ) ) );
            $binary->setAttribute( "original_filename", $binaryFile->attribute( "original_filename" ) );
            $binary->setAttribute( "mime_type", $mime );

            $binary->store();

            $filePath = $binaryFile->attribute( 'filename' );
            $fileHandler = eZClusterFileHandler::instance();
            $fileHandler->fileStore( $filePath, 'binaryfile', true, $mime );

            $contentObjectAttribute->setContent( $binary );
        }
        return true;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:64,代码来源:ezbinaryfiletype.php

示例6: fetchHTTPFile

 /**
  * Fetches the HTTP-File into $file and fills in MIME-Type information into $mimeData.
  *
  * @return bool false if something went wrong.
  */
 function fetchHTTPFile($httpFileIdentifier, &$errors, &$file, &$mimeData)
 {
     $returnCode = eZHTTPFile::canFetch($httpFileIdentifier, 0);
     if ($returnCode !== eZHTTPFile::UPLOADEDFILE_OK && $returnCode !== true) {
         switch ($returnCode) {
             case eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST:
                 $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A file is required for upload, no file were found.'));
                 break;
             case eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT:
             case eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE:
                 $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'The uploaded file size is above the maximum limit.'));
                 break;
             case eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR:
             case eZHTTPFile::UPLOADEDFILE_CANT_WRITE:
             case eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR:
                 $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A system error occured while writing the uploaded file.'));
                 break;
         }
         return false;
     }
     $file = eZHTTPFile::fetch($httpFileIdentifier);
     if (!$file instanceof eZHTTPFile) {
         $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'Expected a eZHTTPFile object but got nothing.'));
         return false;
     }
     $mimeData = eZMimeType::findByFileContents($file->attribute("original_filename"));
     return true;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:33,代码来源:ezcontentupload.php

示例7: initializeFromHTTPFile

 /**
  * Initializes the content object attribute with the uploaded HTTP file
  *
  * @param eZHTTPFile $httpFile
  * @param string $imageAltText Optional image ALT text
  *
  * @return TODO: FIXME
  */
 function initializeFromHTTPFile($httpFile, $imageAltText = false)
 {
     $this->increaseImageSerialNumber();
     $mimeData = eZMimeType::findByFileContents($httpFile->attribute('filename'));
     if (!$mimeData['is_valid']) {
         $mimeData = eZMimeType::findByName($httpFile->attribute('mime_type'));
         if (!$mimeData['is_valid']) {
             $mimeData = eZMimeType::findByURL($httpFile->attribute('original_filename'));
         }
     }
     $attr = false;
     $this->removeAliases($attr);
     $this->setOriginalAttributeDataValues($this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code']);
     $contentVersion = eZContentObjectVersion::fetchVersion($this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['contentobject_id']);
     $objectName = $this->imageName($this->ContentObjectAttributeData, $contentVersion);
     $objectPathString = $this->imagePath($this->ContentObjectAttributeData, $contentVersion, true);
     eZMimeType::changeBaseName($mimeData, $objectName);
     eZMimeType::changeDirectoryPath($mimeData, $objectPathString);
     $httpFile->store(false, false, $mimeData);
     $originalFilename = $httpFile->attribute('original_filename');
     return $this->initialize($mimeData, $originalFilename, $imageAltText);
 }
开发者ID:,项目名称:,代码行数:30,代码来源:

示例8: date

    if ($access['accessWord'] == 'yes') {
        $importCsvFile = true;
    } else {
        return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
    }
}
// upload csv and store data
if (eZHTTPFile::canFetch('UploadCsvFile') && $importId == 0) {
    $importType = 'cjwnl_csv';
    $dataText = '';
    $remoteId = false;
    //$remoteId = 'csv:' . md5( $csvFilePath );
    // create new Import Object
    $importObject = CjwNewsletterImport::create($listContentObjectId, $importType, $note, $dataText, $remoteId);
    $importObject->store();
    $binaryFile = eZHTTPFile::fetch('UploadCsvFile');
    $filePathUpload = $binaryFile->attribute('filename');
    $fileSep = eZSys::fileSeparator();
    // $fileSize = filesize( $filePathUpload );
    //$siteDir =  eZSys::siteDir();
    $dir = eZSys::varDirectory() . $fileSep . 'cjw_newsletter' . $fileSep . 'csvimport';
    $importId = $importObject->attribute('id');
    $fileName = $importId . '-' . date("Ymd-His", $importObject->attribute('created')) . '-' . $binaryFile->attribute('original_filename');
    $csvFilePath = $dir . $fileSep . $fileName;
    $importObject->setAttribute('data_text', $csvFilePath);
    $importObject->setAttribute('note', $note);
    // create dir
    eZDir::mkdir($dir, false, true);
    $createResult = copy($filePathUpload, $csvFilePath);
    $importObject->store();
    // after import object is created redirect to view with import_id
开发者ID:hudri,项目名称:cjw_newsletter,代码行数:31,代码来源:subscription_list_csvimport.php

示例9: fetchObjectAttributeHTTPInput

 function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     eZMediaType::checkFileUploads();
     $classAttribute = $contentObjectAttribute->contentClassAttribute();
     $player = $classAttribute->attribute("data_text1");
     $pluginPage = eZMediaType::pluginPage($player);
     $contentObjectAttributeID = $contentObjectAttribute->attribute("id");
     $version = $contentObjectAttribute->attribute("version");
     $width = $http->postVariable($base . "_data_media_width_" . $contentObjectAttribute->attribute("id"));
     $height = $http->postVariable($base . "_data_media_height_" . $contentObjectAttribute->attribute("id"));
     $quality = $http->hasPostVariable($base . "_data_media_quality_" . $contentObjectAttribute->attribute("id")) ? $http->postVariable($base . "_data_media_quality_" . $contentObjectAttribute->attribute("id")) : null;
     if ($http->hasPostVariable($base . "_data_media_controls_" . $contentObjectAttribute->attribute("id"))) {
         $controls = $http->postVariable($base . "_data_media_controls_" . $contentObjectAttribute->attribute("id"));
     } else {
         $controls = null;
     }
     $media = eZMedia::fetch($contentObjectAttributeID, $version);
     if ($media == null) {
         $media = eZMedia::create($contentObjectAttributeID, $version);
     }
     $media->setAttribute("contentobject_attribute_id", $contentObjectAttributeID);
     $media->setAttribute("version", $version);
     $media->setAttribute("width", $width);
     $media->setAttribute("height", $height);
     $media->setAttribute("quality", $quality);
     $media->setAttribute("controls", $controls);
     $media->setAttribute("pluginspage", $pluginPage);
     if ($http->hasPostVariable($base . "_data_media_is_autoplay_" . $contentObjectAttribute->attribute("id"))) {
         $media->setAttribute("is_autoplay", true);
     } else {
         $media->setAttribute("is_autoplay", false);
     }
     if ($http->hasPostVariable($base . "_data_media_has_controller_" . $contentObjectAttribute->attribute("id"))) {
         $media->setAttribute("has_controller", true);
     } else {
         $media->setAttribute("has_controller", false);
     }
     if ($http->hasPostVariable($base . "_data_media_is_loop_" . $contentObjectAttribute->attribute("id"))) {
         $media->setAttribute("is_loop", true);
     } else {
         $media->setAttribute("is_loop", false);
     }
     $mediaFilePostVarName = $base . "_data_mediafilename_" . $contentObjectAttribute->attribute("id");
     if (eZHTTPFile::canFetch($mediaFilePostVarName)) {
         $mediaFile = eZHTTPFile::fetch($mediaFilePostVarName);
     } else {
         $mediaFile = null;
     }
     if ($mediaFile instanceof eZHTTPFile) {
         $mimeData = eZMimeType::findByFileContents($mediaFile->attribute("original_filename"));
         $mime = $mimeData['name'];
         if ($mime == '') {
             $mime = $mediaFile->attribute("mime_type");
         }
         $extension = eZFile::suffix($mediaFile->attribute("original_filename"));
         $mediaFile->setMimeType($mime);
         if (!$mediaFile->store("original", $extension)) {
             eZDebug::writeError("Failed to store http-file: " . $mediaFile->attribute("original_filename"), "eZMediaType");
             return false;
         }
         $orig_dir = $mediaFile->storageDir("original");
         eZDebug::writeNotice("dir={$orig_dir}");
         $media->setAttribute("filename", basename($mediaFile->attribute("filename")));
         $media->setAttribute("original_filename", $mediaFile->attribute("original_filename"));
         $media->setAttribute("mime_type", $mime);
         $filePath = $mediaFile->attribute('filename');
         $fileHandler = eZClusterFileHandler::instance();
         $fileHandler->fileStore($filePath, 'media', true, $mime);
     } else {
         if ($media->attribute('filename') == '') {
             $media->remove();
             return false;
         }
     }
     $media->store();
     $contentObjectAttribute->setContent($media);
     return true;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:78,代码来源:ezmediatype.php

示例10: checkRelationActions

function checkRelationActions($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
    $http = eZHTTPTool::instance();
    if ($module->isCurrentAction('BrowseForObjects')) {
        $objectID = $object->attribute('id');
        $assignedNodes = $object->attribute('assigned_nodes');
        $assignedNodesIDs = array();
        foreach ($assignedNodes as $node) {
            $assignedNodesIDs = $node->attribute('node_id');
        }
        unset($assignedNodes);
        eZContentBrowse::browse(array('action_name' => 'AddRelatedObject', 'description_template' => 'design:content/browse_related.tpl', 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'ignore_nodes_select' => $assignedNodesIDs, 'from_page' => $module->redirectionURI('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
        return eZModule::HOOK_STATUS_CANCEL_RUN;
    }
    if ($module->isCurrentAction('UploadFileRelation')) {
        $objectID = $object->attribute('id');
        $section = eZSection::fetch($object->attribute('section_id'));
        $navigationPart = false;
        if ($section) {
            $navigationPart = $section->attribute('navigation_part_identifier');
        }
        $location = false;
        if ($module->hasActionParameter('UploadRelationLocation')) {
            $location = $module->actionParameter('UploadRelationLocation');
        }
        // We only do direct uploading if we have the uploaded HTTP file
        // if not we need to go to the content/upload page.
        if (eZHTTPFile::canFetch('UploadRelationFile')) {
            $upload = new eZContentUpload();
            if ($upload->handleUpload($result, 'UploadRelationFile', $location, false)) {
                $relatedObjectID = $result['contentobject_id'];
                if ($relatedObjectID) {
                    $db = eZDB::instance();
                    $db->begin();
                    $object->addContentObjectRelation($relatedObjectID, $editVersion);
                    $db->commit();
                }
            }
        } else {
            eZContentUpload::upload(array('action_name' => 'RelatedObjectUpload', 'description_template' => 'design:content/upload_related.tpl', 'navigation_part_identifier' => $navigationPart, 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'result_action_name' => 'UploadedFileRelation', 'ui_context' => 'edit', 'result_module' => array('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module);
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }
    }
    if ($module->isCurrentAction('DeleteRelation')) {
        $objectID = $object->attribute('id');
        if ($http->hasPostVariable('DeleteRelationIDArray')) {
            $relationObjectIDs = $http->postVariable('DeleteRelationIDArray');
        } else {
            $relationObjectIDs = array();
        }
        $db = eZDB::instance();
        $db->begin();
        foreach ($relationObjectIDs as $relationObjectID) {
            $object->removeContentObjectRelation($relationObjectID, $editVersion);
        }
        $db->commit();
    }
    if ($module->isCurrentAction('NewObject')) {
        if ($http->hasPostVariable('ClassID')) {
            if ($http->hasPostVariable('SectionID')) {
                $sectionID = $http->postVariable('SectionID');
            } else {
                $sectionID = 0;
                /* Will be changed later */
            }
            $contentClassID = $http->postVariable('ClassID');
            $class = eZContentClass::fetch($contentClassID);
            $db = eZDB::instance();
            $db->begin();
            $relatedContentObject = $class->instantiate(false, $sectionID);
            $db->commit();
            $newObjectID = $relatedContentObject->attribute('id');
            $relatedContentVersion = $relatedContentObject->attribute('current');
            if ($relatedContentObject->attribute('can_edit')) {
                $db = eZDB::instance();
                $db->begin();
                $assignmentHandler = new eZContentObjectAssignmentHandler($relatedContentObject, $relatedContentVersion);
                $sectionID = (int) $assignmentHandler->setupAssignments(array('group-name' => 'RelationAssignmentSettings', 'default-variable-name' => 'DefaultAssignment', 'specific-variable-name' => 'ClassSpecificAssignment', 'section-id-wanted' => true, 'fallback-node-id' => $object->attribute('main_node_id')));
                $http->setSessionVariable('ParentObject', array($object->attribute('id'), $editVersion, $editLanguage));
                $http->setSessionVariable('NewObjectID', $newObjectID);
                /* Change section ID to the same one as the main node placement */
                $db->query("UPDATE ezcontentobject SET section_id = {$sectionID} WHERE id = {$newObjectID}");
                $db->commit();
                $module->redirectToView('edit', array($relatedContentObject->attribute('id'), $relatedContentObject->attribute('current_version'), false));
            } else {
                $db = eZDB::instance();
                $db->begin();
                $relatedContentObject->purge();
                $db->commit();
            }
            return;
        }
    }
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:94,代码来源:relation_edit.php

示例11: makeErrorArray

    else
    {
        eZDebug::writeError( "Cannot import document, supplied placement nodeID is not valid." );
        $tpl->setVariable( 'error', makeErrorArray( eZOOImport::ERROR_PLACEMENTINVALID,
                                                    ezpI18n::tr( 'extension/ezodf/import/error', "Cannot import document, supplied placement nodeID is not valid." ) ) );
    }

//    $tpl->setVariable( 'oo_mode', 'imported' );
}
else
{
    $tpl->setVariable( 'oo_mode', 'browse' );

    if( eZHTTPFile::canFetch( "oo_file" ) )
    {
        $file = eZHTTPFile::fetch( "oo_file" );

        if ( $file )
        {
            if ( $file->store() )
            {
                $fileName = $file->attribute( 'filename' );

                $originalFileName = $file->attribute( 'original_filename' );

                // If we have the NodeID do the import/replace directly
                if (  $http->sessionVariable( 'oo_direct_import_node' )  )
                {
                    $nodeID = $http->sessionVariable( 'oo_direct_import_node' );
                    $importType = $http->sessionVariable( 'oo_import_type' );
                    if ( $importType != "replace" )
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:import.php

示例12: print

    // User authentication
    $user = eZUser::loginUser( $username, $password );
    if ( $user == false )
    {
        print( 'problem:Authentication failed' );
        eZExecution::cleanExit();
    }

    if ( !eZHTTPFile::canFetch( 'File' ) )
    {
        print( 'problem:Can\'t fetch HTTP file.' );
        eZExecution::cleanExit();
    }

    $file = eZHTTPFile::fetch('File');

    $fileName = $file->attribute( 'filename' );
    $originalFilename = $file->attribute('original_filename');

    $content = base64_decode( file_get_contents( $fileName ) );

    $fd = fopen( $fileName, 'w' );
    fwrite( $fd, $content );
    fclose( $fd );

    // Conversion of the stored file
    $import = new eZOOImport();
    $importResult = $import->import( $fileName, $nodeID, $originalFilename, $importType );

    // Verification : conversion OK ?
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:30,代码来源:upload_import.php

示例13: fetchHTTPFile

 function fetchHTTPFile($httpFileIdentifier, &$errors, &$file, &$mimeData)
 {
     if (!eZHTTPFile::canFetch($httpFileIdentifier)) {
         $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'A file is required for upload, no file were found.'));
         return false;
     }
     $file = eZHTTPFile::fetch($httpFileIdentifier);
     if (!$file instanceof eZHTTPFile) {
         $errors[] = array('description' => ezpI18n::tr('kernel/content/upload', 'Expected a eZHTTPFile object but got nothing.'));
         return false;
     }
     $mimeData = eZMimeType::findByFileContents($file->attribute("original_filename"));
     return false;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:14,代码来源:ezcontentupload.php

示例14: validateFileHTTPInput

 function validateFileHTTPInput($base, $contentObjectAttribute, $classAttribute)
 {
     //Check allowed file type
     //Have to do it here again, otherwise no error message
     $binaryFile = eZHTTPFile::fetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id"));
     if (!$binaryFile) {
         return eZInputValidator::STATE_INVALID;
     }
     $moduleINI = eZINI::instance('module.ini.append.php', 'settings');
     $allowed = $moduleINI->variable('AllowedFileTypes', 'AllowedFileTypeList');
     // $binaryFile->attribute( 'mime_type_part' ) not always the extension
     $extension = preg_replace('/.*\\.(.+?)$/', '\\1', $binaryFile->attribute("original_filename"));
     if (!in_array(strtolower($extension), $allowed)) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Failed to store file. Only the following file types are allowed: %1.'), implode(", ", $allowed));
         return eZInputValidator::STATE_INVALID;
     }
     //Check size
     $mustUpload = false;
     $maxSize = 1024 * 1024 * $classAttribute->attribute(self::MAX_FILESIZE_FIELD);
     /* Since it is not an ezbinary file this can never be true
        unfortunately, this is where the check would be to not upload the file
        multiple times in the event the form fails somewhere.  Unfortunately it
        can't be a binary file since it is a collection object and not a content
        object.
     	if ( $contentObjectAttribute->validateIsRequired() )
             {
                 $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
                 $version = $contentObjectAttribute->attribute( "version" );
                 $binary = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
                 if ( $binary === null )
                 {
                     $mustUpload = true;
                 }
             }
     */
     $canFetchResult = EnhancedeZBinaryFileType::canFetch($base . "_data_enhancedbinaryfilename_" . $contentObjectAttribute->attribute("id"), $maxSize);
     //$binaryfile doesn't have an attribute(http_name)
     if ($mustUpload && $canFetchResult === eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'A valid file is required.'));
         return eZInputValidator::STATE_INVALID;
     }
     if ($canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The size of the uploaded file exceeds the limit set by the upload_max_filesize directive in php.ini.'));
         return eZInputValidator::STATE_INVALID;
     }
     if ($canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The size of the uploaded file exceeds the maximum upload size: %1 bytes.'), $maxSize);
         return eZInputValidator::STATE_INVALID;
     }
     //Dropped all the way through with no error
     return eZInputValidator::STATE_ACCEPTED;
 }
开发者ID:Alexnder,项目名称:enhancedezbinaryfile,代码行数:52,代码来源:enhancedezbinaryfiletype.php

示例15: checkFileFormat

 /**
  * Tries to validate uploaded file format through handler
  *
  * @param string $handler
  * @param string $option
  * @param eZHTTPFile $file
  * @return boolean	true if file validates or if no validator is defined
  */
 protected static function checkFileFormat($handler, $option, eZHTTPFile $file)
 {
     //Handler instantiation code copied from SQLIImportFactory::runImport
     //TODO : refactoring handler instantiation ?
     $importINI = eZINI::instance('sqliimport.ini');
     $handlerSection = $handler . '-HandlerSettings';
     if (!$importINI->hasSection($handlerSection)) {
         // Check INI Section
         throw new ezcConfigurationNoConfigException('Error : Handler "' . $handler . '" does not have proper config section in sqliimport.ini !');
     }
     if (!$importINI->hasVariable($handlerSection, 'ClassName')) {
         // Check if ClassName is properly defined
         throw new ezcConfigurationNoConfigException('Error : ClassName not defined for "' . $handler . '" in sqliimport.ini !');
     }
     // Default values
     $handlerClassName = $importINI->variable($handlerSection, 'ClassName');
     $handlerEnabled = true;
     $debug = false;
     $defaultParentNodeID = $importINI->variable('ImportSettings', 'DefaultParentNodeID');
     $streamTimeout = $importINI->variable('ImportSettings', 'StreamTimeout');
     if ($importINI->hasVariable($handlerSection, 'Enabled')) {
         $handlerEnabled = $importINI->variable($handlerSection, 'Enabled') === 'true';
     }
     if ($importINI->hasVariable($handlerSection, 'Debug')) {
         $debug = $importINI->variable($handlerSection, 'Debug') === 'enabled';
     }
     if ($importINI->hasVariable($handlerSection, 'DefaultParentNodeID')) {
         $localParentNodeID = $importINI->variable($handlerSection, 'DefaultParentNodeID');
         $defaultParentNodeID = is_int($localParentNodeID) ? (int) $localParentNode : $defaultParentNodeID;
     }
     // Check handler class validity
     if (!class_exists($handlerClassName)) {
         throw new SQLIImportRuntimeException('Error : invalid handler class "' . $handlerClassName . '". Did you regenerate autolads ?');
     }
     $handlerOptions = new SQLIImportHandlerOptions(array());
     $importHandler = new $handlerClassName($handlerOptions);
     if (!$importHandler instanceof ISQLIFileImportHandler) {
         return true;
     }
     $importHandler->handlerConfArray = $importINI->group($handlerSection);
     return $importHandler->validateFile($option, $file->attribute('filename'));
 }
开发者ID:heliopsis,项目名称:SQLIImport,代码行数:50,代码来源:sqliimportjsserverfunctions.php


注:本文中的eZHTTPFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。