<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Creare immagine png dinamica con stat forum]]></title><description><![CDATA[<p dir="auto">Come da titolo...</p>
<p dir="auto">Non so quasi niente di php ma ho trovato uno script per creare (in teoria) un'immagine dinamica con le statistiche del forum che si aggiorni, diciamo, in tempo reale...</p>
<p dir="auto">Lo script è questo:</p>
<pre><code>&lt;?php

global $lang, $cache;

$lang-&gt;load('stats');

$stats = $cache-&gt;read('stats');

$img_width = 468;
$img_height = 30;

$border_color_outer = '#000000';
$border_color_inner = '#ffffff';

$gradient_start = '#035488';
$gradient_end = '#026cb1';

$color_top = '#ffffff';
$color_bottom = '#fff6bf';

$custom_text = false;

$im = imagecreatetruecolor($img_width, $img_height);

$gradient_start = hex2rgb($gradient_start);
$gradient_end = hex2rgb($gradient_end);

for($i = 0; $i &lt; $img_height; $i++)
{
	$line_color = imagecolorallocate($im, max(0, $gradient_start['r']-((($gradient_end['r']-$gradient_start['r'])/-$img_height)*$i)), max(0, $gradient_start['g']-((($gradient_end['g']-$gradient_start['g'])/-$img_height)*$i)), max(0, $gradient_start['b']-((($gradient_end['b']-$gradient_start['b'])/-$img_height)*$i)));
	imageline($im, 0, $i, $img_width, $i, $line_color);
}

if($border_color_outer)
{
	$border_color_outer = hex2rgb($border_color_outer);
	$border_color_outer = imagecolorallocate($im, $border_color_outer['r'], $border_color_outer['g'], $border_color_outer['b']);
	imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color_outer);
}

if($border_color_inner)
{
	$border_color_inner = hex2rgb($border_color_inner);
	$border_color_inner = imagecolorallocate($im, $border_color_inner['r'], $border_color_inner['g'], $border_color_inner['b']);
	imagerectangle($im, 1, 1, $img_width-2, $img_height-2, $border_color_inner);
}

$color_top = hex2rgb($color_top);
$color_top = imagecolorallocate($im, $color_top['r'], $color_top['g'], $color_top['b']);

$color_bottom = hex2rgb($color_bottom);
$color_bottom = imagecolorallocate($im, $color_bottom['r'], $color_bottom['g'], $color_bottom['b']);

$string_top = $mybb-&gt;settings['bbname'];

if($custom_text)
{
	$string_top .= ' - '.$custom_text;
}
else
{
	$string_top .= ' - '.$mybb-&gt;settings['bburl'];
}

$string_bottom_users = $lang-&gt;members.' '.$stats['numusers'];
$string_bottom_posts = $lang-&gt;posts.' '.$stats['numposts'];
$string_bottom_threads = $lang-&gt;threads.' '.$stats['numthreads'];

$padding_lr = 10;

imagestring($im, 3, $padding_lr, 2, utf8_decode($string_top), $color_top);
imagestring($im, 2, $padding_lr, 14, utf8_decode($string_bottom_users), $color_bottom);
imagestring($im, 2, intval(($img_width-2*$padding_lr)/3), 14, utf8_decode($string_bottom_posts), $color_bottom);
imagestring($im, 2, intval(($img_width-2*$padding_lr)/3*2), 14, utf8_decode($string_bottom_threads), $color_bottom);

header('Content-type: image/png');
header('Content-disposition: inline; filename="'.$mybb-&gt;settings['bbname'].'.png"');

imagepng($im);
imagedestroy($im);

function hex2rgb($hex)
{
	$hex = ltrim($hex, '#');
	$rgb['r'] = hexdec(substr($hex, 0, 2));
	$rgb['g'] = hexdec(substr($hex, 2, 2));
	$rgb['b'] = hexdec(substr($hex, 4));
	return $rgb;
}

?&gt;
</code></pre>
<p dir="auto">io l'ho copiato in un file.php e l'ho inserito nella root del forum, ma quando provo a chiamarlo mi restituisce questo errore:<br />
<strong>Fatal error: Call to a member function on a non-object in /membri/nerdnest/forum/sig.php on line 5</strong></p>
<p dir="auto">il forum è su piattaforma mybb</p>
]]></description><link>https://dev.connect.gt/topic/122789/creare-immagine-png-dinamica-con-stat-forum</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 06:35:52 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/122789.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Mar 2010 16:53:32 GMT</pubDate><ttl>60</ttl></channel></rss>