/**
 * @file
 *   Create a status graph based on likes/comments
 */

function print_graph() {
  $statuses = statuses_retrieve();
  $graph_data = new stdClass();
  $graph_data = array(
    'period_1' => generate_data($statuses, 1),
    'period_3' => generate_data($statuses, 3),
    'period_6' => generate_data($statuses, 6),    
  );   
?>
  <script type="text/javascript">
    var graph_data = <?php print json_encode($graph_data); ?>;
    // var statuses = <?php // print $statuses_json; ?>
  </script>
  <div id="placeholder" style="width:720px;height:250px;"></div>

  <br />

  <div class="timeframe"><input class="fetchSeries uibutton" id="button-1" graph_period="6" type="button"
	value="6 months"> 
  <span></span></div>

  <div class="timeframe"><input class="fetchSeries uibutton" id="button-2" graph_period="3" type="button"
	value="3 Months">
  <span></span></div>
  
  <div class="timeframe"><input class="fetchSeries uibutton" id="button-3" graph_period="1" type="button"
	value="1 Month">  
  <span></span></div>
  
  <div class="clearfloat"></div>
  
<?php   
}
Exemplo n.º 2
0
Arquivo: poc.php Projeto: kcyeu/RedOp
        }
    } else {
        foreach ($expected as $sm => $countries) {
            $result = json_decode($redis->get($sm), true);
        }
    }
}
$redis = setup();
//$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
//$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
$filename = 'data-' . SM_COUNT . '-' . COUNTRY_COUNT . '.json';
on_the_fly($redis);
exit;
if (GEN_DATA_ON_FLY) {
    $data = generate_data();
    $json_str = json_encode($data);
    file_put_contents($filename, $json_str);
} else {
    $json_str = file_get_contents($filename);
    $data = json_decode($json_str, true);
}
$start_write_time = microtime(true);
if (USE_FILTER) {
    put_filter_data($data, $redis);
} else {
    put_data($data, $redis);
}
$write_time = microtime(true) - $start_write_time;
$start_read_time = microtime(true);
if (USE_FILTER) {
Exemplo n.º 3
0
            printf("   Is Banned: %s\n", $item->is_banned ? 'Y' : 'N');
            printf("Agreed Terms: %s\n", $item->agreed_to_terms ? 'Y' : 'N');
            printf(" Gold Member: %s\n", $item->gold_member ? 'Y' : 'N');
            printf("   Autologin: %s\n", $item->pref_autologin ? 'Y' : 'N');
            printf("    Show Ads: %s\n", $item->pref_show_ads ? 'Y' : 'N');
            printf("  Newsletter: %s\n", $item->pref_newsletter ? 'Y' : 'N');
            printf("Chat Enabled: %s\n", $item->pref_chat_enabled ? 'Y' : 'N');
            printf("\n");
        }
        fclose($fp);
        return;
    }
    throw new Exception("Failed to open example.data");
}
echo "Writing random data...\n";
generate_data(1000);
echo "Reading entries...\n";
read_data_entries();
echo "Done.\n";
exit;
// Example of how to use Bitfield directly:
$field = new Bitfield();
$field->addOption('USER_IS_ADMIN');
$field->addOption('USER_IS_BANNED');
$field->addOption('USER_IS_ADVERTISER');
$field->addOption('PREF_AUTOLOGIN');
$field->addOption('PREF_SHOW_ADS');
$field->setBitfield(USER_IS_ADMIN | PREF_AUTOLOGIN | PREF_SHOW_ADS);
if ($field->isEnabled(USER_IS_ADMIN)) {
    echo "Hello sir!\n";
    if ($field->isEnabled(PREF_AUTOLOGIN)) {
Exemplo n.º 4
0
        $data_arr[$k]['tel'] = trim(substr($tel, 0, -1));
        $data_arr[$k]['dp_id'] = trim($dp_id);
        $data_arr[$k]['thumb'] = $thumb;
        $data_arr[$k]['area'] = trim($area);
        $data_arr[$k]['category'] = trim($category);
        $data_arr[$k]['comment_count'] = $comment_count;
        $data_arr[$k]['avg_cost'] = $avg_cost;
        $data_arr[$k]['bus_time'] = trim($bus_time);
        $data_arr[$k]['lng'] = trim($baidu_map_arr['lng']);
        $data_arr[$k]['lat'] = trim($baidu_map_arr['lat']);
    }
    return $data_arr;
}
function generate_data($data_arr)
{
    global $city_key;
    $db = new DB();
    foreach ($data_arr as $k => $v) {
        $time = date("Y-m-d h:m:s");
        $rows = $db->select('select * from grab_sport_shop where dp_id=? and city=?', array($v['dp_id'], $city_key));
        if ($rows) {
            echo "[notice] dp_id {$v['dp_id']} city {$city_key} has exists.\n";
            return;
        }
        echo "[info] insert {$k}\n";
        $rows = $db->insert("insert into grab_sport_shop (\n            `name`,\n            `addr`,\n            `city`,\n            `tel`,\n            `dp_id`,\n            `thumb`,\n            `area`,\n            `category`,\n            `comment_count`,\n            `avg_cost`,\n            `bus_time`,\n            `lng`,\n            `lat`,\n            `create_time`\n        ) values (\n            ?,?,?,?,?,?,?,?,?,?,?,?,?,now()\n        )", array($v['name'], $v['addr'], $v['city'], $v['tel'], $v['dp_id'], $v['thumb'], $v['area'], $v['category'], $v['comment_count'], $v['avg_cost'], $v['bus_time'], $v['lng'], $v['lat']));
    }
}
$dp_arr = parse_html_from_file();
generate_data($dp_arr);