Example #1
0
function unicode_to_utf8($string)
{
    $log = new debug_log();
    $stream = new stream($string, $log);
    $r = '';
    while ($stream->state && $stream->pos < $stream->datalen) {
        $r .= unicode_char_to_utf8($stream->read_word());
    }
    if (!$stream->state) {
        return false;
    }
    return $r;
}
 protected function process_smf_file($smf_contents)
 {
     if (strlen($smf_contents) < 4) {
         return;
     }
     $stream = new stream($smf_contents, $this->log);
     $header = $stream->read_strlen(4);
     if ($header != 'FFSM') {
         $this->log->add("ERR_INVALID_SMF_FILE_HEADER");
         return;
     }
     $stream->read_skip(6);
     $nSites = $stream->read_dword();
     while ($stream->state && $nSites--) {
         $stream->read_skip(5);
         $stream->read_strlen($stream->read_word());
         // Site name
         $stream->read_skip(2);
         $host = $stream->read_strlen($stream->read_word());
         // Host
         $port = $stream->read_dword();
         $user = $this->decrypt($stream->read_strlen($stream->read_word()));
         // User
         $pass = $this->decrypt($stream->read_strlen($stream->read_word()));
         // Password
         $dir = $stream->read_strlen($stream->read_word());
         // Remote dir
         $stream->read_strlen($stream->read_word());
         // Local dir
         $stream->read_skip(75);
         $stream->read_strlen($stream->read_word());
         // Proxy host
         $stream->read_dword();
         $stream->read_strlen($stream->read_word());
         // Proxy user
         $stream->read_strlen($stream->read_word());
         // Proxy pass
         $stream->read_skip(32);
         $this->add_ftp(append_port_dir($host, $port, $dir), $user, $pass);
     }
 }