Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Server-side Scripting

  1. #1
    Join Date
    Jan 2010
    Beans
    7

    Server-side Scripting

    Afternoon all,

    I have been banging my head against this for a few days now, and need some help ! I have an Ubuntu 12.04 server with media directories containing films and music etc. I have another server which is effectively a mirror of the other for all intents and purposes. What I am trying to do is:


    • Use Unison to copy between the servers, and keep the directories in sync using shell scripts
    • Create a webpage with links/buttons to the relevant scripts to execute them


    So far I have managed to get the shell scripts up and running, which work fine. I have managed to test both that PHP is working on my primary server, and that CGI scripts are able to run. What I cannot figure out is how to create the webpage with the links/buttons. I am getting lost between using PHP / CGi / HTML and getting the output right.

    Any help would be appreciated !

    Thanks

  2. #2
    Join Date
    Jan 2011
    Beans
    193

    Re: Server-side Scripting

    Well , its not easy to build a secure working html server with cgi-scripts.
    It is also not very difficult to start with it.
    But it is not very easy to explain it in short.

    Best to just read some docs and try one yourself, then ask for specific problems you encounter.

    And I am thinking now you want to create a apache server ? right.
    Maybe lighthttpd is an option, I never used it.
    You may also install additional plugins for appache to handle the php code.

    There is a lot of docs around. just google for html and cgi and apache.
    Apache has very good documentation.

    I just copy the first I found.

    http://www.jmarshall.com/easy/cgi/


    http://snowwhite.it.brighton.ac.uk/~...html/html.html


    But a quick hind.

    You have a running apache server, then the page you create is html, with some javascript maby. and direct links or via the javascript to your phpscripts on the apache server.

    Edit, to get the output from a script back in your page, you might need ajax. ( sensitive to browsertype )
    with ajax you can update a part of your page using "name=" and name is then filled with the returned code.
    Have a look here : http://www.w3schools.com/ajax/default.asp
    Last edited by kuifje09; March 17th, 2013 at 04:29 PM.

  3. #3
    Join Date
    Jan 2011
    Beans
    193

    Re: Server-side Scripting

    If it is just about a local page and script then this might help , just made a very little example and a bit incomplete :

    create in "your homedir" as example 2 files aap.html and noot.php

    aap.html:
    Code:
    <!DOCTYPE html>
    
    <script>
    
    function Justjava()
    {
          alert("Hello World!");
          return true;
    }
    
    function Justphp()
    {
            window.open ("file://home/"SOME-USER"/noot.php");
            return true;
    }
    
    </script>
    
    <body>
    <button onclick="Justjava()" type="button">Click Me! java</button>
    </br></br>
    <button onclick="Justphp()" type="button">Click Me! php</button>
    
    </body>
    </html>
    and noot.php :
    Code:
    <?php
    
    // Show all information, defaults to INFO_ALL
    phpinfo();
    
    ?>
    Load aap.html and see if you get the picture.
    Last edited by kuifje09; March 17th, 2013 at 05:47 PM. Reason: typo

  4. #4
    Join Date
    Jan 2010
    Beans
    7

    Re: Server-side Scripting

    Thanks for that, its a start.

    The JAVA button works fine, but the PHP button doesnt do anything.

  5. #5
    Join Date
    Jun 2011
    Beans
    357

    Re: Server-side Scripting

    Assuming PHP is enabled on your server you could using something like

    Code:
    <form action="myscript.php">
    <input type=submit value="Run Script">
    </form>
    Then put your actions into the myscript.php file. As someone else pointed out this isn't really secure as anyone with access to your web server will be able to run the script (or perhaps other scripts) on your server. A more secure and reliable method would be to run your backup/sync script using cron. This would allow you to perform backups at regular intervals without need for user intervention and it would remove a good deal of the security risk.

  6. #6
    Join Date
    Jan 2011
    Beans
    193

    Re: Server-side Scripting

    Shure you installed php ? phpinfo can be used as testpage.
    Tells a lot and creat a nice page for testing

    If you want to use ajax also, this is a nice tutorial : http://www.tizag.com/ajaxTutorial/index.php

  7. #7
    Join Date
    Jan 2011
    Beans
    193

    Re: Server-side Scripting

    Just in case of.. I can be you configured your browser to deny new paes or popups.
    The php button creates a new window for the result of the command.

  8. #8
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,044
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Server-side Scripting

    Is there a reason that you are not using a content management system (CMS) like drupal? http://drupal.org The heavy lifting has already been done. There is a learning curve, but once it is installed and running, it's works pretty well to serve up media.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  9. #9
    Join Date
    Jan 2010
    Beans
    7

    Re: Server-side Scripting

    Re. Drupal, lack of experience and not actually realising what it does.


    Have installed it now though, just trying to get a scripts module loaded onto it.

  10. #10
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,044
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Server-side Scripting

    Don't forget to load the views module. Very important for creating templates. Watch some videos, listen to some Drupal podcasts, read some Drupal forums, read some blogs on how people use Drupal. It may have a learning curve, but it beats programming a CMS from scratch. Unless it is a class assignment.

    http://twit.tv is a media-heavy website that uses drupal.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

Page 1 of 2 12 LastLast

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
  •