Hi.. I had a semi popular URL shortening website but as it's now offline I have no use for the script.
Features:
- Shortening URLs and providing the short url
- htaccess for dynamic short urls
- OOP PHP
- Simple yet elegant design
- Template system
Here is the shortening class for a taste of what is inside the download;
Download; Download SOSHORT.rar @ UppITCode:<?php class SoShort { public function ParseConfig() { require_once "inc/config.php"; $this->config = new Config; } public function AddURL($short_code, $full_url) { global $db; $db->real_query("INSERT INTO `urls` (`original_url`, `short_code`, `active`) VALUES ('" . $full_url . "', '" . $short_code . "', '1')") or die($db->error); } public function IsAlreadyShortened($full_url) { global $db; if($query = $db->query("SELECT `full_url` FROM `urls` WHERE `full_url` = '" . $full_url . "'")) { $num = $query->num_rows; if($num > 0) { return true; } } return false; } public function GetURLInfo($url, $info) { global $db; if($query = $db->query("SELECT `" . $info . "` FROM `urls` WHERE `original_url` = '" . $url . "'")) { while($dRow = $query->fetch_row()) { $data = $dRow[0]; } return $data; } } public function GenerateShortURL() { $strs = "1234567890asdfghjklqwertyuiopzxcvbnm"; $random = ''; for($i = 0; $i < 5; $i++) { $random .= $strs[mt_rand(0, strlen($strs) - 1)]; } return $random; } public function IsAURL($url) { if(strpos($url, 'http://') !== false) { return true; } else if(strpos($url, 'https://') !== false) { return true; } return false; } public function GetFullFromShort($url) { global $db; if($query = $db->query("SELECT `original_url` FROM `urls` WHERE `short_code` = '" . $url . "'")) { while($data = $query->fetch_assoc()) { $return = $data['original_url']; } } return $return; } public function DoesShortURLExist($url) { global $db; if($query = $db->query("SELECT null FROM `urls` WHERE `short_code` = '" . $url . "'")) { $num = $query->num_rows; if($num >= 1) { return true; } } return false; } public function GetNumberOfURLs() { global $db; if($query = $db->query("SELECT null FROM urls")) { return number_format($query->num_rows); } return 0; } } ?>
Have fun & good luck with php



Reply With Quote![[Release] URL Shortner in OOP PHP](http://ragezone.com/hyper728.png)


