<?php
require( dirname(__FILE__) . '/wp-config.php' );

$story = $_REQUEST['story'];

nocache_headers();

// insert article lookup here
$ID = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_gl_sid' AND meta_value = '" . $wpdb->escape($story) . "' LIMIT 1");

if ($ID) {
  header('Location: ' . get_permalink($ID));
}
else {
  header('Location: ' . get_settings('siteurl'));
}

?>
