1<?php 2 3/** 4 * Dokuwiki Action Plugin: automatic login 5 * 6 * @author Ondrej Machac <omachac@seznam.cz> 7 */ 8 9if(!defined('DOKU_INC')) die(); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'action.php'); 12 13class action_plugin_autlogin extends DokuWiki_Action_Plugin { 14 15 var $acl = array(); 16 var $passw = "autlogin"; 17 18/** 19 * return some info 20 */ 21 function getInfo(){ 22 return array( 23 'author' => 'Ondrej Machac', 24 'email' => 'omachac@seznam.cz', 25 'date' => '2011-02-17', 26 'name' => 'Automatic login', 27 'desc' => 'Automatic login for host, who meets some criterion of performance.', 28 'url' => 'http://dl.dropbox.com/u/26256434/autlogin.tgz', 29 ); 30 } 31 32 33 function register(&$controller) { 34 $controller->register_hook( 35 'TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'get_searchq' 36 ); 37 38 $controller->register_hook 39 ('TPL_ACT_RENDER', 'AFTER', $this, display_banner, array()); 40 } 41 42 //if is login host a moderator display new button 43 function display_banner(&$event, $param) { 44 if($this->_ismoderator()) { 45 echo '<br><br>'; 46 echo '<HR size=1 width="100%" align="center">'; 47 echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL; 48 echo '<input type="submit" value="'.$this->getLang('moderator').'" name="moderat" class="button" />'; 49 echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL; 50 echo '<input type="hidden" name="do" value="admin" />'.NL; 51 echo '<input type="hidden" name="page" value="autlogin" />'.NL; 52 echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL; 53 echo '</div></form>'.NL; 54 55 56 } 57 58 59 } 60 /** 61 * Handle the event 62 */ 63 function get_searchq(&$event, $param) { 64 65 global $ID; 66 global $BName, $Version, $Platform; //browser, OS 67 global $entry_page; //entry page 68 global $ACTUAL_ACL; //actual ACL with alias 69 global $user_ip; 70 global $auth; 71 global $ACT; 72 global $conf; 73 74 75 76 77 if(empty($_SERVER['REMOTE_USER'])) // if isn't somebody login continue 78 { 79 80 $user_ip = $_SERVER['REMOTE_ADDR']; //host's IP 81 82 if(!empty($_SERVER['HTTP_REFERER'])) //if exist entry page 83 $entry_page = $_SERVER['HTTP_REFERER']; //load 84 85 $user_agent=$_SERVER['HTTP_USER_AGENT']; 86 $this->detect_browser($user_agent); //load browser and OS 87 88 89 $ACTUAL_ACL = file(DOKU_PLUGIN.'/autlogin/settings/transl.php'); 90 91 // $this->get_perm(); //load actual rules from transl.php 92 93 $best = $this->find_best(); //find best rule for host 94 95 if($best != -1) //some rule is accepting, log in like $best 96 { 97 $best = auth_nameencode($best,true); 98 $info = $auth->getUserData($best); 99 if($info === false){ 100 $exist = false; 101 }else{ 102 $groups = $info['grps']; 103 $exist = true; 104 } 105 if($exist){ 106 auth_login($best,$passw,false,false); 107 if(auth_aclcheck($ID,$best,$groups) == AUTH_NONE) 108 $ACT = 'denied'; 109 echo '<br><h3>'.$this->getLang('refresh_page').'</h3><br>'.NL; 110 } 111 } 112 else //if no rule is right, write hosts info to file visit.php 113 { 114 $this->write_to_visit(); 115 } 116 117 } 118 119 } 120 121 //find best rule for actual host 122 function find_best() 123 { 124 125 global $ID; 126 global $BName, $Version, $Platform; //browser, OS 127 global $entry_page; //entry page 128 global $ACTUAL_ACL; //actual ACL with alias 129 global $user_ip; 130 131 132 $ip=0; 133 $is=0; 134 $max = 0; 135 $best = -1; 136 $this->get_perm(); //load actual rules from transl.php 137 138 if(empty($this->acl)) // no rule is set 139 return -1; 140 141 foreach($this->acl as $stranka => $n1) 142 { 143 //if($ID != $stranka) //only for rights ID's::!!!!!!! 144 if(!$this->_is_page($ID,$stranka)) 145 continue; 146 foreach ($n1 as $kriterium => $n2) 147 foreach ($n2 as $alias => $cislo) 148 { 149 $numb=0; 150 $count = 0; 151 $rules = preg_split('/,/',$kriterium); 152 foreach($rules as $asd) 153 $numb++; //number of item in criteria 154 if($numb == 0) 155 $numb=1; 156 157 if(!empty($user_ip)) 158 { 159 if(preg_match("~$user_ip~",$kriterium)){ //search if is user IP in criterium 160 $count++; 161 $ip = 1; 162 } 163 } 164 if(!empty($BName)) 165 { 166 if(preg_match("~$BName~",$kriterium)) 167 $count++; 168 } 169 if(!empty($Version)) 170 { 171 if(preg_match("~$Version~",$kriterium)) 172 $count++; 173 } 174 if(!empty($Platform)) 175 { 176 if(preg_match("~$Platform~",$kriterium)) 177 $count++; 178 } 179 if(!empty($entry_page)) 180 { 181 $line = preg_split('/,/',$kriterium); 182 foreach($line as $match) 183 if((SubStr($match,0,3)) == 'EP='){ 184 $match = SubStr($match,3,(strlen($match))); 185 $match = trim($match); 186 $entry_page = trim($entry_page); 187 if($entry_page == $match) 188 $count++; 189 } 190 } 191 192 if(($count == $numb)) //all criteria are right? 193 { 194 if($ip != 1 && $is == 1 )//if is set ip and same criteria set new $best 195 $ip = 0; 196 else{ 197 $is = 1; 198 $max = $count; 199 $best = $alias; 200 $ip=0; 201 } 202 $numb=0; 203 } 204 } 205 } 206 207 return $best; 208 } 209 210 211 212 function write_to_visit() 213 { 214 global $ID; 215 global $BName, $Version, $Platform; //browser, OS 216 global $entry_page; //entry page 217 global $ACTUAL_ACL; //actual ACL with alias 218 global $user_ip; 219 220 221 if(($BName != 'Unknown') && ($Version != 'Unknown') && ($Platform != 'Unknown')) //neznamy navstevnik 222 { 223 if (file_exists(DOKU_PLUGIN.'/autlogin/settings/visit.php')) { 224 225 $visit = file_get_contents(DOKU_PLUGIN.'/autlogin/settings/visit.php'); 226 227 $datum = StrFTime("%d/%m/%Y-%H:%M:%S", Time()); 228 //$line.=$datum." ".$ID; 229 $line = $ID; 230 if(!empty($user_ip)) 231 $line.=" IP=".$user_ip.","; 232 if(!empty($BName) && ($BName != 'Unknown')) 233 $line.="WB=".$BName.","; 234 if(!empty($Version) && ($Version != 'Unknown')) 235 $line.="VER=".$Version.","; 236 if(!empty($entry_page)) 237 $line.="EP=".$entry_page.","; 238 if(!empty($Platform) && ($Platform != 'Unknown')) 239 $line.="OS=".$Platform; 240 241 if(($this->_exist($line)) == 1){ //exist the same host? 242 $visit.="\n".$datum." ".$line."\n"; 243 io_saveFile(DOKU_PLUGIN.'/autlogin/settings/visit.php', $visit); 244 } 245 } 246 247 } 248 } 249 250 251 // is exist host whit the same criteria and same $ID return -1 252 // else return 1 253 function _exist($line) 254 { 255 $line = trim($line); 256 $file_line = file(DOKU_PLUGIN.'/autlogin/settings/visit.php'); 257 foreach($file_line as $lines) 258 { 259 $users = preg_split('/\s+/',$lines); 260 $users[2] = rawurldecode($users[2]); 261 $match =$users[1]." ".$users[2]; 262 263 $match = trim($match); 264 if($line == $match){ 265 return -1; 266 } 267 } 268 269 return 1; 270 } 271 272 273 //is $id and $stranka the same, or is $id in $stranka's namespace 274 function _is_page($ID,$stranka) 275 { 276 if($ID == $stranka) return true; 277 278 $ids = preg_split('/:/',$ID); 279 $pages = preg_split('/:/',$stranka); 280 $count = count($ids); 281 if($count>0) for($i=0; $i<$count; $i++){ 282 if($ids[$i] != $pages[$i]){ 283 if($pages[$i] == '*') 284 return true; 285 else return false; 286 } 287 } 288 return true; 289 290 } 291 292 //load actual setttings store in transl.php 293 function get_perm() 294 { 295 global $ACTUAL_ACL; 296 297 if($ACTUAL_ACL){ 298 foreach($ACTUAL_ACL as $line){ 299 $line = trim(preg_replace('/#.*$/','',$line)); //ignore comments 300 if(!$line) continue; 301 302 $acl = preg_split('/\s+/',$line); 303 //0 is pege, 1 kriterium, 2 alias, 3 is acl 304 305 $acl[1] = rawurldecode($acl[1]); 306 $acl_config[$acl[0]][$acl[1]][$acl[2]] = $acl[3]; 307 } 308 $this->acl = $acl_config; 309 } 310} 311 312 //is login user a moderator? 313 function _ismoderator(){ 314 global $auth; 315 316 $user = $_SERVER['REMOTE_USER']; 317 $user = auth_nameencode($user); 318 $info = $auth->getUserData($user); 319 if($info === false){ 320 $exist = false; 321 }else{ 322 $groups = $info['grps']; 323 $exist = true; 324 } 325 if($exist == true){ 326 foreach($groups as $lines) 327 if($lines == 'moderator') 328 return 1; 329 } 330 331 332 return 0; 333 } 334 335 336 337 //function for find browser, his version and OS 338 339 function detect_browser($user_agent) 340 { 341 global $BName, $Version, $Platform; 342 343 344 345 //--- Browser, Robot, crawler, spider & Download Managers --- 346 if(preg_match("~(Offline Explorer)/([0-9]{1}.[0-9]{1})~",$user_agent,$match)) 347 { 348 $BName = "Offline_Explorer"; $Version=$match[2]; 349 } 350 if(preg_match("~WebCopier v ([0-9]{1}.[0-9]{1}.{0,1}[0-9]{0,1})~",$user_agent,$match)) 351 { 352 $BName = "WebCopier"; $Version=$match[2]; 353 } 354 elseif(preg_match("~(Web Downloader)/([0-9]{1}.[0-9]{1})~",$user_agent,$match)) 355 { 356 $BName = "Web_Downloader"; $Version=$match[2]; 357 } 358 elseif(preg_match("~(Mass Downloader)/([0-9]{1}.[0-9]{1})~",$user_agent,$match)) 359 { 360 $BName = "Mass_Downloader"; $Version=$match[2]; 361 } 362 elseif(preg_match("(Ask Jeeves/Teoma)",$user_agent)) 363 { 364 $BName = 'Search_Bot_Ask_Jeeves/Teoma'; 365 } 366 elseif(preg_match("(Googlebot)",$user_agent)) 367 { 368 $BName = 'Search_Bot_Googlebot'; 369 } 370 elseif(preg_match("(nuhk)",$user_agent)) 371 { 372 $BName = 'Search_Bot_NUHK'; 373 } 374 elseif(preg_match("(Openbot)",$user_agent)) 375 { 376 $BName = 'Search_Bot_Openbot'; 377 } 378 elseif(preg_match("(Slurp)",$user_agent)) 379 { 380 $BName = 'Search_Bot_Slurp'; 381 } 382 elseif(preg_match("(ia_archiver)",$user_agent)) 383 { 384 $BName = 'Search_Bot_ia_archiver'; 385 } 386 elseif(preg_match("(MSNBot)",$user_agent)) 387 { 388 $BName = 'Search_Bot_MSNBot'; 389 } 390 elseif(preg_match("(Yammybot)",$user_agent)) 391 { 392 $BName = 'Search_Bot_Yammybot'; 393 } 394 elseif(preg_match("~(Opera Mini)/([0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 395 { 396 $BName = "Opera_Mini"; $Version=$match[2]; 397 } 398 elseif(preg_match("~(Opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}~",$user_agent,$match) 399 || preg_match("~(Opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}~",$user_agent,$match)) 400 { 401 $BName = "Opera"; $Version=$match[2]; 402 403 if ($Version == '9.80'){ 404 preg_match("~([0-9]{1,2}.[0-9]{1,3}){0,1}$~",$user_agent,$match); 405 $Version=$match[1]; 406 } 407 408 } 409 elseif( preg_match("~(NetCaptor) ([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,3})~",$user_agent,$match) 410 || preg_match("~(NetCaptor) ([0-9]{1,2}.[0-9]{1,3})~",$user_agent,$match)) 411 { 412 $BName = "NetCaptor"; $Version=$match[2]; 413 } 414 elseif(preg_match("(amaya)",$user_agent,$match)) 415 { 416 $BName = "Amaya"; $Version="Unknown"; 417 } 418 elseif(preg_match("~(Camino)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 419 { 420 $BName = "Camino"; $Version=$match[2]; 421 } 422 elseif(preg_match("~(Epiphany)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match) 423 || preg_match("~(Epiphany)/([0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 424 { 425 $BName = "Epiphany"; $Version=$match[2]; 426 } 427 elseif(preg_match("~(Flock)/([0-9]{1,2}.[0-9]{1,2}.{0,1}[0-9]{0,3}.{0,1}[0-9]{0,3})~",$user_agent,$match)) 428 { 429 $BName = "Flock"; $Version=$match[2]; 430 } 431 elseif(preg_match("~(Galeon)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 432 { 433 $BName = "Galeon"; $Version=$match[2]; 434 } 435 elseif(preg_match("~(Chimera)/([0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 436 { 437 $BName = "Chimera"; $Version=$match[2]; 438 } 439 elseif(preg_match("~(Chrome)/([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})~",$user_agent,$match)) 440 { 441 $BName = "Chrome"; $Version=$match[2]; 442 } 443 elseif(preg_match("(icab)",$user_agent,$match)) 444 { 445 $BName = "iCab"; $Version="Unknown"; 446 } 447 elseif(preg_match("~(K-Meleon)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 448 { 449 $BName = "K-Meleon"; $Version=$match[2]; 450 } 451 elseif(preg_match("~(konqueror)/([0-9]{1,2}.[0-9]{1,3})~",$user_agent,$match)) 452 { 453 $BName = "Konqueror"; $Version=$match[2]; 454 } 455 elseif(preg_match("~(Lunascape) ([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 456 { 457 $BName = "Lunascape"; $Version=$match[2]; 458 } 459 elseif(preg_match("~(links) / ([0-9]{1,2}.[0-9]{1,3})~",$user_agent,$match)) 460 { 461 $BName = "Links"; $Version=$match[2]; 462 } 463 elseif(preg_match("(lotus)",$user_agent,$match)) 464 { 465 $BName = "Lotus "; $Version="Unknown"; 466 } 467 elseif(preg_match("~(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 468 { 469 $BName = "Lynx"; $Version=$match[2]; 470 } 471 elseif(preg_match("(Maxthon)",$user_agent,$match)) 472 { 473 $BName = "Maxthon"; $Version="Unknown"; 474 } 475 elseif(preg_match("(mosaic)",$user_agent,$match)) 476 { 477 $BName = "Mosaic "; $Version="Unknown"; 478 } 479 elseif( preg_match("~(Safari)/([0-9]{1,3})~",$user_agent,$match) ) 480 { 481 $BName = "Safari"; 482 if ( preg_match("~(Version)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match) 483 || preg_match("~(Version)/([0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match) 484 ) $Version=$match[2]; 485 } 486 elseif(preg_match("~(SeaMonkey)/([0-9]{1,2}.[0-9]{1,2}.{0,1}[0-9]{0,3}.{0,1}[0-9]{0,3})~",$user_agent,$match)) 487 { 488 $BName = "SeaMonkey"; $Version=$match[2]; 489 } 490 elseif(preg_match("~(Sleipnir)/([0-9]{1,2}.[0-9]{1,2}.{0,1}[0-9]{0,3}.{0,1}[0-9]{0,3})~",$user_agent,$match)) 491 { 492 $BName = "Sleipnir"; $Version=$match[2]; 493 } 494 elseif(preg_match("~(Songbird)/([0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 495 { 496 $BName = "Songbird"; $Version=$match[2]; 497 } 498 elseif(preg_match("~(Sylera)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})~",$user_agent,$match)) 499 { 500 $BName = "Sylera"; $Version=$match[2]; 501 } 502 elseif(preg_match("~(Firefox)/([0-9]{1,2}.[0-9]{1,2}.{0,1}[0-9]{0,3}.{0,1}[0-9]{0,3})~",$user_agent,$match)) 503 { 504 $BName = "Firefox"; $Version=$match[2]; 505 } 506 elseif((preg_match("~MSIE 7.0~",$user_agent,$match)) 507 && (preg_match("~(Trident/4.0)~",$user_agent,$match))) 508 { 509 $BName = "MSIE"; $Version= 8.0 ; 510 } 511 elseif(preg_match("~(MSIE) ([0-9]{1,2}.[0-9]{1,3})~",$user_agent,$match)) 512 { 513 $BName = "MSIE"; $Version=$match[2]; 514 } 515 elseif(preg_match("~(netscape6)/(6.[0-9]{1,3})~",$user_agent,$match)) 516 { 517 $BName = "Netscape"; $Version=$match[2]; 518 } 519 elseif(preg_match("~(netscape)/(7.[0-9]{1,2})~",$user_agent,$match)) 520 { 521 $BName = "Netscape"; $Version=$match[2]; 522 } 523 elseif(preg_match("~(Gecko)/([0-9]{1,8})~",$user_agent,$match)) 524 { 525 $BName = "Mozilla"; 526 $Version=$match[2]; 527 if (preg_match("(rv):([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,3})",$user_agent,$match)) 528 { 529 $Version=$match[2]; 530 }; 531 if (preg_match("(rv):([0-9]{1,2}.[0-9]{1,3})",$user_agent,$match)) 532 { 533 $Version=$match[2]; 534 }; 535 } 536 elseif(preg_match("~mozilla/5~",$user_agent)) 537 { 538 $BName = "Netscape"; $Version="Unknown"; 539 } 540 elseif(preg_match("~(mozilla)/([0-9]{1,2}.[0-9]{1,3})~",$user_agent,$match)) 541 { 542 $BName = "Netscape "; $Version=$match[2]; 543 } 544 elseif(preg_match("~w3m~",$user_agent)) 545 { 546 $BName = "W3M"; $Version="Unknown"; 547 } 548 else{$BName = "Unknown"; $Version="Unknown";} 549 550 //--- Detekce Syst� mu ------------------------------------------------ 551 if((preg_match("~Windows XP~",$user_agent)) 552 || (preg_match("(Windows NT 5.1)",$user_agent,$match))) 553 { 554 $Platform = "Windows_XP"; 555 } 556 elseif(preg_match("win16",$user_agent)) 557 { 558 $Platform = "Windows_3.11"; 559 } 560 elseif((preg_match("(Windows 2000)",$user_agent,$match)) 561 || (preg_match("(Windows NT 5.0)",$user_agent,$match))) 562 { 563 $Platform = "Windows_2000"; 564 } 565 elseif(preg_match("(Windows NT 5.2)|(windows 2003)",$user_agent)) 566 { 567 $Platform = "Windows_Server_2003"; 568 } 569 elseif(preg_match("(Windows NT 6.0)|(Windows Vista)",$user_agent)) 570 { 571 $Platform = "Windows_Vista"; 572 } 573 elseif((preg_match("(Windows NT 7.0)",$user_agent)) 574 || (preg_match("(Windows NT 6.1)",$user_agent,$match))) 575 { 576 $Platform = "Windows_7"; 577 } 578 elseif(preg_match("Windows.ME",$user_agent)) 579 { 580 $Platform = "Windows_ME"; 581 } 582 elseif(preg_match("windows.ce",$user_agent)) 583 { 584 $Platform = "Windows_CE"; 585 } 586 elseif(preg_match("win32",$user_agent)) 587 { 588 $Platform = "Windows"; 589 } 590 elseif((preg_match("(win)([0-9]{4})",$user_agent,$match)) 591 || (preg_match("(windows) ([0-9]{4})",$user_agent,$match))) 592 { 593 $Platform = "Windows $match[2]"; 594 } 595 elseif((preg_match("(win)([0-9]{2})",$user_agent,$match)) 596 || (preg_match("(windows) ([0-9]{2})",$user_agent,$match))) 597 { 598 $Platform = "Windows $match[2]"; 599 } 600 elseif(preg_match("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}",$user_agent,$match)) 601 { 602 $Platform = "Windows_NT $match[2]"; 603 } 604 elseif(preg_match("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}",$user_agent,$match)) 605 { 606 $Platform = "Windows_NT $match[3]"; 607 } 608 elseif(preg_match("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}",$user_agent,$match)) 609 { 610 $Platform = "SunOS $match[2]"; 611 } 612 elseif(preg_match("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}",$user_agent,$match)) 613 { 614 $Platform = "BeOS $match[2]"; 615 } 616 elseif(preg_match("(CentOS)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$user_agent)) 617 { 618 $Platform = "CentOS"; 619 } 620 elseif(preg_match("freebsd",$user_agent)) 621 { 622 $Platform = "FreeBSD"; 623 } 624 elseif(preg_match("(Fedora)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$user_agent,$match)) 625 { 626 $Platform = "Fedora $match[2]"; 627 } 628 elseif(preg_match("hp-ux",$user_agent)) 629 { 630 $Platform = "HP-Unix"; 631 } 632 elseif(preg_match("(iPhone OS)",$user_agent)) 633 { 634 $Platform = "iPhone_OS"; 635 } 636 elseif(preg_match("irix",$user_agent)) 637 { 638 $Platform = "IRIX"; 639 } 640 elseif(preg_match("netbsd",$user_agent)) 641 { 642 $Platform = "NetBSD"; 643 } 644 elseif(preg_match("(Mandriva)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$user_agent)) 645 { 646 $Platform = "Mandriva"; 647 } 648 elseif(preg_match("openbsd",$user_agent)) 649 { 650 $Platform = "OpenBSD"; 651 } 652 elseif(preg_match("osf",$user_agent)) 653 { 654 $Platform = "OSF"; 655 } 656 elseif(preg_match("os/2",$user_agent)) 657 { 658 $Platform = "OS/2"; 659 } 660 elseif(preg_match("plan9",$user_agent)) 661 { 662 $Platform = "Plan9"; 663 } 664 elseif(preg_match("(Red Hat)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$user_agent,$match)) 665 { 666 $Platform = "Red_Hat"; 667 } 668 elseif(preg_match("(SUSE)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$user_agent)) 669 { 670 $Platform = "SUSE_Linux"; 671 } 672 elseif(preg_match("sunos",$user_agent)) 673 { 674 $Platform = "SunOS"; 675 } 676 elseif(preg_match("symbian",$user_agent)) 677 { 678 $Platform = "Symbian_OS"; 679 } 680 elseif(preg_match("ubuntu",$user_agent)) 681 { 682 $Platform = "Ubuntu_Linux"; 683 } 684 elseif(preg_match("(debian)",$user_agent)) 685 { 686 $Platform = "Debian_Linux"; 687 } 688 elseif(preg_match("unix",$user_agent)) 689 { 690 $Platform = "Unix"; 691 } 692 elseif(preg_match("linux",$user_agent)) 693 { 694 $Platform = "Linux"; 695 } 696 elseif(preg_match("(Mac_PowerPC)|(Mac_PPC)|(Macintosh)|(Mac_68000)|(Mac OS X)",$user_agent)) 697 { 698 $Platform = "Mac_OS"; 699 } 700 else 701 { 702 $Platform = "Unknown"; 703 } 704 705 } 706} 707