summaryrefslogtreecommitdiff
path: root/lib/client.php
blob: 358e60b64b2c5b4c03f4b38fb51f95d14a77e280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
 * Part of grauphel
 *
 * PHP version 5
 *
 * @category  Tools
 * @package   Grauphel
 * @author    Christian Weiske <cweiske@cweiske.de>
 * @copyright 2014 Christian Weiske
 * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
 * @link      http://cweiske.de/grauphel.htm
 */
namespace OCA\Grauphel\Lib;

/**
 * Client identification helper
 *
 * @category  Tools
 * @package   Grauphel
 * @author    Christian Weiske <cweiske@cweiske.de>
 * @copyright 2014 Christian Weiske
 * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
 * @version   Release: @package_version@
 * @link      http://cweiske.de/grauphel.htm
 */
class Client
{
    public function getClient()
    {
        if (isset($_SERVER['HTTP_X_TOMBOY_CLIENT'])) {
            $client = $_SERVER['HTTP_X_TOMBOY_CLIENT'];
            $doublepos = strpos($client, ', org.tomdroid');
            if ($doublepos !== false) {
                //https://bugs.launchpad.net/tomdroid/+bug/1375436
                //X-Tomboy-Client header is sent twice
                $client = substr($client, 0, $doublepos);
            }
            return $client;
        }

        return false;
    }

    public function getNiceName($client)
    {
        if (substr($client, 0, 12) == 'org.tomdroid') {
            //org.tomdroid v0.7.5, build 14, Android v4.4.2, innotek GmbH/VirtualBox
            return 'Tomdroid';
        }
        return $client;
    }

}
?>