Welcome Guest, Not a member yet? Register   Sign In
URL shortening service
#5

[eluser]Dregond Rahl[/eluser]
[quote author="xwero" date="1243951302"]Url shortening websites probably will use a database but if the site is small you could get away storing the shortened urls in a file with a php array and include that so all you have to do to is an isset check to find out if the image is available or not.

I think to keep the files as small as possible i would create one for each shortened begin letter so the lookup method could be
Code:
function pic($url)
{
   $first_letter = substr($url,0,1);

   if( ! file_exists('urls/'.$first_letter.EXT))
   {
      show_404();
   }

   include('urls/'.$first_letter.EXT);

   if( ! isset($urls[$url]))
   {
      show_404();
   }
  
   // output the actual file the way you want
}
[/quote]

Thanks for giving me some options. I think i will use a database system, would be better in the long run for storing other details in case, and modifying. If im using the DB method, i would need to keep looking up from the database and then redirecting right? using CI can i cache only those requests to that specific table ?


Messages In This Thread
URL shortening service - by El Forum - 06-02-2009, 02:36 AM
URL shortening service - by El Forum - 06-02-2009, 03:01 AM
URL shortening service - by El Forum - 06-02-2009, 03:02 AM
URL shortening service - by El Forum - 06-02-2009, 03:10 AM
URL shortening service - by El Forum - 06-02-2009, 04:13 AM
URL shortening service - by El Forum - 06-02-2009, 06:20 AM
URL shortening service - by El Forum - 06-02-2009, 06:44 AM
URL shortening service - by El Forum - 06-02-2009, 06:48 AM
URL shortening service - by El Forum - 06-02-2009, 06:56 AM
URL shortening service - by El Forum - 06-02-2009, 07:00 AM
URL shortening service - by El Forum - 06-02-2009, 07:19 AM
URL shortening service - by El Forum - 06-02-2009, 07:31 AM
URL shortening service - by El Forum - 06-02-2009, 07:44 AM
URL shortening service - by El Forum - 06-02-2009, 07:47 AM
URL shortening service - by El Forum - 06-02-2009, 07:53 AM
URL shortening service - by El Forum - 06-02-2009, 08:03 AM
URL shortening service - by El Forum - 06-02-2009, 08:11 AM
URL shortening service - by El Forum - 06-02-2009, 08:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB