<?php
$im = imagecreatetruecolor(1, 1);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Use header to indicate file type —— For this example: image/jpeg
header('Content-Type: image/jpeg');
// Output image
imagejpeg($im);
// Free Memory
imagedestroy($im);
?>
Each link should be distinguished by some variables, for example, we can use "GET" to pass in different variables. Each varialbe can be assigned to different users!
<?php
//We can pass in 'Get' variable to make each link unique in order to track accordingly
if(isset($_GET['mail'])){
$key= htmlspecialchars($_GET['mail']);
}
//Below to line's function is to log device inforamtion and their ip address
$agent=$_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
//Option1:we can use a SQL database to log details
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error){
die("连接失败: " . $conn->connect_error);
}
//Option2:we can also use a txt file to log data alternatively
$myfile = fopen("feed.txt", "a+") or die("Unable to open file!");
fwrite($myfile, $rich);
fclose($myfile);
//After the log of data, we can use the code from part1 to display image afterward
?>
<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>