Source for file KTUploadManager.inc.php
Documentation is available at KTUploadManager.inc.php
* KTUploadManager manages files in the uploaded_files table.
* @license http://www.knowledgetree.com/KPL KnowledgeTree Public License Version 1.1
* The contents of this file are subject to the KnowledgeTree Public
* License Version 1.1 ("License"); You may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.knowledgetree.com/KPL
* Software distributed under the License is distributed on an "AS IS"
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* The Original Code is: KnowledgeTree Open Source
* The Initial Developer of the Original Code is The Jam Warehouse Software
* (Pty) Ltd, trading as KnowledgeTree.
* Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
* (C) 2007 The Jam Warehouse Software (Pty) Ltd;
$config =
KTConfig::getSingleton();
$this->age =
$config->get('webservice/uploadExpiry',60);
$this->temp_dir=
$config->get('webservice/uploadDirectory');
* Sets the current session.
* @param KTAPI_Session $session
$user =
&$session->get_user();
$this->session =
$session->get_session();
* This tells the manager to manage a file that has been uploaded.
* @param string $filename
* @param string $tempfile
function uploaded($filename, $tempfile, $action, $relatedid =
null)
$now=
date('Y-m-d H:i:s');
DBUtil::startTransaction();
$id =
DBUtil::autoInsert('uploaded_files',
'tempfilename'=>
$newtempfile,
'related_uploadid'=>
$relatedid
* This is a list of all all managed files.
$sql =
"SELECT id, tempfilename, filename, userid, action, related_uploadid FROM uploaded_files WHERE userid=$this->userid";
$sql .=
" AND action='$action'";
$result =
DBUtil::getResultArray($sql);
DBUtil::startTransaction();
$sql =
"DELETE FROM uploaded_files WHERE action='$action' AND filename='$filename'";
$rs =
DBUtil::runQuery($sql);
$sql =
"INSERT INTO index_files(document_id, user_id) VALUES($documentid, $this->userid)";
* This will remove any temporary files that have not been dealt with in the correct timeframe.
list
($year,$mon,$day,$hour, $min) =
explode(':', date('Y:m:d:H:i'));
$expirydate =
date('Y-m-d H:i:s', mktime($hour, $min -
$this->age, 0, $mon, $day, $year));
$sql =
"SELECT tempfilename FROM uploaded_files WHERE uploaddate<'$expirydate'";
$rows =
DBUtil::getResultArray($sql);
foreach($rows as $record)
$tempfilename=
addslashes($record['tempfilename']);
$sql =
"DELETE FROM uploaded_files WHERE tempfilename='$tempfilename'";
$rs =
DBUtil::runQuery($sql);
Documentation generated on Sun, 22 Apr 2007 02:30:55 +0200 by phpDocumentor 1.3.2