#StackBounty: #php #android #android-volley Android : Volley Timeout Error in Chat APP

Bounty: 50

I am working on an chat application where i am using FCM, php backend and Volley for requests.

Initially when i login my application, chat works fine and fast, but after sometime volley timeout error start coming up and as i am not using any retry policy, chat message gets lost.

And if i increase socket time out and use retry policy then app gets hang.

Please help.

Here is my code snippet where i am calling API:

public void doNetworkRequest(int type, String url, final HashMap<String, String> params, Response.Listener requestListener, Response.ErrorListener errorListener) {
        StringRequest mRequest = new StringRequest(type, url, requestListener, errorListener) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                return params;
            }


            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                return headers;
            }
        };
//        int socketTimeout = 500000;
//        RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
//        mRequest.setRetryPolicy(policy);
        mQueue.add(mRequest);
    }

UPDATE : This issue is coming almost every API sometimes like login, logout, chatting etc


Get this bounty!!!

#StackBounty: #php #apache #response-headers #zend-expressive Missing CORS headers in response from PHP/Apache2

Bounty: 250

A Zend Expressive project my company is working on is ready to be shipped but in our staging environment we seem to be missing response headers for a CORS pre-flight request. This does not happen in our development environment. We’re using CorsMiddleware in our pipeline but it doesn’t look like that middleware is the culprit.

The problem

During runtime, the middleware detects incoming pre-flight requests and it will reply with a response like so:

HTTP/1.1 200 OK
Date: Mon, 20 Aug 2018 15:09:03 GMT
Server: Apache
X-Powered-By: PHP/7.1.19
Access-Control-Allow-Origin: https://example.com
Vary: Origin
Access-Control-Allow-Headers: content-type
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

Well, that only works on our development servers and php’s built-in webservers. The response is different from our staging server, even though the request is exactly the same, apart from the host:

HTTP/1.1 200 OK
Date: Mon, 20 Aug 2018 15:11:29 GMT
Server: Apache
Keep-Alive: timeout=5, max=100
Cache-Control: max-age=0, no-cache
Content-Length: 0
Content-Type: text/html; charset=UTF-8

What we’ve tried

Investigating the middleware

We’ve verified that CorsMiddleware runs perfectly fine and actually sets the required headers. When we modify CorsMiddleware’s response code and set it to 202 instead of 200 we now do get the headers we’re looking for. Changing the response code back to 200 makes the headers disappear again.

Setting the headers manually

Using the following example:

header('Access-Control-Allow-Origin: https://example.com');
header('Access-Control-Allow-Headers: content-type');
header('Vary: Origin');
exit(0);

This has the same behavior until we modify the response code to 204 or anything other than 200.

Looking at the body

The response body is empty and shouldn’t contain anything but when we add content to the response body the headers appear as if nothing was wrong.

So if I add body content, the headers are present. No body content? No CORS headers. Is this some setting in Apache? Am I missing some configuration in PHP? Am I forgetting anything?

Further details

All requests have been tested with httpie, Postman, curl and PhpStorm’s http client.

Here’s the httpie example:

http -v OPTIONS https://staging.****.com 
    'access-control-request-method:POST' 
    'origin:https://example.com' 
    'access-control-request-headers:content-type'

Here’s the curl example:

curl "https://staging.****.com" 
--request OPTIONS 
--include 
--header "access-control-request-method: POST" 
--header "origin: https://example.com" 
--header "access-control-request-headers: content-type"

The staging environment:

OS: Debian 9.5 server
Webserver: Apache/2.4.25 (Debian) (built: 2018-06-02T08:01:13)
PHP: PHP 7.1.20-1+0~20180725103315.2+stretch~1.gbpd5b650 (cli) (built: Jul 25 2018 10:33:20) ( NTS )

Apache2 vhost on staging:

<IfModule mod_ssl.c>
<VirtualHost ****:443>
        ServerName staging.****.com
        DocumentRoot /var/www/com.****.staging/public

        ErrorLog /var/log/apache2/com.****.staging.error.log
        CustomLog /var/log/apache2/com.****.staging.access.log combined
        <Directory /var/www/com.****.staging>
                Options +SymLinksIfOwnerMatch
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
SSLCertificateFile /etc/letsencrypt/live/staging.****.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/staging.****.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Apache2 vhost on development:

