Location: PHPKode > scripts > CrawlProtect > crawlprotect/graphs/origine-graph.php
<?php
//----------------------------------------------------------------------
//  CrawlProtect 2.0.0
//----------------------------------------------------------------------
// Protect your website from hackers
//----------------------------------------------------------------------
// Author: Jean-Denis Brun
//----------------------------------------------------------------------
// Website: www.crawlprotect.com
//----------------------------------------------------------------------
// That script is distributed under GNU GPL license
//----------------------------------------------------------------------
// file: origine-graph.php
//----------------------------------------------------------------------
// this graph is made with artichow    website: www.artichow.org
//----------------------------------------------------------------------
//  Last update: 24/06/2010
//----------------------------------------------------------------------
//get graph infos
if(file_exists("../data/country.php"))
	{
	include("../data/country.php");
	}
else
	{
	include ("../include/configconnect.php");
	$connexion = @mysql_connect($crawlthost,$crawltuser,$crawltpassword);
	$selection = @mysql_select_db($crawltdb);
	include ("../include/functionsdata.php");
	getdatas('mysql');
	}
$datatransfert= array();
//get graph values
$datatransfert= unserialize($countryserialize);
arsort($datatransfert);
$totvalues=array_sum( $datatransfert);  
$i=0;
$total=0;
foreach ($datatransfert as $key => $value)
	{
	if($i<7)
		{
		if($key=='')
			{
			$key='???';
			}
		$legend[] = $key;
		$values[]=$value;
		$total=$total+$value;
		}
	$i++;
	}
if($total<$totvalues)
	{
	$legend[]='Others';
	$values[]= $totvalues-$total;
	}

  
//build the graph
//test to see if ttf font is available
if(function_exists('gd_info'))
	{
	$fontttf= gd_info();
	if( @$fontttf['FreeType Linkage']=='with freetype')
		{
		$ttf='ok';
		}
	else
		{
		$ttf='no-ok';
		}
	}
else
		{
		$ttf='no-ok';
		}
require_once("artichow/Pie.class.php");



$graph = new Graph(450, 200);
if(function_exists('imageantialias'))
    {
    $graph->setAntiAliasing(TRUE);
    }
else
    {
     $graph->setAntiAliasing(FALSE);   
    }
$graph->border->hide(TRUE);

$graph->shadow->setSize(5);
$graph->shadow->smooth(TRUE);

$graph->shadow->setPosition('SHADOW_LEFT_BOTTOM');
$graph->shadow->setColor(new DarkBlue);



$plot = new Pie($values);
$plot->setCenter(0.33, 0.5);
$plot->setSize(0.6, 0.8);
$plot->set3D(15);
$plot->setLabelPosition(10);
$plot->label->setColor(new DarkBlue);
if ($ttf=='ok')
    {
    $plot->label->setFont(new Tuffy(10));
    }
else
    {
    $plot->label->setFont(new Font(2));
    }
$plot->setBorder(new DarkBlue);

$plot->setLegend($legend);


$plot->legend->setPosition(1.6);

$plot->legend->shadow->setSize(0);
$plot->legend->setBackgroundColor(new White);
$plot->legend->border->hide(TRUE);
$plot->legend->setTextColor(new DarkBlue);
if ($ttf=='ok')
	{
	$plot->legend->setTextFont(new Tuffy(10));
	}
else
    {
    $plot->legend->setTextFont(new Font(2));
    }
$graph->add($plot);
$graph->draw();

?>
Return current item: CrawlProtect