/** * Outputs all the runs info in a one row table. * * @return string HTML */ protected function output_runs_info() { if (!$this->report->get_runs()) { return false; } // Is the web interface read only?. $properties = properties_reader::get('readonlyweb'); $runsinfo = array(); foreach ($this->report->get_runs() as $run) { // Run vars. $runinfo = $run->get_run_info(); $filenamestr = 'filename=' . $run->get_filename(false); // Link to download the run. $runinfo->downloadlink = '<a href="download_run.php?' . $filenamestr . '">Download</a>'; // Only if the web is read/write. if (empty($properties['readonlyweb'])) { // Link to delete the run. $returnurlstr = 'returnurl=' . urlencode('timestamps[]=' . implode('×tamps[]=', $_GET['timestamps'])); $runinfo->deletelink = '<a href="delete_run.php?' . $filenamestr . '&' . $returnurlstr . '" class="delete-run">Delete</a>'; } $runsinfo[] = $this->get_info_container($runinfo); } $output = '<div id="confirm-delete-dialog" title="Delete" class=""><p>Are you sure you want to delete this run?</p></div>'; $output .= $this->create_table('Runs information', $runsinfo, count($runsinfo), '', 'runs-info'); return $output; }
/** * Gets the default thresholds. * * Hopefully your eyes will not burn after reading this function's code. * * Uses the .properties files looking for the threshold values. Gives preference to * $thresholds array over $groupedthreshold and $singlestepthreshold. * * @return array Format: array('bystep' => array('dbreads' => 1, 'dbwrites' => ...), 'total' => array('dbreads' => 2, 'dbwrites'...)) */ protected function get_default_thresholds() { // Read values from the properties file. $vars = array('groupedthreshold', 'singlestepthreshold', 'thresholds'); $properties = properties_reader::get($vars); // There will always be a value in defaults.properties. if (empty($properties['groupedthreshold']) || empty($properties['singlestepthreshold'])) { die('Error: defaults.properties thresholds values can not be found' . PHP_EOL); } // Preference to $thresholds. if (!empty($properties['thresholds'])) { return json_decode($properties['thresholds'], true); } // Generate the default thresholds array. $thresholds = array('bystep' => array(), 'total' => array()); foreach (test_plan_run::$runvars as $var) { $thresholds['bystep'][$var] = $properties['singlestepthreshold']; $thresholds['total'][$var] = $properties['groupedthreshold']; } return $thresholds; }
<?php include __DIR__ . '/webapp/inc.php'; $properties = properties_reader::get('readonlyweb'); if (!empty($properties['readonlyweb'])) { die('Error: You are not allowed to perform write actions from the web interface'); } if (!($filename = $_GET['filename'])) { die('Error: No filename to delete'); } if (!preg_match('/^\\d*$/', $filename, $matches)) { die('Error: Incorrect filename'); } $returnurl = urldecode($_GET['returnurl']); $run = new test_plan_run($filename); if (!$run->delete()) { echo '<b>Error: There was a problem deleting the file</b>'; } else { echo '<p>Run deleted</p>'; // Remove the deleted one. $timestamps = explode('&', $returnurl); foreach ($timestamps as $key => $timestamp) { if (strstr($timestamp, $filename) != false) { unset($timestamps[$key]); } } $returnurl = implode('&', $timestamps); } // Link to return to the index. echo '<br/><br/><a href="index.php?' . $returnurl . '">Return to the runs page</a>';