Phppgads 2.0.7 > PhpPgAds 2.0.7 / Admin / Graph Daily.php

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Phppgads 2.0.7

Download:
phppgads-2.0.7.zip

Category:
Ad Management

Archive Content:

PhpPgAds 2.0.7

PhpPgAds 2.0.7 > Admin

PhpPgAds 2.0.7 > Admin > Report Plugins

PhpPgAds 2.0.7 > Admin

PhpPgAds 2.0.7 > Admin > Images

PhpPgAds 2.0.7 > Admin > Images > Ltr

PhpPgAds 2.0.7 > Admin > Images

PhpPgAds 2.0.7 > Admin > Images > Flags

PhpPgAds 2.0.7 > Admin > Images

PhpPgAds 2.0.7 > Admin > Images > Rtl

PhpPgAds 2.0.7 > Admin > Images

PhpPgAds 2.0.7 > Admin

PhpPgAds 2.0.7 > Admin > Templates

PhpPgAds 2.0.7

PhpPgAds 2.0.7 > Cache

PhpPgAds 2.0.7 > Client

PhpPgAds 2.0.7 > Language

PhpPgAds 2.0.7 > Language > Brazilian Portuguese

PhpPgAds 2.0.7 > Language > Chinese Big5

PhpPgAds 2.0.7 > Language > Chinese Gb2312

PhpPgAds 2.0.7 > Language > Dutch

PhpPgAds 2.0.7 > Language > English

PhpPgAds 2.0.7 > Language > English Us

PhpPgAds 2.0.7 > Language > French

PhpPgAds 2.0.7 > Language > German

PhpPgAds 2.0.7 > Language > Hebrew

PhpPgAds 2.0.7 > Language > Hungarian

PhpPgAds 2.0.7 > Language > Indonesian

PhpPgAds 2.0.7 > Language > Italian

PhpPgAds 2.0.7 > Language > Korean

PhpPgAds 2.0.7 > Language > Polish

PhpPgAds 2.0.7 > Language > Portuguese

PhpPgAds 2.0.7 > Language > Russian Cp1251

PhpPgAds 2.0.7 > Language > Russian Koi8r

PhpPgAds 2.0.7 > Language > Spanish

PhpPgAds 2.0.7 > Language > Turkish

PhpPgAds 2.0.7 > Libraries

PhpPgAds 2.0.7 > Libraries > Defaults

PhpPgAds 2.0.7 > Libraries

PhpPgAds 2.0.7 > Libraries > Layerstyles

PhpPgAds 2.0.7 > Libraries > Layerstyles > Cursor

PhpPgAds 2.0.7 > Libraries > Layerstyles > Floater

PhpPgAds 2.0.7 > Libraries > Layerstyles > Geocities

PhpPgAds 2.0.7 > Libraries > Layerstyles > Geocities > Images

PhpPgAds 2.0.7 > Libraries > Layerstyles > Geocities

PhpPgAds 2.0.7 > Libraries > Layerstyles > Simple

PhpPgAds 2.0.7 > Libraries > Layerstyles > Simple > Images

PhpPgAds 2.0.7 > Libraries > Layerstyles > Simple

PhpPgAds 2.0.7 > Libraries

PhpPgAds 2.0.7 > Libraries > Deliverycache

PhpPgAds 2.0.7 > Libraries > Geotargeting

PhpPgAds 2.0.7 > Libraries > Resources

PhpPgAds 2.0.7 > Maintenance

PhpPgAds 2.0.7 > Misc

PhpPgAds 2.0.7 > Misc > Documentation

PhpPgAds 2.0.7 > Misc

PhpPgAds 2.0.7 > Misc > Fakecron

PhpPgAds 2.0.7 > Misc > Revisions

PhpPgAds 2.0.7 > Misc > Samples

PhpPgAds 2.0.7 > Misc > Samples > Xmlrpc

PhpPgAds 2.0.7 > Misc > Samples > Xmlrpc > Php

Graph Daily.php:


<?php // $Revision: 2.0.2.3 $

