function sync($ct_id, $insert_into_failed) { $openqrm_server = new openqrm_server(); $OPENQRM_SERVER_IP_ADDRESS = $openqrm_server->get_ip_address(); $this->get_instance_by_id($ct_id); // get cloud user $local_transaction_cloud_user = new clouduser(); $local_transaction_cloud_user->get_instance_by_id($this->cu_id); // get cloud-zones config parameters from main config $cz_conf = new cloudconfig(); $cloud_zones_master_ip = $cz_conf->get_value(36); // 36 is cloud_zones_master_ip // check if cloud_external_ip is set $cloud_external_ip = $cz_conf->get_value(37); // 37 is cloud_external_ip if (!strlen($cloud_external_ip)) { $cloud_external_ip = $openqrm_server->get_ip_address(); } // get the admin user, the zone master will automatically authenticate against this user $openqrm_admin_user = new user("openqrm"); $openqrm_admin_user->set_user(); // url for the wdsl $url = "https://" . $cloud_zones_master_ip . "/openqrm/boot-service/cloud-zones-soap.wsdl"; // turn off the WSDL cache ini_set("soap.wsdl_cache_enabled", "0"); // create the soap-client $client = new SoapClient($url, array('soap_version' => SOAP_1_2, 'trace' => 1, 'login' => $openqrm_admin_user->name, 'password' => $openqrm_admin_user->password)); // var_dump($client->__getFunctions()); try { $send_transaction_parameters = $openqrm_admin_user->name . "," . $openqrm_admin_user->password . "," . $cloud_external_ip . "," . $local_transaction_cloud_user->name . "," . $this->id . "," . $this->time . "," . $this->cr_id . "," . $this->ccu_charge . "," . $this->reason . "," . $this->comment; $new_local_ccu_value = $client->CloudZonesSync($send_transaction_parameters); // update users ccus values with return from master $local_transaction_cloud_user->set_users_ccunits($this->cu_id, $new_local_ccu_value); $this->_event->log("push", $_SERVER['REQUEST_TIME'], 5, "cloudtransaction.class.php", "Synced transaction! User:"******"/CR:" . $this->cr_id . "/Global CCU:" . $new_local_ccu_value, "", "", 0, 0, 0); return true; } catch (Exception $e) { $soap_error_msg = $e->getMessage(); $this->_event->log("push", $_SERVER['REQUEST_TIME'], 2, "cloudtransaction.class.php", "Could not sync transaction! User:"******"/CR:" . $this->cr_id . "/Charge:" . $this->ccu_charge . "/" . $soap_error_msg, "", "", 0, 0, 0); if ($insert_into_failed) { // add to failed transactions $cloudtransactionfailed = new cloudtransactionfailed(); $failed_transaction_fields['tf_id'] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0")); $failed_transaction_fields['tf_ct_id'] = $ct_id; $cloudtransactionfailed->add($failed_transaction_fields); } return false; } }