private function request($params) { $params['username'] = $this->username; $params['password'] = $this->password; if (empty($this->conn['fd'])) { if (!M_Connect($this->conn)) { throw new MonetraException(__(M_ConnectionError($this->conn))); } } $identifier = M_TransNew($this->conn); foreach ($params as $key => $value) { M_TransKeyVal($this->conn, $identifier, $key, $value); } return $this->executeRequest($identifier); }
if (!M_Connect($conn)) { echo "Connection failed: " . M_ConnectionError($conn) . "\r\n"; /* Free memory associated with conn */ M_DestroyConn($conn); // free memory return; } echo "connected\r\n"; /* Allocate new transaction */ $identifier = M_TransNew($conn); /* User credentials */ M_TransKeyVal($conn, $identifier, "username", $MYUSER); M_TransKeyVal($conn, $identifier, "password", $MYPASS); /* Transaction Type */ M_TransKeyVal($conn, $identifier, "action", "admin"); M_TransKeyVal($conn, $identifier, "admin", "GUT"); echo "Sending Unsettled report request...\r\n"; /* Additional Auditing parameters may be specified * Please consult the Monetra Client Interface Protocol */ if (!M_TransSend($conn, $identifier)) { echo "Communication Error: " . M_ConnectionError($conn) . "\r\n"; /* Free memory associated with conn */ M_DestroyConn($conn); return; } echo "Response received\r\n"; /* We do not have to perform the M_Monitor() loop * because we are in blocking mode */ if (M_ReturnStatus($conn, $identifier) != M_SUCCESS) { echo "Audit failed\r\n"; M_DestroyConn($conn);
function MCVE_Bt(&$conn, $username, $password) { $id = M_TransNew($conn); M_TransKeyVal($conn, $id, "username", $username); M_TransKeyVal($conn, $id, "password", $password); M_TransKeyVal($conn, $id, "action", "admin"); M_TransKeyVal($conn, $id, "admin", "bt"); if (!M_TransSend($conn, $id)) { return -1; } return $id; }
function M_TransBinaryKeyVal(&$conn, $id, $key, $val, $val_len) { return M_TransKeyVal($conn, $id, $key, base64_encode($val)); }