Вход Регистрация
Файл: top/graphic_tel.php
Строк: 61
<?php
// by -=ШАХТЕР=- (waphp.ru - качай только тут)
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
include 
"config.php";



//проверка  ввода id
if (empty($_GET['uid'])) exit;
$uid=check($_GET['uid']);
// проверка существования учетной записи
$result = mysql_query("SELECT link FROM top_users WHERE uid=$uid");
$row=mysql_fetch_row($result);
if (empty(
$row)) exit;

$week_day = date("w");
$today = date("Ymd");
// параметры диаграммы
$r = 45;
$cx = 50;
$cy = 50;
$g1 = 0;
$g2 = 0;
// параметры сносок
$x_leg = 10;
$y_leg = 110;
$w_h = 5;
$step = 10;

// созданире изображения
$img = ImageCreate(100,235);
$colorWhite = imageColorAllocate($img, 255,255,255);
$colorBlack = imageColorAllocate($img, 0,0,0);
$colorGrey = imageColorAllocate($img, 180,180,180);
for (
$i=0;$i<6;$i++){
    
imageArc($img, $cx, $cy, 2*$r+$i, 2*$r+$i, 0, 360, imageColorAllocate($img, 180+($i*10),180+($i*10),180+($i*10)));
}
imageFill($img, $cx, $cy, $colorGrey);

$color = array(
    
imageColorAllocate($img, 237,27,35),
    
imageColorAllocate($img, 255,172,72),
    
imageColorAllocate($img, 56,181,73),
    
imageColorAllocate($img, 0,174,239),
    
imageColorAllocate($img, 255,0,255),
    
imageColorAllocate($img, 255,242,0),
    
imageColorAllocate($img, 0,0,255),
    
imageColorAllocate($img, 166,124,81),
    
imageColorAllocate($img, 183,183,183),
    
imageColorAllocate($img, 0,255,0),
    
imageColorAllocate($img, 255,0,0),
    
imageColorAllocate($img, 0,90,100)
);

$tel = array(
    
"Siemens",
    
"Nokia",
    
"Samsung",
    
"Motorola",
    
"LG",
    
"Sagem",
    
"SonyEricsson",
    
"Alcatel",
    
"Sharp",
    
"Pantech",
    
"Panasonic",
    
"Other"
);

// данные телов
$result = mysql_query("SELECT `Siemens`,`Nokia`,`Samsung`,`Motorola`,`LG`,`Sagem`,`SonyEricsson`,`Alcatel`,`Sharp`,`Pantech`,`Panasonic`,`Other` FROM `weeks` WHERE `date`=$today AND `day_week`=$week_day AND `uid`=$uid LIMIT 1");
$tel_data = mysql_fetch_row($result);
if (empty(
$tel_data)) exit;

$result = mysql_query("SELECT `Siemens`+`Nokia`+`Samsung`+`Motorola`+`LG`+`Sagem`+`SonyEricsson`+`Alcatel`+`Sharp`+`Pantech`+`Panasonic`+`Other` FROM `weeks` WHERE `date`=$today AND `day_week`=$week_day AND `uid`=$uid LIMIT 1");
$row = mysql_fetch_row($result);
$sum_count = $row[0];

$percent_data = array();
$grad = array();

foreach (
$tel_data as $index => $value)
{
    if (
$sum_count > 0)
        
$percent_data[$index] = $value/$sum_count*100;
    else
        
$percent_data[$index] = 0;
    
$grad[$index] = $percent_data[$index]*360/100;
}

// ======================== создаём график ================
foreach ($grad as $index => $g)
{
    
$g2 = $g1+$g;

    
imageArc($img, $cx, $cy, 2*$r, 2*$r, $g1, $g2, $colorBlack);

    if (
$g1 == 0){
        
$x = $cx + $r;
        
$y = $cy;
        
imageLine($img,$cx,$cy,$x,$y,$colorBlack);
    }

    
$x = $r*cos($g2*pi()/180)+$cx;
    
$y = $r*sin($g2*pi()/180)+$cy;
    
imageLine($img,$cx,$cy,$x,$y,$colorBlack);

    
$x = ($r-5)*cos(($g2+$g1)/2*pi()/180)+$cx;
    
$y = ($r-5)*sin(($g2+$g1)/2*pi()/180)+$cy;
    
// закраска области
    
if ($g > 2){
        
imageFill($img, $x, $y, $color[$index]);
    }
    
$g1 += $g;

    
// вывод легенды
    
imageFilledRectangle($img, $x_leg, $y_leg, $x_leg+$w_h, $y_leg+$w_h, $color[$index]);
    
imageRectangle($img, $x_leg, $y_leg, $x_leg+$w_h, $y_leg+$w_h, $colorBlack);
    
imageTTFtext($img, 6, 0, $x_leg+$w_h+5, $y_leg+$w_h, $colorBlack, "./font/font.ttf",$tel[$index]." (".(int)$percent_data[$index]."%)");
    
$y_leg += $step;
}
imageRectangle($img, 0, 105, 99, $y_leg, $colorBlack);
imageFilledRectangle($img, 0, 105, 5, $y_leg, $colorGrey);
imageRectangle($img, 0, 105, 5, $y_leg, $colorBlack);

Header("Content-type: image/png");
ImagePNG($img);
ImageDestroy($img);
?>
Онлайн: 2
Реклама