diff --git a/livesupport/modules/storageServer/var/html/gbHtmlLogin.php b/livesupport/modules/storageServer/var/html/gbHtmlLogin.php index a30a54764..54815edbf 100644 --- a/livesupport/modules/storageServer/var/html/gbHtmlLogin.php +++ b/livesupport/modules/storageServer/var/html/gbHtmlLogin.php @@ -1,5 +1,5 @@ Storage - login diff --git a/livesupport/modules/storageServer/var/html/gbHtmlPerms.php b/livesupport/modules/storageServer/var/html/gbHtmlPerms.php index 63b939fd6..78bb451b1 100644 --- a/livesupport/modules/storageServer/var/html/gbHtmlPerms.php +++ b/livesupport/modules/storageServer/var/html/gbHtmlPerms.php @@ -1,5 +1,5 @@ Storage - permission editor diff --git a/livesupport/modules/storageServer/var/html/gbHtmlSubj.php b/livesupport/modules/storageServer/var/html/gbHtmlSubj.php index 40a018109..3d4d67606 100644 --- a/livesupport/modules/storageServer/var/html/gbHtmlSubj.php +++ b/livesupport/modules/storageServer/var/html/gbHtmlSubj.php @@ -1,5 +1,5 @@ Storage - user and roles editor diff --git a/livesupport/modules/storageServer/var/html/gbHttp.php b/livesupport/modules/storageServer/var/html/gbHttp.php index 96dd0a363..fdce92545 100644 --- a/livesupport/modules/storageServer/var/html/gbHttp.php +++ b/livesupport/modules/storageServer/var/html/gbHttp.php @@ -1,38 +1,89 @@ \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"
$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"
\n"; print_r($_REQUEST); exit;
         $sessid = $gb->login($_REQUEST['login'], $_REQUEST['pass']);
         if($sessid && !PEAR::isError($sessid)){
-#            echo"
$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"
$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"
\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"
$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"
$redirUrl\n"; print_r($_REQUEST); exit;
 header("Location: $redirUrl");
 ?>
\ No newline at end of file