File inc/admin.inc.php changed (mode: 100644) (index 2c98283..0ecfcd0) |
... |
... |
function rg_admin_invites_high_level($db, $rg) |
190 |
190 |
*/ |
*/ |
191 |
191 |
function rg_init($db, $rg) |
function rg_init($db, $rg) |
192 |
192 |
{ |
{ |
193 |
|
global $rg_admin_name; |
|
194 |
|
global $rg_admin_email; |
|
195 |
|
|
|
196 |
193 |
rg_prof_start("rg_init"); |
rg_prof_start("rg_init"); |
197 |
194 |
rg_log_enter("rg_init"); |
rg_log_enter("rg_init"); |
198 |
195 |
|
|
|
... |
... |
function rg_init($db, $rg) |
201 |
198 |
$doit = rg_var_uint('doit'); |
$doit = rg_var_uint('doit'); |
202 |
199 |
if ($doit == 0) { |
if ($doit == 0) { |
203 |
200 |
$rg['init']['username'] = 'admin'; |
$rg['init']['username'] = 'admin'; |
204 |
|
$rg['init']['realname'] = $rg_admin_name; |
|
205 |
|
$rg['init']['email'] = $rg_admin_email; |
|
|
201 |
|
$rg['init']['realname'] = ''; |
|
202 |
|
$rg['init']['email'] = ''; |
206 |
203 |
$rg['init']['pass'] = ''; |
$rg['init']['pass'] = ''; |
207 |
204 |
$rg['init']['pass2'] = ''; |
$rg['init']['pass2'] = ''; |
208 |
205 |
$rg['init']['session_time'] = 600; |
$rg['init']['session_time'] = 600; |
|
... |
... |
function rg_admin_report1($db, $rg) |
322 |
319 |
$body .= "Report between " . gmdate('Y-m-d H:i:s', $y_start) |
$body .= "Report between " . gmdate('Y-m-d H:i:s', $y_start) |
323 |
320 |
. " and " . gmdate('Y-m-d H:i:s', $y_end) . " UTC\n"; |
. " and " . gmdate('Y-m-d H:i:s', $y_end) . " UTC\n"; |
324 |
321 |
|
|
325 |
|
$sql = "SELECT COUNT(*) AS total FROM users"; |
|
326 |
|
$res = rg_sql_query($db, $sql); |
|
327 |
|
if ($res === FALSE) { |
|
328 |
|
$total_users = "ERR"; |
|
329 |
|
} else { |
|
330 |
|
$row = rg_sql_fetch_array($res); |
|
331 |
|
$total_users = $row['total']; |
|
332 |
|
$body .= "\nTotal users: " . $total_users . "\n"; |
|
333 |
|
} |
|
334 |
|
rg_sql_free_result($res); |
|
|
322 |
|
$list = array( |
|
323 |
|
'users' => 'users', |
|
324 |
|
'repos' => 'repositories', |
|
325 |
|
'bugs' => 'bugs', |
|
326 |
|
'bug_notes' => 'bug notes', |
|
327 |
|
'keys' => 'keys', |
|
328 |
|
'login_tokens' => 'login tokens', |
|
329 |
|
'scratch_codes' => 'scratch codes', |
|
330 |
|
'merge_requests' => 'pull requests', |
|
331 |
|
'webhooks' => 'webhooks', |
|
332 |
|
'rights' => 'rights', |
|
333 |
|
'events' => 'events'); |
|
334 |
|
foreach ($list as $table => $text) { |
|
335 |
|
// Yesterday |
|
336 |
|
$sql = "SELECT COUNT(*) AS count FROM " . $table |
|
337 |
|
. " WHERE itime >= $y_start" |
|
338 |
|
. " AND itime <= $y_end"; |
|
339 |
|
$res = rg_sql_query($db, $sql); |
|
340 |
|
if ($res === FALSE) { |
|
341 |
|
$yesterday = "ERR"; |
|
342 |
|
} else { |
|
343 |
|
$row = rg_sql_fetch_array($res); |
|
344 |
|
$yesterday = $row['count']; |
|
345 |
|
} |
|
346 |
|
rg_sql_free_result($res); |
|
347 |
|
|
|
348 |
|
// Total |
|
349 |
|
$sql = "SELECT COUNT(*) AS total FROM " . $table; |
|
350 |
|
$res = rg_sql_query($db, $sql); |
|
351 |
|
if ($res === FALSE) { |
|
352 |
|
$total = "ERR"; |
|
353 |
|
} else { |
|
354 |
|
$row = rg_sql_fetch_array($res); |
|
355 |
|
$total = $row['total']; |
|
356 |
|
} |
|
357 |
|
rg_sql_free_result($res); |
335 |
358 |
|
|
336 |
|
$sql = "SELECT COUNT(*) AS total FROM repos"; |
|
337 |
|
$res = rg_sql_query($db, $sql); |
|
338 |
|
if ($res === FALSE) { |
|
339 |
|
$total_repos = "ERR"; |
|
340 |
|
} else { |
|
341 |
|
$row = rg_sql_fetch_array($res); |
|
342 |
|
$total_repos = $row['total']; |
|
343 |
|
$body .= "\nTotal repositories: " . $total_users . "\n"; |
|
|
359 |
|
$body .= "\nYesterday / total " . $text . ": " |
|
360 |
|
. $yesterday . "\t" . $total . "\n"; |
344 |
361 |
} |
} |
345 |
|
rg_sql_free_result($res); |
|
346 |
362 |
|
|
347 |
363 |
$sql = "SELECT username, realname FROM users" |
$sql = "SELECT username, realname FROM users" |
348 |
364 |
. " WHERE itime >= $y_start" |
. " WHERE itime >= $y_start" |
|
... |
... |
function rg_admin_report1($db, $rg) |
391 |
407 |
$rg['ui']['email'] = $rg_admin_email; |
$rg['ui']['email'] = $rg_admin_email; |
392 |
408 |
$rg['mail'] = array(); |
$rg['mail'] = array(); |
393 |
409 |
$rg['mail']['subject'] = 'RocketGit report' |
$rg['mail']['subject'] = 'RocketGit report' |
394 |
|
. ' [' . $users . '/' . $total_users . ']' |
|
395 |
|
. ' [' . $repos . '/' . $total_repos . ']' |
|
396 |
|
. ' ' . $sug['yesterday'] . 's'; |
|
|
410 |
|
. ' [' . $users . 'u]' |
|
411 |
|
. ' [' . $repos . 'r]' |
|
412 |
|
. ' [' . $sug['yesterday'] . 's]'; |
397 |
413 |
$rg['mail']['body'] = $body; |
$rg['mail']['body'] = $body; |
398 |
414 |
rg_mail_template("mail/admin/report1", $rg); |
rg_mail_template("mail/admin/report1", $rg); |
399 |
415 |
} |
} |