本文整理汇总了PHP中Surfer::get_capability方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::get_capability方法的具体用法?PHP Surfer::get_capability怎么用?PHP Surfer::get_capability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::get_capability方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: may_upload
/**
* check upload capability
*
* This function checks surfer overall capability against actual
* server configuration (PHP parameter 'file_uploads') and also
* against the parameter [code]users_without_uploads[/code]
* set in the configuration panel for users.
*
* @see users/configure.php
*
* @param string actual capability, for possible impersonation (see services/blog.php)
* @return TRUE if the surfer is allowed to upload files, FALSE otherwise
*/
public static function may_upload($capability = NULL)
{
global $context;
// sanity check
if (!$capability) {
$capability = Surfer::get_capability();
}
// server limitation
if (!ini_get('file_uploads')) {
return FALSE;
}
// administrative permission has not been set
if (!isset($context['users_without_uploads'])) {
return TRUE;
}
// even associates may not upload files
if ($context['users_without_uploads'] == 'Y') {
return FALSE;
}
// only associates may upload files
if ($context['users_without_uploads'] == 'R' && !Surfer::is_associate() && $capability != 'A') {
return FALSE;
}
// surfers are encouraged to share files and images
return TRUE;
}
示例2: put
/**
* put something into the cache
*
* You can store an array or another kind of structured object, but after
* serialization.
*
* The default caching period is 20 minutes (actually, 20m*60s = 1,200s)
*
* @param string the id of this item
* @param string the content to store
* @param string the topic related to this item
* @param int the maximum time before expiration, in seconds
*/
public static function put($id, &$text, $topic = 'global', $duration = 1200, $f_capa = true, $f_lang = true, $f_gmt_off = true)
{
global $context;
// maybe we don't have to cache
if (isset($context['without_cache']) && $context['without_cache'] == 'Y') {
return;
}
// cache has been poisoned
if (isset($context['cache_has_been_poisoned']) && $context['cache_has_been_poisoned']) {
return;
}
// the sql back-end may be not available during software updates or on NO_MODEL_PRELOAD
if (!is_callable(array('SQL', 'query'))) {
return;
}
// cached content depends on surfer capability
if ($f_capa) {
$id .= '/' . Surfer::get_capability();
}
// cached content depends on selected language
if ($f_lang) {
$id .= '/' . $context['language'];
}
// cached content depends on time offset
if ($f_gmt_off) {
$id .= '/' . Surfer::get_gmt_offset();
}
// don't cache more than expected
$expiry = gmstrftime('%Y-%m-%d %H:%M:%S', time() + $duration);
// cache also empty content
if (!$text) {
$text = ' ';
}
// update the database; do not report on error
$query = "REPLACE INTO " . SQL::table_name('cache') . " SET" . " id='" . SQL::escape($id) . "'," . " text='" . SQL::escape($text) . "'," . " topic='" . SQL::escape($topic) . "'," . " expiry_date='" . $expiry . "'," . " edit_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'";
SQL::query($query, TRUE);
}