public
Last active — forked from bxt/kopeteHistXml2Html.php

  • Download Gist
kopeteHistXml2Html.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.