Pass report file on to admin users
3677
public static function enable_direct_download() {
    global $pagenow;

    // This check fires on every page load, so keep the scope small
    if ( $pagenow === 'tools.php' && isset( $_GET['report'] ) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification

      // Next check if the request for a report is valid
      // - user be administrator
      // - filename must be of correct form, e.g. 2016-09.html
      if ( current_user_can( 'administrator' ) &&
          preg_match( '/[0-9]{4}-[0-9]{2}\.html/', $_GET['report'], $matches) ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification

        header('Content-type: text/html');
        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_readfile
        readfile( '/data/slog/html/goaccess-' . $matches[0] );
        // Stop executing WordPress once a HTML file has been sent
        exit();
      } else {
        // Yield an error if ?report was requested, but without permissions
        // or with wrong filename.
        exit( 'Report file not found.' );
      }
    }
  }
641454
def prepend_global_admin_user(other_users, server):
    
    cred0 = get_global_login_user(server, "admin")
    if cred0 and cred0["username"] and cred0["password"]:
        log_verbose("Seeding : CRED0 to the front of the line!")
        return [cred0] + other_users if other_users else [cred0]
    else:
        return other_users
433701
function attach($file,$alias=NULL,$cid=NULL) {
		if (!is_file($file))
			user_error(sprintf(self::E_Attach,$file),E_USER_ERROR);
		if ($alias)
			$file=[$alias,$file];
		$this->attachments[]=['filename'=>$file,'cid'=>$cid];
	}
365682
def get_admin():
    '''
        
    '''
    if os.path.isfile(LOGIN_FILENAME):
        with open(LOGIN_FILENAME, 'r') as token_file:
            old_login, old_password = token_file.read().splitlines()[:2]
            return old_login, old_password
    else:
        return None, None
757619
def write_report(self, force=False):
        '''
        
        '''
        path = self.title + '.html'
        value = self._template.format(
            title=self.title, body=self.body, sidebar=self.sidebar)
        write_file(path, value, force=force)
        plt.ion()
1313622
def write_report(filename)
      extension = File.extname(filename)
      report = yield(extension)
      File.open(filename, "wb") do |file|
        file.write(report)
      end
    end
