Problem with opentogoogle and require_login because of redirection

Problem with opentogoogle and require_login because of redirection

David Bogner -
回帖数:1
Core developers的头像 Plugin developers的头像
Hello,

we plan to establish courses with moodle-learning resources and want that the content of the course is found by google. So we set autologinguest to true and opentogoogle to yes, but google still does not crawl the resources because of following reason:

the require_login function does a redirect to login guests (MDL-19533). This redirections causes the googlebot to ignore the content of the course (not to access the course at all). (Checked this with lynx and the results of google webmaster tools)

In lib/moodlelib.php I identified the lines causing the redirection (1.9.3):
1883 if (empty($CFG->loginhttps) or $loginguest) { //do not require https for guest logins
1884 redirect($CFG->wwwroot .'/login/index.php'. $loginguest);
1885 } else {
1886 $wwwroot = str_replace('http:','https:', $CFG->wwwroot);
1887 redirect($wwwroot .'/login/index.php');
1888 }
Is there a way to autologin guests without this redirection? Or another possibility to enable google to view the content of an open course?

Thanks,
David
回复David Bogner

Re: Problem with opentogoogle and require_login because of redirection

David Bogner -
Core developers的头像 Plugin developers的头像
Is there any security issue if I change the code in the require_login function in lib/moodlelib.php (1883) to this :

if (empty($CFG->loginhttps) or $loginguest) { //do not require https for guest logins
$user->username = 'guest';
$user = authenticate_user_login('guest', 'guest');
unset($user->lang);
add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $user->id, 0, $user->id);
$USER = complete_user_login($user);
//redirect($CFG->wwwroot .'/login/index.php'. $loginguest);
} else {
$user->username = 'guest';
$user = authenticate_user_login('guest', 'guest');
unset($user->lang);
add_to_log(SITEID, 'user', 'login', "view.php?id=$USER->id&course=".SITEID, $user->id, 0, $user->id);
$USER = complete_user_login($user);
//$wwwroot = str_replace('http:','https:', $CFG->wwwroot);
//redirect($wwwroot .'/login/index.php');
}
//exit;
}
Thanks,
David