* @created 28.05.2011 */ // input file $file = "MDataStore.db3"; // open sqlite3 database file $db = new PDO('sqlite:'.$file); // get sms $stmt = $db->query("SELECT * FROM MessageEx"); // fetch sms data $data = $stmt->fetchAll(PDO::FETCH_ASSOC); // generate xml output $output = ""."\n"; $output .= ''."\n"; foreach ($data as $msg){ // get text $txt = htmlspecialchars($msg['Text']); // get adr $adr = $msg['Sender']; // calculate unix timestamp from sqlite timestamp- well offset of -4 hours ! $dte = getUnixTS($msg['SentReceivedTimestamp']) + (4*1000*60*60); // 5: send // 36: received // msg['Text']; if ($msg['Status']==5){ $output .= ''."\n"; }else{ $output .= ''."\n"; } } $output.= ''; // store xml file file_put_contents('sms-n900.xml', $output); // convert "strange" timestamp to unix timestamp function getUnixTS($str){ // calculate unix timestamp from sqlite timestamp $parts = explode('.', $str); // days since 1.1.1900 in [0] // seconds normalized to 1 in [1] (x1000 -> ms) $days = mktime(0,0,0,1,$parts[0]-1,1900) * 1000; // get normaaalizing factor $nFactor = floatval('0.'.$parts[1]); // get seconds (x1000 -> ms) $seconds = (60.0*60.0*24.0*1000.0) * $nFactor; // calculate timestamp $dte = $days + $seconds; return $dte; } ?>