@ -0,0 +1,257 @@ |
||||
<?php |
||||
/* See license terms in /dokeos_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
* This is an interface between Dokeos and Videoconference application |
||||
* |
||||
============================================================================== |
||||
*/ |
||||
/*==== DEBUG ====*/ |
||||
$debug=0; |
||||
/*==== CONSTANTS ==== */ |
||||
define('VIDEOCONF_UPLOAD_PATH', '/videoconf'); |
||||
$presentation_extension = array('.ppt', '.odp'); |
||||
$image_extension = array ('.png', '.jpg', '.gif', '.jpeg'); |
||||
|
||||
if ($debug>0) |
||||
{ |
||||
// dump the request |
||||
$v = array_keys(get_defined_vars()); |
||||
error_log(var_export($v, true),3, '/tmp/log'); |
||||
|
||||
foreach (array_keys(get_defined_vars()) as $k) { |
||||
if ($k == 'GLOBALS') |
||||
continue; |
||||
error_log($k, 3, '/tmp/log'); |
||||
error_log(var_export($$k, true), 3, '/tmp/log'); |
||||
} |
||||
|
||||
} |
||||
|
||||
/*==== INCLUDE ====*/ |
||||
require_once ('../inc/global.inc.php'); |
||||
api_block_anonymous_users(); |
||||
require_once (api_get_path(LIBRARY_PATH)."course.lib.php"); |
||||
require_once (api_get_path(LIBRARY_PATH)."document.lib.php"); |
||||
require_once (api_get_path(LIBRARY_PATH)."fileUpload.lib.php"); |
||||
|
||||
/*==== Variables initialisation ====*/ |
||||
$action = $_REQUEST["action"]; //safe as only used in if()'s |
||||
$seek = array('/','%2F','..'); |
||||
$destroy = array('','',''); |
||||
$cidReq = str_replace($seek,$destroy,$_REQUEST["cidReq"]); |
||||
$cidReq = Security::remove_XSS($cidReq); |
||||
|
||||
$user_id = api_get_user_id(); |
||||
$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document'; |
||||
$_course = CourseManager::get_course_information($cidReq); |
||||
|
||||
// FIXME: add_document needs this to work |
||||
$_course['dbName'] = $_course['db_name']; |
||||
|
||||
// FIXME: check if CourseManager::get_user_in_course_status return != |
||||
// COURSEMANAGER when the code is not valid |
||||
if ($debug>0) error_log($coursePath, 0); |
||||
|
||||
if ($action == "uploadgui") |
||||
{ |
||||
echo '<form enctype="multipart/form-data" action="api.php" method="POST"> |
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" /> |
||||
<input type="hidden" name="action" value="upload" /> |
||||
<input type="hidden" name="cidReq" value="'.$cidReq.'" /> |
||||
<input type="hidden" name="sid" value="'.Security::remove_XSS($_REQUEST["sid"]).'" /> |
||||
|
||||
Choose a file to upload: <input name="filedata" type="file" /><br /> |
||||
<input type="submit" value="Upload File" /> |
||||
</form> |
||||
'; |
||||
die(); |
||||
} |
||||
else if ($action == "upload") |
||||
{ |
||||
/*==== PERMISSION ====*/ |
||||
$permissions = CourseManager::get_user_in_course_status($user_id, $cidReq); |
||||
if ($permissions != COURSEMANAGER) |
||||
{ |
||||
if ($debug >0) error_log("Upload from videoconf not allowed !!!",0); |
||||
die('Not allowed'); // this user is not allowed to add upload documents |
||||
} |
||||
/*==== UPLOAD ====*/ |
||||
$destPath = $coursePath.VIDEOCONF_UPLOAD_PATH; |
||||
if (!is_dir($destPath)) |
||||
{ |
||||
$result = create_unexisting_directory($_course,$user_id,0,NULL,$coursePath,VIDEOCONF_UPLOAD_PATH); |
||||
if (!$result) |
||||
{ |
||||
if ($debug>0) error_log("Can't create ".$destPath." folder",0); |
||||
} |
||||
} |
||||
|
||||
$newPath = handle_uploaded_document($_course,$_FILES['filedata'],$coursePath,VIDEOCONF_UPLOAD_PATH,$user_id,0,NULL,'',0,'rename',false); |
||||
// based on ../newscorm/presentation.class.php |
||||
$file_name = (strrpos($newPath,'.')>0 ? substr($newPath, 0, strrpos($newPath,'.')) : $newPath); |
||||
$file_extension = (strrpos($newPath,'.')>0 ? substr($newPath, strrpos($newPath,'.'),10) : ''); |
||||
if (in_array($file_extension, $presentation_extension)) |
||||
{ |
||||
if ($debug > 0) error_log("converting $coursePath$newPath", 0); |
||||
/* creating output folder */ |
||||
$created_dir = create_unexisting_directory($_course,$user_id,0,NULL,$coursePath,$file_name); |
||||
|
||||
/* alow user of openoffice to write into the folder */ |
||||
// FIXME |
||||
chmod($coursePath.$created_dir, 0777); |
||||
|
||||
/* |
||||
* exec java application |
||||
* the parameters of the program are : |
||||
* - javacommand on this server ; |
||||
* - host where openoffice is running; |
||||
* - port with which openoffice is listening |
||||
* - file to convert |
||||
* - folder where put the slides |
||||
* - ftppassword if required |
||||
* The program fills $files with the list of slides created |
||||
*/ |
||||
/* building command line */ |
||||
$classpath = '-cp .:ridl.jar:js.jar:juh.jar:jurt.jar:jut.jar:java_uno.jar:java_uno_accessbridge.jar:edtftpj-1.5.2.jar:unoil.jar'; |
||||
if(strpos($_ENV['OS'],'Windows') !== false) |
||||
{ |
||||
$classpath = str_replace(':',';',$classpath); |
||||
} |
||||
$slide_width=640; |
||||
$slide_height=480; |
||||
|
||||
if(strpos($_ENV['OS'],'Windows') !== false) |
||||
{ |
||||
$cmd = 'cd '.str_replace('/','\\',api_get_path(SYS_PATH)).'main/inc/lib/ppt2png && java '.$classpath.' DocumentConverter '.api_get_setting('service_ppt2lp','host').' 2002'.' "'.$coursePath.$newPath.'" "'.$coursePath.$created_dir.'"'.' '.$slide_width.' '.$slide_height.' '.api_get_setting('service_ppt2lp','user').' '.api_get_setting('service_ppt2lp','ftp_password'); |
||||
} |
||||
else |
||||
{ |
||||
$cmd = 'cd '.api_get_path(SYS_PATH).'main/inc/lib/ppt2png && java '.$classpath.' DocumentConverter '.api_get_setting('service_ppt2lp','host').' 2002'.' "'.$coursePath.$newPath.'" "'.$coursePath.$created_dir.'"'.' '.$slide_width.' '.$slide_height.' '.api_get_setting('service_ppt2lp','user').' '.api_get_setting('service_ppt2lp','ftp_password'); |
||||
} |
||||
if ($debug>0) error_log($cmd,0); |
||||
|
||||
/* Exec */ |
||||
$shell = exec($cmd, $files, $return); // files: list of created files, return: shell return code |
||||
|
||||
/* Add Files */ |
||||
foreach($files as $f) |
||||
{ |
||||
$did = add_document($_course, $created_dir.'/'.$f, 'file', filesize($coursePath.$created_dir.'/'.$f), $f); |
||||
if ($did) |
||||
api_item_property_update($_course, TOOL_DOCUMENT, $did, 'DocumentAdded', $user_id, 0, NULL); |
||||
} |
||||
} |
||||
echo '<html><body><script language="javascript">setTimeout(1000,window.close());</script></body></html>'; |
||||
} |
||||
else if ($action == "service") |
||||
{ |
||||
/*==== List files ====*/ |
||||
if ($debug>0) error_log("sending file list",0); |
||||
$subaction = $_REQUEST["subaction"]; |
||||
$can_delete = (CourseManager::get_user_in_course_status($user_id, $cidReq) == COURSEMANAGER); |
||||
if ($subaction == "list") |
||||
{ |
||||
// FIXME: check security around $_REQUEST["cwd"] |
||||
$cwd = $_REQUEST["cwd"]; |
||||
$is_bellow_videoconf_upload_path = Security::check_abs_path($cwd,api_get_path(SYS_PATH)); |
||||
/* |
||||
// treat /.. |
||||
$nParent = 0; // the number of /.. into the url |
||||
while (substr($cwd, -3, 3) == "/..") |
||||
{ |
||||
// go to parent directory |
||||
$cwd= substr($cwd, 0, -3); |
||||
if (strlen($cwd) == 0) $cwd="/"; |
||||
$nParent++; |
||||
} |
||||
for (;$nParent >0; $nParent--){ |
||||
$cwd = (strrpos($cwd,'/')>-1 ? substr($cwd, 0, strrpos($cwd,'/')) : $cwd); |
||||
} |
||||
|
||||
if (strlen($cwd) == 0) $cwd="/"; |
||||
|
||||
// check if user can delete files. He must be manager and be inside /videoconf |
||||
$isBellowVideoConfUploadPath = (substr($cwd,0,strlen(VIDEOCONF_UPLOAD_PATH)) == VIDEOCONF_UPLOAD_PATH); |
||||
$canDelete = ($canDelete && $isBellowVideoConfUploadPath); |
||||
*/ |
||||
$can_delete = ($can_delete && $is_bellow_videoconf_upload_path); |
||||
|
||||
// get files list |
||||
$files = DocumentManager::get_all_document_data($_course, $cwd, 0, NULL, false); |
||||
printf("<dokeosobject><fileListMeta></fileListMeta><fileList>"); |
||||
printf("<folders>"); |
||||
foreach($files as $i) |
||||
{ |
||||
if ($i["filetype"] != "folder") |
||||
{ |
||||
continue; |
||||
} |
||||
else |
||||
{ |
||||
printf('<folder><path>%s</path><title>%s</title><canDelete>%s</canDelete></folder>', $i['path'],$i['title'],($can_delete?'true':'false')); |
||||
} |
||||
} |
||||
printf("</folders><files>"); |
||||
foreach($files as $i) { |
||||
$extension = (strrpos($i['path'],'.')>0 ? substr($i['path'], strrpos($i['path'],'.'),10) : ''); |
||||
if ($i["filetype"] != "file" || !in_array($extension, $image_extension)) |
||||
{ |
||||
continue; |
||||
} |
||||
else |
||||
{ |
||||
printf('<file><path>%s</path><title>%s</title><canDelete>%s</canDelete></file>', $i['path'],$i['title'],($can_delete?'true':'false')); |
||||
} |
||||
} |
||||
printf("</files><ppts>"); |
||||
printf("</ppts>"); |
||||
printf("</fileList></dokeosobject>"); |
||||
} |
||||
else if ($subaction == "delete") |
||||
{ |
||||
/*==== PERMISSION ====*/ |
||||
$permissions = CourseManager::get_user_in_course_status($user_id, $cidReq); |
||||
if ($permissions != COURSEMANAGER) |
||||
{ |
||||
if ($debug > 0) error_log("Upload from videoconf not allowed !!!",0); |
||||
die(); // this user is not allowed to add upload documents |
||||
} |
||||
/*==== DELETE ====*/ |
||||
$path = str_replace('../','',$_REQUEST["path"]); |
||||
if ((substr($path,0,strlen(VIDEOCONF_UPLOAD_PATH)) != VIDEOCONF_UPLOAD_PATH)) |
||||
{ |
||||
if ($debug >0 ) error_log("Delete from videoconf for "+$path+" NOT ALLOWED",0); |
||||
die(); |
||||
} |
||||
DocumentManager::delete_document($_course, $path, $coursePath); |
||||
echo "<result>OK</result>"; // We have to returns something to OpenLaszlo |
||||
} |
||||
} |
||||
else if ($action == "download") |
||||
{ |
||||
/*==== DOWNLOAD ====*/ |
||||
//check if the document is in the database |
||||
if(!DocumentManager::get_document_id($_course,$_REQUEST['file'])) |
||||
{ |
||||
//file not found! |
||||
if ($debug>0) error_log("404 ".$_REQUEST["file"]); |
||||
header("HTTP/1.0 404 Not Found"); |
||||
$error404 = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'; |
||||
$error404 .= '<html><head>'; |
||||
$error404 .= '<title>404 Not Found</title>'; |
||||
$error404 .= '</head><body>'; |
||||
$error404 .= '<h1>Not Found</h1>'; |
||||
$error404 .= '<p>The requested URL was not found on this server.</p>'; |
||||
$error404 .= '<hr>'; |
||||
$error404 .= '</body></html>'; |
||||
echo($error404); |
||||
exit; |
||||
} |
||||
$doc_url = str_replace('../','',$_REQUEST['file']); |
||||
if ($debug >0) error_log($doc_url); |
||||
$full_file_name = $coursePath.$doc_url; |
||||
DocumentManager::file_send_for_download($full_file_name,false); |
||||
exit; |
||||
} |
||||
?> |
@ -0,0 +1,83 @@ |
||||
<?php |
||||
/* See license terms in /dokeos_license.txt */ |
||||
/** |
||||
* This script gives information to the videoconference scripts (in OpenLaszlo) |
||||
* to use the right URL and ports for the videoconference. |
||||
*/ |
||||
require_once('../newscorm/learnpath.class.php'); |
||||
if($debug>0) error_log('New LP - Included learnpath',0); |
||||
require_once('../newscorm/learnpathItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included learnpathItem',0); |
||||
require_once('../newscorm/scorm.class.php'); |
||||
if($debug>0) error_log('New LP - Included scorm',0); |
||||
require_once('../newscorm/scormItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included scormItem',0); |
||||
require_once('../newscorm/aicc.class.php'); |
||||
if($debug>0) error_log('New LP - Included aicc',0); |
||||
require_once('../newscorm/aiccItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included aiccItem',0); |
||||
|
||||
include("../../main/inc/global.inc.php"); |
||||
api_block_anonymous_users(); |
||||
|
||||
//$confkey = "0123456789abcdef0123456789abcdef"; |
||||
$confkey = api_get_setting('service_visio','visio_pass'); |
||||
$challenge = api_generate_password(32); //generate a 32 characters-long challenge key |
||||
|
||||
require_once (api_get_path(LIBRARY_PATH)."course.lib.php"); |
||||
printf ('<?xml version="1.0" encoding="UTF-8" ?>');
|
||||
|
||||
printf('<dokeosobject>'); |
||||
|
||||
printf('<courseobject>'); |
||||
foreach ($_SESSION['_course'] as $key => $val) |
||||
printf('<%s>%s</%s>',$key,utf8_encode($val),$key); |
||||
printf('</courseobject>'); |
||||
|
||||
printf('<userobject>'); |
||||
foreach ($_SESSION['_user'] as $key => $val) if ($key != "auth_source") printf('<%s>%s</%s>',$key,utf8_encode($val),$key); |
||||
printf('<sid>%s</sid>', session_id()); |
||||
$isadmin =((CourseManager::get_user_in_course_status($_SESSION['_user']['user_id'], $_SESSION['_course']['sysCode']) == COURSEMANAGER)||api_is_platform_admin() ? "true" : "false"); |
||||
printf('<key>%s</key>', md5($confkey.$challenge)); |
||||
printf('<challenge>%s</challenge>', $challenge); |
||||
printf('<isUploadAllowed>%s</isUploadAllowed>', $isadmin); |
||||
printf('<canStartModerator>%s</canStartModerator>',($isadmin=='true' || $_SESSION["roomType"] == "conference")?'true':'false'); |
||||
printf('<mustStartModerator>%s</mustStartModerator>',($isadmin=='true' || $_SESSION["roomType"] == "conference")?'true':'false'); |
||||
printf('</userobject>'); |
||||
|
||||
printf('<config>'); |
||||
printf('<host>'.api_get_setting('service_visio','visio_host').'</host>'); |
||||
printf('<port>'.api_get_setting('service_visio','visio_port').'</port>'); |
||||
printf('</config>'); |
||||
|
||||
$path = preg_replace('/^([^:]*:\/\/)/','',api_get_path(WEB_PATH)); |
||||
$path = str_replace('/','_',$path); |
||||
printf('<roomConfig>'); |
||||
printf('<portal>%s</portal>', $path); |
||||
printf('<roomType>%s</roomType>', $_SESSION['roomType']); // fixme remove + |
||||
printf('</roomConfig>'); |
||||
|
||||
printf('<recorderparams>'); |
||||
|
||||
if(isset($_SESSION['oLP'])) |
||||
{ |
||||
switch ($_SESSION['whereami']) |
||||
{ |
||||
case 'lp/build' : |
||||
$student_view = 'false'; |
||||
break; |
||||
default : |
||||
$student_view = 'true'; |
||||
break; |
||||
} |
||||
$document_id = $_SESSION['oLP']->current; |
||||
} |
||||
|
||||
printf('<studentview>%s</studentview>',$student_view); |
||||
printf('<documentid>%s</documentid>',$document_id); |
||||
printf('</recorderparams>'); |
||||
printf('<languageobject>'); |
||||
printf(get_language_file_as_xml($language_interface)); |
||||
printf('</languageobject>'); |
||||
printf('</dokeosobject>'); |
||||
?> |
@ -0,0 +1,72 @@ |
||||
<?php |
||||
/* See license terms in /dokeos_license.txt */ |
||||
/** |
||||
* Library for language translation from Dokeos language files to XML for videoconference |
||||
* @uses main_api.lib.php for api_get_path() |
||||
*/ |
||||
/** |
||||
* This function reads a Dokeos language file and transforms it into XML, |
||||
* then returns the XML string to the caller. |
||||
*/ |
||||
function get_language_file_as_xml($language='english') |
||||
{ |
||||
$path = api_get_path(SYS_LANG_PATH).$language.'/'; |
||||
if(!is_dir($path) or !is_readable($path)) |
||||
{ |
||||
if($language != 'english') |
||||
{ |
||||
return get_language_file_as_xml('english'); |
||||
} |
||||
else |
||||
{ |
||||
return ''; |
||||
} |
||||
} |
||||
//error_log('Analysing path '.$path); |
||||
$file = $path.'videoconf.inc.php'; |
||||
if(!is_file($file) or !is_readable($file)) |
||||
{ |
||||
if($language != 'english') |
||||
{ |
||||
return get_language_file_as_xml('english'); |
||||
} |
||||
else |
||||
{ |
||||
return ''; |
||||
} |
||||
} |
||||
$convert = true; |
||||
if(substr($language,-7,7) == 'unicode') |
||||
{//do not convert if the language ends with 'unicode', which means it's in UTF-8 |
||||
$convert=false; |
||||
} |
||||
$list = file($file); |
||||
$xml = ''; |
||||
foreach ( $list as $line ) |
||||
{ |
||||
if(substr($line,0,1)=='$') |
||||
{ |
||||
$items = array(); |
||||
$match = preg_match('/^\$([^\s]*)\s*=\s*"(.*)";$/',$line,$items); |
||||
if($match) |
||||
{ |
||||
//todo: The following conversion should only happen for old language files (encoded in ISO-8859-1). |
||||
if($convert) |
||||
{ |
||||
$string = mb_convert_encoding($items[2],'UTF-8','ISO-8859-1'); |
||||
} |
||||
else |
||||
{ |
||||
$string = $items[2]; |
||||
} |
||||
$xml .= '<labelfield><labelid>'.$items[1].'</labelid><labelvalue>'.$string.'</labelvalue></labelfield>'."\n"; |
||||
} |
||||
} |
||||
} |
||||
if(empty($xml) && $language!='english') |
||||
{ |
||||
return get_language_file_as_xml('english'); |
||||
} |
||||
return $xml; |
||||
} |
||||
?> |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 254 B |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 441 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 978 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 362 B |
After Width: | Height: | Size: 323 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 367 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 987 B |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 254 B |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.5 KiB |