function parseFile($fileName)
 {
     eZPerfLogger::accumulatorStart('binaryfile_metadataextractions');
     $result = parent::parseFile($fileName);
     eZPerfLogger::accumulatorStop('binaryfile_metadataextractions');
     return $result;
 }
 function sendMail(eZMail $mail)
 {
     $ini = eZINI::instance();
     $parameters = array();
     $parameters['host'] = $ini->variable('MailSettings', 'TransportServer');
     $parameters['helo'] = $ini->variable('MailSettings', 'SenderHost');
     $parameters['port'] = $ini->variable('MailSettings', 'TransportPort');
     $parameters['connectionType'] = $ini->variable('MailSettings', 'TransportConnectionType');
     $user = $ini->variable('MailSettings', 'TransportUser');
     $password = $ini->variable('MailSettings', 'TransportPassword');
     if ($user and $password) {
         $parameters['auth'] = true;
         $parameters['user'] = $user;
         $parameters['pass'] = $password;
     }
     /* If email sender hasn't been specified or is empty
      * we substitute it with either MailSettings.EmailSender or AdminEmail.
      */
     if (!$mail->senderText()) {
         $emailSender = $ini->variable('MailSettings', 'EmailSender');
         if (!$emailSender) {
             $emailSender = $ini->variable('MailSettings', 'AdminEmail');
         }
         eZMail::extractEmail($emailSender, $emailSenderAddress, $emailSenderName);
         if (!eZMail::validate($emailSenderAddress)) {
             $emailSender = false;
         }
         if ($emailSender) {
             $mail->setSenderText($emailSender);
         }
     }
     $excludeHeaders = $ini->variable('MailSettings', 'ExcludeHeaders');
     if (count($excludeHeaders) > 0) {
         $mail->Mail->appendExcludeHeaders($excludeHeaders);
     }
     $options = new ezcMailSmtpTransportOptions();
     if ($parameters['connectionType']) {
         $options->connectionType = $parameters['connectionType'];
     }
     $smtp = new ezcMailSmtpTransport($parameters['host'], $user, $password, $parameters['port'], $options);
     // If in debug mode, send to debug email address and nothing else
     if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') {
         $mail->Mail->to = array(new ezcMailAddress($ini->variable('MailSettings', 'DebugReceiverEmail')));
         $mail->Mail->cc = array();
         $mail->Mail->bcc = array();
     }
     // send() from ezcMailSmtpTransport doesn't return anything (it uses exceptions in case
     // something goes bad)
     try {
         eZPerfLogger::accumulatorStart('mail_sent');
         $smtp->send($mail->Mail);
         eZPerfLogger::accumulatorStop('mail_sent');
     } catch (ezcMailException $e) {
         eZPerfLogger::accumulatorStop('mail_send');
         eZDebug::writeError($e->getMessage(), __METHOD__);
         return false;
     }
     // return true in case of no exceptions
     return true;
 }
 function arrayQuery($sql, $params = array(), $server = false)
 {
     $retArray = array();
     if ($this->IsConnected) {
         $limit = false;
         $offset = 0;
         $column = false;
         // check for array parameters
         if (is_array($params)) {
             if (isset($params["limit"]) and is_numeric($params["limit"])) {
                 $limit = $params["limit"];
             }
             if (isset($params["offset"]) and is_numeric($params["offset"])) {
                 $offset = $params["offset"];
             }
             if (isset($params["column"]) and (is_numeric($params["column"]) or is_string($params["column"]))) {
                 $column = $params["column"];
             }
         }
         if ($limit !== false and is_numeric($limit)) {
             $sql .= "\nLIMIT {$offset}, {$limit} ";
         } else {
             if ($offset !== false and is_numeric($offset) and $offset > 0) {
                 $sql .= "\nLIMIT {$offset}, 18446744073709551615";
                 // 2^64-1
             }
         }
         $result = $this->query($sql, $server);
         if ($result == false) {
             $this->reportQuery(__CLASS__, $sql, false, false);
             return false;
         }
         eZPerfLogger::accumulatorStart('mysqli_loop', 'mysqli_total', 'Looping result');
         $numRows = mysqli_num_rows($result);
         if ($numRows > 0) {
             if (!is_string($column)) {
                 //eZPerfLogger::accumulatorStart( 'mysqli_loop', 'mysqli_total', 'Looping result' );
                 for ($i = 0; $i < $numRows; $i++) {
                     if ($this->InputTextCodec) {
                         $tmpRow = mysqli_fetch_array($result, MYSQLI_ASSOC);
                         $convRow = array();
                         foreach ($tmpRow as $key => $row) {
                             eZPerfLogger::accumulatorStart('mysqli_conversion', 'mysqli_total', 'String conversion in mysqli');
                             $convRow[$key] = $this->OutputTextCodec->convertString($row);
                             eZPerfLogger::accumulatorStop('mysqli_conversion');
                         }
                         $retArray[$i + $offset] = $convRow;
                     } else {
                         $retArray[$i + $offset] = mysqli_fetch_array($result, MYSQLI_ASSOC);
                     }
                 }
                 eZPerfLogger::accumulatorStop('mysqli_loop');
             } else {
                 //eZPerfLogger::accumulatorStart( 'mysqli_loop', 'mysqli_total', 'Looping result' );
                 for ($i = 0; $i < $numRows; $i++) {
                     $tmp_row = mysqli_fetch_array($result, MYSQLI_ASSOC);
                     if ($this->InputTextCodec) {
                         eZPerfLogger::accumulatorStart('mysqli_conversion', 'mysqli_total', 'String conversion in mysqli');
                         $retArray[$i + $offset] = $this->OutputTextCodec->convertString($tmp_row[$column]);
                         eZPerfLogger::accumulatorStop('mysqli_conversion');
                     } else {
                         $retArray[$i + $offset] =& $tmp_row[$column];
                     }
                 }
                 eZPerfLogger::accumulatorStop('mysqli_loop');
             }
         } else {
             eZPerfLogger::accumulatorStop('mysqli_loop');
         }
     }
     return $retArray;
 }
 /**
  * Same code as parent, with one extra eZPerfLogger::accumulatorStart/Stop call
  */
 function processCache($retrieveCallback, $generateCallback = null, $ttl = null, $expiry = null, $extraData = null)
 {
     $forceDB = false;
     $curtime = time();
     $tries = 0;
     $noCache = false;
     if ($expiry < 0) {
         $expiry = null;
     }
     if ($ttl < 0) {
         $ttl = null;
     }
     // Main loop
     while (true) {
         // Start read checks
         // Note: The while loop is used to make it easier to break out of the "read" code
         while (true) {
             // No retrieve method so go directly to generate+store
             if ($retrieveCallback === null || !$this->filePath) {
                 break;
             }
             if (!self::LOCAL_CACHE) {
                 $forceDB = true;
             } else {
                 if ($this->isLocalFileExpired($expiry, $curtime, $ttl)) {
                     // if we are in stale cache mode, we only forceDB if the
                     // file does not exist at all
                     if ($this->useStaleCache) {
                         if (!file_exists($this->filePath)) {
                             eZDebugSetting::writeDebug('kernel-clustering', "Local file '{$this->filePath}' does not exist and can not be used for stale cache. Checking with DB", __METHOD__);
                             $forceDB = true;
                             // forceDB + useStaleCache means that we should check for the DB file.
                         }
                     } else {
                         // Local file is older than global timestamp, check with DB
                         eZDebugSetting::writeDebug('kernel-clustering', "Local file (mtime=" . @filemtime($this->filePath) . ") is older than timestamp ({$expiry}) and ttl({$ttl}), check with DB", __METHOD__);
                         $forceDB = true;
                     }
                 }
             }
             if (!$forceDB) {
                 // check if DB file is deleted
                 if (!$this->useStaleCache && ($this->metaData === false || $this->metaData['mtime'] < 0)) {
                     if ($generateCallback !== false) {
                         eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, need to regenerate data", __METHOD__);
                     } else {
                         eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, cannot get data", __METHOD__);
                     }
                     break;
                 }
                 // check if FS file is older than DB file
                 if (!$this->useStaleCache && $this->isLocalFileExpired($this->metaData['mtime'], $curtime, $ttl)) {
                     eZDebugSetting::writeDebug('kernel-clustering', "Local file (mtime=" . @filemtime($this->filePath) . ") is older than DB, checking with DB", __METHOD__);
                     $forceDB = true;
                 } else {
                     if ($this->useStaleCache) {
                         // to get the retrieve callback to accept the cache file,
                         // we force its mtime to the current time
                         $mtime = $curtime;
                         eZDebugSetting::writeDebug('kernel-clustering', "Processing local stale cache file {$this->filePath}", __METHOD__);
                     } else {
                         $mtime = filemtime($this->filePath);
                         eZDebugSetting::writeDebug('kernel-clustering', "Processing local cache file {$this->filePath}", __METHOD__);
                     }
                     $args = array($this->filePath, $mtime);
                     if ($extraData !== null) {
                         $args[] = $extraData;
                     }
                     $retval = call_user_func_array($retrieveCallback, $args);
                     if ($retval instanceof eZClusterFileFailure) {
                         break;
                     }
                     return $retval;
                 }
             }
             if ($forceDB) {
                 // stale cache, and no DB or FS file available
                 if ($this->useStaleCache && $this->metaData === false) {
                     // configuration says we have to generate our own version
                     if ($this->nonExistantStaleCacheHandling[$this->cacheType] == 'generate') {
                         // no cache available, but a generate callback exists, skip to generation
                         if ($generateCallback !== false) {
                             eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, need to regenerate data");
                             break;
                         } else {
                             eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, cannot get data");
                             break 2;
                         }
                     } else {
                         eZPerfLogger::accumulatorStart('mysql_cluster_cache_waits', 'MySQL Cluster', 'Cache waits');
                         while ($this->remainingCacheGenerationTime-- >= 0) {
                             // we don't know if the file gets generated on the current
                             // frontend or not. However, we can still try the FS cache
                             // first, then the DB cache if FS is not found, since this
                             // will be much more efficient
                             if (!file_exists($this->filePath)) {
                                 $this->loadMetaData(true);
                                 if ($this->metaData === false) {
                                     sleep(1);
                                     continue;
                                 } else {
                                     break;
                                 }
                             } else {
                                 break;
                             }
                         }
                         eZPerfLogger::accumulatorStop('mysql_cluster_cache_waits');
                         // if we reached this point, it means that we are over the estimated timeout value
                         // we try to take the generation over by starting the cache generation. IF this
                         // fails again, it is probably because another waiting process has taken the generation
                         // over. Maybe add a counter here to prevent some kind of death loop ?
                         eZDebugSetting::writeDebug('kernel-clustering', "Checking if {$this->filePath} was generating during the wait loop", __METHOD__);
                         $this->loadMetaData(true);
                         $this->useStaleCache = false;
                         $this->remainingCacheGenerationTime = false;
                         $forceDB = false;
                         // this continues to the main loop 'while (true)'
                         continue 2;
                     }
                 } elseif (!$this->useStaleCache && ($this->metaData === false || $this->isDBFileExpired($expiry, $curtime, $ttl))) {
                     // no cache available, but a generate callback exists, skip to generation
                     if ($generateCallback !== false) {
                         eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, need to regenerate data", __METHOD__);
                         // we break out of one loop so that the generateCallback is called
                         break;
                     } else {
                         eZDebugSetting::writeDebug('kernel-clustering', "Database file is deleted, cannot get data", __METHOD__);
                         // we break out of two loops so that we directly exit the method and have
                         // the rest of execution generate the data
                         break 2;
                     }
                 } else {
                     eZDebugSetting::writeDebug('kernel-clustering', "Callback from DB file {$this->filePath}", __METHOD__);
                     if (self::LOCAL_CACHE) {
                         $this->fetch();
                         // Figure out which mtime to use for new file, must be larger than
                         // mtime in DB at least.
                         $mtime = $this->metaData['mtime'] + 1;
                         $localmtime = @filemtime($this->filePath);
                         $mtime = max($mtime, $localmtime);
                         touch($this->filePath, $mtime, $mtime);
                         clearstatcache();
                         // Needed because of touch() call
                         $args = array($this->filePath, $mtime);
                         if ($extraData !== null) {
                             $args[] = $extraData;
                         }
                         $retval = call_user_func_array($retrieveCallback, $args);
                         if ($retval instanceof eZClusterFileFailure) {
                             break;
                         }
                         return $retval;
                     } else {
                         $uniquePath = $this->fetchUnique();
                         $args = array($uniquePath, $this->metaData['mtime']);
                         if ($extraData !== null) {
                             $args[] = $extraData;
                         }
                         $retval = call_user_func_array($retrieveCallback, $args);
                         $this->fileDeleteLocal($uniquePath);
                         if ($retval instanceof eZClusterFileFailure) {
                             break;
                         }
                         return $retval;
                     }
                 }
                 eZDebugSetting::writeDebug('kernel-clustering', "Database file does not exist, need to regenerate data", __METHOD__);
                 break;
             }
         }
         if ($tries >= 2) {
             eZDebugSetting::writeDebug('kernel-clustering', "Reading was retried {$tries} times and reached the maximum, returning null", __METHOD__);
             return null;
         }
         // Generation part starts here
         if (isset($retval) && $retval instanceof eZClusterFileFailure) {
             // This error means that the retrieve callback told
             // us NOT to enter generation mode and therefore NOT to store this
             // cache.
             // This parameter will then be passed to the generate callback,
             // and this will set store to false
             if ($retval->errno() == 3) {
                 $noCache = true;
             } elseif ($retval->errno() != 1) {
                 eZDebug::writeError("Failed to retrieve data from callback", __METHOD__);
                 return null;
             }
             $message = $retval->message();
             if (strlen($message) > 0) {
                 eZDebugSetting::writeDebug('kernel-clustering', $retval->message(), __METHOD__);
             }
             // the retrieved data was expired so we need to generate it, let's continue
         }
         // We need to lock if we have a generate-callback or
         // the generation is deferred to the caller.
         // Note: false means no generation, while null means that generation
         // is deferred to the processing that follows (f.i. cache-blocks)
         if ($generateCallback !== false && $this->filePath) {
             if (!$this->useStaleCache && !$noCache) {
                 $res = $this->startCacheGeneration();
                 if ($res !== true) {
                     eZDebugSetting::writeDebug('kernel-clustering', "{$this->filePath} is being generated, switching to staleCache mode", __METHOD__);
                     $this->useStaleCache = true;
                     $this->remainingCacheGenerationTime = $res;
                     $forceDB = false;
                     continue;
                 }
             }
             // File in DB is outdated or non-existing, call write-callback to generate content
             if ($generateCallback) {
                 $args = array($this->filePath);
                 if ($noCache) {
                     $extraData['noCache'] = $noCache;
                 }
                 if ($extraData !== null) {
                     $args[] = $extraData;
                 }
                 $fileData = call_user_func_array($generateCallback, $args);
                 return $this->storeCache($fileData);
             }
         }
         break;
     }
     // End main loop
     return new eZClusterFileFailure(2, "Manual generation of file data is required, calling storeCache is required");
 }
Ejemplo n.º 5
0
 /**
  * Performs mysql query and returns mysql result.
  * Times the sql execution, adds accumulator timings and reports SQL to
  * debug.
  * @param string $fname The function name that started the query, should
  *                      contain relevant arguments in the text.
  */
 protected function _query($query, $fname = false, $reportError = true)
 {
     eZPerfLogger::accumulatorStart('mysql_cluster_query', 'MySQL Cluster', 'DB queries');
     $time = microtime(true);
     $res = mysqli_query($this->db, $query);
     if (!$res && $reportError) {
         $this->_error($query, $fname);
     }
     $numRows = mysqli_affected_rows($this->db);
     $time = microtime(true) - $time;
     eZPerfLogger::accumulatorStop('mysql_cluster_query');
     $this->_report($query, $fname, $time, $numRows);
     return $res;
 }
Ejemplo n.º 6
0
 /**
  * Overrides methods from parent to always trace data even when debug is off
  */
 protected function accumulatorStop()
 {
     eZPerfLogger::accumulatorStop('mysql_cluster_dfs_operations');
 }
Ejemplo n.º 7
0
 /**
  * Performs mysql query and returns mysql result.
  * Times the sql execution, adds accumulator timings and reports SQL to
  * debug.
  * @param string $fname The function name that started the query, should
  *                      contain relevant arguments in the text.
  **/
 protected function _query($query, $fname = false, $reportError = true, $bindparams = array(), $return_type = self::RETURN_BOOL)
 {
     eZPerfLogger::accumulatorStart('oracle_cluster_query', 'oracle_cluster_total', 'Oracle_cluster_queries');
     $time = microtime(true);
     $this->error = null;
     $res = false;
     if ($statement = oci_parse($this->db, $query)) {
         foreach ($bindparams as $name => $val) {
             if (!oci_bind_by_name($statement, $name, $bindparams[$name], -1)) {
                 $this->error = oci_error($statement);
                 $this->_error($query, $fname, $error);
             }
         }
         if (!($res = oci_execute($statement, OCI_DEFAULT))) {
             $this->error = oci_error($statement);
         } else {
             if ($return_type == self::RETURN_COUNT) {
                 $res = oci_num_rows($statement);
             } else {
                 if ($return_type == self::RETURN_DATA) {
                     oci_fetch_all($statement, $res, 0, 0, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
                 } else {
                     if ($return_type == self::RETURN_DATA_BY_COL) {
                         oci_fetch_all($statement, $res, 0, 0, OCI_FETCHSTATEMENT_BY_COLUMN + OCI_ASSOC);
                     }
                 }
             }
         }
         oci_free_statement($statement);
     } else {
         $this->error = oci_error($this->db);
     }
     // take care: 0 might be a valid result if RETURN_COUNT is used
     if ($res === false && $reportError) {
         $this->_error($query, $fname, false, $statement);
     }
     //$numRows = mysql_affected_rows( $this->db );
     $time = microtime(true) - $time;
     eZPerfLogger::accumulatorStop('oracle_cluster_query');
     $this->_report($query, $fname, $time, 0);
     return $res;
 }
 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));
         eZPerfLogger::accumulatorStart('mail_sent');
         $returnedValue = mail($receiverEmailText, $mail->subject(), $message, $extraHeaders, $sendmailOptions);
         eZPerfLogger::accumulatorStop('mail_sent');
         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;
 }
 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['url']);
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     eZPerfLogger::accumulatorStart('imagemagick_image_conversion', 'Image conversion');
     system($systemString, $returnCode);
     eZPerfLogger::accumulatorStop('imagemagick_image_conversion');
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     // Issue EZP-21357:
     // ImageMagick has it's own meta-characters support, hence:
     //     $ convert 'File*.jpg'' ...
     // Still expand File*.jpg as the shell would do, however, this is only true for the file's basename part and not
     // for the whole path.
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['dirpath'] . DIRECTORY_SEPARATOR . addcslashes($sourceMimeData['filename'], '~*?[]{}<>'));
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     eZPerfLogger::accumulatorStart('imagemagick_image_conversion', 'Image conversion');
     system($systemString, $returnCode);
     eZPerfLogger::accumulatorStop('imagemagick_image_conversion');
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
 function arrayQuery($sql, $params = false, $server = false)
 {
     $resultArray = array();
     if (!$this->isConnected()) {
         return $resultArray;
     }
     $limit = -1;
     $offset = 0;
     $column = false;
     // check for array parameters
     if (is_array($params)) {
         if (isset($params["limit"]) and is_numeric($params["limit"])) {
             $limit = $params["limit"];
         }
         if (isset($params["offset"]) and is_numeric($params["offset"])) {
             $offset = $params["offset"];
         }
         if (isset($params["column"]) and (is_numeric($params["column"]) or is_string($params["column"]))) {
             $column = strtoupper($params["column"]);
         }
     }
     eZPerfLogger::accumulatorStart('oracle_query', 'oracle_total', 'Oracle_queries');
     //        if ( $this->OutputSQL )
     //            $this->startTimer();
     // The converted sql should not be output
     if ($this->InputTextCodec) {
         eZPerfLogger::accumulatorStart('oracle_conversion', 'oracle_total', 'String conversion in oracle');
         $sql = $this->InputTextCodec->convertString($sql);
         eZPerfLogger::accumulatorStop('oracle_conversion');
     }
     $analysisText = $this->analyseQuery($sql, $server);
     if ($this->OutputSQL) {
         $this->startTimer();
     }
     $statement = oci_parse($this->DBConnection, $sql);
     //flush();
     if (!@oci_execute($statement, $this->Mode)) {
         eZPerfLogger::accumulatorStop('oracle_query');
         $error = oci_error($statement);
         $hasError = true;
         if (!$error['code']) {
             $hasError = false;
         }
         if ($hasError) {
             $result = false;
             $this->ErrorMessage = $error['message'];
             $this->ErrorNumber = $error['code'];
             if (isset($error['sqltext'])) {
                 $sql = $error['sqltext'];
             }
             $offset = false;
             if (isset($error['offset'])) {
                 $offset = $error['offset'];
             }
             $offsetText = '';
             if ($offset !== false) {
                 $offsetText = ' at offset ' . $offset;
                 $sqlOffsetText = "\n\nStart of error:\n" . substr($sql, $offset);
             }
             eZDebug::writeError("Error (" . $error['code'] . "): " . $error['message'] . "\n" . "Failed query{$offsetText}:\n" . $sql . $sqlOffsetText, "eZOracleDB");
             oci_free_statement($statement);
             eZPerfLogger::accumulatorStop('oracle_query');
             return $result;
         }
     }
     eZPerfLogger::accumulatorStop('oracle_query');
     if ($this->OutputSQL) {
         $this->endTimer();
         if ($this->timeTaken() > $this->SlowSQLTimeout) {
             // If we have some analysis text we append this to the SQL output
             if ($analysisText !== false) {
                 $sql = "EXPLAIN\n" . $sql . "\n\nANALYSIS:\n" . $analysisText;
             }
             $this->reportQuery('eZOracleDB', $sql, false, $this->timeTaken());
         }
     }
     //$numCols = oci_num_fields( $statement );
     $results = array();
     eZPerfLogger::accumulatorStart('oracle_loop', 'oracle_total', 'Oracle looping results');
     if ($column !== false) {
         if (is_numeric($column)) {
             $rowCount = oci_fetch_all($statement, $results, $offset, $limit, OCI_FETCHSTATEMENT_BY_COLUMN + OCI_NUM);
         } else {
             $rowCount = oci_fetch_all($statement, $results, $offset, $limit, OCI_FETCHSTATEMENT_BY_COLUMN + OCI_ASSOC);
         }
         // optimize to our best the special case: 1 row
         if ($rowCount == 1) {
             $resultArray[$offset] = $this->OutputTextCodec ? $this->OutputTextCodec->convertString($results[$column][0]) : $results[$column][0];
         } else {
             if ($rowCount > 0) {
                 $results = $results[$column];
                 if ($this->OutputTextCodec) {
                     array_walk($results, array('eZOracleDB', 'arrayConvertStrings'), $this->OutputTextCodec);
                 }
                 $resultArray = $offset == 0 ? $results : array_combine(range($offset, $offset + $rowCount - 1), $results);
             }
         }
     } else {
         $rowCount = oci_fetch_all($statement, $results, $offset, $limit, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
         // optimize to our best the special case: 1 row
         if ($rowCount == 1) {
             if ($this->OutputTextCodec) {
                 array_walk($results[0], array('eZOracleDB', 'arrayConvertStrings'), $this->OutputTextCodec);
             }
             $resultArray[$offset] = array_change_key_case($results[0]);
         } else {
             if ($rowCount > 0) {
                 $keys = array_keys(array_change_key_case($results[0]));
                 // this would be slightly faster, but we have to work around a php bug
                 // with recursive array_walk present in 5.1 (eg. on red hat 5.2)
                 //array_walk( $results, array( 'eZOracleDB', 'arrayChangeKeys' ), array( $this->OutputTextCodec, $keys ) );
                 $arr = array($this->OutputTextCodec, $keys);
                 foreach ($results as $key => &$val) {
                     self::arrayChangeKeys($val, $key, $arr);
                 }
                 $resultArray = $offset == 0 ? $results : array_combine(range($offset, $offset + $rowCount - 1), $results);
             }
         }
     }
     eZPerfLogger::accumulatorStop('oracle_loop');
     oci_free_statement($statement);
     return $resultArray;
 }