/**
  * 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;
 }
 /**
  * Generic method for logging a message
  *
  * @param string $msg
  * @param bool $bPrintMsg
  * @param string $logType
  */
 public static function logMessage($msg, $bPrintMsg = true, $logType = self::NOTICELOG)
 {
     switch ($logType) {
         case self::ERRORLOG:
             $logFile = self::ERRORLOG_FILE;
             if ($bPrintMsg) {
                 self::writeError($msg);
             }
             break;
         case self::WARNINGLOG:
             $logFile = self::WARNINGLOG_FILE;
             if ($bPrintMsg) {
                 self::writeWarning($msg);
             }
             break;
         case self::NOTICELOG:
         default:
             $logFile = self::NOTICELOG_FILE;
             if ($bPrintMsg) {
                 self::writeNotice($msg);
             }
             break;
     }
     eZLog::write($msg, $logFile);
 }
 /**
  * @param int $objectID ContentObjectID
  */
 public function __construct($objectID)
 {
     $userID = eZUser::currentUserID();
     $message = ezpI18n::tr('design/standard/error/kernel', 'Access denied') . '. ' . ezpI18n::tr('design/standard/error/kernel', 'You do not have permission to access this area.');
     eZLog::write("Access denied to content object #{$objectID} for user #{$userID}", 'error.log');
     parent::__construct($message);
 }
 public static function write_invalid_checkcreditcard_log($order_id, $response = array("errorcode" => "unknown", "errormessage" => "unknown"))
 {
     $http = eZHTTPTool::instance();
     //set fallbacks for direct ajax request
     if (!isset($order_id) or is_array($order_id) and count($order_id) == 0) {
         $order_id = $http->postVariable('order_id');
     }
     if (!isset($response) or is_array($response) and count($response) == 0) {
         $response = $http->postVariable('response');
     }
     eZLog::write("FAILED in step 1 ('checkcreditcard') for order ID " . $order_id . " with ERRORCODE " . $response["errorcode"] . " Message: " . $response["errormessage"], $logName = 'xrowpayone.log', $dir = 'var/log');
 }
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 {
     switch ($operatorName) {
         case 'hashcreate':
             $algorithm = $namedParameters['algorithm'];
             $hash_array = $namedParameters['hash_array'];
             $key = $namedParameters['key'];
             $operatorValue = xrowPayoneHelper::generate_hash($algorithm, $hash_array, $key);
             break;
         case 'payone_info_by_order':
             $order = $namedParameters['order'];
             $payone_info = array();
             if ($order instanceof eZOrder) {
                 $doc = new DOMDocument('1.0', 'utf-8');
                 $doc->loadXML($order->DataText1);
                 //try to fetch txid
                 $txid_element = $doc->getElementsByTagName('txid');
                 if ($txid_element->length >= 1) {
                     $payone_info["txid"] = (string) $txid_element->item(0)->nodeValue;
                 }
                 //try to fetch txid
                 $truncatedcardpan_element = $doc->getElementsByTagName('truncatedcardpan');
                 if ($txid_element->length >= 1) {
                     $payone_info["truncatedcardpan"] = (string) $truncatedcardpan_element->item(0)->nodeValue;
                 }
                 //try to fetch userid
                 $userid_element = $doc->getElementsByTagName('userid');
                 if ($userid_element->length >= 1) {
                     $payone_info["userid"] = (string) $userid_element->item(0)->nodeValue;
                 }
                 //try to fetch 3d secure payment status
                 $cc3d_reserved_element = $doc->getElementsByTagName('cc3d_reserved');
                 if ($cc3d_reserved_element->length >= 1) {
                     $payone_info["cc3d_reserved"] = (string) $cc3d_reserved_element->item(0)->nodeValue;
                 }
                 //try to fetch the paymentgateway
                 $paymentmethod_element = $doc->getElementsByTagName('paymentmethod');
                 if ($paymentmethod_element->length >= 1) {
                     $payone_info["paymentmethod"] = (string) $paymentmethod_element->item(0)->nodeValue;
                 }
             } else {
                 eZLog::write("\$order is not an instance of eZOrder in extension/xrowpayone/autoloads/xrowpayoneoperator.php", $logName = 'xrowpayone.log', $dir = 'var/log');
             }
             if (count($payone_info) == 0) {
                 $operatorValue = false;
             } else {
                 $operatorValue = $payone_info;
             }
             break;
     }
 }
    /**
     * @param SQLIImportHandlerOptions $options
     */
    public function __construct( SQLIImportHandlerOptions $options = null )
    {
        parent::__construct( $options );

        $ftpFolder       = 'oscar1';
        $modeUAT         = false;
        $this->startDate = microtime( true );

        if ( $this->importINI->hasVariable( 'XMLImportSettings', 'ModeUAT' )
             && $this->importINI->variable( 'XMLImportSettings', 'ModeUAT' ) == 'enabled' )
        {
            $modeUAT = true;
        }

        if ( is_object($this->options) )
        {
            if ( $this->options->hasAttribute( 'reportLevel' ) && is_numeric($reportLevel = $this->options->attribute( 'reportLevel' )) )
                XMLImportMonitor::setReportLevel( $reportLevel );

            if ( $this->options->hasAttribute( 'ftpFolder' ) && in_array($this->options->attribute( 'ftpFolder' ),array('oscar1','oscar2') ) )
                $ftpFolder = $this->options->attribute( 'ftpFolder' );
        }

        $this->rootImportFolder = $ftpFolder;

        // Initialize sqliImportItem Statistics and logs
        XMLImportDB::init( $this->importINI );
        XMLImportMapping::init( $this->importINI );
        eZLog::setMaxLogSize( 2000000 );
        eZLog::setLogrotateFiles( 20 );
        XMLImportMonitor::setOrigin($ftpFolder);
        XMLImportMonitor::setSQLiImportItem( $this->getCurrentSQLiImportItem() );
        XMLImportMonitor::pushStatistic( 'start_date', time() );

        $this->fileHandler = XMLImportFileHandler::instance($this->importINI, $ftpFolder, $modeUAT);
        XMLImportDataHandler::setIni ( $this->importINI );
        XMLImportDataHandler::setFileHandler ( $this->fileHandler );
    }
