You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2012-04-12 13:07:06

christian.michallek
Member
Registered: 2012-04-12
Posts: 2

Human ressource plugin is broken with php 5.4

The Installation fails with a white page and following log error  on glpi .80.7

apache2: PHP Fatal error:  Cannot re-assign auto-global variable _FILES in /usr/share/glpi/plugins/resources/inc/resource.class.php on line 435

i got it working with an older System and php 5.3

greetings Christian

Offline

#2 2012-04-13 16:30:54

yonyon
Member
Registered: 2012-03-28
Posts: 16

Re: Human ressource plugin is broken with php 5.4

Hi,

I have the same error.

For solve this, edit your file "resource.class.php on line 435" and change $_FILES by $files

my code before edit (with error) :

function addPhoto($_FILES,$class)
   {
      $uploadedfile= $_FILES['picture']['tmp_name'];
      $src = imagecreatefromjpeg($uploadedfile);
      
      list($width,$height)=getimagesize($uploadedfile);

      $newwidth=75;
      $newheight=($height/$width)*$newwidth;
      $tmp=imagecreatetruecolor($newwidth,$newheight);

      imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
      $ext = strtolower(substr(strrchr($_FILES['picture']['name'], '.'), 1));
      $resources_name = str_replace(" ","", strtolower($class->fields["name"]));
      $resources_firstname = str_replace(" ","", strtolower($class->fields["firstname"]));
      $name = $resources_name."_".$resources_firstname.".".$ext;

      $name = $this->replace_accents($name);

      $tmpfile = GLPI_DOC_DIR."/_uploads/". $name;
      $filename = GLPI_PLUGIN_DOC_DIR."/resources/". $name;
      
      imagejpeg($tmp,$tmpfile,100);
      
      rename($tmpfile,$filename);
      //Document::renameForce($tmpfile, $filename);
      
      imagedestroy($src);
      imagedestroy($tmp);

      return $name;
   }

and after edit (without error)

function addPhoto($files,$class)
   {
      $uploadedfile= $files['picture']['tmp_name'];
      $src = imagecreatefromjpeg($uploadedfile);
      
      list($width,$height)=getimagesize($uploadedfile);

      $newwidth=75;
      $newheight=($height/$width)*$newwidth;
      $tmp=imagecreatetruecolor($newwidth,$newheight);

      imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
      $ext = strtolower(substr(strrchr($files['picture']['name'], '.'), 1));
      $resources_name = str_replace(" ","", strtolower($class->fields["name"]));
      $resources_firstname = str_replace(" ","", strtolower($class->fields["firstname"]));
      $name = $resources_name."_".$resources_firstname.".".$ext;

      $name = $this->replace_accents($name);

      $tmpfile = GLPI_DOC_DIR."/_uploads/". $name;
      $filename = GLPI_PLUGIN_DOC_DIR."/resources/". $name;
      
      imagejpeg($tmp,$tmpfile,100);
      
      rename($tmpfile,$filename);
      //Document::renameForce($tmpfile, $filename);
      
      imagedestroy($src);
      imagedestroy($tmp);

      return $name;
   }

beware, this code is take from V 01.8.0

Offline

#3 2012-04-14 14:53:30

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: Human ressource plugin is broken with php 5.4


Xavier Caillaud
Blog GLPI Infotel

Offline

#4 2012-04-16 11:56:03

christian.michallek
Member
Registered: 2012-04-12
Posts: 2

Re: Human ressource plugin is broken with php 5.4

thank you,

the plugin installs now.

greetings

Christian

Offline

Board footer

Powered by FluxBB