root/trunk/inc/news/statistics.inc.php

Revision 15, 3.9 KB (checked in by alexx, 7 years ago)
  • fix last bug in communities (see [14])
  • execute a "conversion smarty style" script ;) : for i in find . -type f | grep "\.php$" | grep -v "\.svn"; do perl -pi -e "s/\\\$smarty->assign\((.*),(.*)\);/\\\$_SMARTY\[\$1\] = \$2;/" $i; done
Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25
26$total = $db->getOne('SELECT value FROM global_data WHERE name=?', array('nb_nodians'));
27
28$country_r = $db->query('SELECT DISTINCT(country) AS name, COUNT(id) AS nb FROM user_contact WHERE country IS NOT NULL GROUP BY country ORDER BY nb DESC LIMIT 10');
29
30while($country = $country_r->fetchRow())
31{
32    $country['male'] = $db->getOne('SELECT COUNT(id) FROM cache_user WHERE country=? AND gender=?', array($country['name'], 'male'));
33    $country['female'] = $db->getOne('SELECT COUNT(id) FROM cache_user WHERE country=? AND gender=?', array($country['name'], 'female'));
34    $stats['country'][$country['name']]['nb'] = $country['nb'];
35    $stats['country'][$country['name']]['percent'] = $country['nb']/$total*100;
36    $stats['country'][$country['name']]['male'] = $country['male']/$country['nb']*100;
37    $stats['country'][$country['name']]['female'] = $country['female']/$country['nb']*100;
38}
39
40$stats['interest'][tr($labels['profile']['here_for']['friend'])] = $db->getOne('SELECT COUNT(id) as nb FROM cache_user WHERE here_for=here_for|1')/$total*100;
41$stats['interest'][tr($labels['profile']['here_for']['business'])] = $db->getOne('SELECT COUNT(id) as nb FROM cache_user WHERE here_for=here_for|2')/$total*100;
42$stats['interest'][tr($labels['profile']['here_for']['dating'])] = $db->getOne('SELECT COUNT(id) as nb FROM cache_user WHERE here_for=here_for|4')/$total*100;
43$stats['interest'][tr($labels['profile']['here_for']['partners'])] = $db->getOne('SELECT COUNT(id) as nb FROM cache_user WHERE here_for=here_for|8')/$total*100;
44
45$relationship_r = $db->query('SELECT DISTINCT(relationship_status) AS name, COUNT(id) AS nb FROM cache_user GROUP BY relationship_status ORDER BY nb DESC LIMIT 10');
46
47
48$relationship_r = $db->query('SELECT DISTINCT(relationship_status) AS name, COUNT(id) AS nb FROM cache_user WHERE relationship_status IS NOT NULL GROUP BY relationship_status ORDER BY nb DESC');
49
50while($relationship = $relationship_r->fetchRow())
51{
52    if(!$relationship['name'])
53        continue;
54//                $relationship['name'] = 'no_anwser';
55
56        $relationship['male'] = $db->getOne('SELECT COUNT(id) FROM cache_user WHERE relationship_status=? AND gender=?', array($relationship['name'], 'male'));
57        $relationship['female'] = $db->getOne('SELECT COUNT(id) FROM cache_user WHERE relationship_status=? AND gender=?', array($relationship['name'], 'female'));
58        $stats['relationship'][$relationship['name']]['nb'] = $relationship['nb'];
59        $stats['relationship'][$relationship['name']]['percent'] = $relationship['nb']/$total*100;
60    $stats['relationship'][$relationship['name']]['male'] = ( $relationship['male'] / $relationship['nb'] ) * 100 ;
61
62        $stats['relationship'][$relationship['name']]['female'] = ($relationship['female']/$relationship['nb'])*100;
63    $stats['relationship'][$relationship['name']]['label'] = $labels['profile']['relationship_status_cb'][$relationship['name']];
64}
65
66$_SMARTY['stats'] =  $stats;
67?>
Note: See TracBrowser for help on using the browser.