<commit_before><?php

class PlexLogin {

    private static $loginEndpoint = "https://plex.tv/users/sign_in.xml";
    private static $serversEndpoint = "https://plex.tv/pms/servers.xml?X-Plex-Token=";

    private $username = null;
    private $password = null;

    private $authToken = null;

    public function __construct($username, $password) {
        $this->username = $username;
        $this->password = $password;
    }

    public function isLoggedIn() {
        return ($this->authToken != null);
    }

    public function login() {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, self::$loginEndpoint);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/xml; charset=utf-8',
            'X-Plex-Device-Name: PlexLogin',
            'X-Plex-Product: PlexLogin',
            'X-Plex-Version: 0.1',
            'X-Plex-Platform: PlexLogin',
            'X-Plex-Platform-Version: 0.1',
            'X-Plex-Client-Identifier: PlexLogin/' . uniqid(),
            'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password)
        ));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $server_output = curl_exec($ch);

        curl_close($ch);

        $xml = simplexml_load_string($server_output);

        if ($xml === false)
            return false;

        if ($xml['authenticationToken']) {
            $this->username = sprintf("%s", $xml['username']);
            $this->authToken = sprintf("%s", $xml['authenticationToken']);

            return true;
        }

        return false;
    }

    public function getUsername() {
        if (!$this->isLoggedIn())
            return false;

        return $this->username;
    }

    public function getServers() {
        if (!$this->isLoggedIn())
            return [];

        $arr = [];
<commit_msg>Version 0.3<commit_after><?php

class PlexLogin {

    private static $loginEndpoint = "https://plex.tv/users/sign_in.xml";
    private static $serversEndpoint = "https://plex.tv/pms/servers.xml?X-Plex-Token=";

    private $username = null;
    private $password = <PASSWORD>;

    private $authToken = null;

    private $clientId = null;

    private $properties = array(
        'deviceName' => 'PlexLogin',
        'product' => 'PlexLogin',
        'version' => '0.3',
        'platform' => array(
            'name' => 'PlexLogin',
            'version' => '0.3'
        ),
        'clientIdentifier' => 'PlexLogin/0.3'
    );

    public function __construct($username, $password) {
        $this->username = $username;
        $this->password = $password;
    }

    public function isLoggedIn() {
        return ($this->authToken != null);
    }

    public function login() {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, self::$loginEndpoint);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/xml; charset=utf-8',
            'X-Plex-Device-Name: ' . $this->properties['deviceName'],
            'X-Plex-Product: ' . $this->properties['product'],
            'X-Plex-Version: ' . $this->properties['version'],
            'X-Plex-Platform: ' . $this->properties['platform']['name'],
            'X-Plex-Platform-Version: ' . $this->properties['platform']['version'],
            'X-Plex-Client-Identifier: ' . $this->properties['clientIdentifier'],
            'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password)
        ));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $server_output = curl_exec($ch);

        curl_close($ch);

        $xml = simplexml_load_string($server_output);

        if ($xml === false)
            return false;

        if ($xml['authenticationToken']) {
            $this->username = sprintf("%s", $xml['username']);
            $this->authToken = sprintf("%s", $xml['authenticationToken']);

            return true;
        }

        return false;
    }

    public function getUsername() {
        if (!$this->isLoggedIn())
            return false;

        return $this->username;
    }

    public function getProperties() {
        return $properties;
    }

    public function setProperties($properties) {
        $this->properties = $properties;
    }

    public function setProperty($key, $value) {
        $this->properties[$key] = $value;
    }

    public function getServers() {
        if (!$this->isLoggedIn())
            return [];

        $arr = [];

{'fraction_non_alphanumeric': 0.1562158619182871, 'fraction_numerical': 0.004369674459252786, 'mean_word_length': 2.2353356890459364, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 39, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504344', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1347, 'n_words': 254}