各位前輩..小妹最近幫朋友寫一些程式!
有一些問題想請教!!
目前有伺服器有A.B兩台
A:網頁的主伺服器 (winXP php + mysql)
B:部分資料存放資料的伺服器 (linux php + postpreSQL)
希望:
A的網頁 送條件 到B 然後 B回傳值 然後顯示在A網頁上
目前只做到
A的網頁 送條件 到B 然後 顯示B執行後的畫面(連結的網址是B伺服器的IP)
如果我現在用 curl 將條件傳給B
那在B伺服器 應該要怎麼做 才能將值 傳回A
或是有什麼指令可將 所搜尋到的值打包 回傳
(所得到的值,有可能會很大)
程式碼
// im.php $star_date = $_POST['year'] .'-'. $_POST['month'] .'-'. $_POST['day']; $end_date = $_POST['year1'] .'-'. $_POST['month1'] .'-'. $_POST['day1']; require_once 'include/cc.func.php'; $ret = cc($_SESSION['callid'], $star_date, $end_date); echo $ret;
|
//cc.func.php require_once 'curl.func.php';
$cc_url = 'http://202.33.62.113/cdr.php?';
global $cc_url;
function cc($callid, $start_time, $end_time) {
$username = 'username='.$callid; $starr_time = '&start_time='.$start_time.'%'; $end_time = '&end_time='.$end_time.'%'; $url = $GLOBALS['cc_url'].$username.$starr_time.$end_time; $ret = curl_string($url); return $ret; }
|
//curl.func.php function curl_string($url){
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $fname1 = tempnam('C:/temp', "FOO"); $fp = fopen($fname1, 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_exec ($ch); curl_close($ch); fclose($fp); $tmp = '';
if ($fp2 = fopen($fname1, 'r')) { while(!feof($fp2)) { $tmp2 = fgets($fp2, 4096); if ($tmp2 != '') {$tmp[] = $tmp2;} } fclose($fp2); } unlink($fname1); return $tmp; }
|