Thread: Browser, URI, etc related

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Browser, URI, etc related

    Can I find out, when I go to http://mysite.com by typing that exatly in address bar, whether it is index.php, index.html, index.asp, or default.html or the like that is being displayed?

    note: the method must be client-side script solution, no server side

    Thanks.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Well to do that in an automated, client-side script, you're gonna have to write a plug-in, which is very platform-specific. You could either write a very simple client program yourself, or if this needs to be integrated into a particular browser, look into how to write plug-ins for that browser. Firefox is a good choice because it's open source, and IE, being very popular, also has a lot of resources.

  3. #3
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Hey, how did you know I'm making a firefox extension? Anyhow, how am I supposed to do it exactly? Not making a firefox extension, but finding out the URL of displayed webpage like I explain above.
    I mean I could know that when user enters http://mysite.com/index.php, then there is a file index.php, but if user only enters http://mysite.com, how would I know which index page is being displayed?
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I didn't know that you were making a plug-in - that's just how most client-side scripting is done. I've never done it before - so I'm afraid I can't tell you. My only suggestion if someone here can't answer your question is to refer to some FF documentation - that should tell you how to access internal events and data.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    What does it matter which particular file you are being served?

  6. #6
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Okay, here comes some details. One of the things that the firefox extension will do is the following.

    The user will be able to download the actual file that currently being displayed. So, when she goes to http://hisdomain.com/page.php, she'd be able to download the actual page.php file, not as rendered by web browser, but the actual file with its original code.
    The user will have ftp access to the domain, and the firefox extension will use FTP channel to download the file.
    So, now when user goes to http://hisdomain.com, the firefox extension needs to know which index page currently displaying in order to download the file.

    My plan B is just to check whether all possible files exist, check for existent of index.php, then index.html, then default.html and so on. But then different server may have different index filenames precedency.
    Plan C will prompt, when filename can't be determined, the user to enter the filename.

    But I'm still looking for my Plan A, if possible at all, though I highly doubt it.

    Thanks
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  7. #7
    Arggggh DeepFyre's Avatar
    Join Date
    Sep 2004
    Posts
    227
    Google search on how to make a firefox extension

    I used that link when I was tryin to make an extension but it is really hard and complicated


    btw thats just simple stuff, im sure if you still wanted to make an extension you could find the resources pretty easily
    Last edited by DeepFyre; 04-25-2005 at 07:34 PM.
    Keyboard Not Found! Press any key to continue. . .

  8. #8
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    The question is NOT how to make a firefox extension, read my post carefully.
    Thanks, though, but I think I'll go with plan B and/or C.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  9. #9
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    You cannot do what you're suggesting. You cannot get the origional file and its contents without access to the filesystem itself and the username/password to the server. Do you realize how stupid this might be if anyone could make a plug-in to do that? Talk about a security hole waiting to happen.

  10. #10
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    My firefox extension requires that the user provides the login info. The way it works is similar to the following case. In FileZilla ftp client, user could "View/Edit" a file in the server, and then FileZilla will download the file and open it in an editor. If you make changes and close the editor, FileZilla will prompt the user if user wants to upload the edited file replacing the old one.

    My firefox extension will do something similar. Say I have a resume at http://mysite.com/resume.html. I view it as a rendered webpage in Firefox and noticed that it has some type. I would just right click -> "start my extension", and then resume.html will be downloaded and displayed in an editor. I make changes, save, and the firefox extension will automatically upload resume.html and replace the old one.

    Concerning my issue I stated previously, I would just make the user enter the full URL in web browser, e.g. http://mysite.com/index.html, in order for it to download the correct file, I guess.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  11. #11
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Ahh... see, if you had explained it that way the first time...

    Either way, I'm not sure why it matters what kind of extension you're dealing with. All text-based web files can be edited from a text editor, so unless you're planning on firing off a specific development platform based on the extension, I wouldn't worry about it.

  12. #12
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Hmm, you don't seem to get my problem.

    When user enters http://mysite.com, how would my firefox extension know what file to download (index.php, index.html, default.html, etc)?
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  13. #13
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    I don't think you get what I'm driving at.

    I'd assume you'd almost have to make the user know the name of the file because even entering the url of a certain site won't give you the filename:

    Example: Most of my sites don't use "mysite.com/somefile.ext". I use keywords that get run through a PHP switch and then I serve a file based on that input. And there's no way you could guess which file I'm actually using.

    So you see, your problem is more than determining that one file. You might as well force them to enter the URL of the entire file. Besides, I still don't get how you plan to FTP to the right spot, because what if the file is up one or down one folder in the filesystem on the server? How are you supposed to know that and force the FTP client to automatically go to that folder on the server?

    I like your idea of what you're trying to do, but it's almost impractical.

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    There are two ways in which web servers can serve the default file. The first uses redirects. If you connect to the server using telnet and manually communicate, requesting / (the root), then you may get a 3** HTTP code back, with the Location header pointing you to the correct file. A browser will automatically re-request that file.
    In this case, you can get the file by watching the HTTP traffic. (There's an ext that does that, look at their code.)

    However, the far more common case is that the web server keeps the details of the transaction to itself and translates / to /index.php (or whatever) internally, pretending to your browser that it is really / that contains that stuff. In that case, what you're trying to do is impossible.

    It is, in general, not at all unusual nowadays that an URL doesn't match the actual file, so your extension is only of value to completely static pages that don't even use SSI. (Because those you'd only get in part.) Not to mention PHP includes.

    With trying several defaults, you probably won't get far. index.html, index.htm, index.shtml, index.php, index.php3, index.php4, index.jsp, Default.html, Default.htm, Default.asp, Default.aspx, default.html, default.htm, default.asp, default.aspx, just to list a few common possibilities. And that's not counting uncommon possibilities. (index.xml, index.xhtml, ...)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #15
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    duh, thanks for the insight, guys. I'm aware that my firefox extension won't be that practical for a dynamic website, but, yeah I just have to make one for class project and got no other idea.

    Thanks for chime in.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Internet Browser Handling
    By pobri19 in forum Windows Programming
    Replies: 9
    Last Post: 04-04-2009, 06:19 AM
  2. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 01:24 PM
  3. Getting Default Browser and Running It
    By Driver in forum Windows Programming
    Replies: 4
    Last Post: 10-22-2004, 02:08 PM
  4. Replies: 4
    Last Post: 05-28-2002, 06:19 PM