Auto File Gallery Insertion
I do sysadmin in a chemistry laboratory. I want to take files produce by measuring instruments and make them available to certain users on tikiwiki pages. It is to be done automatically and once every hour
The way I want to do this is to copy files from the instrumentaion source into the file gallery directory (using rsync) and then run a php script to insert the files into the appropriate file gallery. Rsync and the script would be run at regular intervals using crontab.
Checking tiki pages I saw that tikiwiki user, Damian Parker, has provided a script that sort of does this but it involves using the tiki pages to perform the insert. I want a script that produces no html code and just sets up the tikiwiki files for when the user logs in they get their upto date files.
I might be able to hack Damian's script but it will take me a long time because I'm not php literate. Does anyone have a script that might help me or can you give general advice on how to hack Damian's script which I include below. If I get something going I'll post it back.
<?php
// Damian Parker
// Damosoft
// Given to the Tiki Community
// Initialization
require_once('tiki-setup.php');
include_once('lib/filegals/filegallib.php');
// Process an upload here
$errors = Array();
$uploads = Array();
$file = $_REQUEST'fname';
// Check the name
$name = $file;
$data = '';
$fhash='';
$fhash = md5($name);
$fhash = md5$fhash;
rename($fgal_use_dir.$name, $fgal_use_dir.$fhash);
$size = filesize($fgal_use_dir.$fhash);
- Dont think this is the correct function.
- $type = filetype($fgal_use_dir.$fhash);
$type = 'application/octet-stream';
$fileId = $filegallib->insert_file($_REQUEST%22galleryId%22,$name,'',$name, $data, $size, $type, 'damian',$fhash);
$aux'name'=$name;
$aux'size'=$size;
$aux'fileId'=$fileId;
$uploads[] = $aux;
print "Completed."
?>