Index: branches/RC/core/kernel/globals.php =================================================================== diff -u -N -r9558 -r9639 --- branches/RC/core/kernel/globals.php (.../globals.php) (revision 9558) +++ branches/RC/core/kernel/globals.php (.../globals.php) (revision 9639) @@ -305,7 +305,7 @@ * @param unknown_type $post * @return unknown */ - function curl_post($url, $post, $headers=null, $request_type = 'POST') + function curl_post($url, $post, $headers=null, $request_type = 'POST', $curl_options=null) { if( is_array($post) ) { @@ -348,6 +348,11 @@ curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 90); + if (is_array($curl_options)) { + foreach ($curl_options as $option => $value) { + curl_setopt($ch, $option, $value); + } + } $ret = curl_exec($ch); $GLOBALS['curl_errorno'] = curl_errno($ch); $GLOBALS['curl_error'] = curl_error($ch); @@ -472,10 +477,30 @@ } $line = $enclosure.implode($enclosure.$delimiter.$enclosure, $data).$enclosure.$recordSeparator; + $line = preg_replace('/'.preg_quote($enclosure).'([0-9\.]+)'.preg_quote($enclosure).'/', '$1', $line); fwrite($filePointer, $line); } /** + * Enter description here... + * + * @param resource $filePointer the file resource to write to + * @param Array $data the data to write out + * @param string $delimiter the field separator + * @param string $enclosure symbol to enclose field data to + * @param string $recordSeparator symbols to separate records with + */ + function getcsvline($data, $delimiter = ',', $enclosure = '"', $recordSeparator = "\r\n") + { + foreach($data as $field_index => $field_value) { + // replaces an enclosure with two enclosures + $data[$field_index] = str_replace($enclosure, $enclosure.$enclosure, $field_value); + } + $line = $enclosure.implode($enclosure.$delimiter.$enclosure, $data).$enclosure.$recordSeparator; + $line = preg_replace('/'.preg_quote($enclosure).'([0-9\.]+)'.preg_quote($enclosure).'/', '$1', $line); + return $line; + } + /** * Allows to replace #section# within any string with current section * * @param string $string