Make WordPress Core


Ignore:
Timestamp:
11/17/2007 11:21:34 AM (17 years ago)
Author:
westi
Message:

Ensure that we offer https access to atom if it is available. Fixes #5298 props rubys.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r6250 r6339  
    14851485}
    14861486
     1487/**
     1488 * Determines if the blog can be accessed over SSL
     1489 * @return bool whether of not SSL access is available
     1490 */
     1491function url_is_accessable_via_ssl($url)
     1492{
     1493    if (in_array('curl', get_loaded_extensions())) {
     1494         $ssl = preg_replace( '/^http:\/\//', 'https://',  $url );
     1495
     1496         $ch = curl_init();
     1497         curl_setopt($ch, CURLOPT_URL, $ssl);
     1498         curl_setopt($ch, CURLOPT_FAILONERROR, true);
     1499         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     1500         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     1501
     1502         $data = curl_exec ($ch);
     1503
     1504         $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     1505         curl_close ($ch);
     1506
     1507         if ($status == 200 || $status == 401) {
     1508             return true;
     1509         }
     1510    }
     1511    return false;
     1512}
     1513
     1514function atom_service_url_filter($url)
     1515{
     1516    if ( url_is_accessable_via_ssl($url) )
     1517        return  preg_replace( '/^http:\/\//', 'https://',  $url );
     1518}
    14871519?>
Note: See TracChangeset for help on using the changeset viewer.