Few comments added

This commit is contained in:
tomas 2004-12-09 00:42:42 +00:00
parent fe6a11cab1
commit 1a14163965
4 changed files with 215 additions and 44 deletions

View file

@ -1,5 +1,5 @@
<?php
// $Id: gbHtmlLogin.php,v 1.2 2004/09/21 00:27:41 tomas Exp $
// $Id: gbHtmlLogin.php,v 1.3 2004/12/09 00:42:42 tomas Exp $
require_once"gbHtml_h.php";
// prefill data structure for template
@ -21,7 +21,8 @@ unset($_SESSION['lastPost']);
#header("Content-type: text/plain"); print_r($d); exit;
#require_once"gbHtml_f.php";
// template follows:
// =================== template: ===================
?>
<html><head>
<title>Storage - login</title>

View file

@ -1,5 +1,5 @@
<?php
// $Id: gbHtmlPerms.php,v 1.2 2004/09/21 00:27:41 tomas Exp $
// $Id: gbHtmlPerms.php,v 1.3 2004/12/09 00:42:42 tomas Exp $
require_once"gbHtml_h.php";
require_once"gbHtmlTestAuth.php";
@ -26,7 +26,8 @@ $tpldata['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
#require_once"gbHtml_f.php";
// template follows:
// =================== template: ===================
?>
<html><head>
<title>Storage - permission editor</title>

View file

@ -1,5 +1,5 @@
<?php
// $Id: gbHtmlSubj.php,v 1.2 2004/09/21 00:27:41 tomas Exp $
// $Id: gbHtmlSubj.php,v 1.3 2004/12/09 00:42:42 tomas Exp $
require_once"gbHtml_h.php";
require_once"gbHtmlTestAuth.php";
@ -40,7 +40,8 @@ $d['msg'] = $_SESSION['alertMsg']; unset($_SESSION['alertMsg']);
#header("Content-type: text/plain"); print_r($d); echo($list ? 'Y' : 'N')."\n"; exit;
#require_once"gbHtml_f.php";
// template follows:
// =================== template: ===================
?>
<html><head>
<title>Storage - user and roles editor</title>

View file

@ -1,38 +1,89 @@
<?php
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
LiveSupport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: tomas $
Version : $Revision: 1.5 $
Location : $ $
------------------------------------------------------------------------------*/
require_once"gbHtml_h.php";
#header("Content-type: text/plain"); echo"GET:\n"; print_r($_GET); echo"POST:\n"; print_r($_POST); echo"REQUEST:\n"; print_r($_REQUEST); echo"FILES:\n"; print_r($_FILES); exit;
#echo"<pre>\n"; print_r($_SERVER); exit;
/**
* storageServer WWW-form interface
*
* @author $Author: tomas $
* @version $Revision: 1.5 $
* @see Alib
* @see GreenBox
*/
// debugging utilities:
#header("Content-type: text/plain"); echo"GET:\n"; print_r($_GET); exit;
#header("Content-type: text/plain"); echo"POST:\n"; print_r($_POST); exit;
#header("Content-type: text/plain"); echo"REQUEST:\n"; print_r($_REQUEST); exit;
#header("Content-type: text/plain"); echo"FILES:\n"; print_r($_FILES); exit;
#echo"<pre>$redirUrl\n"; print_r($_REQUEST); exit;
define('BROWSER', "gbHtmlBrowse.php");
$sessid = $_REQUEST[$config['authCookieName']];
$userid = $gb->getSessUserId($sessid);
$login = $gb->getSessLogin($sessid);
#$path = ($_REQUEST['path']=='' ? '/' : $_REQUEST['path']);
#$upath = urlencode($path);
#$id = $gb->_idFromPath($path);
$id = (!$_REQUEST['id'] ? $gb->storId : $_REQUEST['id']);
#if(PEAR::isError($id)){ $_SESSION['msg'] = $id->getMessage(); header("Location: ".BROWSER."?id=$id"); exit; }
$redirUrl="gbHtmlBrowse.php?id=$id";
switch($_REQUEST['act']){
// --- authentication ---
/**
* login
*
* Login to the storageServer.
* It set sessid to the cookie with name defined in ../conf.php
*
* @param login string, username
* @param pass string, password
*/
case"login";
# echo"<pre>\n"; print_r($_REQUEST); exit;
$sessid = $gb->login($_REQUEST['login'], $_REQUEST['pass']);
if($sessid && !PEAR::isError($sessid)){
# echo"<pre>$sessid\n"; print_r($_REQUEST); exit;
setcookie($config['authCookieName'], $sessid);
$redirUrl="gbHtmlBrowse.php";
$fid = $gb->getObjId($_REQUEST['login'], $gb->storId);
if(!PEAR::isError($fid)) $redirUrl.="?id=$fid";
}else{ $redirUrl="gbHtmlLogin.php"; $_SESSION['alertMsg']='Login failed.'; }
# echo"<pre>$redirUrl\n"; print_r($_REQUEST); exit;
}else{
$redirUrl="gbHtmlLogin.php"; $_SESSION['alertMsg']='Login failed.';
}
break;
/**
* logout
*
* Logut from storageServer, takes sessid from cookie
*
*/
case"logout";
$gb->logout($sessid);
setcookie($config['authCookieName'], '');
@ -40,12 +91,25 @@ switch($_REQUEST['act']){
break;
// --- files ---
/**
* upload
*
* Provides file upload and store it to the storage
*
* @param filename string, name for the uploaded file
* @param mediafile file uploded by HTTP, raw binary media file
* @param mdatafile file uploded by HTTP, metadata XML file
* @param id int, destination folder id
*/
case"upload":
$tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.livesupport");
$tmpgunid = md5(
microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.livesupport"
);
$ntmp = "{$gb->bufferDir}/$tmpgunid";
# $ntmp = tempnam(""{$gb->bufferDir}", 'gbTmp_');
$mdtmp = "";
move_uploaded_file($_FILES['mediafile']['tmp_name'], $ntmp); chmod($ntmp, 0664);
move_uploaded_file($_FILES['mediafile']['tmp_name'], $ntmp);
chmod($ntmp, 0664);
if($_FILES['mdatafile']['tmp_name']){
$mdtmp = "$ntmp.xml";
if(move_uploaded_file($_FILES['mdatafile']['tmp_name'], $mdtmp)){
@ -61,17 +125,42 @@ switch($_REQUEST['act']){
}
$redirUrl = BROWSER."?id=$id";
break;
/**
* newFolder
*
* Create new folder in the storage
*
* @param newname string, name for the new folder
* @param id int, destination folder id
*/
case"newFolder":
$r = $gb->createFolder($id, $_REQUEST['newname'], $sessid);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage();
$redirUrl = BROWSER."?id=$id";
break;
/**
* rename
*
* Change the name of file or folder
*
* @param newname string, new name for the file or folder
* @param id int, destination folder id
*/
case"rename":
$parid = $gb->getparent($id);
$r = $gb->renameFile($id, $_REQUEST['newname'], $sessid);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage();
$redirUrl = BROWSER."?id=$parid";
break;
/**
* move
*
* Move file to another folder
* TODO: format of destinantion path should be properly defined
*
* @param newPath string, destination relative path
* @param id int, destination folder id
*/
case"move":
$newPath = urlencode($_REQUEST['newPath']);
$did = $gb->getObjIdFromRelPath($id, $newPath);
@ -83,11 +172,19 @@ switch($_REQUEST['act']){
}
else $redirUrl = BROWSER."?id=$did";
break;
/**
* copy
*
* Copy file to another folder
* TODO: format of destinantion path should be properly defined
*
* @param newPath string, destination relative path
* @param id int, destination folder id
*/
case"copy":
$newPath = urldecode($_REQUEST['newPath']);
$did = $gb->getObjIdFromRelPath($id, $newPath);
$parid = $gb->getparent($id);
# echo"<pre>\n$id\t$newPath\t$did\n"; print_r($did); exit;
$r = $gb->copyFile($id, $did, $sessid);
if(PEAR::isError($r)){
$_SESSION['alertMsg'] = $r->getMessage();
@ -95,34 +192,55 @@ switch($_REQUEST['act']){
}
else $redirUrl = BROWSER."?id=$did";
break;
/* NOT WORKING - sorry
case"repl":
$unewpath = urlencode($_REQUEST['newpath']);
$r = $gb->createReplica($id, $_REQUEST['newpath'], '', $sessid);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage();
$redirUrl = BROWSER."?id=$newparid";
break;
*/
/**
* delete
*
* Delete of stored file
*
* @param id int, local id of deleted file or folder
*/
case"delete":
$parid = $gb->getparent($id);
$r = $gb->deleteFile($id, $sessid);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage();
$redirUrl = BROWSER."?id=$parid";
break;
/**
* getFile
*
* Call access method and show access path.
* Example only - not really useable.
* TODO: resource should be released by release method call
*
* @param id int, local id of accessed file
*/
case"getFile":
# echo"<pre>$t, $ctype\n"; exit;
# $r = $gb->getFile($id, $sessid);
$r = $gb->access($id, $sessid);
if(PEAR::isError($r)) $_SESSION['alertMsg'] = $r->getMessage();
else echo $r;
exit;
break;
/**
* getMdata
*
* Show file's metadata as XML
*
* @param id int, local id of stored file
*/
case"getMdata":
header("Content-type: text/xml");
$r = $gb->getMdata($id, $sessid);
print_r($r);
exit;
break;
/**
* getInfo
*
* Call getid3 library to analyze media file and show some results
*
* @param
* @param
*/
case"getInfo":
header("Content-type: text/plain");
$ia = $gb->analyzeFile($id, $sessid);
@ -134,26 +252,56 @@ switch($_REQUEST['act']){
echo"title: {$ia['id3v1']['title']}\n";
echo"artist: {$ia['id3v1']['artist']}\n";
echo"comment: {$ia['id3v1']['comment']}\n";
# echo": {$ia['id3v1']['']}\n";
# print_r($ia);
exit;
break;
// --- subjs ----
/**
* addSubj
*
* Create new user or group (empty pass => create group)
*
* @param login string, login name from new user
* @param pass string, password for new user
*/
case"addSubj";
$redirUrl="gbHtmlSubj.php";
if($gb->checkPerm($userid, 'subjects'))
$res = $gb->addSubj($_REQUEST['login'], ($_REQUEST['pass']=='' ? NULL:$_REQUEST['pass'] ));
else{ $_SESSION['alertMsg']='Access denied.'; break; }
if($gb->checkPerm($userid, 'subjects')){
$res = $gb->addSubj($_REQUEST['login'],
($_REQUEST['pass']=='' ? NULL:$_REQUEST['pass'] ));
}else{
$_SESSION['alertMsg']='Access denied.';
break;
}
if(PEAR::isError($res)) $_SESSION['alertMsg'] = $res->getMessage();
break;
/**
* removeSubj
*
* Remove existing user or group
*
* @param login string, login name of removed user
*/
case"removeSubj";
$redirUrl="gbHtmlSubj.php";
if($gb->checkPerm($userid, 'subjects'))
if($gb->checkPerm($userid, 'subjects')){
$res = $gb->removeSubj($_REQUEST['login']);
else{ $_SESSION['alertMsg']='Access denied.'; break; }
}else{
$_SESSION['alertMsg']='Access denied.';
break;
}
if(PEAR::isError($res)) $_SESSION['alertMsg'] = $res->getMessage();
break;
/**
* passwd
*
* Change password for specified user
*
* @param uid int, local user id
* @param oldpass string, old user password
* @param pass string, new password
* @param pass2 string, retype of new password
*/
case"passwd";
$redirUrl="gbHtmlSubj.php";
$ulogin = $gb->getSubjName($_REQUEST['uid']);
@ -167,22 +315,43 @@ switch($_REQUEST['act']){
break;
}
if($_REQUEST['pass'] !== $_REQUEST['pass2']){
$_SESSION['alertMsg']="Passwords do not match. ({$_REQUEST['pass']}/{$_REQUEST['pass2']})";
$_SESSION['alertMsg'] = "Passwords do not match. ".
"({$_REQUEST['pass']}/{$_REQUEST['pass2']})";
break;
}
$gb->passwd($ulogin, $_REQUEST['oldpass'], $_REQUEST['pass']);
break;
// --- perms ---
/**
* addPerm
*
* Add new permission record
*
* @param subj int, local user/group id
* @param permAction string, type of action from set predefined in conf.php
* @param id int, local id of file/object
* @param allowDeny char, A or D
*/
case"addPerm";
if($gb->checkPerm($userid, 'editPerms', $_REQUEST['id']))
$gb->addPerm($_REQUEST['subj'], $_REQUEST['permAction'], $_REQUEST['id'], $_REQUEST['allowDeny']);
else $_SESSION['alertMsg']='Access denied.';
if($gb->checkPerm($userid, 'editPerms', $_REQUEST['id'])){
$gb->addPerm($_REQUEST['subj'], $_REQUEST['permAction'],
$_REQUEST['id'], $_REQUEST['allowDeny']);
}else{
$_SESSION['alertMsg']='Access denied.';
}
$redirUrl="gbHtmlPerms.php?id=$id";
break;
/**
* removePerm
*
* Remove permission record
*
* @param permid int, local id of permission record
*/
case"removePerm";
if($gb->checkPerm($userid, 'editPerms', $_REQUEST['oid']))
$gb->removePerm($_GET['permid']);
$gb->removePerm($_REQUEST['permid']);
else $_SESSION['alertMsg']='Access denied.';
$redirUrl="gbHtmlPerms.php?id=$id";
break;
@ -192,6 +361,5 @@ switch($_REQUEST['act']){
$redirUrl="gbHtmlLogin.php";
}
#echo"<pre>$redirUrl\n"; print_r($_REQUEST); exit;
header("Location: $redirUrl");
?>