public static function performCheck($website, $sendOnline = false, &$emailOutput = null) { $result = MainWP_Utility::isWebsiteAvailable($website); if (!$result || isset($result['error']) && $result['error'] != '' || $result['httpCode'] != '200') { MainWP_DB::Instance()->updateWebsiteValues($website->id, array('offline_check_result' => '-1', 'offline_checks_last' => time())); $body = 'We\'ve had some issues trying to reach your website <a href="' . $website->url . '">' . stripslashes($website->name) . '</a>. ' . (isset($result['error']) && $result['error'] != '' ? ' Error message: ' . $result['error'] . '.' : 'Received HTTP-code: ' . $result['httpCode'] . ($result['httpCodeString'] != '' ? ' (' . $result['httpCodeString'] . ').' : '')); if ($emailOutput === null) { $email = MainWP_DB::Instance()->getUserNotificationEmail($website->userid); wp_mail($email, 'Down Time Alert - MainWP', MainWP_Utility::formatEmail($email, $body . '<br /><br />Please take a look at the <a href="' . $website->url . '">website</a> and make sure everything is ok.'), array('From: "' . get_option('admin_email') . '" <' . get_option('admin_email') . '>', 'content-type: text/html')); } else { $emailOutput .= ($emailOutput != '' ? '<br />' : '') . $body; } return false; } else { MainWP_DB::Instance()->updateWebsiteValues($website->id, array('offline_check_result' => '1', 'offline_checks_last' => time())); $userExtension = MainWP_DB::Instance()->getUserExtensionByUserId($website->userid); if ($sendOnline || $userExtension->offlineChecksOnlineNotification == 1) { $body = 'Your website <a href="' . $website->url . '">' . stripslashes($website->name) . '</a> is up and responding as expected!'; //if set in config! if ($emailOutput === null) { $email = MainWP_DB::Instance()->getUserNotificationEmail($website->userid); wp_mail($email, 'Up Time Alert - MainWP', MainWP_Utility::formatEmail($email, $body), array('From: "' . get_option('admin_email') . '" <' . get_option('admin_email') . '>', 'content-type: text/html')); } else { $emailOutput .= ($emailOutput != '' ? '<br />' : '') . $body; } } return true; } }