Question

On my codeigniter project I am making a system check but for some reason three of my table sections below are showing my danger icon when should display success icon because the setting are show OK. But they not showing correct icon.

It is display every thing is correct just not showing correct icon

The three ones that are showing wrong icon is Register Globals:, Magic Quotes GPC:, Session Auto Start:

<table class="table table-bordered">
<thead>
<tr>
<th class="align_left">PHP Settings</th>
<th>Current Settings</th>
<th>Required Settings</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>PHP Version:</td>
<td class="align_center"><?php echo phpversion(); ?></td>
<td class="align_center">5.1.6+</td>
<td><?php echo phpversion() ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>
</tr>
<tr>
<td>Register Globals:</td>
<td class="align_center"><?php echo (ini_get('register_globals')) ? 'On' : 'Off'; ?></td>
<td class="align_center">Off</td>
<td><?php echo (ini_get('register_globals')) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>
</tr>
<tr>
<td>Magic Quotes GPC:</td>
<td class="align_center"><?php echo (ini_get('magic_quotes_gpc')) ? 'On' : 'Off'; ?></td>
<td class="align_center">Off</td>
<td><?php echo (ini_get('magic_quotes_gpc')) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>
</tr>
<tr>
<td>File Uploads:</td>
<td class="align_center"><?php echo (ini_get('file_uploads')) ? 'On' : 'Off'; ?></td>
<td class="align_center">On</td>
<td><?php echo (ini_get('file_uploads')) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>
</tr>
<tr>
<td>Session Auto Start:</td>
<td class="align_center"><?php echo (ini_get('session_auto_start')) ? 'On' : 'Off'; ?></td>
<td class="align_center">Off</td>
<td><?php echo (ini_get('session_auto_start')) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>
</tr>
</tbody>
</table>
Was it helpful?

Solution

Your code is functioning exactly as you tell it to. Take your Magic Quotes example:

<td>Magic Quotes GPC:</td>
<td class="align_center"><?php echo (ini_get('magic_quotes_gpc')) ? 'On' : 'Off'; ?></td>
<td class="align_center">Off</td>
<td><?php echo (ini_get('magic_quotes_gpc')) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?></td>

According to your question, this value needs to be OFF. So you want the success icon to show if this value is OFF. However, your shorthand IF statement will display the success icon if Magic Quotes are ON, and the danger icon if the magic quotes are OFF.

You either need to change the order of the results, or inverse the IF statement. For example,

<?php echo ( ini_get('magic_quotes_gpc') ) ? '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>' : '<span class="text-success"><i class="fa fa-check-circle"></i></span>'; ?>

OR

<?php echo ( ! ini_get('magic_quotes_gpc') ) ? '<span class="text-success"><i class="fa fa-check-circle"></i></span>' : '<span class="text-danger"><i class="fa fa-minus-circle"></i></span>'; ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top