Пример #1
0
 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'];
 }
Пример #2
0
$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 */
    if ($MYVERIFYSSL) {
        if (!M_SetSSL_CAfile($conn, $MYCAFILE)) {
            echo "Could not set SSL CAFile. " . "Does the file exist?\r\n";
            M_DestroyConn($conn);
            return;
        }
        M_VerifySSLCert($conn, 1);
    }
} else {
Пример #3
0
 function MCVE_SetSSL(&$conn, $host, $port)
 {
     return M_SetSSL($conn, $host, $port);
 }