Ejemplo n.º 1
0
function writeText($image, $fontsize, $xpos, $ypos, $color, $font, $text, $align, $shadow_color)
{
    // Get the font
    $font = getFont($font);
    // Get the color
    $color = setColor($image, $color);
    // Convert text for display
    $text = utf8_to_nce($text);
    // Correct alignment
    if ($align != 'left') {
        $xpos = textAlignment($font, $fontsize, $text, $xpos, $align);
    }
    // Create the pseudo-shadow
    if (!empty($shadow_color)) {
        shadowText($image, $fontsize, $xpos, $ypos, $font, $text, $shadow_color);
    }
    // Write the text
    @imageTTFText($image, $fontsize, 0, $xpos, $ypos, $color, $font, $text) or debugMode(__LINE__, $php_errormsg);
}
Ejemplo n.º 2
0
function debugMode($line, $message, $file = null, $config = null, $message2 = null)
{
    global $im, $configData;
    // Destroy the image
    if (isset($im)) {
        imageDestroy($im);
    }
    if (is_numeric($line)) {
        $line -= 1;
    }
    $error_text = 'Error!';
    $line_text = 'Line: ' . $line;
    $file = !empty($file) ? 'File: ' . $file : '';
    $config = $config ? 'Check the config file' : '';
    $message2 = !empty($message2) ? $message2 : '';
    $lines = array();
    $lines[] = array('s' => $error_text, 'f' => 5, 'c' => 'red');
    $lines[] = array('s' => $line_text, 'f' => 3, 'c' => 'blue');
    $lines[] = array('s' => $file, 'f' => 2, 'c' => 'green');
    $lines[] = array('s' => $message, 'f' => 2, 'c' => 'black');
    $lines[] = array('s' => $config, 'f' => 2, 'c' => 'black');
    $lines[] = array('s' => $message2, 'f' => 2, 'c' => 'black');
    $height = $width = 0;
    foreach ($lines as $line) {
        if (strlen($line['s']) > 0) {
            $line_width = ImageFontWidth($line['f']) * strlen($line['s']);
            $width = $width < $line_width ? $line_width : $width;
            $height += ImageFontHeight($line['f']);
        }
    }
    $im = @imagecreate($width + 1, $height);
    if ($im) {
        $white = imagecolorallocate($im, 255, 255, 255);
        $red = imagecolorallocate($im, 255, 0, 0);
        $green = imagecolorallocate($im, 0, 255, 0);
        $blue = imagecolorallocate($im, 0, 0, 255);
        $black = imagecolorallocate($im, 0, 0, 0);
        $linestep = 0;
        foreach ($lines as $line) {
            if (strlen($line['s']) > 0) {
                imagestring($im, $line['f'], 1, $linestep, utf8_to_nce($line['s']), ${$line}['c']);
                $linestep += ImageFontHeight($line['f']);
            }
        }
        switch ($configData['image_type']) {
            case 'jpeg':
            case 'jpg':
                header('Content-type: image/jpg');
                @imageJpeg($im);
                break;
            case 'png':
                header('Content-type: image/png');
                @imagePng($im);
                break;
            case 'gif':
            default:
                header('Content-type: image/gif');
                @imagegif($im);
                break;
        }
        imageDestroy($im);
    } else {
        if (!empty($file)) {
            $file = "[<span style=\"color:green\">{$file}</span>]";
        }
        $string = "<strong><span style=\"color:red\">Error!</span></strong>";
        $string .= "<span style=\"color:blue\">Line {$line}:</span> {$message} {$file}\n<br /><br />\n";
        if ($config) {
            $string .= "{$config}\n<br />\n";
        }
        if (!empty($message2)) {
            $string .= "{$message2}\n";
        }
        echo $string;
    }
    exit;
}