本文整理汇总了PHP中check_browser_version函数的典型用法代码示例。如果您正苦于以下问题:PHP check_browser_version函数的具体用法?PHP check_browser_version怎么用?PHP check_browser_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_browser_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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, $USER;
if (!empty($browsers)) {
$valid = false;
foreach ($browsers as $brand => $version) {
if (check_browser_version($brand, $version)) {
$valid = true;
}
}
if (!$valid) {
return false;
}
}
$ie = check_browser_version('MSIE', 6.0);
$ff = check_browser_version('Gecko', 20051106);
$op = check_browser_version('Opera', 9.0);
$sa = check_browser_version('Safari', 412);
if (!$ie && !$ff && !$op && !$sa) {
/** @see http://en.wikipedia.org/wiki/User_agent */
// Gecko build 20051107 is what is in Firefox 1.5.
// We still have issues with AJAX in other browsers.
return false;
}
if (!empty($CFG->enableajax) && (!empty($USER->ajax) || !isloggedin())) {
return true;
} else {
return false;
}
}
示例2: is_legacy_browser
protected function is_legacy_browser()
{
// IE8 and IE9 are the only supported browsers that do not have spellchecker.
if (check_browser_version('MSIE', 5) and !check_browser_version('MSIE', 10)) {
return true;
}
// The rest of browsers supports spellchecking or is horribly outdated and we do not care...
return false;
}
示例3: can_use_drag_and_drop
protected function can_use_drag_and_drop()
{
global $USER;
$ie = check_browser_version('MSIE', 6.0);
$ff = check_browser_version('Gecko', 20051106);
$op = check_browser_version('Opera', 9.0);
$sa = check_browser_version('Safari', 412);
$ch = check_browser_version('Chrome', 6);
if (!$ie && !$ff && !$op && !$sa && !$ch or !empty($USER->screenreader)) {
return false;
}
return true;
}
示例4: supported_by_browser
public function supported_by_browser() {
if (check_browser_version('MSIE', 6)) {
return true;
}
if (check_browser_version('Gecko', 20030516)) {
return true;
}
if (check_browser_version('Safari', 412)) {
return true;
}
if (check_browser_version('Chrome', 6)) {
return true;
}
if (check_browser_version('Opera', 9)) {
return true;
}
return false;
}
示例5: supported_by_browser
public function supported_by_browser()
{
if (check_browser_version('MSIE', 5.5)) {
return true;
} else {
if (check_browser_version('Gecko', 20030516)) {
return true;
} else {
if (check_browser_version('Safari', 3)) {
return true;
} else {
if (check_browser_version('Opera', 9)) {
return true;
}
}
}
}
return true;
}
示例6: test_check_browser_version
/**
* Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version
* works as expected.
*/
function test_check_browser_version()
{
global $CFG;
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Safari']['2.0']['Mac OS X'];
$this->assertTrue(check_browser_version('Safari', '312'));
$this->assertFalse(check_browser_version('Safari', '500'));
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Opera']['9.0']['Windows XP'];
$this->assertTrue(check_browser_version('Opera', '8.0'));
$this->assertFalse(check_browser_version('Opera', '10.0'));
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['MSIE']['6.0']['Windows XP SP2'];
$this->assertTrue(check_browser_version('MSIE', '5.0'));
$this->assertFalse(check_browser_version('MSIE', '7.0'));
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['2.0']['Windows XP'];
$this->assertTrue(check_browser_version('Firefox', '1.5'));
$this->assertFalse(check_browser_version('Firefox', '3.0'));
}
示例7: resourcelib_embed_general
/**
* Returns general link or file embedding html.
* @param string $fullurl
* @param string $title
* @param string $clicktoopen
* @return string html
*/
function resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype)
{
global $CFG, $PAGE;
if ($fullurl instanceof moodle_url) {
$fullurl = $fullurl->out();
}
$iframe = 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 check_browser_version('MSIE', 5)) {
if (preg_match('(^https?://[^/]*)', $fullurl, $matches)) {
if (strpos($CFG->wwwroot, $matches[0]) !== 0) {
$iframe = true;
}
}
}
if ($iframe) {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<iframe id="resourceobject" src="{$fullurl}">
{$clicktoopen}
</iframe>
</div>
EOT;
} else {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<object id="resourceobject" data="{$fullurl}" type="{$mimetype}" width="800" height="600">
<param name="src" value="{$fullurl}" />
{$clicktoopen}
</object>
</div>
EOT;
}
// the size is hardcoded in the boject obove intentionally because it is adjusted by the following function on-the-fly
$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
return $code;
}
示例8: header
$USER->editing = 1;
$bodyclasses[] = 'krystle_persistent_edit';
}
if (!empty($PAGE->theme->settings->footnote)) {
$footnote = $PAGE->theme->settings->footnote;
} else {
$footnote = '<!-- There was no custom footnote set -->';
}
// Tell IE to use the latest engine (no Compatibility mode), if the user is using IE.
$ie = false;
if (class_exists('core_useragent')) {
if (core_useragent::check_ie_version()) {
$ie = true;
}
} else {
if (check_browser_version("MSIE", "0")) {
$ie = true;
}
}
if ($ie) {
header('X-UA-Compatible: IE=edge');
}
//Settings for responsive design taken from Zebra theme
$userespond = $PAGE->theme->settings->userespond;
//Check the theme settings to see if respond.js should be called
$usecf = $PAGE->theme->settings->usecf;
//Check the theme settings to see if Chrome Frame should be called
$cfmaxversion = $PAGE->theme->settings->cfmaxversion;
//Check the theme settings to see which versions of IE get prompted for Chrome Frame
$ieversion = strpos($PAGE->bodyclasses, $cfmaxversion);
$usingie = strpos($PAGE->bodyclasses, 'ie ie');
示例9: send_stored_file
/**
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
*
* @global object
* @global object
* @global object
* @param object $stored_file local file object
* @param int $lifetime Number of seconds before the file should expire from caches (default 24 hours)
* @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 string $filename Override filename
* @param 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.
* @return void no return or void, script execution stopped unless $dontdie is true
*/
function send_stored_file($stored_file, $lifetime = 86400, $filter = 0, $forcedownload = false, $filename = null, $dontdie = false)
{
global $CFG, $COURSE, $SESSION;
if (!$stored_file or $stored_file->is_directory()) {
// nothing to serve
if ($dontdie) {
return;
}
die;
}
if ($dontdie) {
ignore_user_abort(true);
}
session_get_instance()->write_close();
// unlock session during fileserving
// 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 = check_browser_version('Firefox', '1.5');
// only FF > 1.5 properly tested
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
$lastmodified = $stored_file->get_timemodified();
$filesize = $stored_file->get_filesize();
//try to disable automatic sid rewrite in cookieless mode
@ini_set("session.use_trans_sid", "false");
if ($lifetime > 0 && !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
// get unixtime of request header; clip extra junk off first
$since = strtotime(preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]));
if ($since && $since >= $lastmodified) {
header('HTTP/1.1 304 Not Modified');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
header('Cache-Control: max-age=' . $lifetime);
header('Content-Type: ' . $mimetype);
if ($dontdie) {
return;
}
die;
}
}
//do not put '@' before the next header to detect incorrect moodle configurations,
//error should be better than "weird" empty lines for admins/users
//TODO: should we remove all those @ before the header()? Are all of the values supported on all servers?
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastmodified) . ' GMT');
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
if (check_browser_version('MSIE')) {
$filename = rawurlencode($filename);
}
if ($forcedownload) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
header('Content-Disposition: inline; filename="' . $filename . '"');
}
if ($lifetime > 0) {
header('Cache-Control: max-age=' . $lifetime);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
header('Pragma: ');
if (empty($CFG->disablebyteserving) && $mimetype != 'text/plain' && $mimetype != 'text/html') {
header('Accept-Ranges: bytes');
if (!empty($_SERVER['HTTP_RANGE']) && strpos($_SERVER['HTTP_RANGE'], 'bytes=') !== FALSE) {
// byteserving stuff - for acrobat reader and download accelerators
// see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
// inspired by: http://www.coneural.org/florian/papers/04_byteserving.php
$ranges = false;
if (preg_match_all('/(\\d*)-(\\d*)/', $_SERVER['HTTP_RANGE'], $ranges, PREG_SET_ORDER)) {
foreach ($ranges as $key => $value) {
if ($ranges[$key][1] == '') {
//suffix case
$ranges[$key][1] = $filesize - $ranges[$key][2];
$ranges[$key][2] = $filesize - 1;
} else {
if ($ranges[$key][2] == '' || $ranges[$key][2] > $filesize - 1) {
//fix range length
$ranges[$key][2] = $filesize - 1;
}
}
if ($ranges[$key][2] != '' && $ranges[$key][2] < $ranges[$key][1]) {
//invalid byte-range ==> ignore header
$ranges = false;
break;
}
//prepare multipart header
//.........这里部分代码省略.........
示例10: can_use_html_editor
/**
* Determines if the HTML editor is enabled.
*
* This depends on site and user
* settings, as well as the current browser being used.
*
* @return string|false Returns false if editor is not being used, otherwise
* returns 'MSIE' or 'Gecko'.
*/
function can_use_html_editor()
{
global $USER, $CFG;
if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) {
if (check_browser_version('MSIE', 5.5)) {
return 'MSIE';
} else {
if (check_browser_version('Gecko', 20030516)) {
return 'Gecko';
}
}
}
return false;
}
示例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 (default 24 hours)
* @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 = 86400, $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 (!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);
}
session_get_instance()->write_close();
// unlock session during fileserving
// 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 = check_browser_version('Firefox', '1.5');
// only FF > 1.5 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 (check_browser_version('MSIE')) {
$filename = rawurlencode($filename);
}
if ($forcedownload) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
header('Content-Disposition: inline; filename="' . $filename . '"');
}
if ($lifetime > 0) {
header('Cache-Control: max-age=' . $lifetime);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
header('Pragma: ');
} else {
// Do not cache files in proxies and browsers
if (strpos($CFG->wwwroot, 'https://') === 0) {
//https sites - watch out for IE! KB812935 and KB316431
//.........这里部分代码省略.........
示例12: equella_embed_general
/**
* Returns general link or file embedding html.
*
* @param string $fullurl
* @param string $clicktoopen
* @param string $mimetype
* @return string html
*/
function equella_embed_general($equella)
{
global $CFG, $PAGE;
if ($CFG->equella_enable_lti) {
$launchurl = new moodle_url('/mod/equella/ltilaunch.php', array('cmid' => $equella->cmid, 'action' => 'view'));
$url = $launchurl->out();
} else {
$url = equella_appendtoken($equella->url);
}
$link = html_writer::tag('a', $equella->name, array('href' => str_replace('&', '&', $url)));
$clicktoopen = get_string('clicktoopen', 'equella', $link);
$iframe = false;
// IE can not embed stuff properly, that is why we use iframe instead.
// Unfortunately this tag does not validate in xhtml strict mode,
// but in any case it is undeprecated in HTML 5 - we will use it everywhere soon!
$ie5 = false;
$vendor = 'MSIE';
$version = 5;
if (method_exists('core_useragent', 'check_browser_version')) {
$ie5 = core_useragent::check_browser_version($vendor, $version);
} else {
$ie5 = check_browser_version($vendor, $version);
}
if ($ie5 || $CFG->equella_enable_lti) {
$iframe = true;
}
if ($iframe) {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<iframe id="resourceobject" src="{$url}">
{$clicktoopen}
</iframe>
</div>
EOT;
} else {
$param = '<param name="src" value="' . $url . '" />';
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<object id="resourceobject" data="{$url}" width="800" height="600">
{$param}
{$clicktoopen}
</object>
</div>
EOT;
}
// the size is hardcoded in the object above intentionally because it is adjusted by the following function on-the-fly
$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
return $code;
}
示例13: resourcelib_embed_general
/**
* Returns general link or file embedding html.
* @param string $fullurl
* @param string $title
* @param string $clicktoopen
* @param string $mimetype
* @return string html
*/
function resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype)
{
global $CFG, $PAGE;
if ($fullurl instanceof moodle_url) {
$fullurl = $fullurl->out();
}
$iframe = false;
$param = '<param name="src" value="' . $fullurl . '" />';
// IE can not embed stuff properly, that is why we use iframe instead.
// Unfortunately this tag does not validate in xhtml strict mode,
// but in any case it is undeprecated in HTML 5 - we will use it everywhere soon!
if ($mimetype === 'text/html' and check_browser_version('MSIE', 5)) {
$iframe = true;
}
if ($iframe) {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<iframe id="resourceobject" src="{$fullurl}">
{$clicktoopen}
</iframe>
</div>
EOT;
} else {
$code = <<<EOT
<div class="resourcecontent resourcegeneral">
<object id="resourceobject" data="{$fullurl}" type="{$mimetype}" width="800" height="600">
{$param}
{$clicktoopen}
</object>
</div>
EOT;
}
// the size is hardcoded in the boject obove intentionally because it is adjusted by the following function on-the-fly
$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
return $code;
}
示例14: is_fixed_students
/**
* Returns whether or not to display fixed students column.
* Includes a browser check, because IE6 doesn't support the scrollbar.
*
* @return bool
*/
public function is_fixed_students()
{
global $USER, $CFG;
return $CFG->grade_report_fixedstudents && (check_browser_version('MSIE', '7.0') || check_browser_version('Firefox', '2.0') || check_browser_version('Gecko', '2006010100') || check_browser_version('Camino', '1.0') || check_browser_version('Opera', '6.0') || check_browser_version('Chrome', '6') || check_browser_version('Safari', '300'));
}
示例15: get_dashboard
/**
* Get the user dashboard report view.
*
* @uses $CFG, $CURMAN
* @param none
* @return string The HTML for the dashboard report.
*/
function get_dashboard()
{
global $CFG, $CURMAN;
require_once CURMAN_DIRLOCATION . '/lib/curriculumstudent.class.php';
//needed for AJAX calls
require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_connection', "{$CFG->wwwroot}/curriculum/js/util.js", "{$CFG->wwwroot}/curriculum/js/dashboard.js"), true);
if (optional_param('tab', '', PARAM_CLEAN) == 'archivedlp') {
$tab = 'archivedlp';
$show_archived = 1;
} else {
$tab = 'currentlp';
$show_archived = 0;
}
$content = '';
$archive_var = '_elis_curriculum_archive';
$totalcourses = 0;
$totalcurricula = 0;
$completecourses = 0;
$curriculas = array();
$classids = array();
$sql = 'SELECT curstu.id, curstu.curriculumid as curid, cur.name as name
FROM ' . $CURMAN->db->prefix_table(CURASSTABLE) . ' curstu
JOIN ' . $CURMAN->db->prefix_table(CURTABLE) . ' cur
ON cur.id = curstu.curriculumid
WHERE curstu.userid = \'' . $this->id . '\' ORDER BY cur.priority ASC, cur.name ASC';
if ($usercurs = get_records_sql($sql)) {
foreach ($usercurs as $usercur) {
// Check if this curricula is set as archived and whether we want to display it
$crlm_context = get_context_instance(context_level_base::get_custom_context_level('curriculum', 'block_curr_admin'), $usercur->curid);
$data_array = field_data::get_for_context_and_field($crlm_context, $archive_var);
$crlm_archived = 0;
if (is_array($data_array) && !empty($data_array)) {
foreach ($data_array as $data_key => $data_obj) {
$crlm_archived = !empty($data_obj->data) ? 1 : 0;
}
}
if ($show_archived == $crlm_archived) {
$totalcurricula++;
$curriculas[$usercur->curid]['id'] = $usercur->curid;
$curriculas[$usercur->curid]['name'] = $usercur->name;
$data = array();
if ($courses = curriculumcourse_get_listing($usercur->curid, 'curcrs.position, crs.name', 'ASC')) {
foreach ($courses as $course) {
$totalcourses++;
$course_obj = new course($course->courseid);
$coursedesc = $course_obj->syllabus;
if ($cdata = student_get_class_from_course($course->courseid, $this->id)) {
foreach ($cdata as $classdata) {
if (!in_array($classdata->id, $classids)) {
$classids[] = $classdata->id;
}
if ($classdata->completestatusid == STUSTATUS_PASSED) {
$completecourses++;
}
if ($mdlcrs = moodle_get_course($classdata->id)) {
$coursename = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $mdlcrs . '">' . $course->coursename . '</a>';
} else {
$coursename = $course->coursename;
}
$data[] = array($coursename, $coursedesc, $classdata->grade, $classdata->completestatusid == STUSTATUS_PASSED ? get_string('yes') : get_string('no'), $classdata->completestatusid == STUSTATUS_PASSED && !empty($classdata->completetime) ? date('M j, Y', $classdata->completetime) : get_string('na', 'block_curr_admin'));
}
} else {
$data[] = array($course->coursename, $coursedesc, 0, get_string('no'), get_string('na', 'block_curr_admin'));
}
}
}
$curriculas[$usercur->curid]['data'] = $data;
} else {
// Keep note of the classid's regardless if set archived or not for later use in determining non-curricula courses
if ($courses = curriculumcourse_get_listing($usercur->curid, 'curcrs.position, crs.name', 'ASC')) {
foreach ($courses as $course) {
if ($cdata = student_get_class_from_course($course->courseid, $this->id)) {
foreach ($cdata as $classdata) {
if (!in_array($classdata->id, $classids)) {
$classids[] = $classdata->id;
}
}
}
}
}
}
}
}
// Show different css for IE below version 8
if (check_browser_version('MSIE', 7.0) && !check_browser_version('MSIE', 8.0)) {
// IEs that are lower than version 8 do not get the float because it messes up the tabs at the top of the page for some reason
$float_style = 'text-align:right;';
} else {
// Sane browsers get the float tag
$float_style = 'text-align:right; float:right;';
}
// Tab header
$field_exists = field::get_for_context_level_with_name('curriculum', $archive_var);
//.........这里部分代码省略.........