本文整理汇总了PHP中f函数的典型用法代码示例。如果您正苦于以下问题:PHP f函数的具体用法?PHP f怎么用?PHP f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了f函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: authenticateRemoteUser
public function authenticateRemoteUser($remoteUser)
{
$app = \App::getInstance();
$authorized = f('auth.remoteAuthorize', $remoteUser);
if ($authorized) {
$users = \Norm\Norm::factory('User');
$user = $users->findOne(array('username' => $remoteUser['username']));
if (is_null($user)) {
$user = $users->newInstance();
$user['username'] = $remoteUser['username'];
$user['first_name'] = $remoteUser['first_name'];
$user['last_name'] = $remoteUser['last_name'];
$user['birth_date'] = $remoteUser['birth_date'];
$user['birth_place'] = $remoteUser['birth_place'];
}
if (!empty($remoteUser['normalized_username'])) {
$user['normalized_username'] = $remoteUser['normalized_username'];
}
$user['email'] = $remoteUser['email'];
$user['sso_account_id'] = $remoteUser['$id'];
$user->save();
} else {
throw new \Exception('You are unauthorized to access this application. Please contact administrator.');
}
return $user->toArray();
}
开发者ID:reekoheek,项目名称:bono-auth,代码行数:26,代码来源:OAuth.php
示例2: doError
public function doError($exception = null)
{
function setError($code, $msg)
{
http_response_code($code);
return sprintf("%s%s", is_numeric($code) ? "<span style=\"color: red;\">{$code}</span> " : '', $msg);
}
function f($e)
{
if ($e instanceof ForbiddenException) {
return setError(403, 'FORBIDDEN');
} else {
if ($e instanceof WrongMethodException) {
return setError(405, 'WRONG METHOD');
} else {
if ($e instanceof BadRequestException) {
return setError(400, 'BAD REQUEST');
} else {
if ($e instanceof NotFoundException) {
return setError(404, 'NOT FOUND');
} else {
return setError(500, 'INTERNAL SERVER ERROR');
}
}
}
}
}
return '<div style="text-align: center; padding-top: 20px;">' . f($exception) . '</div>';
}
开发者ID:zivanof,项目名称:fun_project,代码行数:29,代码来源:Controller.php
示例3: getFields
/**
* 获取表字段信息
*
* @param string $table
*
* @return array|bool|void
*/
public function getFields($table)
{
$name = c('database.database') . '.' . $table;
//字段缓存
if (!c('app.debug') && f($name, '[get]', 0, ROOT_PATH . '/storage/field')) {
$data = f($name, '[get]', 0, ROOT_PATH . '/storage/cache/field');
} else {
$sql = "show columns from " . c('database.prefix') . $table;
if (!($result = Db::query($sql))) {
return [];
}
$data = [];
foreach ((array) $result as $res) {
$f['field'] = $res['Field'];
$f['type'] = $res['Type'];
$f['null'] = $res['Null'];
$f['field'] = $res['Field'];
$f['key'] = $res['Key'] == "PRI" && $res['Extra'] || $res['Key'] == "PRI";
$f['default'] = $res['Default'];
$f['extra'] = $res['Extra'];
$data[$res['Field']] = $f;
}
f($name, $data, 0, ROOT_PATH . '/storage/field');
}
return $data;
}
开发者ID:houdunwang,项目名称:hdphp,代码行数:33,代码来源:Mysql.php
示例4: move
/**
* @role update
*/
public function move()
{
$page = StaticPage::getInstanceById((int) $this->request->get('id'), StaticPage::LOAD_DATA);
// update parent
if ($this->request->get('parent')) {
$parent = StaticPage::getInstanceById((int) $this->request->get('parent'), StaticPage::LOAD_DATA);
} else {
$parent = null;
}
$page->parent->set($parent);
$page->save();
// update order
$f = new ARUpdateFilter();
if ($parent) {
$f->setCondition(eq(f('StaticPage.parentID'), $parent->getID()));
} else {
$f->setCondition(new IsNullCond(f('StaticPage.parentID')));
}
$f->addModifier('StaticPage.position', new ARExpressionHandle('position+2'));
if ($this->request->get('previous')) {
$previous = StaticPage::getInstanceById((int) $this->request->get('previous'), StaticPage::LOAD_DATA);
$position = $previous->position->get();
$f->mergeCondition(gt(f('StaticPage.position'), $position));
$page->position->set($position + 1);
} else {
$previous = null;
$page->position->set(1);
}
ActiveRecordModel::updateRecordSet('StaticPage', $f);
$page->save();
return new JSONResponse(array(), 'success', $this->translate('_pages_were_successfully_reordered'));
}
开发者ID:saiber,项目名称:livecart,代码行数:35,代码来源:StaticPageController.php
示例5: set
public function set(array $delete, array $cookies)
{
$pending = array();
$f = function ($spec, $key, $val) use($pending) {
if (!array_key_exists($spec, $pending)) {
$pending[$spec] = array();
}
$pending[$spec][$key] = $val;
};
foreach ($delete as $key) {
f(null, $key, '');
}
foreach ($cookies as $key => $data) {
list($val, $spec) = $data;
$f($spec, $key, $val);
}
$callback = $this->callback;
foreach ($pending as $spec => $data) {
if ($spec === null) {
$spec = new CookieSpec();
}
$flags = $spec->secure ? extCookie::SECURE : 0;
$flags += $spec->httponly ? extCookie::HTTPONLY : 0;
$httpCookie = new extCookie(null, $flags);
$httpCookie->setCookies($data);
$httpCookie->setExpires($spec->expire);
$httpCookie->setPath($spec->path);
$httpCookie->setDomain($spec->domain);
$callback($httpCookie->toString());
}
return true;
}
开发者ID:Ronmi,项目名称:fruit-cookiekit,代码行数:32,代码来源:PeclHttpCookieSetter.php
示例6: rss
function rss()
{
$url = f('url');
if (!$url) {
$url = 'http://java5000.blogspot.com/feeds/posts/default?alt=rss';
}
require ROOT . 'lib/rss/lastRSS.php';
$rss = new lastRSS();
$str = $this->url2str($url, 1);
if (!$str) {
$data = $this->fmodel('rss')->peek(array('url' => $url));
$data['valid'] = 2;
$this->fmodel('rss')->save($data);
$str = "";
} else {
cacheme($url, $str);
}
$result = $rss->ParseStr($str);
if ($result["encoding"] && strcasecmp($result["encoding"], "utf-8") != 0) {
$result = $rss->ParseStr(mb_convert_encoding($str, "UTF-8", $result["encoding"]));
}
foreach ($result["items"] as &$i) {
$i["description"] = html_entity_decode($i["description"]);
$i["description"] = preg_replace('/< *br *[\\/]?>/', "\n", $i["description"]);
$i["description"] = preg_replace('|href=("?)|i', 'target=_blank href=${1}/self/out/rd?url=', $i["description"]);
$i["link"] = preg_replace('/>$/', "", $i["link"]);
if (!preg_match('/^https?\\:/', $i["link"])) {
$i["link"] = "http://www.google.com/search?q=" . urlencode($i["title"]);
}
}
$this->sv("rssresult", $result);
$rsslist = $this->fmodel('rss')->peeks(array('valid' => 1));
$this->sv("rssfeed", array_reverse($rsslist));
}
开发者ID:tranngocthang89,项目名称:basephpmvc,代码行数:34,代码来源:wiki_controller.php
示例7: replaceFields
private function replaceFields($item)
{
// SEARCH {} IN TEMPLATE
preg_match_all('`{([A-Za-z0-9\\._\\x7f-\\xff]+?)}`', $this->tpl, $results);
if (!$results) {
return;
}
$results[0] = array_unique($results[0]);
$results[1] = array_unique($results[1]);
foreach ($results[0] as $key => $value) {
// ONLY FOR PHPTHUMB AND JCROP
if ($results[1][$key] == 'phptParams') {
if ($item['cropCords']) {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getCropParams($item['cropCords']), $this->copyTpl);
} else {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getParams(), $this->copyTpl);
}
}
// RETURN WIDTH AND HEIGHT ATTR OF IMG
if ($results[1][$key] == 'imgSize') {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getImgDimentions(), $this->copyTpl);
}
// ITERATE ALL {} FOUND IN TEMPLATE
$this->copyTpl = preg_replace('/' . $value . '/', f($item[$results[1][$key]]), $this->copyTpl);
}
}
开发者ID:santikrass,项目名称:poliversal,代码行数:26,代码来源:class.Loop.php
示例8: foo
function foo()
{
$obj = new C();
$obj->a = f();
$obj->b = new C();
$obj->b->a = f();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:1519.php
示例9: foo
function foo($a)
{
(yield 1);
foreach ((array) f($a) as $x) {
var_dump('i:' . $x);
}
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:2160.php
示例10: fetch
function fetch($tpl = '')
{
// 模板文件
T('POEM_COMPILE_TIME');
$tpl = $this->parseTpl($tpl);
$filekey = str_replace(APP_PATH, '', $tpl);
// 文件名 Home/Index/index.html
$c_w_v_tpl = f($filekey, '', 2);
// 判断是否存在
if (APP_DEBUG || $c_w_v_tpl === false) {
$content = file_get_contents($tpl);
// 开启页面布局
if (($layfile = config('layout')) && config('layout_on') === true) {
$layfile = $this->parseTpl($layfile);
$content = str_replace('{__LAYOUT__}', $content, file_get_contents($layfile));
}
$content = $this->compiler($content);
// 模板编译
$c_w_v_tpl = f($filekey, $content);
// F($filekey, php_strip_whitespace($c_w_v_tpl) ); // 去掉空格什么的
}
T('POEM_COMPILE_TIME', 0);
// 模板变量
if (!empty($this->html_vars)) {
extract($this->html_vars);
}
$this->html_vars = array();
// 清空
// 缓冲区
ob_start();
ob_implicit_flush(0);
include $c_w_v_tpl;
// 获取并清空缓存
return ob_get_clean();
}
开发者ID:rehorn,项目名称:phppoem,代码行数:35,代码来源:view.php
示例11: get_aid_by_name
function get_aid_by_name($name)
{
$s = q("SELECT * FROM aid WHERE name = '" . clean_query($name) . "' limit 1;");
if (a() > 0) {
return f($s);
}
}
开发者ID:mwcs01,项目名称:openpantry,代码行数:7,代码来源:food_source.lib.php
示例12: __construct
public function __construct()
{
Language::read("common");
Language::read("microshop");
if (c("microshop_isuse") != "1") {
header("location: " . SiteUrl);
exit;
}
Tpl::setdir("default");
self::cp();
Tpl::setlayout("microshop_layout");
if ($_GET['column'] && strtoupper(CHARSET) == "GBK") {
$GLOBALS['_GET'] = Language::getgbk($_GET);
}
Tpl::output("nav_list", ($nav = f("nav")) ? $nav : h("nav", TRUE, "file"));
$search_type = array();
$search_type['goods'] = Language::get("nc_microshop_goods");
$search_type['personal'] = Language::get("nc_microshop_personal");
$search_type['store'] = Language::get("nc_microshop_store");
Tpl::output("search_type", $search_type);
if (!empty($_SESSION['member_id']) || 0 < intval($_SESSION['member_id'])) {
self::get_member_avatar($_SESSION['member_id']);
}
if (!c("site_status")) {
halt(c("closed_reason"));
}
Tpl::output("html_title", Language::get("nc_microshop") . "-" . c("site_name"));
Tpl::output("seo_keywords", c("microshop_seo_keywords"));
Tpl::output("seo_description", c("microshop_seo_description"));
$this->queryCart();
}
开发者ID:noikiy,项目名称:ecmall,代码行数:31,代码来源:control.php
示例13: f
function f($a, $b)
{
echo number_format($a, 0, '', '') . '<br>' . number_format($b, 0, '', '') . '<br>';
$a = $a + $b;
$b = $a + $b;
f($a, $b);
}
开发者ID:monodesigns,项目名称:RandomSnippets,代码行数:7,代码来源:index.php
示例14: pr
function pr(...$args)
{
return f(function ($a) {
echo $a, "\n";
return $a;
}, ...$args);
}
开发者ID:nishimura,项目名称:monad-fizzbuzz,代码行数:7,代码来源:fizzbuzz.php
示例15: getSelectFilter
public function getSelectFilter($disableFilters = false)
{
$selectFilter = $this->category->getProductsFilter($this, false);
$selectFilter->merge($this->productFilter);
$cond = null;
$list = array();
// group filters by class
foreach ($this->filters as $filter) {
if ($disableFilters && !$filter instanceof SearchFilter) {
continue;
}
$id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : '';
$list[get_class($filter) . '_' . $id][] = $filter->getCondition();
$filter->defineJoin($selectFilter);
}
// convert filter group to OrChainCondition
foreach ($list as &$filterGroup) {
$filterGroup = new OrChainCondition($filterGroup);
}
if ($fCond = $selectFilter->getCondition()) {
$list[] = $fCond;
}
$selectFilter->setCondition(new AndChainCondition($list));
// all merged with and
$selectFilter->setOrder(f('Product.ID'), 'DESC');
ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter);
return $selectFilter;
}
开发者ID:saiber,项目名称:livecart,代码行数:28,代码来源:ProductFilter.php
示例16: parse_conf
private static function parse_conf(&$setting_config)
{
$nc_config = $GLOBALS['config'];
if (is_array($nc_config['db']['slave']) && !empty($nc_config['db']['slave'])) {
$dbslave = $nc_config['db']['slave'];
$sid = array_rand($dbslave);
$nc_config['db']['read'] = $dbslave[$sid];
} else {
$nc_config['db']['read'] = $nc_config['db'][1];
}
$nc_config['db']['write'] = $nc_config['db'][1];
$setting_config = $nc_config;
$setting = ($setting = f("setting")) ? $setting : h("setting", TRUE, "file");
if ($nc_config['thumb']['save_type'] == 1) {
$nc_config['thumb_url'] = SiteUrl;
} else {
if ($nc_config['thumb']['save_type'] == 2 && preg_match("/^http:\\/\\/[\\.\\-\\w]+/", $nc_config['thumb']['url'])) {
$nc_config['thumb_url'] = $nc_config['thumb']['url'];
} else {
if ($nc_config['thumb']['save_type'] == 3 && $setting['ftp_open']) {
$nc_config['thumb_url'] = $setting['ftp_access_url'];
} else {
$nc_config['thumb_url'] = SiteUrl;
}
}
}
$setting_config = array_merge_recursive($setting, $nc_config);
}
开发者ID:dw250100785,项目名称:shopnc,代码行数:28,代码来源:base.php
示例17: getExtraFilteringMapping
public function getExtraFilteringMapping()
{
if (count($this->extraFilteringMapping) == 0) {
$this->extraFilteringMapping = array('id' => array(self::AR_FIELD_HANDLE => f('User.ID'), self::AR_CONDITION => 'EqualsCond'), 'name' => array(self::AR_FIELD_HANDLE => new ARExpressionHandle("CONCAT(User.firstName,' ',User.lastName)"), self::AR_CONDITION => 'LikeCond'), 'created' => array(self::AR_FIELD_HANDLE => f('User.dateCreated'), self::AR_CONDITION => 'EqualsCond'), 'enabled' => array(self::AR_FIELD_HANDLE => f('User.isEnabled'), self::AR_CONDITION => 'EqualsCond'));
}
return $this->extraFilteringMapping;
}
开发者ID:saiber,项目名称:livecart,代码行数:7,代码来源:XmlUserApiReader.php
示例18: process
public function process()
{
if (!$this->response instanceof ActionResponse) {
return;
}
$products = $this->response->get('products');
$ids = array();
foreach ($products as $key => $product) {
$ids[$product['ID']] = !empty($product['parentID']) ? $product['parentID'] : $product['ID'];
}
if (!$ids) {
return;
}
$f = select(in(f('ProductImage.productID'), array_values($ids)), new LikeCond(f('ProductImage.title'), '%Virtual Mirror%'));
$hasMirror = array();
foreach (ActiveRecordModel::getRecordSetArray('ProductImage', $f) as $mirror) {
$hasMirror[$mirror['productID']] = true;
}
foreach ($ids as $realID => $parentID) {
if (!empty($hasMirror[$parentID])) {
$hasMirror[$realID] = true;
}
}
foreach ($products as $key => $product) {
if ($hasMirror[$product['ID']]) {
$products[$key]['hasMirror'] = true;
}
}
$this->response->set('hasMirror', $hasMirror);
$this->response->set('products', $products);
}
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:LoadMirror.php
示例19: home
public function home()
{
global $user;
$v = $this->__(w('alias filename ext'));
if (!f($v['alias']) || !f($v['filename'])) {
_fatal();
}
$sql = 'SELECT tree_id
FROM _tree
WHERE tree_alias = ?';
if (!($tree = _fieldrow(sql_filter($sql, $v['alias'])))) {
_fatal();
}
$sql = 'SELECT *
FROM _downloads
WHERE download_alias = ?
AND download_tree = ?';
if (!($download = _fieldrow(sql_filter($sql, $v['filename'], $tree['tree_id'])))) {
_fatal();
}
if ($download['download_login']) {
_login();
}
$sql = 'UPDATE _downloads SET download_count = download_count + 1
WHERE download_id = ?';
_sql(sql_filter($sql, $download['download_id']));
$filepath = LIB . 'fetch/' . _filename($download['download_id'], $download['download_extension']);
return;
}
开发者ID:nopticon,项目名称:noptc,代码行数:29,代码来源:_fetch.php
示例20: home
public function home()
{
$v = $this->__(array('category' => '', 'faq' => 0));
if (f($v['category'])) {
$sql = 'SELECT *
FROM _faq_categories
ORDER BY cat_order';
$category = _rowset($sql);
if (!count($category)) {
_fatal();
}
foreach ($category as $i => $row) {
if (!$i) {
_style('category');
}
_style('category.row', array('CAT_SUBJECT' => $row['cat_subject'], 'CAT_ALIAS' => _link('help', $row['help_alias'])));
}
}
if ($v['faq']) {
$sql = 'SELECT *
FROM _help_faq
WHERE faq_id = ?';
if (!($faq = _fieldrow(sql_filter($sql, $v['faq'])))) {
_fatal();
}
}
return;
}
开发者ID:nopticon,项目名称:mag,代码行数:28,代码来源:_help.php
注:本文中的f函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论