PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/code/user.php

https://bitbucket.org/Ecoder/ecoder
PHP | 39 lines | 32 code | 4 blank | 3 comment | 22 complexity | 0c61db893f9aacb8b50bc83b41e75dec MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, Apache-2.0
  1. <?php
  2. //For now, holds user preferences and system information
  3. //Later (todo) user preferences (via db?)
  4. class ecoder_user {
  5. public $browser,$os; //System info
  6. public $hiddenfiles,$root,$editor; //Preferences
  7. function __construct() {
  8. $this->_getSystem();
  9. $this->hiddenfiles=(isset($_SESSION['ecoder_hiddenfiles'])) ? (bool)$_SESSION['ecoder_hiddenfiles'] : false;
  10. $this->root="";
  11. $this->editor="";
  12. }
  13. //TODO: possibly extend with things like rendering engine, ...
  14. private function _getSystem() {
  15. $ua = $_SERVER['HTTP_USER_AGENT'];
  16. if (stristr($ua,"firefox")) { $this->browser="ff"; }
  17. else if (stristr($ua,"chrome")) { $this->browser="chrome"; }
  18. else if (stristr($ua,"safari")) { $this->browser="safari"; }
  19. else if (stristr($ua,"opera")) { $this->browser="opera"; }
  20. else if (stristr($ua,"msie 6")) { $this->browser="ie6"; }
  21. else if (stristr($ua,"msie 7")) { $this->browser="ie7"; }
  22. else if (stristr($ua,"msie 8")) { $this->browser="ie8"; }
  23. else if (stristr($ua,"msie 9")) { $this->browser="ie9"; }
  24. else { $this->browser="unknown"; }
  25. if (stristr($ua,"windows")) { $this->os="windows"; }
  26. else if (stristr($ua,"linux")) { $this->os="linux"; }
  27. else if (stristr($ua,"macintosh")) { $this->os="mac"; }
  28. else { $this->os="unknown"; }
  29. }
  30. function setHiddenFiles($new) {
  31. $this->hiddenfiles=$new;
  32. $_SESSION['ecoder_hiddenfiles']=$new;
  33. }
  34. }
  35. ?>