Web App Explained By Page In Each Card

Page: ADA Testing Scripts
Missing ALT Text Attribute
scan_results.php Script Function Explained

File Name: scan_results.php
This code is written in PHP and performs a scanning operation on a specified folder for HTML files. It checks each HTML file in the folder for any <img> tags that do not have an alt attribute. It then generates a report of the scanned files and the issues found.
Here is a step-by-step explanation of the code:
1.  The code starts with some error reporting settings to display any errors that occur during execution.
2.  The value of the folder parameter is retrieved from the URL query string using $_GET['folder']. The ?? operator is used to provide a default value of an empty string if the folder parameter is not present. This parameter represents the folder that needs to be scanned.
3.  A block of code is used for debugging purposes, marked with comments "Debugging code block ---- START --- 1" and "Debugging code block ---- END --- 1". This block checks if the specified folder exists, is a directory, and is readable. If any of these conditions are not met, it outputs an error message and stops the execution.
4.  The glob() function is used to find all the HTML files (*.html) in the specified folder. The result is an array of file names.
5.  The array of file names is converted to a JSON string using the json_encode() function. This JSON string will be used later to print the list of files to the browser console using JavaScript.
6.  The list of files is printed to the browser console using an echo statement with a JavaScript code embedded in HTML. The JavaScript code logs the list of files to the console using console.log().
7.  A variable $results and $totalFilesScanned are initialized. $results will hold information about the files with missing alt attributes, and $totalFileScanned will store the count of total files scanned.
8.  The code checks if the folder parameter is not empty and is a directory using is_dir(). If the condition is true, it proceeds to scan the HTML files in the folder.
9.  Inside the loop, each HTML file is read using file_get_contents(), and the content is stored in the $content variable.
10.   The preg_match_all() function is used with a regular expression (/<img[^>]*>/i) to find all the <img> tags in the HTML content. The result is stored in the $matches array.
11.   A loop is used to iterate over the $matches[0] array, which contains all the <img> tags found in the HTML.
12.   For each <img> tag, it checks if there is no alt attribute present by using strpos() to find the position of "alt="
13.   in the tag. If the alt attribute is not found, it adds the whole <img> tag to the $issues array.If the $issues array is not empty, it means there are missing alt attributes. In that case, it creates an associative array with the file name (basename($file)), the count of issues (count($issues)), and the extracted code (implode('<br>', $issues)). This array is then added to the $results array.
14.   The HTML content for the scan results is generated using output buffering and HTML markup. The $totalFilesScanned variable is included to display the total number of files scanned.
15.   The $results array is iterated over using a foreach loop to display the file name, issue count, and extracted code in a table.
16.   Some JavaScript and CSS dependencies are included using <script> and <link> tags to enhance the functionality and styling of the page.
17.   Another JavaScript code block is included to load the navigation and highlight the active menu item based on the current page. It fetches the navigation HTML from /navigation.html and inserts it into the designated container.
18.   The HTML content, including the scan results and navigation, is printed to the browser.
19.   The generated HTML content is then saved to a file using file_put_contents(). The file name is generated using the current date and time.
20.   Finally, the user is redirected to the newly created page using the header() function and the Location header. The exit statement is used to stop further execution after the redirection.


Page: Update "PHP.ini"
Open the toggle to view the steps required to update the php.ini file.

Find what version of PHP the system is using

php -v

Find where the php.ini file is located

php

Find what version of PHP is being used in the virtual host

Step 1: Create a webpage called "info.php" and paste the following code.


<?php
phpinfo();
?>

then go to this webpage: https://example.com/info.php


Restart Apache2 after modifying PHP.ini

sudo service apache2 restart


Fix PHP unable to Write File To Folder
Fix PHP permission issue with not being able to write output to specified folder

If your PHP script is not able to create or not creating a file in the desired folder.


run the following permission scripts

sudo chown -R www-data:www-data /path/to/folder-for-php/write-file-folder/

also ensure the folder is set to 755 permissions by using the script below

sudo chmod 775 /path/to/folder-for-php/write-file-folder/

Fix PHP unable to Write File To Folder
Give PHP correct file writing permissions.

Fix PHP permission issue with not being able to write output to specified folder If your PHP script is not able to create or not creating a file in the desired folder. run the following permission scripts

run the following permission scripts

sudo chown -R www-data:www-data /path/to/folder-for-php/write-file-folder/

also ensure the folder is set to 755 permissions by using the script below

sudo chmod 775 /path/to/folder-for-php/write-file-folder/

Create a new webpage called "info.php" and paste the contents below inside.


                    <?php
                    phpinfo();
                    ?>
                    

Then open it in your browser at "https://example.com/info.php"


Tutorial Videos
All Final Training Videos For Lighthouse Web App

Explain the script & requirments.


Flow Chart
Lighthouse Web App User Flow Chart

This flow chart shows the users flow through the Lighthouse Web App; and explains some functionality componets of the tool.

View Flow Chart

Flow Chart
Lighthouse Web App - ADA Issue Analysis Testing Results TEMPLATES
get folders file
index.html
scan results page template

Log Web App Updates
Lighthouse Web App New Features Form
Go To: New Feature Logging Form