} else { $sOutputData = $sCSVData; } if ($sFileName == '') { // Plain text => Firefox will NOT propose to download the file $oP->add_header("Content-type: text/plain; charset={$sCharset}"); } else { $oP->add_header("Content-type: text/csv; charset={$sCharset}"); } $oP->add($sOutputData); $oP->TrashUnexpectedOutput(); $oP->output(); exit; } else { $oP->add('<div class="page_header"><h1>Audit Errors: <span class="hilite">' . $oAuditRule->Get('description') . '</span></h1><img style="margin-top: -20px; margin-right: 10px; float: right;" src="../images/stop.png"/></div>'); $oP->p('<a href="./audit.php?' . $oAppContext->GetForLink() . '">[Back to audit results]</a>'); $sBlockId = 'audit_errors'; $oP->p("<div id=\"{$sBlockId}\" style=\"clear:both\">\n"); $oBlock = DisplayBlock::FromObjectSet($oErrorObjectSet, 'csv'); $oBlock->Display($oP, 1); $oP->p("</div>\n"); // Adjust the size of the Textarea containing the CSV to fit almost all the remaining space $oP->add_ready_script(" \$('#1>textarea').height(400);"); // adjust the size of the block $sExportUrl = utils::GetAbsoluteUrlAppRoot() . "pages/audit.php?operation=csv&category=" . $oAuditCategory->GetKey() . "&rule=" . $oAuditRule->GetKey(); $oP->add_ready_script("\$('a[href*=\"webservices/export.php?expression=\"]').attr('href', '" . $sExportUrl . "&filename=audit.csv" . $sAdvanced . "');"); $oP->add_ready_script("\$('#1 :checkbox').removeAttr('onclick').click( function() { var sAdvanced = ''; if (this.checked) sAdvanced = '&advanced=1'; window.location.href='{$sExportUrl}'+sAdvanced; } );"); } break; case 'errors': $iCategory = utils::ReadParam('category', '');
$oP->p("ERROR: Missing argument '{$sParam}'\n"); UsageAndExit($oP); } return trim($sValue); } ///////////////////////////////// // Main program if (utils::IsModeCLI()) { $oP = new CLIPage("iTop - Bulk import"); } else { $oP = new CSVPage("iTop - Bulk import"); } 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'); $sCsvFile = ReadMandatoryParam($oP, 'csvfile', '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}')");