- Timestamp:
- 09/26/13 15:41:49 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/adodb-csvlib.inc.php
r34 r8222 9 9 /* 10 10 11 V 4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.11 V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 12 12 Released under both BSD license and Lesser GPL library license. 13 13 Whenever there is any discrepancy between the two licenses, … … 55 55 56 56 if ($rs->databaseType == 'array') { 57 $rows = &$rs->_array;57 $rows = $rs->_array; 58 58 } else { 59 59 $rows = array(); … … 65 65 66 66 for($i=0; $i < $max; $i++) { 67 $o = &$rs->FetchField($i);67 $o = $rs->FetchField($i); 68 68 $flds[] = $o; 69 69 } … … 72 72 $class = $rs->connection->arrayClass; 73 73 $rs2 = new $class(); 74 $rs2->timeCreated = $rs->timeCreated; # memcache fix 74 75 $rs2->sql = $rs->sql; 75 76 $rs2->oldProvider = $rs->dataProvider; … … 91 92 * empty recordset is returned 92 93 */ 93 function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')94 function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') 94 95 { 95 96 $false = false; … … 262 263 /** 263 264 * Save a file $filename and its $contents (normally for caching) with file locking 265 * Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked) 264 266 */ 265 267 function adodb_write_file($filename, $contents,$debug=false) … … 281 283 // getmypid() actually returns 0 on Win98 - never mind! 282 284 $tmpname = $filename.uniqid($mtime).getmypid(); 283 if (!($fd = @fopen($tmpname,' a'))) return false;284 $ok = ftruncate($fd,0);285 if (!fwrite($fd,$contents))$ok = false;285 if (!($fd = @fopen($tmpname,'w'))) return false; 286 if (fwrite($fd,$contents)) $ok = true; 287 else $ok = false; 286 288 fclose($fd); 287 chmod($tmpname,0644); 288 // the tricky moment 289 @unlink($filename); 290 if (!@rename($tmpname,$filename)) { 291 unlink($tmpname); 292 $ok = false; 293 } 294 if (!$ok) { 295 if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); 289 290 if ($ok) { 291 @chmod($tmpname,0644); 292 // the tricky moment 293 @unlink($filename); 294 if (!@rename($tmpname,$filename)) { 295 unlink($tmpname); 296 $ok = 0; 297 } 298 if (!$ok) { 299 if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); 300 } 296 301 } 297 302 return $ok; … … 299 304 if (!($fd = @fopen($filename, 'a'))) return false; 300 305 if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { 301 $ok = fwrite( $fd, $contents ); 306 if (fwrite( $fd, $contents )) $ok = true; 307 else $ok = false; 302 308 fclose($fd); 303 chmod($filename,0644);309 @chmod($filename,0644); 304 310 }else { 305 311 fclose($fd);
Note: See TracChangeset
for help on using the changeset viewer.