<commit_before><?php
/**************************************************************************
 MantisBT / MantisHub PHP Client
 Copyright (c) MantisHub - <NAME>
 All rights reserved.
 MIT License
 **************************************************************************/

/**
 * A php client for MantisBT / MantisHub SOAP API.
 */
class MantisPhpClient {
    /**
     * The Soap Client.
     */
    private $soap_client;

    /**
     * The uri for the webservice.
     */
    private $soap_uri;

    /**
     * The uri for MantisBT instance.
     */
    private $mantis_uri;

    /**
     * The MantisBT version.
     */
    private $mantis_version;

    /**
     * The cached list of projects.
     */
    private $projects;

    /**
     * The user name.
     */
    private $username;

    /**
     * The user password.
     */
    private $password;

    /**
     * Username returned by mc_login() this should be used for further queries to webservice.
     * It will be different from $username in case of anonymous login where username will be
     * blank and this one will be the actual username.
     */
    private $effective_username;

    /**
     * The constructor.
     */
    public function __construct( $p_soap_wsdl_url, $p_username, $p_password ) {
        global $g_mantis_touch_version;

        $this->soap_uri = rtrim( $p_soap_wsdl_url, " /" );

        # Make sure url points to the webservice and not just mantisbt instance
        if ( stristr( $this->soap_uri, 'mantisconnect.php' ) === false ) {
            $this->soap_uri .= '/api/soap/mantisconnect.php';
        }

        # Make sure url starts with http:// or https://
        if ( stristr( $this->soap_uri, 'http' ) === false ) {
            $this->soap_uri = 'http://' . $this->soap_uri;
        }

        $t_suffix = stristr( $this->soap_uri, '/api' );
        $this->mantis_uri = substr( $this->soap_uri, 0, strlen( $this->soap_uri ) - strlen( $t_suffix ) );

        $this->soap_client = @new SoapClient(
            $this->soap_uri . '?wsdl',
            array(
                'location' => $this->soap_uri,
                'soap_version' => SOAP_1_1,
                'encoding' => 'UTF-8',
                'user_agent' => 'MantisTouch/' . $g_mantis_touch_version,
                'exceptions' => 1,
                'connection_timeout' => 15,
                'style'    => SOAP_DOCUMENT,
                'use'      => SOAP_LITERAL,
                'cache_wsdl' => WSDL_CACHE_DISK,
            )
        );

        $this->mantis_version = null;
        $this->username = $p_username;
        $this->password = $p_password;
    }

    /**<commit_msg>Allow clients to set user agent<commit_after><?php
/**************************************************************************
 MantisBT / MantisHub PHP Client
 Copyright (c) MantisHub - <NAME>
 All rights reserved.
 MIT License
 **************************************************************************/

/**
 * A php client for MantisBT / MantisHub SOAP API.
 */
class MantisPhpClient {
    /**
     * The Soap Client.
     */
    private $soap_client;

    /**
     * The uri for the webservice.
     */
    private $soap_uri;

    /**
     * The uri for MantisBT instance.
     */
    private $mantis_uri;

    /**
     * The MantisBT version.
     */
    private $mantis_version;

    /**
     * The cached list of projects.
     */
    private $projects;

    /**
     * The user name.
     */
    private $username;

    /**
     * The user password.
     */
    private $password;

    /**
     * Username returned by mc_login() this should be used for further queries to webservice.
     * It will be different from $username in case of anonymous login where username will be
     * blank and this one will be the actual username.
     */
    private $effective_username;

    /**
     * The constructor.
     */
    public function __construct( $p_soap_wsdl_url, $p_username, $p_password, $p_user_agent = 'MantisPhpClient' ) {
        $this->soap_uri = rtrim( $p_soap_wsdl_url, " /" );

        # Make sure url points to the webservice and not just mantisbt instance
        if ( stristr( $this->soap_uri, 'mantisconnect.php' ) === false ) {
            $this->soap_uri .= '/api/soap/mantisconnect.php';
        }

        # Make sure url starts with http:// or https://
        if ( stristr( $this->soap_uri, 'http' ) === false ) {
            $this->soap_uri = 'http://' . $this->soap_uri;
        }

        $t_suffix = stristr( $this->soap_uri, '/api' );
        $this->mantis_uri = substr( $this->soap_uri, 0, strlen( $this->soap_uri ) - strlen( $t_suffix ) );

        $this->soap_client = @new SoapClient(
            $this->soap_uri . '?wsdl',
            array(
                'location' => $this->soap_uri,
                'soap_version' => SOAP_1_1,
                'encoding' => 'UTF-8',
                'user_agent' => $p_user_agent,
                'exceptions' => 1,
                'connection_timeout' => 15,
                'style'    => SOAP_DOCUMENT,
                'use'      => SOAP_LITERAL,
                'cache_wsdl' => WSDL_CACHE_DISK,
            )
        );

        $this->mantis_version = null;
        $this->username = $p_username;
        $this->password = $<PASSWORD>;
    }

    /**
{'fraction_non_alphanumeric': 0.17863231672665278, 'fraction_numerical': 0.002652017427543095, 'mean_word_length': 1.9763246899661782, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 56, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4696093', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1555, 'n_words': 394}