waue/2011/1202: png_out.php

File png_out.php, 1.2 KB (added by waue, 13 years ago)
Line 
1<?php
2
3$style="";
4$date="";
5$hour="";
6if(isset($_GET['style'])){
7  $style = trim($_GET['style']);
8//  echo $style;
9}
10if(isset($_GET['date'])){
11  $date = trim($_GET['date']);
12//  echo $date;
13}
14if(isset($_GET['hour'])){
15  $hour = trim($_GET['hour']);
16//  echo $hour;
17}
18
19$key_space = 'png';
20$column_family = 'png';
21$column_family_date = 'date';
22
23require_once 'Cassandra.php';
24
25
26// list of seed servers to randomly connect to
27// all the parameters are optional and default to given values
28$servers = array(
29  array(
30    'host' => '127.0.0.1',
31    'port' => 9160,
32    'use-framed-transport' => true,
33    'send-timeout-ms' => 1000,
34    'receive-timeout-ms' => 1000
35  )
36);
37
38$cassandra = Cassandra::createInstance($servers);
39$cassandra->useKeyspace($key_space);
40$cassandra->setMaxCallRetries(5);
41
42$id=$date.$hour;
43if ( $id == ""){
44  echo "nothing! <br>";
45  echo "ex:png_out.php?date=20110817&hour=02";
46}else{
47  $target = $cassandra->cf($column_family)->get($id);
48  if ($target == null){
49    echo "no data";
50  }else{
51    header('Content-Type: image/png');
52    echo $target["content"];
53    /*
54    // show all , maybe work but exceed 30 secs.
55    $target = $cassandra->cf($column_family)->getKeyRange();
56    echo 'Schema: <pre>'.print_r($target->getAll(), true).'</pre><hr/>';
57    */
58  }
59}
60
61?>
62