@ -66,35 +66,35 @@ if ($dir[0] == '.') {
}
if ($dir[0] != '/') {
$dir = '/' . $dir;
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
//groups //TODO: clean
if (!empty($groupId)) {
$interbreadcrumb[] = array(
"url" => "../group/group_space.php?" . api_get_cidreq(),
"url" => "../group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace')
);
$group = GroupManager:: get_group_properties($groupId);
$path = explode('/', $dir);
if ('/' . $path[1] != $group['directory']) {
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = array(
"url" => "./document.php?curdirpath=" . urlencode($dir) . "& " . api_get_cidreq(),
"url" => "./document.php?curdirpath=".urlencode($dir)."& ".api_get_cidreq(),
"name" => get_lang('Documents')
);
@ -130,11 +130,11 @@ $array_len = count($dir_array);
$dir_acum = '';
for ($i = 0; $i < $array_len; $i++) {
$url_dir = 'document.php?& curdirpath=' . $dir_acum . $dir_array[$i];
$url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
//Max char 80
$url_to_who = cut($dir_array[$i], 80);
$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
$dir_acum .= $dir_array[$i] . '/';
$dir_acum .= $dir_array[$i].'/';
}
$service = isset($_GET['service']) ? $_GET['service'] : 'pediaphon';
@ -142,15 +142,15 @@ $service = isset($_GET['service']) ? $_GET['service'] : 'pediaphon';
Display:: display_header($nameTools, 'Doc');
echo '< div class = "actions" > ';
echo '< a href = "document.php?id=' . $document_id . '" > ' .
Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '',
ICON_SIZE_MEDIUM) . '< / a > ';
echo '< a href = "document.php?id='.$document_id.'" > '.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '',
ICON_SIZE_MEDIUM).'< / a > ';
echo '< a href = "create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=pediaphon" > ' .
Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM) . '< / a > ';
echo '< a href = "create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=pediaphon" > '.
Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM).'< / a > ';
echo '< a href = "create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=google" > ' .
Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM) . '< / a > ';
echo '< a href = "create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=google" > '.
Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM).'< / a > ';
echo '< / div > ';
?>
<!-- javascript and styles for textareaCounter -->
@ -215,14 +215,14 @@ $options = $options_pedia = array();
$selected_language = null;
while ($row = Database::fetch_array($result_select)) {
$options[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
$options[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))) {
$options_pedia[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
$options_pedia[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
}
}
if ($service == 'google') {
$selected_language = api_get_language_isocode();//lang default is the course language
$selected_language = api_get_language_isocode(); //lang default is the course language
$form = new FormValidator('form1', 'post', api_get_self().'?'.api_get_cidreq(), '', array('id' => 'form1'));
$form->addHeader(get_lang('HelpText2Audio'));
@ -274,16 +274,16 @@ if ($service == 'pediaphon') {
var voices = new Array()
<!-- German -->
voices['de'] = ["<?php echo get_lang ( 'Female' ) . ' (de1)' ; ?> |de1", "<?php echo get_lang ( 'Male' ) . ' (de2)' ; ?> |de2", "<?php echo get_lang ( 'Female' ) . ' (de3)' ; ?> |de3", "<?php echo get_lang ( 'Male' ) . ' (de4)' ; ?> |de4", "<?php echo get_lang ( 'Female' ) . ' (de5)' ; ?> |de5", "<?php echo get_lang ( 'Male' ) . ' (de6)' ; ?> |de6", "<?php echo get_lang ( 'Female' ) . ' (de7)' ; ?> |de7", "<?php echo get_lang ( 'Female' ) . ' (de8 HQ)' ; ?> |de8"]
voices['de'] = ["<?php echo get_lang ( 'Female' ) . ' (de1)' ; ?> |de1", "<?php echo get_lang ( 'Male' ) . ' (de2)' ; ?> |de2", "<?php echo get_lang ( 'Female' ) . ' (de3)' ; ?> |de3", "<?php echo get_lang ( 'Male' ) . ' (de4)' ; ?> |de4", "<?php echo get_lang ( 'Female' ) . ' (de5)' ; ?> |de5", "<?php echo get_lang ( 'Male' ) . ' (de6)' ; ?> |de6", "<?php echo get_lang ( 'Female' ) . ' (de7)' ; ?> |de7", "<?php echo get_lang ( 'Female' ) . ' (de8 HQ)' ; ?> |de8"]
<!-- English -->
voices['en'] = ["<?php echo get_lang ( 'Male' ) . ' (en1)' ; ?> |en1", "<?php echo get_lang ( 'Male' ) . ' (en2 HQ)' ; ?> |en2", "<?php echo get_lang ( 'Female' ) . ' (us1)' ; ?> |us1", "<?php echo get_lang ( 'Male' ) . ' (us2)' ; ?> |us2", "<?php echo get_lang ( 'Male' ) . ' (us3)' ; ?> |us3", "<?php echo get_lang ( 'Female' ) . '(us4 HQ)' ; ?> |us4"]
voices['en'] = ["<?php echo get_lang ( 'Male' ) . ' (en1)' ; ?> |en1", "<?php echo get_lang ( 'Male' ) . ' (en2 HQ)' ; ?> |en2", "<?php echo get_lang ( 'Female' ) . ' (us1)' ; ?> |us1", "<?php echo get_lang ( 'Male' ) . ' (us2)' ; ?> |us2", "<?php echo get_lang ( 'Male' ) . ' (us3)' ; ?> |us3", "<?php echo get_lang ( 'Female' ) . '(us4 HQ)' ; ?> |us4"]
<!-- Spanish -->
voices['es'] = ["<?php echo get_lang ( 'Male' ) . ' (es5 HQ)' ; ?> |es5"]
voices['es'] = ["<?php echo get_lang ( 'Male' ) . ' (es5 HQ)' ; ?> |es5"]
<!-- French -->
voices['fr'] = ["<?php echo get_lang ( 'Female' ) . ' (fr8 HQ)' ; ?> |fr8"]
voices['fr'] = ["<?php echo get_lang ( 'Female' ) . ' (fr8 HQ)' ; ?> |fr8"]
$(document).ready(function () {
$('.lang').on('change', function () {
@ -314,11 +314,11 @@ Display:: display_footer();
*/
function downloadMP3_google($filepath, $dir)
{
$location = 'create_audio.php?' . api_get_cidreq() . '& id=' . intval($_POST['id']) . ' &service=google';
$location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).' &service=google';
//security
if (!isset($_POST['lang']) & & !isset($_POST['text']) & & !isset($_POST['title']) & & !isset($filepath) & & !isset($dir)) {
echo '< script > window . location . href = "' . $location . '" < / script > ';
echo '< script > window . location . href = "'.$location.'" < / script > ';
return;
}
@ -363,7 +363,7 @@ function downloadMP3_google($filepath, $dir)
$proxySettings = api_get_configuration_value('proxy_settings');
$key = api_get_configuration_value('translate_app_google_key');
$url = "https://www.googleapis.com/language/translate/v2?key=$key& " . $clean_lang . "& target=$clean_lang& q=" . urlencode($clean_text) . "";
$url = "https://www.googleapis.com/language/translate/v2?key=$key&".$clean_lang."&target=$clean_lang&q=".urlencode($clean_text)."";
if (empty($proxySettings)) {
$content = file_get_contents($url);
@ -383,7 +383,7 @@ function downloadMP3_google($filepath, $dir)
$relativeUrlPath = $dir;
$doc_id = add_document(
$_course,
$relativeUrlPath . $audio_filename,
$relativeUrlPath.$audio_filename,
'file',
filesize($documentPath),
$audio_title
@ -402,7 +402,7 @@ function downloadMP3_google($filepath, $dir)
);
Display::display_confirmation_message(get_lang('DocumentCreated'));
//return to location
echo '< script > window . location . href = "' . $location . '" < / script > ';
echo '< script > window . location . href = "'.$location.'" < / script > ';
}
/**
@ -415,10 +415,10 @@ function downloadMP3_google($filepath, $dir)
*/
function downloadMP3_pediaphon($filepath, $dir)
{
$location = 'create_audio.php?' . api_get_cidreq() . '& id=' . intval($_POST['id']) . ' &service=pediaphon';
$location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).' &service=pediaphon';
//security
if (!isset($_POST['lang']) & & !isset($_POST['text']) & & !isset($_POST['title']) & & !isset($filepath) & & !isset($dir)) {
echo '< script > window . location . href = "' . $location . '" < / script > ';
echo '< script > window . location . href = "'.$location.'" < / script > ';
return;
}
$_course = api_get_course_info();
@ -428,33 +428,33 @@ function downloadMP3_pediaphon($filepath, $dir)
$clean_text = trim($_POST['text']);
$clean_voices = Security::remove_XSS($_POST['voices']);
if (empty($clean_title) || empty($clean_text) || empty($clean_voices)) {
echo '< script > window . location . href = "' . $location . '" < / script > ';
echo '< script > window . location . href = "'.$location.'" < / script > ';
return;
}
$clean_title = Security::remove_XSS($clean_title);
$clean_title = Database::escape_string($clean_title);
$clean_title = str_replace(' ', '_', $clean_title);//compound file names
$clean_title = str_replace(' ', '_', $clean_title); //compound file names
$clean_text = Security::remove_XSS($clean_text);
$clean_lang = Security::remove_XSS($_POST['lang']);
$clean_speed = Security::remove_XSS($_POST['speed']);
$extension = 'mp3';
$audio_filename = $clean_title . '.' . $extension;
$audio_filename = $clean_title.'.'.$extension;
$audio_title = str_replace('_', ' ', $clean_title);
//prevent duplicates
if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
$i = 1;
while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
$i++;
}
$audio_filename = $clean_title . '_' . $i . '.' . $extension;
$audio_title = $clean_title . '_' . $i . '.' . $extension;
$audio_filename = $clean_title.'_'.$i.'.'.$extension;
$audio_title = $clean_title.'_'.$i.'.'.$extension;
$audio_title = str_replace('_', ' ', $audio_title);
}
$documentPath = $filepath . '/' . $audio_filename;
$documentPath = $filepath.'/'.$audio_filename;
$clean_text = api_replace_dangerous_char($clean_text);
//adding the file
@ -463,17 +463,17 @@ function downloadMP3_pediaphon($filepath, $dir)
$url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
$find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/';
} else {
$url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_' . $clean_lang . '.cgi';//en, es, fr
$find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/' . $clean_lang . '\/(.*)\.mp3\"/';
$url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi'; //en, es, fr
$find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/';
}
$data = "stimme=" . $clean_voices . "& inputtext=" . $clean_text . "& speed=" . $clean_speed . " &go=speak";
$data = "stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed." &go=speak";
$opts = array(
'http' =>
array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
"Content-Length: " . strlen($data) . "\r\n",
"Content-Length: ".strlen($data)."\r\n",
'content' => $data
)
);
@ -517,5 +517,5 @@ function downloadMP3_pediaphon($filepath, $dir)
);
Display::display_confirmation_message(get_lang('DocumentCreated'));
//return to location
echo '< script > window . location . href = "' . $location . '" < / script > ';
echo '< script > window . location . href = "'.$location.'" < / script > ';
}