getfile and convo gen
getfile and convo gen

--- a/calls.json.php
+++ b/calls.json.php
@@ -3,10 +3,10 @@
 function getTGIDValuesByHour($TGID, $timeFrom, $timeTo) {
     global $conn;
     $sth = $conn->prepare( 'select tgid, min(call_timestamp) as time, count(*), min(length), max(length), avg(length), stddev(length) from recordings
+where call_timestamp between to_timestamp(?) and to_timestamp(?)
             group by tgid, date_trunc(\'hour\', call_timestamp) order by time');
 
-    $sth->execute( );
-    //Array($TGID, $timeFrom, $timeTo)
+    $sth->execute(Array($timeFrom, $timeTo));
         return  $sth->fetchAll();
 
 

--- a/generateConvos.php
+++ b/generateConvos.php
@@ -8,18 +8,26 @@
 $convo = Array();
 foreach ($recordings as $i => $recording) {
 
-	if (count($convo) > 0 && strcasecmp($convo[count($convos)]['tgid'], $recording['tgid']) != 0) {
+	if (count($convo) > 0) {
+		echo "<br> ".strcasecmp($convos[count($convos)-1][0]['call_timestamp'],$recording['call_timestamp']);
+		if (abs(strcasecmp($convos[count($convos)-1][0]['call_timestamp'],$recording['call_timestamp'])) > 2) {
+			echo " ".$convos[count($convos)-1][0]['call_timestamp']." ".$recording['call_timestamp'];
+		}
+		if (strcasecmp($convos[count($convos)-1][0]['tgid'], $recording['tgid']) != 0 ) {
 		$convos[] = $convo;
 		$convo = Array();
+		}
 	} ;
 	//print_r($recording);
 	$convo[] = $recording;
 	//print_r($convo);
-	echo "<br>\n";
+	//echo "<br>\n";
 }
 foreach ($convos as $i => $convo) {
-	print_r($convo);
-	echo "<br>\n";
+	foreach($convo as $recording) {
+		echo $recording['filename']." , ";
+	}
+	echo "<br><hr>\n";
 }
 ?>
 

file:b/getfile.php (new)
--- /dev/null
+++ b/getfile.php
@@ -1,1 +1,20 @@
+<?php
+$reqfile = "path/to/file.3gp";
+$contenttype="audio/3gpp";
+ 
+if($fn=fopen($reqfile, "rba")){
+  header("Content-Type: ".$contenttype); 
+  header("Content-Length: ".filesize($reqfile)); 
+  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+  header("Pragma: no-cache");
+  header("Expires: Mon, 26 Jul 1997 06:00:00 GMT");
+  header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
+passthru("ffmpeg -i 2012-09-29-1348911268.34-demo.wav -ar 8000 -ab 4.75k -");
+  fpassthru($fn);
+  fclose($fn);
+}else{
+  exit("error....");
+}
+exit();
+?>
 

--- a/viewcalls.php
+++ b/viewcalls.php
@@ -1,7 +1,16 @@
 <?php
 include('common.inc.php');
 $tgid = 44028;
+$from = (isset($_REQUEST['from']) ? $_REQUEST['from'] : strtotime("2012-09-12"));
+$to = (isset($_REQUEST['to']) ? $_REQUEST['to'] : strtotime("2012-12-12"));
 include_header("fdds");
+    $sth = $conn->prepare('select distinct date_trunc(\'day\', call_timestamp) as rdate from recordings order by rdate');
+
+    $sth->execute();
+    foreach( $sth->fetchAll() as $row) {
+echo '<a href="?from='.strtotime($row['rdate']).'&amp;to='.strtotime($row['rdate'].' +1 day').'">'.$row['rdate'].'</a> <br>';
+}
+
 ?>
 <div class="span12">
 
@@ -48,7 +57,7 @@
             Flotr.EventAdapter.observe(placeholder, 'flotr:click', function () { drawGraph(); });
 
                
-        getData('<?php echo $tgid; ?>','<?php echo strtotime("10/09/2012") ?>','<?php echo strtotime("10/11/2012") ?>');
+        getData('<?php echo $tgid; ?>','<?php echo $from ?>','<?php echo $to ?>');
         
     });
 
@@ -91,3 +100,4 @@
 <?php
 include_footer();
 ?>
+