                                                                                                                                    

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
//--Description:
//--  This script attempts to install the webpad system on the current
//--  web-server. It does this by retrieving the files from across the
//--  Internet using whatever method is available. It has to create 
//--  directories, set up permissions, change GLOBAL variable paths and so
//--  on.
//--
//--  The installation process probably needs some user input, but this
//--  script attempts to basically guess at the correct answers for 
//--  everything.   
//--
//--

  $INSTALLROOT = "/home/waggacwc/public_html/test1";
  $sSourceInstallationUrl = "http://wagga-cwc.org.au/";

  $sLibraryFolder = "$INSTALLROOT/system/lib";
  $sConfigFolder = "$INSTALLROOT/system/config";
  $sWebpadFolder = "$INSTALLROOT/system/webpad";
  $sManageFolder = "$INSTALLROOT/system/manage";
  $sCodepadFolder = "$INSTALLROOT/system/manage/codepad";
  $sDocumentFolder = "$INSTALLROOT/system/docs";

  $sFileList = "";
  $iMode = 0777;

  if (file_exists($INSTALLROOT))
  {
    sMessagePage = "
      <html><body><pre>
     
        The installation folder $INSTALLROOT already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. There are two scenarios to think 
        about here; either there is already a folder of the same name
        on the server which contains valuable information which has 
        nothing to do with the webpad system, or else that folder is just
        a previous installation, or a partial installation of the 
        webpad system.

        Unfortunately there is no real way for the installation script
        to know which of these cases is the reality and for this reason
        the script has decided to take the 'safe' option and not do anything.
        Otherwise the script could end up deleting some very important
        information.

        
       
      </pre></body></html>";

    exit;
  }

  mkdir("$INSTALLROOT", $iMode);  

  if (file_exists("$INSTALLROOT/system"))
  {
    sMessagePage = "
      <html><body><pre>
     
        The folder $INSTALLROOT/system already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. 
       
      </pre></body></html>";

    exit;
  }

  mkdir("$INSTALLROOT/system", $iMode);  
      
  if (file_exists($sLibraryFolder))
  {
    sMessagePage = "
      <html><body><pre>
     
        The folder $sLibraryFolder already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. 
       
      </pre></body></html>";

    exit;
  }                                                      


  mkdir("$sLibraryFolder", $iMode);  


  if (file_exists("$sWebpadFolder"))
  {
    sMessagePage = "
      <html><body><pre>
     
        The folder $sWebpadFolder already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. 
       
      </pre></body></html>";

    exit;
  }                                                      


  mkdir("$sWebpadFolder", $iMode);  

  if (file_exists("$sManageFolder"))
  {
    sMessagePage = "
      <html><body><pre>
     
        The folder $sManageFolder already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. 
       
      </pre></body></html>";

    exit;
  }                                                      

  mkdir("$sManageFolder", $iMode);  

  if (file_exists("$sCodepadFolder"))
  {
    sMessagePage = "
      <html><body><pre>
     
        The folder $sCodepadFolder already exists.
        The installation script cannot proceed. This is what is
        known as a 'fatal' error. 
       
      </pre></body></html>";

    exit;
  }                                                      

  mkdir("$sCodepadFolder", $iMode);  


/--<--<--<--<--<--<--<--<--<--<--<--<--<--<                                            