<commit_before><?php

// Make sure we are called from index.php
if (!defined('SECURITY'))
die('Hacking attempt');

// Check user token
$id = $user->checkApiKey($_REQUEST['api_key']);

// We have to check if that user is admin too
if ( ! $user->isAdmin($id) ) {
  header("HTTP/1.1 401 Unauthorized");
  die("Access denied");
}

// Is it a username or a user ID
ctype_digit($_REQUEST['id']) ? $id = $_REQUEST['id'] : $id = $user->getUserId($_REQUEST['id']);

// Output JSON format
echo json_encode(array('getuserworkers' => $worker->getWorkers($id)));

// Supress master template
$supress_master = 1;
?>
<commit_msg>Allow regular users to check their own workers<commit_after><?php

// Make sure we are called from index.php
if (!defined('SECURITY'))
die('Hacking attempt');

// Check user token
$user_id = $user->checkApiKey($_REQUEST['api_key']);

// We have to check if that user is admin too
if ( ! $user->isAdmin($user_id) && ($_REQUEST['id'] != $user_id && !empty($_REQUEST['id']))) {
  header("HTTP/1.1 401 Unauthorized");
  die("Access denied");
} else if ($user->isAdmin($user_id)) {
  $id = $_REQUEST['id'];
  ctype_digit($_REQUEST['id']) ? $id = $_REQUEST['id'] : $id = $user->getUserId($_REQUEST['id']);
} else {
  $id = $user_id;
}

// Output JSON format
echo json_encode(array('getuserworkers' => $worker->getWorkers($id)));

// Supress master template
$supress_master = 1;
?>

{'fraction_non_alphanumeric': 0.19726421886249101, 'fraction_numerical': 0.008639308855291577, 'mean_word_length': 4.94017094017094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3946931', 'n_tokens_mistral': 471, 'n_tokens_neox': 462, 'n_words': 126}