Using the file system as a database.



  • I'm sure some of us may have joked around about using the file system as a database, well probably not. It turns out that somebody thought this would be a good idea.


    Each link takes you to another pre-created page. Each city gets it's own page page. From there you type in the address, as we can see from this bit of code

    [code]
    citypage=city+"_"+ss+".htm";
    redirect(citypage);
    [/code]



    there is at least one page for each letter in the alphabet. The 'ss' variable is the first letter of the address typed in. Once it figures out what the first letter of the street name is, it redirects to the next page. There must be hundreds of pages making this up. Each time a change is made somebody would have to go in and manually change every page that is effected. I doubt they have created any automated way of doing this.

    Just for a bit of variety the menus are all broken, regx is not used to parse the address, and there is validation on the street number but not on the street name. If you put in a character that does not exist for the street name (any character that has no page for it) you are directed to a 404 page.

    I also like this.

    [code]
    if(thisCookie[i].split("=")[0]=="street"){
    ss=thisCookie[i].split("=")[1];
    ss=ss.charAt(0);
    [/code]



    They know they can get a character out of a string, but don't know you can just pluck a character out from any old string.

    Interestingly enough, this page on the same site actually uses a database, and if you put in information that does not exist you don't get a 404.




    I would hate to see what the master that created the voting page would have done for this.


    Edit: Am I missing something, why do I have to put html in my post for line breaks? 😞



  • @Yaos said:

    Edit: Am I missing something, why do I have to put html in my post for line breaks? 😞
    It took you 26 posts to realize this?


    As for the OP WTF, they could be using somthing like mod_rewrite.



  • @Yaos said:

    Edit: Am I missing something, why do I have to put html in my post for line breaks? 😞

    Are you using a web browser made in the last 5 years? Welcome to the WTF that is Community Server.



  • @Lingerance said:

    As for the OP WTF, they could be using somthing like mod_rewrite.

    I highly doubt this.


    'Small' snippet from the source code of one of the pages:

    var i;
    streets= new Array(4); for (i = 0; i < streets.length; ++ i)
    streets[i]= new Array(13);streets[0][0]="NASHVILLE";
    streets[0][1]="AMBERWOOD PL";
    streets[0][2]="700";
    streets[0][3]="799";
    streets[0][4]="B";
    streets[0][5]=" 8";
    streets[0][6]=" 83";
    streets[0][7]=" ";
    streets[0][8]=" 61";
    streets[0][9]=" 23";
    streets[0][10]=" 8";
    streets[0][11]=" 7";
    streets[0][12]="37221";
    streets[1][0]="NASHVILLE";
    streets[1][1]="ASBERRY CT";
    streets[1][2]="5900";
    streets[1][3]="6099";
    streets[1][4]="B";
    streets[1][5]=" 8";
    streets[1][6]=" 83";
    streets[1][7]=" ";
    streets[1][8]=" 61";
    streets[1][9]=" 23";
    streets[1][10]=" 8";
    streets[1][11]=" 7";
    streets[1][12]="37221";
    streets[2][0]="NASHVILLE";
    streets[2][1]="ASBERRY DR";
    streets[2][2]="7000";
    streets[2][3]="7099";
    streets[2][4]="B";
    streets[2][5]=" 8";
    streets[2][6]=" 83";
    streets[2][7]=" ";
    streets[2][8]=" 61";
    streets[2][9]=" 23";
    streets[2][10]=" 8";
    streets[2][11]=" 7";
    streets[2][12]="37221";
    streets[3][0]="NASHVILLE";
    streets[3][1]="AYLEWORTH LN";
    streets[3][2]="4000";
    streets[3][3]="4099";
    streets[3][4]="B";
    streets[3][5]=" 8";
    streets[3][6]=" 83";
    streets[3][7]=" ";
    streets[3][8]=" 61";
    streets[3][9]=" 23";
    streets[3][10]=" 8";
    streets[3][11]=" 7";
    streets[3][12]="37221";


  • This isn't using the file system as a database, it's simply a static web site... yeah a rare sight in year 2010 but not necesary a WTF.

    Really using filesystems as a database isn't a WTF either, a lot of classic unix-originated server software does that, pretty much every single MTA, news servers, various store-and-forward-networks nodes etc. Hell even /proc and /sys are somewhat of a database with filesystem interface. It's not that insane when you consider filesystems other than NTFS and FAT where file look and creation up can be very fast.



  • @Shondoit said:

    @Lingerance said:
    As for the OP WTF, they could be using somthing like mod_rewrite.

    I highly doubt this.


    'Small' snippet from the source code of one of the pages:

    var i;
    streets= new Array(4); for (i = 0; i < streets.length; ++ i)
    streets[i]= new Array(13);streets[0][0]="NASHVILLE";
    streets[0][1]="AMBERWOOD PL";
    streets[0][2]="700";
    streets[0][3]="799";
    streets[0][4]="B";
    streets[0][5]=" 8";
    streets[0][6]=" 83";
    streets[0][7]=" ";
    streets[0][8]=" 61";
    streets[0][9]=" 23";
    streets[0][10]=" 8";
    streets[0][11]=" 7";
    streets[0][12]="37221";
    streets[1][0]="NASHVILLE";
    streets[1][1]="ASBERRY CT";
    streets[1][2]="5900";
    streets[1][3]="6099";
    streets[1][4]="B";
    streets[1][5]=" 8";
    streets[1][6]=" 83";
    streets[1][7]=" ";
    streets[1][8]=" 61";
    streets[1][9]=" 23";
    streets[1][10]=" 8";
    streets[1][11]=" 7";
    streets[1][12]="37221";
    streets[2][0]="NASHVILLE";
    streets[2][1]="ASBERRY DR";
    streets[2][2]="7000";
    streets[2][3]="7099";
    streets[2][4]="B";
    streets[2][5]=" 8";
    streets[2][6]=" 83";
    streets[2][7]=" ";
    streets[2][8]=" 61";
    streets[2][9]=" 23";
    streets[2][10]=" 8";
    streets[2][11]=" 7";
    streets[2][12]="37221";
    streets[3][0]="NASHVILLE";
    streets[3][1]="AYLEWORTH LN";
    streets[3][2]="4000";
    streets[3][3]="4099";
    streets[3][4]="B";
    streets[3][5]=" 8";
    streets[3][6]=" 83";
    streets[3][7]=" ";
    streets[3][8]=" 61";
    streets[3][9]=" 23";
    streets[3][10]=" 8";
    streets[3][11]=" 7";
    streets[3][12]="37221";
    Okay, that is stupid. And badly formatted, though I can't tell whose fault that is.


  • @bdew said:

    Really using filesystems as a database isn't a WTF either, a lot of classic unix-originated server software does that, pretty much every single MTA, news servers, various store-and-forward-networks nodes etc. Hell even /proc and /sys are somewhat of a database with filesystem interface. It's not that insane when you consider filesystems other than NTFS and FAT where file look and creation up can be very fast.
     

    Yeah, but they are a real bitch if you want to do anything besides very simple stuff. If you're using this for simple primary key access and sorting, then I can see a filesystem database being useful, but if you want to do anything fancy like having an advanced search form or complicated sorting, then you're shooting yourself in the foot not realizing how better suited that is in a DB. Furthermore, maybe you don't have that requirement now, but if the situation ever arises where you want to move to a DB, it's a bit more difficult to migrate depending on the format.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.