$sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
    UserRights::Login($sAuthUser);
    // Login & set the user's language
} else {
    $oP->p("Access restricted or wrong credentials ('{$sAuthUser}')");
    $oP->output();
    exit - 1;
}
$iStepCount = ReadMandatoryParam($oP, 'step_count');
$oP->p('Executing a partial synchro - step ' . $iStepCount);
$iSource = ReadMandatoryParam($oP, 'source');
$iStatLog = ReadMandatoryParam($oP, 'log');
$iChange = ReadMandatoryParam($oP, 'change');
$sLastFullLoad = ReadMandatoryParam($oP, 'last_full_load', 'raw_data');
$iChunkSize = ReadMandatoryParam($oP, 'chunk');
$oP->p('Last full load: ' . $sLastFullLoad);
$oP->p('Chunk size: ' . $iChunkSize);
$oP->p('Source: ' . $iSource);
try {
    $oSynchroDataSource = MetaModel::GetObject('SynchroDataSource', $iSource);
    $oLog = MetaModel::GetObject('SynchroLog', $iStatLog);
    $oChange = MetaModel::GetObject('CMDBChange', $iChange);
    if (strlen($sLastFullLoad) > 0) {
        $oLastFullLoad = new DateTime($sLastFullLoad);
        $oSynchroExec = new SynchroExecution($oSynchroDataSource, $oLastFullLoad);
    } else {
        $oSynchroExec = new SynchroExecution($oSynchroDataSource);
    }
    if ($oSynchroExec->DoSynchronizeChunk($oLog, $oChange, $iChunkSize)) {
        // The last line MUST follow this convention
Example #2
0
} else {
    $oP = new WebPage("iTop - CRON");
}
try {
    utils::UseParamFile();
} catch (Exception $e) {
    $oP->p("Error: " . $e->GetMessage());
    $oP->output();
    exit - 2;
}
if (utils::IsModeCLI()) {
    // Next steps:
    //   specific arguments: 'csvfile'
    //
    $sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
    $sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
    if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
        UserRights::Login($sAuthUser);
        // Login & set the user's language
    } else {
        $oP->p("Access wrong credentials ('{$sAuthUser}')");
        $oP->output();
        exit - 1;
    }
} else {
    $_SESSION['login_mode'] = 'basic';
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
}
if (!UserRights::IsAdministrator()) {
Example #3
0
        exit - 1;
    }
    $sCSVData = file_get_contents($sCsvFile);
} else {
    $_SESSION['login_mode'] = 'basic';
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
    $sCSVData = utils::ReadPostedParam('csvdata', '', false, 'raw_data');
}
try {
    //////////////////////////////////////////////////
    //
    // Read parameters
    //
    $iDataSourceId = ReadMandatoryParam($oP, 'data_source_id', 'raw_data');
    $sSynchronize = ReadParam($oP, 'synchronize');
    $sSep = ReadParam($oP, 'separator', 'raw_data');
    $sQualifier = ReadParam($oP, 'qualifier', 'raw_data');
    $sCharSet = ReadParam($oP, 'charset', 'raw_data');
    $sDateFormat = ReadParam($oP, 'date_format', 'raw_data');
    $sOutput = ReadParam($oP, 'output');
    //	$sReportLevel = ReadParam($oP, 'reportlevel');
    $sSimulate = ReadParam($oP, 'simulate');
    $sComment = ReadParam($oP, 'comment', 'raw_data');
    $sNoStopOnImportError = ReadParam($oP, 'no_stop_on_import_error');
    if (strtolower(trim($sSep)) == 'tab') {
        $sSep = "\t";
    }
    $oLoadStartDate = new DateTime();
    // Now
Example #4
0
    echo "<h3>Existing tests</h3>\n";
    echo "<ul>\n";
    foreach (get_declared_classes() as $sClassName) {
        if (!IsAValidTestClass($sClassName)) {
            continue;
        }
        $sName = call_user_func(array($sClassName, 'GetName'));
        $sDescription = call_user_func(array($sClassName, 'GetDescription'));
        echo "<li><a href=\"?todo=exec&testid={$sClassName}\">{$sName}</a> ({$sDescription})</li>\n";
    }
    echo "</ul>\n";
} else {
    if ($sTodo == 'exec') {
        // Execute a test
        //
        $sTestClass = ReadMandatoryParam("testid");
        if (!IsAValidTestClass($sTestClass)) {
            echo "<p>Wrong value for testid, expecting a valid class name</p>\n";
        } else {
            $oTest = new $sTestClass();
            $iStartLine = GetTestClassLine($sTestClass);
            echo "<h3>Testing: " . $oTest->GetName() . "</h3>\n";
            echo "<h6>testlist.inc.php: {$iStartLine}</h6>\n";
            $bRes = $oTest->Execute();
        }
        /*
        MyHelpers::var_dump_html($oTest->GetResults());
        MyHelpers::var_dump_html($oTest->GetWarnings());
        MyHelpers::var_dump_html($oTest->GetErrors());
        */
        if ($bRes) {
Example #5
0
    }
    $sCSVData = file_get_contents($sCsvFile);
} else {
    $_SESSION['login_mode'] = 'basic';
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
    $sCSVData = utils::ReadPostedParam('csvdata', '', 'raw_data');
}
try {
    $aWarnings = array();
    //////////////////////////////////////////////////
    //
    // Read parameters
    //
    $sClass = ReadMandatoryParam($oP, 'class', 'raw_data');
    // do not filter as a valid class, we want to produce the report "wrong class" ourselves
    $sSep = ReadParam($oP, 'separator', 'raw_data');
    $sQualifier = ReadParam($oP, 'qualifier', 'raw_data');
    $sCharSet = ReadParam($oP, 'charset', 'raw_data');
    $sDateFormat = ReadParam($oP, 'date_format', 'raw_data');
    $sOutput = ReadParam($oP, 'output', 'string');
    $sReconcKeys = ReadParam($oP, 'reconciliationkeys', 'raw_data');
    $sSimulate = ReadParam($oP, 'simulate');
    $sComment = ReadParam($oP, 'comment', 'raw_data');
    $bLocalize = ReadParam($oP, 'no_localize') != 1;
    if (strtolower(trim($sSep)) == 'tab') {
        $sSep = "\t";
    }
    //////////////////////////////////////////////////
    //
Example #6
0
    $oP = new WebPage(Dict::S("TitleSynchroExecution"));
}
try {
    utils::UseParamFile();
} catch (Exception $e) {
    $oP->p("Error: " . $e->GetMessage());
    $oP->output();
    exit - 2;
}
if (utils::IsModeCLI()) {
    // Next steps:
    //   specific arguments: 'csvfile'
    //
    $sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
    $sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd', 'raw_data');
    $sDataSourcesList = ReadMandatoryParam($oP, 'data_sources', 'raw_data');
    // May contain commas
    if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
        UserRights::Login($sAuthUser);
        // Login & set the user's language
    } else {
        $oP->p("Access restricted or wrong credentials ('{$sAuthUser}')");
        $oP->output();
        exit - 1;
    }
} else {
    require_once APPROOT . '/application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
    $sDataSourcesList = utils::ReadParam('data_sources', null, true, 'raw_data');
    if ($sDataSourcesList == null) {
Example #7
0
// Main program
set_time_limit(0);
if (utils::IsModeCLI()) {
    $oP = new CLIPage("iTop - Database Backup");
} else {
    $oP = new WebPage("iTop - Database Backup");
}
try {
    utils::UseParamFile();
} catch (Exception $e) {
    ExitError($oP, $e->GetMessage());
}
if (utils::IsModeCLI()) {
    $oP->p(date('Y-m-d H:i:s') . " - running backup utility");
    $sAuthUser = ReadMandatoryParam($oP, 'auth_user');
    $sAuthPwd = ReadMandatoryParam($oP, 'auth_pwd');
    $bDownloadBackup = false;
    if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
        UserRights::Login($sAuthUser);
        // Login & set the user's language
    } else {
        ExitError($oP, "Access restricted or wrong credentials ('{$sAuthUser}')");
    }
} else {
    require_once APPROOT . 'application/loginwebpage.class.inc.php';
    LoginWebPage::DoLogin();
    // Check user rights and prompt if needed
    $bDownloadBackup = utils::ReadParam('download', false);
}
if (!UserRights::IsAdministrator()) {
    ExitError($oP, "Access restricted to administors");
Example #8
0
function RaiseAlarm($sMessage)
{
    echo "{$sMessage}\n";
    try {
        $sTicketLogin = ReadMandatoryParam('check_ticket_login');
        $sTicketPwd = ReadMandatoryParam('check_ticket_pwd');
        $sTicketTitle = ReadMandatoryParam('check_ticket_title');
        $sTicketCustomer = ReadMandatoryParam('check_ticket_customer');
        $sTicketService = ReadMandatoryParam('check_ticket_service');
        $sTicketSubcategory = ReadMandatoryParam('check_ticket_service_subcategory');
        $sTicketWorkgroup = ReadMandatoryParam('check_ticket_workgroup');
        $sTicketImpactedServer = ReadMandatoryParam('check_ticket_impacted_server');
    } catch (Exception $e) {
        echo "The ticket could not be created: " . $e->GetMessage() . "\n";
        return;
    }
    $sMessage = "Server: [[Server:" . $sTicketImpactedServer . "]]\n" . $sMessage;
    require_once APPROOT . 'webservices/itopsoaptypes.class.inc.php';
    //$sItopRootDefault = 'http'.((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off')) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].dirname($_SERVER['SCRIPT_NAME']).'/../..';
    //$sItopRoot = utils::ReadParam('check_ticket_itop', $sItopRootDefault);
    $sItopRoot = ReadMandatoryParam('check_ticket_itop');
    $sWsdlUri = $sItopRoot . '/webservices/itop.wsdl.php';
    //$sWsdlUri .= '?service_category=';
    $aSOAPMapping = SOAPMapping::GetMapping();
    ini_set("soap.wsdl_cache_enabled", "0");
    $oSoapClient = new SoapClient($sWsdlUri, array('trace' => 1, 'classmap' => $aSOAPMapping));
    try {
        $oRes = $oSoapClient->CreateIncidentTicket($sTicketLogin, $sTicketPwd, $sTicketTitle, $sMessage, null, new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', $sTicketCustomer))), new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', $sTicketService))), new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', $sTicketSubcategory))), '', new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', $sTicketWorkgroup))), array(new SOAPLinkCreationSpec('Server', array(new SOAPSearchCondition('name', $sTicketImpactedServer)), array())), '1', '1');
    } catch (Exception $e) {
        echo "The ticket could not be created: SOAP Exception = '" . $e->getMessage() . "'\n";
    }
    //echo "<pre>\n";
    //print_r($oRes);
    //echo "</pre>\n";
    if ($oRes->status) {
        $sTicketName = $oRes->result[0]->values[1]->value;
        echo "Created ticket: {$sTicketName}\n";
    } else {
        echo "ERROR: Failed to create the ticket in target iTop ({$sItopRoot})\n";
        foreach ($oRes->errors->messages as $oMessage) {
            echo $oMessage->text . "\n";
        }
    }
}