<commit_before><?php
/**
 * Redirector
 * This file handles all incoming URL keys, increments the counter, and forwards
 * along to the destination if it exists
 */

if (!file_exists('config.php')) {
    die('Configuration file missing. Please copy config.php.default to config.php and fill in the values.');
}

require 'config.php';

$db = mysql_connect($db_host, $db_user, $db_pass) or die ('Could not connect to database');
mysql_select_db($db_name) or die('Could not select database');

$path = dirname($_SERVER['PHP_SELF']);
$key = mysql_real_escape_string(str_replace($path.'/', '', $_SERVER['REQUEST_URI']));

// key is a MySQL reserved word
$qry = mysql_query("SELECT * FROM lilliputian WHERE `key` = '{$key}' LIMIT 1");

$result = mysql_fetch_array($qry);

if ($result) {
    mysql_query("UPDATE lilliputian SET hits = hits + 1 WHERE `key` = '{$key}'");
    
    header('Location: '.$result['url']);
    exit;
}
else {
    die('Bad URL! Bad!');
}

?><commit_msg>Fixing a slash bug when used at top-level<commit_after><?php
/**
 * Redirector
 * This file handles all incoming URL keys, increments the counter, and forwards
 * along to the destination if it exists
 */

if (!file_exists('config.php')) {
    die('Configuration file missing. Please copy config.php.default to config.php and fill in the values.');
}

require 'config.php';

$db = mysql_connect($db_host, $db_user, $db_pass) or die ('Could not connect to database');
mysql_select_db($db_name) or die('Could not select database');

$path = dirname($_SERVER['PHP_SELF']);
$path = ($path == '/') ? '' : $path;
$key = mysql_real_escape_string(str_replace($path.'/', '', $_SERVER['REQUEST_URI']));

// key is a MySQL reserved word
$qry = mysql_query("SELECT * FROM lilliputian WHERE `key` = '{$key}' LIMIT 1");

$result = mysql_fetch_array($qry);

if ($result) {
    mysql_query("UPDATE lilliputian SET hits = hits + 1 WHERE `key` = '{$key}'");
    
    header('Location: '.$result['url']);
    exit;
}
else {
    die('Bad URL! Bad!');
}

?>
{'fraction_non_alphanumeric': 0.16791230692575984, 'fraction_numerical': 0.001993024414549078, 'mean_word_length': 4.624649859943977, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4957637', 'n_tokens_mistral': 659, 'n_tokens_neox': 651, 'n_words': 200}