998327
public function Index() {
      $this->Permission('Garden.Import'); // This permission doesn't exist, so only users with Admin == '1' will succeed.
      $Timer = new Gdn_Timer();

      // Determine the current step.
      $this->Form = new Gdn_Form();
      $Imp = new ImportModel();
      $Imp->LoadState();

      // Search for the list of acceptable imports.
      $ImportPaths = array();
      $ExistingPaths = SafeGlob(PATH_UPLOADS.'/export*', array('gz', 'txt'));
      $ExistingPaths2 = SafeGlob(PATH_UPLOADS.'/porter/export*', array('gz'));
      $ExistingPaths = array_merge($ExistingPaths, $ExistingPaths2);
      foreach ($ExistingPaths as $Path)
         $ImportPaths[$Path] = basename($Path);
      // Add the database as a path.
      $ImportPaths = array_merge(array('db:' => T('This Database')), $ImportPaths);

      if($Imp->CurrentStep < 1) {
         // Check to see if there is a file.
         $ImportPath = C('Garden.Import.ImportPath');
         $Validation = new Gdn_Validation();


         if (strcasecmp(Gdn::Request()->RequestMethod(), 'post') == 0) {
            $Upload = new Gdn_Upload();
            $Validation = new Gdn_Validation();
            if (count($ImportPaths) > 0)
               $Validation->ApplyRule('PathSelect', 'Required', T('You must select a file to import.'));

            if (count($ImportPaths) == 0 || $this->Form->GetFormValue('PathSelect') == 'NEW')
               $TmpFile = $Upload->ValidateUpload('ImportFile', FALSE);
            else
               $TmpFile = '';

            if ($TmpFile) {
               $Filename = $_FILES['ImportFile']['name'];
               $Extension = pathinfo($Filename, PATHINFO_EXTENSION);
               $TargetFolder = PATH_ROOT . DS . 'uploads' . DS . 'import';
               if(!file_exists($TargetFolder)) {
                  mkdir($TargetFolder, 0777, TRUE);
               }
               $ImportPath = $Upload->GenerateTargetName(PATH_ROOT . DS . 'uploads' . DS . 'import', $Extension);
               $Upload->SaveAs($TmpFile, $ImportPath);
               $Imp->ImportPath = $ImportPath;
               $this->Form->SetFormValue('PathSelect', $ImportPath);

               $UploadedFiles = GetValue('UploadedFiles', $Imp->Data);
               $UploadedFiles[$ImportPath] = basename($Filename);
               $Imp->Data['UploadedFiles'] = $UploadedFiles;
            } elseif (($PathSelect = $this->Form->GetFormValue('PathSelect'))) {
               if ($PathSelect == 'NEW')
                  $Validation->AddValidationResult('ImportFile', 'ValidateRequired');
               else
                  $Imp->ImportPath = $PathSelect;
            } elseif (!$Imp->ImportPath && count($ImportPaths) == 0) {
               // There was no file uploaded this request or before.
               $Validation->AddValidationResult('ImportFile', $Upload->Exception);
            }

            // Validate the overwrite.
            if(TRUE || strcasecmp($this->Form->GetFormValue('Overwrite'), 'Overwrite') == 0) {
               if (!StringBeginsWith($this->Form->GetFormValue('PathSelect'), 'Db:', TRUE)) {
                  $Validation->ApplyRule('Email', 'Required');
                  if (!$this->Form->GetFormValue('UseCurrentPassword'))
                     $Validation->ApplyRule('Password', 'Required');
               }
            }

            if ($Validation->Validate($this->Form->FormValues())) {
               $this->Form->SetFormValue('Overwrite', 'overwrite');
               $Imp->FromPost($this->Form->FormValues());
               $this->View = 'Info';
            } else {
               $this->Form->SetValidationResults($Validation->Results());
            }
         } else {
            $this->Form->SetFormValue('PathSelect', $Imp->ImportPath);
         }
         $Imp->SaveState();
      } else {
         $this->SetData('Steps', $Imp->Steps());
         $this->View = 'Info';
      }

      if (!StringBeginsWith($Imp->ImportPath, 'db:') && !file_exists($Imp->ImportPath))
         $Imp->DeleteState();

      try {
         $UploadedFiles = GetValue('UploadedFiles', $Imp->Data, array());
         $ImportPaths = array_merge($ImportPaths, $UploadedFiles);
         $this->SetData('ImportPaths', $ImportPaths);
         $this->SetData('Header', $Imp->GetImportHeader());
         $this->SetData('Stats', GetValue('Stats', $Imp->Data, array()));
         $this->SetData('GenerateSQL', GetValue('GenerateSQL', $Imp->Data));
         $this->SetData('ImportPath', $Imp->ImportPath);
         $this->SetData('OriginalFilename', GetValue('OriginalFilename', $Imp->Data));
         $this->SetData('CurrentStep', $Imp->CurrentStep);
         $this->SetData('LoadSpeedWarning', $Imp->LoadTableType(FALSE) == 'LoadTableWithInsert');
      } catch(Gdn_UserException $Ex) {
         $this->Form->AddError($Ex);
         $Imp->SaveState();
         $this->View = 'Index';
      }
      $this->Render();
   }
614392
public function writeReport(Report $report): void
    {
        $xml = new \DOMDocument('1.0', 'UTF-8');

        $root = $xml->createElement('checkstyle');
        $root->setAttribute('version', APP_NAME . '-' . APP_VERSION);

        foreach ($report->getFiles() as $file) {
            $xmlFile = $xml->createElement('file');
            $xmlFile->setAttribute('name', $file->getFilename());

            foreach ($file->getIssues() as $issue) {
                $xmlWarning = $xml->createElement('error');
                $xmlWarning->setAttribute('line', "" . $issue->getLine());
                $xmlWarning->setAttribute('severity', $issue->getSeverity());
                $xmlWarning->setAttribute('message', $issue->getMessage());
                $xmlWarning->setAttribute('source', $issue->getSource());

                if ($issue->getColumn() !== null) {
                    $xmlWarning->setAttribute('column', "" . $issue->getColumn());
                }

                $xmlFile->appendChild($xmlWarning);
            }

            $root->appendChild($xmlFile);
        }

        $xml->appendChild($root);
        $xml->formatOutput = true;

        $this->output->write($xml->saveXML());
    }
