[[email protected] home]# cat itop.php <?php /** * itop.php - place this file in the ocsreports directory on the OCSInventory server * * This page redirects the browser to the details page (in OCS) for a given named object * basically it transforms the given name into an OCS internal ID. * @param name string Fully Qualified Domain Name (FQDN) of the server */ define(‘OCS_SERVER‘, ‘localhost‘); // Host DB Server define(‘OCS_DB_USER‘, ‘root‘); // User to connect to the OCS DB Server define(‘OCS_DB_PWD‘, ‘*****‘); // Password to connect to the OCS DB Server define(‘OCS_WEB_PATH‘, ‘https://***************/ocsreports/index.php?function=computer&head=1&systemid=3‘); // Path to the OCS details web page $sName = isset($_GET[‘name‘]) ? $_GET[‘name‘] : null; if ($sName != null) { $sSQL = "SELECT ID FROM ocsweb.hardware WHERE CONCAT(NAME,‘.‘,WORKGROUP) = ‘$sName‘"; $link = mysql_connect(OCS_SERVER, OCS_DB_USER, OCS_DB_PWD); if (!$link) { die(‘Could not connect: ‘ . mysql_error()); } $result = mysql_query($sSQL); if (!$result) { echo "<p>Could not successfully run query ($sSQL) from DB: " . mysql_error()."</p>\n"; exit; } if (mysql_num_rows($result) == 0) { echo "<p>Server ‘$sName‘ not found in the OCS database.</p>"; exit; } // We‘re expecting just one row, let‘s read it $row = mysql_fetch_assoc($result); $id = $row["ID"]; // Redirect to the OCS server page $sUrl = OCS_WEB_PATH; //.$id; header("Location: $sUrl"); mysql_close($link); } ?>
时间: 2024-11-01 12:06:20