/** * @deprecated since 2.1 * Get instance of PHPCreator to use for storing and loading * look up table. * * @return eZPHPCreator return instance of eZPHPCreator * @todo Refactor with ezcPhpGenerator * http://ezcomponents.org/docs/api/trunk/classtrees_PhpGenerator.html */ protected function getPHPCreatorInstance() { if (empty(self::$PHPCreator)) { self::$PHPCreator = new eZPHPCreator(eZDIR::path(array(eZSys::storageDirectory(), ezfSolrDocumentFieldName::LOOKUP_FILEDIR)), ezfSolrDocumentFieldName::LOOKUP_FILENAME); } return self::$PHPCreator; }
function filePathForBinaryFile($fileName, $mimeType) { $storageDir = eZSys::storageDirectory(); list($group, $type) = explode('/', $mimeType); $filePath = $storageDir . '/original/' . $group . '/' . $fileName; return $filePath; }
function eZSurveyFile($row = false) { $bfsf_ini = eZINI::instance('bfsurveyfile.ini'); $varPath = eZSys::storageDirectory(); $survey_object_id = 0; //get survey object (lookup object ID, as the survey_id changes with each edit) $survey = new eZSurveyType(); $surveyObject = $survey->fetchSurveyByID($row['survey_id']); if ($surveyObject) { $survey_object_id = $surveyObject->attribute('contentobject_id'); } //set directory paths $surveyUploadDir = self::UPLOAD_DIR_BASE . '/' . self::UPLOAD_DIR_PREFIX . $survey_object_id . '/'; // syntax example: surveryfiles/survey_123/ $this->uploadPath = $varPath . '/' . $surveyUploadDir; //create directory if NOT exists if (!is_dir($this->uploadPath)) { mkdir($this->uploadPath, 0777, true); } //TODO: error if directory cannot be created //set allowed file extensions $allowedExtensions = $bfsf_ini->variable('SurveyFile', 'AllowedExtensions'); if (isset($allowedExtensions)) { $this->allowedExtensions = $allowedExtensions; } //set max file size $sizeLimit = $bfsf_ini->variable('SurveyFile', 'MaxFileSize'); $row['type'] = 'File'; if (!isset($row['mandatory'])) { $row['mandatory'] = 0; } $this->eZSurveyQuestion($row); }
function store($sub_dir = false, $suffix = false, $mimeData = false) { if (!$this->IsTemporary) { eZDebug::writeError("Cannot store non temporary file: " . $this->Filename, "eZHTTPFile"); return false; } $this->IsTemporary = false; $ini = eZINI::instance(); // $storage_dir = $ini->variable( "FileSettings", "VarDir" ) . '/' . $ini->variable( "FileSettings", "StorageDir" ); $storage_dir = eZSys::storageDirectory(); if ($sub_dir !== false) { $dir = $storage_dir . "/{$sub_dir}/"; } else { $dir = $storage_dir . "/"; } if ($mimeData) { $dir = $mimeData['dirpath']; } if (!$mimeData) { $dir .= $this->MimeCategory; } if (!file_exists($dir)) { if (!eZDir::mkdir($dir, false, true)) { return false; } } $suffixString = false; if ($suffix != false) { $suffixString = ".{$suffix}"; } if ($mimeData) { $dest_name = $mimeData['url']; } else { $dest_name = $dir . "/" . md5(basename($this->Filename) . microtime() . mt_rand()) . $suffixString; } if (!move_uploaded_file($this->Filename, $dest_name)) { eZDebug::writeError("Failed moving uploaded file " . $this->Filename . " to destination {$dest_name}"); unlink($dest_name); $ret = false; } else { $ret = true; $this->Filename = $dest_name; $perm = $ini->variable("FileSettings", "StorageFilePermissions"); $oldumask = umask(0); chmod($dest_name, octdec($perm)); umask($oldumask); // Write log message to storage.log $storageDir = $dir . "/"; eZLog::writeStorageLog(basename($this->Filename), $storageDir); } return $ret; }
function copyBrightcovefilesTODB($remove) { global $cli, $fileHandler; $db = eZDB::instance(); $cli->output("Importing brightcove files to database:"); $rows = $db->arrayQuery('select file_path, file_name, mime_type from ezbrightcove_data'); foreach ($rows as $row) { $filePath = eZSys::storageDirectory() . "/" . $row['file_path'] . "/" . $row['file_name']; $cli->output("- " . $filePath); $fileHandler->fileStore($filePath, 'brightcove', $remove); } $cli->output(); }
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode ) { $fileNode = $attributeNode->getElementsByTagName( 'binary-file' )->item( 0 ); if ( !is_object( $fileNode ) or !$fileNode->hasAttributes() ) { return; } $binaryFile = eZBinaryFile::create( $objectAttribute->attribute( 'id' ), $objectAttribute->attribute( 'version' ) ); $sourcePath = $package->simpleFilePath( $fileNode->getAttribute( 'filekey' ) ); if ( !file_exists( $sourcePath ) ) { eZDebug::writeError( "The file '$sourcePath' does not exist, cannot initialize file attribute with it", __METHOD__ ); return false; } $ini = eZINI::instance(); $mimeType = $fileNode->getAttribute( 'mime-type' ); list( $mimeTypeCategory, $mimeTypeName ) = explode( '/', $mimeType ); $destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/'; if ( !file_exists( $destinationPath ) ) { $oldumask = umask( 0 ); if ( !eZDir::mkdir( $destinationPath, false, true ) ) { umask( $oldumask ); return false; } umask( $oldumask ); } $basename = basename( $fileNode->getAttribute( 'filename' ) ); while ( file_exists( $destinationPath . $basename ) ) { $basename = substr( md5( mt_rand() ), 0, 8 ) . '.' . eZFile::suffix( $fileNode->getAttribute( 'filename' ) ); } eZFileHandler::copy( $sourcePath, $destinationPath . $basename ); eZDebug::writeNotice( 'Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, __METHOD__ ); $binaryFile->setAttribute( 'contentobject_attribute_id', $objectAttribute->attribute( 'id' ) ); $binaryFile->setAttribute( 'filename', $basename ); $binaryFile->setAttribute( 'original_filename', $fileNode->getAttribute( 'original-filename' ) ); $binaryFile->setAttribute( 'mime_type', $fileNode->getAttribute( 'mime-type' ) ); $binaryFile->store(); $fileHandler = eZClusterFileHandler::instance(); $fileHandler->fileStore( $destinationPath . $basename, 'binaryfile', true ); }
$prio = $manualPriority[$mKey]; } else { $prio = null; } if (isset($manualFrequency[$mKey])) { $freq = $manualFrequency[$mKey]; } else { $freq = null; } $sitemap->add($url, null, $freq, $prio); if (isset($bar)) { $bar->advance(); } } // write XML Sitemap to file $dir = eZSys::storageDirectory() . '/sitemap'; if (!file_exists($dir)) { mkdir($dir, 0777, true); } $filename = $dir . '/' . $language['siteaccess'] . '_' . xrowGoogleSiteMap::BASENAME . '.' . xrowGoogleSiteMap::SUFFIX; $sitemap->save($filename); if (function_exists('gzencode') and $googlesitemapsINI->variable('SiteMapSettings', 'Gzip') == 'enabled') { $content = file_get_contents($filename); $content = gzencode($content); file_put_contents($filename . '.gz', $content); unlink($filename); $filename .= '.gz'; } if (!$isQuiet) { $cli->output(); $cli->output("Sitemap {$filename} for siteaccess " . $language['siteaccess'] . " (language code " . $language['locale'] . ") has been generated!\n\n");
function imagePathByNode($contentObjectAttribute, $mainNode) { $pathString = $mainNode->pathWithNames(); $pathString = function_exists('mb_strtolower') ? mb_strtolower($pathString) : strtolower($pathString); $ini = eZINI::instance('image.ini'); $contentImageSubtree = $ini->variable('FileSettings', 'PublishedImages'); $attributeData = $this->originalAttributeData(); $attributeID = $attributeData['attribute_id']; $attributeVersion = $attributeData['attribute_version']; $attributeLanguage = $attributeData['attribute_language']; $pathParts = array(eZSys::storageDirectory(), $contentImageSubtree); if ($pathString != '') { $pathParts[] = $pathString; } $pathParts[] = $attributeID . '-' . $attributeVersion . '-' . $attributeLanguage; $imagePath = implode('/', $pathParts); return $imagePath; }
public static function createMFSitemap() { eZDebug::writeDebug("Generating Standard Sitemap with images ...", __METHOD__); $cli = $GLOBALS['cli']; global $cli, $isQuiet; if (!$isQuiet) { $cli->output("Generating Sitemap for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n"); } $ini = eZINI::instance('site.ini'); $googlesitemapsINI = eZINI::instance('xrowsitemap.ini'); // Get the Sitemap's root node $contentINI = eZINI::instance('content.ini'); $rootNode = eZContentObjectTreeNode::fetch($contentINI->variable('NodeSettings', 'RootNode')); if (!$rootNode instanceof eZContentObjectTreeNode) { $cli->output("Invalid RootNode for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n"); continue; } // Settings variables if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterType') and $googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterArray')) { $params2 = array('ClassFilterType' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterArray')); } $max = 49997; // max. amount of links in 1 sitemap $limit = 50; // Fetch the content tree $params = array('SortBy' => array(array('depth', true), array('published', false))); if (isset($params2)) { $params = array_merge($params, $params2); } $subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID); if ($subtreeCount == 1) { $cli->output("No Items found under node #" . $contentINI->variable('NodeSettings', 'RootNode') . "."); } if (!$isQuiet) { $amount = $subtreeCount + 1; // +1 is root node $cli->output("Adding {$amount} nodes to the sitemap."); $output = new ezcConsoleOutput(); $bar = new ezcConsoleProgressbar($output, $amount); } $addPrio = false; if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'AddPriorityToSubtree') and $googlesitemapsINI->variable('MFSitemapSettings', 'AddPriorityToSubtree') == 'true') { $addPrio = true; } $sitemap = new xrowSitemap(); // Generate Sitemap /** START Adding the root node **/ $object = $rootNode->object(); $meta = xrowMetaDataFunctions::fetchByObject($object); $extensions = array(); $extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode')); $url = $rootNode->attribute('url_alias'); eZURI::transformURI($url, true); if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') { $url = 'http://' . xrowSitemapTools::domain() . $url; } else { $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url; } if ($meta and $meta->googlemap != '0') { $extensions[] = new xrowSitemapItemFrequency($meta->change); $extensions[] = new xrowSitemapItemPriority($meta->priority); $sitemap->add($url, $extensions); } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') { if ($addPrio) { $extensions[] = new xrowSitemapItemPriority('1'); } $sitemap->add($url, $extensions); } if (isset($bar)) { $bar->advance(); } /** END Adding the root node **/ $max = min($max, $subtreeCount); $params['Limit'] = min($max, $limit); $params['Offset'] = 0; while ($params['Offset'] < $max) { $nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID); foreach ($nodeArray as $subTreeNode) { eZContentLanguage::expireCache(); $object = $subTreeNode->object(); $images = array(); $meta = xrowMetaDataFunctions::fetchByObject($object); $extensions = array(); $extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode')); $url = $subTreeNode->attribute('url_alias'); eZURI::transformURI($url, true); if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') { $url = 'http://' . xrowSitemapTools::domain() . $url; } else { $url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url; } if ($meta and $meta->googlemap != '0') { $extensions[] = new xrowSitemapItemFrequency($meta->change); $extensions[] = new xrowSitemapItemPriority($meta->priority); } elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') { if ($addPrio) { $rootDepth = $rootNode->attribute('depth'); $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10; if ($prio > 0) { $extensions[] = new xrowSitemapItemPriority($prio); } } } $images = self::getSitemapImageItems($object); $sitemap->add($url, array_merge($extensions, $images)); if (isset($bar)) { $bar->advance(); } } eZContentObject::clearCache(); $params['Offset'] += $params['Limit']; } // write XML Sitemap to file $dir = eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain(); if (!is_dir($dir)) { mkdir($dir, 0777, true); } $filename = $dir . '/' . xrowSitemap::BASENAME . '_standard_' . $GLOBALS['eZCurrentAccess']['name'] . '.' . xrowSitemap::SUFFIX; $sitemap->save($filename); if (!$isQuiet) { $cli->output("\n"); $cli->output("Sitemap {$filename} for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " has been generated.\n"); } }
<?php /** * * @author G. Giunta * @copyright (C) G. Giunta 2008-2016 * @license Licensed under GNU General Public License v2.0. See file license.txt * * @todo add more details, such as dates of first/last files * @todo add support for db-clustered configs - hard currently, since there is no recursive search in api... * @todo in edfs mode allow user to only show clustered data */ $storageFilesList = array(); $storageDir = eZSys::storageDirectory(); $files = @scandir($storageDir); foreach ($files as $file) { if ($file != '.' && $file != '..' && is_dir($storageDir . '/' . $file)) { $storageFilesList[$file] = array('path' => $storageDir . '/' . $file, 'count' => number_format(sysInfoTools::countFilesInDir($storageDir . '/' . $file)), 'size' => number_format(sysInfoTools::countFilesSizeInDir($storageDir . '/' . $file))); } } if ($Params['viewmode'] == 'json') { $response_type = $Params['viewmode']; $response_data = $storageFilesList; return; } $tpl->setVariable('filelist', $storageFilesList);
function storedFilename(&$binary, $returnMimeData = false) { $origDir = eZSys::storageDirectory() . '/original'; $class = get_class($binary); $fileName = false; $originalFilename = false; if (in_array($class, array('eZBinaryFile', 'eZMedia'))) { $fileName = $origDir . "/" . $binary->attribute('mime_type_category') . '/' . $binary->attribute("filename"); $originalFilename = $binary->attribute('original_filename'); } else { if ($class == 'eZImageAliasHandler') { $alias = $binary->attribute('original'); if ($alias) { $fileName = $alias['url']; } $originalFilename = $binary->attribute('original_filename'); } } if ($fileName) { $mimeData = eZMimeType::findByFileContents($fileName); $mimeData['original_filename'] = $originalFilename; if (!isset($mimeData['name'])) { $mimeData['name'] = 'application/octet-stream'; } if ($returnMimeData) { return $mimeData; } else { return $mimeData['url']; } } return false; }
function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode) { $mediaNode = $attributeNode->getElementsByTagName('media-file')->item(0); if (!$mediaNode) { // No media type data found. return; } $mediaFile = eZMedia::create($objectAttribute->attribute('id'), $objectAttribute->attribute('version')); $sourcePath = $package->simpleFilePath($mediaNode->getAttribute('filekey')); $ini = eZINI::instance(); $mimeType = $mediaNode->getAttribute('mime-type'); list($mimeTypeCategory, $mimeTypeName) = explode('/', $mimeType); $destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/'; if (!file_exists($destinationPath)) { if (!eZDir::mkdir($destinationPath, false, true)) { return false; } } $basename = basename($mediaNode->getAttribute('filename')); while (file_exists($destinationPath . $basename)) { $basename = substr(md5(mt_rand()), 0, 8) . '.' . eZFile::suffix($mediaNode->getAttribute('filename')); } eZFileHandler::copy($sourcePath, $destinationPath . $basename); eZDebug::writeNotice('Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, __METHOD__); $mediaFile->setAttribute('contentobject_attribute_id', $objectAttribute->attribute('id')); $mediaFile->setAttribute('filename', $basename); $mediaFile->setAttribute('original_filename', $mediaNode->getAttribute('original-filename')); $mediaFile->setAttribute('mime_type', $mediaNode->getAttribute('mime-type')); $mediaFile->setAttribute('width', $mediaNode->getAttribute('width')); $mediaFile->setAttribute('height', $mediaNode->getAttribute('height')); $mediaFile->setAttribute('has_controller', $mediaNode->getAttribute('has-controller')); $mediaFile->setAttribute('controls', $mediaNode->getAttribute('controls')); $mediaFile->setAttribute('is_autoplay', $mediaNode->getAttribute('is-autoplay')); $mediaFile->setAttribute('pluginspage', $mediaNode->getAttribute('plugins-page')); $mediaFile->setAttribute('quality', $mediaNode->getAttribute('quality')); $mediaFile->setAttribute('is_loop', $mediaNode->getAttribute('is-loop')); $fileHandler = eZClusterFileHandler::instance(); $fileHandler->fileStore($destinationPath . $basename, 'mediafile', true); $mediaFile->store(); }
$sitemap_index = '<?xml version="1.0" encoding="UTF-8"?>'; $sitemap_index .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $limit = 40000; $offset = 0; $sql_count = "SELECT count(*) FROM do_sitemap "; $sitemap_number = 1; while ($offset < $count) { $sitemap_file_name = 'sitemap_' . $sitemap_number . '.xml'; $sql = "SELECT dosm_loc , dosm_lastmod , dosm_priority , dosm_changefreq FROM do_sitemap LIMIT {$offset} , {$limit} "; $results = $db->arrayQuery($sql); $sm = '<?xml version="1.0" encoding="UTF-8"?>'; $sm .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; foreach ($results as $result) { $sm .= '<url>'; $sm .= '<loc>' . $result['dosm_loc'] . '</loc>'; $sm .= '<lastmod>' . $result['dosm_lastmod'] . '</lastmod>'; $sm .= '<changefreq>' . $result['dosm_changefreq'] . '</changefreq>'; $sm .= '<priority>' . $result['dosm_priority'] . '</priority>'; $sm .= '</url>'; } $sm .= '</urlset>'; eZFile::create($sitemap_file_name, eZSys::storageDirectory() . '/images/do_sitemap/', $sm); $sitemap_index .= '<sitemap>'; $sitemap_index .= '<loc>' . $siteURL . '/' . eZSys::storageDirectory() . '/images/do_sitemap/' . $sitemap_file_name . '</loc>'; $sitemap_index .= '</sitemap>'; $offset = $offset + $limit; $sitemap_number++; } $sitemap_index .= '</sitemapindex>'; eZFile::create('sitemap.xml', eZSys::storageDirectory() . '/images/do_sitemap/', $sitemap_index);
/** * @param string $logoField * @return string */ public function getFile( $logoField ) { if( $this->attribute( $logoField ) != null && $this->attribute( $logoField ) != '' ) { $storageDir = eZSys::storageDirectory(); $clusterIdentifier = ClusterTool::clusterIdentifier(); $publisherFolderPath = $this->publisherFolder['path']; $outputDirectory = "{$storageDir}/static-data/{$clusterIdentifier}/publisher_folders/{$publisherFolderPath}"; if (!is_readable($outputDirectory) || !is_dir($outputDirectory)) { mkdir($outputDirectory, 0777, true); } $outputFile = "{$outputDirectory}/{$logoField}.png"; $fileUtils = eZClusterFileHandler::instance( $outputFile ); if( !$fileUtils->fileExists( $outputFile ) ) { if ( $fileUtils->requiresClusterizing() ) { eZDFSFileHandler::fileStoreContents( $outputFile, $this->attribute( $logoField ) ); } else { file_put_contents( $outputFile, $this->attribute( $logoField ) ); } } return '/' . $outputFile; } else { return null; } }
} else { $siteAccessArray = array($ini->variable('SiteSettings', 'DefaultAccess')); } // adding the mobile sitemap site accesses if ($xrowsitemapINI->hasVariable('MobileSitemapSettings', 'AvailableSiteAccessList')) { $siteAccessArray = array_merge($siteAccessArray, $xrowsitemapINI->variable('MobileSitemapSettings', 'AvailableSiteAccessList')); } $Module = $Params['Module']; $access = $GLOBALS['eZCurrentAccess']['name']; if (is_array($siteAccessArray) && count($siteAccessArray) > 0) { if (!in_array($access, $siteAccessArray)) { return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'); } } $index = new xrowSitemapIndex(); $dirArray = array(eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain(), eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain() . '/' . xrowSitemapTools::FILETYP_ARCHIVE, eZSys::storageDirectory() . '/sitemap/' . xrowSitemapTools::domain() . '/' . xrowSitemapTools::FILETYP_STANDARD); foreach ($dirArray as $item) { addFiles($index, $item, $dirArray); } function addFiles(&$index, $dirname, $dirArray) { try { $dir = new eZClusterDirectoryIterator($dirname); } catch (Exception $e) { if ($e instanceof UnexpectedValueException) { eZDebug::writeDebug("Cannot add {$dirname} to the sitemaps index because it does not exist"); return; } } foreach ($dir as $file) { $f = eZClusterFileHandler::instance($file->name());
public static function createMobileSitemap() { eZDebug::writeDebug("Generating mobile sitemap ...", __METHOD__); $cli = eZCLI::instance(); if (!$isQuiet) { $cli->output("Generating mobile sitemap for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n"); } $ini = eZINI::instance('site.ini'); $xrowsitemapINI = eZINI::instance('xrowsitemap.ini'); // Get the Sitemap's root node $rootNode = self::rootNode(); // Settings variables if ($xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterType') and $xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterArray')) { $params2 = array('ClassFilterType' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterArray')); } $max = self::MAX_PER_FILE; $limit = 50; // Fetch the content tree $params = array('SortBy' => array(array('depth', true), array('published', true))); if (isset($params2)) { $params = array_merge($params, $params2); } $subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID); if ($subtreeCount == 1) { $cli->output("No Items found under RootNode {$rootNode->NodeID}."); } if (!$isQuiet) { $amount = $subtreeCount + 1; // +1 is root node $cli->output("Adding {$amount} nodes to the sitemap for RootNode {$rootNode->NodeID}."); $output = new ezcConsoleOutput(); $bar = new ezcConsoleProgressbar($output, $amount); } $addPrio = false; if ($xrowsitemapINI->hasVariable('Settings', 'AddPriorityToSubtree') and $xrowsitemapINI->variable('Settings', 'AddPriorityToSubtree') == 'true') { $addPrio = true; } $sitemap = new xrowMobileSitemap(); // Generate Sitemap /** START Adding the root node **/ $object = $rootNode->object(); $meta = xrowMetaDataFunctions::fetchByObject($object); $extensions = array(); $extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode')); $url = $rootNode->attribute('url_alias'); eZURI::transformURI($url); if ($xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') && $xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') != '') { $mobileDomain = $xrowsitemapINI->variable('SitemapSettings', 'MobileDomainName'); } else { $mobileDomain = self::domain(); } $url = 'http://' . $mobileDomain . $url; if ($meta and $meta->sitemap_use != '0') { $extensions[] = new xrowSitemapItemFrequency($meta->change); $extensions[] = new xrowSitemapItemPriority($meta->priority); $sitemap->add($url, $extensions); } elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') { if ($addPrio) { $extensions[] = new xrowSitemapItemPriority('1'); } $sitemap->add($url, $extensions); } if (isset($bar)) { $bar->advance(); } /** END Adding the root node **/ $max = min($max, $subtreeCount); $params['Limit'] = min($max, $limit); $params['Offset'] = 0; while ($params['Offset'] < $max) { $nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID); foreach ($nodeArray as $subTreeNode) { eZContentLanguage::expireCache(); $meta = xrowMetaDataFunctions::fetchByNode($subTreeNode); $extensions = array(); $extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode')); $url = $subTreeNode->attribute('url_alias'); eZURI::transformURI($url); $url = 'http://' . $mobileDomain . $url; if ($meta and $meta->sitemap_use != '0') { $extensions[] = new xrowSitemapItemFrequency($meta->change); $extensions[] = new xrowSitemapItemPriority($meta->priority); $sitemap->add($url, $extensions); } elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') { if ($addPrio) { $rootDepth = $rootNode->attribute('depth'); $prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10; if ($prio > 0) { $extensions[] = new xrowSitemapItemPriority($prio); } } $sitemap->add($url, $extensions); } if (isset($bar)) { $bar->advance(); } } eZContentObject::clearCache(); $params['Offset'] += $params['Limit']; } // write XML Sitemap to file $dir = eZSys::storageDirectory() . '/sitemap/' . self::domain(); if (!is_dir($dir)) { mkdir($dir, 0777, true); } $filename = $dir . '/' . xrowSitemap::BASENAME . '_' . self::FILETYP_MOBILE . '_' . $GLOBALS['eZCurrentAccess']['name'] . '.' . xrowSitemap::SUFFIX; $sitemap->save($filename); /** * @TODO How will this work with cluster? if ( function_exists( 'gzencode' ) and $xrowsitemapINI->variable( 'MobileSitemapSettings', 'Gzip' ) == 'enabled' ) { $content = file_get_contents( $filename ); $content = gzencode( $content ); file_put_contents( $filename . '.gz', $content ); unlink( $filename ); $filename .= '.gz'; } **/ if (!$isQuiet) { $cli->output("\n"); $cli->output("Mobile sitemap {$filename} for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " has been generated.\n"); } }
/** * @todo optimize db query: use a prepared statement */ public function checkFiles($doDelete = false, $returnData = false) { $violations = array(); $dir = $this->clusterizeDir(eZSys::storageDirectory() . '/original'); if (!is_dir($dir)) { return $violations; } $dir = realpath($dir); foreach (glob($dir . '/*', GLOB_ONLYDIR) as $storageDir) { if (in_array(basename($storageDir), array('.', '..'))) { continue; } foreach (glob($storageDir . '/*') as $storageFile) { if (!is_file($storageFile)) { continue; } $fileName = basename($storageFile); $dirName = basename($storageDir); $sql1 = "SELECT COUNT(*) AS found FROM ezbinaryfile " . "WHERE filename = '" . $this->db->escapeString($fileName) . "' AND mime_type LIKE '" . $this->db->escapeString($dirName) . "/%'"; $sql2 = "SELECT COUNT(*) AS found FROM ezmedia " . "WHERE filename = '" . $this->db->escapeString($fileName) . "' AND mime_type LIKE '" . $this->db->escapeString($dirName) . "/%'"; $results1 = $this->db->arrayQuery($sql1); $results2 = $this->db->arrayQuery($sql2); if ($results1[0]['found'] == 0 && $results2[0]['found'] == 0) { if (isset($violations['violatingFileCount'])) { $violations['violatingFileCount']++; } else { $violations['violatingFileCount'] = 1; } if ($returnData) { $violations['violatingFiles'][] = $storageFile; } if ($doDelete) { unlink($storageFile); } } /*else { echo "OK: $storageFile\n"; }*/ } } return $violations; }
function storedFileInfo() { $fileName = $this->attribute('filename'); $mimeType = $this->attribute('mime_type'); $originalFileName = $this->attribute('original_filename'); $storageDir = eZSys::storageDirectory(); $group = ''; $type = ''; if ($mimeType) { list($group, $type) = explode('/', $mimeType); } $filePath = $storageDir . '/original/' . $group . '/' . $fileName; return array('filename' => $fileName, 'original_filename' => $originalFileName, 'filepath' => $filePath, 'mime_type' => $mimeType); }
function getMIBTree() { // build list of oids corresponding to order status $db = self::eZDBinstance(); $orderStatusIdoids = array(); $orderStatusNameoids = array(); $orderStatusCountoids = array(); $orderStatusArchiveCountoids = array(); if ($db) { $status = $db->arrayQuery('select status_id, name from ezorder_status where is_active=1 order by id'); $db->close(); if (is_array($status)) { $i = 1; foreach ($status as $line) { self::$orderstatuslist = array_merge(self::$orderstatuslist, array("2.1.5.1.1.1.{$i}" => $line['status_id'], "2.1.5.1.1.2.{$i}" => $line['name'], "2.1.5.1.1.3.{$i}" => $line['status_id'], "2.1.5.1.1.4.{$i}" => $line['status_id'])); $orderStatusIdoids[$i] = array('name' => 'orderStatusId' . $i, 'syntax' => 'INTEGER'); $orderStatusNameoids[$i] = array('name' => 'orderStatusname' . $i, 'syntax' => 'DisplayString'); $orderStatusCountoids[$i] = array('name' => 'orderStatusCount' . $i, 'syntax' => 'INTEGER'); $orderStatusArchiveCountoids[$i] = array('name' => 'orderStatusArchive' . $i, 'syntax' => 'INTEGER'); $i++; } } //var_dump($orderStatusArchiveCountoids); //die(); } else { // what to do in this case? db is down - maybe we should raise an exception // instead of producing a shortened oid list... } // build list of oids corresponding to caches and store for later their config $i = 1; $cacheoids = array(); foreach (eZCache::fetchList() as $cacheItem) { if ($cacheItem['path'] != false) { $id = $cacheItem['id']; self::$cachelist = array_merge(self::$cachelist, array("2.2.{$i}.1" => $id, "2.2.{$i}.2" => $id, "2.2.{$i}.3" => $id, "2.2.{$i}.4" => $id)); $cachename = 'cache' . ucfirst(eZSNMPd::asncleanup($id)); $cacheoids[$i] = array('name' => $cachename, 'children' => array(1 => array('name' => "{$cachename}Name", 'syntax' => 'DisplayString', 'description' => 'The name of this cache.'), 2 => array('name' => "{$cachename}Status", 'syntax' => 'INTEGER', 'description' => 'Cache status: 1 for enabled, 0 for disabled.'), 3 => array('name' => "{$cachename}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the cache (-1 if current cluster mode not supported).'), 4 => array('name' => "{$cachename}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the cache (-1 if current cluster mode not supported).'))); $i++; } } // build list of oids corresponding to storage dirs /// @todo this way of finding storage dir is lame, as it depends on them having been created /// it will also not work in cluster mode, as there will be no dirs on the fs... $storagedir = eZSys::storageDirectory(); $files = @scandir($storagedir); $i = 1; $storagediroids = array(); foreach ($files as $file) { if ($file != '.' && $file != '..' && is_dir($storagedir . '/' . $file)) { self::$storagedirlist = array_merge(self::$storagedirlist, array("2.3.{$i}.1" => $storagedir . '/' . $file, "2.3.{$i}.2" => $storagedir . '/' . $file, "2.3.{$i}.3" => $storagedir . '/' . $file)); $storagedirname = 'storage' . ucfirst(eZSNMPd::asncleanup($file)); $storagediroids[$i] = array('name' => $storagedirname, 'children' => array(1 => array('name' => "{$storagedirname}Path", 'syntax' => 'DisplayString', 'description' => 'The path of this storage dir.'), 2 => array('name' => "{$storagedirname}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the dir (-1 if current cluster mode not supported).'), 3 => array('name' => "{$storagedirname}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the dir (-1 if current cluster mode not supported).'))); $i++; } } return array('name' => 'eZPublish', 'children' => array(2 => array('name' => 'status', 'children' => array(1 => array('name' => 'database', 'children' => array(1 => array('name' => 'dbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the database.'), 2 => array('name' => 'content', 'children' => array(1 => array('name' => 'contentObjects', 'syntax' => 'INTEGER', 'description' => 'The number of content objects.'), 2 => array('name' => 'contentObjectAttributes', 'syntax' => 'INTEGER', 'description' => 'The number of content object attributes.'), 3 => array('name' => 'contentObjectNodes', 'syntax' => 'INTEGER', 'description' => 'The number of content nodes.'), 4 => array('name' => 'contentObjectRelations', 'syntax' => 'INTEGER', 'description' => 'The number of content object relations.'), 5 => array('name' => 'contentObjectDrafts', 'syntax' => 'INTEGER', 'description' => 'The number of content objects in DRAFT state.'), 6 => array('name' => 'contentObjectClasses', 'syntax' => 'INTEGER', 'description' => 'The number of content object classes.'), 7 => array('name' => 'contentObjectInfoCollections', 'syntax' => 'INTEGER', 'description' => 'The number of information collections.'), 8 => array('name' => 'contentObjectsPendingIndexation', 'syntax' => 'INTEGER', 'description' => 'The number of objects pending a search-engine indexation.'), 9 => array('name' => 'pendingNotificationEvents', 'syntax' => 'INTEGER', 'description' => 'The number of pending notification events.'))), 3 => array('name' => 'users', 'children' => array(1 => array('name' => 'registeredusers', 'syntax' => 'INTEGER', 'description' => 'The number of existing user accounts.'))), 4 => array('name' => 'sessions', 'children' => array(1 => array('name' => 'allSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active sessions.'), 2 => array('name' => 'anonSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active anonymous users sessions.'), 3 => array('name' => 'registeredSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active registered users sessions.'))), 5 => array('name' => 'shop', 'children' => array(1 => array('name' => 'orderStatusTable', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'SEQUENCE OF OrderStatusEntry', 'description' => 'A table containing the number of orders per order state.', 'children' => array(0 => array('name' => 'OrderStatusEntry', 'syntax' => 'SEQUENCE', 'items' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER'), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString'), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER'), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER'))), 1 => array('name' => 'orderStatusEntry', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'OrderStatusEntry', 'description' => 'A table row describing the set of orders in status N.', 'index' => 'orderStatusId', 'children' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER (1..99)', 'description' => 'ID of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusIdoids), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString', 'description' => 'The name of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusNameoids), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER', 'description' => 'Number of active orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusCountoids), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER', 'description' => 'Number of archived orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusArchiveCountoids))))))), 6 => array('name' => 'asyncpublishing', 'children' => array(1 => array('name' => 'AsyncPublishingWorkingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Working status'), 2 => array('name' => 'AsyncPublishingFinishedCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Finished status'), 3 => array('name' => 'AsyncPublishingPendingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Pending status'), 4 => array('name' => 'AsyncPublishingDeferredCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Deferred status'), 5 => array('name' => 'AsyncPublishingUnknownCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Unknown status'))))), 2 => array('name' => 'cache', 'children' => $cacheoids), 3 => array('name' => 'storage', 'children' => $storagediroids), 4 => array('name' => 'external', 'children' => array(1 => array('name' => 'ldap', 'syntax' => 'INTEGER', 'description' => 'Connectivity to LDAP server (-1 if not configured).'), 2 => array('name' => 'web', 'syntax' => 'INTEGER', 'description' => 'Connectivity to the web. (probes a series of webservers defined in snmpd.ini, returns -1 if not configured).'), 3 => array('name' => 'email', 'syntax' => 'INTEGER', 'description' => 'Connectivity to mail server (NB: will send a test mail when probed to a recipient defined in snmpd.ini, returns -1 if not configured).'))), 5 => array('name' => 'cluster', 'children' => array(1 => array('name' => 'clusterdbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the cluster database (-1 for NA).'))))))); }
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; }
/** * @return string */ public static function directory() { $ini = eZIni::instance('merck.ini'); return eZDir::path(array(eZSys::storageDirectory(), $ini->variable('FileSettings', 'StaticDir'))); }
$originalFileName = $imageRows[0]['original_filename']; $mimeType = $imageRows[0]['mime_type']; $altText = $imageRows[0]['alternative_text']; $dirPath = eZSys::storageDirectory() . '/original/image'; $filePath = $dirPath . '/' . $fileName; $baseName = $fileName; $dotPosition = strrpos($fileName, '.'); if ($dotPosition !== false) { $baseName = substr($fileName, 0, $dotPosition); $suffix = substr($fileName, $dotPosition + 1); } $width = false; $height = false; $fileExists = file_exists($filePath); if (!$fileExists) { $referenceDirPath = eZSys::storageDirectory() . '/reference/image'; $suffixList = array('jpg', 'png', 'gif'); foreach ($suffixList as $suffix) { $referenceFilePath = $referenceDirPath . '/' . $baseName . '.' . $suffix; if (file_exists($referenceFilePath)) { $filePath = $referenceFilePath; $dirPath = $referenceDirPath; $fileExists = true; break; } } } if ($fileExists) { $isValid = true; $info = getimagesize($filePath); if ($info) {
/** * Fills the user object data map with auth data * * @param array $dataMap * @param array $authResult */ private static function fillUserObject($dataMap, $authResult) { if (isset($dataMap['first_name'])) { $dataMap['first_name']->fromString($authResult['first_name']); $dataMap['first_name']->store(); } if (isset($dataMap['last_name'])) { $dataMap['last_name']->fromString($authResult['last_name']); $dataMap['last_name']->store(); } if (isset($dataMap['image']) && !empty($authResult['picture'])) { $storageDir = eZSys::storageDirectory() . '/ngconnect'; if (!file_exists($storageDir)) { mkdir($storageDir); } $fileName = $storageDir . '/' . $authResult['login_method'] . '_' . $authResult['id']; $image = ngConnectFunctions::fetchDataFromUrl($authResult['picture'], true, $fileName); if ($image) { $dataMap['image']->fromString($fileName); $dataMap['image']->store(); unlink($fileName); } } }