function handle_action_rdp($MAPCFG, $objId) { $host_name = $MAPCFG->getValue($objId, 'host_name'); $domain = $MAPCFG->getValue($objId, 'domain'); $username = $MAPCFG->getValue($objId, 'username'); // Get the host address! erm ... looks a little complicated... global $_BACKEND; $backendIds = $MAPCFG->getValue($objId, 'backend_id'); $OBJ = new NagVisHost($backendIds, $host_name); $OBJ->setConfiguration($MAPCFG->getMapObject($objId)); $OBJ->queueState(GET_STATE, DONT_GET_SINGLE_MEMBER_STATES); $_BACKEND->execute(); $OBJ->applyState(); $host_address = $OBJ->getStateAttr(ADDRESS); // Now generate the .rdp file for the user which is then (hopefully) handled // correctly by the users browser. header('Content-Type: application/rdp; charset=utf-8'); header('Content-Disposition: attachment; filename=' . $host_name . '.rdp'); echo 'full address:s:' . $host_address . "\n"; if ($domain) { echo 'domain:s:' . $domain . "\n"; } if ($username) { echo 'username:s:' . $username . "\n"; } }
function handle_action_win_ssh($MAPCFG, $objId) { $host_name = $MAPCFG->getValue($objId, 'host_name'); // Get the host address! erm ... looks a little complicated... global $_BACKEND; $backendIds = $MAPCFG->getValue($objId, 'backend_id'); $OBJ = new NagVisHost($backendIds, $host_name); $OBJ->setConfiguration($MAPCFG->getMapObject($objId)); $OBJ->queueState(GET_STATE, DONT_GET_SINGLE_MEMBER_STATES); $_BACKEND->execute(); $OBJ->applyState(); $host_address = $OBJ->getStateAttr(ADDRESS); // Now generate the .cmd file for the user which is then (hopefully) handled // correctly by the users browser. header('Content-Type: application/cmd; charset=utf-8'); header('Content-Disposition: attachment; filename=' . $host_name . '.cmd'); echo "@echo off\n"; echo "REM # This file has been generated by NagVis.\n"; echo "REM # \n"; echo "REM # Simply execute the file to connect to the host via SSH. We assume\n"; echo "REM # that you have putty installed and in your system path.\n"; echo "putty -ssh " . $host_address . " 22\n"; }