osDate Forum - osDate Dating Script

osDateEvo => osDateEvo Bugs => Topic started by: Benoitc64 on April 25, 2018, 06:46:27 AM

Title: Autogenprofile error
Post by: Benoitc64 on April 25, 2018, 06:46:27 AM
First thanks for the good job for osdate evo 1.3 in php 7.

When we generate profile with photo stored in directory instead of database
I have this error:  See the attachment

and i found that the directory is empty and the image profiles is generate at the wrong place
so I search and found why

i modifiy the
libs/modOsDate/modplugins.php

line 2902

    function modWriteImageToFile($img, $userid, $picno, $file) {
        if ($file == '') {
            $filename= time().$userid.$picno.'.jpg';
        } else {
            $filename = $file;
        }

        $img = imagecreatefromstring($img);
      mkdir(USER_IMAGE_DIR.$userid,0700);
        imagejpeg($img, USER_IMAGE_DIR.$userid.'/'.$filename);
        return ($filename);
    }

and that's work
Title: Re: Autogenprofile error
Post by: Pharg on April 25, 2018, 07:09:07 AM
Hi Benoitc64,

Thanks for that fix, will check it out soon.

Is this in PHP 7 or PHP 5.6?
Title: Re: Autogenprofile error
Post by: Pharg on April 25, 2018, 11:38:35 AM
Hi Benoitc64,

Works great but going to have to find another method to this fix, as it now gives PHP Warnings in the error log  :(

PHP Warning:  mkdir(): File exists in /domain.com/libs/modOsDate/modPlugin.php on line 2902
Title: Re: Autogenprofile error
Post by: Benoitc64 on April 25, 2018, 05:17:42 PM
but we are on the right way. I will check it to make it better.
Title: Re: Autogenprofile error
Post by: Benoitc64 on April 28, 2018, 05:53:05 AM
Hi

I've correct the script.
Sorry that's was my mistake.

In libs/modOsDate/modPlugins.php

find the function modWriteImageToFile and replace by

Code: [Select]
    function modWriteImageToFile($img, $userid, $picno, $file) {
        if ($file == '') {
            $filename= time().$userid.$picno.'.jpg';
        } else {
            $filename = $file;
        }

        $img = imagecreatefromstring($img);
        $directory = USER_IMAGE_DIR . $userid;
        if (!is_dir($directory)){
             mkdir($directory);
         }



        imagejpeg($img, USER_IMAGE_DIR . $userid . '/' . $filename);
imagedestroy($img);
        return ($filename);
    }


Title: Re: Autogenprofile error
Post by: Pharg on April 28, 2018, 07:01:47 AM
Hi Benoitc64,


Thanks I will look at sometime later.

You can find further code and how it was done in the snaps_functions.php if we still get warnings in PHP 7