/code/user.php
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
- <?php
- //For now, holds user preferences and system information
- //Later (todo) user preferences (via db?)
- class ecoder_user {
- public $browser,$os; //System info
- public $hiddenfiles,$root,$editor; //Preferences
- function __construct() {
- $this->_getSystem();
- $this->hiddenfiles=(isset($_SESSION['ecoder_hiddenfiles'])) ? (bool)$_SESSION['ecoder_hiddenfiles'] : false;
- $this->root="";
- $this->editor="";
- }
-
- //TODO: possibly extend with things like rendering engine, ...
- private function _getSystem() {
- $ua = $_SERVER['HTTP_USER_AGENT'];
- if (stristr($ua,"firefox")) { $this->browser="ff"; }
- else if (stristr($ua,"chrome")) { $this->browser="chrome"; }
- else if (stristr($ua,"safari")) { $this->browser="safari"; }
- else if (stristr($ua,"opera")) { $this->browser="opera"; }
- else if (stristr($ua,"msie 6")) { $this->browser="ie6"; }
- else if (stristr($ua,"msie 7")) { $this->browser="ie7"; }
- else if (stristr($ua,"msie 8")) { $this->browser="ie8"; }
- else if (stristr($ua,"msie 9")) { $this->browser="ie9"; }
- else { $this->browser="unknown"; }
- if (stristr($ua,"windows")) { $this->os="windows"; }
- else if (stristr($ua,"linux")) { $this->os="linux"; }
- else if (stristr($ua,"macintosh")) { $this->os="mac"; }
- else { $this->os="unknown"; }
- }
- function setHiddenFiles($new) {
- $this->hiddenfiles=$new;
- $_SESSION['ecoder_hiddenfiles']=$new;
- }
- }
- ?>