Exemple #1
0
function ReportErrorAndUsage($sErrorMessage)
{
    if (utils::IsModeCLI()) {
        $oP = new CLIPage("iTop - Export");
        $oP->p('ERROR: ' . $sErrorMessage);
        Usage($oP);
        $oP->output();
        exit - 1;
    } else {
        $oP = new WebPage("iTop - Export");
        $oP->p('ERROR: ' . $sErrorMessage);
        Usage($oP);
        $oP->output();
        exit - 1;
    }
}
    $sValue = utils::ReadParam($sParam, null, true, $sSanitizationFilter);
    if (is_null($sValue)) {
        $oP->p("ERROR: Missing argument '{$sParam}'\n");
        exit(29);
    }
    return trim($sValue);
}
/////////////////////////////////
// Main program
if (!utils::IsModeCLI()) {
    $oP = new WebPage(Dict::S("TitleSynchroExecution"));
    $oP->p("This page is used internally by iTop");
    $oP->output();
    exit - 2;
}
$oP = new CLIPage(Dict::S("TitleSynchroExecution"));
try {
    utils::UseParamFile();
} catch (Exception $e) {
    $oP->p("Error: " . $e->GetMessage());
    $oP->output();
    exit - 2;
}
// 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
Exemple #3
0
require_once APPROOT . '/application/startup.inc.php';
try {
    // Do this before loging, in order to allow setting user credentials from within the file
    utils::UseParamFile();
} catch (Exception $e) {
    echo "Error: " . $e->GetMessage() . "<br/>\n";
    exit - 2;
}
if (utils::IsModeCLI()) {
    $sAuthUser = utils::ReadParam('auth_user', null, true, 'raw_data');
    $sAuthPwd = utils::ReadParam('auth_pwd', null, true, 'raw_data');
    if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) {
        UserRights::Login($sAuthUser);
        // Login & set the user's language
    } else {
        $oP = new CLIPage("iTop - Export");
        $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
}
ApplicationContext::SetUrlMakerClass('iTopStandardURLMaker');
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', '');
$bLocalize = utils::ReadParam('no_localize', 0) != 1;
$sFileName = utils::ReadParam('filename', '', true, 'string');