Mar
15
2008

Sharing the voolia.com core

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.

Written by Kevin in: MySQL, PHP, WebDev |

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes