Created
February 27, 2011 12:29
-
-
Save bxt/846142 to your computer and use it in GitHub Desktop.
Exporting Kopete chatlog history XML-files to HTML (CLI-Version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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