Skip to content

Instantly share code, notes, and snippets.

@symm symm/gist:5987565
Created Jul 12, 2013

Embed
What would you like to do?
Quick and dirty script for reading Skype conversions from db file
<?php
class SkypeLogs {
private $db;
public function __construct()
{
// Create (connect to) SQLite database in file
$this->db = new PDO('sqlite:main.db');
// Set errormode to exceptions
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
function getConversationIds() {
$ids = array();
$sql = "SELECT distinct(convo_id) FROM Messages";
foreach($this->db->query($sql) as $row) {
$ids[] = $row['convo_id'];
}
return $ids;
}
public function getMessages($conversationId) {
$messages = array();
$sql = "SELECT * FROM Messages where convo_id = " . $conversationId;
return $this->db->query($sql);
}
}
ob_start();
$sl = new SkypeLogs();
$ids = $sl->getConversationIds();
foreach($ids as $id) {
echo '<a href="?id=' . $id . '"> ' . $id . '</a> ';
}
if(isset($_GET['id'])) {
$messages = $sl->getMessages($_GET['id']);
foreach($messages as $message) {
$dt = new DateTime("@" . $message['timestamp']);
$timeFormat = $dt->format('Y-m-d H:i:s');
echo '<p><strong>' . $timeFormat . ' ' . $message['author'] . ':</strong> ' .$message['body_xml']. '</p>';
}
}
ob_end_flush();
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.