Skip to content

Instantly share code, notes, and snippets.

@bxt
Created February 27, 2011 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bxt/846142 to your computer and use it in GitHub Desktop.
Save bxt/846142 to your computer and use it in GitHub Desktop.
Exporting Kopete chatlog history XML-files to HTML (CLI-Version)
#!/usr/bin/php
<?php
//echo "kopeteHistXml2Html.php - Exporting Kopete history xml-files to html (CLI-Version)";
$doc=simplexml_load_file($argv[1]);
//var_dump($doc);
$new_msgs=array();
foreach ($doc->msg as $msg) {
$a=$msg->attributes();
$msg_p=array("nick"=>(string)$a->nick,"in?"=>((string)$a->in=="1"),"time"=>(string)$a->time,"text"=>(string)$msg);
$new_msgs[]=$msg_p;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Chatlog</title>
<style>
* {padding:0;margin:0;}
body {font-size:12px; width:600px; margin:0 auto;font-family:Tahoma, sans-serif;}
h1 {margin:20px 0 50px 0;text-align:center;}
.out {text-align:right;padding-right:300px;}
.in {text-align:left;padding-left:300px;}
dt {font-size:8px;color:#999;}
dd {padding-bottom:10px;}
</style>
</head>
<body>
<h1>Chatlog</h1>
<dl>
<?php foreach ($new_msgs as $ms) : ?>
<dt class="<?php echo ($ms["in?"]?"in":"out"); ?>"><?php echo htmlspecialchars($ms["nick"]); ?></dt>
<dd class="<?php echo ($ms["in?"]?"in":"out"); ?>"><?php echo htmlspecialchars($ms["text"]); ?></dd>
<?php endforeach; ?>
</dl>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment