Click to See Complete Forum and Search --> : Problems with GD
Extreme
12-25-2003, 07:39 PM
When I open my SOME.HTML file that contains foolowing code:
....
<xml id=oExec>
<![CDATA[
<object id="oFile" data="file1.php"></object>
</XMLCDATA>
</xml>
.....
then everything works OK, and it then opens file1.php like it says in a script.. But when I call this SOME.HTML file using GD scripts, then it won't work.. It looks as though it doesn't open my html file... I use the following GD script to call it:
<?php
$string = $_GET['SOME.HTML'];
$im = imagecreatefrompng("viper.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagejpeg($im);
imagedestroy($im);
?>
PunkSktBrdr01
12-25-2003, 08:41 PM
Are you trying to put the contents of "SOME.HTML" into $string?
Extreme
12-25-2003, 08:50 PM
Well, yes.. But I thought it would be OK, if I would just call it with GET like in my example. Apperently not. How do I putt content of my HTML file into string?
PunkSktBrdr01
12-25-2003, 08:54 PM
$_GET contains any data in the query string. (the stuff after the "?" in the URL)
Try file() (http://us3.php.net/manual/en/function.file.php).
Extreme
12-25-2003, 08:58 PM
I don't get it.. Should I just replace $_GET[] with file() or maybe include() ????
PunkSktBrdr01
12-25-2003, 09:05 PM
Yeah, replace $_GET with file. Try this:
<?php
$file = file("SOME.HTML");
$string = "";
foreach ($file as $line) {
$string .= $line;
}
$im = imagecreatefrompng("viper.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagejpeg($im);
imagedestroy($im);
?>
Extreme
12-25-2003, 09:13 PM
Nope.. It just shows content(source) of my HTML file over the picture(viper.png)... I need this HTML to be executed like I visited it directly, and not over GD...
For ex. When the HTML is viewed normally then there are all sort of scripts there that are executed there, like JavaScripts etc.
PunkSktBrdr01
12-25-2003, 10:37 PM
Well, I don't think you can execute the scripts within PHP. The file() function simply reads the file into an array. It doesn't execute it, or anything like that.
Extreme
12-26-2003, 07:21 AM
Well, it worked parcially with include(), but it didn't showed picture then.. HTML was executed and result showed ,but in the bottom of the page was sme garbled text what I believe to be my picture appearing as a text..
You know how there was that simple example where you could show IP over the picture... Showing IP is just some code, and it is executed.. There was 12.12.12.12 on top of the picture, and not $string = $_SERVER['REMOTE_ADDR'];
My code is HTML code, but I don't think it changes stuf that much...So why this code can't be executed and then result showed over picture like it is the case with $_SERVER['REMOTE_ADDR'];
PunkSktBrdr01
12-26-2003, 10:36 AM
The HTML isn't executed because PHP isn't a browser. It only reads the text in the file. include()ing the file will just put its contents into the PHP script. If you're trying to get a screenshot of the HTML page, you'll have to use the "print screen" key and upload the image.
Extreme
12-26-2003, 10:51 AM
How about simulating browser then??? Maybe it could be possible to combine something with fsockopen()???
PunkSktBrdr01
12-26-2003, 10:58 AM
I've never done anything with sockets, but I don't think that would be possible. You'd need to remotely open a browser, have it render the page, and then take a screenshot and send it to the PHP script. This would require C/C++, as far as I know. You could, however, parse the file with PHP, and use some of the image functions to create a representation of the page. That would be extremely difficult, though. I think you'll just have to take a screenshot and upload it.
Extreme
12-26-2003, 11:05 AM
Ah, well.. The point is that I don't need screenshot at all.. I just need to call my file1.php using this script as it is important to call it via this way:
....
<xml id=oExec>
<![CDATA[
<object id="oFile" data="file1.php"></object>
</XMLCDATA>
</xml>
.....
PunkSktBrdr01
12-26-2003, 11:14 AM
Okay, try adding this to the PHP script:
header("Content-type: image/jpeg");
Extreme
12-26-2003, 11:20 AM
Yes, it was allways there.. I just didn't post it here. The problem still lies in $string I guess. Oh well, we tryed. Thanks.