<?php
// create instrument directory (and several subdirecotires)


require("../phpVars.php");
// find all .xml files in instruments_dir


  $svydir='';
 $rootdir=$_SERVER['DOCUMENT_ROOT'];
 $dsvydir=$rootdir.'dSurvey/';
 $tmpdir=$dsvydir.'temp/';
 $wwwdir=$dsvydir;
 $instruments_dir=$dsvydir.'instruments/';
 $sessions_dir=$dsvydir.'sessions/';
 $data_dir=$dsvydir.'data/';
 $lookup_dir=$dsvydir.'pinfo/';
 $backup_dir=$dsvydir.'sessions/backup/';

 $pinfo_dir=$lookup_dir;
 $debug=0;

 $hdrMysql='dsurvey_';
 $mysqlHdr='dSurvey_';
 $currentDatabse='';

 $break = Explode('/',$_SERVER['SCRIPT_NAME']);
 $myScriptName = $break[count($break) - 1];

$aname=extractRequestVar('NAME','','No Instrument name in makeInstDirs');

$basedir=$instruments_dir.$aname;
$made1="Directory already exists: ".$basedir .', ' ;
$arf=is_dir($basedir);
if (!$arf) {
  if (!mkdir($basedir)) {
       print "Sorry.  Unable to create directory: $basedir ";
      return 0 ;
  }
  $made1='Ok. Directories created: '.$basedir.', ' ;
}

  $newdir=$basedir.'/lib';
  $arf=is_dir($newdir);
  if (!$arf) {
   $arf=mkdir($newdir);
   if ($arf==0) {
      print "Sorry.  Unable to create directory: $newdir ";
      return 0 ;
   }
   $made1=$made1.$newdir.', ';
  }


  $newdir=$basedir.'/modules';
  $arf=is_dir($newdir);
  if (!$arf) {
     $arf=mkdir($newdir) ;
    if ($arf==0) {
      print "Sorry.  Unable to create directory: $newdir ";
      return 0 ;
    }
    $made1=$made1.$newdir.', ';
  }

  $newdir=$basedir.'/specs';
  $arf=is_dir($newdir);
  if (!$arf) {
    $arf=mkdir($newdir)  ;
    if ($arf==0) {
        print "Sorry.  Unable to create directory: $newdir ";
        return 0 ;
    }
    $made1=$made1.$newdir.', ' ;
  }

  $arf=is_dir($newdir);
  if (!$arf) {
     $newdir=$basedir.'/old';
    $arf=mkdir($newdir);
      if ($arf==0) {
        print "Sorry.  Unable to create directory: $newdir ";
        return 0 ;
    }
    $made1=$made1.$newdir.', '  ;
  }

header("Content-Type: text/plain");
print $made1 ;



?>