Example #7
0
 public function generateCustomErrorString($order, $response)
 {
     $payoneINI = eZINI::instance('xrowpayone.ini');
     $custom_error_node_id = $payoneINI->variable('GeneralSettings', 'CustomErrorNode');
     $error_fallback = $payoneINI->variable('GeneralSettings', 'CustomErrorFallback');
     $error_fallback = ezpI18n::tr('extension/xrowpayone', $error_fallback);
     if ($custom_error_node_id !== "disabled") {
         if (is_numeric($custom_error_node_id)) {
             $custom_error_node = eZContentObjectTreeNode::fetch($custom_error_node_id);
             if (isset($custom_error_node) and $custom_error_node instanceof eZContentObjectTreeNode) {
                 $error_code = $response["errorcode"];
                 $data_map = $custom_error_node->dataMap();
                 $matrix_identifier = $payoneINI->variable('GeneralSettings', 'CustomErrorNodeMatrixIdentifier');
                 if (isset($data_map[$matrix_identifier])) {
                     $matrix_attribute_content = $data_map[$matrix_identifier]->content();
                     $matrix_data = $matrix_attribute_content->Matrix;
                     $matrix_rows = $matrix_data["rows"];
                     $matrix_rows = $matrix_rows["sequential"];
                     foreach ($matrix_rows as $row) {
                         //now map the error code to the matrix code
                         if ($row["columns"]["0"] == $error_code) {
                             $custom_errormessage = $row["columns"]["1"];
                             //return the translated code from object
                             return $custom_errormessage;
                         }
                     }
                 } else {
                     eZLog::write("No attribute identifier named " . $matrix_identifier . " found. Please check your configuration 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode'", $logName = 'xrowpayone.log', $dir = 'var/log');
                 }
             } else {
                 eZLog::write("Could not fetch node from settings 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode' please check your configuration", $logName = 'xrowpayone.log', $dir = 'var/log');
             }
         }
     }
     //the worst fallback
     return $error_fallback;
 }
Example #8
0
 function loadCache($reset = true, $placement = false)
 {
     eZDebug::accumulatorStart('ini', 'ini_load', 'Load cache');
     if ($reset) {
         $this->reset();
     }
     $cachedDir = self::CONFIG_CACHE_DIR;
     $inputFileTime = 0;
     $fileName = $this->cacheFileName($placement);
     $cachedFile = $cachedDir . $fileName;
     if ($placement) {
         $this->PlacementCacheFile = $cachedFile;
     } else {
         $this->CacheFile = $cachedFile;
     }
     $loadCache = false;
     if (file_exists($cachedFile)) {
         $loadCache = true;
     }
     $useCache = false;
     if ($loadCache) {
         $useCache = true;
         if (eZINI::isDebugEnabled()) {
             eZDebug::writeNotice("Loading cache '{$cachedFile}' for file '" . $this->FileName . "'", __METHOD__);
         }
         include $cachedFile;
         if (!isset($data) || !isset($data['rev']) || $data['rev'] != eZINI::CONFIG_CACHE_REV) {
             if (eZINI::isDebugEnabled()) {
                 eZDebug::writeNotice("Old structure in cache file used, recreating '{$cachedFile}' to new structure", __METHOD__);
             }
             unset($data);
             $this->reset();
             $useCache = false;
         } else {
             if (self::$checkFileMtime === true || self::$checkFileMtime === $this->FileName) {
                 eZDebug::accumulatorStart('ini_check_mtime', 'ini_load', 'Check MTime');
                 $currentTime = time();
                 $cacheCreatedTime = strtotime($data['created']);
                 $iniFile = $data['file'];
                 $inputFiles = $data['files'];
                 foreach ($inputFiles as $inputFile) {
                     $fileTime = filemtime($inputFile);
                     if ($currentTime < $fileTime) {
                         eZDebug::writeError('Input file "' . $inputFile . '" has a timestamp higher then current time, ignoring to avoid infinite recursion!', __METHOD__);
                     } else {
                         if ($fileTime === false || $fileTime > $cacheCreatedTime) {
                             unset($data);
                             $this->reset();
                             $useCache = false;
                             break;
                         }
                     }
                 }
                 eZDebug::accumulatorStop('ini_check_mtime');
             }
         }
     }
     if ($useCache && isset($data)) {
         $this->Charset = $data['charset'];
         $this->ModifiedBlockValues = array();
         if ($placement) {
             $this->BlockValuesPlacement = $data['val'];
         } else {
             $this->BlockValues = $data['val'];
         }
         unset($data);
     } else {
         if (!isset($inputFiles)) {
             eZDebug::accumulatorStart('ini_find_files', 'ini_load', 'Find INI Files');
             $this->findInputFiles($inputFiles, $iniFile);
             eZDebug::accumulatorStop('ini_find_files');
             if (count($inputFiles) === 0) {
                 eZDebug::accumulatorStop('ini');
                 return false;
             }
         }
         eZDebug::accumulatorStart('ini_files_parse', 'ini_load', 'Parse');
         $this->parse($inputFiles, $iniFile, false, $placement);
         eZDebug::accumulatorStop('ini_files_parse');
         eZDebug::accumulatorStart('ini_files_save', 'ini_load', 'Save Cache');
         $cacheSaved = $this->saveCache($cachedDir, $cachedFile, $placement ? $this->BlockValuesPlacement : $this->BlockValues, $inputFiles, $iniFile);
         eZDebug::accumulatorStop('ini_files_save');
         if ($cacheSaved) {
             // Write log message to storage.log
             eZLog::writeStorageLog($fileName, $cachedDir);
         }
     }
     eZDebug::accumulatorStop('ini');
 }
