Detect if the URL is a wordpress

0

For this I make a query to domain / wp-admin and try to read the result with the following function:

function Url_exists( $url = NULL ) {
    if(empty($url)){
        return false;
    }
    $headers = get_headers($url, 1);
    //print_r($headers);
    if(count($headers['Location']) > 1){
        return url_exists(end($headers['Location']));
    }else{
        sscanf($headers[0], 'HTTP/%*d.%*d %d', $httpcode);
        //Aceptar solo respuesta 200 (Ok), 301 (redirección permanente) o 302 (redirección temporal)
        $accepted_response = array(200, 301, 302);
        if( in_array( $httpcode, $accepted_response)) {
            echo 'existe';
            return true;
        } else {
            echo 'no existe';
            return false;
        }
    }
}

But sometimes I'm doing well and sometimes I do not know why, but as long as it's not wordpreeess, the domain tells me it's not wordpress, but if it's wordpress, depending on the web, I'm doing well and others are not.

Does anyone help me? Thanks

    
asked by pablo 04.06.2018 в 16:11
source

0 answers