Example 1 :

This script decodes the encoded files "C:\01 - before decoding\ST.001", "C:\01 - before decoding\ST.002" and "C:\01 - before decoding\ST.003" which belong to the same decoded file "ST.gif". This file will be saved in the directory "C:\02 - after decoding". This script also defines a Message Callback function which prints the library messages with a level greater or equal than UUMSG_NOTE into the web page.

<?php

// We define the array that contains the name of the files to decode.
$array = array ('C:\01 - before decoding\ST.001', 'C:\01 - before decoding\ST.002', 'C:\01 - before decoding\ST.003');

// We define the message callback function
function msgcallback_function($msg, $level)
{
   if ($level >= UUMSG_NOTE)
      echo "$msg";
}

// We initialize the library
php_uuinitialize();

// We indicate the function of treatment for the messages generated by the library
php_uusetmsgcallback ("msgcallback_function");

// We go throw the array defined above
for ($i = 0; $i < count($array); $i++)
{
   // We scan the files to found encoded data and we insere the result in a uulist
   php_uuloadfile ($array[$i]);
}

// We specify the savepath
php_uusetoption (UUOPT_SAVEPATH, 'C:\02 - after decodage\\');

// We go throw the list
for ($i = 0; ($item = php_uugetfilelistitem ($i)) != NULL; $i++)
{
   $object = php_uulistitemtoobject ($item);
   // We verify if it is a valid file
   if (($object->state & UUFILE_OK) != UUFILE_OK)
   {
      // If the file is not valid, we indicate the errors
      // and we don't decode it : we go to the begining of
      // the loop and check for the next file if it exists
      echo "Error in file ".$object->filename." : ";
      if (($object->state & UUFILE_MISPART) == UUFILE_MISPART)
      {
         echo "Missing Parts: ".$object->misparts[0];
         for ($j = 1; $object->misparts[$j] != 0; $j++)
            echo ", ".$object->misparts[$j];
         echo "; ";
      }
      if (($object->state & UUFILE_NOBEGIN) == UUFILE_NOBEGIN)
         echo "No Begin found; ";
      if (($object->state & UUFILE_NOEND) == UUFILE_NOEND)
         echo "No End found; ";
      if (($object->state & UUFILE_NODATA) == UUFILE_NODATA)
         echo "No encoded data found; ";
      if (($object->state & UUFILE_ERROR) == UUFILE_ERROR)
         echo "Decode operation failed; ";
      echo "<br>";
      continue;
   }
   //If there is no problem, we try to decode the file.
   php_uudecodefile ($item);
}
// We clean up all the resources php_uucleanup ();

?>

Piscines en bois