0 Members and 1 Guest are viewing this topic.

*

staan

  • *
  • 35
  • Stan, 29 Yo - France
  • osDate Version: osDateEvo v1.3
LAGS : Too much picture dir on server !
« on: February 08, 2019, 12:55:13 PM »
Hello,

I found a big problem in the last Osdate version, and same probleme in Osdate Evo.

FTP is limited to show 10 000 directory (other are hide, and you cant save them to your backup).

Some global hoster become very laggy when PHP try to get the image, and too much directory are write into the TEMP/USERIMAGES and TEMP/CACHE/USERIMAGES

So, I'll share with you a little hack for big website (my website with Osdate was born in 2010, and now there is around 40 000 user on my website!)

It's very simple, you just have to create a subdirectory .

For example, userid with id 93 , userid with id 10504 and user with id 21501 will be like :


USERIMAGES\0\93
USERIMAGES\10000\10504
USERIMAGES\20000\21501

As you can see, we just split userid and group them by 10 000 ID.

This is my short code for create it :


if ($userid >= 0 && $userid < 10000) {

$repid = '0';
}
elseif ($userid >= 10000 && $userid < 20000) {
$repid = '10000';
}
elseif ($userid >= 20000 && $userid < 30000) {
$repid = '20000';
}   
elseif ($userid >= 30000 && $userid < 40000) {
$repid = '30000';
}
elseif ($userid >= 40000 && $userid < 50000) {
$repid = '40000';
}
elseif ($userid >= 50000 && $userid < 60000) {
$repid = '50000';
}
elseif ($userid >= 60000 && $userid < 70000) {
$repid = '60000';
}
elseif ($userid >= 70000 && $userid < 80000) {
$repid = '70000';
}
elseif ($userid >= 80000 && $userid < 90000) {
$repid = '80000';
}
elseif ($userid >= 90000 && $userid < 100000) {
$repid = '90000';
}
elseif ($userid >= 100000 && $userid < 110000) {
$repid = '100000';
}


Then everywhere where you can find "USER_IMAGE_DIR" or "USER_IMAGE_CACHE_DIR" you have to add the $repid var like

OLD :  $cachefiles = USER_IMAGE_CACHE_DIR.$userid.'/';
NEW :  $cachefiles = USER_IMAGE_CACHE_DIR.$repid.'/'.$userid.'/';

OLD : $userimagedir=USER_IMAGE_DIR.$userid.'/';
NEW : $userimagedir=USER_IMAGE_DIR.$repid.'/'.$userid.'/';

If you have some question, ask me !

(sorry for my little english, i'm french)

*

Pharg

  • *****
  • 3,272
    • OsDateFourm
  • osDate Version: osDateEvo v1.3
Re: LAGS : Too much picture dir on server !
« Reply #1 on: February 08, 2019, 07:49:03 PM »
Hi staan,

Thanks for sharing.
Regards,
Pharg ( Phill )

Don't Personal Message me unless it's about a sensitive matter!!

REMEMBER TO ALWAYS BACKUP BEFORE MAKING ANY CHANGES!!

osDateEvo v1.3 | PHP: 5.3.42 & PHP: 7.2 | MySQL: 5.5.35