先週のバージョンアップの際に,Moodle1.9.1+にfunction check_browser_operating_system()という,クライアントPCのOS種別を確認する関数が追加されたようです.そういえばサーバOSの種類を判別する関数はありましたが,クライアント側のPCのOSを知る関数は無かったかも知れません.なぜこの関数が出現したのか,という点について興味がありますねぇ.
/**
* Checks to see if is the browser operating system matches the specified
* brand.
*
* Known brand: 'Windows','Linux','Macintosh','SGI','SunOS','HP-UX'
*
* @uses $_SERVER
* @param string $brand The operating system identifier being tested
* @return bool true if the given brand below to the detected operating system
*/
function check_browser_operating_system($brand) {
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return false;
}if (preg_match("/$brand/i", $_SERVER['HTTP_USER_AGENT'])) {
return true;
}
return false;
}