From 74d50d0f1f87fcdeb540fd1e643482bc98a5012f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Fri, 20 Jul 2012 22:44:48 +0200 Subject: [PATCH] Bug #4788 fix load a nanogong audio file from documents --- main/document/document.php | 9 ++++++++ main/document/showinframes.php | 38 ++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/main/document/document.php b/main/document/document.php index 989e3cea08..2841c56b3d 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -46,9 +46,18 @@ require_once $lib_path . 'fileDisplay.lib.php'; api_protect_course_script(true); +//erase temp nanogons' audio +if(isset($_SESSION['temp_audio_nanogong']) && !empty($_SESSION['temp_audio_nanogong'])) { + unlink($_SESSION['temp_audio_nanogong']); +} + //Removing sessions unset($_SESSION['draw_dir']); unset($_SESSION['paint_dir']); +unset($_SESSION['temp_audio_nanogong']); + + + // Create directory certificates DocumentManager::create_directory_certificate_in_course(api_get_course_id()); diff --git a/main/document/showinframes.php b/main/document/showinframes.php index a58dd94212..344a9ba383 100644 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -290,12 +290,46 @@ if ($jplayer_supported) { if ($is_nanogong_available){ echo '
'; echo '
'; - echo ''; - echo ''; + + //make temp audio + $temp_folder=api_get_path(SYS_ARCHIVE_PATH).'temp/audio'; + if (!file_exists($temp_folder)) { + @mkdir($temp_folder, api_get_permissions_for_new_directories(), true); + } + + //make htaccess with allow from all, and file index.html into temp/audio + $htaccess=api_get_path(SYS_ARCHIVE_PATH).'temp/audio/.htacess'; + if (!file_exists($htaccess)) { + $htaccess_content="order deny,allow\r\nallow from all"; + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/audio/.htaccess', 'w'); + if ($fp) { + fwrite($fp, $htaccess_content); + fclose($fp); + } + } + + //encript temp name file + $name_crip=sha1(uniqid());//encript + $findext= explode(".", $file); + $extension= $findext[count($findext)-1]; + $file_crip=$name_crip.'.'.$extension; + + //copy file to temp/audio directory + $from_sys=$file_url_sys; + $to_sys=api_get_path(SYS_ARCHIVE_PATH).'temp/audio/'.$file_crip; + copy($from_sys, $to_sys); + + //get file from tmp directory + $to_url=api_get_path(WEB_ARCHIVE_PATH).'temp/audio/'.$file_crip; + echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; + + //erase temp file in tmp directory when return to documents + $_SESSION['temp_audio_nanogong']=$to_sys; echo ''; }