本文整理汇总了PHP中fetch函数的典型用法代码示例。如果您正苦于以下问题:PHP fetch函数的具体用法?PHP fetch怎么用?PHP fetch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: class_rules
function class_rules($user_id, $tbl_result = "")
{
$this->user_id = $user_id;
$this->login = $tbl_result["login"] == "" ? "Super Admin" : $tbl_result["login"];
$this->listgroupeid = "";
if ($user_id != -1) {
$sql_getPerms = "select shortright from " . __racinebd__ . "droits d inner join " . __racinebd__ . "groupe_droits gd on d.droits_id=gd.droits_id inner join " . __racinebd__ . "groupe_users gu on gd.groupe_id=gu.groupe_id where gu.users_id=" . $user_id . " and droitarbre=0";
$link = query($sql_getPerms);
while ($li = fetch($link)) {
$this->genericRules[$li["shortright"]] = 1;
}
$this->list_groupe_id = implode(",", $listgroupe_id);
$sql_getPerms = "select * from " . __racinebd__ . "groupe_users gu where users_id=" . $user_id;
//print $sql_getPerms;
$link = query($sql_getPerms);
$listgroupe_id = array();
$tmptab = array();
$tmptab[] = 0;
while ($li = fetch($link)) {
$this->groupe_id[$li["groupe_id"]] = 1;
$tmptab[] = $li["groupe_id"];
}
$this->listgroupeid = implode(",", $tmptab) . ",0";
} else {
$this->listgroupeid = 0;
}
}
示例2: friend_link_check_ajax
function friend_link_check_ajax()
{
global $_G;
$host = $_SERVER['HTTP_HOST'];
$host = str_replace(array('http://', 'https://', '/'), '', $host);
$id = intval($_GET[id]);
$url = $_G[friend_link][$id]['url'];
if (!$url) {
json(array('status' => 'success', 'msg' => '-1'));
} else {
try {
$res = fetch($url);
} catch (Exception $e) {
$res = false;
}
if (!$res) {
$extends = -1;
} elseif (stripos($res, $host) !== false) {
$extends = 1;
} else {
$extends = 0;
}
json(array('status' => 'success', 'msg' => $extends));
}
}
示例3: getDownloadByUrl
/**
* 返回的是分段视频
* @param string $url
* @return array
*/
public function getDownloadByUrl($url)
{
require_once VPARSER_ROOT . '/Common/function.php';
$content = fetch($url);
preg_match_all('/fo\\.addVariable\\(\\"videoCenterId\\"\\,\\"(.*?)\\"\\)\\;/', $content, $arr);
$contents = fetch('http://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid=' . $arr[1][0] . '&idl=32&idlr=32&modifyed=false');
$v = json_decode($contents, true);
// [video] => Array
// (
// [validChapterNum] => 2
// [lowChapters] => Array
// (
// [0] => Array
// (
// [image] => http://p4.img.cctvpic.com/fmspic/2015/09/19/cdaae8023379407eb547870805762508-180.jpg
// [url] => http://vod.cntv.lxdns.com/flash/mp4video45/TMS/2015/09/19/cdaae8023379407eb547870805762508_h264200000nero_aac16.mp4
// [duration] => 146
// )
// )
// [totalLength] => 146.00
// [chapters] => Array
// (
// [0] => Array
// (
// [image] => http://p4.img.cctvpic.com/fmspic/2015/09/19/cdaae8023379407eb547870805762508-180.jpg
// [url] => http://vod.cntv.lxdns.com/flash/mp4video45/TMS/2015/09/19/cdaae8023379407eb547870805762508_h264418000nero_aac32.mp4
// [duration] => 146
// )
// )
// [url] =>
// )
$vUrl = $v['video']['chapters'];
return $vUrl;
}
示例4: svn_clone
function svn_clone($url)
{
#去除多余的url结尾多余的斜杠
$url = trim($url, '/');
$entries_url = $url . '/.svn/entries';
$content = get($entries_url);
if (!$content) {
return debug("{$url} 不是一个合法的svn工作副本!\n", ERROR);
} elseif (strlen($content) < 10) {
return debug("某个东西太短了,需要蓝色小药丸么?\n", ERROR);
}
#匹配出entries中的文件和目录名
preg_match_all('/\\f\\n([^\\n]+?)\\s(\\w+)\\s/s', $content, $m) or debug("{$entries_url} 不包含文件或子目录\n", WARNING);
$files = array_combine($m[1], $m[2]);
foreach ($files as $file => $type) {
if ($type == 'dir') {
debug(">>> 进入 {$file} 目录\n", ALL);
svn_clone($url . '/' . $file);
debug("<<< 退出 {$file} 目录\n", ALL);
} elseif ($type == 'file') {
debug("*** 下载 {$file} 文件\n", ALL);
fetch($url . '/.svn/text-base/' . $file . '.svn-base');
}
}
}
示例5: video_js
/**
* PLayer video in video-js player
* @global boolean $pak_player
* @param type $in
* @return boolean
*/
function video_js($in)
{
//Assigning configs so we can easily use them in template..
assign('configs', $in);
//get the file for video...
$files = $in['files'];
$video_files = array();
if ($files) {
foreach ($files as $key => $file) {
if ($key) {
if ($key == 'flv' || $key == 'mp4' || $key == 'mobile') {
$video_file = $file;
break;
}
}
if ($file['status'] == 's' && $file['is_original'] != 'yes') {
$video_file = $file['file_path'];
break;
}
}
}
assign('file', $video_file);
assign('video_files', $video_files);
$player = fetch(VIDEO_JS_DIR . '/player.html', false);
return $player;
}
示例6: checkMilestone
function checkMilestone($class, $action)
{
if (!$class) {
$action();
return;
}
$milestones = fetchAll("SELECT points FROM milestone ORDER BY points ASC");
$startPoints = array_pop(calculatePoints($class)["points"]);
$action();
$endPoints = array_pop(calculatePoints($class)["points"]);
$achieved = [];
foreach ($milestones as $stone) {
if ($stone->points > $endPoints) {
break;
}
if ($stone->points > $startPoints) {
array_push($achieved, $stone->points);
}
}
if (empty($achieved)) {
return;
}
$classInfo = fetch("SELECT c.name, u.email FROM class AS c JOIN user AS u ON c.teacher = u.id");
$n = "";
if (count($achieved) > 1) {
$n = "n";
}
foreach (fetchAll("SELECT email FROM user WHERE role = :admin", ["admin" => ADMIN]) as $admin) {
own_mail($admin->email, "Etappe{$n} erreicht", "Guten Tag,\r\nDie Klasse \"{$classInfo->name}\" hat die Etappe{$n} " . implode(", ", $achieved) . " erreicht!\r\nDie Lehrkraft ist: {$classInfo->email} \r\n\r\nNachhaltige Grüße\r\nIhre Weltfairsteher-Website");
}
own_mail($classInfo->email, "Etappe{$n} erreicht", "Herzlichen Glückwunsch, Ihre Klasse \"{$classInfo->name}\" hat bei WeltFAIRsteher die Etappe{$n} " . implode(", ", $achieved) . " erreicht!\r\nSie erhalten demnächst eine Überraschung per Post\r\n\r\nNachhaltige Grüße\r\nIhr WeltFAIRsteher-Team");
}
示例7: requestAndDisplayCompany
function requestAndDisplayCompany($company)
{
// echo $response;
$companies = fetch('GET', "/v1/company-search?keywords=" . urlencode($company) . "&country-code=us&facet=location,us:0&hq-only=true&");
if ($companies === FALSE) {
restart();
} else {
?>
<html>
<head>
<title>Companies</title>
</head>
<body>
<h1>Expires at: <?php
date_default_timezone_set('America/Los_Angeles');
echo date('l jS \\of F Y h:i:s A', $_SESSION['expires_at']);
?>
</h1>
<br><br>
<h1><?php
echo $companies;
?>
</h1>
</body>
</html>
<?php
}
}
示例8: fetch_forums
function fetch_forums()
{
// data to be stored in here
$json = array();
$good = 0;
foreach (self::$feeds as $url) {
$data = fetch($url);
if ($data) {
$good++;
$keep = self::$itemsToKeep;
$rss = simplexml_load_string($data);
foreach ($rss->channel->item as $item) {
if ($keep-- == 0) {
break;
}
$time = strtotime($item->pubDate);
$text = strip_tags($item->description);
if (strlen($text) > 140) {
$text = substr($text, 0, 140) . "…";
}
$json["T{$time}"] = array("time" => $time, "link" => (string) $item->link, "text" => $text);
}
}
}
if (count($json) > 0) {
// sort items by key, newest to oldest
krsort($json);
apc_store(self::$forumKey, json_encode($json));
return true;
} else {
return false;
}
}
示例9: fetch_platform_issues
function fetch_platform_issues()
{
// 1. Fetch the json encoded issues from github
// 2. Iterate thru issues, just keeping data we need (title/number)
// 3. Sort "temp" by updated_at (stored in key)
// 4. Cache sorted json string
$json = fetch(self::$platformIssueUrl);
if ($json) {
// Strip \r\n out of json, otherwise json_decode will fail
$json = str_replace(array(chr(13), chr(10)), array("", ""), $json);
$issues_arr = json_decode($json, 1);
if ($issues_arr) {
$data = array();
foreach ($issues_arr as $issues) {
foreach ($issues as $i) {
// temp key so we can sort array based on date
$ut = strtotime($i["updated_at"]);
$data["T{$ut}"] = $this->get_issue_object($i);
}
}
// newest issues first
krsort($data);
apc_store(self::$platformIssueKey, json_encode(array_values($data)));
return true;
}
}
return false;
}
示例10: get_video_info
function get_video_info($id)
{
$html = fetch("http://www.youtube.com/get_video_info?video_id={$id}");
// id: nCnJ_x-QpJM
//
// array (size=8)
// 'errorcode' => string '150' (length=3)
// 'reason' => string 'This video contains content from Quiz Group Pro. It is restricted from playback on certain sites.<br/><u><a href='http://www.youtube.com/watch?v=nCnJ_x-QpJM&feature=player_embedded' target='_blank'>Watch on YouTube</a></u>' (length=222)
// 'status' => string 'fail' (length=4)
// 'eventid' => string 'Aq4qVMLdN4ab-gOroIHwDQ' (length=22)
// 'errordetail' => string '0' (length=1)
// 'csi_page_type' => string 'embed' (length=5)
// 'c' => string 'WEB' (length=3)
// 'enablecsi' => string '1' (length=1)
parse_str($html, $video_info);
if (!empty($video_info['errorcode'])) {
throw new Exception(__FUNCTION__ . ': ' . json_encode($video_info));
}
$tmp = array();
foreach (explode(',', $video_info['url_encoded_fmt_stream_map']) as $stream_str) {
parse_str($stream_str, $stream);
$tmp[] = $stream;
}
$video_info['url_encoded_fmt_stream_map'] = $tmp;
$tmp = array();
foreach (explode(',', $video_info['adaptive_fmts']) as $fmt_str) {
parse_str($fmt_str, $fmt);
$tmp[] = $fmt;
}
$video_info['adaptive_fmts'] = $tmp;
return $video_info;
}
示例11: getAllSubCategories
function getAllSubCategories($filename)
{
$categories = unserialize(file_get_contents($filename));
echo "---- run getAllSubCategories() ----\n\r";
foreach ($categories as $j => $category) {
if ($category['childrens']) {
foreach ($category['childrens'] as $k => $children) {
echo "---- crawling childrens for {$children['name']} ----\n\r";
$doc = phpQuery::newDocumentHTML(fetch('http://www.walmart.com' . $children['link']));
phpQuery::selectDocument($doc);
foreach (pq('.shop-by-category li') as $el) {
echo "---- " . pq($el)->find('a')->attr('href') . "} ----\n\r";
$childrens[] = array('name' => pq($el)->find('a')->data('name'), 'link' => pq($el)->find('a')->attr('href'));
}
$categories[$j]['childrens'][$k]['childrens'] = $childrens;
}
}
}
echo "---- creating deparment file ----\n\r";
$file = fopen($filename, 'w+');
echo "---- writing deparment file ----\n\r";
fputs($file, serialize($categories));
echo "---- closing deparment file ----\n\r";
fclose($file);
}
示例12: adjust_tags
function adjust_tags($from, $layout = FALSE)
{
static $open = '/\\s*<(script|style)[^>]*?>.*?<\\/\\1>\\s*/s', $close = '/\\s*<(meta|link)[^>]*?\\/?>\\s*/s', $header = '/<(head)[^<>]*>(.+?)<\\/\\1>/s', $descript = '/<title>(.+?)<\\/title>/s';
if (preg_match('/^(?:<html|["\'\\[{])/', $from)) {
return $from;
}
$separator = option('separator') ?: ' - ';
$top_title = option('title');
$sub_title = fetch('title');
$raw = $head = $body = $title = $stack = array();
$collect = function ($match) use(&$stack) {
$stack[] = array('tag' => $match[1], 'full' => trim($match[0]));
};
$from = preg_replace_callback($header, function ($match) use(&$raw) {
$raw[] = $match[2];
}, $from);
preg_match($descript, $layout, $match) && ($top_title = $match[1]);
preg_match($descript, $from, $match) && ($sub_title = $match[1]);
$top_title && ($title[] = trim($top_title));
$sub_title && ($title[] = trim($sub_title));
$layout = preg_replace($descript, '', $layout);
$from = preg_replace($descript, '', $from);
$from = preg_replace_callback($open, $collect, $from);
$from = preg_replace_callback($close, $collect, $from);
foreach ($stack as $one) {
$one['tag'] === 'script' ? $body[] = $one['full'] : ($head[] = $one['full']);
}
while ($head[] = array_shift($raw)) {
}
$from = preg_replace('/<(body)([^<>]*?)>/', "<\\1\\2>\n{$from}", $layout);
$from = str_replace('</head>', sprintf("%s\n</head>", join("\n", $head)), $from);
$from = str_replace('</body>', sprintf("%s\n</body>", join("\n", $body)), $from);
$from = str_replace('</head>', sprintf("<title>%s</title>\n</head>", join($separator, $title)), $from);
return $from;
}
示例13: replaceTag
/**
* 编译并返回内容
* @param unknown_type $attr
* @param unknown_type $value
* @param unknown_type $tagInfo
* @return Ambigous <void, mixed>|string
*/
public function replaceTag($attr, $value = '', $tagInfo)
{
$this->init($attr, $value);
//调用子类的replace方法把参数引入
$var = $this->replace();
return fetch($this->templateFile, $var);
}
示例14: page_edit
/**
* The main Page editor panel.
*
* @param string|array $message The activity message
*/
function page_edit($message = '')
{
global $event, $step;
pagetop(gTxt('edit_pages'), $message);
extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
$name = sanitizeForPage(assert_string(gps('name')));
$newname = sanitizeForPage(assert_string(gps('newname')));
if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
$name = safe_field('page', 'txp_section', "name = 'default'");
} elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
$name = $newname;
}
$buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true);
if ($name) {
$buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions'));
} else {
$buttons .= hInput('savenew', 'savenew');
}
$html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
// Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
$tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
$tagbuild_links = '';
foreach ($tagbuild_items as $tb => $item) {
$tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
}
echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading'));
echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
示例15: section_create
function section_create()
{
global $txpcfg;
$name = ps('name');
//Prevent non url chars on section names
include_once txpath . '/lib/classTextile.php';
$textile = new Textile();
$title = $textile->TextileThis($name, 1);
$name = strtolower(sanitizeForUrl($name));
$chk = fetch('name', 'txp_section', 'name', $name);
if (!$chk) {
if ($name) {
$default = doSlash(safe_row('page, css', 'txp_section', "name = 'default'"));
$rs = safe_insert("txp_section", "name = '" . doSlash($name) . "',\n\t\t\t\t\ttitle = '" . doSlash($title) . "',\n\t\t\t\t\tpage = '" . $default['page'] . "',\n\t\t\t\t\tcss = '" . $default['css'] . "',\n\t\t\t\t\tis_default = 0,\n\t\t\t\t\tin_rss = 1,\n\t\t\t\t\ton_frontpage = 1");
if ($rs) {
update_lastmod();
$message = gTxt('section_created', array('{name}' => $name));
sec_section_list($message);
}
} else {
sec_section_list();
}
} else {
$message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
sec_section_list($message);
}
}