|
| 1 | +<?php |
| 2 | + |
| 3 | +$username = 'admin'; |
| 4 | +$password = 'admin'; |
| 5 | + |
| 6 | +$soap_location = 'http://localhost:8080/remote/index.php'; |
| 7 | +$soap_uri = 'http://localhost:8080/remote/'; |
| 8 | + |
| 9 | +$client = new SoapClient(null, array('location' => $soap_location, |
| 10 | + 'uri' => $soap_uri)); |
| 11 | +try { |
| 12 | + if($session_id = $client->login($username,$password)) { |
| 13 | + echo "Logged:".$session_id."<br />\n"; |
| 14 | +} |
| 15 | + |
| 16 | +$database_type = 'mysql'; //Only mysql type avaliable more types coming soon. |
| 17 | +$database_name = 'yourdbname'; |
| 18 | +$database_username = 'yourusername'; |
| 19 | +$database_password = 'yourpassword'; |
| 20 | +$database_charset = ''; // blank = db default, latin1 or utf8 |
| 21 | +$database_remoteips = ''; //remote ip´s separated by commas |
| 22 | + |
| 23 | +$params = array( |
| 24 | + 'server_id' => 1, |
| 25 | + 'type' => $database_type, |
| 26 | + 'database_name' => $database_name, |
| 27 | + 'database_user' => $database_username, |
| 28 | + 'database_password' => $database_password, |
| 29 | + 'database_charset' => $database_charset, |
| 30 | + 'remote_access' => 'n', // n disabled - y enabled |
| 31 | + 'active' => 'y', // n disabled - y enabled |
| 32 | + 'remote_ips' => $database_remoteips |
| 33 | + ); |
| 34 | + |
| 35 | +$client_id = 1; |
| 36 | +$database_id = $client->sites_database_add($session_id, $client_id, $params); |
| 37 | + |
| 38 | +if($client->logout($session_id)) { |
| 39 | + echo "Logout.<br />\n"; |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +} catch (SoapFault $e) { |
| 44 | + die('Error: '.$e->getMessage()); |
| 45 | +} |
| 46 | + |
| 47 | +?> |
| 48 | + |
0 commit comments