                                                                                                                    

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
//--Description:
//--  The purpose of the current script is to return a list of files in
//--  particular areas of an installation of this system. The areas will be
//--  lib, codepad, manage, webpad, docs, config
//--
//--  This current script is important
//--  because I am envisioning an 'across-the-web' or internet-oriented
//--  system installation proceedure. This proceedure would involve a set-up
//--  or installation script querying another installation for all the 
//--  required files to set up a new installation of this system.
//--
//--  This would involve first obtaining a list of files in each of the 
//--  main areas of the system, such as; library functions, management scripts,
//--  the notepad files, and the webpad files, and also system documentation
//--  and configuration files.
//--
//--  Once these lists were obtained then this 'get-source.php' script would
//--  be able to be employed to serve each of the required files, one at
//--  a time. This proceedure obviates the need to have unzipping software
//--  available on the server, even if this software is quite common.
//--
//--See Also:
//--  
//--
//--
  include "/home/waggacwc/public_html/refurb/RETRO-GLOBALS.php";

  include "$LIBRARYPATH/fnFillWebTemplate.php";
  include "$LIBRARYPATH/fnMessageToHtml.php";
  include "$LIBRARYPATH/fnCodeBlockToHtml.php";
  include "$LIBRARYPATH/fnCodeBlockFromHtml.php";
  include "$LIBRARYPATH/fnListBlockToHtml.php";

  include "$LIBRARYPATH/fnHyperlinkPlainText.php";



  $sLibraryFolder = "$WEBROOT/refurb/product-data/lib";
  $sConfigFolder = "$WEBROOT/refurb";
  $sWebpadFolder = "$WEBROOT/refurb/webpad";
  $sCodepad = "$WEBROOT/refurb/manage/notepad";
  $sManageFolder = "$WEBROOT/refurb/manage";
  $sDocumentFolder = "$WEBROOT/refurb/docs";

  $sFileList = "";

  $sWebDocumentRoot = "$WEBROOT";
  $sFilePath = '';

  $sFileGroup = $_REQUEST['group'];
  $sFileGroupEncoded = htmlspecialchars($sFileGroup);

  $aaTextLines = file($ADMINTEMPLATE);
  $sAdminTemplateContents = implode('', $aaTextLines);
  
  if ($sFileGroup == '')
  {

    $sPageTitle = "Get File List: no group name specified";
    $sPageContent = "
          = No File Group Specified

        
    The purpose of this script is to help you to install the webpad 
    system. This system allows you to create webpages and documents in
    other formats using a web-browser interface. The current script 
    aids the installation proceedure by providing a list of all the 
    required files for any given area of the system. The installation
    script can then use this list to retrieve each of the files in turn
    and install them on the server where the setup script is running.

    An example installation of this system can be seen at
    http://wagga-cwc.org.au/refurb

    You did not specify any group name. The group names are
    currently; 
         u- 'lib' link:///refurb/manage/get-file-list.php?group=lib
          - 'codepad' link:///refurb/manage/get-file-list.php?group=codepad
          - 'webpad' link:///refurb/manage/get-file-list.php?group=webpad
          - 'config' link:///refurb/manage/get-file-list.php?group=config
          - 'docs' link:///refurb/manage/get-file-list.php?group=docs
          - 'manage' link:///refurb/manage/get-file-list.php?group=manage


      ";

    $sPageContent = fnMessageToHtml($sPageContent);
    $sErrorPage = fnFillWebTemplate(
      $sAdminTemplateContents, $sPageContent, $sPageTitle);   
    echo $sErrorPage;

    exit; 

  } //-- if no group specified
 
  if ($sFileGroup == 'lib')
  {

    $dh  = opendir($sLibraryFolder);
    while (false !== ($sMemberFileName = readdir($dh)))
    {
       $sCurrentFilePath = $sLibraryFolder.'/'.$sMemberFileName;
       $sCurrentFileWebPath = str_replace($WEBROOT, '', $sCurrentFilePath);

       if (!is_dir($sCurrentFilePath))
       {
          $sFileList = $sFileList.
            "<file>$sCurrentFileWebPath</file>\n";
       }

    } //--while
       
    //sort($aaFiles);
    //reset($aaFiles);

    $sFileList = "
      <file-list> 
         $sFileList 
      </file-list>";
    $sPageContent = "$sFileList";

    echo $sPageContent;

    exit; 

  } //-- if group 'lib'
  
  if ($sFileGroup == 'manage')
  {

    $dh  = opendir($sManageFolder);
    while (false !== ($sMemberFileName = readdir($dh)))
    {
       $sCurrentFilePath = $sLibraryFolder.'/'.$sMemberFileName;
       $sCurrentFileWebPath = str_replace($WEBROOT, '', $sCurrentFilePath);

       if (!is_dir($sCurrentFilePath))
       {
          $sFileList = $sFileList.
            "<file>$sCurrentFileWebPath</file>\n";
       }

    } //--while
       
    //sort($aaFiles);
    //reset($aaFiles);

    $sFileList = "
      <file-list> 
         $sFileList 
      </file-list>";
    $sPageContent = "$sFileList";

    echo $sPageContent;

    exit; 

  } //-- if group 'manage'
  
  if ($sFileGroup == 'webpad')
  {

    $dh  = opendir($sWebpadFolder);
    while (false !== ($sMemberFileName = readdir($dh)))
    {
       $sCurrentFilePath = $sLibraryFolder.'/'.$sMemberFileName;
       $sCurrentFileWebPath = str_replace($WEBROOT, '', $sCurrentFilePath);

       if (!is_dir($sCurrentFilePath))
       {
          $sFileList = $sFileList.
            "<file>$sCurrentFileWebPath</file>\n";
       }

    } //--while
       
    //sort($aaFiles);
    //reset($aaFiles);

    $sFileList = "
      <file-list> 
         $sFileList 
      </file-list>";
    $sPageContent = "$sFileList";

    echo $sPageContent;

    exit; 

  } //-- if group 'webpad'

  if ($sFileGroup == 'codepad')
  {

    $dh  = opendir($sCodepadFolder);
    while (false !== ($sMemberFileName = readdir($dh)))
    {
       $sCurrentFilePath = $sLibraryFolder.'/'.$sMemberFileName;
       $sCurrentFileWebPath = str_replace($WEBROOT, '', $sCurrentFilePath);

       if (!is_dir($sCurrentFilePath))
       {
          $sFileList = $sFileList.
            "<file>$sCurrentFileWebPath</file>\n";
       }

    } //--while
       
    //sort($aaFiles);
    //reset($aaFiles);

    $sFileList = "
      <file-list> 
         $sFileList 
      </file-list>";
    $sPageContent = "$sFileList";

    echo $sPageContent;

    exit; 

  } //-- if group 'codepad'

  if ($sFileGroup == 'docs')
  {

    $dh  = opendir($sDocumentFolder);
    while (false !== ($sMemberFileName = readdir($dh)))
    {
       $sCurrentFilePath = $sLibraryFolder.'/'.$sMemberFileName;
       $sCurrentFileWebPath = str_replace($WEBROOT, '', $sCurrentFilePath);

       if (!is_dir($sCurrentFilePath))
       {
          $sFileList = $sFileList.
            "<file>$sCurrentFileWebPath</file>\n";
       }

    } //--while
       
    //sort($aaFiles);
    //reset($aaFiles);

    $sFileList = "
      <file-list> 
         $sFileList 
      </file-list>";
    $sPageContent = "$sFileList";

    echo $sPageContent;

    exit; 

  } //-- if group 'docs'

//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>


<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
 echo " get file list";
//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>



                                                                                                                    