static function writeEventLogExtra($data) {
self::$extra_data = $data;
}
+ static $files = array();
+
+ /**
+ * Add a file to the output log
+ * this needs to be called before addEvent, and the data format should be the same as $_FILES
+ * eg.
+ *
+ * DB_DataObject::factory('Events')->addFile(array(
+ * 'tmp_name' => real file location
+ * 'name' => real file name
+ * 'type' => mimetype
+ * 'size' => filesize
+ *
+ * ))
+ *
+ */
+ function addFile($data)
+ {
+ self::$files[] = $data;
+ }
function logDir($user = false)
{
$i=0;
$files = array();
+
- $i = 0;
- foreach ($_FILES as $k=>$f){
+
+ foreach (array_merge($_FILES, self::$files) as $k=>$f){
// does not handle any other file[] arrary very well..
if (empty($f['tmp_name']) || !file_exists($f['tmp_name'])) {
continue;
$mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
$ext = "xlsx";
}
-
-
-
-
-
-
- // unlink($srcTmp);
if (empty($fname)) {
$fname = basename($targetTmp);
}
$fname .= preg_match('/\.' . $ext . '/i', $fname) ? '' : ('.' . $ext); // make sure it ends in xls..
+
+ DB_DataObject::factory('Events')->addFile(array(
+ 'tmp_name' => $targetTmp,
+ 'name' => $fname,
+ 'type' => $mime,
+ 'size' => filesize($targetTmp)
+ ));
+
+ $this->addEvent("DOWNLOAD", false, $fname );
+
+ // unlink($srcTmp);
+
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
header('Content-length: '. filesize($targetTmp));