����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /var/www/html/api-truyentranh/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/api-truyentranh/includes/class_text_to_image.php
<?php
/**
 * phpTextToImage class
 * This class converts text to image in PHP
 *
 * @author    Legend Blogs
 * @link    https://www.legendblogs.com
 */
class phpTextToImage {
    private $image;
    /**
     * Create image from text
     * @param string text to convert into image
     * @param string textColor
     * @param string backgroundColor
     * @param int font size of text
     * @param int width of the image
     * @param int height of the image
     */
    function createImage($text, $textColor = '#f8f9fa', $backgroundColor = '#012713', $fontSize = 90, $imgWidth = 300, $imgHeight = 300) {
        //text font path
        $font = '/var/www/html/nhg_portal/classes/text_to_image/Roboto-Bold.ttf';
        //create the image
        $this->image = imagecreatetruecolor($imgWidth, $imgHeight);
        $colorCode = array('#ffffff','#db3236', '#f4c20d', '#3cba54', '#4c53cc', '#56aad8', '#61c4a8');

        if ($backgroundColor == '') {
            /* select random color */
            $backgroundColor = $this->hexToRGB($colorCode[rand(0, count($colorCode) - 1)]);
        } else {
            /* select background color as provided */
            $backgroundColor = $this->hexToRGB($backgroundColor);
        }

        if ($textColor == '') {
            /* select random color */
            $textColor = $this->hexToRGB($colorCode[rand(0, count($colorCode) - 1)]);
        } else {
            /* select background color as provided */
            $textColor = $this->hexToRGB($colorCode[rand(0, count($colorCode) - 1)]);
        }
        $textColor = imagecolorallocate($this->image, $textColor['r'], $textColor['g'], $textColor['b']);
        $backgroundColor = imagecolorallocate($this->image, $backgroundColor['r'], $backgroundColor['g'], $backgroundColor['b']);
        imagefilledrectangle($this->image, 0, 0, $imgWidth - 1, $imgHeight - 1, $backgroundColor);
        //break lines
        $splitText = explode("\\n", $text);
        $lines = count($splitText);
        $angle = 0;
        foreach ($splitText as $txt) {
            $textBox = imagettfbbox($fontSize, $angle, $font, $txt);
            $textWidth = abs(max($textBox[2], $textBox[4]));
            $textHeight = abs(max($textBox[5], $textBox[7]));
            $x = (imagesx($this->image) - $textWidth) / 2;
            $y = (imagesy($this->image) + $textHeight) / 2;
            $lines = $lines - 1;
            //add the text
            imagettftext($this->image, $fontSize, $angle, $x, $y, $textColor, $font, $txt);
        }
        return true;
    }
    /* function to convert hex value to rgb array */
    protected function hexToRGB($colour) {
        if ($colour[0] == '#') {
            $colour = substr($colour, 1);
        }
        if (strlen($colour) == 6) {
            list( $r, $g, $b ) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
        } elseif (strlen($colour) == 3) {
            list( $r, $g, $b ) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
        } else {
            return false;
        }
        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);
        return array('r' => $r, 'g' => $g, 'b' => $b);
    }
    /**
     * Display image
     */
    function showImage() {
        header('Content-Type: image/png');
        return @imagepng($this->image);
    }
    /**
     * Save image as png format
     * @param string file name to save
     * @param string location to save image file
     */
    function saveAsPng($fileName = 'text-image', $location = '') {
        $fileName = $fileName . ".png";
        $fileName = !empty($location) ? $location . $fileName : $fileName;
        return @imagepng($this->image, $fileName);
    }
    /**
     * Save image as jpg format
     * @param string file name to save
     * @param string location to save image file
     */
    function saveAsJpg($fileName = 'text-image', $location = '') {
        $fileName = $fileName . ".jpg";
        $fileName = !empty($location) ? $location . $fileName : $fileName;
        return @imagejpeg($this->image, $fileName);
    }
}
?>

ZeroDay Forums Mini