"; /* curl info http_code http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html [Informational 1xx] [Successful 2xx] [Redirection 3xx] [Client Error 4xx] [Server Error 5xx] */ $http_code = array( '100'=>"Continue", '101'=>"Switching Protocols", '200'=>"OK", '201'=>"Created", '202'=>"Accepted", '203'=>"Non-Authoritative Information", '204'=>"No Content", '205'=>"Reset Content", '206'=>"Partial Content", '300'=>"Multiple Choices", '301'=>"Moved Permanently", '302'=>"Found", '303'=>"See Other", '304'=>"Not Modified", '305'=>"Use Proxy", '306'=>"(Unused)", '307'=>"Temporary Redirect", '400'=>"Bad Request", '401'=>"Unauthorized", '402'=>"Payment Required", '403'=>"Forbidden", '404'=>"Not Found", '405'=>"Method Not Allowed", '406'=>"Not Acceptable", '407'=>"Proxy Authentication Required", '408'=>"Request Timeout", '409'=>"Conflict", '410'=>"Gone", '411'=>"Length Required", '412'=>"Precondition Failed", '413'=>"Request Entity Too Large", '414'=>"Request-URI Too Long", '415'=>"Unsupported Media Type", '416'=>"Requested Range Not Satisfiable", '417'=>"Expectation Failed", '500'=>"Internal Server Error", '501'=>"Not Implemented", '502'=>"Bad Gateway", '503'=>"Service Unavailable", '504'=>"Gateway Timeout" ); //----[]--- ฟังก์ชั่น check curl function iscurlinstalled() { if (in_array('curl', get_loaded_extensions())) { return true; } else{ return false; } } //---[]--- ฟังก์ชั่น check xml function isxmlinstalled() { if (in_array('xml', get_loaded_extensions())) { return true; } else{ return false; } } function simplexmlexists(){ if (function_exists('simplexml_load_string')) { return true; }else{ return false; } } if(iscurlinstalled() and isxmlinstalled() and simplexmlexists()) { if (in_array('curl', get_loaded_extensions())) { echo 'curl OK
'; } if (in_array('xml', get_loaded_extensions())) { echo 'xml OK
'; } echo '
'; /* receive_data */ //---[]--- start curl function //$url = $this->config->item('url_reg2ea')."curl_curriculum"; //$url = "http://10.16.65.95/mis/index_codeigniter.php/eregis/export/curl_curriculum"; $url = "http://localhost/check_server/export_xml.php"; $xmlStr = ""; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); $rs = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $info = curl_getinfo($ch); curl_close ($ch); //---[]--- end curl function if (empty($info['http_code'])) { die("No HTTP code was returned"); } else { // echo results echo "The server responded: "; echo $info['http_code'] . " (" . $http_code[$info['http_code']]." )
"; } $rs_cur = simplexml_load_string($rs); echo '
Receive data :
'; print_r($rs); echo '

'; //print_r($curl_getinfo); //echo $rs_cur; /* end receive_data */ } // end if($this->iscurlinstalled() && $this->isxmlinstalled()) else { echo "
ไม่สามารถอัพเดทข้อมูลนักศึกษาจากระบบทะเบียนได้
กรุณาตรวจสอบการติดตั้ง cURL และ SimpleXML
ติดต่อผู้ดูแลระบบ
"; if (function_exists('simplexml_load_string')) { return true; }else{ echo "ไม่พบ ฟังก์ชั่น simplexml_load_string
"; } } echo "
สิ้นสุดการทดสอบ
"; ?>