2014-01-26 19 views
3

我有一個cron作業設置,運行一個php腳本,每5分鐘使用file_get_contents()檢查我的服務器並在發生錯誤時向我發送電子郵件。現在我收到了兩封包含相同JavaScript代碼段的電子郵件,而不是它所請求的主頁。該腳本從不同的虛擬主機運行。使用PHP腳本定期檢查LAMP服務器主頁時返回奇怪的Javascript

腳本正在接收而不是頁面是:

<html> 
<head> 
    <title> </title> 

    <script type="text/javascript"> 
     function bredir(a, b, c, d, e, ldr, ifc) { 
      var h, i, j; 
      var f = 0; 
      var g = 0; 
      var k = false; 
      var l = false; 
      var m = [ 
       [300, 250, false], 
       [250, 250, false], 
       [240, 400, false], 
       [336, 280, false], 
       [180, 150, false], 
       [468, 60, false], 
       [234, 60, false], 
       [88, 31, false], 
       [120, 90, false], 
       [120, 60, false], 
       [120, 240, false], 
       [125, 125, false], 
       [728, 90, false], 
       [160, 600, false], 
       [120, 600, false], 
       [300, 600, false], 
       [300, 125, false], 
       [530, 300, false], 
       [190, 200, false], 
       [470, 250, false], 
       [720, 300, true], 
       [500, 350, true], 
       [550, 480, true], 
       //YouTube: 
       [560, 315, true], 
       [640, 360, true], 
       [853, 480, true], 
       [1280, 720, true], 
       //Vimeo: 
       [400, 300, true], 
       [500, 281, true], 
       //Hulu: 
       [480, 270, true], 
       [512, 288, true], 
       //metacafe: 
       [440, 248, true], 
       [460, 284, true], 
       [540, 304, true], 
       [600, 338, true], 
       //Other dimensions (metacafe, myspace video, yahoo video, break.com, ustream, vevo, justin.tv, etc): 
       [210, 120, true], 
       [400, 300, true], 
       [425, 350, true], 
       [425, 360, true], 
       [435, 251, true], 
       [435, 271, true], 
       [500, 300, true], 
       [525, 295, true], 
       [575, 324, true], 
       [620, 389, true], 
       [624, 351, true], 
       [630, 381, true], 
       [640, 385, true], 
       [650, 368, true], 
       [1000, 562, true], 
       [1000, 563, true], 
       [1000, 564, true] 
      ]; 
      if (typeof window.innerHeight == "number") { 
       g = window.innerHeight; 
       f = window.innerWidth; 
      } else if (typeof document.body.offsetHeight == "number") { 
       g = document.body.offsetHeight; 
       f = document.body.offsetWidth; 
      } 
      for (var n = 0; n < m.length; n++) { 
       j = m[n]; 
       h = Math.abs(f - j[0]); 
       i = Math.abs(g - j[1]); 
       if (top != self) { 
        ifc = 1; 
       } else { 
        ifc = 0; 
       }; 
       if (h <= 2 && i <= 2) { 
        k = true; 
        l = j[2] 
       } 
      } 
      if(f === 0 && g === 0){ 
       return; 
      } 
      if ((a != "www.facebook.com" && a != "platform.twitter.com") && (k || f < 100 && f !== 0 || g < 100 && g !== 0)) { 
       if (l && self == parent) { 
        return; 
       } 
       return "/b" + "anner.php?w=" + f + "&h=" + g + "&d=" + a + "&url=" + b + "&ref=" + c + "&view=" + d 
      } else if ((a == "www.facebook.com" || a == "platform.twitter.com") && (f >= 250 && g >= 60) && (k || f < 100 && f !== 0 || g < 100 && g !== 0)) { 
       if (l && self == parent) { 
        return; 
       } 
       return e + "&w=" + f + "&h=" + g + "&ldr=" + "b" + "&ifc=" + ifc; 
      } else if ((a == "www.facebook.com" || a == "platform.twitter.com") && (f < 250 || g < 60) && (k || f < 100 && f !== 0 || g < 100 && g !== 0)) { 
       if (l && self == parent) { 
        return; 
       } 
       return "/b" + "anner.php?w=" + f + "&h=" + g + "&d=" + a + "&url=" + b + "&ref=" + c + "&view=" + d; 
      } else { 
       return e + "&w=" + f + "&h=" + g + "&ifc=" + ifc; 
      } 
     } 
     function bdetect() { 
      var loc = bredir(
       'mydomain.com', 
       'mydomain.com', 
       '', 
       'error', 
       '/main?wc=EWJoExdxBAVDBxduBAoL&url=mydomain.com' 
      ); 

      if(typeof loc === 'undefined') { 
       self.close(); 
       return; 
      } 

      location.replace(loc); 

     } 
    </script> 
</head> 
<body onLoad="bdetect()" style="margin: 0px;"> 
    <noscript> 
     <iframe frameborder="0" src="/main?wc=EWJoExdxBAVDBxduBAoL&amp;url=mydomain.com" width="100%" height="100%"></iframe> 
    </noscript> 
</body> 

我發現與各種錯誤的網絡解決此代碼,但它通常是與IIS的錯誤,我不真的很確定爲什麼我會得到這個而不是主頁。

我搜索了整個網絡服務器的任何類似的東西,什麼也沒找到。

稍微修改PHP代碼的版本是:

$mail_these_people = "[email protected],[email protected]"; 
$site_foot_code = 'Specific code to look for'; 

$mysite_url = "http://mydomain.com"; 
$mysite_site_title_code = "More specific txt to look for"; 

$mysite_code = file_get_contents($mysite_url); 

if(strpos($mysite_code,$mysite_site_title_code)===false || strpos($mysite_code,$site_foot_code)===false) 
{ 
     echo "mysite Down\n"; 
     if(mail($mail_these_people,"mysite not showing up correctly!","This is what we got instead:\n\n".$mysite_code)) 
       echo "Mail sent successfully\n"; 
     else 
       echo "Mail failded!\m"; 
} 
else 
     echo "mysite Up\n"; 
+0

什麼是PHP代碼? –

+0

您的ISP有時可能將請求重定向到其他網站嗎?這聽起來像是在你的請求和目標站點之間注入了某些東西。 –

+0

當你直接運行php時是否下載正確的頁面? –

回答

0

我已經注意到了同樣的事情,它似乎是由OpenDNS的,該域名沒有找到的情況下發出重定向頁面。這裏是由提琴手捕獲的標題:

HTTP/1.0 200 OK 
Cache-Control: no-cache, must-revalidate 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Content-Type: text/html; charset=utf-8 
Pragma: no-cache 
Content-Length: 5444 
Connection: close 
Date: Fri, 14 Feb 2014 13:36:22 GMT 
Server: OpenDNS Guide 
相關問題