public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_title = $result_file->get_title();
     echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL;
     $new_title = pts_user_io::prompt_user_input('Enter New Title');
     if (!empty($new_title)) {
         $result_file->set_title($new_title);
     }
     $result_description = $result_file->get_description();
     echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL;
     $new_description = pts_user_io::prompt_user_input('Enter New Description');
     if (!empty($new_description)) {
         $result_file->set_description($new_description);
     }
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_title = $result_file->get_title();
     echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL;
     $new_title = pts_user_io::prompt_user_input('Enter New Title');
     if (!empty($new_title)) {
         $result_title = $new_title;
     }
     $result_description = $result_file->get_description();
     echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL;
     $new_description = pts_user_io::prompt_user_input('Enter New Description');
     if (!empty($new_description)) {
         $result_description = $new_description;
     }
     $result_file_writer = new pts_result_file_writer();
     $result_file_writer->add_result_file_meta_data($result_file, null, $new_title, $new_description);
     $result_file_writer->add_system_information_from_result_file($result_file);
     $result_file_writer->add_results_from_result_file($result_file);
     pts_client::save_test_result($r[0] . '/composite.xml', $result_file_writer->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($r)
 {
     $_REQUEST['force_format'] = 'PNG';
     // Force to PNG renderer
     $_REQUEST['svg_dom_gd_no_interlacing'] = true;
     // Otherwise FPDF will fail
     $tdir = pts_client::create_temporary_directory();
     pts_client::generate_result_file_graphs($r[0], $tdir);
     $result_file = new pts_result_file($r[0]);
     $pdf = new pts_pdf_template($result_file->get_title(), null);
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38);
     $pdf->Ln(120);
     $pdf->WriteStatementCenter('www.phoronix-test-suite.com');
     $pdf->Ln(15);
     $pdf->WriteBigHeaderCenter($result_file->get_title());
     $pdf->WriteText($result_file->get_description());
     $pdf->AddPage();
     $pdf->Ln(15);
     $pdf->SetSubject($result_file->get_title() . ' Benchmarks');
     //$pdf->SetKeywords(implode(', ', $identifiers));
     $pdf->WriteHeader('Test Systems:');
     foreach ($result_file->get_systems() as $s) {
         $pdf->WriteMiniHeader($s->get_identifier());
         $pdf->WriteText($s->get_hardware());
         $pdf->WriteText($s->get_software());
         //$pdf->WriteText($notes_r[$i]);
     }
     /*
     if(count($identifiers) > 1 && is_file($tdir . 'result-graphs/overview.jpg'))
     {
     	$pdf->AddPage();
     	$pdf->Ln(100);
     	$pdf->Image($tdir . 'result-graphs/overview.jpg', 15, 40, 180);
     }
     */
     $pdf->AddPage();
     $placement = 1;
     $results = $result_file->get_result_objects();
     for ($i = 1; $i <= count($results); $i++) {
         if (is_file($tdir . 'result-graphs/' . $i . '.png')) {
             $pdf->Ln(100);
             $pdf->Image($tdir . 'result-graphs/' . $i . '.png', 50, 40 + ($placement - 1) * 120, 120);
         }
         if ($placement == 2) {
             $placement = 0;
             if ($i != count($results)) {
                 $pdf->AddPage();
             }
         }
         $placement++;
     }
     // To save:
     /*
     $pdf_file = 'SAVE_TO';
     
     if(substr($pdf_file, -4) != '.pdf')
     {
     	$pdf_file .= '.pdf';
     }
     */
     $pdf_file = pts_client::user_home_directory() . $r[0] . '.pdf';
     $pdf->Output($pdf_file);
     pts_file_io::delete($tdir, null, true);
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
 }
 public static function search_test_results($query, $search = 'RESULTS')
 {
     $matches = array();
     foreach (self::test_results_by_date() as $file) {
         $result_file = new pts_result_file($file);
         if (($search == 'ALL' || $search == 'INFO') && (stripos($result_file->get_title(), $query) !== false || stripos($result_file->get_description(), $query) !== false)) {
             array_push($matches, $file);
             continue;
         }
         if ($search == 'ALL' || $search == 'SYSTEM_INFO') {
             $matched = false;
             foreach ($result_file->get_systems() as $s) {
                 if (stripos($s->get_software(), $query) !== false || stripos($s->get_identifier(), $query) !== false || stripos($s->get_hardware(), $query) !== false) {
                     array_push($matches, $file);
                     $matched = true;
                     break;
                 }
             }
             if ($matched) {
                 continue;
             }
         }
         if ($search == 'ALL' || $search == 'RESULTS') {
             $matched = false;
             $result_titles = array();
             foreach ($result_file->get_result_objects() as $result_object) {
                 $result_identifier = $result_object->test_profile->get_title();
                 if (stripos($result_identifier, $query) !== false) {
                     array_push($matches, $file);
                     $matched = true;
                     break;
                 }
             }
             if ($matched) {
                 continue;
             }
         }
     }
     return $matches;
 }
