2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merged from McMasterReports branch

This commit is contained in:
azammitdcarf
2010-01-14 07:45:37 +00:00
parent 18dbb16138
commit d1b139d315
1884 changed files with 555891 additions and 364768 deletions

View File

@@ -8,7 +8,7 @@ $ADODB_INCLUDED_CSV = 1;
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.08 6 Apr 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
@@ -54,7 +54,7 @@ $ADODB_INCLUDED_CSV = 1;
$line = "====1,$tt,$sql\n";
if ($rs->databaseType == 'array') {
$rows =& $rs->_array;
$rows = $rs->_array;
} else {
$rows = array();
while (!$rs->EOF) {
@@ -64,7 +64,7 @@ $ADODB_INCLUDED_CSV = 1;
}
for($i=0; $i < $max; $i++) {
$o =& $rs->FetchField($i);
$o = $rs->FetchField($i);
$flds[] = $o;
}
@@ -90,7 +90,7 @@ $ADODB_INCLUDED_CSV = 1;
* error occurred in sql INSERT/UPDATE/DELETE,
* empty recordset is returned
*/
function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
{
$false = false;
$err = false;
@@ -261,6 +261,7 @@ $ADODB_INCLUDED_CSV = 1;
/**
* Save a file $filename and its $contents (normally for caching) with file locking
* Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked)
*/
function adodb_write_file($filename, $contents,$debug=false)
{
@@ -280,27 +281,31 @@ $ADODB_INCLUDED_CSV = 1;
$mtime = substr(str_replace(' ','_',microtime()),2);
// getmypid() actually returns 0 on Win98 - never mind!
$tmpname = $filename.uniqid($mtime).getmypid();
if (!($fd = @fopen($tmpname,'a'))) return false;
$ok = ftruncate($fd,0);
if (!fwrite($fd,$contents)) $ok = false;
if (!($fd = @fopen($tmpname,'w'))) return false;
if (fwrite($fd,$contents)) $ok = true;
else $ok = false;
fclose($fd);
chmod($tmpname,0644);
// the tricky moment
@unlink($filename);
if (!@rename($tmpname,$filename)) {
unlink($tmpname);
$ok = false;
}
if (!$ok) {
if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
if ($ok) {
@chmod($tmpname,0644);
// the tricky moment
@unlink($filename);
if (!@rename($tmpname,$filename)) {
unlink($tmpname);
$ok = 0;
}
if (!$ok) {
if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
}
}
return $ok;
}
if (!($fd = @fopen($filename, 'a'))) return false;
if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
$ok = fwrite( $fd, $contents );
if (fwrite( $fd, $contents )) $ok = true;
else $ok = false;
fclose($fd);
chmod($filename,0644);
@chmod($filename,0644);
}else {
fclose($fd);
if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");