0) { $hash = substr($charset, 0, HASH_LENGTH); } $result = mysqli_query($mysqli, "INSERT INTO " . DB_TABLE . " (id, url, ip, count) VALUES ('$hash', '$url', '$clientip', '0')"); if (!mysqli_affected_rows($mysqli)) { print "FAILURE INSERTING\n"; } } return $hash; } function find_short($hash, $mysqli) { $result = mysqli_query($mysqli, "SELECT * FROM " . DB_TABLE . " WHERE id='" . mysqli_real_escape_string($mysqli, $hash) . "'"); if ($row = mysqli_fetch_assoc($result)) { $link = $row['url']; mysqli_query($mysqli, "UPDATE " . DB_TABLE . " SET count='" . ($row['count'] + 1) . "' WHERE id='" . $row['id'] . "'"); } else { $link = false; } return $link; } if (isset($_POST['url'])) { if ($_POST['url'] != '' && strlen($_POST['url']) > 0) { $db = db_connect(); $link = generate_short($_POST['url'], $db); } else { $link = false; } } if (isset($_GET['hash']) && $_GET['hash'] != '' && strlen($_GET['hash']) > 0) { $path = explode('/', $_SERVER['REQUEST_URI']); $uri = $path[count($path)-1]; if ($uri != '') { $db = db_connect(); $link = find_short($uri, $db); if ($link != '') { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Wed, 29 Feb 1984 00:00:00 GMT"); header("Location: $link", TRUE, 301); } } } if ($callback == 'NO') { $db = db_connect(); $count = count_urls($db); ?> <?php print SITE_TITLE ?>
Unknown / Invalid URL"; } else { if ($link != '') { echo "" . BASE_URL . $link . ""; } } ?>

Currently holding entries.