Best Phoronix-test-suite code snippet using pts_result_viewer_embed.html_template_log_viewer
pts_result_viewer_embed.php
Source:pts_result_viewer_embed.php  
...450		}451		$PAGE .= '</div>';452		return $PAGE;453	}454	public static function html_template_log_viewer($html_to_show, &$result_file)455	{456		return '<!doctype html>457		<html lang="en">458		<head><title>' . ($result_file ? $result_file->get_title() . ' ' : '') . 'Log Viewer</title>459		' . (defined('CSS_RESULT_VIEWER_PATH') ? '<link rel="stylesheet" href="' . CSS_RESULT_VIEWER_PATH . '">' : '') . '</head>460		<body>' . (empty($html_to_show) ? '<p>No logs available.</p>' : $html_to_show) . '</body></html>';461	}462	public static function display_log_html_or_download(&$log_contents, &$list_of_log_files, $log_selected, &$append_to_html, $title, $identifiers_with_logs = false)463	{464		$append_to_html .= '<h2 align="center">' . $title . ' Logs</h2>';465		if(empty($list_of_log_files) && $identifiers_with_logs && !empty($identifiers_with_logs))466		{467			$append_to_html = '[DEBUG] No log files were found for this system identifier (' . $title . '), but logs were found for: ' . implode(', ', $identifiers_with_logs);468		}469		$append_to_html .= '<div style="text-align: center;"><form action="' . str_replace('&log_select=' . $log_selected, '', str_replace('&download', '', $_SERVER['REQUEST_URI'])) . '" method="post">';470		$append_to_html .= '<input type="hidden" name="modify" value="0" /><select name="log_select" id="log_select" onchange="this.form.submit()">';471		foreach($list_of_log_files as $log_file)472		{473			$append_to_html .= '<option value="' . $log_file . '"' . (isset($_REQUEST['log_select']) && $log_file == $_REQUEST['log_select'] ? 'selected="selected"' : '') . '>' . $log_file . '</option>';474		}475		$append_to_html .= '</select>   <input type="submit" value="Show Log"></form></div><br /><hr />';476		$append_to_html .= '<p style="font-size: 12px; margin: 5px; text-align: right"><form action="' . $_SERVER['REQUEST_URI'] . '" method="post"><input type="hidden" name="download" value="download" /><input type="hidden" name="log_select" value="' . $log_selected . '" /><input type="submit" value="Download Log File" style="float: right;"> </form></p>';477		if($log_contents == null)478		{479			$append_to_html .= '<p>No log file available.</p>';480		}481		else if(pts_strings::is_text_string($log_contents) && !isset($_REQUEST['download']))482		{483			$log_contents = phodevi_vfs::cleanse_file($log_contents);484			$log_contents = htmlentities($log_contents);485			$log_contents = str_replace(PHP_EOL, '<br />', $log_contents);486			$append_to_html .= '<br /><pre style="font-family: monospace;">' . $log_contents . '</pre>';487		}488		else if(isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined') // to avoid blocking the popup window in first place if it wasn't explicitly selected489		{490			if(class_exists('finfo'))491			{492				$finfo = new finfo(FILEINFO_MIME);493				header('Content-type: '. $finfo->buffer($log_contents));494			}495			//header('Content-Type: application/octet-stream');496			header('Content-Length: ' . strlen($log_contents));497			header('Content-Disposition: attachment; filename="' . str_ireplace(array('/', '\\', '.'), '', $title) . ' - ' . $log_selected . '"');498			echo $log_contents;499			exit;500		}501		else502		{503			$append_to_html .= '<p>Download log file to view.</p>';504		}505	}506	public static function get_html_sort_bar(&$result_file, &$request)507	{508		$analyze_options = null;509		$drop_down_menus = array('Export Benchmark Data' => array(510						'export=pdf' => 'Result File To PDF',511						'export=txt' => 'Result File To Text',512						'export=html' => 'Result File To HTML',513						'export=json' => 'Result File To JSON',514					//	'export=xml' => 'Result File To XML',515						'export=xml-suite' => 'Result File To Test Suite (XML)',516						'export=csv' => 'Result File To CSV/Excel',517						'export=csv-all' => 'Individual Run Data To CSV/Excel',518						),519					);520		if(count($result_file->get_system_identifiers()) > 1)521		{522			$drop_down_menus['Sort Result Order'] = array(523				'sro&rro' => 'By Identifier (DESC)',524				'sro' => 'By Identifier (ASC)',525				'sor' => 'By Performance (DESC)',526				'sor&rro' => 'By Performance (ASC)',527				'rdt&rro' => 'By Run Date/Time (DESC)',528				'rdt' => 'By Run Date/Time (ASC)',529				);530		}531		if($result_file->get_test_count() > 1)532		{533			$drop_down_menus['Sort Graph Order'] = array(534				'grs' => 'By Result Spread',535				'gru' => 'By Result Unit',536				'grt' => 'By Test Title',537				'grr' => 'By Test Length/Time'538				);539		}540		$analyze_options .= '<div style="float: right;"><ul>';541		foreach(array_reverse($drop_down_menus, true) as $menu => $sub_menu)542		{543			$analyze_options .= '<li><a href="#">' . $menu . '</a><ul>';544			foreach($sub_menu as $option => $txt)545			{546				$uri = $_SERVER['REQUEST_URI'];547				foreach(array_reverse(array_keys($sub_menu)) as $rem)548				{549					$uri = str_replace('&' . $rem, '', $uri);550				}551				$uri = str_replace('&rro', '', $uri);552				$analyze_options .= '<li><a href="' . $uri . '&' . $option . '">' . $txt . '</a></li>';553			}554			$analyze_options .= '</ul></li>';555		}556		$analyze_options .= '</ul></div>';557		return $analyze_options;558	}559	public static function get_html_options_markup(&$result_file, &$request, $public_id = null, $can_delete_results = false)560	{561		if($public_id == null && defined('RESULTS_VIEWING_ID'))562		{563			$public_id = RESULTS_VIEWING_ID;564		}565		$analyze_options = null;566		// CHECKS FOR DETERMINING OPTIONS TO DISPLAY567		$has_identifier_with_color_brand = false;568		$has_box_plot = false;569		$has_line_graph = false;570		$is_multi_way = $result_file->is_multi_way_comparison();571		$system_count = $result_file->get_system_count();572		foreach($result_file->get_system_identifiers() as $sys)573		{574			if(pts_render::identifier_to_brand_color($sys, null) != null)575			{576				$has_identifier_with_color_brand = true;577				break;578			}579		}580		$multi_test_run_options_tracking = array();581		$tests_with_multiple_versions = array();582		$has_test_with_multiple_options = false;583		$has_test_with_multiple_versions = false;584		foreach($result_file->get_result_objects() as $i => $result_object)585		{586			if(!$has_box_plot && $result_object->test_profile->get_display_format() == 'HORIZONTAL_BOX_PLOT')587			{588				$has_box_plot = true;589			}590			if(!$has_line_graph && $result_object->test_profile->get_display_format() == 'LINE_GRAPH')591			{592				$has_line_graph = true;593			}594			if(!$is_multi_way && !$has_test_with_multiple_options)595			{596				if(!isset($multi_test_run_options_tracking[$result_object->test_profile->get_identifier()]))597				{598					$multi_test_run_options_tracking[$result_object->test_profile->get_identifier()] = array();599				}600				$multi_test_run_options_tracking[$result_object->test_profile->get_identifier()][] = $result_object->get_arguments_description();601				if(count($multi_test_run_options_tracking[$result_object->test_profile->get_identifier()]) > 1)602				{603					$has_test_with_multiple_options = true;604					unset($multi_test_run_options_tracking);605				}606			}607			if(!$is_multi_way && !$has_test_with_multiple_versions)608			{609				$ti_no_version = $result_object->test_profile->get_identifier(false);610				if(!isset($tests_with_multiple_versions[$ti_no_version]))611				{612					$tests_with_multiple_versions[$ti_no_version] = array();613				}614				pts_arrays::unique_push($tests_with_multiple_versions[$ti_no_version], $result_object->test_profile->get_app_version());615				if(count($tests_with_multiple_versions[$ti_no_version]) > 1)616				{617					$has_test_with_multiple_versions = true;618					unset($tests_with_multiple_versions);619				}620			}621			// (optimization) if it has everything, break622			if($has_line_graph && $has_box_plot && $has_test_with_multiple_options && $has_test_with_multiple_versions)623			{624				break;625			}626		}627		$suites_in_result_file = $system_count > 1 ? pts_test_suites::suites_in_result_file($result_file, true, 0) : array();628		// END OF CHECKS629		$analyze_options .= '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">';630		$analyze_checkboxes = array(631			'View' => array(),632			'Statistics' => array(),633			'Sorting' => array(),634			'Graph Settings' => array(),635			'Additional Graphs' => array(),636			'Multi-Way Comparison' => array(),637			);638		if($system_count > 1)639		{640			$analyze_checkboxes['Statistics'][] = array('shm', 'Show Overall Harmonic Mean(s)');641			$analyze_checkboxes['Statistics'][] = array('sgm', 'Show Overall Geometric Mean');642			if(count($suites_in_result_file) > 1)643			{644				$analyze_checkboxes['Statistics'][] = array('sts', 'Show Geometric Means Per-Suite/Category');645			}646			$analyze_checkboxes['Statistics'][] = array('swl', 'Show Wins / Losses Counts (Pie Chart)');647			$analyze_checkboxes['Statistics'][] = array('nor', 'Normalize Results');648			$analyze_checkboxes['Graph Settings'][] = array('ftr', 'Force Line Graphs Where Applicable');649			$analyze_checkboxes['Graph Settings'][] = array('scalar', 'Convert To Scalar Where Applicable');650			$analyze_checkboxes['View'][] = array('hnr', 'Do Not Show Noisy Results');651			$analyze_checkboxes['View'][] = array('hni', 'Do Not Show Results With Incomplete Data');652			$analyze_checkboxes['View'][] = array('hlc', 'Do Not Show Results With Little Change/Spread');653			$analyze_checkboxes['View'][] = array('spr', 'List Notable Results');654			if($has_identifier_with_color_brand)655			{656				$analyze_checkboxes['Graph Settings'][] = array('ncb', 'Disable Color Branding');657			}658			// Additional Graphs659			if(!$result_file->is_multi_way_comparison())660			{661				$identifier_mapping_to_cores = array();662				$identifier_mapping_to_threads = array();663				$identifier_mapping_to_cpu_clock = array();664				$identifier_mapping_to_ram_channels = array();665				foreach($result_file->get_systems() as $system)666				{667					$t = $system->get_cpu_core_count();668					if($t > 0)669					{670						$identifier_mapping_to_cores[$system->get_identifier()] = $t;671					}672					$t = $system->get_cpu_thread_count();673					if($t > 0)674					{675						$identifier_mapping_to_threads[$system->get_identifier()] = $t;676					}677					$t = $system->get_cpu_clock();678					if($t > 0)679					{680						$identifier_mapping_to_cpu_clock[$system->get_identifier()] = $t;681					}682					$t = $system->get_memory_channels();683					if($t > 0)684					{685						$identifier_mapping_to_ram_channels[$system->get_identifier()] = $t;686					}687				}688				if(count(array_unique($identifier_mapping_to_cores)) > 1 || count(array_unique($identifier_mapping_to_threads)) > 1)689				{690					$analyze_checkboxes['Additional Graphs'][] = array('sppt', 'Show Perf Per Core/Thread Calculation Graphs Where Applicable');691				}692				if(count(array_unique($identifier_mapping_to_cpu_clock)) > 1)693				{694					$analyze_checkboxes['Additional Graphs'][] = array('sppc', 'Show Perf Per Clock Calculation Graphs Where Applicable');695				}696				if(count(array_unique($identifier_mapping_to_ram_channels)) > 1)697				{698					$analyze_checkboxes['Additional Graphs'][] = array('sppm', 'Show Perf Per RAM Channel Calculation Graphs Where Applicable');699				}700			}701		}702		if(count($suites_in_result_file) > 1)703		{704			$suite_limit = '<h3>Limit displaying results to tests within:</h3>';705			$stis = self::check_request_for_var($request, 'stis');706			if(!is_array($stis))707			{708				$stis = explode(',', $stis);709			}710			ksort($suites_in_result_file);711			$suite_limit .= '<div style="max-height: 250px; overflow: scroll;">';712			foreach($suites_in_result_file as $suite_identifier => $s)713			{714				list($suite, $contained_tests) = $s;715				$id = rtrim(base64_encode($suite_identifier), '=');716				$suite_limit .= '<input type="checkbox" name="stis[]" value="' . $id . '"' . (is_array($stis) && in_array($id, $stis) ? ' checked="checked"' : null) . ' /> ' . $suite->get_title() . ' <sup><em>' . count($contained_tests) . ' Tests</em></sup><br />';717			}718			$suite_limit .= '</div>';719			$analyze_checkboxes['View'][] = array('', $suite_limit);720		}721		$analyze_checkboxes['Graph Settings'][] = array('vb', 'Prefer Vertical Bar Graphs');722		$analyze_checkboxes['Statistics'][] = array('rol', 'Remove Outliers Before Calculating Averages');723		//$analyze_checkboxes['Statistics'][] = array('gtb', 'Graph Values Of All Runs (Box Plot)');724		//$analyze_checkboxes['Statistics'][] = array('gtl', 'Graph Values Of All Runs (Line Graph)');725		if($has_box_plot || $has_line_graph)726		{727			$analyze_checkboxes['Graph Settings'][] = array('nbp', 'No Box Plots');728		}729		if($is_multi_way && $system_count > 1)730		{731			$analyze_checkboxes['Multi-Way Comparison'][] = array('cmw', 'Condense Comparison');732		}733		if(($is_multi_way && $system_count > 1) || self::check_request_for_var($request, 'cmv') || self::check_request_for_var($request, 'cts'))734		{735			$analyze_checkboxes['Multi-Way Comparison'][] = array('imw', 'Transpose Comparison');736		}737		if((!$is_multi_way && $has_test_with_multiple_options && !self::check_request_for_var($request, 'cmv')) || self::check_request_for_var($request, 'cts'))738		{739			$analyze_checkboxes['Multi-Way Comparison'][] = array('cts', 'Condense Multi-Option Tests Into Single Result Graphs');740		}741		if((!$is_multi_way && $has_test_with_multiple_versions && !self::check_request_for_var($request, 'cts')) || self::check_request_for_var($request, 'cmv'))742		{743			$analyze_checkboxes['Multi-Way Comparison'][] = array('cmv', 'Condense Test Profiles With Multiple Version Results Into Single Result Graphs');744		}745		$analyze_checkboxes['Table'][] = array('sdt', 'Show Detailed System Result Table');746		$t = null;747		foreach($analyze_checkboxes as $title => $group)748		{749			if(empty($group))750			{751				continue;752			}753			$t .= '<div class="pts_result_viewer_settings_box">';754			$t .= '<h2>' . $title . '</h2>';755			foreach($group as $key)756			{757				if($key[0] == null)758				{759					$t .= $key[1] . '<br />';760				}761				else762				{763					$t .= '<input type="checkbox" name="' . $key[0] . '" value="1"' . (self::check_request_for_var($request, $key[0]) ? ' checked="checked"' : null) . ' /> ' . $key[1] . '<br />';764				}765			}766			$t .= '</div>';767		}768		if($system_count > 0)769		{770			$has_system_logs = $result_file->system_logs_available();771			$t .= '<div style="clear: both;"><h2>Run Management</h2>772			<div class="div_table">773			<div class="div_table_body">774			<div class="div_table_first_row">';775			if($system_count > 1)776			{777				$t .= '<div class="div_table_cell">Highlight<br />Result</div>778			<div class="div_table_cell">Hide<br />Result</div>';779			}780			$t .= '<div class="div_table_cell">Result<br />Identifier</div>';781			if($has_system_logs)782			{783				$t .= '<div class="div_table_cell">View Logs</div>';784			}785			$t .= '<div class="div_table_cell">Performance Per<br />Dollar</div>786			<div class="div_table_cell">Date<br />Run</div>787			<div class="div_table_cell">   Test<br />   Duration</div>788			<div class="div_table_cell"> </div>789			</div>790			';791			$hgv = self::check_request_for_var($request, 'hgv');792			if(!is_array($hgv))793			{794				$hgv = explode(',', $hgv);795			}796			$rmm = self::check_request_for_var($request, 'rmm');797			if(!is_array($rmm))798			{799				$rmm = explode(',', $rmm);800			}801			$start_of_year = strtotime(date('Y-01-01'));802			$test_run_times = $result_file->get_test_run_times();803			foreach($result_file->get_systems() as $sys)804			{805				$si = $sys->get_identifier();806				$ppdx = rtrim(base64_encode($si), '=');807				$ppd = self::check_request_for_var($request, 'ppd_' . $ppdx);808			$t .= '809				<div id="table-line-' . $ppdx . '" class="div_table_row">';810				if($system_count > 1)811				{812					$t .= '<div class="div_table_cell"><input type="checkbox" name="hgv[]" value="' . $si . '"' . (is_array($hgv) && in_array($si, $hgv) ? ' checked="checked"' : null) . ' /></div>813				<div class="div_table_cell"><input type="checkbox" name="rmm[]" value="' . $si . '"' . (is_array($rmm) && in_array($si, $rmm) ? ' checked="checked"' : null) . ' /></div>';814				}815				$t .= '<div class="div_table_cell"><strong>' . $si . '</strong></div>';816				if($has_system_logs)817				{818					$t .= '<div class="div_table_cell">' . ($system_count == 1 || $sys->has_log_files() ? '<button type="button" onclick="javascript:display_system_logs_for_result(\'' . $public_id . '\', \'' . $sys->get_original_identifier() . '\'); return false;">View System Logs</button>' : ' ') . '</div>';819				}820				$stime = strtotime($sys->get_timestamp());821				$t .= '<div class="div_table_cell"><input type="number" min="0" step="0.001" name="ppd_' . $ppdx . '" value="' . ($ppd && $ppd !== true ? strip_tags($ppd) : '0') . '" /></div>822			<div class="div_table_cell">' . date(($stime > $start_of_year ? 'F d' : 'F d Y'), $stime) . '</div>823			<div class="div_table_cell">   ' . (isset($test_run_times[$si]) && $test_run_times[$si] > 0 ? pts_strings::format_time($test_run_times[$si], 'SECONDS', true, 60) : ' ') . '</div>';824				if($can_delete_results && !empty($public_id))825				{826					$t .= '<div class="div_table_cell">';827					if($system_count > 1)828					{829						$t .= '<button type="button" onclick="javascript:delete_run_from_result_file(\'' . $public_id . '\', \'' . $si . '\', \'' . $ppdx . '\'); return false;">Delete Run</button> ';830					}831					$t .= '<button type="button" onclick="javascript:rename_run_in_result_file(\'' . $public_id . '\', \'' . $si . '\'); return false;">Rename Run</button></div>';832				}833				$t .= '</div>';834			}835			if($system_count > 1)836			{837				$t .= '838				<div class="div_table_row">839				<div class="div_table_cell"> </div>840				<div class="div_table_cell"><input type="checkbox" onclick="javascript:invert_hide_all_results_checkboxes();" /></div>841				<div class="div_table_cell"><em>Invert Hiding All Results Option</em></div>';842				if($has_system_logs)843				{844					$t .= '<div class="div_table_cell"> </div>';845				}846				$t .= '<div class="div_table_cell">' . self::html_select_menu('ppt', 'ppt', null, array('D' => 'Dollar', 'DPH' => 'Dollar / Hour'), true) . '</div>847				<div class="div_table_cell"> </div>848				<div class="div_table_cell">   <em>' . pts_strings::format_time(array_sum($test_run_times) / count($test_run_times), 'SECONDS', true, 60) . '</em></div>849				<div class="div_table_cell">';850				if($can_delete_results)851				{852					$t .= '<button type="button" onclick="javascript:reorder_result_file(\'' . $public_id . '\'); return false;">Sort / Reorder Runs</button>';853				}854				$t .= '</div></div>';855			}856			$t .= '857			</div>858			</div></div>';859		}860		$analyze_options .= $t;861		if($system_count > 2)862		{863			$analyze_options .= '<br /><div>Only show results where ' . self::html_select_menu('ftt', 'ftt', null, array_merge(array(null), $result_file->get_system_identifiers()), false) . ' is faster than ' . self::html_select_menu('ftb', 'ftb', null, array_merge(array(null), $result_file->get_system_identifiers()), false) . '</div>';864		}865		if($result_file->get_test_count() > 1)866		{867			$analyze_options .= '<div>Only show results matching title/arguments (delimit multiple options with a comma): ' . self::html_input_field('oss', 'oss') . '</div>';868		}869		$analyze_options .= '<br /><input style="clear: both;" name="submit" value="Refresh Results" type="submit" /></form>';870		return $analyze_options;871	}872	public static function process_result_export_pre_render(&$request, &$result_file, &$extra_attributes, $can_modify_results = false, $can_delete_results = false)873	{874		if(self::check_request_for_var($request, 'rdt'))875		{876			$result_file->reorder_runs($result_file->get_system_identifiers_by_date());877		}878		// Result export?879		$result_title = (isset($_GET['result']) ? $_GET['result'] : 'result');880		switch(isset($_REQUEST['export']) ? $_REQUEST['export'] : '')881		{882			case '':883				break;884			case 'pdf':885				header('Content-Type: application/pdf');886				$pdf_output = pts_result_file_output::result_file_to_pdf($result_file, $result_title . '.pdf', 'D', $extra_attributes);887				exit;888			case 'html':889				$referral_url = '';890				if(defined('OPENBENCHMARKING_BUILD'))891				{892					$referral_url = 'https://openbenchmarking.org' . str_replace('&export=html', '', $_SERVER['REQUEST_URI']);893				}894				echo pts_result_file_output::result_file_to_html($result_file, $extra_attributes, $referral_url);895				exit;896			case 'json':897				header('Content-Type: application/json');898				echo pts_result_file_output::result_file_to_json($result_file);899				exit;900			case 'csv':901				$result_csv = pts_result_file_output::result_file_to_csv($result_file, ',', $extra_attributes);902				header('Content-Description: File Transfer');903				header('Content-Type: application/csv');904				header('Content-Disposition: attachment; filename=' . $result_title . '.csv');905				header('Expires: 0');906				header('Cache-Control: must-revalidate');907				header('Pragma: public');908				header('Content-Length: ' . strlen($result_csv));909				echo $result_csv;910				exit;911			case 'csv-all':912				$result_csv = pts_result_file_output::result_file_raw_to_csv($result_file);913				header('Content-Description: File Transfer');914				header('Content-Type: application/csv');915				header('Content-Disposition: attachment; filename=' . $result_title . '.csv');916				header('Expires: 0');917				header('Cache-Control: must-revalidate');918				header('Pragma: public');919				header('Content-Length: ' . strlen($result_csv));920				echo $result_csv;921				exit;922			case 'txt':923				$result_txt = pts_result_file_output::result_file_to_text($result_file);924				header('Content-Description: File Transfer');925				header('Content-Type: text/plain');926				header('Content-Disposition: attachment; filename=' . $result_title . '.txt');927				header('Expires: 0');928				header('Cache-Control: must-revalidate');929				header('Pragma: public');930				header('Content-Length: ' . strlen($result_txt));931				echo $result_txt;932				exit;933			case 'xml-suite':934				$suite_xml = pts_result_file_output::result_file_to_suite_xml($result_file);935				header('Content-Description: File Transfer');936				header('Content-Type: text/xml');937				header('Content-Disposition: attachment; filename=' . $result_title . '-suite.xml');938				header('Expires: 0');939				header('Cache-Control: must-revalidate');940				header('Pragma: public');941				header('Content-Length: ' . strlen($suite_xml));942				echo $suite_xml;943				exit;944			case 'xml':945				$result_xml = $result_file->get_xml(null, true);946				header('Content-Description: File Transfer');947				header('Content-Type: text/xml');948				header('Content-Disposition: attachment; filename=' . $result_title . '.xml');949				header('Expires: 0');950				header('Cache-Control: must-revalidate');951				header('Pragma: public');952				header('Content-Length: ' . strlen($result_xml));953				echo $result_xml;954				exit;955			case 'view_system_logs':956				$html_viewer = '';957				foreach($result_file->get_systems() as $system)958				{959					$sid = base64_decode($_REQUEST['system_id']);960					if($system->get_original_identifier() == $sid || $system->get_identifier() == $sid)961					{962						$system_logs = $system->log_files();963						$identifiers_with_logs = empty($system_logs) ? $result_file->identifiers_with_system_logs() : array();964						$show_log = isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined' && $_REQUEST['log_select'] != null ? $_REQUEST['log_select'] : (isset($system_logs[0]) ? $system_logs[0] : '');965						$log_contents = $system->log_files($show_log, false);966						pts_result_viewer_embed::display_log_html_or_download($log_contents, $system_logs, $show_log, $html_viewer, $sid, $identifiers_with_logs);967						break;968					}969				}970				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);971				exit;972			case 'view_install_logs':973				$html_viewer = '';974				if(isset($_REQUEST['result_object']))975				{976					if(($result_object = $result_file->get_result_object_by_hash($_REQUEST['result_object'])))977					{978						$install_logs = $result_file->get_install_log_for_test($result_object->test_profile, false);979						if(count($install_logs) > 0)980						{981							$show_log = isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined' ? $_REQUEST['log_select'] : (isset($install_logs[0]) ? $install_logs[0] : '');982							$log_contents = $result_file->get_install_log_for_test($result_object->test_profile, $show_log, false);983							pts_result_viewer_embed::display_log_html_or_download($log_contents, $install_logs, $show_log, $html_viewer, $result_object->test_profile->get_title() . ' Installation');984						}985					}986				}987				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);988				exit;989			case 'view_test_logs':990				$html_viewer = '';991				if(isset($_REQUEST['result_object']))992				{993					if(($result_object = $result_file->get_result_object_by_hash($_REQUEST['result_object'])))994					{995						if(($test_logs = $result_file->get_test_run_log_for_result($result_object, false)))996						{997							$show_log = isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined' ? $_REQUEST['log_select'] : (isset($test_logs[0]) ? $test_logs[0] : '');998							$log_contents = $result_file->get_test_run_log_for_result($result_object, $show_log, false);999							pts_result_viewer_embed::display_log_html_or_download($log_contents, $test_logs, $show_log, $html_viewer, trim($result_object->test_profile->get_title() . ' ' . $result_object->get_arguments_description()));1000						}1001					}1002				}1003				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);1004				exit;1005		}1006	}1007	public static function process_result_modify_pre_render(&$result_file, $can_modify_results = false, $can_delete_results = false)1008	{1009		if(!isset($_REQUEST['modify']) || ($can_modify_results == false && $can_delete_results == false))1010		{1011			return;1012		}1013		switch($_REQUEST['modify'])1014		{1015			case 'update-result-file-meta':1016				if($can_modify_results && isset($_REQUEST['result_title']) && isset($_REQUEST['result_desc']))1017				{...pts_result_viewer_settings.php
Source:pts_result_viewer_settings.php  
...412						pts_result_viewer_embed::display_log_html_or_download($log_contents, $system_logs, $show_log, $html_viewer, $sid);413						break;414					}415				}416				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);417				exit;418			case 'view_install_logs':419				$html_viewer = '';420				if(isset($_REQUEST['result_object']))421				{422					if(($result_object = $result_file->get_result_object_by_hash($_REQUEST['result_object'])))423					{424						$install_logs = $result_file->get_install_log_for_test($result_object->test_profile, false);425						if(count($install_logs) > 0)426						{427							$show_log = isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined' ? $_REQUEST['log_select'] : (isset($install_logs[0]) ? $install_logs[0] : '');428							$log_contents = $result_file->get_install_log_for_test($result_object->test_profile, $show_log, false);429							pts_result_viewer_embed::display_log_html_or_download($log_contents, $install_logs, $show_log, $html_viewer, $result_object->test_profile->get_title() . ' Installation');430						}431					}432				}433				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);434				exit;435			case 'view_test_logs':436				$html_viewer = '';437				if(isset($_REQUEST['result_object']))438				{439					if(($result_object = $result_file->get_result_object_by_hash($_REQUEST['result_object'])))440					{441						if(($test_logs = $result_file->get_test_run_log_for_result($result_object, false)))442						{443							$show_log = isset($_REQUEST['log_select']) && $_REQUEST['log_select'] != 'undefined' ? $_REQUEST['log_select'] : (isset($test_logs[0]) ? $test_logs[0] : '');444							$log_contents = $result_file->get_test_run_log_for_result($result_object, $show_log, false);445							pts_result_viewer_embed::display_log_html_or_download($log_contents, $test_logs, $show_log, $html_viewer, trim($result_object->test_profile->get_title() . ' ' . $result_object->get_arguments_description()));446						}447					}448				}449				echo pts_result_viewer_embed::html_template_log_viewer($html_viewer, $result_file);450				exit;451		}452		// End result export453	}454	public static function process_helper_html(&$request, &$result_file, &$extra_attributes)455	{456		self::process_result_export_pre_render($request, $result_file, $extra_attributes);457		$html = null;458		if(self::check_request_for_var($request, 'spr'))459		{460			$results = $result_file->get_result_objects();461			$spreads = array();462			foreach($results as $i => &$result_object)463			{...html_template_log_viewer
Using AI Code Generation
1require_once('pts_result_viewer_embed.php');2$viewer = new pts_result_viewer_embed();3$viewer->html_template_log_viewer('2.log');4$fp = fopen('2.log', 'w');5fwrite($fp, 'This is a log file');6fclose($fp);7require_once('pts_result_viewer_embed.php');8$viewer = new pts_result_viewer_embed();9$viewer->html_template_log_viewer('3.log');10$fp = fopen('3.log', 'w');11fwrite($fp, 'This is a log file');12fclose($fp);13require_once('pts_result_viewer_embed.php');14$viewer = new pts_result_viewer_embed();15$viewer->html_template_log_viewer('4.log');16$fp = fopen('4.log', 'w');17fwrite($fp, 'This is a log file');18fclose($fp);19require_once('pts_result_viewer_embed.php');20$viewer = new pts_result_viewer_embed();21$viewer->html_template_log_viewer('5.log');22$fp = fopen('5.log', 'w');23fwrite($fp, 'This is a log file');24fclose($fp);25require_once('pts_result_viewer_embed.php');26$viewer = new pts_result_viewer_embed();27$viewer->html_template_log_viewer('6.log');html_template_log_viewer
Using AI Code Generation
1require_once 'pts_result_viewer_embed.php';2$embed = new pts_result_viewer_embed();3$embed->html_template_log_viewer($_GET['log']);4public function html_template_log_viewer($log_file)5{6	$log = file_get_contents($log_file);7	$log = str_replace('8', $log);9	$log = str_replace(' ', ' ', $log);10	$log = str_replace("\t", '    ', $log);11	$log = str_replace('12', $log);13	echo $log;14}html_template_log_viewer
Using AI Code Generation
1require_once('pts_result_viewer_embed.php');2$pts_result_viewer_embed = new pts_result_viewer_embed();3$pts_result_viewer_embed->html_template_log_viewer();4require_once('pts_result_viewer_embed.php');5$pts_result_viewer_embed = new pts_result_viewer_embed();6$pts_result_viewer_embed->html_template_result_viewer();7require_once('pts_result_viewer_embed.php');8$pts_result_viewer_embed = new pts_result_viewer_embed();9$pts_result_viewer_embed->html_template_result_viewer();10require_once('pts_result_viewer_embed.php');html_template_log_viewer
Using AI Code Generation
1require 'pts_result_viewer_embed.php';2pts_result_viewer_embed::html_template_log_viewer($_GET['log']);3require 'pts_result_file_analyzer.php';4$analyzer = new pts_result_file_analyzer($_GET['result']);5$log_file = $analyzer->get_log_file_name();6header('Location: 2.php?log=' . $log_file);Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with html_template_log_viewer on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!