Example #9
0
    /**
     * Installs the default Exception handler
     *
     * @params Exception the exception
     * @return void
     */
    static public function defaultExceptionHandler( Exception $e )
    {
        if( PHP_SAPI != 'cli' )
        {
            header( 'HTTP/1.x 500 Internal Server Error' );
            header( 'Content-Type: text/html' );

            echo "An unexpected error has occurred. Please contact the webmaster.<br />";

            if( eZDebug::isDebugEnabled() )
            {
                echo $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
            }
        }
        else
        {
            $cli = eZCLI::instance();
            $cli->error( "An unexpected error has occurred. Please contact the webmaster.");

            if( eZDebug::isDebugEnabled() )
            {
                $cli->error( $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() );
            }
        }

        eZLog::write( 'Unexpected error, the message was : ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine(), 'error.log' );

        eZExecution::cleanup();
        eZExecution::setCleanExit();
        exit( 1 );
    }
Example #10
0
<?php

$Module =& $Params['Module'];
$order_id = $Params["orderID"];
if (isset($order_id)) {
    eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password ACCEPTED :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
    //create the payment gateway - not the best position but at least it works here :)
    $payment = xrowPaymentObject::createNew((int) $order_id, xrowPayoneCreditCardGateway::GATEWAY_STRING);
    $payment->store();
    //store paymentobject and approve it (required to finish the order)
    $paymentObj = xrowPaymentObject::fetchByOrderID($order_id);
    $paymentObj->approve();
    eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password REDIRECTING to orderview :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
    //redirect into the shopping process => finishing the order!
    $Module->redirectTo('/shop/checkout/');
} else {
    return $Module->handleError(1, 'kernel');
}
$Result = array();
Example #11
0
    /**
     * @return string
     */
    private function setToken()
    {
        $token = array();
        $staticDir = StaticData::directory();
        $outputFile = $staticDir.'/'.$this->tokenFileName;

        if( file_exists( $outputFile ) )
        {
            $token = json_decode( file_get_contents($outputFile), true );
        }
        
        if( !file_exists( $outputFile ) || !isset($token['expiresIn']) || !isset($token['accessToken']) || ($token['expiresIn'] < time()) )
        {
            if( file_exists( $outputFile ) )
            {
                unlink($outputFile);
            }
            $requestData = array(
                "clientId" => $this->clientId,
                "clientSecret" => $this->clientSecret
            );
            
            $query = http_build_query( $requestData );
            $smsApiUrl = "{$this->tokenRequestUrl}?{$query}";
            eZLog::write( "Sending request to: {$smsApiUrl}", 'sms.log' );
            
            $curl = curl_init($this->tokenRequestUrl);                                                                      
            
            curl_setopt_array($curl, array(
                CURLOPT_POST   => true,                                                                   
                CURLOPT_POSTFIELDS => $requestData,                                                                  
                CURLOPT_RETURNTRANSFER => true,
                )
            );
            
            $token = curl_exec( $curl );
            if( $token && isset($token['accessToken']) )
            {
                $logMessage = 'Recieved SMS Service responses: ' . var_export($token, true);
                eZLog::write( $logMessage, 'sms.log' );

                $token = json_decode($token, TRUE);
                $token['expiresIn'] += time() + 300; 
                curl_close( $curl );

                file_put_contents($outputFile, json_encode($token));
                $this->smsToken = $token['accessToken'];
                return true;
            }
            else
            {
                $logMessage = 'Error - Problem with recieved SMS Service responses: ' . var_export($token, true);
                eZLog::write( $logMessage, 'sms.log' );
                return false;
            }
        }
        $this->smsToken = $token['accessToken'];
        return true;
    }
Example #12
0
File: log.php Project: legende91/ez
 public function write($message)
 {
     eZLog::write($message, $this->logFile, $this->logDir);
 }
Example #13
0
 static function rotateLog($fileName)
 {
     $maxLogrotateFiles = eZLog::maxLogrotateFiles();
     if ($maxLogrotateFiles == 0) {
         return;
     }
     for ($i = $maxLogrotateFiles; $i > 0; --$i) {
         $logRotateName = $fileName . '.' . $i;
         if (file_exists($logRotateName)) {
             if ($i == $maxLogrotateFiles) {
                 @unlink($logRotateName);
             } else {
                 $newLogRotateName = $fileName . '.' . ($i + 1);
                 eZFile::rename($logRotateName, $newLogRotateName);
             }
         }
     }
     if (file_exists($fileName)) {
         $newLogRotateName = $fileName . '.' . 1;
         eZFile::rename($fileName, $newLogRotateName);
         return true;
     }
     return false;
 }
Example #14
0
 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;
 }
 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  **/
 public function startCacheGeneration()
 {
     $generatingFilePath = $this->filePath . '.generating';
     $ret = $this->backend->_startCacheGeneration($this->filePath, $generatingFilePath);
     // generation granted
     if ($ret['result'] == 'ok') {
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
    /**
     * Writes a file log (severity below warning)
     * @param  string $message Message to log
     * @param  string $severity Severity of the log message
     */
    protected static function fileLog($message, $severity)
    {
        if (!empty(self::$file))
        {
            $messages = explode("\n", $message);

            foreach ($messages as $index => $m)
            {
                $messages[$index] = 'F : ' . self::$file . ' - P : ' . self::$publisher . " | $m";
            }
        }
        else
            return;

        $index = array_search($severity, self::$severities);

        if ($index >= self::$reportLevel)
        {
            foreach ($messages as $message)
            {
                eZLog::write($message, self::$prefixLog . "$severity.log");
            }
        }
    }
Example #17
0
    /**
     * Will load a cached version of the ini file if it exists,
     * if not it will parse the original file and create the cache file.
     *
     * @access protected
     * @internal Please use {@link eZINI::load()} or {@link eZINI::loadPlacement()}
     * @param bool $reset Reset ini values on instance
     * @param bool $placement Load cache for placment info, not the ini values themself.
     */
    function loadCache( $reset = true, $placement = false )
    {
        eZDebug::accumulatorStart( 'ini', 'Ini load', 'Load cache' );
        if ( $reset )
            $this->reset();
        $cachedDir = self::CONFIG_CACHE_DIR;

        $fileName = $this->cacheFileName( $placement );
        $cachedFile = $cachedDir . $fileName;
        if ( $placement )
        {
            $this->PlacementCacheFile = $cachedFile;
        }
        else
        {
            $this->CacheFile = $cachedFile;
        }

        $data = false;// this will contain cache data if cache data is valid
        if ( file_exists( $cachedFile ) )
        {
            if ( self::isDebugEnabled() )
                eZDebug::writeNotice( "Loading cache '$cachedFile' for file '" . $this->FileName . "'", __METHOD__ );

            include( $cachedFile );

            if ( !isset( $data['rev'] ) || $data['rev'] != eZINI::CONFIG_CACHE_REV )
            {
                if ( self::isDebugEnabled() )
                    eZDebug::writeNotice( "Old structure in cache file used, recreating '$cachedFile' to new structure", __METHOD__ );
                $data = false;
                $this->reset();
            }
            else if ( self::$checkFileMtime === true || self::$checkFileMtime === $this->FileName )
            {
                eZDebug::accumulatorStart( 'ini_check_mtime', 'Ini load', 'Check MTime' );
                $currentTime = time();
                $cacheCreatedTime = strtotime( $data['created'] );
                $iniFile = $data['file'];// used by findInputFiles further down
                $inputFiles = $data['files'];
                foreach ( $inputFiles as $inputFile )
                {
                    $fileTime = file_exists( $inputFile ) ? filemtime( $inputFile ) : false;
                    if ( $fileTime === false )// Refresh cache & input files if file is gone
                    {
                        unset( $inputFiles );
                        $data = false;
                        $this->reset();
                        break;
                    }
                    else if ( $fileTime > $currentTime )
                    {
                        eZDebug::writeError( 'Input file "' . $inputFile . '" has a timestamp higher then current time, ignoring to avoid infinite recursion!', __METHOD__ );
                    }
                    else if ( $fileTime > $cacheCreatedTime )// Refresh cache if file has been changed
                    {
                        $data = false;
                        $this->reset();
                        break;
                    }
                }
                eZDebug::accumulatorStop( 'ini_check_mtime' );
            }
        }

        if ( $data )// if we have cache data on this point, use it
        {
            $this->Charset = $data['charset'];
            $this->ModifiedBlockValues = array();
            if ( $placement )
                $this->BlockValuesPlacement = $data['val'];
            else
                $this->BlockValues = $data['val'];
            unset( $data );
        }
        else
        {
            if ( !isset( $inputFiles ) )// use $inputFiles from cache if defined
            {
                eZDebug::accumulatorStart( 'ini_find_files', 'Ini load', 'Find INI Files' );
                $this->findInputFiles( $inputFiles, $iniFile );
                eZDebug::accumulatorStop( 'ini_find_files' );
                if ( count( $inputFiles ) === 0 )
                {
                    eZDebug::accumulatorStop( 'ini' );
                    return false;
                }
            }

            eZDebug::accumulatorStart( 'ini_files_parse', 'Ini load', 'Parse' );
            $this->parse( $inputFiles, $iniFile, false, $placement );
            eZDebug::accumulatorStop( 'ini_files_parse' );
            eZDebug::accumulatorStart( 'ini_files_save', 'Ini load', 'Save Cache' );
            $cacheSaved = $this->saveCache( $cachedDir, $cachedFile, $placement ? $this->BlockValuesPlacement : $this->BlockValues, $inputFiles, $iniFile );
            eZDebug::accumulatorStop( 'ini_files_save' );

            if ( $cacheSaved )
            {
                // Write log message to storage.log
                eZLog::writeStorageLog( $fileName, $cachedDir );
            }
        }

        eZDebug::accumulatorStop( 'ini' );
    }
Example #18
0
    /**
     * Starts cache generation for the current file.
     *
     * This is done by creating a file named by the original file name, prefixed
     * with '.generating'.
     *
     * @return bool false if the file is being generated, true if it is not
     */
    public function startCacheGeneration()
    {
        $generatingFilePath = $this->filePath . '.generating';
        $ret = self::$dbbackend->_startCacheGeneration( $this->filePath, $generatingFilePath );

        // generation granted
        if ( $ret['result'] == 'ok' )
        {
            eZClusterFileHandler::addGeneratingFile( $this );
            $this->realFilePath = $this->filePath;
            $this->filePath = $generatingFilePath;
            $this->generationStartTimestamp = $ret['mtime'];
            return true;
        }
        // failure: the file is being generated
        elseif ( $ret['result'] == 'ko' )
        {
            return $ret['remaining'];
        }
        // unhandled error case, should not happen
        else
        {
            eZLog::write( "An error occured starting cache generation on '$generatingFilePath'", 'cluster.log' );
            return false;
        }
    }
Example #19
0
$img_name = basename( $img );
$img_extension = strtolower( substr( strrchr( $img_name, "." ), 1 ) );

switch( $file_extension )
{
    case "gif":
        $img_type = "image/gif";
        break;
    case "png":
        $img_type = "image/png";
        break;
    case "jpeg":
    case "jpg":
        $img_type = "image/jpg";
        break;
    default:
        $img_type = "image/jpg";
}

$fp = fopen( $img, 'rb' );

header( 'Content-Type: ' . $img_type );
header( 'Content-Length: ' . filesize( $img ) );

fpassthru( $fp );

if( !file_exists( $img ) )
    eZLog::write( "Image not found: $img", 'warning.log' );

eZExecution::cleanExit();
Example #20
0
 /**
  * Delete files matching regex $fileRegex under directory $dir.
  *
  * \public
  * \static
  * \sa fileDeleteByWildcard()
  */
 function fileDeleteByRegex($dir, $fileRegex)
 {
     eZDebugSetting::writeDebug('kernel-clustering', "fs::fileDeleteByRegex( '{$dir}', '{$fileRegex}' )", __METHOD__);
     eZDebug::accumulatorStart('dbfile', false, 'dbfile');
     if (!file_exists($dir)) {
         //eZDebugSetting::writeDebug( 'kernel-clustering', "Dir '$dir' does not exist", __METHOD__ );
         eZDebug::accumulatorStop('dbfile');
         return;
     }
     $dirHandle = opendir($dir);
     if (!$dirHandle) {
         eZDebug::writeError("opendir( '{$dir}' ) failed.");
         eZDebug::accumulatorStop('dbfile');
         return;
     }
     while (($file = readdir($dirHandle)) !== false) {
         if ($file == '.' or $file == '..') {
             continue;
         }
         if (preg_match("/^{$fileRegex}/", $file)) {
             //eZDebugSetting::writeDebug( 'kernel-clustering', "\$file = eZDir::path( array( '$dir', '$file' ) );", __METHOD__ );
             $file = eZDir::path(array($dir, $file));
             eZDebugSetting::writeDebug('kernel-clustering', "Removing cache file '{$file}'", __METHOD__);
             unlink($file);
             // Write log message to storage.log
             eZLog::writeStorageLog($file);
         }
     }
     closedir($dirHandle);
     eZDebug::accumulatorStop('dbfile');
 }
 function execute($process, $event)
 {
     $http = eZHTTPTool::instance();
     $siteINI = eZINI::instance('site.ini');
     $shopINI = eZINI::instance('shop.ini');
     $payoneINI = eZINI::instance('xrowpayone.ini');
     $processParams = $process->attribute('parameter_list');
     $errors = array();
     $process_id = $process->ID;
     //get the current order
     $order_id = $processParams['order_id'];
     $order = eZOrder::fetch($order_id);
     //checking if its only a redirect and so the preauthorisation is already finished
     $paymentObj = xrowPaymentObject::fetchByOrderID($order_id);
     if (is_object($paymentObj) && $paymentObj->approved()) {
         //now disapprove again because its 3d CC payment and its only paid when capture is successful
         $paymentObj->reject();
         xrowPayoneCreditCardGateway::setPaymentMethod($order);
         eZLog::write("SUCCESS in step 2 ('preauthorisation') ::3D Secure Card detected - FINISHED :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
         return eZWorkflowType::STATUS_ACCEPTED;
     }
     //STEP 2: preauthorisation
     if ($http->hasPostVariable('pseudocardpan')) {
         //fetching settings
         $pseudocardpan = $http->postVariable('pseudocardpan');
         $site_url = $siteINI->variable('SiteSettings', 'SiteURL');
         $aid = $payoneINI->variable('GeneralSettings', 'AID');
         $mid = $payoneINI->variable('GeneralSettings', 'MID');
         $portal_id = $payoneINI->variable('GeneralSettings', 'PortalID');
         $mode = $payoneINI->variable('GeneralSettings', 'Mode');
         $key = $payoneINI->variable('GeneralSettings', 'Key');
         $algorithm = $payoneINI->variable('GeneralSettings', 'Algorithm');
         $api_version = $payoneINI->variable('GeneralSettings', 'APIVersion');
         $response_type = $payoneINI->variable('GeneralSettings', 'ResponseType');
         $cc_3d_secure_enabled = $payoneINI->variable('CC3DSecure', 'Enabled');
         $error_url = $payoneINI->variable('CC3DSecure', 'ErrorURL');
         $success_url = $payoneINI->variable('CC3DSecure', 'SuccessURL');
         $siteaccess = $GLOBALS['eZCurrentAccess'];
         $siteaccess = $siteaccess["name"];
         //prepare some parameter values
         $error_url = "https://" . $site_url . "/" . $siteaccess . "/" . $error_url . "/orderID/" . $order_id;
         $success_url = "https://" . $site_url . "/" . $siteaccess . "/" . $success_url . "/orderID/" . $order_id;
         $order_total_in_cent = (string) $order->totalIncVAT() * 100;
         $currency_code = $order->currencyCode();
         $order_xml = simplexml_load_string($order->DataText1);
         $country_alpha3 = (string) $order_xml->country;
         $country = eZCountryType::fetchCountry($country_alpha3, "Alpha3");
         $country_alpha2 = $country["Alpha2"];
         $last_name = (string) $order_xml->last_name;
         //create hash array
         $hash_array["aid"] = $aid;
         $hash_array["mid"] = $mid;
         $hash_array["portalid"] = $portal_id;
         $hash_array["api_version"] = $api_version;
         $hash_array["mode"] = $mode;
         $hash_array["request"] = "preauthorization";
         $hash_array["responsetype"] = $response_type;
         $hash_array["clearingtype"] = "cc";
         $hash_array["reference"] = $order_id;
         $hash_array["amount"] = $order_total_in_cent;
         $hash_array["currency"] = $currency_code;
         if ($cc_3d_secure_enabled == "true") {
             $hash_array["successurl"] = $success_url;
             $hash_array["errorurl"] = $error_url;
         }
         //please note: country, lastname and pseudocardpan are not needed to be added to the hash because they are not allwoed (p.25 client doc)
         //create param array
         $param_array["aid"] = $aid;
         $param_array["mid"] = $mid;
         $param_array["portalid"] = $portal_id;
         $param_array["api_version"] = $api_version;
         $param_array["mode"] = $mode;
         $param_array["request"] = "preauthorization";
         $param_array["responsetype"] = $response_type;
         $param_array["hash"] = xrowPayoneHelper::generate_hash($algorithm, $hash_array, $key);
         $param_array["clearingtype"] = "cc";
         $param_array["reference"] = $order_id;
         $param_array["amount"] = $order_total_in_cent;
         $param_array["currency"] = $currency_code;
         $param_array["lastname"] = urlencode($last_name);
         $param_array["country"] = $country_alpha2;
         $param_array["pseudocardpan"] = $pseudocardpan;
         if ($cc_3d_secure_enabled == "true") {
             $param_array["successurl"] = $success_url;
             $param_array["errorurl"] = $error_url;
         }
         //sort params in alphabetic order
         ksort($param_array);
         $parameter_string = "?";
         foreach ($param_array as $key => $parameter) {
             $parameter_string .= $key . "=" . $parameter . "&";
         }
         $url = "https://secure.pay1.de/client-api" . $parameter_string;
         if ($siteINI->hasVariable('ProxySettings', 'ProxyServer') && $siteINI->variable('ProxySettings', 'ProxyServer') != "") {
             $proxyserver = $siteINI->variable('ProxySettings', 'ProxyServer');
             //now get the proxy url
             if (strpos($proxyserver, "://") !== false) {
                 $proxy_parts = explode("://", $proxyserver);
                 $proxyserver = $proxy_parts[1];
             }
             $context_array = array('http' => array('method' => 'GET', 'proxy' => $proxyserver));
             $context = stream_context_create($context_array);
             $json_response = file_get_contents($url, false, $context);
         } else {
             $json_response = file_get_contents($url);
         }
         if ($json_response) {
             $json_response = json_decode($json_response);
             if ($json_response->status != "ERROR" and isset($json_response->txid)) {
                 //get 'txid' from response and keep it
                 $txid = $json_response->txid;
                 //get 'userid' from response and keep it
                 $userid = $json_response->userid;
                 //now store it into the order
                 $db = eZDB::instance();
                 $db->begin();
                 $doc = new DOMDocument('1.0', 'utf-8');
                 $doc->loadXML($order->DataText1);
                 $shop_account_element = $doc->getElementsByTagName('shop_account');
                 $shop_account_element = $shop_account_element->item(0);
                 //handle and store the TXID
                 //remove first if exists
                 $txid_elements = $doc->getElementsByTagName('txid');
                 if ($txid_elements->length >= 1) {
                     $txid_element = $txid_elements->item(0);
                     $txid_element->parentNode->removeChild($txid_element);
                 }
                 //then create
                 $txidNode = $doc->createElement("txid", $txid);
                 $shop_account_element->appendChild($txidNode);
                 //handle and store the userid
                 //remove first if exists
                 $userid_elements = $doc->getElementsByTagName('userid');
                 if ($userid_elements->length >= 1) {
                     $userid_element = $userid_elements->item(0);
                     $userid_element->parentNode->removeChild($userid_element);
                 }
                 //then create
                 $useridNode = $doc->createElement("userid", $userid);
                 $shop_account_element->appendChild($useridNode);
                 //handle and store the pseudocardpan
                 if ($http->hasPostVariable('truncatedcardpan')) {
                     //remove first if exists
                     $tpan_elements = $doc->getElementsByTagName('truncatedcardpan');
                     if ($tpan_elements->length >= 1) {
                         $tpan_element = $tpan_elements->item(0);
                         $tpan_element->parentNode->removeChild($tpan_element);
                     }
                     //then create
                     $truncatedcardpan_node = $doc->createElement("truncatedcardpan", $http->postVariable('truncatedcardpan'));
                     $shop_account_element->appendChild($truncatedcardpan_node);
                 }
                 if ($json_response->status === "REDIRECT") {
                     //remove first if exists
                     $cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved');
                     if ($cc3d_sec_elements->length >= 1) {
                         $cc3d_sec_element = $cc3d_sec_elements->item(0);
                         $cc3d_sec_element->parentNode->removeChild($cc3d_sec_element);
                     }
                     //save reserved flag false for now
                     $reservedFlag = $doc->createElement("cc3d_reserved", "false");
                     $shop_account_element->appendChild($reservedFlag);
                 } else {
                     //remove cc3d_reserved if exists. this case could occure if someone changed from 3d CC to normal CC.
                     $cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved');
                     if ($cc3d_sec_elements->length >= 1) {
                         $cc3d_sec_element = $cc3d_sec_elements->item(0);
                         $cc3d_sec_element->parentNode->removeChild($cc3d_sec_element);
                     }
                 }
                 //i must store here redundant otherwise the order will not be stored since its stuck in a transaction
                 $db->commit();
                 //store it
                 $order->setAttribute('data_text_1', $doc->saveXML());
                 $order->store();
                 $db->commit();
                 if ($json_response->status === "REDIRECT") {
                     eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card detected - REDIRECTING to creditcard institute check :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
                     //do redirect to 3d secure password confirm page
                     http_redirect($json_response->redirecturl);
                     exit;
                 } else {
                     xrowPayoneCreditCardGateway::setPaymentMethod($order);
                     eZLog::write("SUCCESS in step 2 ('preauthorisation') for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
                     return eZWorkflowType::STATUS_ACCEPTED;
                 }
             } else {
                 eZLog::write("FAILED in step 2 ('preauthorisation') for order ID " . $order_id . " with ERRORCODE " . $json_response->errorcode . " Message: " . $json_response->errormessage, $logName = 'xrowpayone.log', $dir = 'var/log');
                 if ($payoneINI->variable('GeneralSettings', 'CustomErrorNode') === "disabled") {
                     //use default error of payone
                     $errors = array($json_response->customermessage);
                 } else {
                     //use customized errors
                     $response["errorcode"] = $json_response->errorcode;
                     $response["errormessage"] = $json_response->errormessage;
                     $errors = array(xrowPayoneHelper::generateCustomErrorString($order, $response));
                 }
             }
         } else {
             eZLog::write("ERROR: Remote content not found in file " . __FILE__ . " on line " . __LINE__, $logName = 'xrowpayone.log', $dir = 'var/log');
         }
     } else {
         if (is_object($paymentObj)) {
             //that means, that we have a paymentobject which is not approved. its not approved because the payment has failed so we return a array
             $errors = array(ezpI18n::tr('extension/xrowpayone', 'Error occured during payment process. Please choose your payment option again.'));
             $paymentObj->remove();
         }
     }
     $process->Template = array();
     $process->Template['templateName'] = xrowPayoneCreditCardGateway::TEMPLATE;
     $process->Template['path'] = array(array('url' => false, 'text' => ezpI18n::tr('extension/xrowpayone', 'Payment Information')));
     $process->Template['templateVars'] = array('errors' => $errors, 'order' => $order, 'event' => $event);
     // return eZWorkflowType::STATUS_REJECTED;
     return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
 }
 public function monitor($text)
 {
     if ($this->opt == true) {
         eZLog::write("mem [{$text}]: " . memory_get_usage(), self::LOG_FILE);
     }
 }
 /**
  * Starts cache generation for the current file.
  *
  * This is done by creating a file named by the original file name, prefixed
  * with '.generating'.
  *
  * @return bool false if the file is being generated, true if it is not
  */
 public function startCacheGeneration()
 {
     eZDebugSetting::writeDebug('kernel-clustering', "Starting cache generation", "dfs::startCacheGeneration( '{$this->filePath}' )");
     $generatingFilePath = $this->filePath . '.generating';
     try {
         $ret = self::$dbbackend->_startCacheGeneration($this->filePath, $generatingFilePath);
     } catch (RuntimeException $e) {
         eZDebug::writeError($e->getMessage());
         return false;
     }
     // generation granted
     if ($ret['result'] == 'ok') {
         eZClusterFileHandler::addGeneratingFile($this);
         $this->realFilePath = $this->filePath;
         $this->filePath = $generatingFilePath;
         $this->generationStartTimestamp = $ret['mtime'];
         return true;
     } elseif ($ret['result'] == 'ko') {
         return $ret['remaining'];
     } else {
         eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
         return false;
     }
 }
<?php
if ( MMUsers::getCurrentUserObject() )
{
    $service = ESBFactory::getUserService();
        $user = $service->form();
        if ( $user && $user['data']['errorCode'] == 0 && !is_null($user['data']['profile']['userId']) ){
            
            $dt = new DateTime("Europe/Warsaw");
            $url = isset($_POST['url']) ? $_POST['url'] : '';
            $logMsg = array(
                'uuid'      => $user['data']['profile']['userId'],
                'time'      => $dt->format('Y-m-d H:i:s'),
                'siteurl'   => $url,
            );
            eZLog::write(json_encode($logMsg), 'gtm.log');
        }
}
?>
 /**
  * Log memory usage.
  *
  * @param string $text Text to use while logging.
  */
 private function monitor($text)
 {
     if ($this->memoryMonitoring) {
         eZLog::write("mem [{$text}]: " . memory_get_usage(), $this->logFile);
     }
 }
Example #26
0
 function store($atomic = false)
 {
     if ($this->open($atomic)) {
         $this->write("<?php\n");
         $this->writeElements();
         $this->write("?>\n");
         $this->writeChunks();
         $this->flushChunks();
         $this->close();
         if (!$this->ClusteringEnabled) {
             $perm = octdec(eZINI::instance()->variable('FileSettings', 'StorageFilePermissions'));
             chmod(eZDir::path(array($this->PHPDir, $this->PHPFile)), $perm);
         }
         // Write log message to storage.log
         eZLog::writeStorageLog($this->PHPFile, $this->PHPDir . '/');
         return true;
     } else {
         eZDebug::writeError("Failed to open file '" . $this->PHPDir . '/' . $this->PHPFile . "'", 'eZPHPCreator::store');
         return false;
     }
 }
 public function __construct($userID)
 {
     eZLog::write(__METHOD__ . " : Provided user #{$userID} was not found and could not be logged in", 'error.log');
     parent::__construct('Provided user was not found');
 }
 /**
  *	@desc		Add the new translation found in the existing file of translation
  *	@author 	David LE RICHE <*****@*****.**>
  *	@params		string	$file => the file where the translation is adding
  *	@return		bool
  *	@copyright	2012
  *	@version 	1.1
  */
 public function addTranslationIfNotExist($file)
 {
     $tsFile = new DOMDocument();
     $tsFile->load($file);
     $xpath = new DOMXpath($tsFile);
     $ts = $tsFile->documentElement;
     foreach ($this->tabKey as $sourceName => $tabElement) {
         foreach ($tabElement as $element) {
             $query = "//context[name=" . (strpos($sourceName, "'") === false ? "'{$sourceName}'" : "\"{$sourceName}\"") . "]/message[source=" . (strpos($element, "'") === false ? "'{$element}'" : "\"{$element}\"") . "]";
             try {
                 if ($xpath->query($query) && !$xpath->query($query)->item(0)) {
                     $querySourceName = "//context[name=" . (strpos($sourceName, "'") === false ? "'{$sourceName}'" : "\"{$sourceName}\"") . "]";
                     //create context if not exists
                     if (!$xpath->query($querySourceName)->item(0)) {
                         $context = $tsFile->createElement('context');
                         $ts->appendChild($context);
                         $name = $tsFile->createELement('name', $sourceName);
                         $context->appendChild($name);
                     } else {
                         $context = $xpath->query($querySourceName)->item(0);
                     }
                     $message = $tsFile->createElement('message');
                     $context->appendChild($message);
                     $source = $tsFile->createElement('source', htmlspecialchars($element));
                     $message->appendChild($source);
                     $translation = $tsFile->createElement('translation');
                     $message->appendChild($translation);
                 }
             } catch (Exception $e) {
                 eZLog::write($e, 'owtranslate.log');
             }
         }
     }
     try {
         if ($unlinkFile = unlink($file)) {
             $saveXml = $tsFile->save($file, LIBXML_NOEMPTYTAG);
         }
     } catch (exception $e) {
         echo $e;
     }
     return $saveXml;
 }
 * @subpackage content
 */
/**
 * This script, given a queued contentobject_id + version, will resume the publishing operation on it
 * @package kernel
 * @subpackage content
 */
require 'autoload.php';
$pid = getmypid();
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => 'Asynchronous publishing handler, not meant to be used directly', 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$argumentConfig = '[OBJECT_ID] [VERSION_ID]';
$optionsConfig = '';
$options = $script->getOptions($optionsConfig, $argumentConfig);
$script->initialize();
if (count($options['arguments']) != 2) {
    eZLog::write("Wrong arguments count", 'publishqueue.log');
    $script->shutdown(1, 'wrong argument count');
}
$objectId = $options['arguments'][0];
$version = $options['arguments'][1];
eZLog::write("[{$pid}] Publishing #{$objectId}/{$version}", 'async.log');
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $objectId, 'version' => $version));
if (isset($operationResult['status']) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
    eZLog::write("[{$pid}] Published #{$objectId}/{$version}", 'async.log');
    $script->shutdown(0);
} else {
    eZLog::write("[{$pid}] Operation result for #{$objectId}/{$version}: " . print_r($operationResult, true), 'async.log');
    $script->shutdown(2, 'Publishing did not complete');
}
Example #30
0
 /**
  * Checks if the .generating file was changed, which would mean that generation
  * timed out. If not timed out, refreshes the timestamp so that storage won't
  * be stolen
  */
 public function checkCacheGenerationTimeout()
 {
     clearstatcache();
     // file_exists = false: another process stole the lock and finished the generation
     // filemtime != stored one: another process is generating the file
     if ( !file_exists( $this->filePath ) or ( @filemtime( $this->filePath ) != $this->generationStartTimestamp ) )
     {
         eZDebugSetting::writeDebug( 'kernel-clustering', "'$this->filePath' was changed during generation, looks like a generation timeout", __METHOD__ );
         eZLog::write( "Generation of '$this->filePath' timed out", 'cluster.log' );
         return false;
     }
     else
     {
         $mtime = time();
         touch( $this->filePath, $mtime, $mtime );
         return true;
     }
 }