Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
// +-----------------------------------------------------------------------+
3
// | PhpWebGallery - a PHP based picture gallery                           |
4
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6
// +-----------------------------------------------------------------------+
7
// | branch        : BSF (Best So Far)
8
// | file          : $RCSfile: global_stats.img.php,v $
9
// | last update   : $Date: 2005/01/11 20:04:19 $
10
// | last modifier : $Author: plg $
11
// | revision      : $Revision: 1.6 $
12
// +-----------------------------------------------------------------------+
13
// | This program is free software; you can redistribute it and/or modify  |
14
// | it under the terms of the GNU General Public License as published by  |
15
// | the Free Software Foundation                                          |
16
// |                                                                       |
17
// | This program is distributed in the hope that it will be useful, but   |
18
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20
// | General Public License for more details.                              |
21
// |                                                                       |
22
// | You should have received a copy of the GNU General Public License     |
23
// | along with this program; if not, write to the Free Software           |
24
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25
// | USA.                                                                  |
26
// +-----------------------------------------------------------------------+
27
//----------------------------------------------------------- include
28
define('PHPWG_ROOT_PATH','../../');
29
define('IN_ADMIN', true);
30
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
31
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
32
include_once( 'phpBarGraph.php' );
33
 
34
//------------------------------------------------ variable definition
35
$outputFormat = "png";
36
$legend = $lang['stats_global_graph_title'];
37
$imageHeight = 256;
38
$imageWidth = 320;
39
$sql = "SELECT DISTINCT COUNT(*), MONTH(date) 
40
  FROM ".HISTORY_TABLE." 
41
  WHERE (date > DATE_SUB(CURRENT_DATE(), INTERVAL 12 MONTH)) 
42
  GROUP BY DATE_FORMAT(date,'%Y-%m') DESC;";
43
 
44
//------------------------------------------------ Image definition
45
$image = ImageCreate($imageWidth, $imageHeight);
46
//$image = ImageCreateTrueColor($imageWidth, $imageHeight);
47
// Fill it with your favorite background color..
48
$backgroundColor = ImageColorAllocate($image, 184, 184, 184);
49
ImageFill($image, 0, 0, $backgroundColor);
50
$white = ImageColorAllocate($image, 0, 0, 0);
51
 
52
// Interlace the image..
53
Imageinterlace($image, 1);
54
 
55
// Create a new BarGraph..
56
$myBarGraph = new PhpBarGraph;
57
$myBarGraph->SetX(10);              // Set the starting x position
58
$myBarGraph->SetY(10);              // Set the starting y position
59
$myBarGraph->SetWidth($imageWidth-20);    // Set how wide the bargraph will be
60
$myBarGraph->SetHeight($imageHeight-20);  // Set how tall the bargraph will be
61
$myBarGraph->SetNumOfValueTicks(3); // Set this to zero if you don't want to show any. These are the vertical bars to help see the values.
62
 
63
 
64
// You can try uncommenting these lines below for different looks.
65
 
66
// $myBarGraph->SetShowLabels(false);  // The default is true. Setting this to false will cause phpBarGraph to not print the labels of each bar.
67
 $myBarGraph->SetShowValues(false);  // The default is true. Setting this to false will cause phpBarGraph to not print the values of each bar.
68
// $myBarGraph->SetBarBorder(false);   // The default is true. Setting this to false will cause phpBarGraph to not print the border of each bar.
69
// $myBarGraph->SetShowFade(false);    // The default is true. Setting this to false will cause phpBarGraph to not print each bar as a gradient.
70
// $myBarGraph->SetShowOuterBox(false);   // The default is true. Setting this to false will cause phpBarGraph to not print the outside box.
71
$myBarGraph->SetBarSpacing(5);     // The default is 10. This changes the space inbetween each bar.
72
 
73
 
74
// Add Values to the bargraph..
75
$result = pwg_query($sql)
76
or die(mysql_errno().": ".mysql_error()."<BR>".$sql);
77
 
78
//$monthes =array_fill(1,12,0);
79
$monthes =array();
80
$date = getdate();
81
$current_month = $date['mon'];
82
for ($i=0;$i<12;$i++)
83
{
84
  $monthes[(($current_month-$i+11)%12)+1]=0;
85
}
86
 
87
while ($r = mysql_fetch_row($result))
88
{ 
89
  if (!$monthes[$r[1]]) $monthes[$r[1]]= $r[0];
90
}
91
$monthes = array_reverse($monthes,true);
92
while (list ($key,$value) = each($monthes))
93
{
94
  $nls_key = substr($lang['month'][$key],0,3);
95
  $myBarGraph->AddValue($nls_key, $value);
96
}
97
 
98
//$myBarGraph->SetDebug(true);
99
// Set the colors of the bargraph..
100
$myBarGraph->SetStartBarColor("6666ff");  // This is the color on the top of every bar.
101
$myBarGraph->SetEndBarColor("2222aa");    // This is the color on the bottom of every bar. This is not used when SetShowFade() is set to false.
102
$myBarGraph->SetLineColor("000000");      // This is the color all the lines and text are printed out with.
103
 
104
// Print the BarGraph to the image..
105
$myBarGraph->DrawBarGraph($image);
106
Imagestring($image, 2, 2, $imageHeight-14, $legend, $white);
107
 
108
//------------------------------------------------ Image output
109
if ($outputFormat == "png")
110
{
111
  header("Content-type: image/png");
112
  ImagePNG($image);
113
}
114
else if ($outputFormat == "jpg")
115
{
116
  header("Content-type: image/jpeg");
117
  Imagejpeg($image);
118
}
119
// Destroy the image.
120
Imagedestroy($image);
121
?>