function sendMail(ezcMail $mail) { $separator = "/"; $mail->appendExcludeHeaders(array('to', 'subject')); $headers = rtrim($mail->generateHeaders()); // rtrim removes the linebreak at the end, mail doesn't want it. if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) { throw new ezcMailTransportException('No recipient addresses found in message header.'); } $additionalParameters = ""; if (isset($mail->returnPath)) { $additionalParameters = "-f{$mail->returnPath->email}"; } $sys = eZSys::instance(); $fname = time() . '-' . rand() . '.mail'; $qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq'; $data = $headers . ezcMailTools::lineBreak(); $data .= ezcMailTools::lineBreak(); $data .= $mail->generateBody(); $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data); $success = eZFile::create($fname, $qdir, $data); if ($success === false) { throw new ezcMailTransportException('The email could not be sent by sendmail'); } }
function sendMail(eZMail $mail) { $ini = eZINI::instance(); $sendmailOptions = ''; $emailFrom = $mail->sender(); $emailSender = isset($emailFrom['email']) ? $emailFrom['email'] : false; if (!$emailSender || count($emailSender) <= 0) { $emailSender = $ini->variable('MailSettings', 'EmailSender'); } if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } if (!eZMail::validate($emailSender)) { $emailSender = false; } $isSafeMode = ini_get('safe_mode') != 0; $sendmailOptionsArray = $ini->variable('MailSettings', 'SendmailOptions'); if (is_array($sendmailOptionsArray)) { $sendmailOptions = implode(' ', $sendmailOptionsArray); } elseif (!is_string($sendmailOptionsArray)) { $sendmailOptions = $sendmailOptionsArray; } if (!$isSafeMode and $emailSender) { $sendmailOptions .= ' -f' . $emailSender; } if ($isSafeMode and $emailSender and $mail->sender() == false) { $mail->setSenderText($emailSender); } if (function_exists('mail')) { $message = $mail->body(); $sys = eZSys::instance(); $excludeHeaders = array('Subject'); // If not Windows PHP mail() implementation, we can not specify a To: header in the $additional_headers parameter, // because then there will be 2 To: headers in the resulting e-mail. // However, we can use "undisclosed-recipients:;" in $to. if ($sys->osType() != 'win32') { $excludeHeaders[] = 'To'; $receiverEmailText = count($mail->ReceiverElements) > 0 ? $mail->receiverEmailText() : 'undisclosed-recipients:;'; } else { $receiverEmailText = $mail->receiverEmailText(); } // If in debug mode, send to debug email address and nothing else if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') { $receiverEmailText = $ini->variable('MailSettings', 'DebugReceiverEmail'); $excludeHeaders[] = 'To'; $excludeHeaders[] = 'Cc'; $excludeHeaders[] = 'Bcc'; } $extraHeaders = $mail->headerText(array('exclude-headers' => $excludeHeaders)); $returnedValue = mail($receiverEmailText, $mail->subject(), $message, $extraHeaders, $sendmailOptions); if ($returnedValue === false) { eZDebug::writeError('An error occurred while sending e-mail. Check the Sendmail error message for further information (usually in /var/log/messages)', __METHOD__); } return $returnedValue; } else { eZDebug::writeWarning("Unable to send mail: 'mail' function is not compiled into PHP.", __METHOD__); } return false; }
public function tearDown() { // Make sure to restore the RequestURI in case other tests depends on // on the RequestURI variable. $ezsys = eZSys::instance(); $ezsys->RequestURI = $this->originalRequestURI; parent::tearDown(); }
public function __construct() { $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); $this->ArchiveDir = $storage_dir . '/' . $this->ArchiveDirName; if (!file_exists($this->ArchiveDir)) { eZDir::mkdir($this->ArchiveDir, false, true); } }
function storageDir( $sub_dir = false ) { $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); if ( $sub_dir !== false ) $dir = $storage_dir . "/$sub_dir/" . $this->MimeCategory; else $dir = $storage_dir . "/" . $this->MimeCategory; return $dir; }
public function setUp() { parent::setUp(); // Backup previous instance of eZSys (if any) and reset it $this->oldSysInstance = eZSys::instance(); eZSys::setInstance(); // Set the RequestURI to a known value so that eZSys::requestURI() // returns something known and useful. $this->queryString = "?foo=bar&this=that"; eZSys::setServerVariable("REQUEST_URI", "/all/work/and/no/sleep/makes/(ole)/a/(dull)/boy{$this->queryString}"); eZSys::init(); }
function deleteStoredObjectAttribute($contentObjectAttribute, $version = null) { $contentObjectAttributeID = $contentObjectAttribute->attribute("id"); $mediaFiles = ezflowMedia::fetch($contentObjectAttributeID, null); $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); if ($version == null) { foreach ($mediaFiles as $mediaFile) { $mimeType = $mediaFile->attribute("mime_type"); list($prefix, $suffix) = split('[/]', $mimeType); // $orig_dir = "var/storage/original/" . $prefix; $orig_dir = $storage_dir . '/original/' . $prefix; $fileName = $mediaFile->attribute("filename"); if ($fileName == '') { continue; } $file = eZClusterFileHandler::instance($orig_dir . "/" . $fileName); if ($file->exists()) { $file->delete(); } } } else { $count = 0; $currentBinaryFile = ezflowMedia::fetch($contentObjectAttributeID, $version); if ($currentBinaryFile != null) { $mimeType = $currentBinaryFile->attribute("mime_type"); $currentFileName = $currentBinaryFile->attribute("filename"); list($prefix, $suffix) = is_string($mimeType) && $mimeType ? split('[/]', $mimeType) : array(null, null); // $orig_dir = "var/storage/original/" . $prefix; $orig_dir = $storage_dir . '/original/' . $prefix; foreach ($mediaFiles as $mediaFile) { $fileName = $mediaFile->attribute("filename"); if ($currentFileName == $fileName) { $count += 1; } } if ($count == 1 && $currentFileName != '') { $file = eZClusterFileHandler::instance($orig_dir . "/" . $currentFileName); if ($file->exists()) { $file->delete(); } } } } ezflowMedia::removeByID($contentObjectAttributeID, $version); }
/** * * @param unknown_type $receiver * @param unknown_type $subject * @param unknown_type $message * @param unknown_type $extraHeaders * @param unknown_type $emailReturnPath * @return file */ function createMailFile($receiver, $subject, $message, $extraHeaders, $emailReturnPath = '') { $sys = eZSys::instance(); $lineBreak = $sys->osType() == 'win32' ? "\r\n" : "\n"; // $separator = ($sys->osType() == 'win32' ? "\\" : "/" ); // $fileName = date("Ymd") .'-' .date("His").'-'.rand().'.mail'; $fileName = time() . '-' . rand() . '-cjw_nl.mail'; // $mailDir = eZSys::siteDir().eZSys::varDirectory().'/log/mail'; // $mailDir = eZSys::siteDir().'var/log/mail'; $data = $extraHeaders . $lineBreak; if ($emailReturnPath != '') { $data .= "Return-Path: <" . $emailReturnPath . ">" . $lineBreak; } $data .= "To: " . $receiver . $lineBreak; $data .= "Subject: " . $subject . $lineBreak; // $data .= "From: ".$emailSender.$lineBreak; $data .= $lineBreak; $data .= $message; $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data); return eZFile::create($fileName, $this->mailDir, $data); }
function __construct() { $this->ReceiverElements = array(); $this->MobileElements = array(); $this->From = false; $this->CcElements = array(); $this->BccElements = array(); $this->ReplyTo = false; $this->Subject = false; $this->BodyText = false; $this->ExtraHeaders = array(); $this->TextCodec = false; $this->MessageID = false; $this->Date = false; // Sets some default values $version = eZPublishSDK::version(); $this->MIMEVersion = '1.0'; $this->ContentType = array('type' => 'text/plain', 'charset' => eZTextCodec::internalCharset(), 'transfer-encoding' => '8bit', 'disposition' => 'inline', 'boundary' => false); $this->UserAgent = "eZ publish, Version {$version}"; $ini = eZINI::instance(); // HACK! Ignore system content type //if ( $ini->hasVariable( 'MailSettings', 'ContentType' ) ) // $this->setContentType( $ini->variable( 'MailSettings', 'ContentType' ) ); if (!defined('EZ_MAIL_LINE_SEPARATOR')) { $ini = eZINI::instance('site.ini'); $ending = $ini->variable('MailSettings', 'HeaderLineEnding'); if ($ending == 'auto') { $sys = eZSys::instance(); // For windows we use \r\n which is the endline defined in RFC 2045 if ($sys->osType() == 'win32') { $separator = "\r\n"; } else { $separator = "\n"; } } else { $separator = urldecode($ending); } define('EZ_MAIL_LINE_SEPARATOR', $separator); } }
/** * Implementation of an 'ezurl' template operator * Makes valid eZ Publish urls to use in links * * @param string &$href * @param boolean $ignoreIndexDir * @param string $serverURL full|relative * @return string the link to use */ public static function transformURI(&$href, $ignoreIndexDir = false, $serverURL = null) { if ($serverURL === null) { $serverURL = self::$transformURIMode; } if (preg_match("#^[a-zA-Z0-9]+:#", $href) || substr($href, 0, 2) == '//') { return false; } if (strlen($href) == 0) { $href = '/'; } else { if ($href[0] == '#') { $href = htmlspecialchars($href); return true; } else { if ($href[0] != '/') { $href = '/' . $href; } } } $sys = eZSys::instance(); $dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir(); $serverURL = $serverURL === 'full' ? $sys->serverURL() : ''; $href = $serverURL . $dir . $href; if (!$ignoreIndexDir) { $href = preg_replace("#^(//)#", "/", $href); $href = preg_replace("#(^.*)(/+)\$#", "\$1", $href); } $href = str_replace('&amp;', '&', htmlspecialchars($href)); if ($href == "") { $href = "/"; } return true; }
function fetchNodeInfo( &$node ) { // When finished, we'll return an array of attributes/properties. $entry = array(); // Grab settings from the ini file: $webdavINI = eZINI::instance( eZWebDAVContentServer::WEBDAV_INI_FILE ); $iniSettings = $webdavINI->variable( 'DisplaySettings', 'FileAttribute' ); $classIdentifier = $node->attribute( 'class_identifier' ); $object = $node->attribute( 'object' ); // By default, everything is displayed as a folder: // Trim the name of the node, it is in some cases whitespace in eZ Publish $entry["name"] = trim( $node->attribute( 'name' ) ); $entry["size"] = 0; $entry["mimetype"] = 'httpd/unix-directory'; $entry["ctime"] = $object->attribute( 'published' ); $entry["mtime"] = $object->attribute( 'modified' ); $upload = new eZContentUpload(); $info = $upload->objectFileInfo( $object ); $suffix = ''; $class = $object->contentClass(); $isObjectFolder = $this->isObjectFolder( $object, $class ); if ( $isObjectFolder ) { // We do nothing, the default is to see it as a folder } else if ( $info ) { $filePath = $info['filepath']; $entry["mimetype"] = false; $entry["size"] = false; if ( isset( $info['filesize'] ) ) $entry['size'] = $info['filesize']; if ( isset( $info['mime_type'] ) ) $entry['mimetype'] = $info['mime_type']; // Fill in information from the actual file if they are missing. $file = eZClusterFileHandler::instance( $filePath ); if ( !$entry['size'] and $file->exists() ) { $entry["size"] = $file->size(); } if ( !$entry['mimetype'] ) { $mimeInfo = eZMimeType::findByURL( $filePath ); $entry["mimetype"] = $mimeInfo['name']; $suffix = $mimeInfo['suffix']; if ( strlen( $suffix ) > 0 ) $entry["name"] .= '.' . $suffix; } else { // eZMimeType returns first suffix in its list // this could be another one than the original file extension // so let's try to get the suffix from the file path first $suffix = eZFile::suffix( $filePath ); if ( !$suffix ) { $mimeInfo = eZMimeType::findByName( $entry['mimetype'] ); $suffix = $mimeInfo['suffix']; } if ( strlen( $suffix ) > 0 ) $entry["name"] .= '.' . $suffix; } if ( $file->exists() ) { $entry["ctime"] = $file->mtime(); $entry["mtime"] = $file->mtime(); } } else { // Here we only show items as folders if they have // is_container set to true, otherwise it's an unknown binary file if ( !$class->attribute( 'is_container' ) ) { $entry['mimetype'] = 'application/octet-stream'; } } $scriptURL = eZSys::instance()->RequestURI; if ( strlen( $scriptURL ) > 0 and $scriptURL[ strlen( $scriptURL ) - 1 ] != "/" ) $scriptURL .= "/"; $trimmedScriptURL = trim( $scriptURL, '/' ); $scriptURLParts = explode( '/', $trimmedScriptURL ); $siteAccess = $scriptURLParts[0]; $virtualFolder = $scriptURLParts[1]; $startURL = '/' . $siteAccess . '/' . $virtualFolder . '/'; // Set the href attribute (note that it doesn't just equal the name). if ( !isset( $entry['href'] ) ) { if ( strlen( $suffix ) > 0 ) $suffix = '.' . $suffix; $alias = $node->urlAlias(); if ( $virtualFolder == eZWebDAVContentServer::virtualMediaFolderName() ) { // remove the real media node url alias, the virtual media folder is already in $startURL $aliasParts = explode( '/', $alias ); array_shift( $aliasParts ); $alias = implode( '/', $aliasParts ); } $entry["href"] = $startURL . $alias . $suffix; } // Return array of attributes/properties (name, size, mime, times, etc.). return $entry; }
static function lineSeparator() { $ini = eZINI::instance( 'site.ini' ); $ending = $ini->variable( 'MailSettings', 'HeaderLineEnding' ); if ( $ending == 'auto' ) { $sys = eZSys::instance(); // For windows we use \r\n which is the endline defined in RFC 2045 if ( $sys->osType() == 'win32' ) { $separator = "\r\n"; } else // for linux/unix/mac we use \n only due to some mail transfer agents destroying // emails containing \r\n { $separator = "\n"; } } else { $separator = urldecode( $ending ); } return $separator; }
/** * Sets eZSys instance or clears it if left undefined. * * @param eZSys $instance */ public static function setInstance( eZSys $instance = null ) { self::$instance = $instance; }
/** * generateTag * @param array $files * @return string $html */ private function generateTag($files) { eZDebug::writeDebug($files, 'ezLessOperator::generateTag'); $html = $cssContent = ''; $ini = eZINI::instance('ezless.ini'); $compileMethod = trim($ini->variable('ezlessconfig', 'CompileMethod')); $useOneFile = $ini->variable('ezlessconfig', 'useOneFile'); // ToDo: siteaccess as parameter $bases = eZTemplateDesignResource::allDesignBases(); $triedFiles = array(); $importsTried = array(); if ($compileMethod === 'javascript') { foreach ($files as $file) { $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles); if ($match) { $path = "/{$match['path']}"; $html .= "<link rel=\"stylesheet/less\" type=\"text/css\" href=\"{$path}\">" . PHP_EOL; } } $lessJSFilename = $ini->variable('ezlessconfig', 'LessJSFile'); $lookForLessJS = eZTemplateDesignResource::fileMatch($bases, '', 'javascript/' . $lessJSFilename, $triedFiles); if (!$lookForLessJS) { eZDebug::writeDebug("Using LessJS mode but unable to find less.js (LessJSFile={$lessJSFilename}).\nTried files : " . implode("\n", $triedFiles), __CLASS__ . "::" . __FUNCTION__); } else { $path = "/{$lookForLessJS['path']}"; $html .= "<script src=\"{$path}\" type=\"text/javascript\" ></script>" . PHP_EOL; } return $html; } elseif ($compileMethod === 'lessphp') { $sys = eZSys::instance(); $path = $sys->cacheDirectory() . '/public/stylesheets'; require_once dirname(__FILE__) . '/../lib/lessphp/lessc.inc.php'; $packerLevel = $this->getPackerLevel(); $less = new lessc(); foreach ($bases as $base) { $less->importDir[] = $base . DIRECTORY_SEPARATOR . 'stylesheets'; } $importContent = ""; $importCss = ""; if (count(self::$imports) > 0) { foreach (self::$imports as $import) { $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $import, $importsTried); $importCss = file_get_contents($match['path']); $importContent .= $importCss; } } foreach ($files as $file) { $match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles); $content = file_get_contents($match['path']); $content = ezjscPacker::fixImgPaths($content, $match['path']); if ($useOneFile == "true") { $cssContent .= $content; } else { try { $parsedContent = $less->parse($importContent . $content); if ($packerLevel > 1) { $parsedContent = $this->optimizeCSS($parsedContent, $packerLevel); } // $file = md5(uniqid(mt_rand(), true)) . ".css"; $file = substr($file, 0, -4) . 'css'; // we wan't to know what's the name of the less file on the browser $file = $path . '/' . $file; $clusterFile = eZClusterFileHandler::instance($file); $clusterFile->storeContents($parsedContent, 'ezless', 'text/css'); eZURI::transformURI($file, true); $html .= '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL; } catch (Exception $e) { eZDebug::writeError($e->getMessage(), 'ezLessOperator for ' . $match['path']); } } } if ($useOneFile == "true") { $file = md5(uniqid(mt_rand(), true)) . ".css"; try { $parsedContent = $less->parse($cssContent); if ($packerLevel > 1) { $parsedContent = $this->optimizeCSS($parsedContent, $packerLevel); } $file = $path . '/' . $file; $clusterFile = eZClusterFileHandler::instance($file); $clusterFile->storeContents($parsedContent, 'ezless', 'text/css'); eZURI::transformURI($file, true); $html = '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL; } catch (Exception $e) { eZDebug::writeError($e->getMessage(), 'ezLessOperator parsing error'); } } return $html; } else { eZDebug::writeError("Unknown compile method : '{$compileMethod}'", __CLASS__ . "::" . __FUNCTION__); } }
function deleteStoredObjectAttribute( $contentObjectAttribute, $version = null ) { $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" ); $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); if ( $version == null ) { $binaryFiles = eZBinaryFile::fetch( $contentObjectAttributeID ); eZBinaryFile::removeByID( $contentObjectAttributeID, null ); foreach ( $binaryFiles as $binaryFile ) { $mimeType = $binaryFile->attribute( "mime_type" ); list( $prefix, $suffix ) = explode('/', $mimeType ); $orig_dir = $storage_dir . '/original/' . $prefix; $fileName = $binaryFile->attribute( "filename" ); // Check if there are any other records in ezbinaryfile that point to that fileName. $binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName( $fileName ); $filePath = $orig_dir . "/" . $fileName; $file = eZClusterFileHandler::instance( $filePath ); if ( $file->exists() and count( $binaryObjectsWithSameFileName ) < 1 ) $file->delete(); } } else { $count = 0; $binaryFile = eZBinaryFile::fetch( $contentObjectAttributeID, $version ); if ( $binaryFile != null ) { $mimeType = $binaryFile->attribute( "mime_type" ); list( $prefix, $suffix ) = explode('/', $mimeType ); $orig_dir = $storage_dir . "/original/" . $prefix; $fileName = $binaryFile->attribute( "filename" ); eZBinaryFile::removeByID( $contentObjectAttributeID, $version ); // Check if there are any other records in ezbinaryfile that point to that fileName. $binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName( $fileName ); $filePath = $orig_dir . "/" . $fileName; $file = eZClusterFileHandler::instance( $filePath ); if ( $file->exists() and count( $binaryObjectsWithSameFileName ) < 1 ) $file->delete(); } } }
function createFile($message) { $sys = eZSys::instance(); $lineBreak = $sys->osType() == 'win32' ? "\r\n" : "\n"; $separator = $sys->osType() == 'win32' ? "\\" : "/"; $fname = time() . '-' . rand() . '.sms'; $qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq'; $data = $message; $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data); // echo 'eZFile::create('.$fname.', '.$qdir.', '.$data.');'; eZFile::create($fname, $qdir, $data); }
static function eZImage($tpl, $operatorValue, $operatorName, $skipSlash = false) { $sys = eZSys::instance(); if ($skipSlash && strlen($sys->wwwDir()) != 0) { $skipSlash = false; } $bases = eZTemplateDesignResource::allDesignBases(); $triedFiles = array(); $fileInfo = eZTemplateDesignResource::fileMatch($bases, 'images', $operatorValue, $triedFiles); if (!$fileInfo) { $tpl->warning($operatorName, "Image '{$operatorValue}' does not exist in any design"); $tpl->warning($operatorName, "Tried files: " . implode(', ', $triedFiles)); $siteDesign = eZTemplateDesignResource::designSetting('site'); $imgPath = "design/{$siteDesign}/images/{$operatorValue}"; } else { $imgPath = $fileInfo['path']; } $operatorValue = $skipSlash ? $imgPath : $sys->wwwDir() . '/' . $imgPath; $operatorValue = htmlspecialchars($operatorValue); return $operatorValue; }
/** * Called by PHPUnit before each test, bakup eZSys instance */ public function setUp() { parent::setUp(); $this->eZSysInstanceBackup = eZSys::instance(); }
static function getWwwDir() { static $wwwDir = null; if ($wwwDir === null) { $sys = eZSys::instance(); $wwwDir = $sys->wwwDir() . '/'; } return $wwwDir; }
static function requestURI() { return eZSys::instance()->RequestURI; }
function deleteStoredObjectAttribute($contentObjectAttribute, $version = null) { /* This is called when you delete the datatype from the class*/ $contentObjectAttributeID = $contentObjectAttribute->attribute("id"); $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); require_once 'kernel/classes/ezclusterfilehandler.php'; if ($version == null) { $binaryFiles = eZBinaryFile::fetch($contentObjectAttributeID); eZBinaryFile::removeByID($contentObjectAttributeID, null); foreach ($binaryFiles as $binaryFile) { $mimeType = $binaryFile->attribute("mime_type"); list($prefix, $suffix) = split('[/]', $mimeType); $orig_dir = $storage_dir . '/' . $downloadPath . '/' . $prefix; $fileName = $binaryFile->attribute("filename"); // Check if there are any other records in ezbinaryfile that point to that fileName. $binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName($fileName); $filePath = $orig_dir . "/" . $fileName; $file = eZClusterFileHandler::instance($filePath); if ($file->exists() and count($binaryObjectsWithSameFileName) < 1) { $file->delete(); } } } else { $count = 0; $binaryFile = eZBinaryFile::fetch($contentObjectAttributeID, $version); if ($binaryFile != null) { $mimeType = $binaryFile->attribute("mime_type"); list($prefix, $suffix) = split('[/]', $mimeType); $orig_dir = $storage_dir . "/original/" . $prefix; $fileName = $binaryFile->attribute("filename"); eZBinaryFile::removeByID($contentObjectAttributeID, $version); // Check if there are any other records in ezbinaryfile that point to that fileName. $binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName($fileName); $filePath = $orig_dir . "/" . $fileName; $file = eZClusterFileHandler::instance($filePath); if ($file->exists() and count($binaryObjectsWithSameFileName) < 1) { $file->delete(); } } } }
/** * Implementation of an 'ezurl' template operator * Makes valid eZ Publish urls to use in links * * @param string &$href * @param boolean $ignoreIndexDir * @param string $serverURL full|relative * @param boolean $htmlEscape true to html escape the result for HTML * @return string the link to use */ public static function transformURI(&$href, $ignoreIndexDir = false, $serverURL = null, $htmlEscape = true) { // When using ezroot, immediately stop if the linked element is external if ($ignoreIndexDir) { // The initial / needs to be removed as it is not expected by the cluster handler, // but we must use a temp variable since $href is required later $trimmedHref = ltrim($href, '/'); $modifiedHref = eZClusterFileHandler::instance()->applyServerUri($trimmedHref); if ($modifiedHref != $trimmedHref) { $href = $htmlEscape ? self::escapeHtmlTransformUri($href) : $href; return true; } unset($modifiedHref); } if ($serverURL === null) { $serverURL = self::$transformURIMode; } if (preg_match("#^[a-zA-Z0-9]+:#", $href) || substr($href, 0, 2) == '//') { return false; } if (strlen($href) == 0) { $href = '/'; } else { if ($href[0] == '#') { $href = $htmlEscape ? htmlspecialchars($href) : $href; return true; } else { if ($href[0] != '/') { $href = '/' . $href; } } } $sys = eZSys::instance(); $dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir(); $serverURL = $serverURL === 'full' ? $sys->serverURL() : ''; $href = $serverURL . $dir . $href; if (!$ignoreIndexDir) { $href = preg_replace("#^(//)#", "/", $href); $href = preg_replace("#(^.*)(/+)\$#", "\$1", $href); } $href = $htmlEscape ? self::escapeHtmlTransformUri($href) : $href; if ($href == "") { $href = "/"; } return true; }
function filepath() { $sys = eZSys::instance(); $storage_dir = $sys->storageDirectory(); return $storage_dir . '/pdf/' . $this->attribute('pdf_filename'); }
public static function serverShardingURL( $href ) { $siteINI = eZINI::instance( 'site.ini' ); if ( $siteINI->variable( 'SiteSettings', 'UrlSharding' ) == 'enabled' ) { if ( eZSys::isSSLNow() && $siteINI->variable( 'SiteSettings', 'UrlShardingSSL' ) != 'enabled' ) { // If SSL and Sharding disabled for SSL : use relative path : return ''; } $shardingList = $siteINI->variable( 'SiteSettings', 'UrlShardingList' ); if ( ! empty( $shardingList ) ) { $shardingKey = fmod( hexdec( substr( sha1( $href ), 0, 7 ) ), count( $shardingList ) ); $sys = eZSys::instance(); return $sys->serverProtocol().'://'.$shardingList[$shardingKey]; } } // use relative path as fallback : return ''; }
* File containing the updateviewcount.php cronjob * * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version 2012.8 * @package kernel */ set_time_limit(0); $cli->output("Update content view count..."); $dt = new eZDateTime(); $startTime = $dt->day() . "/" . date('M', time()) . "/" . $dt->year() . ":" . $dt->hour() . ":" . $dt->minute() . ":" . $dt->second(); $cli->output("Started at " . $dt->toString() . "\n"); eZDB::instance()->setIsSQLOutputEnabled(false); $startLine = ""; $hasStartLine = false; $updateViewLogPath = eZSys::instance()->varDirectory() . "/" . eZINI::instance()->variable('FileSettings', 'LogDir') . "/updateview.log"; if (is_file($updateViewLogPath)) { $fh = fopen($updateViewLogPath, "r"); if ($fh) { while (!feof($fh)) { $line = fgets($fh, 1024); if (preg_match("/\\[/", $line)) { $startLine = $line; $hasStartLine = true; } } fclose($fh); } } $cli->output("Start line:\n" . $startLine); $lastLine = "";
/** * Regression test for issue 16400 * @link http://issues.ez.no/16400 * @return unknown_type */ public function testIssue16400() { $className = 'Media test class'; $classIdentifier = 'media_test_class'; $filePath = 'tests/tests/kernel/datatypes/ezmedia/ezmediatype_regression_issue16400.flv'; eZFile::create( $filePath ); $attributeName = 'Media'; $attributeIdentifier = 'media'; $attributeType = 'ezmedia'; //1. test method fetchByContentObjectID $class = new ezpClass( $className, $classIdentifier, $className ); $class->add( $attributeName, $attributeIdentifier, $attributeType ); $attribute = $class->class->fetchAttributeByIdentifier( $attributeIdentifier ); $attribute->setAttribute( 'can_translate', 0 ); $class->store(); $object = new ezpObject( $classIdentifier, 2 ); $dataMap = $object->object->dataMap(); $fileAttribute = $dataMap[$attributeIdentifier]; $dataType = new eZMediaType(); $dataType->fromString( $fileAttribute, $filePath ); $fileAttribute->store(); $object->publish(); $object->refresh(); //verify fetchByContentObjectID $mediaObject = eZMedia::fetch( $fileAttribute->attribute( 'id' ), 1 ); $medias = eZMedia::fetchByContentObjectID( $object->object->attribute( 'id' ) ); $this->assertEquals( $mediaObject->attribute( 'filename' ), $medias[0]->attribute( 'filename' ) ); $medias = eZMedia::fetchByContentObjectID( $object->object->attribute( 'id' ), $fileAttribute->attribute( 'language_code' ) ); $this->assertEquals( $mediaObject->attribute( 'filename' ), $medias[0]->attribute( 'filename' ) ); //2. test issue // create translation $contentObject = $object->object; $storedFileName = $mediaObject->attribute( 'filename' ); $version = $contentObject->createNewVersionIn( 'nor-NO', $fileAttribute->attribute( 'language_code' ) ); $version->setAttribute( 'status', eZContentObjectVersion::STATUS_INTERNAL_DRAFT ); $version->store(); $version->removeThis(); $sys = eZSys::instance(); $dir = $sys->storageDirectory(); //verify the file is deleted $storedFilePath = $dir . '/original/video/' . $storedFileName; $file = eZClusterFileHandler::instance( $storedFilePath ); $this->assertTrue( $file->exists( $storedFilePath ) ); if ( $file->exists( $storedFilePath ) ) unlink( $storedFilePath ); }
function scan() { $this->IsValid = false; $this->CPUSpeed = false; $this->CPUType = false; $this->CPUUnit = false; $this->MemorySize = false; $sys = eZSys::instance(); $osType = $sys->osType(); if ($osType == 'win32') { // Windows (win32) is not supported yet // eZDebug::writeWarning( "System scan for Windows (win32) machines not supported yet" ); } else { if ($osType == 'mac') { // Mac means FreeBSD type of structure? $this->IsValid = $this->scanDMesg(); return $this->IsValid; } else { if ($osType == 'unix') { // Now determine specific 'Unix' type $osName = $sys->osName(); if ($osName == 'linux') { $this->IsValid = $this->scanProc(); return $this->IsValid; } else { if ($osName == 'freebsd') { $this->IsValid = $this->scanDMesg(); return $this->IsValid; } else { // Not known so we just try the various scanners // // /proc for Linux systems if ($this->scanProc()) { $this->IsValid = true; return true; } // dmesg.boot for FreeBSD systems if ($this->scanDMesg()) { $this->IsValid = true; return true; } } } } } } return false; }
static function lineSeparator() { $ini = eZINI::instance('site.ini'); $ending = $ini->variable('MailSettings', 'HeaderLineEnding'); if ($ending == 'auto') { $sys = eZSys::instance(); // For windows we use \r\n which is the endline defined in RFC 2045 if ($sys->osType() == 'win32') { $separator = "\r\n"; } else { $separator = "\n"; } } else { $separator = urldecode($ending); } return $separator; }
} $viewParameters = array('offset' => $Offset); $searchData = false; $tpl->setVariable("search_data", $searchData); $tpl->setVariable("search_section_id", $searchSectionID); $tpl->setVariable("search_subtree_array", $subTreeArray); $tpl->setVariable('search_timestamp', $searchTimestamp); $tpl->setVariable("search_text", $searchText); $tpl->setVariable('search_page_limit', $searchPageLimit); $tpl->setVariable("view_parameters", $viewParameters); $tpl->setVariable('use_template_search', !$useSearchCode); if ($http->hasVariable('Mode') && $http->variable('Mode') == 'browse') { if (!isset($searchResult)) { $searchResult = eZSearch::search($searchText, array("SearchType" => $searchType, "SearchSectionID" => $searchSectionID, "SearchSubTreeArray" => $subTreeArray, 'SearchTimestamp' => $searchTimestamp, "SearchLimit" => $pageLimit, "SearchOffset" => $Offset)); } $sys = eZSys::instance(); $searchResult['RequestedURI'] = "content/search"; // $searchResult['RequestedURISuffix'] = $sys->serverVariable( "QUERY_STRING" ); $searchResult['RequestedURISuffix'] = 'SearchText=' . urlencode($searchText) . ($searchTimestamp > 0 ? '&SearchTimestamp=' . $searchTimestamp : '') . '&BrowsePageLimit=' . $pageLimit . '&Mode=browse'; return $Module->run('browse', array(), array("NodeList" => $searchResult, "Offset" => $Offset, "NodeID" => isset($subTreeArray[0]) && $subTreeArray[0] != 1 ? $subTreeArray[0] : null)); } // --- Compatibility code start --- if ($useSearchCode) { $tpl->setVariable("offset", $Offset); $tpl->setVariable("page_limit", $pageLimit); $tpl->setVariable("search_text_enc", urlencode($searchText)); $tpl->setVariable("search_result", $searchResult["SearchResult"]); $tpl->setVariable("search_count", $searchResult["SearchCount"]); $tpl->setVariable("stop_word_array", $searchResult["StopWordArray"]); if (isset($searchResult["SearchExtras"])) { $tpl->setVariable("search_extras", $searchResult["SearchExtras"]);
function cachedTransformationPath() { $dir =& $GLOBALS['eZCodeMapperCachePath']; if (isset($dir)) { return $dir; } $sys = eZSys::instance(); $dir = $sys->cacheDirectory() . '/trans'; return $dir; }