Jump to content

Reading Config File To Get Variables


dzhax

Recommended Posts

I am working on a dynamic image generator that needs certain variables for each user that uses it.I have the "static" dynamic image working fine. Meaning that it can display the variable data if inputed into the addressbar.I am trying to make this less of a hassel for my users. So when a user inputs the information to get the file, it will eventually save this information in a config.php file to be read later.When the user calls the image, instead of typing all of the variables into the address bar, they would only have to type there username (which is linked to the unique config.php file)What I am having trouble doing is calling the contents of the config.php file so they can be used as variables in the script.Ill show a breif example below:TEST URL:http://www.dzhax.com/server/hiscores/hiscore.php?name=dzhaxCurrent working version:

<?phpheader("Content-type: image/png");$dname = @$_GET['name'];$dip = 'dzhax.com';$dport = '80';$sigNum = '3';$fp = @fsockopen($dip, $dport, $errno, $errstr, 1);if (!$fp) {$string='Offline';} else {$string='Online';}$im = imagecreatefrompng("http://www.dzhax.com/images/dsig".$sigNum.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagestring($im, 3, 60, 47,$string, $orange);imagestring($im,3, 60, 29, $dport, $orange);imagestring($im,3, 60, 11, $dip, $orange);imagepng($im);imagedestroy($im);?>

Variables needed to be in config file:

$dip = 'dzhax.com';$dport = '80';$sigNum = '3';

With Config File Location: (This version didn't work)

<?phpheader("Content-type: image/png");$dname = @$_GET['name'];include('http://www.dzhax.com/server/hiscores/'.$dname.'/config.php');$fp = @fsockopen($dip, $dport, $errno, $errstr, 1);if (!$fp) {$string='Offline';} else {$string='Online';}$im = imagecreatefrompng("http://www.dzhax.com/images/dsig".$sigNum.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagestring($im, 3, 60, 47,$string, $orange);imagestring($im,3, 60, 29, $dport, $orange);imagestring($im,3, 60, 11, $dip, $orange);imagepng($im);imagedestroy($im);?>

Link to comment
Share on other sites

It's not going to work if you include via HTTP. If the file is on the web server, just include it using the local path. e.g.:include 'hiscores/' . $dname . '/config.php';When you include via HTTP the file gets executed and you end up including the output. That config file is probably blank if you open it in a browser, so you're including a blank file. If you need to include via HTTP it's probaby best to use something other than .php for the filename, like .inc. People will be able to see the code in the file, but that's what you need to do if you need to include a file on another server.Also, keep in mind the include file still needs the PHP tags in it.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...