本文整理汇总了PHP中Feed::get_data方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::get_data方法的具体用法?PHP Feed::get_data怎么用?PHP Feed::get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feed
的用法示例。
在下文中一共展示了Feed::get_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: feed_data
public static function feed_data($cmd, $dir_tmp_cache, $temps)
{
// cmd = insert_database
if ($cmd == 'insert_database') {
$dir = 'cache/temp_data.cache.php';
if (file_exists($dir)) {
require $dir;
if (isset($items) and $items) {
foreach ($items as $key => $value) {
// Feed::debug($value);
$table = $value['table'];
if (!DB::fetch('select id from ' . $table . ' where name="' . str_replace('"', '\\"', $value['name']) . '"')) {
unset($value['table']);
DB::insert($table, $value);
}
}
@unlink($dir);
}
}
header('Location:' . $_SERVER['REQUEST_URI']);
} else {
// Case lay du lieu
if ($cmd == 'feed') {
// Lấy tin
$temps = implode(',', $temps);
//require_once 'lib/simple_html_dom.php';
//require_once 'lib/crawler.php';
$_Feed = new Crowler();
// return $_Feed;
$sites = $_Feed->get_site('declaration.id in (' . $temps . ')');
return $sites;
if ($sites = $_Feed::get_site('declaration.id in (' . $temps . ')')) {
// Feed::debug($sites);
foreach ($sites as $key => $value) {
$check_page = strpos($value['url'], '*');
// strpos : tim kiem chuoi
if ($check_page === false) {
Feed::get_data($value, Feed::get_pattern($key));
} else {
if ($page_num = $value['page_num']) {
$check_page_num = strpos($page_num, '-');
if ($check_page_num === false) {
$value['url'] = str_replace('*', $page_num, $value['url']);
Feed::get_data($value, Feed::get_pattern($key));
} else {
$arr_page = explode('-', $page_num);
for ($i = $arr_page[1]; $i >= $arr_page[0]; $i--) {
$site = $value;
$site['url'] = str_replace('*', $i, $value['url']);
Feed::get_data($site, Feed::get_pattern($key));
}
}
} else {
$value['url'] = str_replace('*', '1', $value['url']);
Feed::get_data($value, Feed::get_pattern($key));
}
}
}
// Lưu tin đã lấy vào file cache
$path = 'cache/temp_data.cache.php';
$content = '<?php $items = ' . var_export(Feed::$items, true) . ';?>';
$handler = fopen($path, 'w+');
fwrite($handler, $content);
fclose($handler);
}
header('Location:' . $_SERVER['REQUEST_URI']);
}
}
}
示例2: feed_controller
function feed_controller()
{
global $mysqli, $redis, $session, $route, $feed_settings;
$result = false;
require_once "Modules/feed/feed_model.php";
$feed = new Feed($mysqli, $redis, $feed_settings);
if ($route->format == 'html') {
if ($route->action == "list" && $session['write']) {
$result = view("Modules/feed/Views/feedlist_view.php", array());
} else {
if ($route->action == "api" && $session['write']) {
$result = view("Modules/feed/Views/feedapi_view.php", array());
}
}
} else {
if ($route->format == 'json') {
// Public actions available on public feeds.
if ($route->action == "list") {
if ($session['read']) {
if (!isset($_GET['userid']) || isset($_GET['userid']) && $_GET['userid'] == $session['userid']) {
$result = $feed->get_user_feeds($session['userid']);
} else {
if (isset($_GET['userid']) && $_GET['userid'] != $session['userid']) {
$result = $feed->get_user_public_feeds(get('userid'));
}
}
} else {
if (isset($_GET['userid'])) {
$result = $feed->get_user_public_feeds(get('userid'));
}
}
} elseif ($route->action == "create" && $session['write']) {
$result = $feed->create($session['userid'], get('tag'), get('name'), get('datatype'), get('engine'), json_decode(get('options')));
} elseif ($route->action == "updatesize" && $session['write']) {
$result = $feed->update_user_feeds_size($session['userid']);
} elseif ($route->action == "buffersize" && $session['write']) {
$result = $feed->get_buffer_size();
// To "fetch" multiple feed values in a single request
// http://emoncms.org/feed/fetch.json?ids=123,567,890
} elseif ($route->action == "fetch" && $session['read']) {
$feedids = (array) explode(",", get('ids'));
for ($i = 0; $i < count($feedids); $i++) {
$feedid = (int) $feedids[$i];
if ($feed->exist($feedid)) {
// if the feed exists
$result[$i] = $feed->get_value($feedid);
// null is a valid response
} else {
$result[$i] = false;
}
// false means feed not found
}
} else {
$feedid = (int) get('id');
// Actions that operate on a single existing feed that all use the feedid to select:
// First we load the meta data for the feed that we want
if ($feed->exist($feedid)) {
$f = $feed->get($feedid);
// if public or belongs to user
if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
if ($route->action == "timevalue") {
$result = $feed->get_timevalue($feedid);
} else {
if ($route->action == 'data') {
$skipmissing = 1;
$limitinterval = 1;
if (isset($_GET['skipmissing']) && $_GET['skipmissing'] == 0) {
$skipmissing = 0;
}
if (isset($_GET['limitinterval']) && $_GET['limitinterval'] == 0) {
$limitinterval = 0;
}
$result = $feed->get_data($feedid, get('start'), get('end'), get('interval'), $skipmissing, $limitinterval);
} else {
if ($route->action == "value") {
$result = $feed->get_value($feedid);
} else {
if ($route->action == "get") {
$result = $feed->get_field($feedid, get('field'));
} else {
if ($route->action == "aget") {
$result = $feed->get($feedid);
} else {
if ($route->action == 'histogram') {
$result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
} else {
if ($route->action == 'kwhatpower') {
$result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
} else {
if ($route->action == 'kwhatpowers') {
$result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例3: feed_controller
function feed_controller()
{
global $mysqli, $redis, $session, $route, $feed_settings;
$result = false;
include "Modules/feed/feed_model.php";
$feed = new Feed($mysqli, $redis, $feed_settings);
if ($route->format == 'html') {
if ($route->action == "list" && $session['write']) {
$result = view("Modules/feed/Views/feedlist_view.php", array());
}
if ($route->action == "api" && $session['write']) {
$result = view("Modules/feed/Views/feedapi_view.php", array());
}
}
if ($route->format == 'json') {
// Public actions available on public feeds.
if ($route->action == "list") {
if (!isset($_GET['userid']) && $session['read']) {
$result = $feed->get_user_feeds($session['userid']);
}
if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] == $session['userid']) {
$result = $feed->get_user_feeds($session['userid']);
}
if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] != $session['userid']) {
$result = $feed->get_user_public_feeds(get('userid'));
}
if (isset($_GET['userid']) && !$session['read']) {
$result = $feed->get_user_public_feeds(get('userid'));
}
} elseif ($route->action == "getid" && $session['read']) {
$result = $feed->get_id($session['userid'], get('name'));
} elseif ($route->action == "create" && $session['write']) {
$result = $feed->create($session['userid'], get('name'), get('datatype'), get('engine'), json_decode(get('options')));
} elseif ($route->action == "updatesize" && $session['write']) {
$result = $feed->update_user_feeds_size($session['userid']);
// To "fetch" multiple feed values in a single request
// http://emoncms.org/feed/fetch.json?ids=123,567,890
} elseif ($route->action == "fetch" && $session['read']) {
$feedids = (array) explode(",", get('ids'));
for ($i = 0; $i < count($feedids); $i++) {
$feedid = (int) $feedids[$i];
if ($feed->exist($feedid)) {
$result[$i] = (double) $feed->get_value($feedid);
} else {
$result[$i] = "";
}
}
} else {
$feedid = (int) get('id');
// Actions that operate on a single existing feed that all use the feedid to select:
// First we load the meta data for the feed that we want
if ($feed->exist($feedid)) {
$f = $feed->get($feedid);
// if public or belongs to user
if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
if ($route->action == "value") {
$result = $feed->get_value($feedid);
}
if ($route->action == "timevalue") {
$result = $feed->get_timevalue_seconds($feedid);
}
if ($route->action == "get") {
$result = $feed->get_field($feedid, get('field'));
}
// '/[^\w\s-]/'
if ($route->action == "aget") {
$result = $feed->get($feedid);
}
if ($route->action == 'histogram') {
$result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
}
if ($route->action == 'kwhatpower') {
$result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
}
if ($route->action == 'kwhatpowers') {
$result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
}
if ($route->action == 'data') {
$result = $feed->get_data($feedid, get('start'), get('end'), get('dp'));
}
if ($route->action == 'average') {
$result = $feed->get_average($feedid, get('start'), get('end'), get('interval'));
}
if ($route->action == 'history') {
$result = $feed->get_history($feedid, get('start'), get('end'), get('interval'));
}
}
// write session required
if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $f['userid'] == $session['userid']) {
// Storage engine agnostic
if ($route->action == 'set') {
$result = $feed->set_feed_fields($feedid, get('fields'));
}
if ($route->action == "insert") {
$result = $feed->insert_data($feedid, time(), get("time"), get("value"));
}
if ($route->action == "update") {
$result = $feed->update_data($feedid, time(), get("time"), get('value'));
}
if ($route->action == "delete") {
//.........这里部分代码省略.........