List of commits:
Subject Hash Author Date (UTC)
Added statistics for the installation ed743a601cd187431ccd80b57113ba9bb5704035 Catalin(ux) M. BOIE 2019-11-17 09:08:33
ldap: if we have no server, it is useless to continue processing c022b68a942f471e51cb8343bfef1cda390b27b1 Catalin(ux) M. BOIE 2019-11-16 06:30:47
Do not try to access a repo if is deleted 0a6b1bb704fbeaf60ba053ecc0c323a80f0e397c Catalin(ux) M. BOIE 2019-11-15 19:49:31
Some git tweaks to deal with empty repositories c42a22e41cd6d29862e13077e60374ceb7b0c946 Catalin(ux) M. BOIE 2019-11-14 03:30:12
Texts updates + cosmetic 70246eecb7b63460d28f20b5e2f3c9c1c50852ae Catalin(ux) M. BOIE 2019-11-14 03:29:33
Docker updates aa4cf359af2c7c1e20e4f33c478f2bbcd134f081 Catalin(ux) M. BOIE 2019-11-14 03:24:05
Because of docker, we are now using HTTP_HOST insead of SERVER_NAME 9cf31231d760daac43e1c3454c5a308d69ea4898 Catalin(ux) M. BOIE 2019-11-14 03:22:37
Corrected stupid space char inside cache key 5958389c03b7536d6332a51e30b112ad3a520571 Catalin(ux) M. BOIE 2019-11-10 21:15:32
nginx: remove text/html because it is always added to gzip_types f8717bc9ac127e806696f088389c2911a6d37e28 Catalin(ux) M. BOIE 2019-11-09 13:05:54
vm: get rid of i386 (we move to x86_64) 67662a7b71f1b21f53fe7fa819afdf366ad3b4b4 Catalin(ux) M. BOIE 2019-11-09 07:58:05
SELinux: allow httpd_t to map rocketgit_exec_t files 6d3550736af317791be3d6355dd90bf64de323f5 Catalin(ux) M. BOIE 2019-11-09 00:36:03
Added rg_git_repo_is_empty function plus func test a13c5439fceffd8b1474f1105ca37c7b703d2fc9 Catalin(ux) M. BOIE 2019-11-08 04:34:34
TODO updates, user_min/max defaults changed d2f35a43f5de793565e0df9889d587c524df5f20 Catalin(ux) M. BOIE 2019-11-06 16:32:08
More rg_exec2 fixes 808297884e42942c83762040c4247c7cf9a593e8 Catalin(ux) M. BOIE 2019-11-06 16:31:09
Always set rg[hostname] - used also for ssh connections for TOTP 1a7a693617ac521967b8df73245cd704004b76b5 Catalin(ux) M. BOIE 2019-11-06 04:10:59
White space corrections 92a1b944842439b9476a954daa2a65c5acfca85c Catalin(ux) M. BOIE 2019-11-05 18:52:08
README updates b57e3765de34c5e4ed7afa8384f24b6337352b17 Catalin(ux) M. BOIE 2019-11-01 03:18:48
download page updates 0185da40f7b2779c886b9c3e67b10fe69b1b112c Catalin(ux) M. BOIE 2019-11-01 03:13:14
css: small updates 59ae919c798d64f74ed8bdeb08241e4e76840afe Catalin(ux) M. BOIE 2019-10-30 21:33:37
comparison: updated pagespeed and other changes 3f423b7b0a98c0342e5d855c254812d37a03a5b8 Catalin(ux) M. BOIE 2019-10-30 21:27:20
Commit ed743a601cd187431ccd80b57113ba9bb5704035 - Added statistics for the installation
Author: Catalin(ux) M. BOIE
Author date (UTC): 2019-11-17 09:08
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2019-11-17 09:08
Parent(s): c022b68a942f471e51cb8343bfef1cda390b27b1
Signer:
Signing key:
Signing status: N
Tree: c84a5e05aa4392dfdc4a8af80f7eaafea407ddf3
File Lines added Lines deleted
inc/dispatch/dispatch.php 4 0
inc/gd.inc.php 0 48
inc/graph.inc.php 210 0
inc/mr.inc.php 18 0
inc/repo.inc.php 26 0
inc/site/stats.php 91 0
inc/ssh.inc.php 18 0
inc/user.inc.php 18 0
root/index.php 1 0
root/themes/default/index.html 1 0
root/themes/default/main.css 5 0
root/themes/default/site/stats.html 17 0
File inc/dispatch/dispatch.php changed (mode: 100644) (index 8ece1c3..e069f98)
... ... case 'discover':
113 113 $body .= rg_repo_discover($db, $_op, $rg, $_ui); $body .= rg_repo_discover($db, $_op, $rg, $_ui);
114 114 break; break;
115 115
116 case 'stats':
117 include($INC . "/site/stats.php");
118 break;
119
116 120 case 'doc': case 'doc':
117 121 $sec = array_shift($paras); $sec = array_shift($paras);
118 122 switch ($sec) { switch ($sec) {
File inc/gd.inc.php deleted (index 92b1591..0000000)
1 <?php
2
3
4 /*
5 * Creates a graphic
6 */
7 function rg_gd_graph($a)
8 {
9 $i = imageCreateTrueColor($a['w'], $a['h']);
10 if ($i === FALSE)
11 return FALSE;
12
13 imageSaveAlpha($i, TRUE);
14
15 if (isset($a['bg'])) {
16 $c = $a['bg'];
17 $bg = ImageColorAllocate($i, $c['r'], $c['g'], $c['b']);
18 imageFill($i, 0, 0, $bg);
19 }
20
21
22 // How many seconds?
23 $secons = $a['end'] - $a['start'] + 1;
24
25 // one vertical line means how many seconds?
26 $colums = intval($seconds / $a['seconds_per_column']);
27
28 $line = 0;
29 // Draw title
30 if (isset($a['title_color']))
31 $c = $a['title_color'];
32 else
33 $c = array("r" => 0, "g" => 0, "b" => 255);
34 $tc = imageColorAllocate($i, $c['r'], $c['g'], $c['b']);
35 imageString($i, 4, 3, $line, $a['title'], $tc);
36 $line += 20;
37
38 // main rectangle
39 if (isset($a['border_color']))
40 $c = $a['border_color'];
41 else
42 $c = array("r" => 0, "g" => 0, "b" => 0);
43 $bc = imageColorAllocate($i, $c['r'], $c['g'], $c['b']);
44 imageRectangle($i, 0, $line, $a['w'] - 1, $a['h'] - 1, $bc);
45
46 }
47
48 ?>
File inc/graph.inc.php added (mode: 100644) (index 0000000..67e00ea)
1 <?php
2
3 /*
4 * Helper for rg_graph_data_query to position a value in the correct interval
5 */
6 function rg_graph_pos($db, $itime, $unit)
7 {
8 //rg_log_enter('graph_pos itime=' . $itime . ' unit=' . $unit);
9
10 $h = gmdate('H', $itime);
11 $i = gmdate('i', $itime);
12 $y = gmdate('Y', $itime);
13 $m = gmdate('m', $itime);
14 $d = gmdate('d', $itime);
15
16 switch ($unit) {
17 case 'minute':
18 $n = gmmktime($h, $i, 0, $m, $d, $y);
19 $f = gmmktime($h, $i + 1, 0, $m, $d, $y);
20 break;
21
22 case 'hour':
23 $n = gmmktime($h, 0, 0, $m, $d, $y);
24 $f = gmmktime($h + 1, 0, 0, $m, $d, $y);
25 break;
26
27 case 'day':
28 $n = gmmktime(0, 0, 0, $m, $d, $y);
29 $f = gmmktime(0, 0, 0, $m, $d + 1, $y);
30 break;
31
32 case 'month':
33 $n = gmmktime(0, 0, 0, $m, 0, $y);
34 $f = gmmktime(0, 0, 0, $m + 1, 0, $y);
35 break;
36
37 case 'year':
38 $n = gmmktime(0, 0, 0, 0, 0, $y);
39 $f = gmmktime(0, 0, 0, 0, 0, $y + 1);
40 break;
41
42 default:
43 rg_user_set_error('invalid unit ' . $unit);
44 $n = FALSE;
45 }
46
47 //rg_log_exit();
48 return $n === FALSE ? FALSE : array('pos' => $n, 'next' => $f);
49 }
50
51 /*
52 * Loads data for graphs (helper)
53 * TODO: what about DST?
54 */
55 function rg_graph_query($db, $start, $end, $unit, $query, $params)
56 {
57 rg_log_enter('graph_query start=' . $start . ' end=' . $end
58 . ' unit=' . $unit . ' query=' . $query);
59
60 $ret = FALSE;
61 while (1) {
62 $res = rg_sql_query_params($db, $query, $params);
63 if ($res === FALSE) {
64 rg_user_set_error('query error: ' . rg_sql_error());
65 break;
66 }
67
68 $ret = array('list' => array(), 'min' => -1, 'max' => 0);
69 while (($row = rg_sql_fetch_array($res))) {
70 $p = rg_graph_pos($db, $row['itime'], $unit);
71 if ($p === FALSE)
72 break;
73
74 $pos = $p['pos'];
75 if (!isset($ret['list'][$pos]))
76 $ret['list'][$pos] = 1;
77 else
78 $ret['list'][$pos] += 1;
79 }
80 rg_sql_free_result($res);
81
82 $pos = $start;
83 while ($pos < $end) {
84 $p = rg_graph_pos($db, $pos, $unit);
85 if ($p === FALSE) {
86 $ret = FALSE;
87 break;
88 }
89
90 $pos = $p['pos'];
91 $next = $p['next'];
92
93 if (!isset($ret['list'][$pos]))
94 $ret['list'][$pos] = 0;
95
96 if (($ret['min'] == -1) || ($ret['min'] > $ret['list'][$pos]))
97 $ret['min'] = $ret['list'][$pos];
98 if ($ret['max'] < $ret['list'][$pos])
99 $ret['max'] = $ret['list'][$pos];
100
101 $pos = $next;
102 }
103 ksort($ret['list']);
104 break;
105 }
106
107 rg_log_exit();
108 return $ret;
109 }
110
111 /*
112 * Creates a SVG graph
113 */
114 function rg_graph($a)
115 {
116 if (!isset($a['scale_style']))
117 $a['scale_style'] = 'font-size: 8pt';
118
119 $data_start_x = 10;
120 $data_start_y = 30;
121
122 $len = strlen(sprintf("%s", $a['data']['max']));
123 $data_start_x += $len * 8 + 3;
124
125 $c = count($a['data']['list']);
126 $a['w'] = ($c - 1) * $a['gap'] + $c * $a['data_line_width'];
127 rg_log('DEBUG: count=' . count($a['data']['list']) . ' len=' . $len);
128 rg_log('DEBUG: a[w]=' . $a['w']);
129
130 $w = $data_start_x + 2 + $a['w'] + 2 + 10;
131 $h = $data_start_y + 2 + $a['h'] + 1 + 2 + 20;
132 rg_log('DEBUG: w=' . $w);
133
134 $ret = '<svg width="' . $w . '" height="' . $h . '"'
135 . ' class="stats_svg">' . "\n";
136
137 // Background
138 $ret .= '<rect x="0" y="0" width="100%" height="100%"'
139 . ' style="' . $a['bg_style'] . '" />' . "\n";
140
141 // Title
142 $ret .= '<text x="10" y="20" style="' . $a['title_style']
143 . '">' . $a['title'] . '</text>' . "\n";
144
145 // Subtitle
146 $ret .= '<text x="' . $data_start_x . '"'
147 . ' y="' . ($data_start_y + 2 + $a['h'] + 3 + 12) . '"'
148 . ' style="' . $a['subtitle_style'] . '">'
149 . $a['subtitle'] . '</text>' . "\n";
150
151 // Footer right
152 $a['footer_style'] .= '; text-anchor: end';
153 $t = 'Generated at ' . gmdate('Y-m-d H:i');
154 $ret .= '<text x="' . ($data_start_x + 2 + $a['w'] + 2) . '"'
155 . ' y="' . ($data_start_y + 2 + $a['h'] + 3 + 12) . '"'
156 . ' style="' . $a['footer_style']
157 . '">' . $t . '</text>' . "\n";
158
159 // Left scale
160 $a['scale_style'] .= '; text-anchor: end';
161 $ret .= '<text x="' . ($data_start_x - 3) . '"'
162 . ' y="' . ($data_start_y + 8) . '"'
163 . ' style="' . $a['scale_style']
164 . '">' . $a['data']['max'] . '</text>' . "\n";
165 $ret .= '<text x="' . ($data_start_x - 3) . '"'
166 . ' y="' . ($data_start_y + $a['h'] + 3) . '"'
167 . ' style="' . $a['scale_style']
168 . '">' . $a['data']['min'] . '</text>' . "\n";
169
170 // Data rectangle
171 $ret .= '<g>' . "\n";
172 $ret .= '<rect x="' . $data_start_x . '"'
173 . ' y="' . $data_start_y . '"'
174 . ' width="' . (2 + $a['w'] + 2) . '"'
175 . ' height="' . (2 + $a['h'] + 1 + 2) . '"'
176 . ' style="' . $a['data_style'] . '" />' . "\n";
177
178 $factor = $a['h'] / $a['data']['max'];
179 $x = $data_start_x + 2;
180 foreach ($a['data']['list'] as $pos => $v0) {
181 $v = sprintf('%u', $v0 * $factor);
182
183 $y = $data_start_y + 2 + $a['h'] - $v;
184
185 // marker
186 $ret .= '<rect'
187 . ' x="' . $x . '"'
188 . ' y="' . ($data_start_y + 2 + $a['h']) . '"'
189 . ' width="' . $a['data_line_width'] . '"'
190 . ' height="1"'
191 . ' style="fill: #333"'
192 . '/>' . "\n";
193
194 // value
195 $ret .= '<rect'
196 . ' x="' . $x . '"'
197 . ' y="' . $y . '"'
198 . ' width="' . $a['data_line_width'] . '"'
199 . ' height="' . $v . '"'
200 . ' style="' . $a['data_line_style'] . '"'
201 . '/>' . "\n";
202
203 $x += $a['data_line_width'] + $a['gap'];
204 }
205 $ret .= '</g>' . "\n";
206
207 $ret .= '</svg>' . "\n";
208 return $ret;
209 }
210
File inc/mr.inc.php changed (mode: 100644) (index 536155c..f9f9020)
... ... function rg_mr_merge_set_status($db, $repo_id, $id, $status)
361 361 return $ret; return $ret;
362 362 } }
363 363
364 /*
365 * Loads data for graphs
366 * @unit - interval on which a sum is made
367 */
368 function rg_mr_data($db, $type, $start, $end, $unit)
369 {
370 $params = array('start' => $start, 'end' => $end);
371 switch ($type) {
372 case 'create_mr':
373 $q = 'SELECT itime FROM merge_requests'
374 . ' WHERE itime >= @@start@@ AND itime <= @@end@@';
375 break;
376 default: return FALSE;
377 }
378
379 return rg_graph_query($db, $start, $end, $unit, $q, $params);
380 }
381
364 382 /* /*
365 383 * High level merge request function * High level merge request function
366 384 */ */
File inc/repo.inc.php changed (mode: 100644) (index 89e667f..cdf0bb0)
... ... function rg_repo_lock($db, $repo_id, $uid, $lock, $reason)
1559 1559 return $ret; return $ret;
1560 1560 } }
1561 1561
1562 /*
1563 * Loads data for graphs
1564 * @unit - interval on which a sum is made
1565 */
1566 function rg_repo_data($db, $type, $start, $end, $unit)
1567 {
1568 $params = array('start' => $start, 'end' => $end);
1569 switch ($type) {
1570 case 'create_repo':
1571 $q = 'SELECT itime FROM repos'
1572 . ' WHERE itime >= @@start@@ AND itime <= @@end@@';
1573 break;
1574 case 'create_bug':
1575 $q = 'SELECT itime FROM bugs'
1576 . ' WHERE itime >= @@start@@ AND itime <= @@end@@';
1577 break;
1578 case 'history':
1579 $q = 'SELECT itime FROM repo_history'
1580 . ' WHERE itime >= @@start@@ AND itime <= @@end@@';
1581 break;
1582 default: return FALSE;
1583 }
1584
1585 return rg_graph_query($db, $start, $end, $unit, $q, $params);
1586 }
1587
1562 1588 /* /*
1563 1589 * High level function for Repo -> Admin -> Rights -> Repo/Refs/Path rights menu. * High level function for Repo -> Admin -> Rights -> Repo/Refs/Path rights menu.
1564 1590 */ */
File inc/site/stats.php added (mode: 100644) (index 0000000..413d348)
1 <?php
2 include_once(__DIR__ . '/../graph.inc.php');
3
4 $_sub = empty($paras) ? "" : array_shift($paras);
5 switch ($_sub) {
6 default: /* main stats page */
7 $rg['graph'] = array();
8 $rg['graph']['users'] = 'bla';
9
10 $start = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y') - 1);
11 $end = gmmktime(0, 0, 0, gmdate('m'), gmdate('d') + 1, gmdate('Y')) - 1;
12
13 $subtitle = gmdate('Y-m-d H:i:s', $start)
14 . ' - ' . gmdate('Y-m-d H:i:s', $end) . " UTC\n";
15
16 $a = array(
17 'bg_style' => 'fill: #bdf',
18 'h' => 150,
19 'title_style' => 'color: #fff',
20 'subtitle' => $subtitle,
21 'subtitle_style' => 'color: #00f; font-size: 8pt',
22 'data_style' => 'fill: #ffa',
23 'data_line_style' => 'fill: #f00',
24 'data_line_width' => 1,
25 'gap' => 1,
26 'footer_style' => 'font-color: #000; font-size: 8pt'
27 );
28
29 $b = $a;
30 $b['title'] = '๐Ÿ›ธ Users';
31 $r = rg_user_data($db, 'create_account', $start, $end, 'day');
32 if ($r === FALSE) {
33 $rg['graph']['users'] = 'Error generating graph!';
34 } else {
35 $b['data'] = $r;
36 $rg['graph']['HTML:users'] = rg_graph($b);
37 }
38
39 $b = $a;
40 $b['title'] = '๐Ÿธ Repositories';
41 $r = rg_repo_data($db, 'create_repo', $start, $end, 'day');
42 if ($r === FALSE) {
43 $rg['graph']['repos'] = 'Error generating graph!';
44 } else {
45 $b['data'] = $r;
46 $rg['graph']['HTML:repos'] = rg_graph($b);
47 }
48
49 $b = $a;
50 $b['title'] = '๐Ÿ› Bugs';
51 $r = rg_repo_data($db, 'create_bug', $start, $end, 'day');
52 if ($r === FALSE) {
53 $rg['graph']['repos'] = 'Error generating graph!';
54 } else {
55 $b['data'] = $r;
56 $rg['graph']['HTML:bugs'] = rg_graph($b);
57 }
58
59 $b = $a;
60 $b['title'] = 'โ›™ Merge requests';
61 $r = rg_mr_data($db, 'create_mr', $start, $end, 'day');
62 if ($r === FALSE) {
63 $rg['graph']['repos'] = 'Error generating graph!';
64 } else {
65 $b['data'] = $r;
66 $rg['graph']['HTML:mrs'] = rg_graph($b);
67 }
68
69 $b = $a;
70 $b['title'] = '๐Ÿ“… Repositories history entries';
71 $r = rg_repo_data($db, 'history', $start, $end, 'day');
72 if ($r === FALSE) {
73 $rg['graph']['repos'] = 'Error generating graph!';
74 } else {
75 $b['data'] = $r;
76 $rg['graph']['HTML:repo_history'] = rg_graph($b);
77 }
78
79 $b = $a;
80 $b['title'] = '๐Ÿ”‘ SSH keys';
81 $r = rg_ssh_data($db, 'create_key', $start, $end, 'day');
82 if ($r === FALSE) {
83 $rg['graph']['repos'] = 'Error generating graph!';
84 } else {
85 $b['data'] = $r;
86 $rg['graph']['HTML:keys'] = rg_graph($b);
87 }
88
89 $body .= rg_template('site/stats.html', $rg, TRUE /*xss*/);
90 break;
91 }
File inc/ssh.inc.php changed (mode: 100644) (index 5459e59..00b868e)
... ... function rg_ssh_dispatch($db, $ip, $uid, $orig_cmd)
416 416 return FALSE; // = continue execution return FALSE; // = continue execution
417 417 } }
418 418
419 /*
420 * Loads data for graphs
421 * @unit - interval on which a sum is made
422 */
423 function rg_ssh_data($db, $type, $start, $end, $unit)
424 {
425 $params = array('start' => $start, 'end' => $end);
426 switch ($type) {
427 case 'create_key':
428 $q = 'SELECT itime FROM keys'
429 . ' WHERE itime >= @@start@@ AND itime <= @@end@@';
430 break;
431 default: return FALSE;
432 }
433
434 return rg_graph_query($db, $start, $end, $unit, $q, $params);
435 }
436
419 437 ?> ?>
File inc/user.inc.php changed (mode: 100644) (index c88e6a4..3c46fa5)
... ... function rg_user_nice($db, $uid)
1855 1855 return 'n/a'; return 'n/a';
1856 1856 } }
1857 1857
1858 /*
1859 * Loads data for graphs
1860 * @unit - interval on which a sum is made
1861 */
1862 function rg_user_data($db, $type, $start, $end, $unit)
1863 {
1864 $params = array('start' => $start, 'end' => $end);
1865 switch ($type) {
1866 case 'create_account':
1867 $q = 'SELECT itime FROM users'
1868 . ' WHERE itime >= @@start@@ AND itime <= @@end@@'
1869 . ' AND is_admin = 0';
1870 break;
1871 default: return FALSE;
1872 }
1873
1874 return rg_graph_query($db, $start, $end, $unit, $q, $params);
1875 }
1858 1876
1859 1877 /* /*
1860 1878 * High level functions * High level functions
File root/index.php changed (mode: 100644) (index 3594bf9..73d7f6b)
... ... include_once($INC . "/apikeys.inc.php");
28 28 include_once($INC . "/demo.inc.php"); include_once($INC . "/demo.inc.php");
29 29 include_once($INC . "/ver.php"); include_once($INC . "/ver.php");
30 30 include_once($INC . "/ldap.inc.php"); include_once($INC . "/ldap.inc.php");
31 include_once($INC . "/ssh.inc.php");
31 32
32 33 rg_prof_start("MAIN"); rg_prof_start("MAIN");
33 34
File root/themes/default/index.html changed (mode: 100644) (index b66075a..7d59d9f)
57 57 </div> </div>
58 58
59 59 <div class="footer_info"> <div class="footer_info">
60 <a href="/op/stats">Statistics</a><br />
60 61 <a href="/op/doc/demo">Tutorials</a><br /> <a href="/op/doc/demo">Tutorials</a><br />
61 62 <a href="/op/doc/api">API</a><br /> <a href="/op/doc/api">API</a><br />
62 63 <a href="/op/doc/compare">Comparison</a><br /> <a href="/op/doc/compare">Comparison</a><br />
File root/themes/default/main.css changed (mode: 100644) (index 06b1e2c..334da7f)
... ... legend { padding: 0px 2pt; }
611 611 background-color: #000; background-color: #000;
612 612 color: #fff; color: #fff;
613 613 } }
614
615 .stats_svg {
616 display: grid;
617 padding: 5px;
618 }
File root/themes/default/site/stats.html added (mode: 100644) (index 0000000..03b038d)
1 <div class="main_title">Statistics</div>
2
3 <div class="islands">
4
5 @@graph::users@@
6
7 @@graph::repos@@
8
9 @@graph::bugs@@
10
11 @@graph::mrs@@
12
13 @@graph::repo_history@@
14
15 @@graph::keys@@
16
17 </div>
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main