I started a sideproject called Voolia a few weeks ago so I could send multiple urls through Twitter. After getting it to a stable state (meaning it functions perfectly for what I want to do lol), I just left it alone. I checked the stats on it today to find that it has been getting some attention from random websites...pretty neat.
You might be surprised at how simple the base of the site is. It's under 50 line (counting empty lines and comments!) ...check it out:
<? //define vars $links = $_POST["links"]; $email = $_POST["email"]; $dateadded = date('Y/n/j'); //build callsign // Notice that I don't user lowercase l and the number 1....too easily mistaken for eachother. function createsign() { $chars = "abcdefghijkmnopqrstuvwxyz023456789ABCDEFGHIJKMNOPQRSTUVWXYZ"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 2) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass;} $callsign = createsign(); //Check if callsign already exists... $q2 = mysql_query("SELECT * FROM links WHERE callsign='$callsign'"); $q3 = mysql_fetch_object($q2); if($q3->callsign == $callsign) { $callsign = createsign(); //do it again } //insert vars $insertlinksquery = "INSERT INTO links (links, dateadded, email, hits, ip, callsign) VALUES ('$links', '$dateadded', '$email', '0', '".$_SERVER['REMOTE_ADDR']."', '$callsign')"; $runinsertlinksquery = mysql_query($insertlinksquery) or die(mysql_error()); //now do a foreach and insert each url within the murl as $callsign+1; //first, we pull up what we just insertted ...i need to make this more efficient! $result = mysql_query("SELECT * FROM links WHERE callsign='$callsign1'"); $row = mysql_fetch_array($result); $linksrow = $row['links']; $i = 0; $chunks = spliti (" ", $links, 100); //print_r($chunks); foreach ($chunks as $value) { if($value == "") { $newstring = "http://voolia.com"; $cliprow = "http://voolia.com"; } //get rid of empty links from bookmarklet and replace with voolia.com for kicks and giggles $i++; $individualcallsign = "$callsign$i"; $insertindividual = "INSERT INTO links (links, dateadded, email, hits, ip, callsign) VALUES ('$value', '$dateadded', '$email', '0', '".$_SERVER['REMOTE_ADDR']."', '$individualcallsign')"; $runinsertindividual = mysql_query($insertindividual) or die(mysql_error()); } ?>
Isn't that amazingly simple?...I think so. With just a tiny bit of .htaccess manipulation, you can have your own url redirection service....I find these handy.
This entry was posted on Saturday, March 15th, 2008 at 12:53 pm and is filed under Blog, MySQL, PHP, WebDev. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get a Trackback link
No Comments Yet
You can be the first to comment!
Leave a comment