<commit_before><?php
error_reporting(E_ALL);

header("Access-Control-Allow-Origin: web-platform.test");

$data = "no data";

if (isset($_POST["file"]) && isset($_POST["log"])) {
  $file = $_POST["file"];
  $data = $_POST["log"];

  if (preg_match('/^[0-9a-km-z]{6}$/', $file)) {

    $fp = fopen("./logs/$file.log", "a");
    if (!$fp) {
      echo "Not able to open file: $file";
      return;
    }

    fwrite($fp, $data, strlen($data));
    fclose($fp);
  }
} else {
  echo "Missing: file or log parameter";
}
?>
<?php
echo "Uploaded to: $file.log";<commit_msg>Allow posting from anywhere, does not really open up any security issue as you could post to the script not using AJAX.<commit_after><?php
error_reporting(E_ALL);

header("Access-Control-Allow-Origin: *");

$data = "no data";

if (isset($_POST["file"]) && isset($_POST["log"])) {
  $file = $_POST["file"];
  $data = $_POST["log"];

  if (preg_match('/^[0-9a-km-z]{6}$/', $file)) {

    $fp = fopen("./logs/$file.log", "a");
    if (!$fp) {
      echo "Not able to open file: $file";
      return;
    }

    fwrite($fp, $data, strlen($data));
    fclose($fp);
  }
} else {
  echo "Missing: file or log parameter";
}
?>
<?php
echo "Uploaded to: $file.log";
{'fraction_non_alphanumeric': 0.22704918032786886, 'fraction_numerical': 0.004918032786885246, 'mean_word_length': 3.607547169811321, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5845001', 'n_tokens_mistral': 459, 'n_tokens_neox': 453, 'n_words': 111}