Dreamwidth

May. 30th, 2010 06:34 pm
Updating my dreamwidth after long one month. Now all exams and other duties over. I came back to college. I never knew that its really so nice to work in college during vacation. I learned some new language "Perl" which is required for dreamwidth. I didn't find it much difficult to learn it. May be because I had some basic knowledge in Python and other programming languages. Now busy with dreamwidth. Trying to do some bug fixing. Found some bug like redirecting "shop.dreamwidth.org to dreamwidth.org/shop" as interesting. Just looked around and heard from IRC that all redirections are referred in redirect.dat. Then I started searching for redirect.dat. I found that it is present in /dw/cgi-bin. Then I looked around and found something named Livejournal.pm in /dw/cgi-bin/Apache. I found some code like this as something related to my bug..That stub is :
my %REDIR
# redirect data.
foreach my $file ('redirect.dat', 'redirect-local.dat') {
open (REDIR, "$LJ::HOME/cgi-bin/$file") or next;
while () {
next unless (/^(\S+)\s+(\S+)/);
my ($src, $dest) = ($1, $2);
$REDIR{$src} = $dest;
}
close REDIR;
}

My understanding :-
Here REDIR is a hash. There are two two possibilities for using foeeach function.
One for looping through all elements in an array and the other for manipulating the values of each keys in case of a hash..
So if it has been for the first purpose, 'redirect.dat' and 'redirect-local.dat' should be some array..
But which is of very less chance since it should have an '@' symbol at its head if it had been one..
So the foreach function should have been used for the second purpose.. that is for hash...
If it had been for hash, 'redirect.dat' and 'redirect-local.dat' should be the keys of some hash which has a higher chance than being an array..
So
Now after further thinking I could understand that the redirections described in redirect.dat is from dreamwidth.org/somefile to dreamwidth.org/somefolder/somefile or something similar....

When I go through little depth of Livejournal.pm, I could understand that when shop.dreamwidth.org is taken in a browser, it is showing something like an unknown user. I found the code which is displayig this. "Unknown User. There is no such user shop at dreamwidth studios."
The code is :-
elsif ($opts->{'baduser'})
{
$status = "404 Unknown User";
$html = "

Unknown User

There is no user $user at $LJ::SITENAME.

";
$generate_iejunk = 1;
}

So if some checking of $user is done and if it is found to be shop. I guess it
can be redirected to dreamwidth.org/shop by calling the sub_routine redir
defined in line 174.

I think this can also be done in a more general way so that other redirections
like mobile.dreamwidth.org can also be performed. As in redirect.dat, If we
declare the reserved usernames and the correspong links to which it should be
redirected in some other file and if we could redirect to corresponding links
according to the username, I think this bug could be fixed. I am not sure
whether what I felt is correct. I could very well be wrong.

Profile

Sreenath T.V

January 2011

S M T W T F S
      1
234567 8
9101112131415
16171819202122
23242526272829
3031     

Syndicate

RSS Atom

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 23rd, 2025 05:18 pm
Powered by Dreamwidth Studios