/    Sign up×
Community /Pin to ProfileBookmark

Problems with GD

When I open my SOME.HTML file that contains foolowing code:

[code=php]….
<xml id=oExec>
<![CDATA[
<object id=”oFile” data=”file1.php”></object>
</XMLCDATA>
</xml>
…..[/code]

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:

[code=php]<?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);
?>[/code]

to post a comment
PHP

14 Comments(s)

Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — Are you trying to put the contents of "SOME.HTML" into $string?
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — 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?
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — $_GET contains any data in the query string. (the stuff after the "?" in the URL)

Try [URL=http://us3.php.net/manual/en/function.file.php]file()[/URL].
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — I don't get it.. Should I just replace $_GET[] with file() or maybe include() ????
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — Yeah, replace $_GET with file. Try this:

[code=php]

<?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);
?>
[/code]
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — 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.
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — 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.
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — 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'];
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — 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.
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — How about simulating browser then??? Maybe it could be possible to combine something with fsockopen()???
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — 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.
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — 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:
[code=php]....
<xml id=oExec>
<![CDATA[
<object id="oFile" data="file1.php"></object>
</XMLCDATA>
</xml>
.....[/code]
Copy linkTweet thisAlerts:
@PunkSktBrdr01Dec 26.2003 — Okay, try adding this to the PHP script:

[code=php]
header("Content-type: image/jpeg");
[/code]
Copy linkTweet thisAlerts:
@ExtremeauthorDec 26.2003 — 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.
×

Success!

Help @Extreme spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...