Файл: С™а®ѓв/go.php
Строк: 30
<?php
# Автор Иван Данилов http://vk.com/it_is_qwerty (ICQ: 936545; SKYPE: Pro100PHP)
$_GET['u'] = str_replace(".wab.lt","",$_SERVER['HTTP_HOST']);
if(isset($_GET['u'])){
# Настройки
Class Config{
const dbHost = 'localhost';
const db = 'wab_wapcoder_wab';
const dbUser = 'wab_wapcoder_wab';
const dbPassword = 'u9vOL6kT';
const limit = '1000';
}
# Подключение к базе данных
try{
$db = new PDO("mysql:host=".Config::dbHost.";dbname=".Config::db."", Config::dbUser, Config::dbPassword);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("set names utf8");
}
catch(PDOException $e){
echo $e->getMessage();
}
# Буквы в цифры
function url($id){
$arr = array('a' => '0','b' => '1','c' => '2','d' => '3','e' => '4','f' => '5','g' => '6','h' => '7','i' => '8','j' => '9');
$result = "";
$simbs = strlen($id);
for($i = 0; $i < $simbs; $i++){
$result .= $arr[substr($id, $i, 1)];
}
return $result;
}
$id = url($_GET['u']);
if(strlen($id) != strlen($_GET['u'])){
exit('ERR: ID missed');
}else{
$url = $db->prepare("SELECT `url` FROM `urls` WHERE `id` = ?");
$url->bindValue(1, $id, PDO::PARAM_STR);
$url->execute();
$url_url = $url -> fetch(PDO::FETCH_ASSOC);
if(empty($url_url['url'])) exit('ERR: ID missed');
if(substr($url_url['url'], 0, 7) != "http://" && substr($url_url['url'], 0, 8) != "https://" && substr($url_url['url'], 0, 6) != "ftp://"){
header("Location: http://".$url_url['url']."");
echo '
<script language="JavaScript">
window.location.href = "http://'.$url_url['url'].'"
</script>
<a href="http://'.$url_url['url'].'">http://'.$url_url['url'].'</a>
';
}else{
header("Location: ".$url_url['url']."");
echo '
<script language="JavaScript">
window.location.href = "'.$url_url['url'].'"
</script>
<a href="'.$url_url['url'].'">'.$url_url['url'].'</a>
';
}
}
}else{
exit('ERR: ID missed');
}
?>