Jump to content

GD Generation


phat_hip_prog

Recommended Posts

Hi, i'm playing with a small cms. It uses mod_rewrite to redirect to an index, however in certain circumstances I want to generate images using gd, needing to send appropiate headers first i've put a clause in very early, even before 'session_start()'. Instead a function which generates and returns an image is called. However all I get is the filename, why?

 

I've tested the image creation in files outside the cms and it works fine... But inside the cms it borks!

 

Here's how i've simplified it for tests:

index.html

<?php
include("monkey/inc.php");

$iret = inc_init();
if($iret != -1)
{
print inc_draw();	//	generate page
}
?>

 

Here's the 'inc_init()' and 'draw_img()' functions:

monkey/inc.php

function draw_img()
{
header("Content-type: image/jpeg");
$w = 230;	$h = 45;
$im = ImageCreate($w, $h);
$red = ImageColorAllocate($im, 255, 50, 50);
//	DRAW BACKGROUND
ImageFilledRectangle($im, 0, 0, $w, $h, $red);
//	OUTPUT TO BROWSER
ImageJpeg($im);
}

function inc_init()
{
//	CHECK IMAGE GENERATOR OVERRIDE
if (isset($_GET["page"]))
{
	$p = $_GET["page"];
	$lret = split_url($p);	//	dir, dirs, fn, bn, ext
	if ($lret['dirs'][0] == "img")
	{
		draw_img();
		return -1;
	}
}

//	LOAD MODS
inc_load_mods();
...
...

 

Can anyone tell me why all i'm getting is the filename printed to screen?

 

Cheers!

 

Link to comment
https://forums.phpfreaks.com/topic/45309-gd-generation/
Share on other sites

Because of the way i've got mod_rewrite setup I can't just call the file. I've tried calling the file using both 'include()' and 'eval()', both ways give the same result. But from what I see theres no real need to have them in a seperate file?

 

any more for any more?

Link to comment
https://forums.phpfreaks.com/topic/45309-gd-generation/#findComment-220017
Share on other sites

It is called like that (<img src='img/myimage.php'>), then mod_rewrite translates it to 'index.html?page=img/myimage.php', $page is then split and checked, when discoved it's 'img', either the file is included or the function called. This is all done as if it was in a file on it's own?

Link to comment
https://forums.phpfreaks.com/topic/45309-gd-generation/#findComment-220032
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.