Example 5 :

This script encodes the file "C:\Apache\test.rar" to the file "c:\01 - before decoding\test.yenc". These two files are opened internally by the script. This one also defines a Message Callback function which prints the library messages with a level greater or equal than UUMSG_NOTE into the web page. Finally, a Busy Callback function is defined and called every 100 ms.


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

// We define the busy callback function
function busycallback_function($uuprogress)
   echo "<br><br>Action : ".$uuprogress->action;
   echo "<br>Curfile : ".$uuprogress->curfile;
   echo "<br>Partno : ".$uuprogress->partno;
   echo "<br>Numparts : ".$uuprogress->numparts;
   echo "<br>Percent : ".$uuprogress->percent;
   echo "<br>Fsize : ".$uuprogress->fsize."<br><br>";

// We initialize the library

// We indicate the function of treatment for the messages generated by the library
php_uusetmsgcallback ("msgcallback_function");
// We indicate that the busy callback function must be called every 100 ms.
php_uusetbusycallback("busycallback_function", 100);

// We open the source and destination files.
$source_file = fopen('c:\Apache\test.rar', "r");
$destination_file = fopen('c:\01 - before decoding\test.yenc', "w");

// We try to encode the data
php_uuencodetostream($destination_file, $source_file, YENC_ENCODED, 'test.rar');

// We close the files.
fclose ($source_file);
fclose ($destination_file);

// We clean up all the resources.


Piscines en bois