|
|
|
@ -186,10 +186,9 @@ $(document).ready(function(){ |
|
|
|
|
</style> |
|
|
|
|
<div id="textareaCallBack"></div> |
|
|
|
|
<?php |
|
|
|
|
if(Security::remove_XSS($_POST['text2voice_mode'])=='google'){ |
|
|
|
|
if (Security::remove_XSS($_POST['text2voice_mode'])=='google') { |
|
|
|
|
downloadMP3_google($filepath, $dir); |
|
|
|
|
} |
|
|
|
|
elseif(Security::remove_XSS($_POST['text2voice_mode'])=='pediaphon'){ |
|
|
|
|
} elseif (Security::remove_XSS($_POST['text2voice_mode']) == 'pediaphon') { |
|
|
|
|
downloadMP3_pediaphon($filepath, $dir); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -311,13 +310,10 @@ $(document).ready(function(){ |
|
|
|
|
$result_select = Database::query($sql_select); |
|
|
|
|
echo '<select name="lang" id="select">'; |
|
|
|
|
while ($row = Database::fetch_array($result_select)) { |
|
|
|
|
|
|
|
|
|
if (in_array($row['isocode'], array('ca', 'en', 'es', 'hi', 'it', 'pt'))){ |
|
|
|
|
|
|
|
|
|
if (in_array($row['isocode'], array('ca', 'en', 'es', 'hi', 'it', 'pt'))) { |
|
|
|
|
if (api_get_setting('platformLanguage')==$row['english_name']){ |
|
|
|
|
echo '<option value="'.$row['isocode'].'" selected="selected">'.$row['original_name'].' ('.$row['english_name'].')</option>'; |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
} else { |
|
|
|
|
echo '<option value="'.$row['isocode'].'">'.$row['original_name'].' ('.$row['english_name'].')</option>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -356,7 +352,8 @@ Display :: display_footer(); |
|
|
|
|
* @author Juan Carlos Raña Trabado <herodoto@telefonica.net> |
|
|
|
|
* @version january 2011, chamilo 1.8.8 |
|
|
|
|
*/ |
|
|
|
|
function downloadMP3_google($filepath, $dir) { |
|
|
|
|
function downloadMP3_google($filepath, $dir) |
|
|
|
|
{ |
|
|
|
|
$location='create_audio.php?'.api_get_cidreq().'&id='.Security::remove_XSS($_POST['document_id']).'&dt2a=google'; |
|
|
|
|
|
|
|
|
|
//security |
|
|
|
@ -469,9 +466,6 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
|
|
|
|
|
$documentPath = $filepath.'/'.$audio_filename; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//prev for a fine unicode, borrowed from main api TODO:clean |
|
|
|
|
// Safe replacements for some non-letter characters (whitout blank spaces) |
|
|
|
|
$search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%'); |
|
|
|
@ -488,47 +482,45 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
|
|
|
|
|
//adding the file |
|
|
|
|
|
|
|
|
|
if ($clean_lang=='de') { |
|
|
|
|
$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\"/'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($clean_lang=='de'){ |
|
|
|
|
$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\"/'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$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' => $data |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$context = stream_context_create($opts); |
|
|
|
|
// Download the whole HTML page |
|
|
|
|
$previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); |
|
|
|
|
|
|
|
|
|
//extract the audio file path |
|
|
|
|
$search_source=preg_match($find_t2v, $previous_returntext2voice, $hits); |
|
|
|
|
$souce_end=substr($hits[0], 0,-1); |
|
|
|
|
//download file |
|
|
|
|
$returntext2voice = file_get_contents($souce_end); |
|
|
|
|
//save file |
|
|
|
|
$f = @file_put_contents($documentPath, $returntext2voice); |
|
|
|
|
if ($f === false && !empty($php_errormsg)) { |
|
|
|
|
error_log($php_errormsg); |
|
|
|
|
} |
|
|
|
|
//add document to database |
|
|
|
|
$current_session_id = api_get_session_id(); |
|
|
|
|
$groupId = $_SESSION['_gid']; |
|
|
|
|
$file_size = filesize($documentPath); |
|
|
|
|
$relativeUrlPath=$dir; |
|
|
|
|
$doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); |
|
|
|
|
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
|
|
|
Display::display_confirmation_message(get_lang('DocumentCreated')); |
|
|
|
|
$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' => $data |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$context = stream_context_create($opts); |
|
|
|
|
// Download the whole HTML page |
|
|
|
|
$previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); |
|
|
|
|
|
|
|
|
|
//extract the audio file path |
|
|
|
|
$search_source=preg_match($find_t2v, $previous_returntext2voice, $hits); |
|
|
|
|
$souce_end=substr($hits[0], 0,-1); |
|
|
|
|
//download file |
|
|
|
|
$returntext2voice = file_get_contents($souce_end); |
|
|
|
|
//save file |
|
|
|
|
$f = @file_put_contents($documentPath, $returntext2voice); |
|
|
|
|
if ($f === false && !empty($php_errormsg)) { |
|
|
|
|
error_log($php_errormsg); |
|
|
|
|
} |
|
|
|
|
//add document to database |
|
|
|
|
$current_session_id = api_get_session_id(); |
|
|
|
|
$groupId = $_SESSION['_gid']; |
|
|
|
|
$file_size = filesize($documentPath); |
|
|
|
|
$relativeUrlPath=$dir; |
|
|
|
|
$doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); |
|
|
|
|
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
|
|
|
Display::display_confirmation_message(get_lang('DocumentCreated')); |
|
|
|
|
//return to location |
|
|
|
|
echo '<script>window.location.href="'.$location.'"</script>'; |
|
|
|
|
} |
|
|
|
|