File inc/repo.inc.php changed (mode: 100644) (index 8a47e7f..16f886b) |
... |
... |
function rg_repo_ref_canon($ref) |
344 |
344 |
return $ref; |
return $ref; |
345 |
345 |
} |
} |
346 |
346 |
|
|
|
347 |
|
/* |
|
348 |
|
* Compare function for repo names |
|
349 |
|
*/ |
|
350 |
|
function rg_repo_compare_names($a, $b) |
|
351 |
|
{ |
|
352 |
|
if (empty($a)) |
|
353 |
|
return TRUE; |
|
354 |
|
|
|
355 |
|
$qmisc = str_replace('`', '', $a); |
|
356 |
|
$ret = preg_match('`^' . $qmisc . '`uD', $b); |
|
357 |
|
rg_log('repo_compare_names: ret=' . $ret . ' a=' . $a . ' b=' . $b |
|
358 |
|
. ' [qmisc=' . $qmisc . '] => ' |
|
359 |
|
. ($ret === 1 ? 'match' : 'no match')); |
|
360 |
|
|
|
361 |
|
return $ret === 1; |
|
362 |
|
} |
|
363 |
|
|
347 |
364 |
/* |
/* |
348 |
365 |
* Compare function for refs |
* Compare function for refs |
349 |
366 |
*/ |
*/ |
File inc/stats.inc.php changed (mode: 100644) (index df091b6..05cce28) |
... |
... |
function rg_stats_conns_insert($db) |
124 |
124 |
'login_uid' => 0, |
'login_uid' => 0, |
125 |
125 |
'repo_id' => 0, |
'repo_id' => 0, |
126 |
126 |
'bytes_in' => 0, |
'bytes_in' => 0, |
127 |
|
'bytes_out' => 0 |
|
|
127 |
|
'bytes_out' => 0, |
|
128 |
|
'flags' => '' |
128 |
129 |
); |
); |
129 |
130 |
foreach ($list as $k => $v) |
foreach ($list as $k => $v) |
130 |
131 |
if (!isset($rg_stats_conns_paras[$k])) |
if (!isset($rg_stats_conns_paras[$k])) |
|
... |
... |
function rg_stats_conns_insert($db) |
138 |
139 |
|
|
139 |
140 |
$sql = 'INSERT INTO conns_' . gmdate('Y_m', $rg_stats_conns_paras['start']) |
$sql = 'INSERT INTO conns_' . gmdate('Y_m', $rg_stats_conns_paras['start']) |
140 |
141 |
. ' (type, uid, login_uid, repo_id, itime, ip, url' |
. ' (type, uid, login_uid, repo_id, itime, ip, url' |
141 |
|
. ', referer, elap, ua, cmd, bytes_in, bytes_out)' |
|
|
142 |
|
. ', referer, elap, ua, cmd, bytes_in, bytes_out, flags)' |
142 |
143 |
. ' VALUES (@@type@@, @@uid@@, @@login_uid@@' |
. ' VALUES (@@type@@, @@uid@@, @@login_uid@@' |
143 |
144 |
. ', @@repo_id@@, @@start@@, @@ip@@, @@url@@' |
. ', @@repo_id@@, @@start@@, @@ip@@, @@url@@' |
144 |
145 |
. ', @@referer@@, @@elap@@, @@ua@@, @@cmd@@' |
. ', @@referer@@, @@elap@@, @@ua@@, @@cmd@@' |
145 |
|
. ', @@bytes_in@@, @@bytes_out@@)'; |
|
|
146 |
|
. ', @@bytes_in@@, @@bytes_out@@, @@flags@@)'; |
146 |
147 |
$res = rg_sql_query_params($db, $sql, $rg_stats_conns_paras); |
$res = rg_sql_query_params($db, $sql, $rg_stats_conns_paras); |
147 |
148 |
if ($res == FALSE) { |
if ($res == FALSE) { |
148 |
149 |
rg_internal_error('cannot insert conns: ' . rg_sql_error()); |
rg_internal_error('cannot insert conns: ' . rg_sql_error()); |
File inc/user/repo-page.php changed (mode: 100644) (index 6f3155c..d1b1db3) |
... |
... |
$_subop = empty($paras) ? "history" : array_shift($paras); |
359 |
359 |
if (strcmp($_subop, "history") == 0) { |
if (strcmp($_subop, "history") == 0) { |
360 |
360 |
rg_add_clone_hints($db, $rg, ''); |
rg_add_clone_hints($db, $rg, ''); |
361 |
361 |
|
|
362 |
|
$time_limit = $rg['ri']['itime']; |
|
|
362 |
|
$time_limit = max($rg['ri']['itime'], time() - 30 * 24 * 3600); |
363 |
363 |
$hist = rg_repo_history_load($db, $rg['ri']['repo_id'], 0, 20, $time_limit); |
$hist = rg_repo_history_load($db, $rg['ri']['repo_id'], 0, 20, $time_limit); |
364 |
364 |
if ($hist === FALSE) |
if ($hist === FALSE) |
365 |
365 |
$_repo_body .= rg_warning("Cannot load history. Try again later."); |
$_repo_body .= rg_warning("Cannot load history. Try again later."); |
File root/index.php changed (mode: 100644) (index 6f170f0..e8f7d83) |
... |
... |
if ($r === FALSE) { |
129 |
129 |
rg_debug_set(rg_state_get($db, 'debug')); |
rg_debug_set(rg_state_get($db, 'debug')); |
130 |
130 |
|
|
131 |
131 |
$lim = rg_rate_limit($db); |
$lim = rg_rate_limit($db); |
132 |
|
if (($lim == 0) && (rg_debug() == 0)) { |
|
133 |
|
rg_log('Too many requests'); |
|
134 |
|
header($rg['proto'] . ' 429 Too many requests (lim)'); |
|
135 |
|
echo 'Too many requests. Please slow down.' . "\n"; |
|
136 |
|
exit(0); |
|
137 |
|
} else if ($lim > 0) |
|
|
132 |
|
if ($lim == 0) { |
|
133 |
|
if (rg_debug() == 0) { |
|
134 |
|
rg_log('Too many requests'); |
|
135 |
|
header($rg['proto'] . ' 429 Too many requests (lim)'); |
|
136 |
|
echo 'Too many requests. Please slow down.' . "\n"; |
|
137 |
|
exit(0); |
|
138 |
|
} |
|
139 |
|
} else if ($lim > 0) { |
138 |
140 |
header('X-RocketGit-Limit-Left: ' . $lim); |
header('X-RocketGit-Limit-Left: ' . $lim); |
|
141 |
|
} |
139 |
142 |
|
|
140 |
143 |
// Sets http(s)_allow and hostname |
// Sets http(s)_allow and hostname |
141 |
144 |
$hostname = rg_state_get($db, 'hostname'); |
$hostname = rg_state_get($db, 'hostname'); |