Скрипт создания изображения. Он создает правильное изображение на английском языке, но на арабском языке возникает проблема кодирования. - PullRequest
0 голосов
/ 08 октября 2018

Создает правильное изображение на английском языке, но на арабском языке появляется проблема кодирования

Это php-код для создания изображения в скрипте. Анонимная обратная связь на этом сайте попробуйте https://saraha.100elkholy.com

        // image creation script
    header("Content-type: image/png");
    $im             = imagecreatefrompng('./themes/core/images/'.$this->settings->admin_theme.'.png');
    $white          = imagecolorallocate($im, 255, 255, 255);
    $black          = imagecolorallocate($im, 0, 0, 0);
    $text           = wordwrap(str_replace('<br />', ' ', $result->message), 150, "\n", true);
    $domain         = ucfirst(get_domain());
    $font           = './themes/core/fonts/Cairo-Black.ttf';
    $image_width    = imagesx($im);  
    $image_height   = imagesy($im);
    $text_box       = imagettfbbox(26, 0, $font, $text);
    $text_width     = $text_box[2] - $text_box[0];
    $text_height    = $text_box[7] - $text_box[1];
    $x              = ($image_width / 2) - ($text_width / 2);
    $y              = ($image_height / 2) - ($text_height / 2);
    $y              = (strlen($text) > 150 && strlen($text) < 360) ? $y/2 : (strlen($text) >= 360 ? $y/3 : $y);
    $file           = time().rand(1,988);
    $filename       = $file.'.png';

    imagettftext($im, 26, 0, $x,  $y,    $black, $font, $text );
    imagettftext($im, 16, 0, 60,  632,    $white, $font, $domain);

    if (!is_dir('./upload/users/shares/'.$this->user['id']))
        mkdir('./upload/users/shares/'.$this->user['id'], 0777, TRUE);

    imagepng($im, './upload/users/shares/'.$this->user['id'].'/'.$filename);
    imagedestroy($im);

    echo json_encode(array(
                        'flag'      => 1, 
                        'msg'       => sprintf(lang('alert_report_success'), lang('menu_message')),
                        'type'      => 'success',
                        'url'       => site_url('og/'.$this->user['id'].'/'.$file),
                    ));exit;
}

/**
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...