isAdmin()) { $gBitSmarty->assign('msg', tra("You dont have permission to use this feature")); $gBitSystem->display( 'error.tpl' ); die; } require (WEBMAIL_PKG_PATH."mimeDecode.php"); function parse_output(&$obj, &$parts, $i) { if (!empty($obj->parts)) { for ($i = 0; $i < count($obj->parts); $i++) parse_output($obj->parts[$i], $parts, $i); } else { $ctype = $obj->ctype_primary . '/' . $obj->ctype_secondary; switch ($ctype) { case 'application/x-phpwiki': $aux["body"] = $obj->body; $ccc = $obj->headers["content-type"]; $items = split(';', $ccc); foreach ($items as $item) { $portions = split('=', $item); if (isset($portions[0]) && isset($portions[1])) { $aux[trim($portions[0])] = trim($portions[1]); } } $parts[] = $aux; break; case 'application/x-bitweaver': $aux["body"] = $obj->body; $ccc = $obj->headers["content-type"]; $items = split(';', $ccc); foreach ($items as $item) { $portions = split('=', $item); if (isset($portions[0]) && isset($portions[1])) { $aux[trim($portions[0])] = trim($portions[1]); } } $parts[] = $aux; break; } } } function compare_import_versions($a1, $a2) { return $a1["version"] - $a2["version"]; } $gBitSmarty->assign('result', 'y'); if (isset($_REQUEST["import"])) { $path = $_REQUEST["path"]; $h = opendir("$path/"); $lines = array(); while (false !== $file = readdir($h)) { if (is_file("$path/$file")) { $fp = fopen("$path/$file", "r"); $full = fread($fp, filesize("$path/$file")); //$full=htmlspecialchars($full); fclose ($fp); $params = array( 'input' => $full, 'crlf' => "\r\n", 'include_bodies' => TRUE, 'decode_headers' => TRUE, 'decode_bodies' => TRUE ); $output = Mail_mimeDecode::decode($params); parse_output($output, $parts, 0); usort($parts, 'compare_import_versions'); $last_part = ''; $last_part_ver = 0; foreach ($parts as $part) { if ($part["version"] > $last_part_ver) { $last_part_ver = $part["version"]; $last_part = $part["body"]; } if (isset($part["pagename"])) { // PHPWiki footnotes get handled by refusing to // convert [[...] at all; the latest gBitSystem.php // will render [[foo] as [foo], no link. So the // (?remove_all_versions($pagename, ''); } if ($wikilib->pageExists($pagename)) { if ($_REQUEST["crunch"] == 'n') { $msg = '' . tra('page not added (Exists)'). ''; } else { $msg = '' . tra('overwriting old page'). ''; $wikilib->update_page($pagename, $part["body"], tra('updated by the phpwiki import process'), $author, $authorid, $description); } } else { $msg = tra('page created'); $wikilib->create_page($pagename, $hits, $part["body"], $lastmodified, tra('created from phpwiki import'), $author, $authorid, $description); } $aux["page"] = $pagename; $aux["version"] = $version; $aux["part"] = $ex; $aux["msg"] = $msg; $lines[] = $aux; } } unset ($parts); } } closedir ($h); $gBitSmarty->assign('lines', $lines); $gBitSmarty->assign('result', 'y'); } $gBitSystem->display( 'bitpackage:wiki/import_phpwiki.tpl'); ?>