Fixing bug when uploading files with extensions like image.PNG see #3372

skala
Julio Montoya 14 years ago
parent 71979e00b9
commit a57c8c0151
  1. 6
      main/exercice/hotspot_admin.inc.php
  2. 35
      main/exercice/question.class.php
  3. 1
      main/inc/lib/usermanager.lib.php

@ -957,16 +957,14 @@ if ($modifyAnswers) {
</td>
</tr>
<tr>
<td colspan="2" valign="top" style="border:1px solid #ccc;border-top:none">
<td colspan="2" valign="top" style="border-top:none">
<script type="text/javascript">
<!--
// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
<?php
$swf_loaded = $answerType==HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450;
$height = 450;
?>
// Check to see if the version meets the requirements for playback
if (hasReqestedVersion) { // if we've detected an acceptable version

@ -1,14 +1,13 @@
<?php // $Id: question.class.php 22257 2009-07-20 17:50:09Z juliomontoya $
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the Question class.
* @package chamilo.exercise
* @author Olivier Brouckaert
* @version $Id: question.class.php 22257 2009-07-20 17:50:09Z juliomontoya $
* @author Julio Montoya <gugli100@gmail.com> lot of bug fixes
*/
if(!class_exists('Question')):
// answer types
@ -356,22 +355,20 @@ abstract class Question
}
// if the question has got an ID
if($this->id) {
$extension = pathinfo($PictureName, PATHINFO_EXTENSION);
$this->picture='quiz-'.$this->id.'.jpg';
if($extension == 'gif' || $extension == 'png') {
$o_img = new image($Picture);
$o_img->send_image('JPG',$picturePath.'/'.$this->picture);
$document_id = add_document($this->course, '/images/'.$this->picture, 'file', filesize($picturePath.'/'.$this->picture),$this->picture);
}
else
{
move_uploaded_file($Picture,$picturePath.'/'.$this->picture)?true:false;
}
$document_id = add_document($this->course, '/images/'.$this->picture, 'file', filesize($picturePath.'/'.$this->picture),$this->picture);
if($document_id) {
return api_item_property_update($this->course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', api_get_user_id);
}
if ($this->id) {
$extension = pathinfo($PictureName, PATHINFO_EXTENSION);
$this->picture ='quiz-'.$this->id.'.jpg';
require_once api_get_path(LIBRARY_PATH).'image.lib.php';
$detected = array('GIF','JPEG','JPG','PNG');
if (in_array($extension, $detected)) {
$o_img = new image($Picture);
$o_img->send_image('JPG',$picturePath.'/'.$this->picture);
$document_id = add_document($this->course, '/images/'.$this->picture, 'file', filesize($picturePath.'/'.$this->picture),$this->picture);
if ($document_id) {
return api_item_property_update($this->course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', api_get_user_id);
}
}
}
return false;

@ -2276,6 +2276,7 @@ class UserManager
*
* @param string file picture
* @param int size in pixels
* @todo move this function somewhere else image.lib?
* @return obj image object
*/
public static function resize_picture($file, $max_size_for_picture) {

Loading…
Cancel
Save