Code:
<?
/*
# firma.php by Manuel #
# Copyright (c) 2005 by UltraDigital.it #
# http://www.ultradigital.it #
# Last update: 18/06/2005 #
# */
require_once('mainfile.php');
global $db, $prefix, $user, $multilingual;
$at = $db->sql_numrows($db->sql_query("SELECT sid FROM ".$prefix."_stories"));
$at = number_format($at, 0, ',', '.');
if ($multilingual == 1) {
$querylang = "WHERE planguage='$currentlang' AND artid='0'";
} else {
$querylang = "WHERE artid='0'";
}
$tmp = $db->sql_fetchrow($db->sql_query("SELECT pollID FROM ".$prefix."_poll_desc $querylang ORDER BY pollID DESC LIMIT 1"));
$pollID = intval($tmp['pollID']);
$tmp = $db->sql_fetchrow($db->sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID='$pollID'"));
$pollTitle = $tmp['pollTitle'];
$voters = number_format(intval($tmp['voters']), 0, ',', '.');
$ts = $db->sql_numrows($db->sql_query("SELECT pollID FROM ".$prefix."_poll_desc"));
$ts = number_format($ts, 0, ',', '.');
$tmp = $db->sql_fetchrow($db->sql_query("SELECT SUM(optionCount) as VotiTot FROM ".$prefix."_poll_data"));
$vt = $tmp['VotiTot']; $vt = number_format($vt, 0, ',', '.');
$tmp = $db->sql_fetchrow($db->sql_query("SELECT count FROM ".$prefix."_counter WHERE type='total' AND var='hits'", $db));
$pv = number_format($tmp['count'], 0, ',', '.');
$tot = $db->sql_numrows($db->sql_query("SELECT user_id FROM ".$prefix."_users")) - 1;
$tot = number_format($tot, 0, ',', '.');
$ris = $db->sql_query("SELECT * FROM ".$prefix."_session");
$nonline = $db->sql_numrows($ris);
$nonline = number_format($nonline, 0, ',', '.');
$nt = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_bbtopics"));
$np = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_bbposts"));
$tmp = $db->sql_query("SELECT topic_views, topic_replies, topic_vote FROM ".$prefix."_bbtopics");
while ($tr = $db->sql_fetchrow($tmp)) {
$nv += $tr['topic_views'];
$nr += $tr['topic_replies'];
}
$ns = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_bbvote_desc"));
$tmp = $db->sql_query("SELECT vote_result FROM ".$prefix."_bbvote_results");
while ($tr = $db->sql_fetchrow($tmp)) $nvo += $tr['vote_result'];
$pc = round(($nr*100)/$np,2); $nm = number_format($nm, 0, ',', '.');
$nm = $db->sql_numrows($db->sql_query("SELECT user_id FROM ".$prefix."_users")) - 1;
$nt = number_format($nt, 0, ',', '.'); $np = number_format($np, 0, ',', '.');
$nr = number_format($nr, 0, ',', '.'); $nv = number_format($nv, 0, ',', '.');
$ns = number_format($ns, 0, ',', '.'); $nvo = number_format($nvo, 0, ',', '.');
if (is_user($user)) {
if (!is_array($user)) {
$tmpuser = addslashes($user);
$tmpuser = base64_decode($tmpuser);
$tmpuser = explode(":", $tmpuser);
$uid = "$tmpuser[0]";
} else {
$uid = "$user[0]";
}
$uid = addslashes($uid);
$uid = intval($uid);
$sql = "SELECT username FROM ".$prefix."_users WHERE user_id='$uid'";
if ($result = $db->sql_query($sql)) {
$tmp = $db->sql_fetchrow($result);
$uname = $tmp[username];
$tmp = $db->sql_fetchrow($db->sql_query("SELECT user_rank FROM ".$prefix."_users WHERE username='$uname'", $db));
$urank = $tmp['user_rank'];
$tmp = $db->sql_fetchrow($db->sql_query("SELECT rank_title FROM ".$prefix."_bbranks WHERE rank_id='$urank'", $db));
$tipo = $tmp['rank_title'];
} else {
$uname = ""; $tipo = "Anonimo";
}
} else {
$uname = ""; $tipo = "Anonimo";
}
$nf = $db->sql_numrows($db->sql_query("select * from ".$prefix."_downloads_downloads"));
$tmp = $db->sql_query("select hits from ".$prefix."_downloads_downloads");
while (list($hits) = sql_fetch_row($tmp, $db)) $dw += $hits;
$tmp = $db->sql_query("select sum(filesize*hits) as serv from ".$prefix."_downloads_downloads");
while (list($serv) = sql_fetch_row($tmp)) $served = $serv;
$gb = 1024*1024*1024; $mb = 1024*1024; $kb = 1024;
if ($served >= $gb){
$tr = sprintf ("%01.2f",$served/$gb) . " Gb";
} elseif ($served >= $mb) {
$tr = sprintf ("%01.2f",$served/$mb) . " Mb";
} elseif ($served >= $kb) {
$tr = sprintf ("%01.2f",$served/$kb) . " Kb";
} else{
$tr = $served . " Bytes";
}
$nf = number_format($nf, 0, ',', '.'); $dw = number_format($dw, 0, ',', '.');
$tmp = $db->sql_fetchrow($db->sql_query("SELECT count FROM ".$prefix."_counter WHERE type='firma' AND var='imp'", $db));
$if = $tmp['count'] + 1;
$db->sql_query("UPDATE ".$prefix."_counter SET count = '$if' WHERE type='firma' AND var='imp'", $db);
$if = number_format($if, 0, ',', '.');
$image = imagecreatefrompng("images/firma.png");
$colore_titolo = imagecolorallocate($image, 255, 255, 255);
$colore_subtit = imagecolorallocate($image, 0, 255, 0);
$titolo = "ULTRADIGITAL - LIVESTATS!"; $subtit = "<< $uname - $tipo >>";
$dim_titolo = 6; $font_titolo = 'titolo.ttf';
$dim_subtit = 6; $font_subtit = 'default.ttf';
header("Content-type: image/png");
$arr_null = array(0);
imagefttext($image, $dim_titolo, 0, 60, 10, $colore_titolo, $font_titolo, $titolo, $arr_null);
//imagestring($image, $font, 60, 2, $titolo, $colore_titolo);
if ($uname <> "") imagefttext($image, $dim_subtit, 0, 220, 10, $colore_subtit, $font_subtit, $subtit, $arr_null);
//imagestring($image, $dim_subtit, 260, 2, $subtit, $colore_subtit);
$colore_testo = imagecolorallocate($image, 77, 174, 241);
$dim_testo = 6; $font_testo = 'default.ttf';
$riga0 = "Membri: $nm - OnLine Adesso: $nonline - Visite: $pv - Articoli: $at";
imagefttext($image, $dim_testo, 0, 60, 25, $colore_testo, $font_testo, $riga0, $arr_null);
$riga1 = "Sondaggio corrente: '$pollTitle' - Voti: $voters";
imagefttext($image, $dim_testo, 0, 60, 35, $colore_testo, $font_testo, $riga1, $arr_null);
$riga2 = "Sondaggi: $ts - Voti Totali: $vt - Nei Forums: $ns - Voti Forums: $nvo";
imagefttext($image, $dim_testo, 0, 60, 45, $colore_testo, $font_testo, $riga2, $arr_null);
$riga3 = "Topics: $nt - Posts: $np - Risposte: $nr ($pc%) - Letture: $nv";
imagefttext($image, $dim_testo, 0, 60, 55, $colore_testo, $font_testo, $riga3, $arr_null);
$riga4 = "Files: $nf - Downloads: $dw - Traffico: $tr";
imagefttext($image, $dim_testo, 0, 60, 65, $colore_testo, $font_testo, $riga4, $arr_null);
// imagestring($image, $dim_testo, 60, 17, "Topics $nt | Posts $np | Risposte $nr ($pc%) | Letture $nv", $colore_testo);
// imagestring($image, $dim_testo, 60, 31, "Membri $nm | OnLine Adesso $nonline | Visite $pv | Sondaggi $ns | Voti $nvo", $colore_testo);
// imagestring($image, $dim_testo, 60, 45, "Files $nf | Downloads $dw | Traffico $tr", $colore_testo);
imagefttext($image, $dim_testo, 90, 454, 49, $colore_testo, $font_testo, 'FIRMA N.', $arr_null);
$dim = imageftbbox($dim_testo, 0, $font_testo, $if, $arr_null);
$x = 468 - $dim[3] - 6; $y = 30 + $dim[2] / 2;
imagefttext($image, $dim_testo, 90, $x, $y, $colore_testo, $font_testo, $if, $arr_null);
imagepng($image);
imagedestroy($image);
?>
|