| Server IP : 134.236.49.22 / Your IP : 216.73.216.114 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/questionnaire/_bak/ |
Upload File : |
<?php
//$delay=86400;//เปิด page ทิ้งไว้ จะทำงานทุก1วัน ถ้าใส่ใน Schedule กำหนดเป็น 0 ได้
$delay= 0;
$page = $_SERVER['PHP_SELF'];
//--------------------- ตั้งค่าก่อน
$HospID = '10825';
$UpUrl = 'http://203.157.133.43/anc/rxID.php';//Server ที่จะเก็บข้อมูล
$hostname = "localhost";
$database = "dbqueue";
$username = "root";
$password = "090407";
//-----------------------------------------------
$dbLine= mysqli_connect($hostname, $username, $password) or trigger_error(mysqli_error(),E_USER_ERROR);
mysqli_select_db($dbLine,$database);
mysqli_set_charset($dbLine,"utf8");
date_default_timezone_set("Asia/Bangkok");
$DbfDat = odbc_connect ('mitdat','', '') or die('Could Not Connect to ODBC Database!');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<?php
if ($delay >0) echo '<meta http-equiv="refresh" content="'.$delay.';URL="'.$page.'">';
?>
</head>
<body>
<?php
echo 'วันที่ '.date("Y-m-d เวลา H:i:s").' Refresh: '.$delay.' Sec. #<br>';
$Sql = "select line_id,cid, pname,hn,tel from user_line where (line_id IS NOT NULL OR line_id='') ";
if ( isset($_GET["All"])) $Sql .= " AND dregist >= ' 20210213'"; // วันที่หมอพร้อมเปิดตัว
else $Sql .= " AND dregist >= '".date('Y-m-d',strtotime('-2 day', time()))."'" ; //ตรวจข้อมูลย้อนหลัง 2 วัน
$userline = mysqli_query($dbLine,$Sql ) or die(mysqli_error());
//$totalRows = $mysqli -> affected_rows;
//$totalRows =mysqli_affected_rows($userline )
$totalRows = mysqli_num_rows($userline );
if($totalRows > 0){ //มี lineID
$json_array=array(
'HospID' => $HospID,
'data' => array()
);
//$starttime = microtime(true);
while ($row = mysqli_fetch_assoc($userline)) {
$json_array['data'][] = $row;
/*
// update Mit-net PTNO
$strsql= "update PTNO.DBF set subtype = 'M'+right(subtype,1) where Notype = 'P_ID' and cardno='".$row['cid']."' ";
//echo $strsql.'<br>';
$objExec = odbc_exec($DbfDat, $strsql) or die (odbc_errormsg());
//odbc_free_result($objExec);
*/
}
//$endtime=microtime(true) ;
//echo 'timeUsed:'. ($endtime- $starttime).'<br>';
$data_string = json_encode($json_array);
// ------- test by decode to array
/*
$json_a = json_decode($data_string,true);
echo '<br><br>Receive<br><br>';
echo 'Hospital : '.$json_a['HospID'].'<br>';
foreach ($json_a['data'] as $key) {
$pname = $key['pname'];
$lname =$key['lname'];
if (empty($lname)) {
$nAt = strpos($pname,' ');
if ($nAt > 0) {
$lname = trim(substr($pname,$nAt+1));
$pname = substr($pname,0,$nAt);
}
}
$_sql = "update user_line set hospregist='".$_GET['ID']."' where cid='".$key['cid']."' and line_id = '".$key['line_id']."'";
echo 'SQL : '.$_sql.'<br>';
}
*/
//-------- end test
//-----------------------------------------//
//------ Transfer with Curl ------//
$ch = curl_init($UpUrl);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
// curl_setopt($ch, CURLOPT_SSLVERSION, 'all'); //for another server
curl_setopt($ch, CURLOPT_SSLVERSION, '1'); //for server2003
$result = curl_exec($ch);
var_dump($result);
echo '<br><br>';
if(curl_errno($ch) == 0) {
echo $totalRows.' Reccord';
if ($totalRows > 1) echo 's';
echo ' Sended<br>';
} else echo 'Error Sending';
} else echo 'No reccord to send';
mysqli_free_result($userline);
?>
</body>
</html>