本文整理汇总了PHP中core_useragent类的典型用法代码示例。如果您正苦于以下问题:PHP core_useragent类的具体用法?PHP core_useragent怎么用?PHP core_useragent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了core_useragent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: icon
public function icon($icon)
{
global $OUTPUT;
if (core_useragent::supports_svg()) {
switch ($icon) {
case 'retweet':
return '<svg class="retweeticon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 75 72"><title>' . get_string('retweet', 'block_twitter') . '</title><path d="M70.676 36.644C70.166 35.636 69.13 35 68 35h-7V19c0-2.21-1.79-4-4-4H34c-2.21 0-4 1.79-4 4s1.79 4 4 4h18c.552 0 .998.446 1 .998V35h-7c-1.13 0-2.165.636-2.676 1.644-.51 1.01-.412 2.22.257 3.13l11 15C55.148 55.545 56.046 56 57 56s1.855-.455 2.42-1.226l11-15c.668-.912.767-2.122.256-3.13zM40 48H22c-.54 0-.97-.427-.992-.96L21 36h7c1.13 0 2.166-.636 2.677-1.644.51-1.01.412-2.22-.257-3.13l-11-15C18.854 15.455 17.956 15 17 15s-1.854.455-2.42 1.226l-11 15c-.667.912-.767 2.122-.255 3.13C3.835 35.365 4.87 36 6 36h7l.012 16.003c.002 2.208 1.792 3.997 4 3.997h22.99c2.208 0 4-1.79 4-4s-1.792-4-4-4z"/></svg>';
break;
case 'reply':
return '<svg class="replyicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 65 72"><title>' . get_string('reply', 'block_twitter') . '</title><path d="M41 31h-9V19c0-1.14-.647-2.183-1.668-2.688-1.022-.507-2.243-.39-3.15.302l-21 16C5.438 33.18 5 34.064 5 35s.437 1.82 1.182 2.387l21 16c.533.405 1.174.613 1.82.613.453 0 .908-.103 1.33-.312C31.354 53.183 32 52.14 32 51V39h9c5.514 0 10 4.486 10 10 0 2.21 1.79 4 4 4s4-1.79 4-4c0-9.925-8.075-18-18-18z"/></svg>';
break;
case 'like':
return '<svg class="likeicon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 72"><title>' . get_string('like', 'block_twitter') . '</title><path d="M38.723,12c-7.187,0-11.16,7.306-11.723,8.131C26.437,19.306,22.504,12,15.277,12C8.791,12,3.533,18.163,3.533,24.647 C3.533,39.964,21.891,55.907,27,56c5.109-0.093,23.467-16.036,23.467-31.353C50.467,18.163,45.209,12,38.723,12z"/></svg>';
break;
default:
return '';
break;
}
} else {
switch ($icon) {
case 'retweet':
return $OUTPUT->pix_icon('retweet', get_string('retweet', 'block_twitter'), 'block_twitter', array('class' => 'icon default')) . $OUTPUT->pix_icon('retweet_hover', get_string('retweet', 'block_twitter'), 'block_twitter', array('class' => 'icon hover'));
break;
case 'reply':
return $OUTPUT->pix_icon('reply', get_string('reply', 'block_twitter'), 'block_twitter', array('class' => 'icon default')) . $OUTPUT->pix_icon('reply_hover', get_string('reply', 'block_twitter'), 'block_twitter', array('class' => 'icon hover'));
break;
case 'like':
return $OUTPUT->pix_icon('like', get_string('like', 'block_twitter'), 'block_twitter', array('class' => 'icon default')) . $OUTPUT->pix_icon('like_hover', get_string('like', 'block_twitter'), 'block_twitter', array('class' => 'icon hover'));
break;
default:
return '';
break;
}
}
}
开发者ID:iamandrew,项目名称:moodle-block_twitter,代码行数:35,代码来源:renderer.php
示例2: is_legacy_browser
protected function is_legacy_browser()
{
// IE8 and IE9 are the only supported browsers that do not have spellchecker.
if (core_useragent::is_ie() and !core_useragent::check_ie_version(10)) {
return true;
}
// The rest of browsers supports spellchecking or is horribly outdated and we do not care...
return false;
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:9,代码来源:lib.php
示例3: get_content
public function get_content()
{
global $CFG;
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass();
$obj = new login_msg_lib();
$baseurl = $obj->get_base();
$welcomepage = $obj->get_welcome();
$jquerycdn = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js';
$databaseobj = core_useragent::instance();
$device = $databaseobj->get_device_type();
$jquery = <<<JQ
<script type="text/javascript" src="{$jquerycdn}"></script>
JQ;
if ($device == 'mobile' || $device == 'tablet') {
$jquery = '';
}
if (empty($welcomepage)) {
$popupjs = <<<HTML
{$jquery}
HTML;
} else {
$popupjs = <<<HTML
{$jquery}
<!--ThickBox 3-->
<script>
// Add popup fade?
function welcome() {
var win_width = 600;
var win_height = 400;
var left = screen.width / 2 - win_width/2;
var top = screen.height /2 - win_height/2;
var winoptions = "width="+win_width+", height="+win_height+", top="+top+", left="+left;
var popup = window.open("{$welcomepage}", "Welcome", winoptions );
}
setTimeout( function(){welcome();}, 3000);
</script>
HTML;
}
$this->content->text = <<<HTML
{$popupjs}
<script type="text/javascript" src="{$baseurl}js/thickbox/thickbox.js"></script>
<link rel="stylesheet" href="{$baseurl}js/thickbox/thickbox.css" type="text/css" media="screen" />
<!-- /ThickBox 3 -->
<div id="log_meg_small">
<!-- link to reopen message --!>
<p> <a href="{$welcomepage}" target="_blank">Welcome</a> </p>
<p> <a href="https://www.youtube.com/watch?v=GDk1YOP2f4A"
\ttarget="_blank">Why Durabuilt?</a> </p>
</div>
HTML;
$this->content->footer = '';
return $this->content;
}
开发者ID:sedgwickc,项目名称:moodle_login_message,代码行数:56,代码来源:block_login_message.php
示例4: setUp
/**
* Pre-test setup. Preserves $CFG.
*/
public function setUp()
{
parent::setUp();
// Reset $CFG and $SERVER.
$this->resetAfterTest();
// Consistent initial setup: all players disabled.
\core\plugininfo\media::set_enabled_plugins('videojs');
// Pretend to be using Firefox browser (must support ogg for tests to work).
core_useragent::instance(true, 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0 ');
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:13,代码来源:player_test.php
示例5: tab_embed_general
/**
* Returns general link or file embedding html.
* @param string $fullurl
* @param string $title
* @param string $clicktoopen
* @return string html
*/
function tab_embed_general($fullurl, $title, $clicktoopen, $mimetype)
{
global $CFG, $PAGE;
$iframe = false;
$forcelink = false;
// IE can not embed stuff properly if stored on different server.
// That is why we use iframe instead, unfortunately this tag does not validate.
// In xhtml strict mode.
if ($mimetype === 'text/html' and core_useragent::check_browser_version('MSIE', 5)) {
debugging("Detected IE", DEBUG_DEVELOPER);
if (preg_match('(^https?://[^/]*)', $fullurl, $matches)) {
debugging("Detected IE w/ http://", DEBUG_DEVELOPER);
// Make sure we aren't redirecting to a moodle page.
if (strpos($CFG->wwwroot, $matches[0]) !== 0) {
$forcelink = true;
} else {
// If it is a moodle then embed as iframe.
$iframe = true;
}
}
}
$idsuffix = md5($fullurl);
// We force the link because IE doesn't support embedding web pages.
if ($forcelink) {
$clicktoopen = get_string('embed_fail_msg_ie', 'tab') . "<a href='{$fullurl}' target='_blank'>" . get_string('embed_fail_link_text', 'tab') . '</a>';
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
{$clicktoopen}
</div>
EOT;
} else {
if ($iframe) {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<iframe id="resourceobject_{$idsuffix}" src="{$fullurl}">
{$clicktoopen}
</iframe>
</div>
EOT;
} else {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<object id="resourceobject_{$idsuffix}" data="{$fullurl}" type="{$mimetype}">
<param name="src" value="{$fullurl}" />
{$clicktoopen}
</object>
</div>
EOT;
}
}
$PAGE->requires->js_init_call('M.mod_tab.init_maximised_embed', array("resourceobject_{$idsuffix}"), true);
return $code;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:60,代码来源:locallib.php
示例6: can_use_drag_and_drop
protected function can_use_drag_and_drop()
{
global $USER;
$ie = core_useragent::check_browser_version('MSIE', 6.0);
$ff = core_useragent::check_browser_version('Gecko', 20051106);
$op = core_useragent::check_browser_version('Opera', 9.0);
$sa = core_useragent::check_browser_version('Safari', 412);
$ch = core_useragent::check_browser_version('Chrome', 6);
if (!$ie && !$ff && !$op && !$sa && !$ch or !empty($USER->screenreader)) {
return false;
}
return true;
}
开发者ID:jacac,项目名称:qtype_order,代码行数:13,代码来源:renderer.php
示例7: list_supported_urls
public function list_supported_urls(array $urls, array $options = array())
{
$extensions = $this->get_supported_extensions();
$result = array();
foreach ($urls as $url) {
$ext = core_media_manager::instance()->get_extension($url);
if (in_array('.' . $ext, $extensions) && core_useragent::supports_html5($ext)) {
// Unfortunately html5 video does not handle fallback properly.
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=10975
// That means we need to do browser detect and not use html5 on
// browsers which do not support the given type, otherwise users
// will not even see the fallback link.
$result[] = $url;
}
}
return $result;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:17,代码来源:plugin.php
示例8: ajaxenabled
/**
* Returns whether ajax is enabled/allowed or not.
* @param array $browsers optional list of alowed browsers, empty means use default list
* @return bool
*/
function ajaxenabled(array $browsers = null)
{
global $CFG;
if (!empty($browsers)) {
$valid = false;
foreach ($browsers as $brand => $version) {
if (core_useragent::check_browser_version($brand, $version)) {
$valid = true;
}
}
if (!$valid) {
return false;
}
}
if (!empty($CFG->enableajax)) {
return true;
} else {
return false;
}
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:25,代码来源:ajaxlib.php
示例9: test_svg_image_use
/**
* This function will test directives used to serve SVG images to make sure
* this are making the right decisions.
*/
public function test_svg_image_use()
{
global $CFG;
$this->resetAfterTest();
// The two required tests.
$this->assertTrue(file_exists($CFG->dirroot . '/pix/i/test.svg'));
$this->assertTrue(file_exists($CFG->dirroot . '/pix/i/test.png'));
$theme = theme_config::load(theme_config::DEFAULT_THEME);
// First up test the forced setting.
$imagefile = $theme->resolve_image_location('i/test', 'moodle', true);
$this->assertSame('test.svg', basename($imagefile));
$imagefile = $theme->resolve_image_location('i/test', 'moodle', false);
$this->assertSame('test.png', basename($imagefile));
// Now test the use of the svgicons config setting.
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$CFG->svgicons = true;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
$this->assertSame('test.svg', basename($imagefile));
$CFG->svgicons = false;
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
$this->assertSame('test.png', basename($imagefile));
unset($CFG->svgicons);
// Finally test a few user agents.
$useragents = array('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)' => false, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' => false, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)' => false, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)' => false, 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)' => false, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0; Touch; .NET4.0E; .NET4.0C; Tablet PC 2.0)' => true, 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0)' => true, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)' => true, 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Chrome/11.0.652.0 Safari/534.17' => true, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1' => true, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1' => true, 'Mozilla/5.0 (Windows NT 6.1; rv:1.9) Gecko/20100101 Firefox/4.0' => true, 'Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0.1' => true, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1' => true, 'Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.10.289 Version/12.02' => false, 'Mozilla/5.0 (Linux; U; Android 0.5; en-us) AppleWebKit/522+ (KHTML, like Gecko) Safari/419.3' => false, 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => false, 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13' => true, 'Mozilla/5.0 (Linux; Android 4.3; it-it; SAMSUNG GT-I9505/I9505XXUEMJ7 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36' => true);
foreach ($useragents as $agent => $expected) {
core_useragent::instance(true, $agent);
// We need to clone the theme as usesvg property is calculated only once.
$testtheme = clone $theme;
$imagefile = $testtheme->resolve_image_location('i/test', 'moodle', null);
if ($expected) {
$this->assertSame('test.svg', basename($imagefile), 'Incorrect image returned for user agent `' . $agent . '`');
} else {
$this->assertSame('test.png', basename($imagefile), 'Incorrect image returned for user agent `' . $agent . '`');
}
}
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:43,代码来源:theme_config_test.php
示例10: redirect
/**
* Redirects the user to another page, after printing a notice.
*
* This function calls the OUTPUT redirect method, echo's the output and then dies to ensure nothing else happens.
*
* <strong>Good practice:</strong> You should call this method before starting page
* output by using any of the OUTPUT methods.
*
* @param moodle_url|string $url A moodle_url to redirect to. Strings are not to be trusted!
* @param string $message The message to display to the user
* @param int $delay The delay before redirecting
* @throws moodle_exception
*/
function redirect($url, $message = '', $delay = -1)
{
global $OUTPUT, $PAGE, $CFG;
if (CLI_SCRIPT or AJAX_SCRIPT) {
// This is wrong - developers should not use redirect in these scripts but it should not be very likely.
throw new moodle_exception('redirecterrordetected', 'error');
}
// Prevent debug errors - make sure context is properly initialised.
if ($PAGE) {
$PAGE->set_context(null);
$PAGE->set_pagelayout('redirect');
// No header and footer needed.
$PAGE->set_title(get_string('pageshouldredirect', 'moodle'));
}
if ($url instanceof moodle_url) {
$url = $url->out(false);
}
$debugdisableredirect = false;
do {
if (defined('DEBUGGING_PRINTED')) {
// Some debugging already printed, no need to look more.
$debugdisableredirect = true;
break;
}
if (core_useragent::is_msword()) {
// Clicking a URL from MS Word sends a request to the server without cookies. If that
// causes a redirect Word will open a browser pointing the new URL. If not, the URL that
// was clicked is opened. Because the request from Word is without cookies, it almost
// always results in a redirect to the login page, even if the user is logged in in their
// browser. This is not what we want, so prevent the redirect for requests from Word.
$debugdisableredirect = true;
break;
}
if (empty($CFG->debugdisplay) or empty($CFG->debug)) {
// No errors should be displayed.
break;
}
if (!function_exists('error_get_last') or !($lasterror = error_get_last())) {
break;
}
if (!($lasterror['type'] & $CFG->debug)) {
// Last error not interesting.
break;
}
// Watch out here, @hidden() errors are returned from error_get_last() too.
if (headers_sent()) {
// We already started printing something - that means errors likely printed.
$debugdisableredirect = true;
break;
}
if (ob_get_level() and ob_get_contents()) {
// There is something waiting to be printed, hopefully it is the errors,
// but it might be some error hidden by @ too - such as the timezone mess from setup.php.
$debugdisableredirect = true;
break;
}
} while (false);
// Technically, HTTP/1.1 requires Location: header to contain the absolute path.
// (In practice browsers accept relative paths - but still, might as well do it properly.)
// This code turns relative into absolute.
if (!preg_match('|^[a-z]+:|', $url)) {
// Get host name http://www.wherever.com.
$hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot);
if (preg_match('|^/|', $url)) {
// URLs beginning with / are relative to web server root so we just add them in.
$url = $hostpart . $url;
} else {
// URLs not beginning with / are relative to path of current script, so add that on.
$url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url;
}
// Replace all ..s.
while (true) {
$newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url);
if ($newurl == $url) {
break;
}
$url = $newurl;
}
}
// Sanitise url - we can not rely on moodle_url or our URL cleaning
// because they do not support all valid external URLs.
$url = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $url);
$url = str_replace('"', '%22', $url);
$encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url);
$encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />', FORMAT_HTML));
$url = str_replace('&', '&', $encodedurl);
if (!empty($message)) {
//.........这里部分代码省略.........
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:101,代码来源:weblib.php
示例11: send_stored_file
/**
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
*
* The $options parameter supports the following keys:
* (string|null) preview - send the preview of the file (e.g. "thumb" for a thumbnail)
* (string|null) filename - overrides the implicit filename
* (bool) dontdie - return control to caller afterwards. this is not recommended and only used for cleanup tasks.
* if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel,
* you must detect this case when control is returned using connection_aborted. Please not that session is closed
* and should not be reopened.
*
* @category files
* @param stored_file $stored_file local file object
* @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
* @param array $options additional options affecting the file serving
* @return null script execution stopped unless $options['dontdie'] is true
*/
function send_stored_file($stored_file, $lifetime = null, $filter = 0, $forcedownload = false, array $options = array())
{
global $CFG, $COURSE;
if (empty($options['filename'])) {
$filename = null;
} else {
$filename = $options['filename'];
}
if (empty($options['dontdie'])) {
$dontdie = false;
} else {
$dontdie = true;
}
if ($lifetime === 'default' or is_null($lifetime)) {
$lifetime = $CFG->filelifetime;
}
if (!empty($options['preview'])) {
// replace the file with its preview
$fs = get_file_storage();
$preview_file = $fs->get_file_preview($stored_file, $options['preview']);
if (!$preview_file) {
// unable to create a preview of the file, send its default mime icon instead
if ($options['preview'] === 'tinyicon') {
$size = 24;
} else {
if ($options['preview'] === 'thumb') {
$size = 90;
} else {
$size = 256;
}
}
$fileicon = file_file_icon($stored_file, $size);
send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png');
} else {
// preview images have fixed cache lifetime and they ignore forced download
// (they are generated by GD and therefore they are considered reasonably safe).
$stored_file = $preview_file;
$lifetime = DAYSECS;
$filter = 0;
$forcedownload = false;
}
}
// handle external resource
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
die;
}
if (!$stored_file or $stored_file->is_directory()) {
// nothing to serve
if ($dontdie) {
return;
}
die;
}
if ($dontdie) {
ignore_user_abort(true);
}
\core\session\manager::write_close();
// Unlock session during file serving.
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
// only Firefox saves all files locally before opening when content-disposition: attachment stated
$filename = is_null($filename) ? $stored_file->get_filename() : $filename;
$isFF = core_useragent::is_firefox();
// only FF properly tested
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
if (core_useragent::is_ie()) {
$filename = rawurlencode($filename);
}
if ($forcedownload) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
header('Content-Disposition: inline; filename="' . $filename . '"');
}
if ($lifetime > 0) {
$private = '';
if (isloggedin() and !isguestuser()) {
$private = ' private,';
}
//.........这里部分代码省略.........
开发者ID:ruddj,项目名称:moodle,代码行数:101,代码来源:filelib.php
示例12: loginpage_hook
/**
* Will get called before the login page is shownr. Ff NTLM SSO
* is enabled, and the user is in the right network, we'll redirect
* to the magic NTLM page for SSO...
*
*/
function loginpage_hook()
{
global $CFG, $SESSION;
// HTTPS is potentially required
//httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php
if (($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST' && get_local_referer() != strip_querystring(qualified_me())) && !empty($this->config->ntlmsso_enabled) && !empty($this->config->ntlmsso_subnet) && empty($_GET['authldap_skipntlmsso']) && (isguestuser() || !isloggedin()) && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) {
// First, let's remember where we were trying to get to before we got here
if (empty($SESSION->wantsurl)) {
$SESSION->wantsurl = null;
$referer = get_local_referer(false);
if ($referer && $referer != $CFG->wwwroot && $referer != $CFG->wwwroot . '/' && $referer != $CFG->httpswwwroot . '/login/' && $referer != $CFG->httpswwwroot . '/login/index.php') {
$SESSION->wantsurl = $referer;
}
}
// Now start the whole NTLM machinery.
if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESATTEMPT || $this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) {
if (core_useragent::is_ie()) {
$sesskey = sesskey();
redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey=' . $sesskey);
} else {
if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) {
redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1');
}
}
}
redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_attempt.php');
}
// No NTLM SSO, Use the normal login page instead.
// If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login
// page insists on redirecting us to that page after user validation. If
// we clicked on the redirect link at the ntlmsso_finish.php page (instead
// of waiting for the redirection to happen) then we have a 'Referer:' header
// we don't want to use at all. As we can't get rid of it, just point
// $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there).
if (empty($SESSION->wantsurl) && get_local_referer() == $CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php') {
$SESSION->wantsurl = $CFG->wwwroot;
}
}
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:44,代码来源:auth.php
示例13: is_web_crawler
/**
* Checks if current user is a web crawler.
*
* This list can not be made complete, this is not a security
* restriction, we make the list only to help these sites
* especially when automatic guest login is disabled.
*
* If admin needs security they should enable forcelogin
* and disable guest access!!
*
* @return bool
* @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
*/
function is_web_crawler()
{
debugging('is_web_crawler() has been deprecated, please use core_useragent::is_web_crawler() instead.', DEBUG_DEVELOPER);
return core_useragent::is_web_crawler();
}
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:deprecatedlib.php
示例14:
<!-- End Analytics -->
</head>
<body <?php
echo $OUTPUT->body_attributes($bodyclasses);
?>
>
<?php
echo $OUTPUT->standard_top_of_body_html();
?>
<?php
// If on desktop, then hide the header/footer.
$hideclass = '';
$devicetype = core_useragent::get_device_type();
if ($devicetype !== 'mobile' and $devicetype !== 'tablet') {
// We can not use the Bootstrap responsive css classes because popups are phone sized on desktop.
$hideclass = 'hide';
}
?>
<header role="banner" class="navbar navbar-fixed-top moodle-has-zindex <?php
echo $hideclass;
?>
">
<nav role="navigation" class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="<?php
echo $CFG->wwwroot;
?>
开发者ID:lucisgit,项目名称:moodle-theme_essential,代码行数:31,代码来源:popup.php
示例15: get_string
}
}
echo '</select> <input type="submit" value="' . get_string('showsession', 'realtimequiz') . '" /></form></center>';
if ($CFG->version < 2013111800) {
$tickimg = '<img src="' . $OUTPUT->pix_url('i/tick_green_big') . '" alt="' . get_string('tick', 'realtimequiz') . '" />';
$crossimg = '<img src="' . $OUTPUT->pix_url('i/cross_red_big') . '" alt="' . get_string('cross', 'realtimequiz') . '" />';
} else {
$tickimg = '<img src="' . $OUTPUT->pix_url('i/grade_correct') . '" alt="' . get_string('tick', 'realtimequiz') . '" />';
$crossimg = '<img src="' . $OUTPUT->pix_url('i/grade_incorrect') . '" alt="' . get_string('cross', 'realtimequiz') . '" />';
}
if ($questionid == 0) {
// Show all of the questions
if ($CFG->version < 2013111800) {
$isff = check_browser_version('Gecko');
} else {
$isff = core_useragent::check_browser_version('Gecko');
}
if ($isff) {
$blankcolspan = 'colspan="999" ';
} else {
$blankcolspan = '';
}
$questions = $DB->get_records('realtimequiz_question', array('quizid' => $realtimequiz->id), 'questionnum');
$linkurl = new moodle_url('/mod/realtimequiz/responses.php', array('id' => $cm->id, 'showsession' => $showsession));
if ($showusers) {
$linkurl->param('showusers', 1);
if ($CFG->version < 2013111800) {
$usernames = 'u.firstname, u.lastname';
} else {
$usernames = get_all_user_name_fields(true, 'u');
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:31,代码来源:responses.php
示例16: define
define('NO_MOODLE_COOKIES', false);
}
}
}
}
}
// Start session and prepare global $SESSION, $USER.
if (empty($CFG->sessiontimeout)) {
$CFG->sessiontimeout = 7200;
}
\core\session\manager::start();
// Set default content type and encoding, developers are still required to use
// echo $OUTPUT->header() everywhere, anything that gets set later should override these headers.
// This is intended to mitigate some security problems.
if (AJAX_SCRIPT) {
if (!core_useragent::supports_json_contenttype()) {
// Some bloody old IE.
@header('Content-type: text/plain; charset=utf-8');
@header('X-Content-Type-Options: nosniff');
} else {
if (!empty($_FILES)) {
// Some ajax code may have problems with json and file uploads.
@header('Content-type: text/plain; charset=utf-8');
} else {
@header('Content-type: application/json; charset=utf-8');
}
}
} else {
if (!CLI_SCRIPT) {
@header('Content-type: text/html; charset=utf-8');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:setup.php
示例17: instance
/**
* Get an instance of the user agent object.
*
* @param bool $reload If set to true the user agent will be reset and all ascertations remade.
* @param string $forceuseragent The string to force as the user agent, don't use unless absolutely unavoidable.
* @return core_useragent
*/
public static function instance($reload = false, $forceuseragent = null)
{
if (!self::$instance || $reload) {
self::$instance = new core_useragent($forceuseragent);
}
return self::$instance;
}
开发者ID:nitinnagaraja,项目名称:moodle,代码行数:14,代码来源:useragent.php
示例18: pretend_to_be_firefox
/**
* Sets user agent to Firefox.
*/
private function pretend_to_be_firefox()
{
// Pretend to be using Firefox browser (must support ogg for tests to work).
core_useragent::instance(true, 'Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0');
}
开发者ID:educakanchay,项目名称:campus,代码行数:8,代码来源:medialib_test.php
示例19: theme_essential_ie_properties
/**
* States if the browser is IE by returning properties, otherwise false.
*/
public function theme_essential_ie_properties()
{
$properties = core_useragent::check_ie_properties();
// In /lib/classes/useragent.php.
if (!is_array($properties)) {
return false;
} else {
return $properties;
}
}
开发者ID:blionut,项目名称:elearning,代码行数:13,代码来源:core_renderer_maintenance.php
示例20: close
/**
* Close the Moodle Workbook
*/
public function close()
{
global $CFG;
foreach ($this->objPHPExcel->getAllSheets() as $sheet) {
$sheet->setSelectedCells('A1');
}
$this->objPHPExcel->setActiveSheetIndex(0);
$filename = preg_replace('/\\.xlsx?$/i', '', $this->filename);
$mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
$filename = $filename . '.xlsx';
if (is_https()) {
// HTTPS sites - watch out for IE! KB812935 and KB316431.
header('Cache-Control: max-age=10');
header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
header('Pragma: ');
} else {
//normal http - prevent caching at all cost
header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
header('Pragma: no-cache');
}
if (core_useragent::is_ie()) {
$filename = rawurlencode($filename);
} else {
$filename = s($filename);
}
header('Content-Type: ' . $mimetype);
header('Content-Disposition: attachment;filename="' . $filename . '"');
$objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->type);
$objWriter->save('php://output');
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:34,代码来源:excellib.class.php
注:本文中的core_useragent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论