Files
nexusphp/public/image.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2020-12-26 01:42:23 +08:00
<?php
2021-01-13 19:32:26 +08:00
require_once("../include/bittorrent.php");
2020-12-26 01:42:23 +08:00
dbconn();
$action = $_GET['action'];
$imagehash = $_GET['imagehash'];
if($action == "regimage")
{
$query = "SELECT * FROM regimages WHERE imagehash= ".sqlesc($imagehash);
$sql = sql_query($query);
$regimage = mysql_fetch_array($sql);
$imagestring = $regimage['imagestring'];
2020-12-29 03:02:34 +08:00
$space = $newstring = '';
2020-12-26 01:42:23 +08:00
for($i=0;$i<strlen($imagestring);$i++)
{
$newstring .= $space.$imagestring[$i];
$space = " ";
}
$imagestring = $newstring;
2022-04-01 23:13:42 +08:00
2020-12-26 01:42:23 +08:00
if(function_exists("imagecreatefrompng"))
{
$fontwidth = imageFontWidth(5);
$fontheight = imageFontHeight(5);
$textwidth = $fontwidth*strlen($imagestring);
$textheight = $fontheight;
2022-04-01 23:13:42 +08:00
2020-12-26 01:42:23 +08:00
$randimg = rand(1, 5);
$im = imagecreatefrompng("pic/regimages/reg".$randimg.".png");
2022-04-01 23:13:42 +08:00
2020-12-26 01:42:23 +08:00
$imgheight = 40;
$imgwidth = 150;
2022-04-01 23:13:42 +08:00
$textposh = floor(($imgwidth-$textwidth)/2);
$textposv = floor(($imgheight-$textheight)/2);
2020-12-26 01:42:23 +08:00
$dots = $imgheight*$imgwidth/35;
2022-04-01 23:13:42 +08:00
$gd = imagecreatetruecolor($imgwidth, $imgheight);
2020-12-26 01:42:23 +08:00
for($i=1;$i<=$dots;$i++)
{
2022-04-01 23:13:42 +08:00
imagesetpixel($im, rand(0, $imgwidth), rand(0, $imgheight), imagecolorallocate($gd, rand(0, 255), rand(0, 255), rand(0, 255)));
2020-12-26 01:42:23 +08:00
}
2022-04-01 23:13:42 +08:00
2020-12-26 01:42:23 +08:00
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, $textposh, $textposv, $imagestring, $textcolor);
2022-04-01 23:13:42 +08:00
2020-12-26 01:42:23 +08:00
// output the image
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
exit;
}
else
{
header("Location: pic/clear.gif");
}
}
else
{
die('invalid action');
}
?>