$stmt->bindValue(':account_id', ACCOUNT_ID);
$result = $stmt->execute();
$row = $result->fetchArray();
$upload_id = (isset($row['UploadID']) ? $row['UploadID'] : 0) + 1;
$upload_time = phoromatic_server::current_time();
$xml_upload_hash = sha1($composite_xml);
$stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_results (AccountID, SystemID, UploadID, ScheduleID, BenchmarkTicketID, Trigger, UploadTime, Title, Description, SystemCount, ResultCount, DisplayStatus, XmlUploadHash, ComparisonHash, ElapsedTime, PPRID) VALUES (:account_id, :system_id, :upload_id, :schedule_id, :benchmark_ticket_id, :trigger, :upload_time, :title, :description, :system_count, :result_count, :display_status, :xml_upload_hash, :comparison_hash, :elapsed_time, :pprid)');
$stmt->bindValue(':account_id', ACCOUNT_ID);
$stmt->bindValue(':system_id', SYSTEM_ID);
$stmt->bindValue(':upload_id', $upload_id);
$stmt->bindValue(':schedule_id', $SCHEDULE_ID);
$stmt->bindValue(':benchmark_ticket_id', $BENCHMARK_TICKET_ID);
$stmt->bindValue(':trigger', $TRIGGER_STRING);
$stmt->bindValue(':upload_time', $upload_time);
$stmt->bindValue(':title', sqlite_escape_string($result_file->get_title()));
$stmt->bindValue(':description', sqlite_escape_string($result_file->get_description()));
$stmt->bindValue(':system_count', $result_file->get_system_count());
$stmt->bindValue(':result_count', $result_file->get_test_count());
$stmt->bindValue(':display_status', 1);
$stmt->bindValue(':xml_upload_hash', $xml_upload_hash);
$stmt->bindValue(':comparison_hash', $result_file->get_contained_tests_hash(false));
$stmt->bindValue(':elapsed_time', empty($ELAPSED_TIME) || !is_numeric($ELAPSED_TIME) || $ELAPSED_TIME < 0 ? 0 : $ELAPSED_TIME);
$stmt->bindValue(':pprid', phoromatic_server::compute_pprid(ACCOUNT_ID, SYSTEM_ID, $upload_time, $xml_upload_hash));
$result = $stmt->execute();
//echo phoromatic_server::$db->lastErrorMsg();
$result_directory = phoromatic_server::phoromatic_account_result_path(ACCOUNT_ID, $upload_id);
pts_file_io::mkdir($result_directory);
//phoromatic_add_activity_stream_event('result', $upload_id, 'uploaded');
file_put_contents($result_directory . 'composite.xml', $composite_xml);
if ($SYSTEM_LOGS_ZIP != null && $SYSTEM_LOGS_HASH != null) {
    if (sha1($SYSTEM_LOGS_ZIP) == $SYSTEM_LOGS_HASH) {
 public static function search_test_results($query, $search = 'RESULTS')
 {
     $matches = array();
     foreach (self::test_results_by_date() as $file) {
         $result_file = new pts_result_file($file);
         if (($search == 'ALL' || $search == 'INFO') && (stripos($result_file->get_title(), $query) !== false || stripos($result_file->get_description(), $query) !== false)) {
             array_push($matches, $file);
             continue;
         }
         if ($search == 'ALL' || $search == 'SYSTEM_INFO') {
             $hw = $result_file->get_system_hardware();
             $sw = $result_file->get_system_software();
             $ids = $result_file->get_system_identifiers();
             $matched = false;
             for ($i = 0; $i < count($ids); $i++) {
                 if (stripos($sw[$i], $query) !== false || stripos($ids[$i], $query) !== false || stripos($hw[$i], $query) !== false) {
                     array_push($matches, $file);
                     $matched = true;
                     break;
                 }
             }
             if ($matched) {
                 continue;
             }
         }
         if ($search == 'ALL' || $search == 'RESULTS') {
             $matched = false;
             foreach ($result_file->get_result_identifiers() as $result_identifier) {
                 if (stripos($result_identifier, $query) !== false) {
                     array_push($matches, $file);
                     $matched = true;
                     break;
                 }
             }
             if ($matched) {
                 continue;
             }
         }
     }
     return $matches;
 }
 $attributes = array('new_result_file_title' => $result_file_title);
 $result_file = new pts_result_file(null, true);
 $result_file->merge($result_files, $attributes);
 $extra_attributes = array();
 $attribute_options = array('normalize_results' => 'normalize_result_buffer', 'sort_by_performance' => 'sort_result_buffer_values', 'sort_by_reverse' => 'reverse_result_buffer', 'sort_by_name' => 'sort_result_buffer', 'condense_comparison' => 'condense_multi_way');
 foreach ($attribute_options as $web_var => $attr_var) {
     if (isset($_REQUEST[$web_var])) {
         $extra_attributes[$attr_var] = true;
     }
 }
 if (isset($_POST['transpose_comparison'])) {
     $result_file->invert_multi_way_invert();
 }
 $intent = null;
 $main .= '<h1>' . $result_file->get_title() . '</h1>';
 $main .= '<p>' . $result_file->get_description() . '</p>';
 $main .= phoromatic_annotate_entry('RESULT', implode(',', $result_ids), 'TOP');
 if ($result_file->get_system_count() == 1 || ($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true))) {
     $table = new pts_ResultFileCompactSystemsTable($result_file, $intent);
 } else {
     $table = new pts_ResultFileSystemsTable($result_file);
 }
 $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
 $table = new pts_ResultFileTable($result_file, $intent);
 $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
 $main .= '<div id="pts_results_area">';
 foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) {
     $main .= '<h2><a name="r-' . $i . '"></a><a name="' . $result_object->get_comparison_hash(true, false) . '"></a>' . $result_object->test_profile->get_title() . '</h2>';
     $main .= phoromatic_annotate_entry('RESULT', implode(',', $result_ids), $result_object->get_comparison_hash(true, false));
     $main .= '<p style="text-align: center; overflow: auto;">';
     $main .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);