diff --git a/api/index.php b/api/index.php index 04ec56d..2c7a218 100644 --- a/api/index.php +++ b/api/index.php @@ -1,32 +1,23 @@ $val) echo '$_POST["'.$key.'"]='.$val.'
'; foreach($_GET as $key => $val) echo '$_GET["'.$key.'"]='.$val.'
'; foreach($_SESSION as $key => $val) echo '$_SESSION["'.$key.'"]='.$val.'
'; - */ + /* -$api_key ="TRn9bh2Jg4dw1kBWf35mcF6KDrSNsQixUYZyHuEMCzGt8XL7jepqvoVAaP"; - // Return Ok else NOK //http://YOUR_OSMW_WEBSERVER/api/?api_key=API_KEY_CONFIG&opensim_select=NAME_OPENSIMULATOR&cmd=COMMANDE // COMMANDE FOR SIMULATOR: Start Stop -Restart -Alerte General&msg_alert=MESSAGE -Region Root -Update Client -FCache Assets -FCache ClearF Generate Map +Estate Windlight enable Windlight disable Windlight load -Elevate -Lower StartLogin StopLogin StatusLogin @@ -44,10 +35,17 @@ tmux_kill // COMMANDE FOR TMUX: tmux_load_all tmux_kill_all + +//http://YOUR_OSMW_WEBSERVER/api/?api_key=API_KEY_CONFIG&opensim_select=NAME_OPENSIMULATOR&cmd_gest=COMMANDE +// COMMANDE DE GESTION +list_simu +list_regions + */ require_once ('../inc/config/config.php'); +require_once ('../inc/config/fonctions.php'); if ($_GET['api_key'] == $api_key || $_POST['api_key'] == $api_key) { $_SESSION['authentification_api'] = "autorized"; @@ -104,25 +102,19 @@ if (isset($_SESSION['authentification_api'])) $messageInfo = "OK"; } - if($_GET['cmd'] == 'Restart') {$parameters = array('command' => 'restart');} - if($_GET['cmd'] == 'Alerte General') {$parameters = array('command' => 'alert '.$_GET["msg_alert"]);} - if($_GET['cmd'] == 'Region Root') {$parameters = array('command' => 'change region root');} - if($_GET['cmd'] == 'Update Client') {$parameters = array('command' => 'force update');} - if($_GET['cmd'] == 'FCache Assets') {$parameters = array('command' => 'fcache assets');} - if($_GET['cmd'] == 'FCache ClearF') {$parameters = array('command' => 'fcache clear file');} + if($_GET['cmd'] == 'Update Client') {$parameters = array('command' => 'force update');} if($_GET['cmd'] == 'Generate Map') {$parameters = array('command' => 'generate map');} + if($_GET['cmd'] == 'Windlight enable') {$parameters = array('command' => 'windlight enable');} if($_GET['cmd'] == 'Windlight disable') {$parameters = array('command' => 'windlight disable');} if($_GET['cmd'] == 'Windlight load') {$parameters = array('command' => 'windlight load');} - if($_GET['cmd'] == 'Elevate') {$parameters = array('command' => 'terrain elevate 1');} - if($_GET['cmd'] == 'Lower') {$parameters = array('command' => 'terrain lower 1');} + if($_GET['cmd'] == 'StartLogin') {$parameters = array('command' => 'login enable');} if($_GET['cmd'] == 'StopLogin') {$parameters = array('command' => 'login disable');} if($_GET['cmd'] == 'StatusLogin') {$parameters = array('command' => 'login status');} + if($_GET['cmd'] == 'kick_user') { $kick = 'kick user '.$_GET["avatar_name"].' ejected by administrator.' ;$parameters = array('command' => $kick );} if($_GET['cmd'] == 'appearance_user') { $appearance = 'appearance show '.$_GET["avatar_name"] ;$parameters = array('command' => $appearance );} - if($_GET['cmd'] == 'estate_name') {$estate_name = 'estate set name 101 "'.$_GET["estate_name"].'"' ;$parameters = array('command' => $estate_name );} - if($_GET['cmd'] == 'estate_owner') {$estate_owner = 'estate set owner 101 '.$_GET["estate_owner"] ;$parameters = array('command' => $estate_owner );} if($_GET['cmd']<>"") { $myRemoteAdmin = new RemoteAdmin(trim($hostname), trim($RemotePort), trim($access_password2)); @@ -181,42 +173,30 @@ if (isset($_SESSION['authentification_api'])) } } //################################################################################################################# + if (isset($_GET['cmd_gest'])) + { + + $osmw_simu =$_GET['opensim_select']; + // on se connecte a MySQL + try{$bdd = new PDO('mysql:host='.$hostnameBDD.';dbname='.$database.';charset=utf8', $userBDD, $passBDD);} + catch (Exception $e){ die('Erreur : ' . $e->getMessage()); } + + if($_GET['cmd_tmux'] == 'list_simu') + { + + $messageInfo = "OK"; + } + if($_GET['cmd_tmux'] == 'list_regions') + { + + $messageInfo = "OK"; + } + } + //################################################################################################################# echo $messageInfo; $_SESSION = array(); } else {echo "NO API KEY";} -//-------------------------------------------------------------------------------------------- - /* Fonction envoi commande SSH */ - function CommandeSSH($hostname2,$usernameSSH2,$passwordSSH2,$commande) - { - if($commande <> '') - { - if (!function_exists("ssh2_connect")) die(" function ssh2_connect doesn't exist"); - // log in at server1.example.com on port 22 - if(!($con = ssh2_connect($hostname2, 22))){ - echo " fail: unable to establish connection\n"; - } else - {// try to authenticate with username root, password secretpassword - if(!ssh2_auth_password($con,$usernameSSH2,$passwordSSH2)) { - echo "fail: unable to authenticate\n"; - } else { - //echo " ok: logged in...\n"; - if (!($stream = ssh2_exec($con, $commande ))) { - echo " fail: unable to execute command\n"; - } else { - // collect returning data from command - stream_set_blocking($stream, true); $data = ""; - while ($buf = fread($stream,4096)) - { - $data .= $buf."\n";} - // echo $data; - fclose($stream); - } - } - } - return $data; - } - } ?> diff --git a/install.php b/install.php index 9a8cabb..d4e5f91 100644 --- a/install.php +++ b/install.php @@ -107,6 +107,11 @@ $userBDD = "'. $login .'"; // login $passBDD = "'. $pass .'"; // password $database = "'. $base .'"; // Name of BDD +$hostname = "ip_host"; +$usernameSSH = "user_ssh_tmux"; +$passwordSSH = "pass_user_tmux"; + +$api_key =""; /* Position center of your MAP */ $px = 7000;