Example #1
0
 public static function isWebsiteAvailable($website)
 {
     $http_user = null;
     $http_pass = null;
     if (is_object($website) && isset($website->url)) {
         $url = $website->url;
         $verifyCertificate = isset($website->verify_certificate) ? $website->verify_certificate : null;
         $http_user = $website->http_user;
         $http_pass = $website->http_pass;
     } else {
         $url = $website;
         $verifyCertificate = null;
     }
     if (!self::isDomainValid($url)) {
         return false;
     }
     return MainWPUtility::tryVisit($url, $verifyCertificate, $http_user, $http_pass);
 }
 function mainwp_testwp()
 {
     $this->secure_request('mainwp_testwp');
     $url = null;
     $name = null;
     $http_user = null;
     $http_pass = null;
     $verifyCertificate = 1;
     if (isset($_POST['url'])) {
         $url = $_POST['url'];
         $verifyCertificate = $_POST['test_verify_cert'];
         $http_user = $_POST['http_user'];
         $http_pass = $_POST['http_pass'];
     } else {
         if (isset($_POST['siteid'])) {
             $website = MainWPDB::Instance()->getWebsiteById($_POST['siteid']);
             if ($website) {
                 $url = $website->url;
                 $name = $website->name;
                 $verifyCertificate = $website->verify_certificate;
                 $http_user = $website->http_user;
                 $http_pass = $website->http_pass;
             }
         }
     }
     $rslt = MainWPUtility::tryVisit($url, $verifyCertificate, $http_user, $http_pass);
     if (isset($rslt['error']) && $rslt['error'] != '' && substr($url, -9) != 'wp-admin/') {
         if (substr($url, -1) != '/') {
             $url .= '/';
         }
         $url .= 'wp-admin/';
         $newrslt = MainWPUtility::tryVisit($url, $verifyCertificate, $http_user, $http_pass);
         if (isset($newrslt['error']) && $rslt['error'] != '') {
             $rslt = $newrslt;
         }
     }
     if ($name != null) {
         $rslt['sitename'] = $name;
     }
     die(json_encode($rslt));
 }