UCBrowserOld.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace WhichBrowser\Analyser\Header;
  3. use WhichBrowser\Parser;
  4. use WhichBrowser\Constants;
  5. class UCBrowserOld
  6. {
  7. public function __construct($header, &$data)
  8. {
  9. $this->data =& $data;
  10. if ($this->data->device->type == Constants\DeviceType::DESKTOP) {
  11. $this->data->device->type = Constants\DeviceType::MOBILE;
  12. $this->data->os->reset();
  13. }
  14. if (!isset($this->data->browser->name) || $this->data->browser->name != 'UC Browser') {
  15. $this->data->browser->name = 'UC Browser';
  16. $this->data->browser->version = null;
  17. }
  18. $this->data->browser->mode = 'proxy';
  19. $this->data->engine->reset([ 'name' => 'Gecko' ]);
  20. $extra = new Parser([ 'headers' => [ 'User-Agent' => $header ]]);
  21. if ($extra->device->type != Constants\DeviceType::DESKTOP) {
  22. if ($extra->os->getName() !== '' && ($this->data->os->getName() === '' || $extra->os->getVersion() !== '')) {
  23. $this->data->os = $extra->os;
  24. }
  25. if ($extra->device->identified) {
  26. $this->data->device = $extra->device;
  27. }
  28. }
  29. }
  30. }