4 // SourceForge: Breaking Down the Barriers to Open Source Development
5 // Copyright 1999-2001 (c) VA Linux Systems
6 // http://sourceforge.net
8 // Attempt to set up the include path, to fix problems with relative includes
10 require_once $gfcommon.'include/FusionForge.class.php';
11 require_once $gfcommon.'include/tag_cloud.php';
13 function show_features_boxes() {
14 GLOBAL $HTML,$sys_use_ratings,$sys_use_frs,$sys_use_project_tags;
16 plugin_hook ("features_boxes_top", array());
17 $return = '<h2 class="skip">' . _('Features Boxes') . '</h2>';
19 if ($sys_use_project_tags) {
20 $return .= $HTML->boxTop(_('Tag Cloud'), 'Tag_Cloud');
21 $return .= tag_cloud();
22 $return .= $HTML->boxMiddle(sprintf(_('%1$s Statistics'), $GLOBALS['sys_name']), 'Forge_Statistics');
24 $return .= $HTML->boxTop(sprintf(_('%1$s Statistics'), $GLOBALS['sys_name']), 'Forge_Statistics');
26 $return .= show_sitestats();
28 $return .= $HTML->boxMiddle(_('Top Project Downloads'), 'Top_Projects_Downloads');
29 $return .= show_top_downloads();
31 if ($sys_use_ratings) {
32 $return .= $HTML->boxMiddle(_('Highest Ranked Users'), 'Highest_Ranked_Users');
33 $return .= show_highest_ranked_users();
35 $return .= $HTML->boxMiddle(_('Most Active This Week'), 'Most_Active_This_Week');
36 $return .= show_highest_ranked_projects();
37 $return .= $HTML->boxMiddle(_('Recently Registered Projects'), 'Recently_Registered_Projects');
38 $return .= show_newest_projects();
39 $return .= $HTML->boxBottom();
40 plugin_hook ("features_boxes_bottom", array());
44 function show_top_downloads() {
45 // TODO yesterday is now defined as two days ago. Quick fix
46 // to allow download list to be cached before nightly
47 // aggregation is done. jbyers 2001.03.19
49 $month = date("Ym",time()-(2*3600*24));
50 $day = date("d",time()-(2*3600*24));
52 $res_topdown = db_query_params ('
53 SELECT groups.group_id,
55 groups.unix_group_name,
56 frs_dlstats_grouptotal_vw.downloads
57 FROM frs_dlstats_grouptotal_vw,groups
59 frs_dlstats_grouptotal_vw.group_id=groups.group_id AND groups.is_public=1 and groups.status=$1
60 ORDER BY downloads DESC
66 if (db_numrows($res_topdown) == 0) {
67 return _('No Stats Available');
70 while ($row_topdown = db_fetch_array($res_topdown)) {
71 if ($row_topdown['downloads'] > 0) {
72 $t_downloads = number_format($row_topdown['downloads']);
73 $t_prj_link = util_make_link_g ($row_topdown['unix_group_name'], $row_topdown['group_id'], $row_topdown['group_name']);
76 $return .= '<td class="width-stat-col1">' . $t_downloads . '</td>';
77 $return .= '<td>' . $t_prj_link . '</td>';
81 if ( $return != "" ) {
82 /* MFaure: test required to deal with a special case encountered on zforge by 20091204 */
84 $return = '<table summary="">' . $t_return . "</table>\n";
86 $return .= '<div class="align-center">' . util_make_link ('/top/', _('All the ranking'), array('class' => 'dot-link')) . '</div>';
93 function stats_getprojects_active_public() {
94 $res_count = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1 AND is_public=1',
96 if (db_numrows($res_count) > 0) {
97 $row_count = db_fetch_array($res_count);
98 return $row_count['count'];
104 function stats_getprojects_total() {
105 $res_count = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1 OR status=$2',
108 if (db_numrows($res_count) > 0) {
109 $row_count = db_fetch_array($res_count);
110 return $row_count['count'];
116 function stats_getpageviews_total() {
117 $res_count = db_query_params ('SELECT SUM(site_views) AS site, SUM(subdomain_views) AS subdomain FROM stats_site',
119 if (db_numrows($res_count) > 0) {
120 $row_count = db_fetch_array($res_count);
121 return ($row_count['site'] + $row_count['subdomain']);
127 function stats_downloads_total() {
128 $res_count = db_query_params ('SELECT SUM(downloads) AS downloads FROM stats_site',
130 if (db_numrows($res_count) > 0) {
131 $row_count = db_fetch_array($res_count);
132 return $row_count['downloads'];
138 function show_sitestats() {
139 global $sys_use_trove;
140 $gforge = new FusionForge();
142 $return .= _('Hosted Projects').': ';
143 if ($sys_use_trove) {
144 $return .= '<a href="softwaremap/full_list.php">';
146 $return .= '<strong>'.number_format($gforge->getNumberOfPublicHostedProjects()).'</strong>';
147 if ($sys_use_trove) {
150 $return .= "</p><p>";
151 $return .= _('Registered Users').': <strong>'.number_format($gforge->getNumberOfActiveUsers()).'</strong>';
156 function show_newest_projects() {
157 $res_newproj = db_query_params ('SELECT group_id,unix_group_name,group_name,register_time FROM groups WHERE is_public=1 AND status=$1 AND type_id=1 AND register_time > 0 ORDER BY register_time DESC', array ('A'), 10);
161 if (!$res_newproj || db_numrows($res_newproj) < 1) {
162 return _('No Stats Available')." ".db_error();
165 $return .= '<table summary="">' . "\n";
166 while ( $row_newproj = db_fetch_array($res_newproj) ) {
168 $t_prj_date = date(_('m/d'),$row_newproj['register_time']);
169 $t_prj_link = util_make_link_g ($row_newproj['unix_group_name'],$row_newproj['group_id'],$row_newproj['group_name']);
172 $return .= '<td class="width-stat-col1">' . $t_prj_date . "</td>";
173 $return .= '<td>' . $t_prj_link . '</td>';
174 $return .= "</tr>\n";
176 $return .= '</table>';
179 $return .= '<div class="align-center">'.util_make_link ('/softwaremap/full_list.php', _('All newest projects'), array('class' => 'dot-link')).'</div>';
183 function show_highest_ranked_users() {
184 //select out the users information to show the top users on the site
185 $res = db_query_params ('SELECT users.user_name,users.user_id,users.realname,user_metric.metric FROM user_metric,users WHERE users.user_id=user_metric.user_id AND user_metric.ranking < 11 AND users.status != $1 ORDER BY ranking ASC',
187 $rows=db_numrows($res);
188 if (!$res || $rows<1) {
189 return _('No Stats Available').db_error();
192 for ($i=0; $i<$rows; $i++) {
193 $return .= ($i+1).' - ('. number_format(db_result($res,$i,'metric'),4) .') '
194 . util_make_link_u (db_result($res,$i,'user_name'),db_result($res,$i,'user_id'),db_result($res,$i,'realname'))
198 $return .= '<div class="align-center">'.util_make_link ('/top/topusers.php', _('All users'), array('class' => 'dot-link')).'</div>';
202 function show_highest_ranked_projects() {
203 $result = db_query_params ('SELECT groups.group_name,groups.unix_group_name,groups.group_id,project_weekly_metric.ranking,project_weekly_metric.percentile FROM groups,project_weekly_metric WHERE groups.group_id=project_weekly_metric.group_id AND groups.is_public=1 AND groups.type_id=1 AND groups.status != $1 AND groups.use_stats=1 ORDER BY ranking ASC',
206 if (!$result || db_numrows($result) < 1) {
207 return _('No Stats Available')." ".db_error();
209 $return = '<table summary="">';
210 while ($row=db_fetch_array($result)) {
211 $t_prj_activity = number_format(substr($row['ranking'],0,5),0);
212 $t_prj_link = util_make_link_g ($row['unix_group_name'],$row['group_id'],$row['group_name']);
215 $return .= '<td class="width-stat-col1">'. $t_prj_activity . "</td>";
216 $return .= '<td>' . $t_prj_link . '</td>';
217 $return .= "</tr>\n";
219 $return .= "</table>";
220 $return .= '<div class="align-center">' . util_make_link ('/top/mostactive.php?type=week', _('All project activities'), array('class' => 'dot-link')) . '</div>';
228 // c-file-style: "bsd"