3 require_once( dirname(__FILE__).'/includes/config.php' );
\r
5 // Connect To Database
\r
6 $db = yourls_db_connect();
\r
9 $keyword = yourls_sanitize_string($_GET['id']);
\r
11 // First possible exit:
\r
13 header ('Location: '. YOURLS_SITE);
\r
17 $id = yourls_sanitize_int( yourls_string2int($keyword) );
\r
19 // Get URL From Database
\r
20 $table = YOURLS_DB_TABLE_URL;
\r
21 $url = stripslashes($db->get_var("SELECT `url` FROM `$table` WHERE id = $id"));
\r
23 var_dump($url); die();
\r
27 $update_clicks = $db->query("UPDATE `$table` SET `clicks` = clicks + 1 WHERE `id` = $id");
\r
28 header ('HTTP/1.1 301 Moved Permanently');
\r
29 header ('Location: '. $url);
\r
31 // URL not found. Either reserved, or page, or doesn't exist
\r
34 // Do we have a page?
\r
35 if (file_exists(dirname(__FILE__)."/pages/$keyword.php")) {
\r
36 yourls_page($keyword);
\r
38 // Either reserved id, or no such id
\r
40 header ('HTTP/1.1 307 Temporary Redirect'); // no 404 to tell browser this might change, and also to not pollute logs
\r
41 header ('Location: '. YOURLS_SITE);
\r