/************************************************************************/
/* phpPgAds                                                             */
/* ========                                                             */
/*                                                                      */
/* Copyright (c) 2001 by Steve Maranda <steve_maranda <at> teluq.uquebec <dot> ca> */
/* http://sourceforge.net/projects/phppgads                             */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* you must supply to this script 3 parameters :  title, width and data. */
/* - title is the title of the graph                                    */
/* - width is the width of the generated graph                          */
/* - data is used for the values to be displayed                        */
/*     to split the data you have to use separators "^" and "^^"        */
/*     -> item_title^value^^                                            */
/************************************************************************/
/* call this script directly in the browser or in your html page with   */
/* the img tag.                                                         */
/* example 1 :                                                          */
/* graph-daily.php?title=foo&width=500&data=a^15^^b^20^^                */
/* example 2 :                                                          */
/* <html>                                                               */
/*  ...                                                                 */
/*  <img src="graph-daily.php?title=foo&width=500&data=a^15^^b^20^^">   */
/*  ...                                                                 */
/* </html>                                                              */
/************************************************************************/
/* you can use as many data items as you want                           */
/* you need the GD library in your php module                           */
/* don't forget to encode you parameters (unicode)                      */
/************************************************************************/



// Include required files
require ("../libraries/lib-io.inc.php");
require (
"../libraries/lib-cache.inc.php");
require (
"lib-gd.inc.php");


// Register input variables
phpAds_registerGlobal ('width',  'data');


/*********************************************************/
/* Prepare data for graph                                */
/*********************************************************/

// Prevent errors
if (!isset($width) || $width <= 0)
    exit;

// Decode data
$data = isset($data) ? urldecode($data) : '';  

// Start positions of graph  
$x 27;  
$y 12;

// Right margin  
$right_margin=5;  

$bar_width 5;  
$total 0;  
$max 0;  

$unit = (($width-$x)-$right_margin) / 100;  

$itemsexplode("^^", $data);  

// Calculate total  
while (list($key, $item) = each($items))  
{  
    if (
$item)  
    {  
        
$pos strpos($item, "^");  
        
$value substr($item, $pos+1, strlen($item));  
        
$total $total $value;  
    }  
}  

reset($items);  

// Calculate height of graph  
$height=38;

$im imagecreate($width, $height);  

// Allocate colors  
$white  ImageColorAllocate ($im,  204,  204,  204);
$black  ImageColorAllocate ($im,    0,    0,    0);
$yellow ImageColorAllocate ($im,  240,  240,   70);
$line   ImageColorAllocate ($im,    0,    0,  102);
$blue   ImageColorAllocate ($im,   64,  100,  168);
$barViews    ImageColorAllocate ($im,    0,  102,  204);
$barClicks   ImageColorAllocate ($im,  153,  204,  255);

// Background  
imageColorTransparent($im, $white);
ImageFilledRectangle($im, 0, 0, $width, $height, $white);


// line
Imageline($im, $x, $y-5, $x, $height-17, $line);

//draw data
while (list($key, $item) = each($items))  
{
    if (
$item)
    {
        
$pos strpos($item, "^");
        
$item_title substr($item, 0, $pos);
        
$value substr($item, $pos+1, strlen($item));
        
        
// display percent
        
$percent $total == intval(round(($value/$total)*100));
        
ImageString($im, 3, $x-24, $y-4, $percent."%", $black);
        
        
// value right side rectangle
        
$percent $total == intval(round(($value/$total)*100));
        
$px $x + ($percent $unit);
        
        if (
$item_title == 'Views')
        {
            
// draw rectangle value
            
ImageFilledRectangle($im, $x, $y-2, $px, $y+$bar_width, $barViews);
        }
        else
        {
            
ImageFilledRectangle($im, $x, $y-2, $px, $y+$bar_width, $barClicks);
        }
        
        
// draw empty rectangle
        
ImageRectangle($im, $x, $y-2, ($x+(100*$unit)), $y+$bar_width, $line);
        
        
// line
        
Imageline($im, $px, $y-2, $px, $y+$bar_width, $line);
        
        
// display numbers
        
$fwidth ImageFontWidth(2);
        
$string $value."/".$total;
        
ImageString($im,  2,  $x + (100 $unit) - (strlen($string) * $fwidth) + 2,  $y+12,  $string,  $black);
    }
    
$y=$y+($bar_width+20);
    
    
    
// IE workaround: Turn off outputbuffering
    // if zlib compression is turned on
    
if (strpos ($HTTP_SERVER_VARS['HTTP_USER_AGENT'],  'MSIE') > &&
        
function_exists('ini_get') &&
        
ini_get ("zlib.output_compression"))
        
ob_end_clean ();
    
    
// Send the content-type header
    
phpAds_GDContentType();
    
    
// Display modified image
    
phpAds_GDShowImage($im);
    
    
    
// Release allocated ressources  
    
ImageDestroy($im);
    exit();
}

?>



Other Ad Management Scripts:

WebMaster Resources Home

©RingsWorld.com