TinyURL
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16

Thread: TinyURL

  1. #1
    Registered User Gollo's Avatar
    Join Date
    Sep 2001
    Location
    Grand Rapids, Michigan US of A
    Posts
    2,383

    TinyURL

    TinyURL

    Might be helpfull when trying to post a link to a ms KB article or something.

  2. #2
    Driver Terrier NooNoo's Avatar
    Join Date
    Dec 2000
    Location
    UK
    Posts
    31,824
    TinyURL was created!
    The following URL:

    http://service1.symantec.com/SUPPORT...h.nsf/d3c44a16
    78bd8f45852566aa005902cb/3f2460f30caa6f6e88256b7d00699200?Op
    enDocument&sone=nav_2003_tasks.html&stg=3&prod=Nor ton%20Anti
    Virus&ver=2003%20for%20Windows%202000/Me/98/XP&base=http://w
    ww.symantec.com/techsupp/nav/&next=nav_2003_contact_tscs_oth
    er.html&src=sg&pcode=nav&svy=

    has a length of 329 characters and resulted in the following TinyURL which has a length of 23 characters:
    http://tinyurl.com/629k

  3. #3
    Registered User The Computer Valet's Avatar
    Join Date
    May 2002
    Location
    Billerica, MA
    Posts
    699
    http://makeashorterlink.com

    is another one.

    I think the only potential issue with these services is the links expire after a time.

    Maybe that's not true with TinyURL, but it was/is was Makeashorterlink.

    m

  4. #4
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406
    oh man how ez is this...

    all there doing is having you post a link into there database then giving you a link..

    then when someone clicks on that link it looks at the end number and checks the database sees it then sends you to the url in the database..


    humm I should write somthing like this

  5. #5
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406
    ok I just created one

    http://go.rbcode.com/

    if you cannot connect to the site right now, it will be fully operational tommorrow.. I just had my web hosting service create a virtual doamin for me..

  6. #6
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406

  7. #7
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406
    for those who would like the script

    here is index.php

    PHP Code:
    <link href="style.css" rel="stylesheet" type="text/css"> 
    <?
    include('function.php');
    if ($_REQUEST["Submit"] == "Submit") {
    $today = date("F j, Y, g:i a"); 

    $connect = mysql_connect("localhost", "root", "") or die ("<b><center>".mysql_errno().": ".mysql_error()."</b></center>\n");
    $db = mysql_select_db("shortlink", $connect) or die ("<b><center>".mysql_errno().": ".mysql_error()."</b></center>\n");
    $sql = "INSERT INTO link SET SLink = '".$_REQUEST["linkit"]."', SDate = '".$today."', SIP = '".$_SERVER["REMOTE_ADDR"]."'";
    $sql_result = mysql_query($sql, $connect) or die ("<b><center>".mysql_errno().": ".mysql_error()."</b></center>\n");
            
    $check_query = "SELECT * FROM link WHERE SIP = '".$_SERVER["REMOTE_ADDR"]."' AND SDate = '".$today."'";
    $results = mysql_query($check_query, $connect); 
    while ($row = mysql_fetch_array($results)){
            $geturl = $row["SLink"];
            $id = $row["SID"];
    }
    $filename = "l/$id.php";
    touch ($filename);
    $count = strlen($_REQUEST["linkit"]);
    $count2 = strlen("http://go.rbcode.com/l/".$id.".php");
    $somecontent = "<? \n header(\"Location: $geturl\"); \n exit; \n ?>";

    if (is_writable($filename)) {
        if (!$fp = fopen($filename, 'a')) {
             print "Cannot open file ($filename)";
             exit;
        }
        // Write $somecontent to our opened file.
        if (!fwrite($fp, $somecontent)) {
           print "Cannot write to file ($filename)";
            exit;
       }
       }

    echo "<i>ShortLink was created!</i> <br>";
    $str = wordwrap($_REQUEST["linkit"], 20);
    ?>
    <b>The following URL:</b> <br> <? echo "$str\n"; ?>
    <br><br>
    <?
    echo "Link provided has a length of ".$count." and has been shrunk to ".$count2."<br>";
    echo "<a href=\"http://go.rbcode.com/1/".$id.".php\">[url]http://go.rbcode.com/l/[/url]".$id.".php</a>";

    mysql_close($conenct);
    } else {
    form();
    }
    ?>
    here is function.php

    PHP Code:
    <?
    function form() {
    ?>
    <form name="shrinkit" method="post" action="<? echo $PHP_SELF; ?>">
    <table width="640" border="0" cellspacing="1" cellpadding="0">
      <tr bgcolor="#C8D2DB"> 
        <td width="148" bgcolor="#C8D2DB" class="txt">Enter Link to Shrink</td>
        <td width="489" nowrap bgcolor="#DFE4EA"> 
          <input name="linkit" type="text" class="form" size="65">
        </td>
      </tr>
      <tr align="center" bgcolor="#C8D2DB"> 
        <td colspan="2"> 
          <input name="Submit" type="submit" class="form" value="Submit"> 
          <input name="Submit2" type="reset" class="form" value="Reset"> 
        </td>
      </tr>
    </table>
    </form>
    <?
    }
    ?>
    now all you gotta do is create a subdirectory called "l" and if its on a linux box give it full rights chmod 777

    and here is the sql create commands for mysql

    Code:
    # Host: localhost
    # Database: shortlink
    # Table: 'link'
    # 
    CREATE TABLE `link` (
      `SID` int(11) NOT NULL auto_increment,
      `SLink` longtext NOT NULL,
      `SDate` text NOT NULL,
      `SIP` text NOT NULL,
      PRIMARY KEY  (`SID`)
    ) TYPE=MyISAM;
    Last edited by +Daemon+; February 25th, 2003 at 05:23 PM.

  8. #8
    Registered User Gollo's Avatar
    Join Date
    Sep 2001
    Location
    Grand Rapids, Michigan US of A
    Posts
    2,383
    lol!!! that's amazing! You crack me up danimal.

  9. #9
    Registered User ANumber1's Avatar
    Join Date
    Feb 2003
    Posts
    8

    Wink Changes to script

    Nice script. But you should change it to not write a file for every link. Just have them goto your script with the id of the link in your database and feed it back to them.

    PS. I hope you dont use "root" user to connect to your mysql
    Last edited by ANumber1; February 26th, 2003 at 09:44 AM.

  10. #10
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406
    nope I put root and "" for password all the time when I show my code

    I have it write a file every time for the short url.. if I did a varible then the id it makes it longer.. plus the files are only 200 bytes and less... doesnt take any space.. and you can clear the old filed links later...

    I have the url and ip logged from the user so I can make another page for a bookmark page, so the shortin links wont just be lost forever

  11. #11
    Registered User DANIMAL's Avatar
    Join Date
    Dec 2000
    Location
    Ontario, Canada
    Posts
    2,991
    Originally posted by Gollo
    lol!!! that's amazing! You crack me up danimal.

    ??????

  12. #12
    Registered User Gollo's Avatar
    Join Date
    Sep 2001
    Location
    Grand Rapids, Michigan US of A
    Posts
    2,383
    Originally posted by DANIMAL
    ??????
    HA HA I just realized I wrote your name and not daemon. Sorry.

  13. #13
    Registered User DANIMAL's Avatar
    Join Date
    Dec 2000
    Location
    Ontario, Canada
    Posts
    2,991
    I figured as Much!

  14. #14
    Registered User +Daemon+'s Avatar
    Join Date
    Jan 2002
    Location
    RC, Ca
    Posts
    3,406

  15. #15
    Registered User Thunderwind's Avatar
    Join Date
    Apr 2001
    Location
    South Jersey USA
    Posts
    330
    You should title your page.

    Maybe Shrink that Link

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •