Feature #5346 check space documents size of images and audios before save

skala
Juan Carlos Raña 12 years ago
parent 9854c51a03
commit a689ad487c
  1. 38
      main/document/create_audio.php
  2. 16
      main/document/save_pixlr.php
  3. 25
      main/inc/lib/jpegcam/webcam_receiver.php
  4. 5
      main/inc/lib/nanogong/receiver.php
  5. 13
      main/inc/lib/svg-edit/extensions/filesave.php
  6. 13
      main/inc/lib/wami-recorder/record_document.php

@ -199,6 +199,7 @@ $(document).ready(function(){
$options = $options_pedia = array();
$selected_language = null;
$options_pedia['defaultmessage'] = get_lang('FirstSelectALanguage');//need read before platform languages
while ($row = Database::fetch_array($result_select)) {
if (api_get_setting('platformLanguage')==$row['english_name']) {
@ -238,8 +239,8 @@ $(document).ready(function(){
if(Security::remove_XSS($_GET['dt2a'])=='pediaphon'){
//lang default is a default message
$selected_language = "defaultmessage";
$options_pedia['defaultmessage'] =get_lang('FirstSelectALanguage');
$options['defaultmessage'] =get_lang('FirstSelectALanguage');
$options['defaultmessage'] = get_lang('FirstSelectALanguage');
echo '<div>';
$form = new FormValidator('form2', 'post', null, '', array('id' => 'form2'));
@ -413,9 +414,25 @@ function downloadMP3_google($filepath, $dir) {
// Replacing remaining dangerous non-letter characters.
$clean_text = str_replace($search, $replace, $filename);
$returntext2voice=file_get_contents("http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text)."");
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $returntext2voice);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//adding the file
//add new file to disk
file_put_contents($documentPath, file_get_contents("http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text).""));
file_put_contents($documentPath, $returntext2voice);
//add document to database
$current_session_id = api_get_session_id();
$groupId=$_SESSION['_gid'];
@ -520,7 +537,20 @@ function downloadMP3_pediaphon($filepath, $dir){
$search_source=preg_match($find_t2v, $previous_returntext2voice, $hits);
$souce_end=substr($hits[0], 0,-1);
$returntext2voice = file_get_contents($souce_end);
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $returntext2voice);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//save file
file_put_contents($documentPath, $returntext2voice);

@ -110,6 +110,22 @@ if(strpos($current_mime, 'image')===false) {
}
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $contents);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//path, file and title
$paintFileName = $filename.'.'.$extension;
$title = $title.'.'.$extension;

@ -77,20 +77,19 @@ if (!$content) {
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $content);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $content);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");

@ -57,6 +57,11 @@ if ($nano_user_id!= api_get_user_id() || api_get_user_id()==0 || $nano_user_id==
//Do not use here check Fileinfo method because return: text/plain
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($_FILES['voicefile']['tmp_name']), DocumentManager::get_course_quota())) {
die(get_lang('UplNotEnoughSpace'));
}
if (!file_exists($documentPath)){
//add document to disk
move_uploaded_file($_FILES['voicefile']['tmp_name'], $documentPath);

@ -110,6 +110,19 @@ if (file_exists($saveDir.'/'.$filename.$i.'.'.$extension) && $currentTool=='docu
}
$documentPath = $saveDir.'/'.$drawFileName;
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $contents);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//add new document to disk
file_put_contents( $documentPath, $contents );

@ -65,6 +65,19 @@ if (file_exists($saveDir.'/'.$waminame_noex.'.'.$ext)){
$documentPath = $saveDir.'/'.$waminame_to_save;
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $content);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");

Loading…
Cancel
Save