<VirtualHost *:443>
        ServerName      php71.****.com
        ServerAdmin     dev@****.com
        DocumentRoot    /var/www/

        <Directory /var/www/>
                Options Indexes FollowSymlinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog        ${APACHE_LOG_DIR}/error.ssl.log
        CustomLog       ${APACHE_LOG_DIR}/access.ssl.log combined

        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/****.crt
        SSLCertificateKeyFile /etc/ssl/certs/****.key
</VirtualHost>


Get this bounty!!!

#StackBounty: #php #.htaccess htaccess – multiple extension hiding

Bounty: 50

I want to remove .html and .php extensions in my .htaccess file. I want the users to be able to view www.example.com/page.php by clicking either www.example.com/page.php or www.example.com/page, but the browser always to show www.example.com/page

Tried a few options I found online, and this one was working for me:

RewriteCond %{THE_REQUEST} /([^.]+).html [NC] 
RewriteRule ^ /%1 [NC,L,R] 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^ %{REQUEST_URI}.html [NC,L] 
RewriteCond %{THE_REQUEST} /([^.]+).php [NC] 
RewriteRule ^ /%1 [NC,L,R] 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

Which I thought was great, I could browse between pages like I mentioned above.

However, it then failed trying to log in to any of my pages. When I entered the credentials, it would just re-open the page I was on, with no error message.

The .php pages have a require("connection.php"); in the file to get the access to the database.

Then goes something like:

<?php
    require("connection.php"); 
    if(!empty($_POST)) 
    { 
        // check credentials
        // redirect to specific page
?>
<!DOCTYPE html>
<html>
<body>
    <form action="index.php" method="post">
    // the rest of the form
</body>
</html>

If I comment out the php rewrites in the .htaccess the login works as expected. It’s not a database issue, as I can view pages that display data from there with no issues.

Is there something in my .htaccess file that’s improperly redirecting my .php pages?


Get this bounty!!!

#StackBounty: #php #xml #soap #wsdl SOAP – load local WSDL file

Bounty: 100

How to load a local WSDL file into SoapClient?

$wsdl = __DIR__.'/wsdl/bankconnect.wsdl';
$this->client = new SoapClient($wsdl);

$xsd = __DIR__.'/wsdl/xsd/xmldsig-core-schema.xsd';

PHP Fatal error: SOAP-ERROR: Parsing WSDL: Could not find any usable
binding services in WSDL.

relative path to XSD file from WSDL file: ./xsd/xmldsig-core-schema.xsd

WSDL

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://bankconnect.dk/schema/2014" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="BankConnect" targetNamespace="http://bankconnect.dk/schema/2014">
    <wsdl:documentation>
        Please visit our website at www.bankconnect.dk.
    </wsdl:documentation>
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:tns="http://bankconnect.dk/schema/2014" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://bankconnect.dk/schema/2014" elementFormDefault="qualified" attributeFormDefault="unqualified">
            <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xsd/xmldsig-core-schema.xsd"/>
            <xs:element name="activateServiceAgreement" type="tns:activateServiceAgreement"/>
            <xs:element name="activateServiceAgreementResponse" type="tns:activateServiceAgreementResponse"/>
            <xs:element name="getAlternate" type="tns:getAlternate"/>
            <xs:element name="getAlternateResponse" type="tns:getAlternateResponse"/>
            <xs:element name="getBankCertificate" type="tns:getBankCertificate"/>
            <xs:element name="getBankCertificateResponse" type="tns:getBankCertificateResponse"/>
            <xs:element name="getCustomerStatement" type="tns:getCustomerStatement"/>
            <xs:element name="getCustomerStatementResponse" type="tns:getCustomerStatementResponse"/>
            <xs:element name="getDebitCreditNotification" type="tns:getDebitCreditNotification"/>
            <xs:element name="getDebitCreditNotificationResponse" type="tns:getDebitCreditNotificationResponse"/>
            <xs:element name="getCustomerAccountReport" type="tns:getCustomerAccountReport"/>
            <xs:element name="getCustomerAccountReportResponse" type="tns:getCustomerAccountReportResponse"/>
            <xs:element name="getStatus" type="tns:getStatus"/>
            <xs:element name="getStatusResponse" type="tns:getStatusResponse"/>
            <xs:element name="renewCustomerCertificate" type="tns:renewCustomerCertificate"/>
            <xs:element name="renewCustomerCertificateResponse" type="tns:renewCustomerCertificateResponse"/>
            <xs:element name="transferPayment" type="tns:transferPayment"/>
            <xs:element name="transferPaymentResponse" type="tns:transferPaymentResponse"/>

            <xs:complexType name="getBankCertificate">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getBankCertificateResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="1"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="activateServiceAgreement">
                <xs:sequence>
                    <xs:element name="activationAgreement" type="tns:activationAgreement" minOccurs="1"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="activationAgreement">
                <xs:sequence>
                    <xs:element name="activationCode" type="xs:base64Binary" minOccurs="1"/>
                    <xs:element name="certificateRequest" type="xs:base64Binary" minOccurs="1"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="activateServiceAgreementResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="1"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="renewCustomerCertificate">
                <xs:sequence>
                    <xs:element name="certificateRequestMessage" type="tns:certificateRequestMessage" minOccurs="1"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="certificateRequestMessage">
                <xs:sequence>
                    <xs:element name="certificateRequest" type="xs:base64Binary" minOccurs="1"/>
                </xs:sequence>
                <xs:attribute name="id" type="xs:ID" use="optional"/>
            </xs:complexType>

            <xs:complexType name="renewCustomerCertificateResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="1"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="transferPayment">
                <xs:sequence>
                    <xs:element name="paymentMessage" type="tns:paymentMessage"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="paymentMessage">
                <xs:sequence>
                    <xs:element name="format" type="xs:string" minOccurs="1"/>
                    <xs:element name="mimeType" type="xs:string" minOccurs="1"/>
                    <xs:element name="compressed" type="xs:integer" minOccurs="1"/>
                    <xs:element name="content" type="xs:base64Binary" minOccurs="1"/>
                </xs:sequence>
                <xs:attribute name="id" type="xs:ID" use="optional"/>
            </xs:complexType>
            <xs:complexType name="transferPaymentResponse">
                <xs:sequence>
                    <xs:element name="paymentResponse" type="tns:paymentResponse" minOccurs="1"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="paymentResponse">
                <xs:sequence>
                    <xs:element name="responseCode" type="xs:string" minOccurs="1"/>
                    <xs:element name="sender" type="xs:string" minOccurs="1"/>
                    <xs:element name="endToEndMessageId" type="xs:string" minOccurs="1"/>
                    <xs:element name="correlationId" type="xs:string" minOccurs="1"/>
                    <xs:element name="message" type="xs:string" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>

            <xs:complexType name="getStatus">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getStatusResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="0"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>

            <xs:complexType name="getCustomerStatement">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getCustomerStatementResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="0"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="getDebitCreditNotification">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getDebitCreditNotificationResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="0"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="getCustomerAccountReport">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getCustomerAccountReportResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="0"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="getAlternate">
                <xs:sequence/>
            </xs:complexType>
            <xs:complexType name="getAlternateResponse">
                <xs:sequence>
                    <xs:element name="corporateMessage" type="tns:corporateMessage" minOccurs="0"/>
                    <xs:element minOccurs="0" ref="ds:Signature"/>
                </xs:sequence>
            </xs:complexType>

            <xs:complexType name="ActivationHeader">
                <xs:sequence>
                    <xs:element name="organisationIdentification" type="tns:organisationIdentification"/>
                    <xs:element name="functionIdentification" type="xs:string" minOccurs="1"/>
                    <xs:element name="erpInformation" type="tns:erpInformation"/>
                    <xs:element name="endToEndMessageId" type="xs:string" minOccurs="1"/>
                    <xs:element name="createDateTime" type="xs:dateTime" minOccurs="1"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ServiceHeader">
                <xs:sequence>
                    <xs:element name="organisationIdentification" type="tns:organisationIdentification" minOccurs="1"/>
                    <xs:element name="functionIdentification" type="xs:string" minOccurs="1"/>
                    <xs:element name="erpInformation" type="tns:erpInformation"/>
                    <xs:element name="format" type="xs:string" minOccurs="1"/>
                    <xs:element name="endToEndMessageId" type="xs:string" minOccurs="1"/>
                    <xs:element name="createDateTime" type="xs:dateTime" minOccurs="1"/>
                </xs:sequence>
                <xs:anyAttribute processContents="lax" namespace="##other"/>
            </xs:complexType>

            <xs:complexType name="technicalAddress">
                <xs:sequence>
                    <xs:element name="ipAddress" type="xs:string" minOccurs="0"/>
                    <xs:element name="ipPort" type="xs:string" minOccurs="0"/>
                    <xs:element name="appliedTime" type="xs:dateTime" minOccurs="0"/>
                    <xs:element name="duration" type="tns:duration" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="organisationIdentification">
                <xs:sequence>
                    <xs:element name="mainRegistrationNumber" type="xs:string" minOccurs="1"/>
                    <xs:element name="isoCountryCode" type="xs:string" minOccurs="1"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="duration">
                <xs:sequence>
                    <xs:element name="time" type="xs:long" minOccurs="0"/>
                    <xs:element name="point" type="xs:string" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="erpInformation">
                <xs:sequence>
                    <xs:element name="erpsystem" type="xs:string" minOccurs="0"/>
                    <xs:element name="erpversion" type="xs:string" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>

            <xs:complexType name="corporateMessage">
                <xs:sequence>
                    <xs:element name="format" type="xs:string" minOccurs="1"/>
                    <xs:element name="mimeType" type="xs:string" minOccurs="1"/>
                    <xs:element name="severalMessages" type="xs:boolean" minOccurs="1"/>
                    <xs:element name="sender" type="xs:string" minOccurs="0"/>
                    <xs:element name="version" type="xs:string" minOccurs="0"/>
                    <xs:element name="messageDate" type="xs:dateTime" minOccurs="0"/>
                    <xs:element name="description" type="xs:string" minOccurs="0"/>
                    <xs:element name="endToEndMessageId" type="xs:string" minOccurs="1"/>
                    <xs:element name="compressed" type="xs:integer" minOccurs="1"/>
                    <xs:element name="content" type="xs:base64Binary" minOccurs="0"/>
                </xs:sequence>
                <xs:attribute name="id" type="xs:ID" use="optional"/>
            </xs:complexType>

            <xs:complexType name="corporateDuration">
                <xs:sequence>
                    <xs:element name="description" type="xs:string" minOccurs="0"/>
                    <xs:element name="time" type="xs:long" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="technicalAddress" type="tns:technicalAddress"/>
            <xs:element name="activationHeader" type="tns:ActivationHeader"/>
            <xs:element name="serviceHeader" type="tns:ServiceHeader"/>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="getBankCertificate">
        <wsdl:part name="parameters" element="tns:getBankCertificate"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="activationHeader" element="tns:activationHeader"/>
    </wsdl:message>
    <wsdl:message name="getBankCertificateResponse">
        <wsdl:part name="parameters" element="tns:getBankCertificateResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="activationHeader" element="tns:activationHeader"/>
    </wsdl:message>
    <wsdl:message name="activateServiceAgreement">
        <wsdl:part name="parameters" element="tns:activateServiceAgreement"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="activationHeader" element="tns:activationHeader"/>
    </wsdl:message>
    <wsdl:message name="activateServiceAgreementResponse">
        <wsdl:part name="parameters" element="tns:activateServiceAgreementResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="activationHeader" element="tns:activationHeader"/>
    </wsdl:message>
    <wsdl:message name="renewCustomerCertificate">
        <wsdl:part name="parameters" element="tns:renewCustomerCertificate"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="renewCustomerCertificateResponse">
        <wsdl:part name="parameters" element="tns:renewCustomerCertificateResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="transferPayment">
        <wsdl:part name="parameters" element="tns:transferPayment"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="transferPaymentResponse">
        <wsdl:part name="parameters" element="tns:transferPaymentResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getStatus">
        <wsdl:part name="parameters" element="tns:getStatus"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getStatusResponse">
        <wsdl:part name="parameters" element="tns:getStatusResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getCustomerStatement">
        <wsdl:part name="parameters" element="tns:getCustomerStatement"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getCustomerStatementResponse">
        <wsdl:part name="parameters" element="tns:getCustomerStatementResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getDebitCreditNotification">
        <wsdl:part name="parameters" element="tns:getDebitCreditNotification"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getDebitCreditNotificationResponse">
        <wsdl:part name="parameters" element="tns:getDebitCreditNotificationResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getCustomerAccountReport">
        <wsdl:part name="parameters" element="tns:getCustomerAccountReport"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getCustomerAccountReportResponse">
        <wsdl:part name="parameters" element="tns:getCustomerAccountReportResponse"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
    </wsdl:message>
    <wsdl:message name="getAlternate">
        <wsdl:part name="parameters" element="tns:getAlternate"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:message name="getAlternateResponse">
        <wsdl:part name="parameters" element="tns:getAlternateResponse"/>
        <wsdl:part name="technicalAddress" element="tns:technicalAddress"/>
        <wsdl:part name="serviceHeader" element="tns:serviceHeader"/>
    </wsdl:message>
    <wsdl:portType name="CorporateService">
        <wsdl:operation name="getBankCertificate">
            <wsdl:input name="getBankCertificate" message="tns:getBankCertificate"/>
            <wsdl:output name="getBankCertificateResponse" message="tns:getBankCertificateResponse"/>
        </wsdl:operation>
        <wsdl:operation name="activateServiceAgreement">
            <wsdl:input name="activateServiceAgreement" message="tns:activateServiceAgreement"/>
            <wsdl:output name="activateServiceAgreementResponse" message="tns:activateServiceAgreementResponse"/>
        </wsdl:operation>
        <wsdl:operation name="renewCustomerCertificate">
            <wsdl:input name="renewCustomerCertificate" message="tns:renewCustomerCertificate"/>
            <wsdl:output name="renewCustomerCertificateResponse" message="tns:renewCustomerCertificateResponse"/>
        </wsdl:operation>
        <wsdl:operation name="transferPayments">
            <wsdl:input name="transferPayment" message="tns:transferPayment"/>
            <wsdl:output name="transferPaymentsResponse" message="tns:transferPaymentResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <wsdl:input name="getStatus" message="tns:getStatus"/>
            <wsdl:output name="getStatusResponse" message="tns:getStatusResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getCustomerStatement">
            <wsdl:input name="getCustomerStatement" message="tns:getCustomerStatement"/>
            <wsdl:output name="getCustomerStatementResponse" message="tns:getCustomerStatementResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getDebitCreditNotification">
            <wsdl:input name="getDebitCreditNotification" message="tns:getDebitCreditNotification"/>
            <wsdl:output name="getDebitCreditNotificationResponse" message="tns:getDebitCreditNotificationResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getCustomerAccountReport">
            <wsdl:input name="getCustomerAccountReport" message="tns:getCustomerAccountReport"/>
            <wsdl:output name="getCustomerAccountReportResponse" message="tns:getCustomerAccountReportResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getAlternate">
            <wsdl:input name="getAlternate" message="tns:getAlternate"/>
            <wsdl:output name="getAlternateResponse" message="tns:getAlternateResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="BankConnectSoapBinding" type="tns:CorporateService">
        <soap:binding style="document" transport="https://schemas.xmlsoap.org/soap/https"/>

        <wsdl:operation name="getBankCertificate">
            <soap:operation soapAction="urn:CorporateService:getBankCertificate" style="document"/>
            <wsdl:input name="getBankCertificate">
                <soap:header message="tns:getBankCertificate" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getBankCertificate" part="activationHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getBankCertificateResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header use="literal" part="technicalAddress" message="tns:getBankCertificateResponse"/>
                <soap:header use="literal" part="activationHeader" message="tns:getBankCertificateResponse"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="activateServiceAgreement">
            <soap:operation soapAction="urn:CorporateService:activateServiceAgreement" style="document"/>
            <wsdl:input name="activateServiceAgreement">
                <soap:header message="tns:activateServiceAgreement" part="technicalAddress" use="literal"/>
                <soap:header message="tns:activateServiceAgreement" part="activationHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="activateServiceAgreementResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:activateServiceAgreementResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:activateServiceAgreementResponse" part="activationHeader" use="literal"/>
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="renewCustomerCertificate">
            <soap:operation soapAction="urn:CorporateService:renewCustomerCertificate" style="document"/>
            <wsdl:input name="renewCustomerCertificate">
                <soap:header message="tns:renewCustomerCertificate" part="technicalAddress" use="literal"/>
                <soap:header message="tns:renewCustomerCertificate" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="renewCustomerCertificateResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:renewCustomerCertificateResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:renewCustomerCertificateResponse" part="serviceHeader" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="transferPayments">
            <soap:operation soapAction="urn:CorporateService:transferPayment" style="document"/>
            <wsdl:input name="transferPayment">
                <soap:header message="tns:transferPayment" part="technicalAddress" use="literal"/>
                <soap:header message="tns:transferPayment" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="transferPaymentsResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:transferPaymentResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:transferPaymentResponse" part="serviceHeader" use="literal"/>
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="getCustomerStatement">
            <soap:operation soapAction="urn:CorporateService:getCustomerStatement" style="document"/>
            <wsdl:input name="getCustomerStatement">
                <soap:header message="tns:getCustomerStatement" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getCustomerStatement" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getCustomerStatementResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:getCustomerStatementResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getCustomerStatementResponse" part="serviceHeader" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getDebitCreditNotification">
            <soap:operation soapAction="urn:CorporateService:getDebitCreditNotification" style="document"/>
            <wsdl:input name="getDebitCreditNotification">
                <soap:header message="tns:getDebitCreditNotification" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getDebitCreditNotification" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getDebitCreditNotificationResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:getDebitCreditNotificationResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getDebitCreditNotificationResponse" part="serviceHeader" use="literal"/>
            </wsdl:output>

        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <soap:operation soapAction="urn:CorporateService:getStatus" style="document"/>
            <wsdl:input name="getStatus">
                <soap:header message="tns:getStatus" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getStatus" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getStatusResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header use="literal" part="technicalAddress" message="tns:getStatusResponse"/>
                <soap:header use="literal" part="serviceHeader" message="tns:getStatusResponse"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getCustomerAccountReport">
            <soap:operation soapAction="urn:CorporateService:getCustomerAccountReport" style="document"/>
            <wsdl:input name="getCustomerAccountReport">
                <soap:header message="tns:getCustomerAccountReport" part="technicalAddress" use="literal"/>

                <soap:header message="tns:getCustomerAccountReport" part="serviceHeader" use="literal"/>

                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getCustomerAccountReportResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header use="literal" part="technicalAddress" message="tns:getCustomerAccountReportResponse"/>
                <soap:header use="literal" part="serviceHeader" message="tns:getCustomerAccountReportResponse"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getAlternate">
            <soap:operation soapAction="urn:CorporateService:getAlternate" style="document"/>
            <wsdl:input name="getAlternate">
                <soap:header message="tns:getAlternate" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getAlternate" part="serviceHeader" use="literal"/>
                <soap:body parts="parameters" use="literal"/>
            </wsdl:input>
            <wsdl:output name="getAlternateResponse">
                <soap:body use="literal" parts="parameters"/>
                <soap:header message="tns:getAlternateResponse" part="technicalAddress" use="literal"/>
                <soap:header message="tns:getAlternateResponse" part="serviceHeader" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="BankConnectService">
        <wsdl:port name="CorporateServicePort" binding="tns:BankConnectSoapBinding">
            <soap:address location="http://localhost:8080/bankconnect/services/CorporateService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>


Get this bounty!!!

#StackBounty: #php #url Convert URL into one standard format

Bounty: 50

Here are a few URLs:

http://sub.example.com/?feed=atom&hello=world
http://www.sub.example.com/?feed=atom&hello=world
http://sub.example.com/?hello=world&feed=atom
http://www.sub.example.com/?hello=world&feed=atom
http://www.sub.example.com/?hello=world&feed=atom
http://www.sub.example.com/?hello=world&feed=atom#123

As you can see, they all lead to the exact same page but the URL format is different. Here is two other basic examples:

http://example.com/hello/
http://example.com/hello

Both are the same.

I want to convert the URL into one standard format so that when I store the URL in the database, I can easily check whether if the URL string already exists in the database.

Because of the various ways of how the URL can be formatted, this can be puzzling.

What’s the definitive approach to converting URL into one standard format? Maybe parse_url() route…?

Edit

As outlined in the comments, there is no definitive solution to this, but the aim is to get as close as possible with what we have without “retrieving” the page. Please read comments before posting an answer to this bounty.


Get this bounty!!!

#StackBounty: #php #sql-server #codeigniter #pdo #sqlsrv PHP MSSQL num_rows() not working with sqlsrv driver in Codeigniter

Bounty: 50

I’m getting the following error on a simple query that’s supposed to return a number of rows:

Type: Error

Message: Call to a member function num_rows() on boolean

Filename:
/var/www/cfc-dev/docroot/project/system/database/DB_query_builder.php

Line Number: 1428

I’m using Codeigniter 3.1.9. I recently started using PHP7.2 and also sqlsrv driver to connect to a MSSQL database.

In some other post, someone mentioned that scrollable should be set to an option different than SQLSRV_CURSOR_FORWARD so I dump the value of $this->scrollable in sqlsrv_driver.php and found out that its value is buffered

/**
     * Execute the query
     *
     * @param   string  $sql    an SQL query
     * @return  resource
     */
    protected function _execute($sql)
    {
        echo $this->scrollable; die();
        return ($this->scrollable === FALSE OR $this->is_write_type($sql))
            ? sqlsrv_query($this->conn_id, $sql)
            : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => $this->scrollable));
    }

