cacert-testmgr/external/ZendFramework-1.9.5/externals/dojo/demos/uploader/cLOG.php
Markus Warg 8398c9048d initially import ZendFramework-1.9.5 into repository
code was modified slightly, so the code differs from the original downloadable 1.9.5 version
2010-03-31 10:12:32 +02:00

54 lines
No EOL
1.1 KiB
PHP

<?php
//
// summary
// Creates/Opens files for logging data
// Useful for logging iinformation on a remote server
// when you don't have access to log files
// Also helpful for XHRs - since the page doesn't change
// to the PHP location which normally shows log data
// or errors.
//
//
class cLOG {
var $logfile;
var $boolTimestamp;
function cLOG($filename, $boolTimestamp){
$this->boolTimestamp = $boolTimestamp;
$this->logfile = $filename;
}
function write($txt){
if($this->boolTimestamp){
$dt = date("y.m.d G.i.s");
$txt = "[". $dt ."]: ".$txt;
}
$fh = fopen($this->logfile, "a");
if(is_array($txt)){
//$txt = "::::::::".$txt;
$ar = $txt;
$txt = "Array:::::\n";
foreach($ar as $key => $value){
$txt += $key."=".$value."\n";
}
}
fwrite($fh, $txt."\n");
fclose($fh);
}
function clear(){
$fh = fopen($this->logfile, "w");
fwrite($fh, "");
fclose($fh);
}
function newline(){
$fh = fopen($this->logfile, "a");
fwrite($fh, "\n\n");
fclose($fh);
}
function printr($ar){
$txt = "";
foreach ($ar as $nm => $val) {
$txt .= " ".$nm ." = " . $val . "\n";
}
$this->write($txt);
}
}
?>