Discuz is already outdated, but many older users are still using it. There's no other way but to solve the problem ourselves.
The problem is: even after enabling mandatory profile picture upload, and uploading a profile picture, the system still says that I do not have permission to post and asks me to upload a profile picture.
The main reason lies in the communication with uc_server. uc_server shows that the communication is successful, but this is not necessarily accurate (the reasons are very complex). Moreover, I enabled HTTPS, which makes the cause even more complicated.
First, perform the HTTPS update for UC Browser:Resolving UCENTER communication failures after implementing HTTPS on Discuz
The problem then arose with retrieving the avatar. In uc_client/client.php, you can find...
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
Add the following:
$matches['port'] = !empty($matches['port'])&&$scheme=='https' ? $matches['port'] : 443;
Then find:
if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) { Modified to:
if($port=='443'){ $temp = 'ssl://'; }else{ $temp = 'http://'; } if(!$fp = @fsocketopen($temp.($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) { The problem should be fixed by now. If it's not, try the following methods:
Find it in function uc_check_avatar
$res = uc_fopen2($url, 500000, ”, ”, TRUE, UC_IP, 20);
Revised to:
$res = trim(uc_fopen2(UC_API.'/avatar.php?uid=$uid&check_file_exists=1'));
The original call was very unstable, sometimes it wouldn't return 1, but the new one directly opens the URL and returns the value.
This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:
Original author:Jake Tao,source:"Solve the issue of Discuz 3.4's forced avatar upload function not working (it keeps prompting for an avatar upload)"
Comment list (3 comments)
Please add to pull request https://gitee.com/ComsenzDiscuz/DiscuzX/pulls
@c:Okay~~ Is the community under maintenance now?
Excellent, thank you very much for sharing.