Skip to content

Commit

Permalink
Add PHP info to report
Browse files Browse the repository at this point in the history
  • Loading branch information
timotei-litespeed committed Oct 17, 2024
1 parent db7fd73 commit 72bc352
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/report.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public function post_env()

$notes = !empty($_POST['notes']) ? esc_html($_POST['notes']) : '';

$php_info = !empty($_POST['attach_php']) ? esc_html($_POST['attach_php']) : '';
$report_php = ($php_info === '1') ? $this->generate_php_report() : '';

$data = array(
'env' => $report_con,
'link' => $link,
'notes' => $notes,
'php_info' => $report_php,
);

$json = Cloud::post(Cloud::API_REPORT, $data);
Expand All @@ -77,6 +81,24 @@ public function post_env()
return $num;
}

/**
* Gathers the PHP information.
*
* @since 7.0
* @access public
*/
public function generate_php_report($flags = INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES) // INFO_ENVIRONMENT
{
$report = '';

ob_start();
phpinfo($flags);
$report = ob_get_contents();
ob_end_clean();

return $report;
}

/**
* Gathers the environment details and creates the report.
* Will write to the environment report file.
Expand Down Expand Up @@ -128,7 +150,7 @@ public function generate_environment_report($options = null)
if (is_multisite()) {
$options2 = $this->get_options();
foreach ($options2 as $k => $v) {
if ($options[$k] !== $v) {
if (isset($options[$k]) && $options[$k] !== $v) {
$options['[Overwritten] ' . $k] = $v;
}
}
Expand Down
17 changes: 16 additions & 1 deletion tpl/toolbox/report.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@
<textarea id="litespeed-report" rows="20" cols="100" readonly><?php echo esc_textarea($report); ?></textarea>
</td>
</tr>
<tr>
<th>&nbsp;</th>
<td>
<?php
$this->build_checkbox(
'attach_php',
sprintf(
__('Attach PHP info to report. It will use data returned by function <a %s>phpinfo()</a>.', 'litespeed-cache'),
'href="https://www.php.net/manual/en/function.phpinfo.php" traget="__blank"'
),
false
);
?>
</td>
</tr>
<tr>
<th><?php echo __('Passwordless Link', 'litespeed-cache'); ?></th>
<td>
Expand Down Expand Up @@ -102,4 +117,4 @@
<p class="litespeed-top30 litespeed-left10 litespeed-desc">
<?php echo __('Send this report to LiteSpeed. Refer to this report number when posting in the WordPress support forum.', 'litespeed-cache'); ?>
</p>
</form>
</form>

0 comments on commit 72bc352

Please sign in to comment.