Gunid testing added.

This commit is contained in:
tomas 2004-12-27 15:31:13 +00:00
parent a9e52421d9
commit 8ae91afd94
4 changed files with 25 additions and 18 deletions

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/
@ -48,7 +48,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module
*
* @author $Author: tomas $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
* @see Alib
*/
class BasicStor extends Alib{
@ -388,24 +388,25 @@ class BasicStor extends Alib{
{
if(!$this->bsCheckToken($token, 'put')){
return PEAR::raiseError(
'BasicStor::bsClosePut: invalid token ($token)'
"BasicStor::bsClosePut: invalid token ($token)"
);
}
$chsum = $this->dbc->getOne("
SELECT chsum FROM {$this->accessTable}
WHERE token=x'{$token}'::bigint
");
$fname = "{$this->accessDir}/$token";
$md5sum = md5_file($fname);
if($chsum != $md5sum){
return PEAR::raiseError(
'BasicStor::bsClosePut: md5sum does not match (token=$token)'
);
}
$res = $this->dbc->query("
DELETE FROM {$this->accessTable} WHERE token=x'$token'::bigint
");
if(PEAR::isError($res)){ return $res; }
$fname = "{$this->accessDir}/$token";
$md5sum = md5_file($fname);
if($chsum != $md5sum){
if(file_exists($fname)) @unlink($fname);
return PEAR::raiseError(
"BasicStor::bsClosePut: md5sum does not match (token=$token)"
);
}
return $fname;
}

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
------------------------------------------------------------------------------*/
@ -49,6 +49,11 @@ class LocStor extends GreenBox{
function storeAudioClipOpen($sessid, $gunid, $metadata, $chsum)
{
// test if specified gunid exists:
if(!preg_match("|^[0-9a-fA-F]{16}$|", $gunid)){
return PEAR::raiseError(
"LocStor.php: storeAudioClipOpen: Wrong gunid ($gunid)"
);
}
$ac =& StoredFile::recallByGunid(&$this, $gunid);
if(!PEAR::isError($ac)){
// gunid exists - do replace
@ -57,7 +62,7 @@ class LocStor extends GreenBox{
)) !== TRUE) return $res;
if($ac->isAccessed()){
return PEAR::raiseError(
'LocStor.php: storeAudioClip: is accessed'
'LocStor.php: storeAudioClipOpen: is accessed'
);
}
$res = $ac->replace(
@ -98,8 +103,9 @@ class LocStor extends GreenBox{
function storeAudioClipClose($sessid, $token)
{
$ac =& StoredFile::recallByToken(&$this, $token);
$fname = $this->bsClosePut($token);
if(PEAR::isError($ac)){ return $ac; }
$fname = $this->bsClosePut($token);
if(PEAR::isError($fname)){ return $fname; }
$res = $ac->replaceRawMediaData($fname);
if(PEAR::isError($res)){ return $res; }
@unlink($fname);

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/put.php,v $
------------------------------------------------------------------------------*/
@ -71,7 +71,7 @@ function http_error($code, $err){
exit;
}
if(preg_match("|^[0-9a-f]{16}$|", $_REQUEST['token'])){
if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['token'])){
$token = $_REQUEST['token'];
}else{
http_error(400, "Error on token parameter. ({$_REQUEST['token']})");

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/simpleGet.php,v $
------------------------------------------------------------------------------*/
@ -71,12 +71,12 @@ function http_error($code, $err){
exit;
}
if(preg_match("|^[0-9a-f]{32}$|", $_REQUEST['sessid'])){
if(preg_match("|^[0-9a-fA-F]{32}$|", $_REQUEST['sessid'])){
$sessid = $_REQUEST['sessid'];
}else{
http_error(400, "Error on sessid parameter. ({$_REQUEST['sessid']})");
}
if(preg_match("|^[0-9a-f]{16}$|", $_REQUEST['id'])){
if(preg_match("|^[0-9a-fA-F]{16}$|", $_REQUEST['id'])){
$gunid = $_REQUEST['id'];
}else{
http_error(400, "Error on id parameter. ({$_REQUEST['id']})");