#!/usr/bin/php query($sql); // die(json_encode(array('status' => 'DEBUG_SQL', 'message' => $sql))); if ($dbs->error) { die('Error on database: '.$dbs->error); } echo "Starting send data to UCS server... \n"; flush(); $data = array(); // loop record and poll it in an array while ($d = $q->fetch_assoc()) { $id = (integer)$d['biblio_id']; $data[$id] = $d; $data[$id]['authors'] = array(); $data[$id]['subjects'] = array(); // author $author_q = @$dbs->query("SELECT a.author_name, ba.level, a.authority_type, a.auth_list FROM biblio_author AS ba LEFT JOIN mst_author AS a ON ba.author_id=a.author_id WHERE ba.biblio_id=$id ORDER BY level ASC"); while ($author_d = $author_q->fetch_row()) { $data[$id]['authors'][] = array('name' => $author_d[0], 'level' => $author_d[1], 'type' => $author_d[2], 'auth_list' => $author_d[3]); } // subject $topic_q = @$dbs->query("SELECT t.topic, bt.level, t.topic_type, t.auth_list FROM biblio_topic AS bt LEFT JOIN mst_topic AS t ON bt.topic_id=t.topic_id WHERE bt.biblio_id=$id ORDER BY level ASC"); while ($topic_d = $topic_q->fetch_row()) { $data[$id]['subjects'][] = array('name' => $topic_d[0], 'level' => $topic_d[1], 'type' => $topic_d[2], 'auth_list' => $topic_d[3]); } } // encode array to json format if ($data) { $to_sent['node_info'] = $node; $to_sent['node_data'] = $data; // create HTTP request $http_request = new http_request(); // send HTTP POST request $http_request->send_http_request($ucs['serveraddr'].'/ucpoll.php', @gethostbyaddr(), $to_sent, 'POST', 'text/json'); // below is for debugging purpose only // die($http_request->body()); // check for http request error if ($req_error = $http_request->error()) { echo $req_error['message']."\n"; exit(6); } // print out body of request result $response = json_decode($http_request->body(), true); echo $response['message']."\n"; exit(0); } else { exit(0); }