Results 1 to 6 of 6

Thread: looking for website script

  1. #1
    Join Date
    Nov 2004
    Location
    Quebec
    Beans
    741
    Distro
    Kubuntu 12.04 Precise Pangolin

    looking for website script

    I've been searching but can't find anything that will do what i need so I figured I ask here.

    My brother has a business that is open or closed depending on the weather, so on his website I stuck one of those weather.com banners that shows the weather and states if below -15 we're probably closed.

    However, it's not perfect as if it's sunny and no wind but -15 we might be open lol.

    So what i am looking for is a simple open/closed button that when clicked will present a password dialog box and allow my brother to change the status from the website... does such a thing exsist and where can i find it?
    ~
    Desktop:ASRock P4i65GV/P4 2.8ghz 2gbram
    Laptop:Toshiba L350-PSLD8C Centrino64 dualcore 2ghz 4gbram

  2. #2
    Join Date
    Nov 2004
    Location
    Canuck Land
    Beans
    215
    Distro
    Ubuntu

    Re: looking for website script

    I doubt something that specific exists, you may need the services of a web developer.
    What technologies are you using for the site?

  3. #3
    Join Date
    Nov 2004
    Location
    Quebec
    Beans
    741
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: looking for website script

    Ah thanks, I didn't think it would be that complicated. Nothing special for the site but I assumed something cgi would exsist. I was going to use ICQ messenger since they have an online notifier but figured i would at least check to see if what i wanted exsisted.
    I'll keep looking aroung for something that could work.. thanks.
    ~
    Desktop:ASRock P4i65GV/P4 2.8ghz 2gbram
    Laptop:Toshiba L350-PSLD8C Centrino64 dualcore 2ghz 4gbram

  4. #4
    Join Date
    Apr 2007
    Location
    Ohio
    Beans
    354

    Re: looking for website script

    I'm assuming the server has PHP, right? There are number of easy ways to do this. I'll edit one into this post (let me write it out first).

    First up is the open indicator. You can edit the HTML to suit your needs:
    PHP Code:
    <?php
       $open_indicator 
    file_get_contents("are_we_open"); // Replace this if you want, it's a file name.
       
    if (strlen($open_indicator) < 1) {
           echo 
    "Error collecting business operation status."// The indicator has not been set.
       
    } else {
           if (
    $open_indicator == "y") {
               echo 
    "We are OPEN"// Or whatever you want, maybe an image?
           
    } elseif ($open_indicator == "n") {
               echo 
    "We are CLOSED";
           } else {
               echo 
    "Business operation status could not be determined."// (the file contains something, but not what we expected.
           
    }
       }
    ?>
    If the server is set up to parse regular HTML documents with PHP, you can just stick this somewhere, otherwise you may need to use an <IFRAME> to get the job done.

    Next we have to have a way to change this. The best bet is to just make a new directory, say "admin" or something to that effect, and put an .htaccess and .htpasswd in it:
    .htaccess:
    Code:
    AuthUserFile  /path/to/.htpasswd
    AuthName  "Some page title you want to use"
    AuthType Basic
    require user username
    .htpasswd:
    Code:
    username:encrypted password
    (Use something like this to automatically generate a .htpasswd, as you need to have a properly encrypted password)

    Also in this directory should be an index.php which allows us to change the status:
    PHP Code:
    <?php
        
    // Status changer
        
    if (isset($_POST['status'])) {
            echo 
    "Setting status to {$_POST['status']}...";
            
    file_put_contents("../are_we_open",$_POST['status']);
        } else {
            
    $status file_get_contents("../are_we_open");
            echo 
    "<form action=\"index.php\" method=\"post\">\n";
            echo 
    "<input type=\"text\" id=\"status\" value=\"$status\" /> (y or n)\n";
            echo 
    "<input type=\"submit\" value=\"Set Status\" /></form>";
        }
    ?>
    Last edited by klange; December 29th, 2008 at 05:33 PM.

  5. #5
    Join Date
    Nov 2004
    Location
    Quebec
    Beans
    741
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: looking for website script

    AWESOME! thank you!!
    I'll give it a try this weekend, sounds pretty straight forward but i'll get back to you with results
    ~
    Desktop:ASRock P4i65GV/P4 2.8ghz 2gbram
    Laptop:Toshiba L350-PSLD8C Centrino64 dualcore 2ghz 4gbram

  6. #6
    Join Date
    Nov 2004
    Location
    Quebec
    Beans
    741
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: looking for website script

    it's going to take me a bit longer than i thought to get to testing it... over the weekend we had 100km winds and it blew my old tin roof off! lol.
    I'll post back as soon as i get around to it. Thanks!
    ~
    Desktop:ASRock P4i65GV/P4 2.8ghz 2gbram
    Laptop:Toshiba L350-PSLD8C Centrino64 dualcore 2ghz 4gbram

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •