Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Decoder for ICQ-History that can be found in the backup of your IPhone / IPod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style TYPE="text/css">
<!--
.isfromme {
background: rgb(229, 194, 78);
}
.isfrompartner {
background: rgb(237, 227, 116);
}
.inforow {
background: #AAA;
}
.date {
width: 200px;
}
-->
</style>
</head>
<body>
<?php
# Loop through the current directory
$messages=array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if (substr($file,-3) == 'icq') {
$messages=array_merge($messages,LoadICQFile($file));
}
}
closedir($handle);
}
# Sort the merges Array by Time-Stamps
usort($messages,'SortMessagesByTime');
#print_r($inventory);
?>
<table>
<?php
foreach ($messages as $message) {
if ($message['type']=='im') {
# {
# ["isFromMe"]=>
# int(1)
# ["type"]=>
# string(2) "im"
# ["autoresponse"]=>
# bool(false)
# ["kIMDv"]=>
# int(3)
# ["kMXHTML"]=>
# string(65) "so! bin wieder da und Sitz jetzt auch im Wohnzimmer auf der Couch"
# ["timestamp"]=>
# float(1321295328.4401)
# ["source"]=>
# array(2) {
# ["displayId"]=>
# string(0) ""
# ["aimId"]=>
# string(0) ""
# }
# ["destination"]=>
# array(4) {
# ["userType"]=>
# string(3) "icq"
# ["friendly"]=>
# string(13) "USERNAME"
# ["aimId"]=>
# string(9) "AIMID"
# ["displayId"]=>
# string(9) "DISPLAYID"
# }
#}
if ($message['isFromMe']) {
print "<tr class='messagerow isfromme'>\n";
} else {
print "<tr class='messagerow isfrompartner'>\n";
}
print " <td class='date'>".strftime('%d.%m.%Y %H:%M:%S',$message['timestamp'])."</td>\n";
print " <td class='source'>".$message['source']['aimId']."</td>\n";
print " <td class='destination'>".$message['destination']['aimId']."</td>\n";
print " <td class='message'>".$message['kMXHTML']."</td>\n";
print "</tr>\n";
} elseif ($message['type']=='infotext') {
print "<tr class='inforow'>\n";
print " <td class='date'>".strftime('%d.%m.%Y %H:%M:%S',$message['timestamp'])."</td>\n";
print " <td class='infotype'>".$message['infoType']."</td>\n";
# print " <td class='destination'>".$message['destination']['aimId']."</td>\n";
print " <td colspan='2' class='message'>".$message['message']."</td>\n";
print "</tr>\n";
} else {
#{ ["type"]=>
# string(8) "infotext"
# ["infoType"]=>
# string(9) "imstarter"
# ["message"]=>
# string(29) "IM gestartet 14.11.2011 19:28"
# ["timestamp"]=>
# float(1321295286.721)
# ["destination"]=>
# array(1) {
# ["aimId"]=>
# string(0) ""
# }
#}
print "<tr><td colspan='4'><pre>";
var_dump($message);
print "</pre></td>";
print "</tr>\n";
}
}
?>
</table>
<?php
function SortMessagesByTime($item1,$item2) {
if ((float)$item1['timestamp'] == (float)$item2['timestamp']) return 0;
return ((float)$item1['timestamp'] > (float)$item2['timestamp']) ? 1 : -1;
}
function LoadICQFile($filename) {
# Read the files and decode the JSON-content
$json=file_get_contents($filename);
#echo "Opening $filename\n";
if ($messages=json_decode($json, true)) {
foreach ($messages as &$message) {
if (($message['type'] == 'im') and ($message['isFromMe']==0)) {
$partner=$message['source'];
break;
}
}
foreach ($messages as &$message) {
if (($message['type'] == 'im') and ($message['isFromMe']==1)) {
$message['destination']=$partner;
} else {
$message['destination']['aimId']='';
}
}
return $messages;
}
return Array();
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.