Wednesday, July 8, 2015

Server side log of javascript user notification

<?php
 
$file = 'htmlMsg.txt'; 
 
$input=date("D M d, Y G:i a"); 
$input=$input."\n";
foreach($_REQUEST as $key=>$value) {
 $input=$input.$key.": ".$value."\n";
}

$filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB
if($filesize > 1) {
 file_put_contents($file, $input); // overwrite and thus downsizing the $file
} else {
 file_put_contents($file, $input, FILE_APPEND);
}

die($filesize);  

// ajax call to this script.
// $.post("/ls/htmlMsg.php", { msg: htmlMsg }, console.log('posted htmlMsg') );
?>

No comments: