2012-12-12 66 views
0

我試圖解決我的PHP文件,但我發現一些問題..PHP回聲顯示 - 缺少信息

我需要接收的輸出從我的腳本,使用回聲或打印功能,但回顯結果顯示不完整。

這是我的.PHP:

<?php 
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib'); 

require_once "PHPTelnet.php"; 

$SUBSCRIBER = $_POST["SUBSCRIBER"]; 

$COUNT = $_POST["COUNT"]; 


if ($SUBSCRIBER == "HOME") 

{ 
     echo "It's HOME<br>"; 

     if ($COUNT=="ACTIVE_FLOW") 

     { 

     echo "Value is ACTIVE_FLOW"; 

     $script = "exec cf2:/scripts/active_flow_count.cfg"; 

     } 
} 

echo "<pre>"; 

echo "<pre>"; 

我的回聲輸出是:

It's HOME 
Value is ACTIVE_FLOW 
exec cf2:/scripts/active_flow_count.cfg 

===================================================== 
Application-Assurance flow record search, Version 1.0 
Search Start Time:  "12/12/2012 22:23:08" (UTC) 
Search Criteria: 
    group[:partition]: 1:1 
    aa-sub:    1/1/1:302 (sap) 
    protocol name:  none specified 
    application name: none specified 
    app-group name:  none specified 
    flow-status:   active 
    start-flowId:  none specified 
    classified:   none specified 
    server-ip:   none specified 
    server-port:   none specified 
    client-ip:   none specified 
    bytes-tx:   none specified 
    flow-duration:  none specified 
    max-count:   none specified 
    search-type:   default 
===================================================== 
FlowId Init Src-ip         Dst-ip         Ip-prot  Src-prt Dst-prt Protocol    Application   Pkts-tx Bytes-tx    Pkts-disc Bytes-disc Time-ofp(UTC)   Time-olp(UTC)   
2107678 no 200.141.223.79       10.101.75.199       tcp   57238 1356 "ftp_data"    "FTP"     687100  1026970850   0   0   "12/12/2012 21:00:46" "12/12/2012 22:23:09" 

它應該包含很多比這更多的線路。

當他們看到這個「12/12/2012 22:23:09」雙引號時,是否有任何回聲停止的可能性?

+0

你想要什麼它呼應? – DrinkJavaCodeJava

+0

你的意思是停止回聲或文字停止? – DrinkJavaCodeJava

+0

什麼在'PHPTelnet.php'? – ChrisW

回答

0

如果你的意思是呼應詞「停」時,這個確切的日期和時間顯示的地方,你可以做

if(preg_match("/\b\"12\/12\/2012 22:23:09\"\b/i")==true) 
{ 
    echo "stop" 
} 
+0

因爲他們說它應該包含更多行,我認爲「有什麼可能在他們看到這個時候回聲停止......「他們的意思是」當它看到這個時,PHP是否會停止迴應......「 – Popnoodles

0

你不顯示腳本的重要組成部分。你需要做的是在顯示輸出之前處理輸出,這意味着將它加載到一個字符串中,而不是直接echo()它,或者使用輸出緩衝區來捕獲echo()的ed內容。然後你想找到「12/12/2012 22:23:09」的位置,並使用substr來獲取它以及它之前的字符串的內容。注意下面的代碼使用正則表達式找到位置會更好,但是這是一個例子來說明它是如何工作的。

這將是這樣的:

<?php 

//.... 

ob_start(); 
if ($SUBSCRIBER == "HOME") 

{ 
     echo "It's HOME<br>"; 

     if ($COUNT=="ACTIVE_FLOW") 

     { 

     echo "Value is ACTIVE_FLOW"; 

     $script = "exec cf2:/scripts/active_flow_count.cfg"; 

     } 
} 
$out = ob_get_contents(); 
ob_end_clean(); 

// Should use requex but this will work 
// Find the pos of "Start Time:" then add 22 for the chars in '"xx/xx/xxxx xx:xx:xx"' 
$pos = strpos($out, "Start Time:")+22; 
echo substr($out, 0, $pos); 

//.... 

?>