Jump to content

Text On an image help please


jnerotrix

Recommended Posts

hello I have a script that takes ip's and puts them into a text file

php gets the ip checks if its already in the file ip.txt if it is not in the file it adds the ip to ip.txt on a new line then another script counts the number of lines.

 

I need the Number of Lines Counted to show up on the image heres all the codes so far

 

------------

Files:

visits.php

track.php

ip.txt

index.php

 

and heres the image i need the text to show up on

track.png

I need the Text to Show up Next to Total Visits but i dont know how

 

Visit.php

<?php
include('track.php');
$file = "ip.txt";
  $users = count(file($file));

$string = $users;
$im = imagecreatefrompng('./track.png');

$textColor = imagecolorallocate ($im, 255, 255, 255);
imagestring($im, 5, 0, 0, "$string", $textColor); 


header ("Content-type: image/png");
imagepng($im);

?>

 

track.php

<?php

$ip = $_SERVER['REMOTE_ADDR'];

$myFile = "ip.txt"; 

$lines = file($myFile); 
$lines = array_map('trim',$lines);

if(!in_array($ip,$lines)){
   $fh = fopen($myFile, 'a') or die("can't open file");
   $stringData = "$ip\r\n";
   fwrite($fh, $stringData);
   fclose($fh);
}
?>

 

then theres ip.txt

 

and

 

index.php

<center>
<br><br><br>
<h1> Numbmer Of Visited Users Test
<br>

<?php include ('visits.php'); ?>
</center>

 

All I see on the page is

 

The Image "http://joeyelectric.comuf.com/search/index.php" Could Not Be Displayed Because it Contains Errors

 

Please Help Thanks,

jnerotrix

 

Link to comment
https://forums.phpfreaks.com/topic/147414-text-on-an-image-help-please/
Share on other sites

Try reading up here, I didn't read it myself but it should give the info. you are looking for

 

http://blog.ninedays.org/2007/11/29/writing-text-to-images-with-php/

http://discomoose.org/2005/10/19/write-text-on-to-an-existing-png-image-using-php/

 

Hope this helps some

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.