777521
def export_admin_action(self, request, queryset):
        
        export_format = request.POST.get('file_format')

        if not export_format:
            messages.warning(request, _('You must select an export format.'))
        else:
            formats = self.get_export_formats()
            file_format = formats[int(export_format)]()

            export_data = self.get_export_data(file_format, queryset, request=request)
            content_type = file_format.get_content_type()
            response = HttpResponse(export_data, content_type=content_type)
            response['Content-Disposition'] = 'attachment; filename=%s' % (
                self.get_export_filename(file_format),
            )
            return response
703021
protected function submitCommandFileManager()
    {
        $result = $this->command->submit($this->data_command, array($this));
        $this->setMessageFileManager($result['message'], $result['severity'], true);
        $this->session->delete('file_manager_selected');
        $this->redirect($result['redirect']);
    }
156608
def open(self):
    """"""
    safe_mkdir(os.path.dirname(self._html_dir))
    self._report_file = open(self.report_path(), 'w')
327421
public function updateReport($idReport, $idSite, $description, $period, $hour, $reportType, $reportFormat, $reports, $parameters, $idSegment = false, $evolutionPeriodFor = 'prev',
                                 $evolutionPeriodN = null)
    {
        Piwik::checkUserIsNotAnonymous();
        Piwik::checkUserHasViewAccess($idSite);

        $scheduledReports = $this->getReports($idSite, $periodSearch = false, $idReport);
        $report   = reset($scheduledReports);
        $idReport = $report['idreport'];

        $currentUser = Piwik::getCurrentUserLogin();
        self::ensureLanguageSetForUser($currentUser);

        self::validateCommonReportAttributes($period, $hour, $description, $idSegment, $reportType, $reportFormat, $evolutionPeriodFor, $evolutionPeriodN);

        // report parameters validations
        $parameters = self::validateReportParameters($reportType, $parameters);

        // validation of requested reports
        $reports = self::validateRequestedReports($idSite, $reportType, $reports);

        $this->getModel()->updateReport($idReport, array(
            'description' => $description,
            'idsegment'   => $idSegment,
            'period'      => $period,
            'hour'        => $hour,
            'type'        => $reportType,
            'format'      => $reportFormat,
            'parameters'  => $parameters,
            'reports'     => $reports,
            'evolution_graph_within_period' => $evolutionPeriodFor == 'each',
            'evolution_graph_period_n' => $evolutionPeriodN ?: ImageGraph::getDefaultGraphEvolutionLastPeriods(),
        ));

        self::$cache = array();
    }
246836
def display_report(report)
      super

      File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents)
      log.log "Created #{ConfigurationLoader::AUTO_GENERATED_FILE}."
      log.log "Run `haml-lint --config #{ConfigurationLoader::AUTO_GENERATED_FILE}`" \
        ", or add `inherits_from: #{ConfigurationLoader::AUTO_GENERATED_FILE}` in a " \
        '.haml-lint.yml file.'
    end
587491
def add_report(self, report, ignore_errors=False):
        """"""

        if not isinstance(report, SignedListReport):
            if ignore_errors:
                return

            raise ArgumentError("You can only add SignedListReports to a UTCAssigner", report=report)

        for reading in report.visible_readings:
            self.add_reading(reading)

        self.add_point(report.report_id, report.sent_timestamp, report.received_time)
1359552
def md_report(self, file_path):
        """"""
        self.logger.debug('Generating MD report')
        report = self.zap.core.mdreport()
        self._write_report(report, file_path)
212851
protected void importUserFromFile() {

        CmsImportUserThread thread = new CmsImportUserThread(
            m_cms,
            m_ou,
            m_userImportList,
            getGroupsList(m_importGroups, true),
            getRolesList(m_importRoles, true),
            m_sendMail.getValue().booleanValue());
        thread.start();
        CmsShowReportDialog dialog = new CmsShowReportDialog(thread, new Runnable() {

            public void run() {

                m_window.close();
            }
        });
        m_window.setContent(dialog);

    }
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }