Пример #1
0
    /**
     * Writes $auditName with $auditAttributes as content
     * to file name that will be fetched from ini settings by auditNameSettings() for logging.
     *
     * @param string $auditName
     * @param array $auditAttributes
     * @return bool
     */
    static function writeAudit( $auditName, $auditAttributes = array() )
    {
        $enabled = eZAudit::isAuditEnabled();
        if ( !$enabled )
            return false;

        $auditNameSettings = eZAudit::auditNameSettings();

        if ( !isset( $auditNameSettings[$auditName] ) )
            return false;

        $ip = eZSys::clientIP();
        if ( !$ip )
            $ip = eZSys::serverVariable( 'HOSTNAME', true );

        $user = eZUser::currentUser();
        $userID = $user->attribute( 'contentobject_id' );
        $userLogin = $user->attribute( 'login' );

        $message = "[$ip] [$userLogin:$userID]\n";

        foreach ( array_keys( $auditAttributes ) as $attributeKey )
        {
            $attributeValue = $auditAttributes[$attributeKey];
            $message .= "$attributeKey: $attributeValue\n";
        }

        $logName = $auditNameSettings[$auditName]['file_name'];
        $dir = $auditNameSettings[$auditName]['dir'];
        eZLog::write( $message, $logName, $dir );

        return true;
    }
Пример #2
0
 public function __construct()
 {
     $this->cacheSettings = array('path' => eZSys::cacheDirectory() . '/' . static::$cacheDirectory . '/', 'ttl' => 60);
     $this->debugAccumulatorGroup = 'nxc_social_networks_feed_';
     $this->debugAccumulatorGroup .= strtolower(str_replace(__CLASS__, '', get_called_class()));
     eZDebug::createAccumulatorGroup($this->debugAccumulatorGroup, static::$debugMessagesGroup);
 }
 /**
  * Returns part of the data for the attribute
  *
  * @param string $dataMember
  *
  * @return string
  */
 public function getDataMember($dataMember)
 {
     if ($dataMember === 'related_images') {
         $images = array();
         $relations = $this->ContentObjectAttribute->attribute('content');
         foreach ($relations['relation_list'] as $relation) {
             $object = eZContentObject::fetch($relation['contentobject_id']);
             if ($object instanceof eZContentObject) {
                 $dataMap = $object->attribute('data_map');
                 foreach ($dataMap as $attribute) {
                     /** @var eZContentObjectAttribute $attribute */
                     if ($attribute->attribute('data_type_string') !== eZImageType::DATA_TYPE_STRING) {
                         continue;
                     }
                     if ($attribute->hasContent()) {
                         $imageAliasHandler = $attribute->attribute('content');
                         $imageAlias = $imageAliasHandler->imageAlias('opengraph');
                         if ($imageAlias['is_valid'] == 1) {
                             $images[] = eZSys::serverURL() . '/' . $imageAlias['full_path'];
                         }
                     }
                 }
             }
         }
         if (empty($images)) {
             $images[] = eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
         }
         return $images;
     }
     return $this->getData();
 }
 function sendConfirmation()
 {
     if ($this->attribute('status') != eZSubscription::StatusPending) {
         return;
     }
     $res = eZTemplateDesignResource::instance();
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $template = 'design:eznewsletter/sendout/registration.tpl';
     $tpl = eZNewsletterTemplateWrapper::templateInit();
     $tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email')));
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('subscription', $this);
     $tpl->setVariable('subscriptionList', $this->attribute('subscription_list'));
     $templateResult = $tpl->fetch($template);
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     $mail = new eZMail();
     $mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName'));
     $mail->setReceiver($this->attribute('email'));
     $mail->setBody($templateResult);
     $mail->setSubject($subject);
     eZMailTransport::send($mail);
 }
 function eZTemplateImageOperator($texttoimageName = "texttoimage", $imageName = "image", $imagefileName = "imagefile")
 {
     $this->Operators = array($texttoimageName, $imageName, $imagefileName);
     $ini = eZINI::instance('texttoimage.ini');
     $fontDirs = $ini->variable("PathSettings", "FontDir");
     $this->FontDir = array();
     foreach ($fontDirs as $fontDir) {
         $this->FontDir[] = $fontDir;
     }
     $this->CacheDir = $ini->variable("PathSettings", "CacheDir");
     $this->HTMLDir = eZSys::wwwDir() . $ini->variable("PathSettings", "HtmlDir");
     $this->DefaultClass = 'default';
     $this->Family = "arial";
     $this->Colors = array("bgcolor" => array(255, 255, 255), "textcolor" => array(0, 0, 0));
     $this->PointSize = 12;
     $this->Angle = 0;
     $this->XAdjust = 0;
     $this->YAdjust = 0;
     $this->WAdjust = 0;
     $this->HAdjust = 0;
     $this->UseCache = true;
     if ($ini->variable("ImageSettings", "UseCache") == "disabled") {
         $this->UseCache = false;
     }
     $functions = array("ImageTTFBBox", "ImageCreate", "ImageColorAllocate", "ImageColorAllocate", "ImageTTFText", "ImagePNG", "ImageJPEG", "ImageDestroy");
     $this->MissingGDFunctions = array();
     foreach ($functions as $function) {
         if (!function_exists($function)) {
             $this->MissingGDFunctions[] = $function;
         }
     }
     $this->ImageGDSupported = count($this->MissingGDFunctions) == 0;
 }
Пример #6
0
function filePathForBinaryFile($fileName, $mimeType)
{
    $storageDir = eZSys::storageDirectory();
    list($group, $type) = explode('/', $mimeType);
    $filePath = $storageDir . '/original/' . $group . '/' . $fileName;
    return $filePath;
}
Пример #7
0
 static function reCAPTCHAValidate($http)
 {
     // check if the current user is able to bypass filling in the captcha and
     // return true without checking if so
     $currentUser = eZUser::currentUser();
     $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
     if ($accessAllowed["accessWord"] == 'yes') {
         return true;
     }
     $ini = eZINI::instance('recaptcha.ini');
     // If PrivateKey is an array try and find a match for the current host
     $privatekey = $ini->variable('Keys', 'PrivateKey');
     if (is_array($privatekey)) {
         $hostname = eZSys::hostname();
         if (isset($privatekey[$hostname])) {
             $privatekey = $privatekey[$hostname];
         } else {
             // try our luck with the first entry
             $privatekey = array_shift($privatekey);
         }
     }
     $recaptcha_challenge_field = $http->postVariable('recaptcha_challenge_field');
     $recaptcha_response_field = $http->postVariable('recaptcha_response_field');
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
     return $resp->is_valid;
 }
Пример #8
0
 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 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');
     }
 }
Пример #10
0
 /**
  * @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 modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'parsexml':
             $firstParam = $namedParameters['first_param'];
             if (trim($operatorValue) != '') {
                 $dom = new DOMDocument('1.0', 'utf-8');
                 if ($dom->loadXML($operatorValue)) {
                     $FileAttributeValue = $dom->getElementsByTagName($firstParam)->item(0)->textContent;
                     if (!$FileAttributeValue) {
                         $FileAttributeValue = $dom->getElementsByTagName($firstParam)->item(0)->getAttribute('value');
                     }
                 }
                 $operatorValue = $FileAttributeValue;
             }
             break;
         case 'filecheck':
             if (trim($operatorValue) != '') {
                 $dom = new DOMDocument('1.0', 'utf-8');
                 if ($dom->loadXML($operatorValue)) {
                     $FileAttributeValue = $dom->getElementsByTagName('Filename')->item(0)->textContent;
                     if (!$FileAttributeValue) {
                         $FileAttributeValue = $dom->getElementsByTagName('Filename')->item(0)->getAttribute('value');
                     }
                 }
                 if (file_exists(eZSys::wwwDir() . $FileAttributeValue)) {
                     $operatorValue = true;
                 } else {
                     $operatorValue = false;
                 }
             }
             break;
     }
 }
 function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'recaptcha_get_html':
             include_once 'extension/recaptcha/classes/recaptchalib.php';
             // Retrieve the reCAPTCHA public key from the ini file
             $ini = eZINI::instance('recaptcha.ini');
             $key = $ini->variable('Keys', 'PublicKey');
             if (is_array($key)) {
                 $hostname = eZSys::hostname();
                 if (isset($key[$hostname])) {
                     $key = $key[$hostname];
                 } else {
                     // try our luck with the first entry
                     $key = array_shift($key);
                 }
             }
             // check if the current user is able to bypass filling in the captcha and
             // return nothing so that no captcha is displayed
             $currentUser = eZUser::currentUser();
             $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
             if ($accessAllowed["accessWord"] == 'yes') {
                 $operatorValue = 'User bypasses CAPTCHA';
             } else {
                 // Run the HTML generation code from the reCAPTCHA PHP library
                 $operatorValue = recaptcha_get_html($key);
             }
             break;
     }
 }
/**
 * Loose extension path function for include use originally from ezextension.php
 *
 * @deprecated Since 4.3
 */
function extension_path($extension, $withWWWDir = false, $withHost = false, $withProtocol = false)
{
    $base = eZExtension::baseDirectory();
    $path = '';
    if ($withProtocol) {
        if (is_string($withProtocol)) {
            $path .= $withProtocol;
        } else {
            $path .= eZSys::serverProtocol();
        }
        $path .= ':';
    }
    if ($withHost) {
        $path .= '//';
        if (is_string($withHost)) {
            $path .= $withHost;
        } else {
            $path .= eZSys::hostname();
        }
    }
    if ($withWWWDir) {
        $path .= eZSys::wwwDir();
    }
    if ($withWWWDir) {
        $path .= '/' . $base . '/' . $extension;
    } else {
        $path .= $base . '/' . $extension;
    }
    return $path;
}
 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;
 }
 /**
  * Constructor
  */
 function __construct()
 {
     $this->Timestamps = array();
     $this->IsModified = false;
     $cacheDirectory = eZSys::cacheDirectory();
     $this->CacheFile = eZClusterFileHandler::instance($cacheDirectory . '/' . 'expiry.php');
     $this->restore();
 }
Пример #16
0
 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();
 }
Пример #17
0
 function eZMutex($name)
 {
     $this->Name = md5($name);
     $mutexPath = eZDir::path(array(eZSys::cacheDirectory(), 'ezmutex'));
     eZDir::mkdir($mutexPath, false, true);
     $this->FileName = eZDir::path(array($mutexPath, $this->Name));
     $this->MetaFileName = eZDir::path(array($mutexPath, $this->Name . '_meta'));
 }
 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);
     }
 }
Пример #19
0
 static function isAvailable()
 {
     $extensionName = 'zlib';
     if (!extension_loaded($extensionName)) {
         $dlExtension = eZSys::osType() == 'win32' ? '.dll' : '.so';
         @dl($extensionName . $dlExtension);
     }
     return extension_loaded($extensionName);
 }
Пример #20
0
 public function createRequestParser()
 {
     $parser = new ezpRestHttpRequestParser();
     if (strpos($_SERVER['SCRIPT_NAME'], self::INDEX_FILE) !== false) {
         // In non-vhost mode we need to build the prefix to be removed from URI
         $parser->prefix = eZSys::indexDir(true);
     }
     return $parser;
 }
Пример #21
0
    /**
     * @param string $name
     * @param mixed $value
     * @param string $cacheFileName
     * @return mixed|null
     */
    public static function dailyValue( $name, $value = null, $cacheFileName = null )
    {
        if ( $value === null && isset($memoryCache[$name]) && $cacheFileName === null )
        {
            return self::$memoryCache[$name];
        }
        else
        {
            if (is_null($cacheFileName))
            {
                $cacheFileName = self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier();
            }

            $cache = new eZPHPCreator(
                eZSys::cacheDirectory(),
                $cacheFileName . '.php',
                '',
                array()
            );

            $expiryTime = time() - 24 * 3600;

            // reading
            if ($cache->canRestore($expiryTime))
            {
                $values = $cache->restore(array('cacheTable' => 'cacheTable'));

                if (is_null($value))
                {
                    if (isset($values['cacheTable'][$name]))
                    {
                        return $values['cacheTable'][$name];
                    }
                    else
                    {
                        return null;
                    }
                }
            }
            else
            {
                $values = array('cacheTable' => array());
            }

            $values['cacheTable'][$name] = $value;
            if ( $cacheFileName == self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier() )
                self::$memoryCache = $values['cacheTable'];

            // writing
            $cache->addVariable('cacheTable', $values['cacheTable']);
            $cache->store(true);
            $cache->close();
        }

        return null;
    }
Пример #22
0
 /**
  * Instanciantes the image converter with a set of filters
  *
  * @param array(ezcImageFilter) $filter Filters to add to the image converter
  * @return void
  * @throws ezcBaseSettingValueException Error adding the transformation
  */
 public function __construct($filter)
 {
     $imageINI = eZINI::instance('image.ini');
     // we get an array of handlers, where order of entries in array gives priority
     // for each entry, we need to check if the matching handler is enabled, and this has to be manual
     $imageHandlers = $imageINI->variable('ImageConverterSettings', 'ImageConverters');
     foreach ($imageHandlers as $imageHandler) {
         switch ($imageHandler) {
             case 'ImageMagick':
                 $hasImageMagick = $imageINI->variable('ImageMagick', 'IsEnabled') == 'true';
                 if ($hasImageMagick) {
                     break 2;
                 }
                 break;
                 // GD2 is required for the image editor
                 // @todo Make the image editor degrade as nicely as possible if GD is not bundled
             // GD2 is required for the image editor
             // @todo Make the image editor degrade as nicely as possible if GD is not bundled
             case 'GD':
                 $hasGD2 = $imageINI->variable('GD', 'IsEnabled') == 'true' && $imageINI->variable('GDSettings', 'HasGD2' == 'true');
                 if ($hasGD2) {
                     break 2;
                 }
                 break;
         }
     }
     if ($hasImageMagick) {
         // we need to use the ImageMagick path configured in the image.ini file
         $executable = $imageINI->variable('ImageMagick', 'Executable');
         if (eZSys::osType() == 'win32' && $imageINI->hasVariable('ImageMagick', 'ExecutableWin32')) {
             $executable = $imageINI->variable('ImageMagick', 'ExecutableWin32');
         } else {
             if (eZSys::osType() == 'mac' && $imageINI->hasVariable('ImageMagick', 'ExecutableMac')) {
                 $executable = $imageINI->variable('ImageMagick', 'ExecutableMac');
             } else {
                 if (eZSys::osType() == 'unix' && $imageINI->hasVariable('ImageMagick', 'ExecutableUnix')) {
                     $executable = $imageINI->variable('ImageMagick', 'ExecutableUnix');
                 }
             }
         }
         if ($imageINI->hasVariable('ImageMagick', 'ExecutablePath') && $imageINI->variable('ImageMagick', 'ExecutablePath')) {
             $executable = $imageINI->variable('ImageMagick', 'ExecutablePath') . eZSys::fileSeparator() . $executable;
         }
         // @todo Remove if ezc indeed do it automatically
         // if ( eZSys::osType() == 'win32' )
         //    $executable = "\"$executable\"";
         $imageHandlerSettings = new ezcImageHandlerSettings('ImageMagick', 'eZIEEzcImageMagickHandler', array('binary' => $executable));
         $settings = new ezcImageConverterSettings(array($imageHandlerSettings));
     } else {
         $settings = new ezcImageConverterSettings(array(new ezcImageHandlerSettings('GD', 'eZIEEzcGDHandler')));
     }
     $this->converter = new ezcImageConverter($settings);
     $mimeType = $imageINI->variable('OutputSettings', 'AllowedOutputFormat');
     $this->converter->createTransformation('transformation', $filter, $mimeType);
 }
Пример #23
0
 /**
  * Returns data for the attribute
  *
  * @return string
  */
 public function getData()
 {
     if ($this->ContentObjectAttribute->hasContent()) {
         $imageAliasHandler = $this->ContentObjectAttribute->attribute('content');
         $imageAlias = $imageAliasHandler->imageAlias('opengraph');
         if ($imageAlias['is_valid'] == 1) {
             return eZSys::serverURL() . '/' . $imageAlias['full_path'];
         }
     }
     return eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
 }
