Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Vasanth V  >  URL shortener by hycus  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example file
Class: URL shortener by hycus
Create short URLs storing them in a MySQL database
Author: By
Last change:
Date: 2011-04-14 23:25
Size: 1,040 bytes
 

Contents

Class file image Download
<?php
require_once('hycus_urlshortener.php');

$v array_reverse(explode("/"$_SERVER['REQUEST_URI']));
$shorturlid $v[0];
$urlshortener = new hycus_urlshortener();

if(
$shorturlid){
    
$urlshortener->goto_url($urlshortener->baseurl.$shorturlid);
}else{
    if(
$_POST['longurl']){
        
$shorturl $urlshortener->get_shorturl($_POST['longurl']);
        
$hits $urlshortener->get_hits($shorturl);
    }
    echo 
'<center>';
        echo 
'<h3>Hycus URL shortener script</h3>';
        echo 
'<form action="" method="post">';
            echo 
'<input type="text" name="longurl" style="width:500px;"/><br/><br/>';
            echo 
'<input type="submit" value="Get short URL" />';
        echo 
'</form>';

        if(
$shorturl){
            echo 
'<br/><br/><span style="background:#efefef;padding:10px;border:thin solid #777777;font-size:20px;"><a href="'.$shorturl.'" target="_blank">'.$shorturl.'</a></span>';

            echo 
'<br/><br/><br/><span style="background:#efefef;padding:10px;border:thin solid #777777;font-size:20px;">Hits: '.$hits.'</span>';

        }

    echo 
'</center>';
}
?>