Merge branch 'w07_MDL-26389_20_profile' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-02-14 15:58:26 +01:00
commit 76b7e2d1d6
5 changed files with 49 additions and 21 deletions

View file

@ -216,19 +216,8 @@ abstract class session_stub implements moodle_session {
$user = null;
if (!empty($CFG->opentogoogle) and !NO_MOODLE_COOKIES) {
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
// allow web spiders in as guest users
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
$user = guest_user();
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
$user = guest_user();
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
$user = guest_user();
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
$user = guest_user();
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
$user = guest_user();
}
if (is_web_crawler()) {
$user = guest_user();
}
if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
// automaticaly log in users coming from search engine results

View file

@ -1123,6 +1123,38 @@ function init_eaccelerator() {
return false;
}
/**
* 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
*/
function is_web_crawler() {
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false ) {
return true;
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'AltaVista') !== false ) {
return true;
}
}
return false;
}
/**
* This class solves the problem of how to initialise $OUTPUT.