Example #1
0
function bulkInsertDevices($devicesList, $description)
{
    //Split the string up
    $devices = explode(",", $devicesList);
    //Trim the description
    $description = trim($description);
    //Loop through each device name and call insertDevice
    foreach ($devices as $dev) {
        $dev = trim($dev);
        if (!insertDevice($dev, $description)) {
            //On failure to add record, abort
            return false;
        }
    }
    //Notify the caller that everything went well
    return true;
}
Example #2
0
require_once "system/smtp.php";
require_once "model/required.fields.php";
onlineSystem();
// Inclui o controle solicitado na URL
if (router(0) != "") {
    // Para inclusão dos arquivos Model
    if (router(0) == "model") {
        if (file_exists("model/" . router(1) . ".php") == true) {
            include_once "model/" . router(1) . ".php";
        } else {
            // Carrega o contador sempre que chamar a home
            insertVisitor();
            insertDevice();
            include_once "controller/home.php";
        }
    } else {
        if (file_exists("controller/" . router(0) . ".php") == true) {
            // Carrega o contador de visitas apenas nos controladores de view
            insertVisitor();
            insertDevice();
            include_once "controller/" . router(0) . ".php";
        } else {
            include_once "controller/404.php";
        }
    }
} else {
    // Carrega o contador sempre que chamar a home
    insertVisitor();
    insertDevice();
    include_once "controller/home.php";
}
Example #3
0
 */
require_once "../database/database.php";
require_once "../database/devices.php";
require_once "../model/device.php";
if (!isset($_POST['DeviceName'])) {
    //Exit if a list of devices wasn't provided
    exit;
}
//Get the device name
$hostName = $_POST['DeviceName'];
//Check to see if the username was included.
if (isset($_POST['Username'])) {
    $username = $_POST['Username'];
} else {
    $username = "";
}
//Set Last Check In Time
$checkIn = time();
//Check to see if the device exists in the database, If not, create it
$deviceExists = apiSearchDeviceByHostname($hostName);
if ($deviceExists == 0) {
    $insertResult = insertDevice($hostName, "");
    if ($insertResult == 0) {
        //Failed to insert the device, exit
        echo "Failed to create new device";
        exit;
    }
}
//Update the device
$updateResult = apiUpdateDevice($hostName, $username, $checkIn);
echo $updateResult;