public function __construct($config_data) { if (!isset($config_data['host']) || !isset($config_data['port']) || !isset($config_data['username']) || !isset($config_data['password'])) { throw new MonetraException(__('Monetra hostname, port, username and password must be provided.')); } if (!M_InitEngine()) { throw new MonetraException(__('Could not initialize engine.')); } $this->conn = M_InitConn(); if (!M_SetBlocking($this->conn, 1)) { throw new MonetraException(__('Could not set blocking mode.')); } if (!M_SetSSL($this->conn, $config_data['host'], $config_data['port'])) { throw new MonetraException(__('Could not set method to SSL.')); } $this->username = $config_data['username']; $this->password = $config_data['password']; }
<?php error_reporting(E_ALL); require_once "libmonetra.php"; $MYHOST = "testbox.monetra.com"; $MYPORT = 8665; $MYUSER = "******"; $MYPASS = "******"; $MYMETHOD = "SSL"; $MYCAFILE = NULL; $MYVERIFYSSL = 0; /* Initialize Engine */ if (!M_InitEngine(NULL)) { echo "Failed to initialize libmonetra\r\n"; return; } /* Initialize Connection */ $conn = M_InitConn(); if ($conn === FALSE) { echo "Failed to initialize connection resource\r\n"; return; } if (strcasecmp($MYMETHOD, "SSL") == 0) { /* Set up SSL Connection Location */ if (!M_SetSSL($conn, $MYHOST, $MYPORT)) { echo "Could not set method to SSL\r\n"; /* Free memory associated with conn */ M_DestroyConn($conn); return; } /* Set up information required to verify certificates */
function MCVE_InitEngine($cafile = null) { return M_InitEngine($cafile); }