Making a TinyURL php script...

w0lv3r1ne

Solid State Member
Messages
20
Hello guys, i dont know very much php but i know enough to follow directions.

Im trying to modify an already existing php script. The script is called phpFaber TinyLink and is available for free here.

I have uploaded it to the link below but i have not set up the mysql db yet.
http://uploadtemp.thetechaddict.net/phpfaber_tinylink/

Instead of a submit line i want to have a text box where i can post multiple URLs.

For example...i post one url on one line....the 2nd url on the 2nd line..and the 3rd url on the 3rd line....and so on.

Then i when the user clicks submit(make tinylink)...i want php to convert each line to its own Tinylink and store it in the database. Then for it to display the new tiny links in order.

This doesnt sound too hard, im just not sure where to start.

INDEX.PHP FILE:
<?php

require_once("./tiny_includes/config.php");
$smarty = new Smarty;
$smarty->template_dir = "$dir_ws/tiny_templates";
$smarty->compile_dir = "$dir_ws/tiny_templates_c";
$smarty->assign("url_to_index",$config['url_to_index']);

$HTTP_SESSION_VARS['searchurl'] = '';
$randlink = '';

if($_SERVER['QUERY_STRING'] && !$fullurl && !preg_match('/[\W]/',$_SERVER['QUERY_STRING'])){
//loading index.php with query
if($res = checkQueryString($_SERVER['QUERY_STRING'])){
//query found
if($res['showsplash'] && $config['refreshrate']){
$smarty->assign("fullurl",$res['fullurl']);
$smarty->assign("refreshrate",$config['refreshrate']);
$smarty->assign("ad",getAd());
$smarty->assign("records",getNumb());
$smarty->display("connect.htm");
}
else js_redirect($res['fullurl']);
}
else{
//query did not find
$smarty->display("error.htm");
}
}
else{

if($fullurl){
preg_match("/^((http:\/\/)*)(.*)/i", $fullurl, $matches1);
preg_match("/^(http:\/\/)*/i", $fullurl, $matches2);

if($matches1[1]==$matches2[1] and $matches1[3]) $u = parse_url($fullurl);
else $u['host'] = $fullurl;

$ip = gethostbyname($u['host']);

if($ip == $u['host']){
js_alert ('No such host!');
}
else $randlink = addLink($fullurl,$ip);
}

//loading index.php
$smarty->assign("fullurl",$fullurl);
$smarty->assign("randlink",$randlink);

$smarty->assign("ad",getAd());
$smarty->assign("records",getNumb());
$smarty->display("index.htm");
}

?>
 
Back
Top Bottom