<commit_before><?php

// id
$fname = empty($_GET['f']) ? $_GET['f'] : '';

// match
if (!preg_match('/^[a-zA-Z0-9\_\-\.]+$/', $fname)) {
  header("HTTP/1.0 404 Not Found");
  echo '404 not found';
  exit;
}

// check path
$path = __DIR__.'/images/'.$fname;
if (!file_exists($path)) {
  header("HTTP/1.0 404 Not Found");
  echo '404 not found';
  exit;
}

// アクセスコントロール
header('Access-Control-Allow-Origin: *');
// output
readfile($path);


<commit_msg>image.php をアップロード<commit_after><?php

// id
$fname = empty($_GET['f']) ? '' : $_GET['f'];

// match
if (!preg_match('/^([0-9]+)\.([a-zA-Z0-9]+)$/', $fname, $m)) {
  header("HTTP/1.0 404 Not Found");
  echo '404 not found';
  exit;
}
$id = $m[1];
$ext = $m[2];

// check path
$path = __DIR__.'/images/'.$fname;
if (!file_exists($path)) {
  header("HTTP/1.0 404 Not Found");
  echo '404 not found';
  exit;
}

// アクセスコントロール
header('Access-Control-Allow-Origin: *');
header('Content-Type: '.get_mime($ext));



// output
readfile($path);

function get_mime($ext) {
  $mime = [
    "jpg" => "image/jpeg",
    "jpeg" => "image/jpeg",
    "jpe" => "image/jpeg",
    "gif" => "image/gif",
    "png" => "image/png",
    "mp3" => "audio/mpeg",
    "ogg" => "audio/ogg",
    "oga" => "audio/ogg",
    "txt" => "text/plain",
    "csv" => "text/csv",
    "tsv" => "text/tsv",
    "xml" => "text/xml",
    "json" => "application/json",
    "js" => "text/javascreipt",
  ];
  $ext = strtolower($ext);
  if (isset($mime[$ext])) {
    return $mime[$ext];
  }
  return "application/octet-stream";
}




{'fraction_non_alphanumeric': 0.2648015614834092, 'fraction_numerical': 0.026675341574495772, 'mean_word_length': 3.1793478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4364399', 'n_tokens_mistral': 691, 'n_tokens_neox': 650, 'n_words': 121}