| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|---|
| 4 | |
|---|
| 5 | // +-------------------------------------------------------------------+ |
|---|
| 6 | // | WiFiDog Authentication Server | |
|---|
| 7 | // | ============================= | |
|---|
| 8 | // | | |
|---|
| 9 | // | The WiFiDog Authentication Server is part of the WiFiDog captive | |
|---|
| 10 | // | portal suite. | |
|---|
| 11 | // +-------------------------------------------------------------------+ |
|---|
| 12 | // | PHP version 5 required. | |
|---|
| 13 | // +-------------------------------------------------------------------+ |
|---|
| 14 | // | Homepage: http://www.wifidog.org/ | |
|---|
| 15 | // | Source Forge: http://sourceforge.net/projects/wifidog/ | |
|---|
| 16 | // +-------------------------------------------------------------------+ |
|---|
| 17 | // | This program is free software; you can redistribute it and/or | |
|---|
| 18 | // | modify it under the terms of the GNU General Public License as | |
|---|
| 19 | // | published by the Free Software Foundation; either version 2 of | |
|---|
| 20 | // | the License, or (at your option) any later version. | |
|---|
| 21 | // | | |
|---|
| 22 | // | This program is distributed in the hope that it will be useful, | |
|---|
| 23 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 24 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|---|
| 25 | // | GNU General Public License for more details. | |
|---|
| 26 | // | | |
|---|
| 27 | // | You should have received a copy of the GNU General Public License | |
|---|
| 28 | // | along with this program; if not, contact: | |
|---|
| 29 | // | | |
|---|
| 30 | // | Free Software Foundation Voice: +1-617-542-5942 | |
|---|
| 31 | // | 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
|---|
| 32 | // | Boston, MA 02111-1307, USA gnu@gnu.org | |
|---|
| 33 | // | | |
|---|
| 34 | // +-------------------------------------------------------------------+ |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * @package WiFiDogAuthServer |
|---|
| 38 | * @subpackage Statistics |
|---|
| 39 | * @author Philippe April |
|---|
| 40 | * @copyright 2005-2006 Philippe April |
|---|
| 41 | * @version Subversion $Id$ |
|---|
| 42 | * @link http://www.wifidog.org/ |
|---|
| 43 | */ |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * Load required classes |
|---|
| 47 | */ |
|---|
| 48 | require_once('classes/StatisticGraph.php'); |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * @package WiFiDogAuthServer |
|---|
| 52 | * @subpackage Statistics |
|---|
| 53 | * @author Philippe April |
|---|
| 54 | * @copyright 2005-2006 Philippe April |
|---|
| 55 | */ |
|---|
| 56 | class VisitsPerMonth extends StatisticGraph |
|---|
| 57 | { |
|---|
| 58 | /** Get the Graph's name. Must be overriden by the report class |
|---|
| 59 | * @return a localised string */ |
|---|
| 60 | public static function getGraphName() |
|---|
| 61 | { |
|---|
| 62 | return _("Number of individual user visits per month"); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /** Constructor, must be called by subclasses */ |
|---|
| 66 | protected function __construct() |
|---|
| 67 | { |
|---|
| 68 | parent :: __construct(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | /** Get the actual report. |
|---|
| 72 | * Classes can (but don't have to) override this, but must call the parent's |
|---|
| 73 | * method with what would otherwise be their return value and return that |
|---|
| 74 | * instead. |
|---|
| 75 | * @param $statistics_object Mandatory to give the report it's context |
|---|
| 76 | * @param $child_html The child method's return value |
|---|
| 77 | * @return A html fragment |
|---|
| 78 | */ |
|---|
| 79 | public function getReportUI(Statistics $statistics_object, $child_html = null) |
|---|
| 80 | { |
|---|
| 81 | $html = ''; |
|---|
| 82 | $html .= _("Note: A visit is like counting connections, but only counting one connection per day for each user at a single node"); |
|---|
| 83 | return parent::getReportUI($statistics_object, $html); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | /** Return the actual Image data |
|---|
| 87 | * Classes must override this. |
|---|
| 88 | * @param $child_html The child method's return value |
|---|
| 89 | * @param $param mixed: used for $Graph->done() |
|---|
| 90 | * @return A html fragment |
|---|
| 91 | */ |
|---|
| 92 | public function showImageData($child_html='', $param=false) |
|---|
| 93 | { |
|---|
| 94 | require_once ("Image/Graph.php"); |
|---|
| 95 | $db = AbstractDb::getObject(); |
|---|
| 96 | $Graph =& Image_Graph::factory("Image_Graph", array(600, 200)); |
|---|
| 97 | $Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea")); |
|---|
| 98 | $Dataset =& Image_Graph::factory("Image_Graph_Dataset_Trivial"); |
|---|
| 99 | $Bar =& Image_Graph::factory("Image_Graph_Plot_Bar", $Dataset); |
|---|
| 100 | $Bar->setFillColor("#9db8d2"); |
|---|
| 101 | $Plot =& $Plotarea->add($Bar); |
|---|
| 102 | |
|---|
| 103 | $candidate_connections_sql = self :: $stats->getSqlCandidateConnectionsQuery("COUNT(DISTINCT connections.user_id||connections.node_id) AS daily_connections, date_trunc('day', timestamp_in) AS date"); |
|---|
| 104 | $db->execSql("SELECT SUM(daily_connections) AS connections, date_trunc('month', date) AS month FROM ($candidate_connections_sql GROUP BY date) AS daily_connections_table GROUP BY month ORDER BY month", $results, false); |
|---|
| 105 | if ($results != null) { |
|---|
| 106 | foreach($results as $row) { |
|---|
| 107 | /* Cut xxxx-xx-xx xx:xx:Xx to yy-mm */ |
|---|
| 108 | $Dataset->addPoint( substr($row['month'],0,7), $row['connections']); |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | $Graph->done($param); |
|---|
| 113 | unset( $Graph, $Plot, $Bar, $Plotarea, $Dataset, $row, $results ); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | /* |
|---|
| 119 | * Local variables: |
|---|
| 120 | * tab-width: 4 |
|---|
| 121 | * c-basic-offset: 4 |
|---|
| 122 | * c-hanging-comment-ender-p: nil |
|---|
| 123 | * End: |
|---|
| 124 | */ |
|---|
| 125 | |
|---|
| 126 | |
|---|