Ejemplo n.º 1
0
 function run()
 {
     // Create area where files will be placed if it is the first item;
     if (!is_dir($this->ftpdir)) {
         mkdir($this->ftpdir);
         // Create .htacess for each user ftpdir
         $fd = fopen("{$this->ftpdir}/.htaccess", "w") or die("Cannot open file {$this->ftpdir}\n");
         fwrite($fd, "Options Indexes FollowSymLinks");
         fclose($fd);
         if ($GLOBALS["stationDebug"]) {
             echo "p2u.run creating directory  {$this->ftpdir} <br>\n";
         }
     }
     // Check if this Tiff file is present in disk system
     if (count($this->tiffs) == 0) {
         $this->dbman->endModule($this->moduleId, 5, "tiffs were not found on disk");
         die;
     }
     #
     # Code Segment for Quality Control Test executions
     #
     include_once "globalsFunctions.php";
     include_once "request.class.php";
     $reqItem = new RequestItem($this->dbcat);
     $reqItem->searchItem($this->numitem);
     $reqItem_status = $reqItem->getItemStatus();
     #
     # end of segment
     #
     foreach ($this->tiffs as $tiff) {
         if (strlen($tiff) == 0) {
             $this->dbman->endModule($this->moduleId, 5, "{$tiff} was not found on disk");
             die;
         }
         // OK tiff is already in disk, lets make a copy for user
         //Don't zip BAND3 from CCD2 Intrument
         if (strstr($tiff, "CCD2") && strstr($tiff, "BAND3")) {
             continue;
         }
         #
         # Code Segment for Quality Control Test executions
         #
         if ($reqItem_status == 'Q') {
             /* 
             			  decodeTiff(basename($tiff),$satellite,$number,$instrument,$channel,$type,$date);
             				$qlt_dir = getQualityDir($satellite.$number); 
             				$qlt_dir_usreq = $qlt_dir . $this->userid . $this->reqid; 
             // Create area where files will be placed if it is the first item;
             			  if (!is_dir($qlt_dir_usreq)) mkdir ($qlt_dir_usreq);
             		    $cmd = "cp $tiff $qlt_dir_usreq";
             			  $res = exec($cmd);
             */
         } else {
             $this->saveTiffforUser($tiff);
         }
         #
         # end of segment
         #
     }
     include_once "listFiles.php";
     // Code Segment for dispatching "h1" LANDSAT-5 radiometric parameters file (amongst tiff files).
     $dir = dirname($this->tiffs[0]) . "/";
     $h1_files = listFiles($dir, "h1");
     foreach ($h1_files as $h1_file) {
         if ($h1_file != "") {
             $this->saveTiffforUser($dir . "/" . $h1_file);
         }
     }
     // End Code Segment for LANDSAT-5
     #
     # Code Segment for dispatching "scenario" files (under directory "scenario")
     #
     $cmd = "find {$dir} -name \"*scenario\" ";
     $output = shell_exec($cmd);
     $output = substr($output, 0, strlen($output) - 1);
     $scenario_fullname = explode("\n", $output);
     $this->saveTiffforUser($scenario_fullname[0]);
     #
     # End Code Sement
     #
     #
     # Code Segment for Quality Control Test executions
     #
     if ($reqItem_status == 'Q') {
         $this->dbman->endModule($this->moduleId);
         $reqItem->updateStatus('A');
         return;
     } else {
         $this->updateRequest();
     }
     #
     # end of segment
     #
     // Check how many items have been requested and how many are done
     //			$sql = "SELECT * FROM request WHERE reqid = $this->reqid";
     $sql = "SELECT COUNT(*) as nitem, sum(Status='F' or Status='E') as nitemdone from RequestItem where ReqId = {$this->reqid}";
     $this->dbcat->query($sql);
     if ($row = $this->dbcat->fetchRow()) {
         $nitem = $row["nitem"];
         $nitemdone = $row["nitemdone"];
     } else {
         $this->dbman->endModule($this->moduleId, 4, "{$this->reqid} was not found in DB");
     }
     $this->dbcat->freeResult();
     // If it is last item, send user a mail and terminate function run
     if ($GLOBALS["stationDebug"]) {
         echo "p2u.run nitemdone {$nitemdone} nitem {$nitem}<br>\n";
     }
     if ($nitemdone == $nitem) {
         $this->sendMail();
     } else {
         $this->sendIntermediateMail();
     }
 }