Not quite sure why it’s failing. Any other queries that don’t include num_rows() are fine so far.
Thanks.


Get this bounty!!!

#StackBounty: #php #laravel Why the custom rule is not working? (allow user to select only the quantity for one registration type)

Bounty: 50

I have a select menu for the user to select the quantities of each
registration type that he wants.

<form method="post" action="{{route('conferences.storeQuantities', 
['id' => $conference->id, 'slug' => $conference->slug])}}">
    <ul class="list-group">
        {{ csrf_field() }}
        @foreach($registration_types as $rtype)
        <li>
            <select id="rtype_{{ $rtype->id }}" 
                    data-price="{{ $rtype->price }}"
                    name="rtypes[{{ $rtype->name }}]">
                <option value="0">0</option>
                @for ($i = $rtype->min_participants; $i <= $rtype-> max_participants; $i++)
                    <option value="{{ $i }}">{{ $i }}</option>
                @endfor
            </select>
        </li>
       @endforeach
    </ul>
</form>

But there are some validation rules for this field that are not working properly. Basically there are 4 things that should be validated:

  • the field is required
  • the quantity introduced by the user should be between min_participants and max_participants (min_participants and max_participants are columns in the registration_types table and means the minimum and maximum quantity that a user can select for a specific registration)
  • the user needs to at least select the quantity for a registration type available for the confernece and for the other registration types should be allowed to select “0”
  • but the user can´t introduce the quantity “0” for all registration types available in the conference

Issue: But its not working properly, if the user selects for example the quantity “1” for registration type “general” and for the registration type “plus” “0” it appears the validation error defined in the message() of the RegistrationTypeQuantity rule. But the user should be able to select only the quantity for 1 registration type.

Do you know how to solve that?

The RegistrationTypeQuantity rule that is used in the storeQuantities(), basically the quantities are sum and then is checked if the quantity is greater than 0:

 public function passes($attribute, $value)
    {

        $quantity = 0;

        foreach($value as $key=>$v) {

            if ( is_null($v)) return false;

            $rtype = RegistrationType::where('name',$key)->first();
            if ( ! $rtype) return false;

            // $rtype was found
            if ( ($v < $rtype->min_participants || $v > $rtype->max_participants) )
                return false;
        }

        // track total quantity selected
        $quantity += (int)$v;

        // make sure there was at least one purchase
        if ($quantity === 0) {
            return false;
        }

        return true;
    }

Method to store the selected quantities by the user for each registration type

 public function storeQuantities(Request $request, $id, $slug = null)
 {
     $request->validate([
        'rtypes' => ['required', 'array', new RegistrationTypeQuantity],
    ]);
        if ($validator->fails())
    {
        return redirect()->back()->withErrors($validator, 'quantitiesError');
    }

    $rtypeQuantities = $request->get('rtypes');
    $total = 0;
    $selectedRtypes = [];


    foreach ($rtypeQuantities as $rtypeName => $quantity) {
        if ($quantity) {
            $rtype = RegistrationType::where('name', $rtypeName)->firstOrFail();

            //dd($rtype);
            $price = $rtype->price;

            $selectedRtypes[$rtype->name]['quantity'] = $quantity;
            $selectedRtypes[$rtype->name]['price'] = $price;
            $selectedRtypes[$rtype->name]['subtotal'] = $price * $quantity;
            $total += $selectedRtypes[$rtype->name]['subtotal'];
            $selectedRtypes[$rtype->name]['total'] = $total;

            $selectedRtypes[$rtype->name]['questions'] = $rtype->questions;
            $selectedRtypes[$rtype->name]['id'] = $rtype->id;
        }
    }
    if($selectedRtypes){
        Session::put('selectedRtypes', $selectedRtypes);
        Session::put('customQuestions', $selectedRtypes[$rtype->name]['questions']);
        Session::put('total', $total);
    }
    return redirect(route('conferences.registration', ['id' => $id, 'slug' => $slug]));
     }
 }

HTML of the select menu to select the quantities:

Registration Type Quantity Price
  • general
    <select class="custom-select form-control rtype_name" id="rtype_1" data-price="5" name="rtypes[geral]"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> </select> <span>X 5.00€</span> </li> <li class="list-group-item d-flex align-items-center justify-content-between">
    plus
    <select class="custom-select form-control rtype_name" id="rtype_3" data-price="10" name="rtypes[plus]"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> </select> <span>X 10.00€</span> </li> </ul> </form> </div> </div>

Validation rules better explained:

If there are two registration types associated with the conference (general and plus), the registration type “general” has the column “min_participants” as “1” and max_participants as “1”, the the registration type “plus” has the column “min_participants” as “1” and max_participants as “2”.

  • If the user click “Next” in the select menu with quantity “0” for registration type “general” and quantity “0” for the registration type “plus” it should fail because the user needs to select at least the quantity for one registration type, because a registration needs to have some registration type(s) associated

  • If the user click “Next” in the select menu with quantity “2” for registration type “general” and quantity “0” for the registration type “plus” it should fail because “general” has “max_participants” as “1” and the user selected the quantity “2” (introduced 2 in the source code for example since in the select menu 2 should not appear for the registration type general, only should appear values between 1 and 1)

  • If the user click “Next” in the select menu with quantity “1” for registration type “general” and quantity “1” for the registration type “plus” it should pass

  • If the user click “Next” in the select menu with quantity “1” for registration type “general” and quantity “0” for the registration type “plus” it should pass because the user should be allowed do a registration without select quantities for all registration types, because the user might want to only do a registration in the registration type “general” and none in the registration type “plus”. So it should not be mandatory for the user select quantities for all registration types.


Get this bounty!!!

#StackBounty: #php #posts #customization #pingbacks Remove option to allow trackbacks/pingbacks from post page options

Bounty: 50

I’m trying to disable all functionality related to pingbacks/trackbacks in WordPress and so far I have this:

add_action( 'pre_ping', 'disable_pingback' );

function disable_pingback( &$links ) {
    foreach ( $links as $l => $link ) {
        if ( 0 === strpos( $link, get_option( 'home' ) ) ) {
            unset( $links[ $l ] );
        }
    }
}

However when I open up the page options and enable discussion, I still see this:

enter image description here

I found this answer (method 2), but it is over 5 years old now and I wasn’t sure if totally replacing the whole section was the best way to do things compatibility wise, so I am asking again…

Is there a cleaner way to accomplish this?


Get this bounty!!!

#StackBounty: #php #mongodb #database-administration MongoDB connecting over SSL: What am I doing wrong?

Bounty: 50

Overview: I have an application server running PHP 7, connecting to a separate database server running MongoDB 3.6.x using the MongoDB PHP userland library. I have firewall rules preventing access to the MongoDB server from all sources except the local and private interfaces (i.e. disallowing public IP access).

Connections via PHP look something like this:

$context_information = array(
    "ssl" => array(
        "allow_self_signed" => false,
        "verify_peer"       => true,
        "verify_peer_name"  => true,
        "verify_expiry"     => true,
        "cafile"            => "/path/to/ca_bundle"
));

$context = stream_context_create($context_information);
$connection = new MongoDBClient(
    $host,
    array('ssl'=>true),
    array('context'=> $context)
);

My MongoDB configuration looks something like this:

net:
  port: 27017
  bindIp: 127.0.0.1,10.138.196.241
  ssl:
    mode: requireSSL
    PEMKeyFile: /path/to/my_ca_signed_cert
    CAFile: /path/to/my_ca_bundle

my_ca_signed_cert is a .pem file generated using my openssl-generated RSA private key, as well as the CA-provided .crt file, in the manner described in the MongoDB manual, e.g. cat mongodb.key mongodb.crt > mongodb.pem. my_ca_bundle is the .ca-bundle provided to me by the CA.

Additionally, the ca_bundle described in the PHP context is the same .ca-bundle file as in the MongoDB config.

Problem: I continue to receive the following error:

[23-Jul-2018 16:33:33 America/Los_Angeles] PHP Fatal error: Uncaught MongoDBDriverExceptionConnectionTimeoutException: No suitable servers found (serverSelectionTryOnce set): [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster on. . .

This issue persists even if I comment out the CAFile line for the MongoDB config. Also of note is that I can connect successfully when setting allow_self_signed to true if CAFile is commented out, but not when it’s left uncommented.

Finally, when attempting to connect via the MongoDB shell, I get the following error:

2018-07-23T23:37:02.992+0000 E NETWORK [thread1] SSL peer certificate validation failed: unable to get issuer certificate

2018-07-23T23:37:02.992+0000 E QUERY [thread1] Error: socket exception [CONNECT_ERROR] for SSL peer certificate validation failed: unable to get issuer certificate :

connect@src/mongo/shell/mongo.js:251:13

@(connect):1:6

exception: connect failed

Expected Behavior: I don’t want to use client certificate authentication for connecting to the database. All I want at present is for traffic to be encrypted. This means being able to connect to the database without allowing self-signed certificates.

Notes:

  1. I have a cert set up successfully on the application server for HTTPS connectivity. Additionally, when testing the cert referenced in this question itself, I’ve successfully run verification on the files using openssl verify -CAfile /path/to/my_ca_bundle /path/to/my_ca_signed_cert.

  2. Everything in my application code works when SSL is disabled or when enabled while allowing self-signed certs.

The documentation on all of this is incredibly vague on a number of points, so I’m not sure where my configuration is going wrong. What should I be looking into to resolve this problem?


Get this bounty!!!