Пример #24
0
 function getStore()
 {
     $varDirPath = realpath(eZSys::varDirectory());
     $store_path = $varDirPath . eZSys::fileSeparator() . 'openid_consumer';
     if (!file_exists($store_path) && !mkdir($store_path)) {
         //throw error
         exit(0);
     }
     $store = new Auth_OpenID_FileStore($store_path);
     return $store;
 }
Пример #25
0
 /**
  * Creates a new cache storage for a given location through eZ Publish cluster mechanism
  * Options can contain the 'ttl' ( Time-To-Life ). This is per default set
  * to 1 day.
  *
  * @param string $location Path to the cache location inside the cluster
  * @param array(string=>string) $options Options for the cache.
  */
 public function __construct($location, $options = array())
 {
     $path = eZSys::cacheDirectory() . '/rest/' . $location;
     if (!file_exists($path)) {
         if (!eZDir::mkdir($path, false, true)) {
             throw new ezcBaseFilePermissionException($path, ezcBaseFileException::WRITE, 'Cache location is not writeable.');
         }
     }
     parent::__construct($path);
     $this->properties['options'] = new ezpCacheStorageClusterOptions($options);
 }
Пример #26
0
 public static function save_token($SettingsBlock, $Token, $TokenSuffix = false)
 {
     $ngpush_cache = eZSys::cacheDirectory() . (self::ngpush_cache_dir ? '/' . self::ngpush_cache_dir : '');
     $token_file = $ngpush_cache . '/' . (self::token_prefix ? '_' . self::token_prefix : '') . $SettingsBlock . ($TokenSuffix ? '_' . $TokenSuffix : '') . '.txt';
     $fileHandler = eZClusterFileHandler::instance($token_file);
     $fileHandler->storeContents($Token);
     $storedToken = $fileHandler->fetchContents();
     if ($storedToken !== false) {
         return true;
     }
     return false;
 }
Пример #27
0
 function init()
 {
     if ($this->hasKickstartData()) {
         $data = $this->kickstartData();
         return $this->kickstartContinueNextStep();
     }
     if (file_exists('.htaccess')) {
         return true;
     }
     return eZSys::indexFileName() == '';
     // If in virtual host mode, continue (return true)
 }
 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;
 }
 /**
  * Test scenario for issue #014897: Object/class name pattern and cache issues [patch]
  *
  * @result $phpCache->canRestore() returns true
  * @expected $phpCache->canRestore() should return false
  *
  * @link http://issues.ez.no/14897
  */
 public function testCanRestore()
 {
     $db = eZDB::instance();
     $dbName = md5($db->DB);
     $cacheDir = eZSys::cacheDirectory();
     $phpCache = new eZPHPCreator($cacheDir, 'classidentifiers_' . $dbName . '.php', '', array('clustering' => 'classidentifiers'));
     $handler = eZExpiryHandler::instance();
     $expiryTime = 0;
     if ($handler->hasTimestamp('class-identifier-cache')) {
         $expiryTime = $handler->timestamp('class-identifier-cache');
     }
     $this->assertFalse($phpCache->canRestore($expiryTime));
 }
 function execute($process, $event)
 {
     if (!isset($_POST['CompletePublishing'])) {
         $index = eZSys::indexFile(true);
         $requestUri = eZSys::indexFile(false) . eZSys::requestUri();
         $replace = "@" . preg_quote($index) . "@i";
         $requestUri = preg_replace(array($replace), array(''), $requestUri, 1);
         $process->Template = array('templateName' => 'file:' . dirname(__FILE__) . basename(__FILE__, '.php') . '.tpl', 'templateVars' => array('uri' => $requestUri), 'path' => array(array('url' => false, 'text' => 'Workflow event regression: fetch template repeat')));
         return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
     } else {
         return eZWorkflowType::STATUS_ACCEPTED;
     }
 }