<commit_before><?php
require_once 'ykval-common.php';
require_once 'ykval-config.php';
require_once 'ykval-db.php';

header("content-type: text/plain");

if ($baseParams['__YKR_IP__'] != $_SERVER["REMOTE_ADDR"]) {
  logdie("ERROR Authorization failed");
}

# Parse input
$yk = $_REQUEST["yk"];
$do = $_REQUEST["do"];
if (!$yk || !$do) {
  logdie("ERROR Missing parameter");
}
if (!preg_match("/^([cbdefghijklnrtuv]{0,16})$/", $yk)) {
  logdie("ERROR Unknown yk value: $yk");
}
if ($do != "enable" && $do != "disable") {
  logdie("ERROR Unknown do value: $do");
}

# Connect to db
$db = new Db($baseParams['__YKVAL_DB_DSN__'],
	     $baseParams['__YKVAL_DB_USER__'],
	     $baseParams['__YKVAL_DB_PW__'],
	     $baseParams['__YKVAL_DB_OPTIONS__'], 
	     'ykval-revoke:db');
if (!$db->connect()) {
  logdie("ERROR Database connect error");
}

# Check if key exists
$r = $db->findBy('yubikeys', 'yk_publicname', $yk, 1);
if (!$r) {
  logdie("ERROR Unknown yubikey: $yk");
}

# Enable/Disable the yubikey
if (!$db->updateBy('yubikeys', 'yk_publicname', $yk,
		   array('active'=>($do == "enable" ? "TRUE" : "FALSE")))) {
  logdie("ERROR Could not $do for $yk (rows $rows)");
}

# We are done
logdie("OK Processed $yk with $do");
?>
<commit_msg>MySQL does not parse 'TRUE' as a true boolean, use '1' instead.<commit_after><?php
require_once 'ykval-common.php';
require_once 'ykval-config.php';
require_once 'ykval-db.php';

header("content-type: text/plain");

if ($baseParams['__YKR_IP__'] != $_SERVER["REMOTE_ADDR"]) {
  logdie("ERROR Authorization failed");
}

# Parse input
$yk = $_REQUEST["yk"];
$do = $_REQUEST["do"];
if (!$yk || !$do) {
  logdie("ERROR Missing parameter");
}
if (!preg_match("/^([cbdefghijklnrtuv]{0,16})$/", $yk)) {
  logdie("ERROR Unknown yk value: $yk");
}
if ($do != "enable" && $do != "disable") {
  logdie("ERROR Unknown do value: $do");
}

# Connect to db
$db = new Db($baseParams['__YKVAL_DB_DSN__'],
	     $baseParams['__YKVAL_DB_USER__'],
	     $baseParams['__YKVAL_DB_PW__'],
	     $baseParams['__YKVAL_DB_OPTIONS__'], 
	     'ykval-revoke:db');
if (!$db->connect()) {
  logdie("ERROR Database connect error");
}

# Check if key exists
$r = $db->findBy('yubikeys', 'yk_publicname', $yk, 1);
if (!$r) {
  logdie("ERROR Unknown yubikey: $yk");
}

# Enable/Disable the yubikey
if (!$db->updateBy('yubikeys', 'yk_publicname', $yk,
		   array('active'=>($do == "enable" ? "1" : "0")))) {
  logdie("ERROR Could not $do for $yk (rows $rows)");
}

# We are done
logdie("OK Processed $yk with $do");
?>

{'fraction_non_alphanumeric': 0.21702970297029703, 'fraction_numerical': 0.004356435643564357, 'mean_word_length': 5.086746987951807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3778951', 'n_tokens_mistral': 998, 'n_tokens_neox': 973, 'n_words': 217}